PlatONEnterprise / PlatONE-Go

PlatONE client implemented by golang
GNU Lesser General Public License v3.0
104 stars 49 forks source link

无法添加防火墙规则 #44

Open luoyele opened 3 years ago

luoyele commented 3 years ago

添加防火墙规则

允许任意地址的账户访问合约的getName方法,以及地址为0xabcd的账户访问setName

./../bin/ctool fwInvoke --addr "0xcb5c24289183005caeb929634b56c4ff69c33a96" --func '__sys_FwAdd("Accept","*:getName|0xabcd:setName")' --config config.json

允许地址为0xabcd的账户访问合约的setName方法

./../bin/ctool fwInvoke --addr "0xcb5c24289183005caeb929634b56c4ff69c33a96" --func '__sys_FwAdd("Accept","0xabcd:setName")' --config config.json

拒绝地址为0xabcd的账户访问合约的setName方法

./../bin/ctool fwInvoke --addr "0xcb5c24289183005caeb929634b56c4ff69c33a96" --func '__sys_FwAdd("Reject","0xabcd:setName")' --config config.json

防火墙状态查询 ./../bin/ctool fwInvoke --addr "0xcb5c24289183005caeb929634b56c4ff69c33a96" --func '__sys_FwStatus()' --config config.json

result: {"ContractAddress":"0xcb5c24289183005caeb929634b56c4ff69c33a96","FwActive":true,"AcceptedList":null,"RejectedList":null}

./../bin/ctool fwInvoke --addr 0x22 --func '__sys_FwSet("ACCEPT", "0x33:|:funcName2|0x55:funcName3")' --config config.json

request json data: [{"from":"0xcb055f32ef660d7628a9139ce0602f65e5930f2d","to":"0x22","gas":"0x0","gasPrice":"0x0","value":"","data":"0xf83e8800000000000000128b5f5f7379735f467753657486414343455054a1307833333a2a7c2a3a66756e634e616d65327c307835353a66756e634e616d6533","txType":18}]

response json: {"jsonrpc":"2.0","id":1,"error":{"code":-32602,"message":"invalid argument 0: hex string has length 2, want 40 for common.Address"}}

panic: send transaction error ,error:invalid argument 0: hex string has length 2, want 40 for common.Address

goroutine 1 [running]: github.com/PlatONEnterprise/PlatONE-Go/cmd/ctool/core.parseResponse(0xc002c2c2d0, 0x85, 0xe61ea6) /mnt/cdt/platone/build/_workspace/src/github.com/PlatONEnetwork/PlatONE-Go/cmd/ctool/core/http_util.go:58 +0x165 github.com/PlatONEnterprise/PlatONE-Go/cmd/ctool/core.FwInvokeContract(0x7ffc58478618, 0x4, 0xc0000c6900, 0xb, 0xc000193620, 0x2, 0x0, 0x12, 0xe09801, 0xc0025d2d58, ...) /mnt/cdt/platone/build/_workspace/src/github.com/PlatONEnetwork/PlatONE-Go/cmd/ctool/core/contractcmd.go:345 +0x7a5 github.com/PlatONEnterprise/PlatONE-Go/cmd/ctool/core.fwInvoke(0xc0025fc420, 0x10100, 0xc0025fc420) /mnt/cdt/platone/build/_workspace/src/github.com/PlatONEnetwork/PlatONE-Go/cmd/ctool/core/contractcmd.go:188 +0x2ad gopkg.in/urfave/cli%2ev1.HandleAction(0xd5fb20, 0xe86a28, 0xc0025fc420, 0xc00006fa00, 0x0) /mnt/cdt/platone/build/_workspace/pkg/mod/gopkg.in/urfave/cli.v1@v1.20.0/app.go:490 +0x82 gopkg.in/urfave/cli%2ev1.Command.Run(0xe56d93, 0x8, 0x0, 0x0, 0x15ac5d0, 0x1, 0x1, 0xe66fb7, 0x1b, 0x0, ...) /mnt/cdt/platone/build/_workspace/pkg/mod/gopkg.in/urfave/cli.v1@v1.20.0/command.go:210 +0x9bb gopkg.in/urfave/cli%2ev1.(*App).Run(0xc00009f520, 0xc0000b8000, 0x8, 0x8, 0x0, 0x0) /mnt/cdt/platone/build/_workspace/pkg/mod/gopkg.in/urfave/cli.v1@v1.20.0/app.go:255 +0x768 main.main() /mnt/cdt/platone/build/_workspace/src/github.com/PlatONEnetwork/PlatONE-Go/cmd/ctool/main.go:40 +0x55