diff --git a/x/evm/contracts/counter/Counter.go b/x/evm/contracts/counter/Counter.go index 6a24fbb..ad5170f 100644 --- a/x/evm/contracts/counter/Counter.go +++ b/x/evm/contracts/counter/Counter.go @@ -31,8 +31,8 @@ var ( // CounterMetaData contains all meta data concerning the Counter contract. var CounterMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"}],\"name\":\"StringsInsufficientHexLength\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"callback_id\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"}],\"name\":\"callback_received\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldCount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newCount\",\"type\":\"uint256\"}],\"name\":\"increased\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"n\",\"type\":\"uint64\"}],\"name\":\"recursive_called\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"count\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"exec_msg\",\"type\":\"string\"},{\"internalType\":\"bool\",\"name\":\"try_catch\",\"type\":\"bool\"}],\"name\":\"execute_cosmos\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"n\",\"type\":\"uint64\"}],\"name\":\"get_blockhash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"callback_id\",\"type\":\"uint64\"},{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"}],\"name\":\"ibc_ack\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"callback_id\",\"type\":\"uint64\"}],\"name\":\"ibc_timeout\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"increase\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"num\",\"type\":\"uint64\"}],\"name\":\"increase_for_fuzz\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"path\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"req\",\"type\":\"string\"}],\"name\":\"query_cosmos\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"result\",\"type\":\"string\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"n\",\"type\":\"uint64\"}],\"name\":\"recursive\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x608060405261172a806100115f395ff3fe608060405260043610610085575f3560e01c806331a503f01161005857806331a503f01461012b5780636193689514610153578063ac7fde5f1461017b578063cad23554146101b7578063e8927fbc146101f357610085565b806306661abd146100895780630d4f1f9d146100b357806324c68fce146100db5780632607baf814610103575b5f80fd5b348015610094575f80fd5b5061009d6101fd565b6040516100aa9190610c09565b60405180910390f35b3480156100be575f80fd5b506100d960048036038101906100d49190610ca5565b610202565b005b3480156100e6575f80fd5b5061010160048036038101906100fc9190610e1f565b610249565b005b34801561010e575f80fd5b5061012960048036038101906101249190610e79565b610350565b005b348015610136575f80fd5b50610151600480360381019061014c9190610e79565b610383565b005b34801561015e575f80fd5b5061017960048036038101906101749190610e79565b6103a7565b005b348015610186575f80fd5b506101a1600480360381019061019c9190610e79565b6104fa565b6040516101ae9190610ebc565b60405180910390f35b3480156101c2575f80fd5b506101dd60048036038101906101d89190610ed5565b61050e565b6040516101ea9190610fab565b60405180910390f35b6101fb610597565b005b5f5481565b801561022e578167ffffffffffffffff165f808282546102229190610ff8565b92505081905550610245565b5f8081548092919061023f9061102b565b91905055505b5050565b80156102d05760f173ffffffffffffffffffffffffffffffffffffffff1663d46f64e6836040518263ffffffff1660e01b81526004016102899190610fab565b6020604051808303815f875af19250505080156102c457506040513d601f19601f820116820180604052508101906102c19190611086565b60015b156102cb57505b61034c565b60f173ffffffffffffffffffffffffffffffffffffffff1663d46f64e6836040518263ffffffff1660e01b815260040161030a9190610fab565b6020604051808303815f875af1158015610326573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061034a9190611086565b505b5050565b5f8167ffffffffffffffff1603156103805761036a610597565b61037f60018261037a91906110b1565b610350565b5b50565b8067ffffffffffffffff165f8082825461039d9190610ff8565b9250508190555050565b7f4475bbd12ef452e28d39c4cb77494d85136c2d89ca1354b52188d4aaa8f4ba51816040516103d691906110fb565b60405180910390a15f8167ffffffffffffffff1603156104f75760f173ffffffffffffffffffffffffffffffffffffffff1663d46f64e6610416836105f6565b6040518263ffffffff1660e01b81526004016104329190610fab565b6020604051808303815f875af115801561044e573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104729190611086565b5060f173ffffffffffffffffffffffffffffffffffffffff1663d46f64e6610499836105f6565b6040518263ffffffff1660e01b81526004016104b59190610fab565b6020604051808303815f875af11580156104d1573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104f59190611086565b505b50565b5f8167ffffffffffffffff16409050919050565b606060f173ffffffffffffffffffffffffffffffffffffffff1663cad2355484846040518363ffffffff1660e01b815260040161054c929190611114565b5f604051808303815f875af1158015610567573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f8201168201806040525081019061058f91906111b7565b905092915050565b5f808154809291906105a89061102b565b91905055507f61996fe196f72cb598c483e896a1221263a28bb630480aa89495f737d4a8e3df60015f546105dc91906111fe565b5f546040516105ec929190611231565b60405180910390a1565b606060f173ffffffffffffffffffffffffffffffffffffffff16636af32a55306040518263ffffffff1660e01b81526004016106329190611297565b5f604051808303815f875af115801561064d573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f8201168201806040525081019061067591906111b7565b61067e30610702565b6106da636193689560e01b60018661069691906110b1565b6040516020016106a691906110fb565b6040516020818303038152906040526040516020016106c692919061133f565b60405160208183030381529060405261072f565b6040516020016106ec939291906115cc565b6040516020818303038152906040529050919050565b60606107288273ffffffffffffffffffffffffffffffffffffffff16601460ff166109b3565b9050919050565b60605f6002808451610741919061165f565b61074b9190610ff8565b67ffffffffffffffff81111561076457610763610cfb565b5b6040519080825280601f01601f1916602001820160405280156107965781602001600182028036833780820191505090505b5090507f3000000000000000000000000000000000000000000000000000000000000000815f815181106107cd576107cc6116a0565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106108305761082f6116a0565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a9053505f5b83518110156109a9575f84828151811061087d5761087c6116a0565b5b602001015160f81c60f81b60f81c90507f303132333435363738396162636465660000000000000000000000000000000060048260ff16901c60ff16601081106108ca576108c96116a0565b5b1a60f81b83600280850201815181106108e6576108e56116a0565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a9053507f3031323334353637383961626364656600000000000000000000000000000000600f821660ff166010811061094d5761094c6116a0565b5b1a60f81b83600260016002860201018151811061096d5761096c6116a0565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a905350508080600101915050610860565b5080915050919050565b60605f8390505f60028460026109c9919061165f565b6109d39190610ff8565b67ffffffffffffffff8111156109ec576109eb610cfb565b5b6040519080825280601f01601f191660200182016040528015610a1e5781602001600182028036833780820191505090505b5090507f3000000000000000000000000000000000000000000000000000000000000000815f81518110610a5557610a546116a0565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110610ab857610ab76116a0565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a9053505f6001856002610af6919061165f565b610b009190610ff8565b90505b6001811115610b9f577f3031323334353637383961626364656600000000000000000000000000000000600f841660108110610b4257610b416116a0565b5b1a60f81b828281518110610b5957610b586116a0565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a905350600483901c925080610b98906116cd565b9050610b03565b505f8214610be65784846040517fe22e27eb000000000000000000000000000000000000000000000000000000008152600401610bdd929190611231565b60405180910390fd5b809250505092915050565b5f819050919050565b610c0381610bf1565b82525050565b5f602082019050610c1c5f830184610bfa565b92915050565b5f604051905090565b5f80fd5b5f80fd5b5f67ffffffffffffffff82169050919050565b610c4f81610c33565b8114610c59575f80fd5b50565b5f81359050610c6a81610c46565b92915050565b5f8115159050919050565b610c8481610c70565b8114610c8e575f80fd5b50565b5f81359050610c9f81610c7b565b92915050565b5f8060408385031215610cbb57610cba610c2b565b5b5f610cc885828601610c5c565b9250506020610cd985828601610c91565b9150509250929050565b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610d3182610ceb565b810181811067ffffffffffffffff82111715610d5057610d4f610cfb565b5b80604052505050565b5f610d62610c22565b9050610d6e8282610d28565b919050565b5f67ffffffffffffffff821115610d8d57610d8c610cfb565b5b610d9682610ceb565b9050602081019050919050565b828183375f83830152505050565b5f610dc3610dbe84610d73565b610d59565b905082815260208101848484011115610ddf57610dde610ce7565b5b610dea848285610da3565b509392505050565b5f82601f830112610e0657610e05610ce3565b5b8135610e16848260208601610db1565b91505092915050565b5f8060408385031215610e3557610e34610c2b565b5b5f83013567ffffffffffffffff811115610e5257610e51610c2f565b5b610e5e85828601610df2565b9250506020610e6f85828601610c91565b9150509250929050565b5f60208284031215610e8e57610e8d610c2b565b5b5f610e9b84828501610c5c565b91505092915050565b5f819050919050565b610eb681610ea4565b82525050565b5f602082019050610ecf5f830184610ead565b92915050565b5f8060408385031215610eeb57610eea610c2b565b5b5f83013567ffffffffffffffff811115610f0857610f07610c2f565b5b610f1485828601610df2565b925050602083013567ffffffffffffffff811115610f3557610f34610c2f565b5b610f4185828601610df2565b9150509250929050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f610f7d82610f4b565b610f878185610f55565b9350610f97818560208601610f65565b610fa081610ceb565b840191505092915050565b5f6020820190508181035f830152610fc38184610f73565b905092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f61100282610bf1565b915061100d83610bf1565b925082820190508082111561102557611024610fcb565b5b92915050565b5f61103582610bf1565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361106757611066610fcb565b5b600182019050919050565b5f8151905061108081610c7b565b92915050565b5f6020828403121561109b5761109a610c2b565b5b5f6110a884828501611072565b91505092915050565b5f6110bb82610c33565b91506110c683610c33565b9250828203905067ffffffffffffffff8111156110e6576110e5610fcb565b5b92915050565b6110f581610c33565b82525050565b5f60208201905061110e5f8301846110ec565b92915050565b5f6040820190508181035f83015261112c8185610f73565b905081810360208301526111408184610f73565b90509392505050565b5f61115b61115684610d73565b610d59565b90508281526020810184848401111561117757611176610ce7565b5b611182848285610f65565b509392505050565b5f82601f83011261119e5761119d610ce3565b5b81516111ae848260208601611149565b91505092915050565b5f602082840312156111cc576111cb610c2b565b5b5f82015167ffffffffffffffff8111156111e9576111e8610c2f565b5b6111f58482850161118a565b91505092915050565b5f61120882610bf1565b915061121383610bf1565b925082820390508181111561122b5761122a610fcb565b5b92915050565b5f6040820190506112445f830185610bfa565b6112516020830184610bfa565b9392505050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61128182611258565b9050919050565b61129181611277565b82525050565b5f6020820190506112aa5f830184611288565b92915050565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b5f819050919050565b6112f56112f0826112b0565b6112db565b82525050565b5f81519050919050565b5f81905092915050565b5f611319826112fb565b6113238185611305565b9350611333818560208601610f65565b80840191505092915050565b5f61134a82856112e4565b60048201915061135a828461130f565b91508190509392505050565b5f81905092915050565b7f7b224074797065223a20222f6d696e6965766d2e65766d2e76312e4d736743615f8201527f6c6c222c00000000000000000000000000000000000000000000000000000000602082015250565b5f6113ca602483611366565b91506113d582611370565b602482019050919050565b7f2273656e646572223a20220000000000000000000000000000000000000000005f82015250565b5f611414600b83611366565b915061141f826113e0565b600b82019050919050565b5f61143482610f4b565b61143e8185611366565b935061144e818560208601610f65565b80840191505092915050565b7f222c0000000000000000000000000000000000000000000000000000000000005f82015250565b5f61148e600283611366565b91506114998261145a565b600282019050919050565b7f22636f6e74726163745f61646472223a202200000000000000000000000000005f82015250565b5f6114d8601283611366565b91506114e3826114a4565b601282019050919050565b7f22696e707574223a2022000000000000000000000000000000000000000000005f82015250565b5f611522600a83611366565b915061152d826114ee565b600a82019050919050565b7f2276616c7565223a202230222c000000000000000000000000000000000000005f82015250565b5f61156c600d83611366565b915061157782611538565b600d82019050919050565b7f226163636573735f6c697374223a205b5d7d00000000000000000000000000005f82015250565b5f6115b6601283611366565b91506115c182611582565b601282019050919050565b5f6115d6826113be565b91506115e182611408565b91506115ed828661142a565b91506115f882611482565b9150611603826114cc565b915061160f828561142a565b915061161a82611482565b915061162582611516565b9150611631828461142a565b915061163c82611482565b915061164782611560565b9150611652826115aa565b9150819050949350505050565b5f61166982610bf1565b915061167483610bf1565b925082820261168281610bf1565b9150828204841483151761169957611698610fcb565b5b5092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f6116d782610bf1565b91505f82036116e9576116e8610fcb565b5b60018203905091905056fea264697066735822122029dc1595bc6e794ef66cea60c573059ccdd0278ec0aaf57dd3beb6943a109b6164736f6c63430008190033", + ABI: "[{\"inputs\":[],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"}],\"name\":\"StringsInsufficientHexLength\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"reverted\",\"type\":\"bool\"}],\"name\":\"execute_reverted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldCount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newCount\",\"type\":\"uint256\"}],\"name\":\"increased\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"n\",\"type\":\"uint64\"}],\"name\":\"recursive_called\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"count\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"exec_msg\",\"type\":\"string\"},{\"internalType\":\"bool\",\"name\":\"try_catch\",\"type\":\"bool\"}],\"name\":\"execute_cosmos\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"n\",\"type\":\"uint64\"}],\"name\":\"get_blockhash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"callback_id\",\"type\":\"uint64\"},{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"}],\"name\":\"ibc_ack\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"callback_id\",\"type\":\"uint64\"}],\"name\":\"ibc_timeout\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"increase\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"num\",\"type\":\"uint64\"}],\"name\":\"increase_for_fuzz\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"path\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"req\",\"type\":\"string\"}],\"name\":\"query_cosmos\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"result\",\"type\":\"string\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"n\",\"type\":\"uint64\"}],\"name\":\"recursive\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x60806040526117c5806100115f395ff3fe608060405260043610610085575f3560e01c806331a503f01161005857806331a503f01461012b5780636193689514610153578063ac7fde5f1461017b578063cad23554146101b7578063e8927fbc146101f357610085565b806306661abd146100895780630d4f1f9d146100b357806324c68fce146100db5780632607baf814610103575b5f80fd5b348015610094575f80fd5b5061009d6101fd565b6040516100aa9190610c7c565b60405180910390f35b3480156100be575f80fd5b506100d960048036038101906100d49190610d18565b610202565b005b3480156100e6575f80fd5b5061010160048036038101906100fc9190610e92565b610249565b005b34801561010e575f80fd5b5061012960048036038101906101249190610eec565b6103c3565b005b348015610136575f80fd5b50610151600480360381019061014c9190610eec565b6103f6565b005b34801561015e575f80fd5b5061017960048036038101906101749190610eec565b61041a565b005b348015610186575f80fd5b506101a1600480360381019061019c9190610eec565b61056d565b6040516101ae9190610f2f565b60405180910390f35b3480156101c2575f80fd5b506101dd60048036038101906101d89190610f48565b610581565b6040516101ea919061101e565b60405180910390f35b6101fb61060a565b005b5f5481565b801561022e578167ffffffffffffffff165f80828254610222919061106b565b92505081905550610245565b5f8081548092919061023f9061109e565b91905055505b5050565b80156103435760f173ffffffffffffffffffffffffffffffffffffffff1663d46f64e6836040518263ffffffff1660e01b8152600401610289919061101e565b6020604051808303815f875af19250505080156102c457506040513d601f19601f820116820180604052508101906102c191906110f9565b60015b610305577f1a0d1eca1924bf9fc21c4b3f8b97d45c8fad7f5dbde70453a436a095844b3b6a60016040516102f89190611133565b60405180910390a161033e565b507f1a0d1eca1924bf9fc21c4b3f8b97d45c8fad7f5dbde70453a436a095844b3b6a5f6040516103359190611133565b60405180910390a15b6103bf565b60f173ffffffffffffffffffffffffffffffffffffffff1663d46f64e6836040518263ffffffff1660e01b815260040161037d919061101e565b6020604051808303815f875af1158015610399573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906103bd91906110f9565b505b5050565b5f8167ffffffffffffffff1603156103f3576103dd61060a565b6103f26001826103ed919061114c565b6103c3565b5b50565b8067ffffffffffffffff165f80828254610410919061106b565b9250508190555050565b7f4475bbd12ef452e28d39c4cb77494d85136c2d89ca1354b52188d4aaa8f4ba51816040516104499190611196565b60405180910390a15f8167ffffffffffffffff16031561056a5760f173ffffffffffffffffffffffffffffffffffffffff1663d46f64e661048983610669565b6040518263ffffffff1660e01b81526004016104a5919061101e565b6020604051808303815f875af11580156104c1573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104e591906110f9565b5060f173ffffffffffffffffffffffffffffffffffffffff1663d46f64e661050c83610669565b6040518263ffffffff1660e01b8152600401610528919061101e565b6020604051808303815f875af1158015610544573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061056891906110f9565b505b50565b5f8167ffffffffffffffff16409050919050565b606060f173ffffffffffffffffffffffffffffffffffffffff1663cad2355484846040518363ffffffff1660e01b81526004016105bf9291906111af565b5f604051808303815f875af11580156105da573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f820116820180604052508101906106029190611252565b905092915050565b5f8081548092919061061b9061109e565b91905055507f61996fe196f72cb598c483e896a1221263a28bb630480aa89495f737d4a8e3df60015f5461064f9190611299565b5f5460405161065f9291906112cc565b60405180910390a1565b606060f173ffffffffffffffffffffffffffffffffffffffff16636af32a55306040518263ffffffff1660e01b81526004016106a59190611332565b5f604051808303815f875af11580156106c0573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f820116820180604052508101906106e89190611252565b6106f130610775565b61074d636193689560e01b600186610709919061114c565b6040516020016107199190611196565b6040516020818303038152906040526040516020016107399291906113da565b6040516020818303038152906040526107a2565b60405160200161075f93929190611667565b6040516020818303038152906040529050919050565b606061079b8273ffffffffffffffffffffffffffffffffffffffff16601460ff16610a26565b9050919050565b60605f60028084516107b491906116fa565b6107be919061106b565b67ffffffffffffffff8111156107d7576107d6610d6e565b5b6040519080825280601f01601f1916602001820160405280156108095781602001600182028036833780820191505090505b5090507f3000000000000000000000000000000000000000000000000000000000000000815f815181106108405761083f61173b565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106108a3576108a261173b565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a9053505f5b8351811015610a1c575f8482815181106108f0576108ef61173b565b5b602001015160f81c60f81b60f81c90507f303132333435363738396162636465660000000000000000000000000000000060048260ff16901c60ff166010811061093d5761093c61173b565b5b1a60f81b83600280850201815181106109595761095861173b565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a9053507f3031323334353637383961626364656600000000000000000000000000000000600f821660ff16601081106109c0576109bf61173b565b5b1a60f81b8360026001600286020101815181106109e0576109df61173b565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a9053505080806001019150506108d3565b5080915050919050565b60605f8390505f6002846002610a3c91906116fa565b610a46919061106b565b67ffffffffffffffff811115610a5f57610a5e610d6e565b5b6040519080825280601f01601f191660200182016040528015610a915781602001600182028036833780820191505090505b5090507f3000000000000000000000000000000000000000000000000000000000000000815f81518110610ac857610ac761173b565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110610b2b57610b2a61173b565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a9053505f6001856002610b6991906116fa565b610b73919061106b565b90505b6001811115610c12577f3031323334353637383961626364656600000000000000000000000000000000600f841660108110610bb557610bb461173b565b5b1a60f81b828281518110610bcc57610bcb61173b565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a905350600483901c925080610c0b90611768565b9050610b76565b505f8214610c595784846040517fe22e27eb000000000000000000000000000000000000000000000000000000008152600401610c509291906112cc565b60405180910390fd5b809250505092915050565b5f819050919050565b610c7681610c64565b82525050565b5f602082019050610c8f5f830184610c6d565b92915050565b5f604051905090565b5f80fd5b5f80fd5b5f67ffffffffffffffff82169050919050565b610cc281610ca6565b8114610ccc575f80fd5b50565b5f81359050610cdd81610cb9565b92915050565b5f8115159050919050565b610cf781610ce3565b8114610d01575f80fd5b50565b5f81359050610d1281610cee565b92915050565b5f8060408385031215610d2e57610d2d610c9e565b5b5f610d3b85828601610ccf565b9250506020610d4c85828601610d04565b9150509250929050565b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610da482610d5e565b810181811067ffffffffffffffff82111715610dc357610dc2610d6e565b5b80604052505050565b5f610dd5610c95565b9050610de18282610d9b565b919050565b5f67ffffffffffffffff821115610e0057610dff610d6e565b5b610e0982610d5e565b9050602081019050919050565b828183375f83830152505050565b5f610e36610e3184610de6565b610dcc565b905082815260208101848484011115610e5257610e51610d5a565b5b610e5d848285610e16565b509392505050565b5f82601f830112610e7957610e78610d56565b5b8135610e89848260208601610e24565b91505092915050565b5f8060408385031215610ea857610ea7610c9e565b5b5f83013567ffffffffffffffff811115610ec557610ec4610ca2565b5b610ed185828601610e65565b9250506020610ee285828601610d04565b9150509250929050565b5f60208284031215610f0157610f00610c9e565b5b5f610f0e84828501610ccf565b91505092915050565b5f819050919050565b610f2981610f17565b82525050565b5f602082019050610f425f830184610f20565b92915050565b5f8060408385031215610f5e57610f5d610c9e565b5b5f83013567ffffffffffffffff811115610f7b57610f7a610ca2565b5b610f8785828601610e65565b925050602083013567ffffffffffffffff811115610fa857610fa7610ca2565b5b610fb485828601610e65565b9150509250929050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f610ff082610fbe565b610ffa8185610fc8565b935061100a818560208601610fd8565b61101381610d5e565b840191505092915050565b5f6020820190508181035f8301526110368184610fe6565b905092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f61107582610c64565b915061108083610c64565b92508282019050808211156110985761109761103e565b5b92915050565b5f6110a882610c64565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036110da576110d961103e565b5b600182019050919050565b5f815190506110f381610cee565b92915050565b5f6020828403121561110e5761110d610c9e565b5b5f61111b848285016110e5565b91505092915050565b61112d81610ce3565b82525050565b5f6020820190506111465f830184611124565b92915050565b5f61115682610ca6565b915061116183610ca6565b9250828203905067ffffffffffffffff8111156111815761118061103e565b5b92915050565b61119081610ca6565b82525050565b5f6020820190506111a95f830184611187565b92915050565b5f6040820190508181035f8301526111c78185610fe6565b905081810360208301526111db8184610fe6565b90509392505050565b5f6111f66111f184610de6565b610dcc565b90508281526020810184848401111561121257611211610d5a565b5b61121d848285610fd8565b509392505050565b5f82601f83011261123957611238610d56565b5b81516112498482602086016111e4565b91505092915050565b5f6020828403121561126757611266610c9e565b5b5f82015167ffffffffffffffff81111561128457611283610ca2565b5b61129084828501611225565b91505092915050565b5f6112a382610c64565b91506112ae83610c64565b92508282039050818111156112c6576112c561103e565b5b92915050565b5f6040820190506112df5f830185610c6d565b6112ec6020830184610c6d565b9392505050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61131c826112f3565b9050919050565b61132c81611312565b82525050565b5f6020820190506113455f830184611323565b92915050565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b5f819050919050565b61139061138b8261134b565b611376565b82525050565b5f81519050919050565b5f81905092915050565b5f6113b482611396565b6113be81856113a0565b93506113ce818560208601610fd8565b80840191505092915050565b5f6113e5828561137f565b6004820191506113f582846113aa565b91508190509392505050565b5f81905092915050565b7f7b224074797065223a20222f6d696e6965766d2e65766d2e76312e4d736743615f8201527f6c6c222c00000000000000000000000000000000000000000000000000000000602082015250565b5f611465602483611401565b91506114708261140b565b602482019050919050565b7f2273656e646572223a20220000000000000000000000000000000000000000005f82015250565b5f6114af600b83611401565b91506114ba8261147b565b600b82019050919050565b5f6114cf82610fbe565b6114d98185611401565b93506114e9818560208601610fd8565b80840191505092915050565b7f222c0000000000000000000000000000000000000000000000000000000000005f82015250565b5f611529600283611401565b9150611534826114f5565b600282019050919050565b7f22636f6e74726163745f61646472223a202200000000000000000000000000005f82015250565b5f611573601283611401565b915061157e8261153f565b601282019050919050565b7f22696e707574223a2022000000000000000000000000000000000000000000005f82015250565b5f6115bd600a83611401565b91506115c882611589565b600a82019050919050565b7f2276616c7565223a202230222c000000000000000000000000000000000000005f82015250565b5f611607600d83611401565b9150611612826115d3565b600d82019050919050565b7f226163636573735f6c697374223a205b5d7d00000000000000000000000000005f82015250565b5f611651601283611401565b915061165c8261161d565b601282019050919050565b5f61167182611459565b915061167c826114a3565b915061168882866114c5565b91506116938261151d565b915061169e82611567565b91506116aa82856114c5565b91506116b58261151d565b91506116c0826115b1565b91506116cc82846114c5565b91506116d78261151d565b91506116e2826115fb565b91506116ed82611645565b9150819050949350505050565b5f61170482610c64565b915061170f83610c64565b925082820261171d81610c64565b915082820484148315176117345761173361103e565b5b5092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f61177282610c64565b91505f82036117845761178361103e565b5b60018203905091905056fea26469706673582212203dcfd3e72d386299f9cc3c1e16d724be03a75bf28d1b18677fe42aefd8b2a5b864736f6c63430008190033", } // CounterABI is the input ABI used to generate the binding from. @@ -411,9 +411,9 @@ func (_Counter *CounterTransactorSession) Recursive(n uint64) (*types.Transactio return _Counter.Contract.Recursive(&_Counter.TransactOpts, n) } -// CounterCallbackReceivedIterator is returned from FilterCallbackReceived and is used to iterate over the raw logs and unpacked data for CallbackReceived events raised by the Counter contract. -type CounterCallbackReceivedIterator struct { - Event *CounterCallbackReceived // Event containing the contract specifics and raw log +// CounterExecuteRevertedIterator is returned from FilterExecuteReverted and is used to iterate over the raw logs and unpacked data for ExecuteReverted events raised by the Counter contract. +type CounterExecuteRevertedIterator struct { + Event *CounterExecuteReverted // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -427,7 +427,7 @@ type CounterCallbackReceivedIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *CounterCallbackReceivedIterator) Next() bool { +func (it *CounterExecuteRevertedIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -436,7 +436,7 @@ func (it *CounterCallbackReceivedIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(CounterCallbackReceived) + it.Event = new(CounterExecuteReverted) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -451,7 +451,7 @@ func (it *CounterCallbackReceivedIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(CounterCallbackReceived) + it.Event = new(CounterExecuteReverted) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -467,42 +467,41 @@ func (it *CounterCallbackReceivedIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *CounterCallbackReceivedIterator) Error() error { +func (it *CounterExecuteRevertedIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *CounterCallbackReceivedIterator) Close() error { +func (it *CounterExecuteRevertedIterator) Close() error { it.sub.Unsubscribe() return nil } -// CounterCallbackReceived represents a CallbackReceived event raised by the Counter contract. -type CounterCallbackReceived struct { - CallbackId uint64 - Success bool - Raw types.Log // Blockchain specific contextual infos +// CounterExecuteReverted represents a ExecuteReverted event raised by the Counter contract. +type CounterExecuteReverted struct { + Reverted bool + Raw types.Log // Blockchain specific contextual infos } -// FilterCallbackReceived is a free log retrieval operation binding the contract event 0xa019c7431cdfd7ba63501ffa1ba7d8f2a028e447653a5af5a96077e5038e0339. +// FilterExecuteReverted is a free log retrieval operation binding the contract event 0x1a0d1eca1924bf9fc21c4b3f8b97d45c8fad7f5dbde70453a436a095844b3b6a. // -// Solidity: event callback_received(uint64 callback_id, bool success) -func (_Counter *CounterFilterer) FilterCallbackReceived(opts *bind.FilterOpts) (*CounterCallbackReceivedIterator, error) { +// Solidity: event execute_reverted(bool reverted) +func (_Counter *CounterFilterer) FilterExecuteReverted(opts *bind.FilterOpts) (*CounterExecuteRevertedIterator, error) { - logs, sub, err := _Counter.contract.FilterLogs(opts, "callback_received") + logs, sub, err := _Counter.contract.FilterLogs(opts, "execute_reverted") if err != nil { return nil, err } - return &CounterCallbackReceivedIterator{contract: _Counter.contract, event: "callback_received", logs: logs, sub: sub}, nil + return &CounterExecuteRevertedIterator{contract: _Counter.contract, event: "execute_reverted", logs: logs, sub: sub}, nil } -// WatchCallbackReceived is a free log subscription operation binding the contract event 0xa019c7431cdfd7ba63501ffa1ba7d8f2a028e447653a5af5a96077e5038e0339. +// WatchExecuteReverted is a free log subscription operation binding the contract event 0x1a0d1eca1924bf9fc21c4b3f8b97d45c8fad7f5dbde70453a436a095844b3b6a. // -// Solidity: event callback_received(uint64 callback_id, bool success) -func (_Counter *CounterFilterer) WatchCallbackReceived(opts *bind.WatchOpts, sink chan<- *CounterCallbackReceived) (event.Subscription, error) { +// Solidity: event execute_reverted(bool reverted) +func (_Counter *CounterFilterer) WatchExecuteReverted(opts *bind.WatchOpts, sink chan<- *CounterExecuteReverted) (event.Subscription, error) { - logs, sub, err := _Counter.contract.WatchLogs(opts, "callback_received") + logs, sub, err := _Counter.contract.WatchLogs(opts, "execute_reverted") if err != nil { return nil, err } @@ -512,8 +511,8 @@ func (_Counter *CounterFilterer) WatchCallbackReceived(opts *bind.WatchOpts, sin select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(CounterCallbackReceived) - if err := _Counter.contract.UnpackLog(event, "callback_received", log); err != nil { + event := new(CounterExecuteReverted) + if err := _Counter.contract.UnpackLog(event, "execute_reverted", log); err != nil { return err } event.Raw = log @@ -534,12 +533,12 @@ func (_Counter *CounterFilterer) WatchCallbackReceived(opts *bind.WatchOpts, sin }), nil } -// ParseCallbackReceived is a log parse operation binding the contract event 0xa019c7431cdfd7ba63501ffa1ba7d8f2a028e447653a5af5a96077e5038e0339. +// ParseExecuteReverted is a log parse operation binding the contract event 0x1a0d1eca1924bf9fc21c4b3f8b97d45c8fad7f5dbde70453a436a095844b3b6a. // -// Solidity: event callback_received(uint64 callback_id, bool success) -func (_Counter *CounterFilterer) ParseCallbackReceived(log types.Log) (*CounterCallbackReceived, error) { - event := new(CounterCallbackReceived) - if err := _Counter.contract.UnpackLog(event, "callback_received", log); err != nil { +// Solidity: event execute_reverted(bool reverted) +func (_Counter *CounterFilterer) ParseExecuteReverted(log types.Log) (*CounterExecuteReverted, error) { + event := new(CounterExecuteReverted) + if err := _Counter.contract.UnpackLog(event, "execute_reverted", log); err != nil { return nil, err } event.Raw = log diff --git a/x/evm/contracts/counter/Counter.sol b/x/evm/contracts/counter/Counter.sol index d49e438..d00ec1a 100644 --- a/x/evm/contracts/counter/Counter.sol +++ b/x/evm/contracts/counter/Counter.sol @@ -9,7 +9,7 @@ contract Counter is IIBCAsyncCallback { uint256 public count; event increased(uint256 oldCount, uint256 newCount); - event callback_received(uint64 callback_id, bool success); + event execute_reverted(bool reverted); event recursive_called(uint64 n); constructor() payable {} @@ -53,9 +53,9 @@ contract Counter is IIBCAsyncCallback { ) external { if (try_catch) { try COSMOS_CONTRACT.execute_cosmos(exec_msg) { - // do nothing + emit execute_reverted(false); } catch { - // do nothing + emit execute_reverted(true); } } else { COSMOS_CONTRACT.execute_cosmos(exec_msg); diff --git a/x/evm/keeper/context_test.go b/x/evm/keeper/context_test.go index 2125fb5..43d89f0 100644 --- a/x/evm/keeper/context_test.go +++ b/x/evm/keeper/context_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "encoding/json" "fmt" "strings" "testing" @@ -14,6 +15,7 @@ import ( "golang.org/x/crypto/sha3" sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/initia-labs/minievm/x/evm/contracts/counter" "github.com/initia-labs/minievm/x/evm/contracts/erc20" @@ -313,12 +315,34 @@ func Test_ExecuteCosmos(t *testing.T) { ) require.NoError(t, err) - _, _, err = input.EVMKeeper.EVMCall(ctx, caller, contractAddr, inputBz, nil, nil) + eventManager := sdk.NewEventManager() + _, _, err = input.EVMKeeper.EVMCall(ctx.WithEventManager(eventManager), caller, contractAddr, inputBz, nil, nil) require.NoError(t, err) require.Equal(t, amount, input.BankKeeper.GetBalance(ctx, sdk.AccAddress(contractAddr.Bytes()), denom).Amount) require.Equal(t, math.ZeroInt(), input.BankKeeper.GetBalance(ctx, addr, denom).Amount) + shouldEnter := false + for _, event := range eventManager.Events() { + if event.Type == types.EventTypeEVM { + for _, attr := range event.Attributes { + if attr.Key == types.AttributeKeyLog { + var log types.Log + err := json.Unmarshal([]byte(attr.Value), &log) + require.NoError(t, err) + if log.Address == contractAddr.Hex() { + // should emit reverted true log + require.Equal(t, "0x0000000000000000000000000000000000000000000000000000000000000001", log.Data) + shouldEnter = true + } + } + } + } else if event.Type == banktypes.EventTypeTransfer { + require.FailNow(t, "should not emit bank transfer event") + } + } + require.True(t, shouldEnter) + // call normally inputBz, err = parsed.Pack("execute_cosmos", fmt.Sprintf(`{"@type":"/cosmos.bank.v1beta1.MsgSend","from_address":"%s","to_address":"%s","amount":[{"denom":"%s","amount":"%s"}]}`, @@ -327,13 +351,37 @@ func Test_ExecuteCosmos(t *testing.T) { denom, amount, ), - false, + true, ) require.NoError(t, err) - _, _, err = input.EVMKeeper.EVMCall(ctx, caller, contractAddr, inputBz, nil, nil) + eventManager = sdk.NewEventManager() + _, _, err = input.EVMKeeper.EVMCall(ctx.WithEventManager(eventManager), caller, contractAddr, inputBz, nil, nil) require.NoError(t, err) require.Equal(t, math.ZeroInt(), input.BankKeeper.GetBalance(ctx, sdk.AccAddress(contractAddr.Bytes()), denom).Amount) require.Equal(t, amount, input.BankKeeper.GetBalance(ctx, addr, denom).Amount) + + shouldEnter = false + shouldEnterBank := false + for _, event := range eventManager.Events() { + if event.Type == types.EventTypeEVM { + for _, attr := range event.Attributes { + if attr.Key == types.AttributeKeyLog { + var log types.Log + err := json.Unmarshal([]byte(attr.Value), &log) + require.NoError(t, err) + if log.Address == contractAddr.Hex() { + // should emit reverted false log + require.Equal(t, "0x0000000000000000000000000000000000000000000000000000000000000000", log.Data) + shouldEnter = true + } + } + } + } else if event.Type == banktypes.EventTypeTransfer { + shouldEnterBank = true + } + } + require.True(t, shouldEnter) + require.True(t, shouldEnterBank) } diff --git a/x/evm/state/statedb.go b/x/evm/state/statedb.go index 3613a91..55a5243 100644 --- a/x/evm/state/statedb.go +++ b/x/evm/state/statedb.go @@ -583,7 +583,7 @@ func (s *StateDB) RevertToSnapshot(i int) { s.ctx = snap.ctx // clear the snapshots after the given id - s.snaps = s.snaps[:i] + s.snaps = s.snaps[:i+1] } // ContextOfSnapshot returns the context of the snapshot with the given id