From 5012d289ac817cd882453cfaff83ca7c9f6d3d6a Mon Sep 17 00:00:00 2001 From: Lucas Bertrand Date: Wed, 13 Nov 2024 09:56:56 +0100 Subject: [PATCH 1/3] fix: out of gas on ZetaClient during `onRevert` (#3144) * add gas consumption on revert * comment tests * format * fix testdapp deploy * set no limit * set higher gas * decrease gas usage * try again with 4M * push back old values * add tests back * fix unit test --- e2e/e2etests/test_deploy_contract.go | 2 ++ e2e/runner/v2_setup_evm.go | 8 ++++- e2e/runner/v2_setup_zeta.go | 8 ++++- pkg/contracts/testdappv2/TestDAppV2.abi | 24 +++++++++++++++ pkg/contracts/testdappv2/TestDAppV2.bin | 2 +- pkg/contracts/testdappv2/TestDAppV2.go | 39 +++++++++++++++++++++--- pkg/contracts/testdappv2/TestDAppV2.json | 26 +++++++++++++++- pkg/contracts/testdappv2/TestDAppV2.sol | 34 +++++++++++++++++++++ x/fungible/keeper/v2_deposits_test.go | 2 +- zetaclient/zetacore/constant.go | 4 +-- 10 files changed, 138 insertions(+), 11 deletions(-) diff --git a/e2e/e2etests/test_deploy_contract.go b/e2e/e2etests/test_deploy_contract.go index e2623a1381..92b1ae9257 100644 --- a/e2e/e2etests/test_deploy_contract.go +++ b/e2e/e2etests/test_deploy_contract.go @@ -45,6 +45,7 @@ func deployZEVMTestDApp(r *runner.E2ERunner) (ethcommon.Address, error) { addr, tx, _, err := testdappv2.DeployTestDAppV2( r.ZEVMAuth, r.ZEVMClient, + true, ) if err != nil { return addr, err @@ -64,6 +65,7 @@ func deployEVMTestDApp(r *runner.E2ERunner) (ethcommon.Address, error) { addr, tx, _, err := testdappv2.DeployTestDAppV2( r.EVMAuth, r.EVMClient, + false, ) if err != nil { return addr, err diff --git a/e2e/runner/v2_setup_evm.go b/e2e/runner/v2_setup_evm.go index 5b8e686d9b..8545302fd3 100644 --- a/e2e/runner/v2_setup_evm.go +++ b/e2e/runner/v2_setup_evm.go @@ -4,6 +4,7 @@ import ( "math/big" "time" + "github.com/ethereum/go-ethereum/accounts/abi/bind" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/stretchr/testify/require" erc20custodyv2 "github.com/zeta-chain/protocol-contracts/v2/pkg/erc20custody.sol" @@ -101,7 +102,7 @@ func (r *E2ERunner) SetupEVMV2() { require.NoError(r, err) // deploy test dapp v2 - testDAppV2Addr, txTestDAppV2, _, err := testdappv2.DeployTestDAppV2(r.EVMAuth, r.EVMClient) + testDAppV2Addr, txTestDAppV2, _, err := testdappv2.DeployTestDAppV2(r.EVMAuth, r.EVMClient, false) require.NoError(r, err) r.TestDAppV2EVMAddr = testDAppV2Addr @@ -115,6 +116,11 @@ func (r *E2ERunner) SetupEVMV2() { ensureTxReceipt(txSetCustody, "Set custody in Gateway failed") ensureTxReceipt(txTestDAppV2, "TestDAppV2 deployment failed") + // check isZetaChain is false + isZetaChain, err := r.TestDAppV2EVM.IsZetaChain(&bind.CallOpts{}) + require.NoError(r, err) + require.False(r, isZetaChain) + // whitelist the ERC20 txWhitelist, err := r.ERC20CustodyV2.Whitelist(r.EVMAuth, r.ERC20Addr) require.NoError(r, err) diff --git a/e2e/runner/v2_setup_zeta.go b/e2e/runner/v2_setup_zeta.go index 6d0607a7f9..69f16e2658 100644 --- a/e2e/runner/v2_setup_zeta.go +++ b/e2e/runner/v2_setup_zeta.go @@ -3,6 +3,7 @@ package runner import ( "time" + "github.com/ethereum/go-ethereum/accounts/abi/bind" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/stretchr/testify/require" "github.com/zeta-chain/protocol-contracts/v2/pkg/gatewayzevm.sol" @@ -64,7 +65,7 @@ func (r *E2ERunner) SetZEVMContractsV2() { require.NoError(r, err) // deploy test dapp v2 - testDAppV2Addr, txTestDAppV2, _, err := testdappv2.DeployTestDAppV2(r.ZEVMAuth, r.ZEVMClient) + testDAppV2Addr, txTestDAppV2, _, err := testdappv2.DeployTestDAppV2(r.ZEVMAuth, r.ZEVMClient, true) require.NoError(r, err) r.TestDAppV2ZEVMAddr = testDAppV2Addr @@ -73,6 +74,11 @@ func (r *E2ERunner) SetZEVMContractsV2() { ensureTxReceipt(txProxy, "Gateway proxy deployment failed") ensureTxReceipt(txTestDAppV2, "TestDAppV2 deployment failed") + + // check isZetaChain is true + isZetaChain, err := r.TestDAppV2ZEVM.IsZetaChain(&bind.CallOpts{}) + require.NoError(r, err) + require.True(r, isZetaChain) } // UpdateChainParamsV2Contracts update the erc20 custody contract and gateway address in the chain params diff --git a/pkg/contracts/testdappv2/TestDAppV2.abi b/pkg/contracts/testdappv2/TestDAppV2.abi index 33270e31e3..d87050a8a0 100644 --- a/pkg/contracts/testdappv2/TestDAppV2.abi +++ b/pkg/contracts/testdappv2/TestDAppV2.abi @@ -1,4 +1,15 @@ [ + { + "inputs": [ + { + "internalType": "bool", + "name": "isZetaChain_", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, { "inputs": [], "name": "NO_MESSAGE_CALL", @@ -143,6 +154,19 @@ "stateMutability": "pure", "type": "function" }, + { + "inputs": [], + "name": "isZetaChain", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { diff --git a/pkg/contracts/testdappv2/TestDAppV2.bin b/pkg/contracts/testdappv2/TestDAppV2.bin index b53d34a684..b46669b67e 100644 --- a/pkg/contracts/testdappv2/TestDAppV2.bin +++ b/pkg/contracts/testdappv2/TestDAppV2.bin @@ -1 +1 @@ -6080604052348015600f57600080fd5b506115288061001f6000396000f3fe6080604052600436106100c65760003560e01c8063ad23b28b1161007f578063c9028a3611610059578063c9028a361461027b578063e2842ed7146102a4578063f592cbfb146102e1578063f936ae851461031e576100cd565b8063ad23b28b146101ea578063c7a339a914610227578063c85f843414610250576100cd565b806336e980a0146100d25780634297a263146100fb5780635bcfd61614610138578063676cc054146101615780639291fe2614610191578063a799911f146101ce576100cd565b366100cd57005b600080fd5b3480156100de57600080fd5b506100f960048036038101906100f49190610b86565b61035b565b005b34801561010757600080fd5b50610122600480360381019061011d9190610c05565b610385565b60405161012f9190610c4b565b60405180910390f35b34801561014457600080fd5b5061015f600480360381019061015a9190610d74565b61039d565b005b61017b60048036038101906101769190610e37565b610483565b6040516101889190610f16565b60405180910390f35b34801561019d57600080fd5b506101b860048036038101906101b39190610b86565b610595565b6040516101c59190610c4b565b60405180910390f35b6101e860048036038101906101e39190610b86565b6105d8565b005b3480156101f657600080fd5b50610211600480360381019061020c9190610f38565b610601565b60405161021e9190610fba565b60405180910390f35b34801561023357600080fd5b5061024e6004803603810190610249919061101a565b610661565b005b34801561025c57600080fd5b50610265610715565b6040516102729190610fba565b60405180910390f35b34801561028757600080fd5b506102a2600480360381019061029d91906110a8565b61074e565b005b3480156102b057600080fd5b506102cb60048036038101906102c69190610c05565b610888565b6040516102d8919061110c565b60405180910390f35b3480156102ed57600080fd5b5061030860048036038101906103039190610b86565b6108a8565b604051610315919061110c565b60405180910390f35b34801561032a57600080fd5b50610345600480360381019061034091906111c8565b6108f7565b6040516103529190611220565b60405180910390f35b61036481610940565b1561036e57600080fd5b61037781610996565b6103828160006109ea565b50565b60026020528060005260406000206000915090505481565b6103ea82828080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050610940565b156103f457600080fd5b600080838390501461044a5782828080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050610466565b6104658660200160208101906104609190610f38565b610601565b5b905061047181610996565b61047b81856109ea565b505050505050565b606060008084849050146104db5783838080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506104f7565b6104f68560000160208101906104f19190610f38565b610601565b5b905061050281610996565b61050c81346109ea565b84600001602081019061051f9190610f38565b60018260405161052f9190611277565b908152602001604051809103902060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550604051806020016040528060008152509150509392505050565b600060026000836040516020016105ac91906112ca565b604051602081830303815290604052805190602001208152602001908152602001600020549050919050565b6105e181610940565b156105eb57600080fd5b6105f481610996565b6105fe81346109ea565b50565b60606040518060400160405280601681526020017f63616c6c65642077697468206e6f206d657373616765000000000000000000008152508260405160200161064b929190611329565b6040516020818303038152906040529050919050565b61066a81610940565b1561067457600080fd5b8273ffffffffffffffffffffffffffffffffffffffff166323b872dd3330856040518463ffffffff1660e01b81526004016106b193929190611351565b6020604051808303816000875af11580156106d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f491906113b4565b6106fd57600080fd5b61070681610996565b61071081836109ea565b505050565b6040518060400160405280601681526020017f63616c6c65642077697468206e6f206d6573736167650000000000000000000081525081565b6107a981806060019061076191906113f0565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050610996565b6108068180606001906107bc91906113f0565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505060006109ea565b8060000160208101906108199190610f38565b600182806060019061082b91906113f0565b604051610839929190611478565b908152602001604051809103902060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60006020528060005260406000206000915054906101000a900460ff1681565b6000806000836040516020016108be91906112ca565b60405160208183030381529060405280519060200120815260200190815260200160002060009054906101000a900460ff169050919050565b6001818051602081018201805184825260208301602085012081835280955050505050506000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000604051602001610951906114dd565b604051602081830303815290604052805190602001208260405160200161097891906112ca565b60405160208183030381529060405280519060200120149050919050565b6001600080836040516020016109ac91906112ca565b60405160208183030381529060405280519060200120815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b806002600084604051602001610a0091906112ca565b604051602081830303815290604052805190602001208152602001908152602001600020819055505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610a9382610a4a565b810181811067ffffffffffffffff82111715610ab257610ab1610a5b565b5b80604052505050565b6000610ac5610a2c565b9050610ad18282610a8a565b919050565b600067ffffffffffffffff821115610af157610af0610a5b565b5b610afa82610a4a565b9050602081019050919050565b82818337600083830152505050565b6000610b29610b2484610ad6565b610abb565b905082815260208101848484011115610b4557610b44610a45565b5b610b50848285610b07565b509392505050565b600082601f830112610b6d57610b6c610a40565b5b8135610b7d848260208601610b16565b91505092915050565b600060208284031215610b9c57610b9b610a36565b5b600082013567ffffffffffffffff811115610bba57610bb9610a3b565b5b610bc684828501610b58565b91505092915050565b6000819050919050565b610be281610bcf565b8114610bed57600080fd5b50565b600081359050610bff81610bd9565b92915050565b600060208284031215610c1b57610c1a610a36565b5b6000610c2984828501610bf0565b91505092915050565b6000819050919050565b610c4581610c32565b82525050565b6000602082019050610c606000830184610c3c565b92915050565b600080fd5b600060608284031215610c8157610c80610c66565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610cb582610c8a565b9050919050565b610cc581610caa565b8114610cd057600080fd5b50565b600081359050610ce281610cbc565b92915050565b610cf181610c32565b8114610cfc57600080fd5b50565b600081359050610d0e81610ce8565b92915050565b600080fd5b600080fd5b60008083601f840112610d3457610d33610a40565b5b8235905067ffffffffffffffff811115610d5157610d50610d14565b5b602083019150836001820283011115610d6d57610d6c610d19565b5b9250929050565b600080600080600060808688031215610d9057610d8f610a36565b5b600086013567ffffffffffffffff811115610dae57610dad610a3b565b5b610dba88828901610c6b565b9550506020610dcb88828901610cd3565b9450506040610ddc88828901610cff565b935050606086013567ffffffffffffffff811115610dfd57610dfc610a3b565b5b610e0988828901610d1e565b92509250509295509295909350565b600060208284031215610e2e57610e2d610c66565b5b81905092915050565b600080600060408486031215610e5057610e4f610a36565b5b6000610e5e86828701610e18565b935050602084013567ffffffffffffffff811115610e7f57610e7e610a3b565b5b610e8b86828701610d1e565b92509250509250925092565b600081519050919050565b600082825260208201905092915050565b60005b83811015610ed1578082015181840152602081019050610eb6565b60008484015250505050565b6000610ee882610e97565b610ef28185610ea2565b9350610f02818560208601610eb3565b610f0b81610a4a565b840191505092915050565b60006020820190508181036000830152610f308184610edd565b905092915050565b600060208284031215610f4e57610f4d610a36565b5b6000610f5c84828501610cd3565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000610f8c82610f65565b610f968185610f70565b9350610fa6818560208601610eb3565b610faf81610a4a565b840191505092915050565b60006020820190508181036000830152610fd48184610f81565b905092915050565b6000610fe782610caa565b9050919050565b610ff781610fdc565b811461100257600080fd5b50565b60008135905061101481610fee565b92915050565b60008060006060848603121561103357611032610a36565b5b600061104186828701611005565b935050602061105286828701610cff565b925050604084013567ffffffffffffffff81111561107357611072610a3b565b5b61107f86828701610b58565b9150509250925092565b60006080828403121561109f5761109e610c66565b5b81905092915050565b6000602082840312156110be576110bd610a36565b5b600082013567ffffffffffffffff8111156110dc576110db610a3b565b5b6110e884828501611089565b91505092915050565b60008115159050919050565b611106816110f1565b82525050565b600060208201905061112160008301846110fd565b92915050565b600067ffffffffffffffff82111561114257611141610a5b565b5b61114b82610a4a565b9050602081019050919050565b600061116b61116684611127565b610abb565b90508281526020810184848401111561118757611186610a45565b5b611192848285610b07565b509392505050565b600082601f8301126111af576111ae610a40565b5b81356111bf848260208601611158565b91505092915050565b6000602082840312156111de576111dd610a36565b5b600082013567ffffffffffffffff8111156111fc576111fb610a3b565b5b6112088482850161119a565b91505092915050565b61121a81610caa565b82525050565b60006020820190506112356000830184611211565b92915050565b600081905092915050565b600061125182610e97565b61125b818561123b565b935061126b818560208601610eb3565b80840191505092915050565b60006112838284611246565b915081905092915050565b600081905092915050565b60006112a482610f65565b6112ae818561128e565b93506112be818560208601610eb3565b80840191505092915050565b60006112d68284611299565b915081905092915050565b60008160601b9050919050565b60006112f9826112e1565b9050919050565b600061130b826112ee565b9050919050565b61132361131e82610caa565b611300565b82525050565b60006113358285611299565b91506113418284611312565b6014820191508190509392505050565b60006060820190506113666000830186611211565b6113736020830185611211565b6113806040830184610c3c565b949350505050565b611391816110f1565b811461139c57600080fd5b50565b6000815190506113ae81611388565b92915050565b6000602082840312156113ca576113c9610a36565b5b60006113d88482850161139f565b91505092915050565b600080fd5b600080fd5b600080fd5b6000808335600160200384360303811261140d5761140c6113e1565b5b80840192508235915067ffffffffffffffff82111561142f5761142e6113e6565b5b60208301925060018202360383131561144b5761144a6113eb565b5b509250929050565b600061145f838561123b565b935061146c838584610b07565b82840190509392505050565b6000611485828486611453565b91508190509392505050565b7f7265766572740000000000000000000000000000000000000000000000000000600082015250565b60006114c760068361128e565b91506114d282611491565b600682019050919050565b60006114e8826114ba565b915081905091905056fea26469706673582212205747e512af435680fec20f1d2e088f93d6c12052fee7e353f45e5e49a671377b64736f6c634300081a0033 +60a0604052348015600f57600080fd5b506040516117953803806117958339818101604052810190602f91906078565b8015156080811515815250505060a0565b600080fd5b60008115159050919050565b6058816045565b8114606257600080fd5b50565b6000815190506072816051565b92915050565b600060208284031215608b57608a6040565b5b60006097848285016065565b91505092915050565b6080516116d36100c26000396000818161079601526108ff01526116d36000f3fe6080604052600436106100e15760003560e01c8063c7a339a91161007f578063c91f356711610059578063c91f3567146102bf578063e2842ed7146102ea578063f592cbfb14610327578063f936ae8514610364576100e8565b8063c7a339a914610242578063c85f84341461026b578063c9028a3614610296576100e8565b8063676cc054116100bb578063676cc0541461017c5780639291fe26146101ac578063a799911f146101e9578063ad23b28b14610205576100e8565b806336e980a0146100ed5780634297a263146101165780635bcfd61614610153576100e8565b366100e857005b600080fd5b3480156100f957600080fd5b50610114600480360381019061010f9190610cd1565b6103a1565b005b34801561012257600080fd5b5061013d60048036038101906101389190610d50565b6103cb565b60405161014a9190610d96565b60405180910390f35b34801561015f57600080fd5b5061017a60048036038101906101759190610ebf565b6103e3565b005b61019660048036038101906101919190610f82565b6104c9565b6040516101a39190611061565b60405180910390f35b3480156101b857600080fd5b506101d360048036038101906101ce9190610cd1565b6105db565b6040516101e09190610d96565b60405180910390f35b61020360048036038101906101fe9190610cd1565b61061e565b005b34801561021157600080fd5b5061022c60048036038101906102279190611083565b610647565b6040516102399190611105565b60405180910390f35b34801561024e57600080fd5b5061026960048036038101906102649190611165565b6106a7565b005b34801561027757600080fd5b5061028061075b565b60405161028d9190611105565b60405180910390f35b3480156102a257600080fd5b506102bd60048036038101906102b891906111f3565b610794565b005b3480156102cb57600080fd5b506102d46108fd565b6040516102e19190611257565b60405180910390f35b3480156102f657600080fd5b50610311600480360381019061030c9190610d50565b610921565b60405161031e9190611257565b60405180910390f35b34801561033357600080fd5b5061034e60048036038101906103499190610cd1565b610941565b60405161035b9190611257565b60405180910390f35b34801561037057600080fd5b5061038b60048036038101906103869190611313565b610991565b604051610398919061136b565b60405180910390f35b6103aa816109da565b156103b457600080fd5b6103bd81610a30565b6103c8816000610a84565b50565b60036020528060005260406000206000915090505481565b61043082828080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506109da565b1561043a57600080fd5b60008083839050146104905782828080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506104ac565b6104ab8660200160208101906104a69190611083565b610647565b5b90506104b781610a30565b6104c18185610a84565b505050505050565b606060008084849050146105215783838080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505061053d565b61053c8560000160208101906105379190611083565b610647565b5b905061054881610a30565b6105528134610a84565b8460000160208101906105659190611083565b60028260405161057591906113c2565b908152602001604051809103902060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550604051806020016040528060008152509150509392505050565b600060036000836040516020016105f29190611415565b604051602081830303815290604052805190602001208152602001908152602001600020549050919050565b610627816109da565b1561063157600080fd5b61063a81610a30565b6106448134610a84565b50565b60606040518060400160405280601681526020017f63616c6c65642077697468206e6f206d6573736167650000000000000000000081525082604051602001610691929190611474565b6040516020818303038152906040529050919050565b6106b0816109da565b156106ba57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff166323b872dd3330856040518463ffffffff1660e01b81526004016106f79392919061149c565b6020604051808303816000875af1158015610716573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073a91906114ff565b61074357600080fd5b61074c81610a30565b6107568183610a84565b505050565b6040518060400160405280601681526020017f63616c6c65642077697468206e6f206d6573736167650000000000000000000081525081565b7f0000000000000000000000000000000000000000000000000000000000000000156107c3576107c2610ac6565b5b61081e8180606001906107d6919061153b565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050610a30565b61087b818060600190610831919061153b565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506000610a84565b80600001602081019061088e9190611083565b60028280606001906108a0919061153b565b6040516108ae9291906115c3565b908152602001604051809103902060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60016020528060005260406000206000915054906101000a900460ff1681565b600060016000836040516020016109589190611415565b60405160208183030381529060405280519060200120815260200190815260200160002060009054906101000a900460ff169050919050565b6002818051602081018201805184825260208301602085012081835280955050505050506000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006040516020016109eb90611628565b6040516020818303038152906040528051906020012082604051602001610a129190611415565b60405160208183030381529060405280519060200120149050919050565b600180600083604051602001610a469190611415565b60405160208183030381529060405280519060200120815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b806003600084604051602001610a9a9190611415565b604051602081830303815290604052805190602001208152602001908152602001600020819055505050565b60006207a12090506000614e20905060008183610ae3919061166c565b905060005b81811015610b265760008190806001815401808255809150506001900390600052602060002001600090919091909150558080600101915050610ae8565b50600080610b349190610b39565b505050565b5080546000825590600052602060002090810190610b579190610b5a565b50565b5b80821115610b73576000816000905550600101610b5b565b5090565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610bde82610b95565b810181811067ffffffffffffffff82111715610bfd57610bfc610ba6565b5b80604052505050565b6000610c10610b77565b9050610c1c8282610bd5565b919050565b600067ffffffffffffffff821115610c3c57610c3b610ba6565b5b610c4582610b95565b9050602081019050919050565b82818337600083830152505050565b6000610c74610c6f84610c21565b610c06565b905082815260208101848484011115610c9057610c8f610b90565b5b610c9b848285610c52565b509392505050565b600082601f830112610cb857610cb7610b8b565b5b8135610cc8848260208601610c61565b91505092915050565b600060208284031215610ce757610ce6610b81565b5b600082013567ffffffffffffffff811115610d0557610d04610b86565b5b610d1184828501610ca3565b91505092915050565b6000819050919050565b610d2d81610d1a565b8114610d3857600080fd5b50565b600081359050610d4a81610d24565b92915050565b600060208284031215610d6657610d65610b81565b5b6000610d7484828501610d3b565b91505092915050565b6000819050919050565b610d9081610d7d565b82525050565b6000602082019050610dab6000830184610d87565b92915050565b600080fd5b600060608284031215610dcc57610dcb610db1565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610e0082610dd5565b9050919050565b610e1081610df5565b8114610e1b57600080fd5b50565b600081359050610e2d81610e07565b92915050565b610e3c81610d7d565b8114610e4757600080fd5b50565b600081359050610e5981610e33565b92915050565b600080fd5b600080fd5b60008083601f840112610e7f57610e7e610b8b565b5b8235905067ffffffffffffffff811115610e9c57610e9b610e5f565b5b602083019150836001820283011115610eb857610eb7610e64565b5b9250929050565b600080600080600060808688031215610edb57610eda610b81565b5b600086013567ffffffffffffffff811115610ef957610ef8610b86565b5b610f0588828901610db6565b9550506020610f1688828901610e1e565b9450506040610f2788828901610e4a565b935050606086013567ffffffffffffffff811115610f4857610f47610b86565b5b610f5488828901610e69565b92509250509295509295909350565b600060208284031215610f7957610f78610db1565b5b81905092915050565b600080600060408486031215610f9b57610f9a610b81565b5b6000610fa986828701610f63565b935050602084013567ffffffffffffffff811115610fca57610fc9610b86565b5b610fd686828701610e69565b92509250509250925092565b600081519050919050565b600082825260208201905092915050565b60005b8381101561101c578082015181840152602081019050611001565b60008484015250505050565b600061103382610fe2565b61103d8185610fed565b935061104d818560208601610ffe565b61105681610b95565b840191505092915050565b6000602082019050818103600083015261107b8184611028565b905092915050565b60006020828403121561109957611098610b81565b5b60006110a784828501610e1e565b91505092915050565b600081519050919050565b600082825260208201905092915050565b60006110d7826110b0565b6110e181856110bb565b93506110f1818560208601610ffe565b6110fa81610b95565b840191505092915050565b6000602082019050818103600083015261111f81846110cc565b905092915050565b600061113282610df5565b9050919050565b61114281611127565b811461114d57600080fd5b50565b60008135905061115f81611139565b92915050565b60008060006060848603121561117e5761117d610b81565b5b600061118c86828701611150565b935050602061119d86828701610e4a565b925050604084013567ffffffffffffffff8111156111be576111bd610b86565b5b6111ca86828701610ca3565b9150509250925092565b6000608082840312156111ea576111e9610db1565b5b81905092915050565b60006020828403121561120957611208610b81565b5b600082013567ffffffffffffffff81111561122757611226610b86565b5b611233848285016111d4565b91505092915050565b60008115159050919050565b6112518161123c565b82525050565b600060208201905061126c6000830184611248565b92915050565b600067ffffffffffffffff82111561128d5761128c610ba6565b5b61129682610b95565b9050602081019050919050565b60006112b66112b184611272565b610c06565b9050828152602081018484840111156112d2576112d1610b90565b5b6112dd848285610c52565b509392505050565b600082601f8301126112fa576112f9610b8b565b5b813561130a8482602086016112a3565b91505092915050565b60006020828403121561132957611328610b81565b5b600082013567ffffffffffffffff81111561134757611346610b86565b5b611353848285016112e5565b91505092915050565b61136581610df5565b82525050565b6000602082019050611380600083018461135c565b92915050565b600081905092915050565b600061139c82610fe2565b6113a68185611386565b93506113b6818560208601610ffe565b80840191505092915050565b60006113ce8284611391565b915081905092915050565b600081905092915050565b60006113ef826110b0565b6113f981856113d9565b9350611409818560208601610ffe565b80840191505092915050565b600061142182846113e4565b915081905092915050565b60008160601b9050919050565b60006114448261142c565b9050919050565b600061145682611439565b9050919050565b61146e61146982610df5565b61144b565b82525050565b600061148082856113e4565b915061148c828461145d565b6014820191508190509392505050565b60006060820190506114b1600083018661135c565b6114be602083018561135c565b6114cb6040830184610d87565b949350505050565b6114dc8161123c565b81146114e757600080fd5b50565b6000815190506114f9816114d3565b92915050565b60006020828403121561151557611514610b81565b5b6000611523848285016114ea565b91505092915050565b600080fd5b600080fd5b600080fd5b600080833560016020038436030381126115585761155761152c565b5b80840192508235915067ffffffffffffffff82111561157a57611579611531565b5b60208301925060018202360383131561159657611595611536565b5b509250929050565b60006115aa8385611386565b93506115b7838584610c52565b82840190509392505050565b60006115d082848661159e565b91508190509392505050565b7f7265766572740000000000000000000000000000000000000000000000000000600082015250565b60006116126006836113d9565b915061161d826115dc565b600682019050919050565b600061163382611605565b9150819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061167782610d7d565b915061168283610d7d565b9250826116925761169161163d565b5b82820490509291505056fea2646970667358221220eabca6f5232e330b7bfacfcaa51280bd616323d8694afc461b86845313fcbed364736f6c634300081a0033 diff --git a/pkg/contracts/testdappv2/TestDAppV2.go b/pkg/contracts/testdappv2/TestDAppV2.go index 7414aaccf2..aa825ebcce 100644 --- a/pkg/contracts/testdappv2/TestDAppV2.go +++ b/pkg/contracts/testdappv2/TestDAppV2.go @@ -51,8 +51,8 @@ type TestDAppV2zContext struct { // TestDAppV2MetaData contains all meta data concerning the TestDAppV2 contract. var TestDAppV2MetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"name\":\"NO_MESSAGE_CALL\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"amountWithMessage\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"calledWithMessage\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contractIERC20\",\"name\":\"erc20\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"erc20Call\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"gasCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"getAmountWithMessage\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"getCalledWithMessage\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"getNoMessageIndex\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes\",\"name\":\"origin\",\"type\":\"bytes\"},{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"}],\"internalType\":\"structTestDAppV2.zContext\",\"name\":\"_context\",\"type\":\"tuple\"},{\"internalType\":\"address\",\"name\":\"_zrc20\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"onCall\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"internalType\":\"structTestDAppV2.MessageContext\",\"name\":\"messageContext\",\"type\":\"tuple\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"onCall\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"revertMessage\",\"type\":\"bytes\"}],\"internalType\":\"structTestDAppV2.RevertContext\",\"name\":\"revertContext\",\"type\":\"tuple\"}],\"name\":\"onRevert\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"senderWithMessage\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"simpleCall\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", - Bin: "0x6080604052348015600f57600080fd5b506115288061001f6000396000f3fe6080604052600436106100c65760003560e01c8063ad23b28b1161007f578063c9028a3611610059578063c9028a361461027b578063e2842ed7146102a4578063f592cbfb146102e1578063f936ae851461031e576100cd565b8063ad23b28b146101ea578063c7a339a914610227578063c85f843414610250576100cd565b806336e980a0146100d25780634297a263146100fb5780635bcfd61614610138578063676cc054146101615780639291fe2614610191578063a799911f146101ce576100cd565b366100cd57005b600080fd5b3480156100de57600080fd5b506100f960048036038101906100f49190610b86565b61035b565b005b34801561010757600080fd5b50610122600480360381019061011d9190610c05565b610385565b60405161012f9190610c4b565b60405180910390f35b34801561014457600080fd5b5061015f600480360381019061015a9190610d74565b61039d565b005b61017b60048036038101906101769190610e37565b610483565b6040516101889190610f16565b60405180910390f35b34801561019d57600080fd5b506101b860048036038101906101b39190610b86565b610595565b6040516101c59190610c4b565b60405180910390f35b6101e860048036038101906101e39190610b86565b6105d8565b005b3480156101f657600080fd5b50610211600480360381019061020c9190610f38565b610601565b60405161021e9190610fba565b60405180910390f35b34801561023357600080fd5b5061024e6004803603810190610249919061101a565b610661565b005b34801561025c57600080fd5b50610265610715565b6040516102729190610fba565b60405180910390f35b34801561028757600080fd5b506102a2600480360381019061029d91906110a8565b61074e565b005b3480156102b057600080fd5b506102cb60048036038101906102c69190610c05565b610888565b6040516102d8919061110c565b60405180910390f35b3480156102ed57600080fd5b5061030860048036038101906103039190610b86565b6108a8565b604051610315919061110c565b60405180910390f35b34801561032a57600080fd5b50610345600480360381019061034091906111c8565b6108f7565b6040516103529190611220565b60405180910390f35b61036481610940565b1561036e57600080fd5b61037781610996565b6103828160006109ea565b50565b60026020528060005260406000206000915090505481565b6103ea82828080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050610940565b156103f457600080fd5b600080838390501461044a5782828080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050610466565b6104658660200160208101906104609190610f38565b610601565b5b905061047181610996565b61047b81856109ea565b505050505050565b606060008084849050146104db5783838080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506104f7565b6104f68560000160208101906104f19190610f38565b610601565b5b905061050281610996565b61050c81346109ea565b84600001602081019061051f9190610f38565b60018260405161052f9190611277565b908152602001604051809103902060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550604051806020016040528060008152509150509392505050565b600060026000836040516020016105ac91906112ca565b604051602081830303815290604052805190602001208152602001908152602001600020549050919050565b6105e181610940565b156105eb57600080fd5b6105f481610996565b6105fe81346109ea565b50565b60606040518060400160405280601681526020017f63616c6c65642077697468206e6f206d657373616765000000000000000000008152508260405160200161064b929190611329565b6040516020818303038152906040529050919050565b61066a81610940565b1561067457600080fd5b8273ffffffffffffffffffffffffffffffffffffffff166323b872dd3330856040518463ffffffff1660e01b81526004016106b193929190611351565b6020604051808303816000875af11580156106d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f491906113b4565b6106fd57600080fd5b61070681610996565b61071081836109ea565b505050565b6040518060400160405280601681526020017f63616c6c65642077697468206e6f206d6573736167650000000000000000000081525081565b6107a981806060019061076191906113f0565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050610996565b6108068180606001906107bc91906113f0565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505060006109ea565b8060000160208101906108199190610f38565b600182806060019061082b91906113f0565b604051610839929190611478565b908152602001604051809103902060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60006020528060005260406000206000915054906101000a900460ff1681565b6000806000836040516020016108be91906112ca565b60405160208183030381529060405280519060200120815260200190815260200160002060009054906101000a900460ff169050919050565b6001818051602081018201805184825260208301602085012081835280955050505050506000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000604051602001610951906114dd565b604051602081830303815290604052805190602001208260405160200161097891906112ca565b60405160208183030381529060405280519060200120149050919050565b6001600080836040516020016109ac91906112ca565b60405160208183030381529060405280519060200120815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b806002600084604051602001610a0091906112ca565b604051602081830303815290604052805190602001208152602001908152602001600020819055505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610a9382610a4a565b810181811067ffffffffffffffff82111715610ab257610ab1610a5b565b5b80604052505050565b6000610ac5610a2c565b9050610ad18282610a8a565b919050565b600067ffffffffffffffff821115610af157610af0610a5b565b5b610afa82610a4a565b9050602081019050919050565b82818337600083830152505050565b6000610b29610b2484610ad6565b610abb565b905082815260208101848484011115610b4557610b44610a45565b5b610b50848285610b07565b509392505050565b600082601f830112610b6d57610b6c610a40565b5b8135610b7d848260208601610b16565b91505092915050565b600060208284031215610b9c57610b9b610a36565b5b600082013567ffffffffffffffff811115610bba57610bb9610a3b565b5b610bc684828501610b58565b91505092915050565b6000819050919050565b610be281610bcf565b8114610bed57600080fd5b50565b600081359050610bff81610bd9565b92915050565b600060208284031215610c1b57610c1a610a36565b5b6000610c2984828501610bf0565b91505092915050565b6000819050919050565b610c4581610c32565b82525050565b6000602082019050610c606000830184610c3c565b92915050565b600080fd5b600060608284031215610c8157610c80610c66565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610cb582610c8a565b9050919050565b610cc581610caa565b8114610cd057600080fd5b50565b600081359050610ce281610cbc565b92915050565b610cf181610c32565b8114610cfc57600080fd5b50565b600081359050610d0e81610ce8565b92915050565b600080fd5b600080fd5b60008083601f840112610d3457610d33610a40565b5b8235905067ffffffffffffffff811115610d5157610d50610d14565b5b602083019150836001820283011115610d6d57610d6c610d19565b5b9250929050565b600080600080600060808688031215610d9057610d8f610a36565b5b600086013567ffffffffffffffff811115610dae57610dad610a3b565b5b610dba88828901610c6b565b9550506020610dcb88828901610cd3565b9450506040610ddc88828901610cff565b935050606086013567ffffffffffffffff811115610dfd57610dfc610a3b565b5b610e0988828901610d1e565b92509250509295509295909350565b600060208284031215610e2e57610e2d610c66565b5b81905092915050565b600080600060408486031215610e5057610e4f610a36565b5b6000610e5e86828701610e18565b935050602084013567ffffffffffffffff811115610e7f57610e7e610a3b565b5b610e8b86828701610d1e565b92509250509250925092565b600081519050919050565b600082825260208201905092915050565b60005b83811015610ed1578082015181840152602081019050610eb6565b60008484015250505050565b6000610ee882610e97565b610ef28185610ea2565b9350610f02818560208601610eb3565b610f0b81610a4a565b840191505092915050565b60006020820190508181036000830152610f308184610edd565b905092915050565b600060208284031215610f4e57610f4d610a36565b5b6000610f5c84828501610cd3565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000610f8c82610f65565b610f968185610f70565b9350610fa6818560208601610eb3565b610faf81610a4a565b840191505092915050565b60006020820190508181036000830152610fd48184610f81565b905092915050565b6000610fe782610caa565b9050919050565b610ff781610fdc565b811461100257600080fd5b50565b60008135905061101481610fee565b92915050565b60008060006060848603121561103357611032610a36565b5b600061104186828701611005565b935050602061105286828701610cff565b925050604084013567ffffffffffffffff81111561107357611072610a3b565b5b61107f86828701610b58565b9150509250925092565b60006080828403121561109f5761109e610c66565b5b81905092915050565b6000602082840312156110be576110bd610a36565b5b600082013567ffffffffffffffff8111156110dc576110db610a3b565b5b6110e884828501611089565b91505092915050565b60008115159050919050565b611106816110f1565b82525050565b600060208201905061112160008301846110fd565b92915050565b600067ffffffffffffffff82111561114257611141610a5b565b5b61114b82610a4a565b9050602081019050919050565b600061116b61116684611127565b610abb565b90508281526020810184848401111561118757611186610a45565b5b611192848285610b07565b509392505050565b600082601f8301126111af576111ae610a40565b5b81356111bf848260208601611158565b91505092915050565b6000602082840312156111de576111dd610a36565b5b600082013567ffffffffffffffff8111156111fc576111fb610a3b565b5b6112088482850161119a565b91505092915050565b61121a81610caa565b82525050565b60006020820190506112356000830184611211565b92915050565b600081905092915050565b600061125182610e97565b61125b818561123b565b935061126b818560208601610eb3565b80840191505092915050565b60006112838284611246565b915081905092915050565b600081905092915050565b60006112a482610f65565b6112ae818561128e565b93506112be818560208601610eb3565b80840191505092915050565b60006112d68284611299565b915081905092915050565b60008160601b9050919050565b60006112f9826112e1565b9050919050565b600061130b826112ee565b9050919050565b61132361131e82610caa565b611300565b82525050565b60006113358285611299565b91506113418284611312565b6014820191508190509392505050565b60006060820190506113666000830186611211565b6113736020830185611211565b6113806040830184610c3c565b949350505050565b611391816110f1565b811461139c57600080fd5b50565b6000815190506113ae81611388565b92915050565b6000602082840312156113ca576113c9610a36565b5b60006113d88482850161139f565b91505092915050565b600080fd5b600080fd5b600080fd5b6000808335600160200384360303811261140d5761140c6113e1565b5b80840192508235915067ffffffffffffffff82111561142f5761142e6113e6565b5b60208301925060018202360383131561144b5761144a6113eb565b5b509250929050565b600061145f838561123b565b935061146c838584610b07565b82840190509392505050565b6000611485828486611453565b91508190509392505050565b7f7265766572740000000000000000000000000000000000000000000000000000600082015250565b60006114c760068361128e565b91506114d282611491565b600682019050919050565b60006114e8826114ba565b915081905091905056fea26469706673582212205747e512af435680fec20f1d2e088f93d6c12052fee7e353f45e5e49a671377b64736f6c634300081a0033", + ABI: "[{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"isZetaChain_\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"NO_MESSAGE_CALL\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"amountWithMessage\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"calledWithMessage\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contractIERC20\",\"name\":\"erc20\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"erc20Call\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"gasCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"getAmountWithMessage\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"getCalledWithMessage\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"getNoMessageIndex\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isZetaChain\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes\",\"name\":\"origin\",\"type\":\"bytes\"},{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"}],\"internalType\":\"structTestDAppV2.zContext\",\"name\":\"_context\",\"type\":\"tuple\"},{\"internalType\":\"address\",\"name\":\"_zrc20\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"onCall\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"internalType\":\"structTestDAppV2.MessageContext\",\"name\":\"messageContext\",\"type\":\"tuple\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"onCall\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"revertMessage\",\"type\":\"bytes\"}],\"internalType\":\"structTestDAppV2.RevertContext\",\"name\":\"revertContext\",\"type\":\"tuple\"}],\"name\":\"onRevert\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"senderWithMessage\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"simpleCall\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", + Bin: "0x60a0604052348015600f57600080fd5b506040516117953803806117958339818101604052810190602f91906078565b8015156080811515815250505060a0565b600080fd5b60008115159050919050565b6058816045565b8114606257600080fd5b50565b6000815190506072816051565b92915050565b600060208284031215608b57608a6040565b5b60006097848285016065565b91505092915050565b6080516116d36100c26000396000818161079601526108ff01526116d36000f3fe6080604052600436106100e15760003560e01c8063c7a339a91161007f578063c91f356711610059578063c91f3567146102bf578063e2842ed7146102ea578063f592cbfb14610327578063f936ae8514610364576100e8565b8063c7a339a914610242578063c85f84341461026b578063c9028a3614610296576100e8565b8063676cc054116100bb578063676cc0541461017c5780639291fe26146101ac578063a799911f146101e9578063ad23b28b14610205576100e8565b806336e980a0146100ed5780634297a263146101165780635bcfd61614610153576100e8565b366100e857005b600080fd5b3480156100f957600080fd5b50610114600480360381019061010f9190610cd1565b6103a1565b005b34801561012257600080fd5b5061013d60048036038101906101389190610d50565b6103cb565b60405161014a9190610d96565b60405180910390f35b34801561015f57600080fd5b5061017a60048036038101906101759190610ebf565b6103e3565b005b61019660048036038101906101919190610f82565b6104c9565b6040516101a39190611061565b60405180910390f35b3480156101b857600080fd5b506101d360048036038101906101ce9190610cd1565b6105db565b6040516101e09190610d96565b60405180910390f35b61020360048036038101906101fe9190610cd1565b61061e565b005b34801561021157600080fd5b5061022c60048036038101906102279190611083565b610647565b6040516102399190611105565b60405180910390f35b34801561024e57600080fd5b5061026960048036038101906102649190611165565b6106a7565b005b34801561027757600080fd5b5061028061075b565b60405161028d9190611105565b60405180910390f35b3480156102a257600080fd5b506102bd60048036038101906102b891906111f3565b610794565b005b3480156102cb57600080fd5b506102d46108fd565b6040516102e19190611257565b60405180910390f35b3480156102f657600080fd5b50610311600480360381019061030c9190610d50565b610921565b60405161031e9190611257565b60405180910390f35b34801561033357600080fd5b5061034e60048036038101906103499190610cd1565b610941565b60405161035b9190611257565b60405180910390f35b34801561037057600080fd5b5061038b60048036038101906103869190611313565b610991565b604051610398919061136b565b60405180910390f35b6103aa816109da565b156103b457600080fd5b6103bd81610a30565b6103c8816000610a84565b50565b60036020528060005260406000206000915090505481565b61043082828080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506109da565b1561043a57600080fd5b60008083839050146104905782828080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506104ac565b6104ab8660200160208101906104a69190611083565b610647565b5b90506104b781610a30565b6104c18185610a84565b505050505050565b606060008084849050146105215783838080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505061053d565b61053c8560000160208101906105379190611083565b610647565b5b905061054881610a30565b6105528134610a84565b8460000160208101906105659190611083565b60028260405161057591906113c2565b908152602001604051809103902060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550604051806020016040528060008152509150509392505050565b600060036000836040516020016105f29190611415565b604051602081830303815290604052805190602001208152602001908152602001600020549050919050565b610627816109da565b1561063157600080fd5b61063a81610a30565b6106448134610a84565b50565b60606040518060400160405280601681526020017f63616c6c65642077697468206e6f206d6573736167650000000000000000000081525082604051602001610691929190611474565b6040516020818303038152906040529050919050565b6106b0816109da565b156106ba57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff166323b872dd3330856040518463ffffffff1660e01b81526004016106f79392919061149c565b6020604051808303816000875af1158015610716573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073a91906114ff565b61074357600080fd5b61074c81610a30565b6107568183610a84565b505050565b6040518060400160405280601681526020017f63616c6c65642077697468206e6f206d6573736167650000000000000000000081525081565b7f0000000000000000000000000000000000000000000000000000000000000000156107c3576107c2610ac6565b5b61081e8180606001906107d6919061153b565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050610a30565b61087b818060600190610831919061153b565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506000610a84565b80600001602081019061088e9190611083565b60028280606001906108a0919061153b565b6040516108ae9291906115c3565b908152602001604051809103902060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60016020528060005260406000206000915054906101000a900460ff1681565b600060016000836040516020016109589190611415565b60405160208183030381529060405280519060200120815260200190815260200160002060009054906101000a900460ff169050919050565b6002818051602081018201805184825260208301602085012081835280955050505050506000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006040516020016109eb90611628565b6040516020818303038152906040528051906020012082604051602001610a129190611415565b60405160208183030381529060405280519060200120149050919050565b600180600083604051602001610a469190611415565b60405160208183030381529060405280519060200120815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b806003600084604051602001610a9a9190611415565b604051602081830303815290604052805190602001208152602001908152602001600020819055505050565b60006207a12090506000614e20905060008183610ae3919061166c565b905060005b81811015610b265760008190806001815401808255809150506001900390600052602060002001600090919091909150558080600101915050610ae8565b50600080610b349190610b39565b505050565b5080546000825590600052602060002090810190610b579190610b5a565b50565b5b80821115610b73576000816000905550600101610b5b565b5090565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610bde82610b95565b810181811067ffffffffffffffff82111715610bfd57610bfc610ba6565b5b80604052505050565b6000610c10610b77565b9050610c1c8282610bd5565b919050565b600067ffffffffffffffff821115610c3c57610c3b610ba6565b5b610c4582610b95565b9050602081019050919050565b82818337600083830152505050565b6000610c74610c6f84610c21565b610c06565b905082815260208101848484011115610c9057610c8f610b90565b5b610c9b848285610c52565b509392505050565b600082601f830112610cb857610cb7610b8b565b5b8135610cc8848260208601610c61565b91505092915050565b600060208284031215610ce757610ce6610b81565b5b600082013567ffffffffffffffff811115610d0557610d04610b86565b5b610d1184828501610ca3565b91505092915050565b6000819050919050565b610d2d81610d1a565b8114610d3857600080fd5b50565b600081359050610d4a81610d24565b92915050565b600060208284031215610d6657610d65610b81565b5b6000610d7484828501610d3b565b91505092915050565b6000819050919050565b610d9081610d7d565b82525050565b6000602082019050610dab6000830184610d87565b92915050565b600080fd5b600060608284031215610dcc57610dcb610db1565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610e0082610dd5565b9050919050565b610e1081610df5565b8114610e1b57600080fd5b50565b600081359050610e2d81610e07565b92915050565b610e3c81610d7d565b8114610e4757600080fd5b50565b600081359050610e5981610e33565b92915050565b600080fd5b600080fd5b60008083601f840112610e7f57610e7e610b8b565b5b8235905067ffffffffffffffff811115610e9c57610e9b610e5f565b5b602083019150836001820283011115610eb857610eb7610e64565b5b9250929050565b600080600080600060808688031215610edb57610eda610b81565b5b600086013567ffffffffffffffff811115610ef957610ef8610b86565b5b610f0588828901610db6565b9550506020610f1688828901610e1e565b9450506040610f2788828901610e4a565b935050606086013567ffffffffffffffff811115610f4857610f47610b86565b5b610f5488828901610e69565b92509250509295509295909350565b600060208284031215610f7957610f78610db1565b5b81905092915050565b600080600060408486031215610f9b57610f9a610b81565b5b6000610fa986828701610f63565b935050602084013567ffffffffffffffff811115610fca57610fc9610b86565b5b610fd686828701610e69565b92509250509250925092565b600081519050919050565b600082825260208201905092915050565b60005b8381101561101c578082015181840152602081019050611001565b60008484015250505050565b600061103382610fe2565b61103d8185610fed565b935061104d818560208601610ffe565b61105681610b95565b840191505092915050565b6000602082019050818103600083015261107b8184611028565b905092915050565b60006020828403121561109957611098610b81565b5b60006110a784828501610e1e565b91505092915050565b600081519050919050565b600082825260208201905092915050565b60006110d7826110b0565b6110e181856110bb565b93506110f1818560208601610ffe565b6110fa81610b95565b840191505092915050565b6000602082019050818103600083015261111f81846110cc565b905092915050565b600061113282610df5565b9050919050565b61114281611127565b811461114d57600080fd5b50565b60008135905061115f81611139565b92915050565b60008060006060848603121561117e5761117d610b81565b5b600061118c86828701611150565b935050602061119d86828701610e4a565b925050604084013567ffffffffffffffff8111156111be576111bd610b86565b5b6111ca86828701610ca3565b9150509250925092565b6000608082840312156111ea576111e9610db1565b5b81905092915050565b60006020828403121561120957611208610b81565b5b600082013567ffffffffffffffff81111561122757611226610b86565b5b611233848285016111d4565b91505092915050565b60008115159050919050565b6112518161123c565b82525050565b600060208201905061126c6000830184611248565b92915050565b600067ffffffffffffffff82111561128d5761128c610ba6565b5b61129682610b95565b9050602081019050919050565b60006112b66112b184611272565b610c06565b9050828152602081018484840111156112d2576112d1610b90565b5b6112dd848285610c52565b509392505050565b600082601f8301126112fa576112f9610b8b565b5b813561130a8482602086016112a3565b91505092915050565b60006020828403121561132957611328610b81565b5b600082013567ffffffffffffffff81111561134757611346610b86565b5b611353848285016112e5565b91505092915050565b61136581610df5565b82525050565b6000602082019050611380600083018461135c565b92915050565b600081905092915050565b600061139c82610fe2565b6113a68185611386565b93506113b6818560208601610ffe565b80840191505092915050565b60006113ce8284611391565b915081905092915050565b600081905092915050565b60006113ef826110b0565b6113f981856113d9565b9350611409818560208601610ffe565b80840191505092915050565b600061142182846113e4565b915081905092915050565b60008160601b9050919050565b60006114448261142c565b9050919050565b600061145682611439565b9050919050565b61146e61146982610df5565b61144b565b82525050565b600061148082856113e4565b915061148c828461145d565b6014820191508190509392505050565b60006060820190506114b1600083018661135c565b6114be602083018561135c565b6114cb6040830184610d87565b949350505050565b6114dc8161123c565b81146114e757600080fd5b50565b6000815190506114f9816114d3565b92915050565b60006020828403121561151557611514610b81565b5b6000611523848285016114ea565b91505092915050565b600080fd5b600080fd5b600080fd5b600080833560016020038436030381126115585761155761152c565b5b80840192508235915067ffffffffffffffff82111561157a57611579611531565b5b60208301925060018202360383131561159657611595611536565b5b509250929050565b60006115aa8385611386565b93506115b7838584610c52565b82840190509392505050565b60006115d082848661159e565b91508190509392505050565b7f7265766572740000000000000000000000000000000000000000000000000000600082015250565b60006116126006836113d9565b915061161d826115dc565b600682019050919050565b600061163382611605565b9150819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061167782610d7d565b915061168283610d7d565b9250826116925761169161163d565b5b82820490509291505056fea2646970667358221220eabca6f5232e330b7bfacfcaa51280bd616323d8694afc461b86845313fcbed364736f6c634300081a0033", } // TestDAppV2ABI is the input ABI used to generate the binding from. @@ -64,7 +64,7 @@ var TestDAppV2ABI = TestDAppV2MetaData.ABI var TestDAppV2Bin = TestDAppV2MetaData.Bin // DeployTestDAppV2 deploys a new Ethereum contract, binding an instance of TestDAppV2 to it. -func DeployTestDAppV2(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *TestDAppV2, error) { +func DeployTestDAppV2(auth *bind.TransactOpts, backend bind.ContractBackend, isZetaChain_ bool) (common.Address, *types.Transaction, *TestDAppV2, error) { parsed, err := TestDAppV2MetaData.GetAbi() if err != nil { return common.Address{}, nil, nil, err @@ -73,7 +73,7 @@ func DeployTestDAppV2(auth *bind.TransactOpts, backend bind.ContractBackend) (co return common.Address{}, nil, nil, errors.New("GetABI returned nil") } - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(TestDAppV2Bin), backend) + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(TestDAppV2Bin), backend, isZetaChain_) if err != nil { return common.Address{}, nil, nil, err } @@ -408,6 +408,37 @@ func (_TestDAppV2 *TestDAppV2CallerSession) GetNoMessageIndex(sender common.Addr return _TestDAppV2.Contract.GetNoMessageIndex(&_TestDAppV2.CallOpts, sender) } +// IsZetaChain is a free data retrieval call binding the contract method 0xc91f3567. +// +// Solidity: function isZetaChain() view returns(bool) +func (_TestDAppV2 *TestDAppV2Caller) IsZetaChain(opts *bind.CallOpts) (bool, error) { + var out []interface{} + err := _TestDAppV2.contract.Call(opts, &out, "isZetaChain") + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// IsZetaChain is a free data retrieval call binding the contract method 0xc91f3567. +// +// Solidity: function isZetaChain() view returns(bool) +func (_TestDAppV2 *TestDAppV2Session) IsZetaChain() (bool, error) { + return _TestDAppV2.Contract.IsZetaChain(&_TestDAppV2.CallOpts) +} + +// IsZetaChain is a free data retrieval call binding the contract method 0xc91f3567. +// +// Solidity: function isZetaChain() view returns(bool) +func (_TestDAppV2 *TestDAppV2CallerSession) IsZetaChain() (bool, error) { + return _TestDAppV2.Contract.IsZetaChain(&_TestDAppV2.CallOpts) +} + // SenderWithMessage is a free data retrieval call binding the contract method 0xf936ae85. // // Solidity: function senderWithMessage(bytes ) view returns(address) diff --git a/pkg/contracts/testdappv2/TestDAppV2.json b/pkg/contracts/testdappv2/TestDAppV2.json index 189d8b853f..9e3e79499c 100644 --- a/pkg/contracts/testdappv2/TestDAppV2.json +++ b/pkg/contracts/testdappv2/TestDAppV2.json @@ -1,5 +1,16 @@ { "abi": [ + { + "inputs": [ + { + "internalType": "bool", + "name": "isZetaChain_", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, { "inputs": [], "name": "NO_MESSAGE_CALL", @@ -144,6 +155,19 @@ "stateMutability": "pure", "type": "function" }, + { + "inputs": [], + "name": "isZetaChain", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { @@ -292,5 +316,5 @@ "type": "receive" } ], - "bin": "6080604052348015600f57600080fd5b506115288061001f6000396000f3fe6080604052600436106100c65760003560e01c8063ad23b28b1161007f578063c9028a3611610059578063c9028a361461027b578063e2842ed7146102a4578063f592cbfb146102e1578063f936ae851461031e576100cd565b8063ad23b28b146101ea578063c7a339a914610227578063c85f843414610250576100cd565b806336e980a0146100d25780634297a263146100fb5780635bcfd61614610138578063676cc054146101615780639291fe2614610191578063a799911f146101ce576100cd565b366100cd57005b600080fd5b3480156100de57600080fd5b506100f960048036038101906100f49190610b86565b61035b565b005b34801561010757600080fd5b50610122600480360381019061011d9190610c05565b610385565b60405161012f9190610c4b565b60405180910390f35b34801561014457600080fd5b5061015f600480360381019061015a9190610d74565b61039d565b005b61017b60048036038101906101769190610e37565b610483565b6040516101889190610f16565b60405180910390f35b34801561019d57600080fd5b506101b860048036038101906101b39190610b86565b610595565b6040516101c59190610c4b565b60405180910390f35b6101e860048036038101906101e39190610b86565b6105d8565b005b3480156101f657600080fd5b50610211600480360381019061020c9190610f38565b610601565b60405161021e9190610fba565b60405180910390f35b34801561023357600080fd5b5061024e6004803603810190610249919061101a565b610661565b005b34801561025c57600080fd5b50610265610715565b6040516102729190610fba565b60405180910390f35b34801561028757600080fd5b506102a2600480360381019061029d91906110a8565b61074e565b005b3480156102b057600080fd5b506102cb60048036038101906102c69190610c05565b610888565b6040516102d8919061110c565b60405180910390f35b3480156102ed57600080fd5b5061030860048036038101906103039190610b86565b6108a8565b604051610315919061110c565b60405180910390f35b34801561032a57600080fd5b50610345600480360381019061034091906111c8565b6108f7565b6040516103529190611220565b60405180910390f35b61036481610940565b1561036e57600080fd5b61037781610996565b6103828160006109ea565b50565b60026020528060005260406000206000915090505481565b6103ea82828080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050610940565b156103f457600080fd5b600080838390501461044a5782828080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050610466565b6104658660200160208101906104609190610f38565b610601565b5b905061047181610996565b61047b81856109ea565b505050505050565b606060008084849050146104db5783838080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506104f7565b6104f68560000160208101906104f19190610f38565b610601565b5b905061050281610996565b61050c81346109ea565b84600001602081019061051f9190610f38565b60018260405161052f9190611277565b908152602001604051809103902060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550604051806020016040528060008152509150509392505050565b600060026000836040516020016105ac91906112ca565b604051602081830303815290604052805190602001208152602001908152602001600020549050919050565b6105e181610940565b156105eb57600080fd5b6105f481610996565b6105fe81346109ea565b50565b60606040518060400160405280601681526020017f63616c6c65642077697468206e6f206d657373616765000000000000000000008152508260405160200161064b929190611329565b6040516020818303038152906040529050919050565b61066a81610940565b1561067457600080fd5b8273ffffffffffffffffffffffffffffffffffffffff166323b872dd3330856040518463ffffffff1660e01b81526004016106b193929190611351565b6020604051808303816000875af11580156106d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f491906113b4565b6106fd57600080fd5b61070681610996565b61071081836109ea565b505050565b6040518060400160405280601681526020017f63616c6c65642077697468206e6f206d6573736167650000000000000000000081525081565b6107a981806060019061076191906113f0565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050610996565b6108068180606001906107bc91906113f0565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505060006109ea565b8060000160208101906108199190610f38565b600182806060019061082b91906113f0565b604051610839929190611478565b908152602001604051809103902060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60006020528060005260406000206000915054906101000a900460ff1681565b6000806000836040516020016108be91906112ca565b60405160208183030381529060405280519060200120815260200190815260200160002060009054906101000a900460ff169050919050565b6001818051602081018201805184825260208301602085012081835280955050505050506000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000604051602001610951906114dd565b604051602081830303815290604052805190602001208260405160200161097891906112ca565b60405160208183030381529060405280519060200120149050919050565b6001600080836040516020016109ac91906112ca565b60405160208183030381529060405280519060200120815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b806002600084604051602001610a0091906112ca565b604051602081830303815290604052805190602001208152602001908152602001600020819055505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610a9382610a4a565b810181811067ffffffffffffffff82111715610ab257610ab1610a5b565b5b80604052505050565b6000610ac5610a2c565b9050610ad18282610a8a565b919050565b600067ffffffffffffffff821115610af157610af0610a5b565b5b610afa82610a4a565b9050602081019050919050565b82818337600083830152505050565b6000610b29610b2484610ad6565b610abb565b905082815260208101848484011115610b4557610b44610a45565b5b610b50848285610b07565b509392505050565b600082601f830112610b6d57610b6c610a40565b5b8135610b7d848260208601610b16565b91505092915050565b600060208284031215610b9c57610b9b610a36565b5b600082013567ffffffffffffffff811115610bba57610bb9610a3b565b5b610bc684828501610b58565b91505092915050565b6000819050919050565b610be281610bcf565b8114610bed57600080fd5b50565b600081359050610bff81610bd9565b92915050565b600060208284031215610c1b57610c1a610a36565b5b6000610c2984828501610bf0565b91505092915050565b6000819050919050565b610c4581610c32565b82525050565b6000602082019050610c606000830184610c3c565b92915050565b600080fd5b600060608284031215610c8157610c80610c66565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610cb582610c8a565b9050919050565b610cc581610caa565b8114610cd057600080fd5b50565b600081359050610ce281610cbc565b92915050565b610cf181610c32565b8114610cfc57600080fd5b50565b600081359050610d0e81610ce8565b92915050565b600080fd5b600080fd5b60008083601f840112610d3457610d33610a40565b5b8235905067ffffffffffffffff811115610d5157610d50610d14565b5b602083019150836001820283011115610d6d57610d6c610d19565b5b9250929050565b600080600080600060808688031215610d9057610d8f610a36565b5b600086013567ffffffffffffffff811115610dae57610dad610a3b565b5b610dba88828901610c6b565b9550506020610dcb88828901610cd3565b9450506040610ddc88828901610cff565b935050606086013567ffffffffffffffff811115610dfd57610dfc610a3b565b5b610e0988828901610d1e565b92509250509295509295909350565b600060208284031215610e2e57610e2d610c66565b5b81905092915050565b600080600060408486031215610e5057610e4f610a36565b5b6000610e5e86828701610e18565b935050602084013567ffffffffffffffff811115610e7f57610e7e610a3b565b5b610e8b86828701610d1e565b92509250509250925092565b600081519050919050565b600082825260208201905092915050565b60005b83811015610ed1578082015181840152602081019050610eb6565b60008484015250505050565b6000610ee882610e97565b610ef28185610ea2565b9350610f02818560208601610eb3565b610f0b81610a4a565b840191505092915050565b60006020820190508181036000830152610f308184610edd565b905092915050565b600060208284031215610f4e57610f4d610a36565b5b6000610f5c84828501610cd3565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000610f8c82610f65565b610f968185610f70565b9350610fa6818560208601610eb3565b610faf81610a4a565b840191505092915050565b60006020820190508181036000830152610fd48184610f81565b905092915050565b6000610fe782610caa565b9050919050565b610ff781610fdc565b811461100257600080fd5b50565b60008135905061101481610fee565b92915050565b60008060006060848603121561103357611032610a36565b5b600061104186828701611005565b935050602061105286828701610cff565b925050604084013567ffffffffffffffff81111561107357611072610a3b565b5b61107f86828701610b58565b9150509250925092565b60006080828403121561109f5761109e610c66565b5b81905092915050565b6000602082840312156110be576110bd610a36565b5b600082013567ffffffffffffffff8111156110dc576110db610a3b565b5b6110e884828501611089565b91505092915050565b60008115159050919050565b611106816110f1565b82525050565b600060208201905061112160008301846110fd565b92915050565b600067ffffffffffffffff82111561114257611141610a5b565b5b61114b82610a4a565b9050602081019050919050565b600061116b61116684611127565b610abb565b90508281526020810184848401111561118757611186610a45565b5b611192848285610b07565b509392505050565b600082601f8301126111af576111ae610a40565b5b81356111bf848260208601611158565b91505092915050565b6000602082840312156111de576111dd610a36565b5b600082013567ffffffffffffffff8111156111fc576111fb610a3b565b5b6112088482850161119a565b91505092915050565b61121a81610caa565b82525050565b60006020820190506112356000830184611211565b92915050565b600081905092915050565b600061125182610e97565b61125b818561123b565b935061126b818560208601610eb3565b80840191505092915050565b60006112838284611246565b915081905092915050565b600081905092915050565b60006112a482610f65565b6112ae818561128e565b93506112be818560208601610eb3565b80840191505092915050565b60006112d68284611299565b915081905092915050565b60008160601b9050919050565b60006112f9826112e1565b9050919050565b600061130b826112ee565b9050919050565b61132361131e82610caa565b611300565b82525050565b60006113358285611299565b91506113418284611312565b6014820191508190509392505050565b60006060820190506113666000830186611211565b6113736020830185611211565b6113806040830184610c3c565b949350505050565b611391816110f1565b811461139c57600080fd5b50565b6000815190506113ae81611388565b92915050565b6000602082840312156113ca576113c9610a36565b5b60006113d88482850161139f565b91505092915050565b600080fd5b600080fd5b600080fd5b6000808335600160200384360303811261140d5761140c6113e1565b5b80840192508235915067ffffffffffffffff82111561142f5761142e6113e6565b5b60208301925060018202360383131561144b5761144a6113eb565b5b509250929050565b600061145f838561123b565b935061146c838584610b07565b82840190509392505050565b6000611485828486611453565b91508190509392505050565b7f7265766572740000000000000000000000000000000000000000000000000000600082015250565b60006114c760068361128e565b91506114d282611491565b600682019050919050565b60006114e8826114ba565b915081905091905056fea26469706673582212205747e512af435680fec20f1d2e088f93d6c12052fee7e353f45e5e49a671377b64736f6c634300081a0033" + "bin": "60a0604052348015600f57600080fd5b506040516117953803806117958339818101604052810190602f91906078565b8015156080811515815250505060a0565b600080fd5b60008115159050919050565b6058816045565b8114606257600080fd5b50565b6000815190506072816051565b92915050565b600060208284031215608b57608a6040565b5b60006097848285016065565b91505092915050565b6080516116d36100c26000396000818161079601526108ff01526116d36000f3fe6080604052600436106100e15760003560e01c8063c7a339a91161007f578063c91f356711610059578063c91f3567146102bf578063e2842ed7146102ea578063f592cbfb14610327578063f936ae8514610364576100e8565b8063c7a339a914610242578063c85f84341461026b578063c9028a3614610296576100e8565b8063676cc054116100bb578063676cc0541461017c5780639291fe26146101ac578063a799911f146101e9578063ad23b28b14610205576100e8565b806336e980a0146100ed5780634297a263146101165780635bcfd61614610153576100e8565b366100e857005b600080fd5b3480156100f957600080fd5b50610114600480360381019061010f9190610cd1565b6103a1565b005b34801561012257600080fd5b5061013d60048036038101906101389190610d50565b6103cb565b60405161014a9190610d96565b60405180910390f35b34801561015f57600080fd5b5061017a60048036038101906101759190610ebf565b6103e3565b005b61019660048036038101906101919190610f82565b6104c9565b6040516101a39190611061565b60405180910390f35b3480156101b857600080fd5b506101d360048036038101906101ce9190610cd1565b6105db565b6040516101e09190610d96565b60405180910390f35b61020360048036038101906101fe9190610cd1565b61061e565b005b34801561021157600080fd5b5061022c60048036038101906102279190611083565b610647565b6040516102399190611105565b60405180910390f35b34801561024e57600080fd5b5061026960048036038101906102649190611165565b6106a7565b005b34801561027757600080fd5b5061028061075b565b60405161028d9190611105565b60405180910390f35b3480156102a257600080fd5b506102bd60048036038101906102b891906111f3565b610794565b005b3480156102cb57600080fd5b506102d46108fd565b6040516102e19190611257565b60405180910390f35b3480156102f657600080fd5b50610311600480360381019061030c9190610d50565b610921565b60405161031e9190611257565b60405180910390f35b34801561033357600080fd5b5061034e60048036038101906103499190610cd1565b610941565b60405161035b9190611257565b60405180910390f35b34801561037057600080fd5b5061038b60048036038101906103869190611313565b610991565b604051610398919061136b565b60405180910390f35b6103aa816109da565b156103b457600080fd5b6103bd81610a30565b6103c8816000610a84565b50565b60036020528060005260406000206000915090505481565b61043082828080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506109da565b1561043a57600080fd5b60008083839050146104905782828080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506104ac565b6104ab8660200160208101906104a69190611083565b610647565b5b90506104b781610a30565b6104c18185610a84565b505050505050565b606060008084849050146105215783838080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505061053d565b61053c8560000160208101906105379190611083565b610647565b5b905061054881610a30565b6105528134610a84565b8460000160208101906105659190611083565b60028260405161057591906113c2565b908152602001604051809103902060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550604051806020016040528060008152509150509392505050565b600060036000836040516020016105f29190611415565b604051602081830303815290604052805190602001208152602001908152602001600020549050919050565b610627816109da565b1561063157600080fd5b61063a81610a30565b6106448134610a84565b50565b60606040518060400160405280601681526020017f63616c6c65642077697468206e6f206d6573736167650000000000000000000081525082604051602001610691929190611474565b6040516020818303038152906040529050919050565b6106b0816109da565b156106ba57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff166323b872dd3330856040518463ffffffff1660e01b81526004016106f79392919061149c565b6020604051808303816000875af1158015610716573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073a91906114ff565b61074357600080fd5b61074c81610a30565b6107568183610a84565b505050565b6040518060400160405280601681526020017f63616c6c65642077697468206e6f206d6573736167650000000000000000000081525081565b7f0000000000000000000000000000000000000000000000000000000000000000156107c3576107c2610ac6565b5b61081e8180606001906107d6919061153b565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050610a30565b61087b818060600190610831919061153b565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506000610a84565b80600001602081019061088e9190611083565b60028280606001906108a0919061153b565b6040516108ae9291906115c3565b908152602001604051809103902060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60016020528060005260406000206000915054906101000a900460ff1681565b600060016000836040516020016109589190611415565b60405160208183030381529060405280519060200120815260200190815260200160002060009054906101000a900460ff169050919050565b6002818051602081018201805184825260208301602085012081835280955050505050506000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006040516020016109eb90611628565b6040516020818303038152906040528051906020012082604051602001610a129190611415565b60405160208183030381529060405280519060200120149050919050565b600180600083604051602001610a469190611415565b60405160208183030381529060405280519060200120815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b806003600084604051602001610a9a9190611415565b604051602081830303815290604052805190602001208152602001908152602001600020819055505050565b60006207a12090506000614e20905060008183610ae3919061166c565b905060005b81811015610b265760008190806001815401808255809150506001900390600052602060002001600090919091909150558080600101915050610ae8565b50600080610b349190610b39565b505050565b5080546000825590600052602060002090810190610b579190610b5a565b50565b5b80821115610b73576000816000905550600101610b5b565b5090565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610bde82610b95565b810181811067ffffffffffffffff82111715610bfd57610bfc610ba6565b5b80604052505050565b6000610c10610b77565b9050610c1c8282610bd5565b919050565b600067ffffffffffffffff821115610c3c57610c3b610ba6565b5b610c4582610b95565b9050602081019050919050565b82818337600083830152505050565b6000610c74610c6f84610c21565b610c06565b905082815260208101848484011115610c9057610c8f610b90565b5b610c9b848285610c52565b509392505050565b600082601f830112610cb857610cb7610b8b565b5b8135610cc8848260208601610c61565b91505092915050565b600060208284031215610ce757610ce6610b81565b5b600082013567ffffffffffffffff811115610d0557610d04610b86565b5b610d1184828501610ca3565b91505092915050565b6000819050919050565b610d2d81610d1a565b8114610d3857600080fd5b50565b600081359050610d4a81610d24565b92915050565b600060208284031215610d6657610d65610b81565b5b6000610d7484828501610d3b565b91505092915050565b6000819050919050565b610d9081610d7d565b82525050565b6000602082019050610dab6000830184610d87565b92915050565b600080fd5b600060608284031215610dcc57610dcb610db1565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610e0082610dd5565b9050919050565b610e1081610df5565b8114610e1b57600080fd5b50565b600081359050610e2d81610e07565b92915050565b610e3c81610d7d565b8114610e4757600080fd5b50565b600081359050610e5981610e33565b92915050565b600080fd5b600080fd5b60008083601f840112610e7f57610e7e610b8b565b5b8235905067ffffffffffffffff811115610e9c57610e9b610e5f565b5b602083019150836001820283011115610eb857610eb7610e64565b5b9250929050565b600080600080600060808688031215610edb57610eda610b81565b5b600086013567ffffffffffffffff811115610ef957610ef8610b86565b5b610f0588828901610db6565b9550506020610f1688828901610e1e565b9450506040610f2788828901610e4a565b935050606086013567ffffffffffffffff811115610f4857610f47610b86565b5b610f5488828901610e69565b92509250509295509295909350565b600060208284031215610f7957610f78610db1565b5b81905092915050565b600080600060408486031215610f9b57610f9a610b81565b5b6000610fa986828701610f63565b935050602084013567ffffffffffffffff811115610fca57610fc9610b86565b5b610fd686828701610e69565b92509250509250925092565b600081519050919050565b600082825260208201905092915050565b60005b8381101561101c578082015181840152602081019050611001565b60008484015250505050565b600061103382610fe2565b61103d8185610fed565b935061104d818560208601610ffe565b61105681610b95565b840191505092915050565b6000602082019050818103600083015261107b8184611028565b905092915050565b60006020828403121561109957611098610b81565b5b60006110a784828501610e1e565b91505092915050565b600081519050919050565b600082825260208201905092915050565b60006110d7826110b0565b6110e181856110bb565b93506110f1818560208601610ffe565b6110fa81610b95565b840191505092915050565b6000602082019050818103600083015261111f81846110cc565b905092915050565b600061113282610df5565b9050919050565b61114281611127565b811461114d57600080fd5b50565b60008135905061115f81611139565b92915050565b60008060006060848603121561117e5761117d610b81565b5b600061118c86828701611150565b935050602061119d86828701610e4a565b925050604084013567ffffffffffffffff8111156111be576111bd610b86565b5b6111ca86828701610ca3565b9150509250925092565b6000608082840312156111ea576111e9610db1565b5b81905092915050565b60006020828403121561120957611208610b81565b5b600082013567ffffffffffffffff81111561122757611226610b86565b5b611233848285016111d4565b91505092915050565b60008115159050919050565b6112518161123c565b82525050565b600060208201905061126c6000830184611248565b92915050565b600067ffffffffffffffff82111561128d5761128c610ba6565b5b61129682610b95565b9050602081019050919050565b60006112b66112b184611272565b610c06565b9050828152602081018484840111156112d2576112d1610b90565b5b6112dd848285610c52565b509392505050565b600082601f8301126112fa576112f9610b8b565b5b813561130a8482602086016112a3565b91505092915050565b60006020828403121561132957611328610b81565b5b600082013567ffffffffffffffff81111561134757611346610b86565b5b611353848285016112e5565b91505092915050565b61136581610df5565b82525050565b6000602082019050611380600083018461135c565b92915050565b600081905092915050565b600061139c82610fe2565b6113a68185611386565b93506113b6818560208601610ffe565b80840191505092915050565b60006113ce8284611391565b915081905092915050565b600081905092915050565b60006113ef826110b0565b6113f981856113d9565b9350611409818560208601610ffe565b80840191505092915050565b600061142182846113e4565b915081905092915050565b60008160601b9050919050565b60006114448261142c565b9050919050565b600061145682611439565b9050919050565b61146e61146982610df5565b61144b565b82525050565b600061148082856113e4565b915061148c828461145d565b6014820191508190509392505050565b60006060820190506114b1600083018661135c565b6114be602083018561135c565b6114cb6040830184610d87565b949350505050565b6114dc8161123c565b81146114e757600080fd5b50565b6000815190506114f9816114d3565b92915050565b60006020828403121561151557611514610b81565b5b6000611523848285016114ea565b91505092915050565b600080fd5b600080fd5b600080fd5b600080833560016020038436030381126115585761155761152c565b5b80840192508235915067ffffffffffffffff82111561157a57611579611531565b5b60208301925060018202360383131561159657611595611536565b5b509250929050565b60006115aa8385611386565b93506115b7838584610c52565b82840190509392505050565b60006115d082848661159e565b91508190509392505050565b7f7265766572740000000000000000000000000000000000000000000000000000600082015250565b60006116126006836113d9565b915061161d826115dc565b600682019050919050565b600061163382611605565b9150819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061167782610d7d565b915061168283610d7d565b9250826116925761169161163d565b5b82820490509291505056fea2646970667358221220eabca6f5232e330b7bfacfcaa51280bd616323d8694afc461b86845313fcbed364736f6c634300081a0033" } diff --git a/pkg/contracts/testdappv2/TestDAppV2.sol b/pkg/contracts/testdappv2/TestDAppV2.sol index 3282cbe383..bf0f5887a4 100644 --- a/pkg/contracts/testdappv2/TestDAppV2.sol +++ b/pkg/contracts/testdappv2/TestDAppV2.sol @@ -6,8 +6,14 @@ interface IERC20 { } contract TestDAppV2 { + // used to simulate gas consumption + uint256[] private storageArray; + string public constant NO_MESSAGE_CALL = "called with no message"; + // define if the chain is ZetaChain + bool immutable public isZetaChain; + struct zContext { bytes origin; address sender; @@ -37,6 +43,11 @@ contract TestDAppV2 { mapping(bytes => address) public senderWithMessage; mapping(bytes32 => uint256) public amountWithMessage; + // the constructor is used to determine if the chain is ZetaChain + constructor(bool isZetaChain_) { + isZetaChain = isZetaChain_; + } + // return the index used for the "WithMessage" mapping when the message for calls is empty // this allows testing the message with empty message // this function includes the sender of the message to avoid collisions when running parallel tests with different senders @@ -110,6 +121,13 @@ contract TestDAppV2 { // Revertable interface function onRevert(RevertContext calldata revertContext) external { + + // if the chain is ZetaChain, consume gas to test the gas consumption + // we do it specifically for ZetaChain to test the outbound processing workflow + if (isZetaChain) { + consumeGas(); + } + setCalledWithMessage(string(revertContext.revertMessage)); setAmountWithMessage(string(revertContext.revertMessage), 0); senderWithMessage[revertContext.revertMessage] = revertContext.sender; @@ -126,5 +144,21 @@ contract TestDAppV2 { return ""; } + function consumeGas() internal { + // Approximate target gas consumption + uint256 targetGas = 500000; + // Approximate gas cost for a single storage write + uint256 storageWriteGasCost = 20000; + uint256 iterations = targetGas / storageWriteGasCost; + + // Perform the storage writes + for (uint256 i = 0; i < iterations; i++) { + storageArray.push(i); + } + + // Reset the storage array to avoid accumulation of storage cost + delete storageArray; + } + receive() external payable {} } \ No newline at end of file diff --git a/x/fungible/keeper/v2_deposits_test.go b/x/fungible/keeper/v2_deposits_test.go index 7b13eeef89..7f25ec42e9 100644 --- a/x/fungible/keeper/v2_deposits_test.go +++ b/x/fungible/keeper/v2_deposits_test.go @@ -51,7 +51,7 @@ func getTestDAppNoMessageIndex( // deployTestDAppV2 deploys the test dapp v2 contract and returns its address func deployTestDAppV2(t *testing.T, ctx sdk.Context, k *fungiblekeeper.Keeper, evmk types.EVMKeeper) common.Address { - testDAppV2, err := k.DeployContract(ctx, testdappv2.TestDAppV2MetaData) + testDAppV2, err := k.DeployContract(ctx, testdappv2.TestDAppV2MetaData, true) require.NoError(t, err) require.NotEmpty(t, testDAppV2) assertContractDeployment(t, evmk, ctx, testDAppV2) diff --git a/zetaclient/zetacore/constant.go b/zetaclient/zetacore/constant.go index c2185a08e1..f5ff75ebdd 100644 --- a/zetaclient/zetacore/constant.go +++ b/zetaclient/zetacore/constant.go @@ -37,8 +37,8 @@ const ( PostVoteOutboundGasLimit = 500_000 // PostVoteOutboundRevertGasLimit is the gas limit for voting on observed outbound tx for revert (when outbound fails) - // The value needs to be higher because reverting implies interacting with the EVM to perform swaps for the gas token - PostVoteOutboundRevertGasLimit = 4_000_000 + // The value is set to 7M because in case of onRevert call, it might consume lot of gas + PostVoteOutboundRevertGasLimit = 7_000_000 ) // constants for monitoring tx results From e217ec42d10bb746c67501c3fefef7083d8d7b0b Mon Sep 17 00:00:00 2001 From: Tanmay Date: Wed, 13 Nov 2024 07:31:18 -0500 Subject: [PATCH 2/3] fix: register withdraw emissions to legacy amino (#3117) * register withdraw emissions to legacy amino * add changelog entry * register update params * format code * add changelog * refactor changelog entry * remove MsgWithdrawEmissions from zetaclient grants * Update changelog.md --------- Co-authored-by: Lucas Bertrand --- changelog.md | 1 + x/emissions/types/codec.go | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index ac4e4c351c..244bc9d08d 100644 --- a/changelog.md +++ b/changelog.md @@ -21,6 +21,7 @@ * [3137](https://github.com/zeta-chain/node/pull/3137) - remove chain.Chain from zetaclientd config ### Fixes +* [3117](https://github.com/zeta-chain/node/pull/3117) - register messages for emissions module to legacy amino codec. * [3041](https://github.com/zeta-chain/node/pull/3041) - replace libp2p public DHT with private gossip peer discovery and connection gater for inbound connections * [3106](https://github.com/zeta-chain/node/pull/3106) - prevent blocked CCTX on out of gas during omnichain calls * [3139](https://github.com/zeta-chain/node/pull/3139) - fix config resolution in orchestrator diff --git a/x/emissions/types/codec.go b/x/emissions/types/codec.go index 4f0a3e3b48..4c8ca20637 100644 --- a/x/emissions/types/codec.go +++ b/x/emissions/types/codec.go @@ -3,13 +3,20 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) -func RegisterCodec(_ *codec.LegacyAmino) { +func RegisterCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgWithdrawEmission{}, "emissions/WithdrawEmission", nil) + cdc.RegisterConcrete(&MsgUpdateParams{}, "emissions/UpdateParams", nil) } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgWithdrawEmission{}, + &MsgUpdateParams{}, + ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } From d6ed9aa5ce5862f9ff90cb34669cdf1e5b228826 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Wed, 13 Nov 2024 11:38:11 -0800 Subject: [PATCH 3/3] test: fix evm signer instability (#3133) * test: fix evm signer instability * fix * coderabbit feedback --- zetaclient/chains/evm/signer/sign_test.go | 33 +++++++--------- .../chains/evm/signer/signer_admin_test.go | 39 ++++++++----------- zetaclient/chains/evm/signer/signer_test.go | 17 ++++---- zetaclient/testutils/mocks/tss_signer.go | 10 +++++ 4 files changed, 48 insertions(+), 51 deletions(-) diff --git a/zetaclient/chains/evm/signer/sign_test.go b/zetaclient/chains/evm/signer/sign_test.go index 5123968573..c3d64ebabc 100644 --- a/zetaclient/chains/evm/signer/sign_test.go +++ b/zetaclient/chains/evm/signer/sign_test.go @@ -8,6 +8,7 @@ import ( "github.com/rs/zerolog" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/zeta-chain/node/pkg/chains" "github.com/zeta-chain/node/zetaclient/testutils/mocks" ) @@ -15,7 +16,7 @@ func TestSigner_SignConnectorOnReceive(t *testing.T) { ctx := makeCtx(t) // Setup evm signer - tss := mocks.NewTSSMainnet() + tss := mocks.NewDerivedTSS(chains.BitcoinMainnet) evmSigner, err := getNewEvmSigner(tss) require.NoError(t, err) @@ -33,8 +34,7 @@ func TestSigner_SignConnectorOnReceive(t *testing.T) { require.NoError(t, err) // Verify Signature - tss := mocks.NewTSSMainnet() - verifyTxSignature(t, tx, tss.Pubkey(), evmSigner.EvmSigner()) + verifyTxSender(t, tx, tss.EVMAddress(), evmSigner.EvmSigner()) }) t.Run("SignConnectorOnReceive - should fail if keysign fails", func(t *testing.T) { // Pause tss to make keysign fail @@ -53,8 +53,7 @@ func TestSigner_SignConnectorOnReceive(t *testing.T) { require.NoError(t, err) // Verify Signature - tss := mocks.NewTSSMainnet() - verifyTxSignature(t, tx, tss.Pubkey(), evmSigner.EvmSigner()) + verifyTxSender(t, tx, tss.EVMAddress(), evmSigner.EvmSigner()) // check that by default tx type is legacy tx assert.Equal(t, ethtypes.LegacyTxType, int(tx.Type())) @@ -86,7 +85,7 @@ func TestSigner_SignConnectorOnReceive(t *testing.T) { require.NoError(t, err) // ASSERT - verifyTxSignature(t, tx, mocks.NewTSSMainnet().Pubkey(), evmSigner.EvmSigner()) + verifyTxSender(t, tx, tss.EVMAddress(), evmSigner.EvmSigner()) // check that by default tx type is a dynamic fee tx assert.Equal(t, ethtypes.DynamicFeeTxType, int(tx.Type())) @@ -101,7 +100,7 @@ func TestSigner_SignConnectorOnRevert(t *testing.T) { ctx := makeCtx(t) // Setup evm signer - tss := mocks.NewTSSMainnet() + tss := mocks.NewDerivedTSS(chains.BitcoinMainnet) evmSigner, err := getNewEvmSigner(tss) require.NoError(t, err) @@ -118,8 +117,7 @@ func TestSigner_SignConnectorOnRevert(t *testing.T) { require.NoError(t, err) // Verify tx signature - tss := mocks.NewTSSMainnet() - verifyTxSignature(t, tx, tss.Pubkey(), evmSigner.EvmSigner()) + verifyTxSender(t, tx, tss.EVMAddress(), evmSigner.EvmSigner()) // Verify tx body basics // Note: Revert tx calls connector contract with 0 gas token @@ -140,7 +138,7 @@ func TestSigner_SignCancel(t *testing.T) { ctx := makeCtx(t) // Setup evm signer - tss := mocks.NewTSSMainnet() + tss := mocks.NewDerivedTSS(chains.BitcoinMainnet) evmSigner, err := getNewEvmSigner(tss) require.NoError(t, err) @@ -157,12 +155,11 @@ func TestSigner_SignCancel(t *testing.T) { require.NoError(t, err) // Verify tx signature - tss := mocks.NewTSSMainnet() - verifyTxSignature(t, tx, tss.Pubkey(), evmSigner.EvmSigner()) + verifyTxSender(t, tx, tss.EVMAddress(), evmSigner.EvmSigner()) // Verify tx body basics // Note: Cancel tx sends 0 gas token to TSS self address - verifyTxBodyBasics(t, tx, evmSigner.TSS().EVMAddress(), txData.nonce, big.NewInt(0)) + verifyTxBodyBasics(t, tx, tss.EVMAddress(), txData.nonce, big.NewInt(0)) }) t.Run("SignCancel - should fail if keysign fails", func(t *testing.T) { // Pause tss to make keysign fail @@ -179,7 +176,7 @@ func TestSigner_SignGasWithdraw(t *testing.T) { ctx := makeCtx(t) // Setup evm signer - tss := mocks.NewTSSMainnet() + tss := mocks.NewDerivedTSS(chains.BitcoinMainnet) evmSigner, err := getNewEvmSigner(tss) require.NoError(t, err) @@ -196,8 +193,7 @@ func TestSigner_SignGasWithdraw(t *testing.T) { require.NoError(t, err) // Verify tx signature - tss := mocks.NewTSSMainnet() - verifyTxSignature(t, tx, tss.Pubkey(), evmSigner.EvmSigner()) + verifyTxSender(t, tx, tss.EVMAddress(), evmSigner.EvmSigner()) // Verify tx body basics verifyTxBodyBasics(t, tx, txData.to, txData.nonce, txData.amount) @@ -217,7 +213,7 @@ func TestSigner_SignERC20Withdraw(t *testing.T) { ctx := makeCtx(t) // Setup evm signer - tss := mocks.NewTSSMainnet() + tss := mocks.NewDerivedTSS(chains.BitcoinMainnet) evmSigner, err := getNewEvmSigner(tss) require.NoError(t, err) @@ -233,8 +229,7 @@ func TestSigner_SignERC20Withdraw(t *testing.T) { require.NoError(t, err) // Verify tx signature - tss := mocks.NewTSSMainnet() - verifyTxSignature(t, tx, tss.Pubkey(), evmSigner.EvmSigner()) + verifyTxSender(t, tx, tss.EVMAddress(), evmSigner.EvmSigner()) // Verify tx body basics // Note: Withdraw tx calls erc20 custody contract with 0 gas token diff --git a/zetaclient/chains/evm/signer/signer_admin_test.go b/zetaclient/chains/evm/signer/signer_admin_test.go index 6b43653ffb..e5896edcc2 100644 --- a/zetaclient/chains/evm/signer/signer_admin_test.go +++ b/zetaclient/chains/evm/signer/signer_admin_test.go @@ -7,6 +7,7 @@ import ( "github.com/rs/zerolog" "github.com/stretchr/testify/require" + "github.com/zeta-chain/node/pkg/chains" "github.com/zeta-chain/node/pkg/constant" "github.com/zeta-chain/node/testutil/sample" "github.com/zeta-chain/node/zetaclient/testutils/mocks" @@ -16,7 +17,8 @@ func TestSigner_SignAdminTx(t *testing.T) { ctx := makeCtx(t) // Setup evm signer - evmSigner, err := getNewEvmSigner(nil) + tss := mocks.NewDerivedTSS(chains.BitcoinMainnet) + evmSigner, err := getNewEvmSigner(tss) require.NoError(t, err) // Setup txData struct @@ -36,8 +38,7 @@ func TestSigner_SignAdminTx(t *testing.T) { require.NoError(t, err) // Verify tx signature - tss := mocks.NewTSSMainnet() - verifyTxSignature(t, tx, tss.Pubkey(), evmSigner.EvmSigner()) + verifyTxSender(t, tx, tss.EVMAddress(), evmSigner.EvmSigner()) // Verify tx body basics // Note: Revert tx calls erc20 custody contract with 0 gas token @@ -57,8 +58,7 @@ func TestSigner_SignAdminTx(t *testing.T) { require.NoError(t, err) // Verify tx signature - tss := mocks.NewTSSMainnet() - verifyTxSignature(t, tx, tss.Pubkey(), evmSigner.EvmSigner()) + verifyTxSender(t, tx, tss.EVMAddress(), evmSigner.EvmSigner()) // Verify tx body basics // Note: Revert tx calls erc20 custody contract with 0 gas token @@ -73,8 +73,7 @@ func TestSigner_SignAdminTx(t *testing.T) { require.NoError(t, err) // Verify tx signature - tss := mocks.NewTSSMainnet() - verifyTxSignature(t, tx, tss.Pubkey(), evmSigner.EvmSigner()) + verifyTxSender(t, tx, tss.EVMAddress(), evmSigner.EvmSigner()) // Verify tx body basics // Note: Revert tx calls erc20 custody contract with 0 gas token @@ -88,8 +87,7 @@ func TestSigner_SignAdminTx(t *testing.T) { require.NoError(t, err) // Verify tx signature - tss := mocks.NewTSSMainnet() - verifyTxSignature(t, tx, tss.Pubkey(), evmSigner.EvmSigner()) + verifyTxSender(t, tx, tss.EVMAddress(), evmSigner.EvmSigner()) // Verify tx body basics verifyTxBodyBasics(t, tx, txData.to, txData.nonce, txData.amount) @@ -100,7 +98,7 @@ func TestSigner_SignWhitelistERC20Cmd(t *testing.T) { ctx := makeCtx(t) // Setup evm signer - tss := mocks.NewTSSMainnet() + tss := mocks.NewDerivedTSS(chains.BitcoinMainnet) evmSigner, err := getNewEvmSigner(tss) require.NoError(t, err) @@ -121,8 +119,7 @@ func TestSigner_SignWhitelistERC20Cmd(t *testing.T) { require.NotNil(t, tx) // Verify tx signature - tss := mocks.NewTSSMainnet() - verifyTxSignature(t, tx, tss.Pubkey(), evmSigner.EvmSigner()) + verifyTxSender(t, tx, tss.EVMAddress(), evmSigner.EvmSigner()) // Verify tx body basics verifyTxBodyBasics(t, tx, txData.to, txData.nonce, zeroValue) @@ -149,7 +146,7 @@ func TestSigner_SignMigrateERC20CustodyFundsCmd(t *testing.T) { ctx := makeCtx(t) // Setup evm signer - tss := mocks.NewTSSMainnet() + tss := mocks.NewDerivedTSS(chains.BitcoinMainnet) evmSigner, err := getNewEvmSigner(tss) require.NoError(t, err) @@ -178,8 +175,7 @@ func TestSigner_SignMigrateERC20CustodyFundsCmd(t *testing.T) { require.NotNil(t, tx) // Verify tx signature - tss := mocks.NewTSSMainnet() - verifyTxSignature(t, tx, tss.Pubkey(), evmSigner.EvmSigner()) + verifyTxSender(t, tx, tss.EVMAddress(), evmSigner.EvmSigner()) // Verify tx body basics verifyTxBodyBasics(t, tx, txData.to, txData.nonce, zeroValue) @@ -215,7 +211,7 @@ func TestSigner_SignUpdateERC20CustodyPauseStatusCmd(t *testing.T) { ctx := makeCtx(t) // Setup evm signer - tss := mocks.NewTSSMainnet() + tss := mocks.NewDerivedTSS(chains.BitcoinMainnet) evmSigner, err := getNewEvmSigner(tss) require.NoError(t, err) @@ -238,8 +234,7 @@ func TestSigner_SignUpdateERC20CustodyPauseStatusCmd(t *testing.T) { require.NotNil(t, tx) // Verify tx signature - tss := mocks.NewTSSMainnet() - verifyTxSignature(t, tx, tss.Pubkey(), evmSigner.EvmSigner()) + verifyTxSender(t, tx, tss.EVMAddress(), evmSigner.EvmSigner()) // Verify tx body basics verifyTxBodyBasics(t, tx, txData.to, txData.nonce, zeroValue) @@ -255,8 +250,7 @@ func TestSigner_SignUpdateERC20CustodyPauseStatusCmd(t *testing.T) { require.NotNil(t, tx) // Verify tx signature - tss := mocks.NewTSSMainnet() - verifyTxSignature(t, tx, tss.Pubkey(), evmSigner.EvmSigner()) + verifyTxSender(t, tx, tss.EVMAddress(), evmSigner.EvmSigner()) // Verify tx body basics verifyTxBodyBasics(t, tx, txData.to, txData.nonce, zeroValue) @@ -293,7 +287,7 @@ func TestSigner_SignMigrateTssFundsCmd(t *testing.T) { ctx := makeCtx(t) // Setup evm signer - tss := mocks.NewTSSMainnet() + tss := mocks.NewDerivedTSS(chains.BitcoinMainnet) evmSigner, err := getNewEvmSigner(tss) require.NoError(t, err) @@ -313,8 +307,7 @@ func TestSigner_SignMigrateTssFundsCmd(t *testing.T) { require.NotNil(t, tx) // Verify tx signature - tss := mocks.NewTSSMainnet() - verifyTxSignature(t, tx, tss.Pubkey(), evmSigner.EvmSigner()) + verifyTxSender(t, tx, tss.EVMAddress(), evmSigner.EvmSigner()) // Verify tx body basics verifyTxBodyBasics(t, tx, txData.to, txData.nonce, txData.amount) diff --git a/zetaclient/chains/evm/signer/signer_test.go b/zetaclient/chains/evm/signer/signer_test.go index b2c266b438..43577b475d 100644 --- a/zetaclient/chains/evm/signer/signer_test.go +++ b/zetaclient/chains/evm/signer/signer_test.go @@ -8,7 +8,6 @@ import ( sdktypes "github.com/cosmos/cosmos-sdk/types" ethcommon "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" "github.com/rs/zerolog" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -113,14 +112,14 @@ func getInvalidCCTX(t *testing.T) *crosschaintypes.CrossChainTx { return cctx } -// verifyTxSignature is a helper function to verify the signature of a transaction -func verifyTxSignature(t *testing.T, tx *ethtypes.Transaction, tssPubkey []byte, signer ethtypes.Signer) { - _, r, s := tx.RawSignatureValues() - signature := append(r.Bytes(), s.Bytes()...) - hash := signer.Hash(tx) - - verified := crypto.VerifySignature(tssPubkey, hash.Bytes(), signature) - require.True(t, verified) +// verifyTxSender is a helper function to verify the signature of a transaction +// +// signer.Sender() will ecrecover the public key of the transaction internally +// and will fail if the transaction is not valid or has been tampered with +func verifyTxSender(t *testing.T, tx *ethtypes.Transaction, expectedSender ethcommon.Address, signer ethtypes.Signer) { + senderAddr, err := signer.Sender(tx) + require.NoError(t, err) + require.Equal(t, expectedSender.String(), senderAddr.String()) } // verifyTxBodyBasics is a helper function to verify 'to', 'nonce' and 'amount' of a transaction diff --git a/zetaclient/testutils/mocks/tss_signer.go b/zetaclient/testutils/mocks/tss_signer.go index 78ce36649a..3fa003a3c0 100644 --- a/zetaclient/testutils/mocks/tss_signer.go +++ b/zetaclient/testutils/mocks/tss_signer.go @@ -63,6 +63,16 @@ func NewTSSAthens3() *TSS { return NewMockTSS(chains.BscTestnet, testutils.TSSAddressEVMAthens3, testutils.TSSAddressBTCAthens3) } +// NewDerivedTSS creates a TSS where evmAddress and btcAdresses are always derived from the test +// private key +func NewDerivedTSS(chain chains.Chain) *TSS { + return &TSS{ + paused: false, + chain: chain, + PrivKey: TestPrivateKey, + } +} + func NewGeneratedTSS(t *testing.T, chain chains.Chain) *TSS { pk, err := crypto.GenerateKey() require.NoError(t, err)