diff --git a/app/ante/ante.go b/app/ante/ante.go index 18947d01fa..f1a8b21d45 100644 --- a/app/ante/ante.go +++ b/app/ante/ante.go @@ -26,7 +26,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/authz" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" tmlog "github.com/tendermint/tendermint/libs/log" - cctxtypes "github.com/zeta-chain/zetacore/x/crosschain/types" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -168,10 +168,10 @@ func IsSystemTx(tx sdk.Tx, isAuthorizedSigner func(string) bool) bool { } } switch innerMsg.(type) { - case *cctxtypes.MsgVoteGasPrice, - *cctxtypes.MsgVoteOnObservedInboundTx, - *cctxtypes.MsgVoteOnObservedOutboundTx, - *cctxtypes.MsgAddToOutTxTracker, + case *crosschaintypes.MsgVoteGasPrice, + *crosschaintypes.MsgVoteOnObservedInboundTx, + *crosschaintypes.MsgVoteOnObservedOutboundTx, + *crosschaintypes.MsgAddToOutTxTracker, *observertypes.MsgVoteBlockHeader, *observertypes.MsgVoteTSS, *observertypes.MsgAddBlameVote: diff --git a/changelog.md b/changelog.md index 6cbd8d8f85..dac460d24a 100644 --- a/changelog.md +++ b/changelog.md @@ -55,6 +55,7 @@ * [1979](https://github.com/zeta-chain/node/pull/1979) - add script to import genesis data into an existing genesis file * [2006](https://github.com/zeta-chain/node/pull/2006) - add Amoy testnet static chain information * [2046](https://github.com/zeta-chain/node/pull/2046) - add state variable in crosschain for rate limiter flags +* [2034](https://github.com/zeta-chain/node/pull/2034) - add support for zEVM message passing ### Tests diff --git a/cmd/zetae2e/config/config.go b/cmd/zetae2e/config/config.go index cc6c64b532..da8ef55cda 100644 --- a/cmd/zetae2e/config/config.go +++ b/cmd/zetae2e/config/config.go @@ -106,7 +106,7 @@ func ExportContractsFromRunner(r *runner.E2ERunner, conf config.Config) config.C conf.Contracts.ZEVM.WZetaAddr = r.WZetaAddr.Hex() conf.Contracts.ZEVM.ZEVMSwapAppAddr = r.ZEVMSwapAppAddr.Hex() conf.Contracts.ZEVM.ContextAppAddr = r.ContextAppAddr.Hex() - conf.Contracts.ZEVM.TestDappAddr = r.TestDAppAddr.Hex() + conf.Contracts.ZEVM.TestDappAddr = r.EvmTestDAppAddr.Hex() return conf } diff --git a/cmd/zetae2e/config/contracts.go b/cmd/zetae2e/config/contracts.go index 2d456a8989..a4f05f0058 100644 --- a/cmd/zetae2e/config/contracts.go +++ b/cmd/zetae2e/config/contracts.go @@ -7,9 +7,9 @@ import ( "github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/erc20custody.sol" zetaeth "github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/zeta.eth.sol" zetaconnectoreth "github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/zetaconnector.eth.sol" - "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/connectorzevm.sol" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/systemcontract.sol" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/wzeta.sol" + connectorzevm "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zetaconnectorzevm.sol" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-core/contracts/uniswapv2factory.sol" uniswapv2router "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-periphery/contracts/uniswapv2router02.sol" @@ -181,7 +181,7 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error { if !ethcommon.IsHexAddress(c) { return fmt.Errorf("invalid TestDappAddr: %s", c) } - r.TestDAppAddr = ethcommon.HexToAddress(c) + r.EvmTestDAppAddr = ethcommon.HexToAddress(c) } return nil diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index 1d6a664d71..0fee34f8a9 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -253,6 +253,10 @@ func localE2ETest(cmd *cobra.Command, _ []string) { } zetaAdvancedTests := []string{ e2etests.TestZetaDepositRestrictedName, + e2etests.TestMessagePassingZEVMToEVMName, + e2etests.TestMessagePassingEVMtoZEVMName, + e2etests.TestMessagePassingEVMtoZEVMRevertName, + e2etests.TestMessagePassingZEVMtoEVMRevertName, } bitcoinTests := []string{ e2etests.TestBitcoinWithdrawSegWitName, diff --git a/e2e/e2etests/e2etests.go b/e2e/e2etests/e2etests.go index 765194c425..09197c874a 100644 --- a/e2e/e2etests/e2etests.go +++ b/e2e/e2etests/e2etests.go @@ -25,6 +25,11 @@ const ( TestCrosschainSwapName = "crosschain_swap" TestMessagePassingRevertFailName = "message_passing_revert_fail" TestMessagePassingRevertSuccessName = "message_passing_revert_success" + TestMessagePassingEVMtoZEVMName = "message_passing_zevm" + TestMessagePassingZEVMToEVMName = "message_passing_zevm_to_evm" + + TestMessagePassingZEVMtoEVMRevertName = "message_passing_zevm_to_evm_revert" + TestMessagePassingEVMtoZEVMRevertName = "message_passing_revert_zevm" TestERC20DepositAndCallRefundName = "erc20_deposit_and_call_refund" TestEtherDepositAndCallName = "eth_deposit_and_call" TestDepositEtherLiquidityCapName = "deposit_eth_liquidity_cap" @@ -372,4 +377,36 @@ var AllE2ETests = []runner.E2ETest{ []runner.ArgDefinition{}, TestUpdateBytecodeConnector, ), + runner.NewE2ETest( + TestMessagePassingZEVMToEVMName, + "zevm -> evm message passing contract call", + []runner.ArgDefinition{ + runner.ArgDefinition{Description: "amount in azeta", DefaultValue: "10000000000000000007"}, + }, + TestMessagePassingZEVMtoEVM, + ), + runner.NewE2ETest( + TestMessagePassingZEVMtoEVMRevertName, + "zevm -> evm message passing contract call reverts", + []runner.ArgDefinition{ + runner.ArgDefinition{Description: "amount in azeta", DefaultValue: "10000000000000000006"}, + }, + TestMessagePassingZEVMtoEVMRevert, + ), + runner.NewE2ETest( + TestMessagePassingEVMtoZEVMName, + "evm -> zevm message passing contract call ", + []runner.ArgDefinition{ + runner.ArgDefinition{Description: "amount in azeta", DefaultValue: "10000000000000000009"}, + }, + TestMessagePassingEVMtoZEVM, + ), + runner.NewE2ETest( + TestMessagePassingEVMtoZEVMRevertName, + "evm -> zevm message passing and revert back to evm", + []runner.ArgDefinition{ + runner.ArgDefinition{Description: "amount in azeta", DefaultValue: "10000000000000000008"}, + }, + TestMessagePassingEVMtoZEVMRevert, + ), } diff --git a/e2e/e2etests/test_eth_deposit.go b/e2e/e2etests/test_eth_deposit.go index bfcc33e1a8..65a79f9c15 100644 --- a/e2e/e2etests/test_eth_deposit.go +++ b/e2e/e2etests/test_eth_deposit.go @@ -139,6 +139,7 @@ func TestEtherDepositAndCall(r *runner.E2ERunner, args []string) { if receipt.Status == 0 { panic("tx failed") } + cctx = utils.WaitCctxMinedByInTxHash(r.Ctx, signedTx.Hash().Hex(), r.CctxClient, r.Logger, r.CctxTimeout) if cctx.CctxStatus.Status != types.CctxStatus_Reverted { panic(fmt.Sprintf("expected cctx status to be reverted; got %s", cctx.CctxStatus.Status)) diff --git a/e2e/e2etests/test_message_passing.go b/e2e/e2etests/test_message_passing.go index c01c2a92ac..b17aff8f6b 100644 --- a/e2e/e2etests/test_message_passing.go +++ b/e2e/e2etests/test_message_passing.go @@ -190,7 +190,7 @@ func TestMessagePassingRevertSuccess(r *runner.E2ERunner, args []string) { auth := r.EVMAuth - tx, err := r.ZetaEth.Approve(auth, r.TestDAppAddr, amount) + tx, err := r.ZetaEth.Approve(auth, r.EvmTestDAppAddr, amount) if err != nil { panic(err) } @@ -202,8 +202,8 @@ func TestMessagePassingRevertSuccess(r *runner.E2ERunner, args []string) { } r.Logger.Info("Approve tx receipt: %d", receipt.Status) - r.Logger.Info("Calling TestDApp.SendHello on contract address %s", r.TestDAppAddr.Hex()) - testDApp, err := testdapp.NewTestDApp(r.TestDAppAddr, r.EVMClient) + r.Logger.Info("Calling TestDApp.SendHello on contract address %s", r.EvmTestDAppAddr.Hex()) + testDApp, err := testdapp.NewTestDApp(r.EvmTestDAppAddr, r.EVMClient) if err != nil { panic(err) } @@ -216,7 +216,7 @@ func TestMessagePassingRevertSuccess(r *runner.E2ERunner, args []string) { } r.Logger.Info("$$$ Before: SUPPLY OF AZETA: %d", res2.Amount.Amount) - tx, err = testDApp.SendHelloWorld(auth, r.TestDAppAddr, chainID, amount, true) + tx, err = testDApp.SendHelloWorld(auth, r.EvmTestDAppAddr, chainID, amount, true) if err != nil { panic(err) } diff --git a/e2e/e2etests/test_message_passing_zevm.go b/e2e/e2etests/test_message_passing_zevm.go new file mode 100644 index 0000000000..54ca59b589 --- /dev/null +++ b/e2e/e2etests/test_message_passing_zevm.go @@ -0,0 +1,324 @@ +package e2etests + +import ( + "fmt" + "math/big" + + ethcommon "github.com/ethereum/go-ethereum/common" + "github.com/zeta-chain/zetacore/e2e/contracts/testdapp" + "github.com/zeta-chain/zetacore/e2e/runner" + "github.com/zeta-chain/zetacore/e2e/utils" + cctxtypes "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +func TestMessagePassingEVMtoZEVM(r *runner.E2ERunner, args []string) { + if len(args) != 1 { + panic("TestMessagePassing requires exactly one argument for the amount.") + } + amount, ok := big.NewInt(0).SetString(args[0], 10) + if !ok { + panic("Invalid amount specified for TestMessagePassing.") + } + + // Set destination details + zEVMChainID, err := r.ZEVMClient.ChainID(r.Ctx) + if err != nil { + panic(err) + } + destinationAddress := r.ZevmTestDAppAddr + + // Contract call originates from EVM chain + tx, err := r.ZetaEth.Approve(r.EVMAuth, r.EvmTestDAppAddr, amount) + if err != nil { + panic(err) + } + r.Logger.Info("Approve tx hash: %s", tx.Hash().Hex()) + receipt := utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, tx, r.Logger, r.ReceiptTimeout) + if receipt.Status != 1 { + panic("approve tx failed") + } + r.Logger.Info("Approve tx receipt: %d", receipt.Status) + testDAppEVM, err := testdapp.NewTestDApp(r.EvmTestDAppAddr, r.EVMClient) + if err != nil { + panic(err) + } + // Call the SendHelloWorld function on the EVM dapp Contract which would in turn create a new send, to be picked up by the zeta-clients + // set Do revert to false which adds a message to signal the ZEVM zetaReceiver to not revert the transaction + tx, err = testDAppEVM.SendHelloWorld(r.EVMAuth, destinationAddress, zEVMChainID, amount, false) + if err != nil { + panic(err) + } + r.Logger.Info("TestDApp.SendHello tx hash: %s", tx.Hash().Hex()) + receipt = utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, tx, r.Logger, r.ReceiptTimeout) + + // New inbound message picked up by zeta-clients and voted on by observers to initiate a contract call on zEVM + cctx := utils.WaitCctxMinedByInTxHash(r.Ctx, receipt.TxHash.String(), r.CctxClient, r.Logger, r.CctxTimeout) + if cctx.CctxStatus.Status != cctxtypes.CctxStatus_OutboundMined { + panic("expected cctx to be outbound_mined") + } + r.Logger.Info(fmt.Sprintf("🔄 Cctx mined for contract call chain zevm %s", cctx.Index)) + + // On finalization the Fungible module calls the onReceive function which in turn calls the onZetaMessage function on the destination contract + receipt, err = r.ZEVMClient.TransactionReceipt(r.Ctx, ethcommon.HexToHash(cctx.GetCurrentOutTxParam().OutboundTxHash)) + if err != nil { + panic(err) + } + if receipt.Status != 1 { + panic("tx failed") + } + testDAppZEVM, err := testdapp.NewTestDApp(r.ZevmTestDAppAddr, r.ZEVMClient) + if err != nil { + panic(err) + } + receivedHelloWorldEvent := false + for _, log := range receipt.Logs { + _, err := testDAppZEVM.ParseHelloWorldEvent(*log) + if err == nil { + r.Logger.Info("Received HelloWorld event") + receivedHelloWorldEvent = true + } + } + if !receivedHelloWorldEvent { + panic(fmt.Sprintf("expected HelloWorld event, logs: %+v", receipt.Logs)) + } +} + +func TestMessagePassingEVMtoZEVMRevert(r *runner.E2ERunner, args []string) { + + if len(args) != 1 { + panic("TestMessagePassingRevert requires exactly one argument for the amount.") + } + + amount, ok := big.NewInt(0).SetString(args[0], 10) + if !ok { + panic("Invalid amount specified for TestMessagePassingRevert.") + } + + // Set destination details + zEVMChainID, err := r.ZEVMClient.ChainID(r.Ctx) + if err != nil { + panic(err) + } + destinationAddress := r.ZevmTestDAppAddr + + // Contract call originates from EVM chain + tx, err := r.ZetaEth.Approve(r.EVMAuth, r.EvmTestDAppAddr, amount) + if err != nil { + panic(err) + } + r.Logger.Info("Approve tx hash: %s", tx.Hash().Hex()) + receipt := utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, tx, r.Logger, r.ReceiptTimeout) + if receipt.Status != 1 { + panic("tx failed") + } + r.Logger.Info("Approve tx receipt: %d", receipt.Status) + testDAppEVM, err := testdapp.NewTestDApp(r.EvmTestDAppAddr, r.EVMClient) + if err != nil { + panic(err) + } + // Call the SendHelloWorld function on the EVM dapp Contract which would in turn create a new send, to be picked up by the zeta-clients + // set Do revert to true which adds a message to signal the ZEVM zetaReceiver to revert the transaction + tx, err = testDAppEVM.SendHelloWorld(r.EVMAuth, destinationAddress, zEVMChainID, amount, true) + if err != nil { + panic(err) + } + r.Logger.Info("TestDApp.SendHello tx hash: %s", tx.Hash().Hex()) + receipt = utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, tx, r.Logger, r.ReceiptTimeout) + + // New inbound message picked up by zeta-clients and voted on by observers to initiate a contract call on zEVM which would revert the transaction + // A revert transaction is created and gets fialized on the original sender chain. + cctx := utils.WaitCctxMinedByInTxHash(r.Ctx, receipt.TxHash.String(), r.CctxClient, r.Logger, r.CctxTimeout) + if cctx.CctxStatus.Status != cctxtypes.CctxStatus_Reverted { + panic("expected cctx to be reverted") + } + + // On finalization the Tss address calls the onRevert function which in turn calls the onZetaRevert function on the sender contract + receipt, err = r.EVMClient.TransactionReceipt(r.Ctx, ethcommon.HexToHash(cctx.GetCurrentOutTxParam().OutboundTxHash)) + if err != nil { + panic(err) + } + if receipt.Status != 1 { + panic("tx failed") + } + receivedHelloWorldEvent := false + for _, log := range receipt.Logs { + _, err := testDAppEVM.ParseRevertedHelloWorldEvent(*log) + if err == nil { + r.Logger.Info("Received RevertHelloWorld event:") + receivedHelloWorldEvent = true + } + } + if !receivedHelloWorldEvent { + panic(fmt.Sprintf("expected Reverted HelloWorld event, logs: %+v", receipt.Logs)) + } +} + +func TestMessagePassingZEVMtoEVM(r *runner.E2ERunner, args []string) { + if len(args) != 1 { + panic("TestMessagePassing requires exactly one argument for the amount.") + } + + amount, ok := big.NewInt(0).SetString(args[0], 10) + if !ok { + panic("Invalid amount specified for TestMessagePassing.") + } + // Set destination details + EVMChainID, err := r.EVMClient.ChainID(r.Ctx) + if err != nil { + panic(err) + } + destinationAddress := r.EvmTestDAppAddr + + // Contract call originates from ZEVM chain + r.ZEVMAuth.Value = amount + tx, err := r.WZeta.Deposit(r.ZEVMAuth) + if err != nil { + panic(err) + } + r.ZEVMAuth.Value = big.NewInt(0) + r.Logger.Info("wzeta deposit tx hash: %s", tx.Hash().Hex()) + receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + r.Logger.EVMReceipt(*receipt, "wzeta deposit") + if receipt.Status == 0 { + panic("deposit failed") + } + tx, err = r.WZeta.Approve(r.ZEVMAuth, r.ZevmTestDAppAddr, amount) + if err != nil { + panic(err) + } + r.Logger.Info("wzeta approve tx hash: %s", tx.Hash().Hex()) + receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + r.Logger.EVMReceipt(*receipt, "wzeta approve") + if receipt.Status == 0 { + panic(fmt.Sprintf("approve failed, logs: %+v", receipt.Logs)) + } + testDAppZEVM, err := testdapp.NewTestDApp(r.ZevmTestDAppAddr, r.ZEVMClient) + if err != nil { + panic(err) + } + // Call the SendHelloWorld function on the ZEVM dapp Contract which would in turn create a new send, to be picked up by the zetanode evm hooks + // set Do revert to false which adds a message to signal the EVM zetaReceiver to not revert the transaction + tx, err = testDAppZEVM.SendHelloWorld(r.ZEVMAuth, destinationAddress, EVMChainID, amount, false) + if err != nil { + panic(err) + } + r.Logger.Info("TestDApp.SendHello tx hash: %s", tx.Hash().Hex()) + receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + if receipt.Status == 0 { + panic(fmt.Sprintf("send failed, logs: %+v", receipt.Logs)) + } + + // Transaction is picked up by the zetanode evm hooks and a new contract call is initiated on the EVM chain + cctx := utils.WaitCctxMinedByInTxHash(r.Ctx, receipt.TxHash.String(), r.CctxClient, r.Logger, r.CctxTimeout) + if cctx.CctxStatus.Status != cctxtypes.CctxStatus_OutboundMined { + panic("expected cctx to be outbound_mined") + } + + // On finalization the Tss calls the onReceive function which in turn calls the onZetaMessage function on the destination contract. + receipt, err = r.EVMClient.TransactionReceipt(r.Ctx, ethcommon.HexToHash(cctx.GetCurrentOutTxParam().OutboundTxHash)) + if err != nil { + panic(err) + } + if receipt.Status != 1 { + panic("tx failed") + } + testDAppEVM, err := testdapp.NewTestDApp(r.EvmTestDAppAddr, r.EVMClient) + if err != nil { + panic(err) + } + receivedHelloWorldEvent := false + for _, log := range receipt.Logs { + _, err := testDAppEVM.ParseHelloWorldEvent(*log) + if err == nil { + r.Logger.Info("Received HelloWorld event:") + receivedHelloWorldEvent = true + } + } + if !receivedHelloWorldEvent { + panic(fmt.Sprintf("expected HelloWorld event, logs: %+v", receipt.Logs)) + } +} + +func TestMessagePassingZEVMtoEVMRevert(r *runner.E2ERunner, args []string) { + if len(args) != 1 { + panic("TestMessagePassing requires exactly one argument for the amount.") + } + + amount, ok := big.NewInt(0).SetString(args[0], 10) + if !ok { + panic("Invalid amount specified for TestMessagePassing.") + } + + // Set destination details + EVMChainID, err := r.EVMClient.ChainID(r.Ctx) + if err != nil { + panic(err) + } + destinationAddress := r.EvmTestDAppAddr + + // Contract call originates from ZEVM chain + r.ZEVMAuth.Value = amount + tx, err := r.WZeta.Deposit(r.ZEVMAuth) + if err != nil { + panic(err) + } + r.ZEVMAuth.Value = big.NewInt(0) + r.Logger.Info("wzeta deposit tx hash: %s", tx.Hash().Hex()) + receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + r.Logger.EVMReceipt(*receipt, "wzeta deposit") + if receipt.Status == 0 { + panic("deposit failed") + } + tx, err = r.WZeta.Approve(r.ZEVMAuth, r.ZevmTestDAppAddr, amount) + if err != nil { + panic(err) + } + r.Logger.Info("wzeta approve tx hash: %s", tx.Hash().Hex()) + receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + r.Logger.EVMReceipt(*receipt, "wzeta approve") + if receipt.Status == 0 { + panic(fmt.Sprintf("approve failed, logs: %+v", receipt.Logs)) + } + testDAppZEVM, err := testdapp.NewTestDApp(r.ZevmTestDAppAddr, r.ZEVMClient) + if err != nil { + panic(err) + } + // Call the SendHelloWorld function on the ZEVM dapp Contract which would in turn create a new send, to be picked up by the zetanode evm hooks + // set Do revert to true which adds a message to signal the EVM zetaReceiver to revert the transaction + tx, err = testDAppZEVM.SendHelloWorld(r.ZEVMAuth, destinationAddress, EVMChainID, amount, true) + if err != nil { + panic(err) + } + + r.Logger.Info("TestDApp.SendHello tx hash: %s", tx.Hash().Hex()) + receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + if receipt.Status == 0 { + panic(fmt.Sprintf("send failed, logs: %+v", receipt.Logs)) + } + + // New inbound message picked up by zetanode evm hooks and processed directly to initiate a contract call on EVM which would revert the transaction + cctx := utils.WaitCctxMinedByInTxHash(r.Ctx, receipt.TxHash.String(), r.CctxClient, r.Logger, r.CctxTimeout) + if cctx.CctxStatus.Status != cctxtypes.CctxStatus_Reverted { + panic("expected cctx to be reverted") + } + + // On finalization the Fungible module calls the onRevert function which in turn calls the onZetaRevert function on the sender contract + receipt, err = r.ZEVMClient.TransactionReceipt(r.Ctx, ethcommon.HexToHash(cctx.GetCurrentOutTxParam().OutboundTxHash)) + if err != nil { + panic(err) + } + if receipt.Status != 1 { + panic("tx failed") + } + receivedHelloWorldEvent := false + for _, log := range receipt.Logs { + _, err := testDAppZEVM.ParseRevertedHelloWorldEvent(*log) + if err == nil { + r.Logger.Info("Received HelloWorld event:") + receivedHelloWorldEvent = true + } + } + if !receivedHelloWorldEvent { + panic(fmt.Sprintf("expected Reverted HelloWorld event, logs: %+v", receipt.Logs)) + } +} diff --git a/e2e/e2etests/test_zeta_withdraw.go b/e2e/e2etests/test_zeta_withdraw.go index 2b5dc055e0..6dfc664813 100644 --- a/e2e/e2etests/test_zeta_withdraw.go +++ b/e2e/e2etests/test_zeta_withdraw.go @@ -6,7 +6,7 @@ import ( "math/big" ethcommon "github.com/ethereum/go-ethereum/common" - "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/connectorzevm.sol" + connectorzevm "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zetaconnectorzevm.sol" "github.com/zeta-chain/zetacore/e2e/runner" "github.com/zeta-chain/zetacore/e2e/utils" "github.com/zeta-chain/zetacore/pkg/chains" @@ -70,7 +70,6 @@ func TestZetaWithdraw(r *runner.E2ERunner, args []string) { r.Logger.EVMReceipt(*receipt, "send") if receipt.Status == 0 { panic(fmt.Sprintf("send failed, logs: %+v", receipt.Logs)) - } r.Logger.Info(" Logs:") diff --git a/e2e/runner/runner.go b/e2e/runner/runner.go index d45b542c97..da8944c7d9 100644 --- a/e2e/runner/runner.go +++ b/e2e/runner/runner.go @@ -16,9 +16,9 @@ import ( "github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/erc20custody.sol" zetaeth "github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/zeta.eth.sol" zetaconnectoreth "github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/zetaconnector.eth.sol" - "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/connectorzevm.sol" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/systemcontract.sol" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/wzeta.sol" + connectorzevm "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zetaconnectorzevm.sol" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-core/contracts/uniswapv2factory.sol" uniswapv2router "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-periphery/contracts/uniswapv2router02.sol" @@ -73,6 +73,7 @@ type E2ERunner struct { ERC20Custody *erc20custody.ERC20Custody ERC20Addr ethcommon.Address ERC20 *erc20.ERC20 + EvmTestDAppAddr ethcommon.Address // contracts zevm ERC20ZRC20Addr ethcommon.Address @@ -89,13 +90,13 @@ type E2ERunner struct { ConnectorZEVM *connectorzevm.ZetaConnectorZEVM WZetaAddr ethcommon.Address WZeta *wzeta.WETH9 - TestDAppAddr ethcommon.Address ZEVMSwapAppAddr ethcommon.Address ZEVMSwapApp *zevmswap.ZEVMSwapApp ContextAppAddr ethcommon.Address ContextApp *contextapp.ContextApp SystemContractAddr ethcommon.Address SystemContract *systemcontract.SystemContract + ZevmTestDAppAddr ethcommon.Address // config CctxTimeout time.Duration @@ -179,10 +180,11 @@ func (runner *E2ERunner) CopyAddressesFrom(other *E2ERunner) (err error) { runner.UniswapV2RouterAddr = other.UniswapV2RouterAddr runner.ConnectorZEVMAddr = other.ConnectorZEVMAddr runner.WZetaAddr = other.WZetaAddr - runner.TestDAppAddr = other.TestDAppAddr + runner.EvmTestDAppAddr = other.EvmTestDAppAddr runner.ZEVMSwapAppAddr = other.ZEVMSwapAppAddr runner.ContextAppAddr = other.ContextAppAddr runner.SystemContractAddr = other.SystemContractAddr + runner.ZevmTestDAppAddr = other.ZevmTestDAppAddr // create instances of contracts runner.ZetaEth, err = zetaeth.NewZetaEth(runner.ZetaEthAddr, runner.EVMClient) @@ -272,7 +274,7 @@ func (runner *E2ERunner) PrintContractAddresses() { runner.Logger.Print("ZEVMSwapApp: %s", runner.ZEVMSwapAppAddr.Hex()) runner.Logger.Print("ContextApp: %s", runner.ContextAppAddr.Hex()) - runner.Logger.Print("TestDapp: %s", runner.TestDAppAddr.Hex()) + runner.Logger.Print("TestDappZEVM: %s", runner.ZevmTestDAppAddr.Hex()) // evm contracts runner.Logger.Print(" --- 📜EVM contracts ---") @@ -280,4 +282,5 @@ func (runner *E2ERunner) PrintContractAddresses() { runner.Logger.Print("ConnectorEth: %s", runner.ConnectorEthAddr.Hex()) runner.Logger.Print("ERC20Custody: %s", runner.ERC20CustodyAddr.Hex()) runner.Logger.Print("ERC20: %s", runner.ERC20Addr.Hex()) + runner.Logger.Print("TestDappEVM: %s", runner.EvmTestDAppAddr.Hex()) } diff --git a/e2e/runner/setup_evm.go b/e2e/runner/setup_evm.go index 8e76ac7409..01188c759a 100644 --- a/e2e/runner/setup_evm.go +++ b/e2e/runner/setup_evm.go @@ -131,7 +131,7 @@ func (runner *E2ERunner) SetupEVM(contractsDeployed bool, whitelistERC20 bool) { if err != nil { panic(err) } - runner.TestDAppAddr = appAddr + runner.EvmTestDAppAddr = appAddr runner.Logger.Info("TestDApp contract address: %s, tx hash: %s", appAddr.Hex(), txApp.Hash().Hex()) // check contract deployment receipt diff --git a/e2e/runner/setup_zeta.go b/e2e/runner/setup_zeta.go index 0de4693210..e332f98af9 100644 --- a/e2e/runner/setup_zeta.go +++ b/e2e/runner/setup_zeta.go @@ -7,13 +7,14 @@ import ( "github.com/btcsuite/btcutil" "github.com/ethereum/go-ethereum/accounts/abi/bind" ethcommon "github.com/ethereum/go-ethereum/common" - "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/connectorzevm.sol" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/systemcontract.sol" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/wzeta.sol" + connectorzevm "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zetaconnectorzevm.sol" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-core/contracts/uniswapv2factory.sol" uniswapv2router "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-periphery/contracts/uniswapv2router02.sol" "github.com/zeta-chain/zetacore/e2e/contracts/contextapp" + "github.com/zeta-chain/zetacore/e2e/contracts/testdapp" "github.com/zeta-chain/zetacore/e2e/contracts/zevmswap" "github.com/zeta-chain/zetacore/e2e/txserver" e2eutils "github.com/zeta-chain/zetacore/e2e/utils" @@ -141,6 +142,14 @@ func (runner *E2ERunner) SetZEVMContracts() { runner.SetupETHZRC20() runner.SetupBTCZRC20() + // deploy TestDApp contract on zEVM + appAddr, txApp, _, err := testdapp.DeployTestDApp(runner.ZEVMAuth, runner.ZEVMClient, runner.ConnectorZEVMAddr, runner.WZetaAddr) + if err != nil { + panic(err) + } + runner.ZevmTestDAppAddr = appAddr + runner.Logger.Info("TestDApp Zevm contract address: %s, tx hash: %s", appAddr.Hex(), txApp.Hash().Hex()) + // deploy ZEVMSwapApp and ContextApp zevmSwapAppAddr, txZEVMSwapApp, zevmSwapApp, err := zevmswap.DeployZEVMSwapApp( runner.ZEVMAuth, @@ -170,6 +179,7 @@ func (runner *E2ERunner) SetZEVMContracts() { } runner.ContextAppAddr = contextAppAddr runner.ContextApp = contextApp + } // SetupETHZRC20 sets up the ETH ZRC20 in the runner from the values queried from the chain diff --git a/e2e/utils/zetacore.go b/e2e/utils/zetacore.go index 4aeac71ba3..9abaea7284 100644 --- a/e2e/utils/zetacore.go +++ b/e2e/utils/zetacore.go @@ -57,6 +57,7 @@ func WaitCctxsMinedByInTxHash( res, err := cctxClient.InTxHashToCctxData(ctx, &crosschaintypes.QueryInTxHashToCctxDataRequest{ InTxHash: inTxHash, }) + if err != nil { // prevent spamming logs if i%10 == 0 { diff --git a/go.mod b/go.mod index 245536d185..f1ed9826e8 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,6 @@ require ( github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-retryablehttp v0.7.0 github.com/multiformats/go-multiaddr v0.9.0 github.com/prometheus/client_golang v1.14.0 github.com/rs/zerolog v1.29.1 @@ -44,7 +43,7 @@ require ( github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 github.com/zeta-chain/go-tss v0.1.1-0.20240208222330-f3be0d4a0d98 github.com/zeta-chain/keystone/keys v0.0.0-20231105174229-903bc9405da2 - github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20230816152528-db7d2bf9144b + github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240418181724-c222fd3ae1f5 google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f gopkg.in/yaml.v2 v2.4.0 ) @@ -59,6 +58,7 @@ require ( require ( github.com/binance-chain/tss-lib v0.0.0-20201118045712-70b2cb4bf916 + github.com/btcsuite/btcd/btcutil v1.1.3 github.com/nanmu42/etherscan-api v1.10.0 github.com/onrik/ethrpc v1.2.0 go.nhat.io/grpcmock v0.25.0 @@ -68,7 +68,6 @@ require ( github.com/DataDog/zstd v1.5.2 // indirect github.com/agl/ed25519 v0.0.0-20200225211852-fd4d107ace12 // indirect github.com/bool64/shared v0.1.5 // indirect - github.com/btcsuite/btcd/btcutil v1.1.3 // indirect github.com/cespare/xxhash v1.1.0 // indirect github.com/cockroachdb/errors v1.9.1 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect @@ -156,7 +155,7 @@ require ( github.com/confio/ics23/go v0.9.0 // indirect github.com/containerd/cgroups v1.1.0 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect - github.com/cosmos/btcutil v1.0.5 // indirect + github.com/cosmos/btcutil v1.0.5 github.com/cosmos/cosmos-proto v1.0.0-beta.3 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogoproto v1.4.7 @@ -294,7 +293,7 @@ require ( github.com/sasha-s/go-deadlock v0.3.1 // indirect github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect - github.com/spf13/afero v1.11.0 // indirect + github.com/spf13/afero v1.11.0 github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/viper v1.15.0 github.com/status-im/keycard-go v0.2.0 // indirect @@ -315,7 +314,7 @@ require ( go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/crypto v0.17.0 // indirect + golang.org/x/crypto v0.17.0 golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect golang.org/x/mod v0.10.0 // indirect golang.org/x/net v0.19.0 diff --git a/go.sum b/go.sum index 256540ef43..c28932ba96 100644 --- a/go.sum +++ b/go.sum @@ -1739,7 +1739,6 @@ github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrj github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-hclog v0.16.2/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-hclog v1.0.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-hclog v1.2.0 h1:La19f8d7WIlm4ogzNHB0JGqs5AUDAZ2UfCY4sJXcJdM= github.com/hashicorp/go-hclog v1.2.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= @@ -1753,7 +1752,6 @@ github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9 github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-retryablehttp v0.6.4/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= github.com/hashicorp/go-retryablehttp v0.6.6/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= -github.com/hashicorp/go-retryablehttp v0.7.0 h1:eu1EI/mbirUgP5C8hVsTNaGZreBDlYiwC1FZWkvQPQ4= github.com/hashicorp/go-retryablehttp v0.7.0/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= @@ -1857,6 +1855,7 @@ github.com/ipfs/go-datastore v0.6.0/go.mod h1:rt5M3nNbSO/8q1t4LNkLyUwRs8HupMeN/8 github.com/ipfs/go-detect-race v0.0.1 h1:qX/xay2W3E4Q1U7d9lNs1sU9nvguX0a7319XbyQ6cOk= github.com/ipfs/go-detect-race v0.0.1/go.mod h1:8BNT7shDZPo99Q74BpGMK+4D8Mn4j46UU0LZ723meps= github.com/ipfs/go-ipfs-util v0.0.2 h1:59Sswnk1MFaiq+VcaknX7aYEyGyGDAA73ilhEK2POp8= +github.com/ipfs/go-ipfs-util v0.0.2/go.mod h1:CbPtkWJzjLdEcezDns2XYaehFVNXG9zrdrtMecczcsQ= github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8= github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JPtIo= github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g= @@ -2773,6 +2772,7 @@ github.com/sourcegraph/go-diff v0.5.1/go.mod h1:j2dHj3m8aZgQO8lMTcTnBcXkRRRqi34c github.com/sourcegraph/go-diff v0.5.3/go.mod h1:v9JDtjCE4HHHCZGId75rg8gkKKa98RVjBcBGsVmMmak= github.com/sourcegraph/go-diff v0.6.1/go.mod h1:iBszgVvyxdc8SFZ7gm69go2KDdt3ag071iBaWPF6cjs= github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA= +github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572/go.mod h1:w0SWMsp6j9O/dk4/ZpIhL+3CkG8ofA2vuv7k+ltqUMc= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= @@ -3056,8 +3056,12 @@ github.com/zeta-chain/go-tss v0.1.1-0.20240208222330-f3be0d4a0d98 h1:GCSRgszQbAR github.com/zeta-chain/go-tss v0.1.1-0.20240208222330-f3be0d4a0d98/go.mod h1:+lJfk/qqt+oxXeVuJV+PzpUoxftUfoTRf2eF3qlbyFI= github.com/zeta-chain/keystone/keys v0.0.0-20231105174229-903bc9405da2 h1:gd2uE0X+ZbdFJ8DubxNqLbOVlCB12EgWdzSNRAR82tM= github.com/zeta-chain/keystone/keys v0.0.0-20231105174229-903bc9405da2/go.mod h1:x7Bkwbzt2W2lQfjOirnff0Dj+tykdbTG1FMJPVPZsvE= -github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20230816152528-db7d2bf9144b h1:aZRt5BtXdoDdyrUKwcv3B7mS30m/B854cjKjmnXBE5A= -github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20230816152528-db7d2bf9144b/go.mod h1:v79f+eY6PMpmLv188FAubst4XV2Mm8mUmx1OgmdFG3c= +github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240415192848-ad076a028d30 h1:V1Kl0xLsdL2l9ThMEx/NLqRvr8zTAAyq2IoM+nhPMhE= +github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240415192848-ad076a028d30/go.mod h1:v79f+eY6PMpmLv188FAubst4XV2Mm8mUmx1OgmdFG3c= +github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240417132824-4be6fd4cb877 h1:Lp1HUBFI4M1vJg5exJ4zasIEAtD/iPef/OYW4eM9pXw= +github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240417132824-4be6fd4cb877/go.mod h1:v79f+eY6PMpmLv188FAubst4XV2Mm8mUmx1OgmdFG3c= +github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240418181724-c222fd3ae1f5 h1:ljM7xka3WZvth9k1uYxrG3/FKQQTkR96FZlIjUKOoYw= +github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240418181724-c222fd3ae1f5/go.mod h1:v79f+eY6PMpmLv188FAubst4XV2Mm8mUmx1OgmdFG3c= github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= diff --git a/testutil/contracts/Dapp.abi b/testutil/contracts/Dapp.abi new file mode 100644 index 0000000000..903a4f02d7 --- /dev/null +++ b/testutil/contracts/Dapp.abi @@ -0,0 +1,170 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "destinationAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "destinationChainId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "message", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes", + "name": "zetaTxSenderAddress", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "sourceChainId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "destinationAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "zetaValue", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "message", + "type": "bytes" + } + ], + "internalType": "struct ZetaInterfaces.ZetaMessage", + "name": "zetaMessage", + "type": "tuple" + } + ], + "name": "onZetaMessage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "zetaTxSenderAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "sourceChainId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "destinationAddress", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "destinationChainId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "remainingZetaValue", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "message", + "type": "bytes" + } + ], + "internalType": "struct ZetaInterfaces.ZetaRevert", + "name": "zetaRevert", + "type": "tuple" + } + ], + "name": "onZetaRevert", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "sourceChainId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "zetaTxSenderAddress", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "zetaValue", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/testutil/contracts/Dapp.bin b/testutil/contracts/Dapp.bin new file mode 100644 index 0000000000..52bfd6c0ac --- /dev/null +++ b/testutil/contracts/Dapp.bin @@ -0,0 +1 @@ +608060405234801561001057600080fd5b50604051806020016040528060008152506000908161002f91906102fe565b5060006001819055506000600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600381905550600060048190555060405180602001604052806000815250600590816100a891906102fe565b506103d0565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061012f57607f821691505b602082108103610142576101416100e8565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026101aa7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8261016d565b6101b4868361016d565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b60006101fb6101f66101f1846101cc565b6101d6565b6101cc565b9050919050565b6000819050919050565b610215836101e0565b61022961022182610202565b84845461017a565b825550505050565b600090565b61023e610231565b61024981848461020c565b505050565b5b8181101561026d57610262600082610236565b60018101905061024f565b5050565b601f8211156102b25761028381610148565b61028c8461015d565b8101602085101561029b578190505b6102af6102a78561015d565b83018261024e565b50505b505050565b600082821c905092915050565b60006102d5600019846008026102b7565b1980831691505092915050565b60006102ee83836102c4565b9150826002028217905092915050565b610307826100ae565b67ffffffffffffffff8111156103205761031f6100b9565b5b61032a8254610117565b610335828285610271565b600060209050601f8311600181146103685760008415610356578287015190505b61036085826102e2565b8655506103c8565b601f19841661037686610148565b60005b8281101561039e57848901518255600182019150602085019450602081019050610379565b868310156103bb57848901516103b7601f8916826102c4565b8355505b6001600288020188555050505b505050505050565b610c2c806103df6000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c8063b07506111161005b578063b075061114610101578063ca3254691461011f578063e21f37ce1461013d578063ed6b866b1461015b57610088565b8063050337a21461008d5780631544298e146100ab5780633749c51a146100c95780633ff0693c146100e5575b600080fd5b610095610179565b6040516100a29190610480565b60405180910390f35b6100b361017f565b6040516100c09190610480565b60405180910390f35b6100e360048036038101906100de91906104c9565b610185565b005b6100ff60048036038101906100fa9190610531565b610231565b005b61010961031f565b6040516101169190610480565b60405180910390f35b610127610325565b60405161013491906105bb565b60405180910390f35b61014561034b565b6040516101529190610666565b60405180910390f35b6101636103d9565b6040516101709190610666565b60405180910390f35b60045481565b60015481565b8080600001906101959190610697565b600091826101a4929190610940565b5080602001356001819055508060400160208101906101c39190610a3c565b600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550806060013560048190555080806080019061021e9190610697565b6005918261022d929190610940565b5050565b8060000160208101906102449190610a3c565b6040516020016102549190610ab1565b604051602081830303815290604052600090816102719190610acc565b50806020013560018190555080806040019061028d9190610697565b60405161029b929190610bdd565b604051809103902060001c600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080606001356003819055508060800135600481905550808060a0019061030c9190610697565b6005918261031b929190610940565b5050565b60035481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6005805461035890610763565b80601f016020809104026020016040519081016040528092919081815260200182805461038490610763565b80156103d15780601f106103a6576101008083540402835291602001916103d1565b820191906000526020600020905b8154815290600101906020018083116103b457829003601f168201915b505050505081565b600080546103e690610763565b80601f016020809104026020016040519081016040528092919081815260200182805461041290610763565b801561045f5780601f106104345761010080835404028352916020019161045f565b820191906000526020600020905b81548152906001019060200180831161044257829003601f168201915b505050505081565b6000819050919050565b61047a81610467565b82525050565b60006020820190506104956000830184610471565b92915050565b600080fd5b600080fd5b600080fd5b600060a082840312156104c0576104bf6104a5565b5b81905092915050565b6000602082840312156104df576104de61049b565b5b600082013567ffffffffffffffff8111156104fd576104fc6104a0565b5b610509848285016104aa565b91505092915050565b600060c08284031215610528576105276104a5565b5b81905092915050565b6000602082840312156105475761054661049b565b5b600082013567ffffffffffffffff811115610565576105646104a0565b5b61057184828501610512565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006105a58261057a565b9050919050565b6105b58161059a565b82525050565b60006020820190506105d060008301846105ac565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156106105780820151818401526020810190506105f5565b60008484015250505050565b6000601f19601f8301169050919050565b6000610638826105d6565b61064281856105e1565b93506106528185602086016105f2565b61065b8161061c565b840191505092915050565b60006020820190508181036000830152610680818461062d565b905092915050565b600080fd5b600080fd5b600080fd5b600080833560016020038436030381126106b4576106b3610688565b5b80840192508235915067ffffffffffffffff8211156106d6576106d561068d565b5b6020830192506001820236038313156106f2576106f1610692565b5b509250929050565b600082905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061077b57607f821691505b60208210810361078e5761078d610734565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026107f67fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826107b9565b61080086836107b9565b95508019841693508086168417925050509392505050565b6000819050919050565b600061083d61083861083384610467565b610818565b610467565b9050919050565b6000819050919050565b61085783610822565b61086b61086382610844565b8484546107c6565b825550505050565b600090565b610880610873565b61088b81848461084e565b505050565b5b818110156108af576108a4600082610878565b600181019050610891565b5050565b601f8211156108f4576108c581610794565b6108ce846107a9565b810160208510156108dd578190505b6108f16108e9856107a9565b830182610890565b50505b505050565b600082821c905092915050565b6000610917600019846008026108f9565b1980831691505092915050565b60006109308383610906565b9150826002028217905092915050565b61094a83836106fa565b67ffffffffffffffff81111561096357610962610705565b5b61096d8254610763565b6109788282856108b3565b6000601f8311600181146109a75760008415610995578287013590505b61099f8582610924565b865550610a07565b601f1984166109b586610794565b60005b828110156109dd578489013582556001820191506020850194506020810190506109b8565b868310156109fa57848901356109f6601f891682610906565b8355505b6001600288020188555050505b50505050505050565b610a198161059a565b8114610a2457600080fd5b50565b600081359050610a3681610a10565b92915050565b600060208284031215610a5257610a5161049b565b5b6000610a6084828501610a27565b91505092915050565b60008160601b9050919050565b6000610a8182610a69565b9050919050565b6000610a9382610a76565b9050919050565b610aab610aa68261059a565b610a88565b82525050565b6000610abd8284610a9a565b60148201915081905092915050565b610ad5826105d6565b67ffffffffffffffff811115610aee57610aed610705565b5b610af88254610763565b610b038282856108b3565b600060209050601f831160018114610b365760008415610b24578287015190505b610b2e8582610924565b865550610b96565b601f198416610b4486610794565b60005b82811015610b6c57848901518255600182019150602085019450602081019050610b47565b86831015610b895784890151610b85601f891682610906565b8355505b6001600288020188555050505b505050505050565b600081905092915050565b82818337600083830152505050565b6000610bc48385610b9e565b9350610bd1838584610ba9565b82840190509392505050565b6000610bea828486610bb8565b9150819050939250505056fea26469706673582212207c5ed9b805f7e22d563799330b1c6e310dd5b1625dc35c9598846e17a8a5686664736f6c63430008190033 diff --git a/testutil/contracts/Dapp.go b/testutil/contracts/Dapp.go new file mode 100644 index 0000000000..075e1d24dc --- /dev/null +++ b/testutil/contracts/Dapp.go @@ -0,0 +1,449 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package contracts + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription +) + +// ZetaInterfacesZetaMessage is an auto generated low-level Go binding around an user-defined struct. +type ZetaInterfacesZetaMessage struct { + ZetaTxSenderAddress []byte + SourceChainId *big.Int + DestinationAddress common.Address + ZetaValue *big.Int + Message []byte +} + +// ZetaInterfacesZetaRevert is an auto generated low-level Go binding around an user-defined struct. +type ZetaInterfacesZetaRevert struct { + ZetaTxSenderAddress common.Address + SourceChainId *big.Int + DestinationAddress []byte + DestinationChainId *big.Int + RemainingZetaValue *big.Int + Message []byte +} + +// DappMetaData contains all meta data concerning the Dapp contract. +var DappMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"destinationAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"destinationChainId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"message\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes\",\"name\":\"zetaTxSenderAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"sourceChainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"zetaValue\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"internalType\":\"structZetaInterfaces.ZetaMessage\",\"name\":\"zetaMessage\",\"type\":\"tuple\"}],\"name\":\"onZetaMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"zetaTxSenderAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"sourceChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"destinationAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"destinationChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"remainingZetaValue\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"internalType\":\"structZetaInterfaces.ZetaRevert\",\"name\":\"zetaRevert\",\"type\":\"tuple\"}],\"name\":\"onZetaRevert\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sourceChainId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"zetaTxSenderAddress\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"zetaValue\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + Bin: "0x608060405234801561001057600080fd5b50604051806020016040528060008152506000908161002f91906102fe565b5060006001819055506000600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600381905550600060048190555060405180602001604052806000815250600590816100a891906102fe565b506103d0565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061012f57607f821691505b602082108103610142576101416100e8565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026101aa7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8261016d565b6101b4868361016d565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b60006101fb6101f66101f1846101cc565b6101d6565b6101cc565b9050919050565b6000819050919050565b610215836101e0565b61022961022182610202565b84845461017a565b825550505050565b600090565b61023e610231565b61024981848461020c565b505050565b5b8181101561026d57610262600082610236565b60018101905061024f565b5050565b601f8211156102b25761028381610148565b61028c8461015d565b8101602085101561029b578190505b6102af6102a78561015d565b83018261024e565b50505b505050565b600082821c905092915050565b60006102d5600019846008026102b7565b1980831691505092915050565b60006102ee83836102c4565b9150826002028217905092915050565b610307826100ae565b67ffffffffffffffff8111156103205761031f6100b9565b5b61032a8254610117565b610335828285610271565b600060209050601f8311600181146103685760008415610356578287015190505b61036085826102e2565b8655506103c8565b601f19841661037686610148565b60005b8281101561039e57848901518255600182019150602085019450602081019050610379565b868310156103bb57848901516103b7601f8916826102c4565b8355505b6001600288020188555050505b505050505050565b610c2c806103df6000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c8063b07506111161005b578063b075061114610101578063ca3254691461011f578063e21f37ce1461013d578063ed6b866b1461015b57610088565b8063050337a21461008d5780631544298e146100ab5780633749c51a146100c95780633ff0693c146100e5575b600080fd5b610095610179565b6040516100a29190610480565b60405180910390f35b6100b361017f565b6040516100c09190610480565b60405180910390f35b6100e360048036038101906100de91906104c9565b610185565b005b6100ff60048036038101906100fa9190610531565b610231565b005b61010961031f565b6040516101169190610480565b60405180910390f35b610127610325565b60405161013491906105bb565b60405180910390f35b61014561034b565b6040516101529190610666565b60405180910390f35b6101636103d9565b6040516101709190610666565b60405180910390f35b60045481565b60015481565b8080600001906101959190610697565b600091826101a4929190610940565b5080602001356001819055508060400160208101906101c39190610a3c565b600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550806060013560048190555080806080019061021e9190610697565b6005918261022d929190610940565b5050565b8060000160208101906102449190610a3c565b6040516020016102549190610ab1565b604051602081830303815290604052600090816102719190610acc565b50806020013560018190555080806040019061028d9190610697565b60405161029b929190610bdd565b604051809103902060001c600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080606001356003819055508060800135600481905550808060a0019061030c9190610697565b6005918261031b929190610940565b5050565b60035481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6005805461035890610763565b80601f016020809104026020016040519081016040528092919081815260200182805461038490610763565b80156103d15780601f106103a6576101008083540402835291602001916103d1565b820191906000526020600020905b8154815290600101906020018083116103b457829003601f168201915b505050505081565b600080546103e690610763565b80601f016020809104026020016040519081016040528092919081815260200182805461041290610763565b801561045f5780601f106104345761010080835404028352916020019161045f565b820191906000526020600020905b81548152906001019060200180831161044257829003601f168201915b505050505081565b6000819050919050565b61047a81610467565b82525050565b60006020820190506104956000830184610471565b92915050565b600080fd5b600080fd5b600080fd5b600060a082840312156104c0576104bf6104a5565b5b81905092915050565b6000602082840312156104df576104de61049b565b5b600082013567ffffffffffffffff8111156104fd576104fc6104a0565b5b610509848285016104aa565b91505092915050565b600060c08284031215610528576105276104a5565b5b81905092915050565b6000602082840312156105475761054661049b565b5b600082013567ffffffffffffffff811115610565576105646104a0565b5b61057184828501610512565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006105a58261057a565b9050919050565b6105b58161059a565b82525050565b60006020820190506105d060008301846105ac565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156106105780820151818401526020810190506105f5565b60008484015250505050565b6000601f19601f8301169050919050565b6000610638826105d6565b61064281856105e1565b93506106528185602086016105f2565b61065b8161061c565b840191505092915050565b60006020820190508181036000830152610680818461062d565b905092915050565b600080fd5b600080fd5b600080fd5b600080833560016020038436030381126106b4576106b3610688565b5b80840192508235915067ffffffffffffffff8211156106d6576106d561068d565b5b6020830192506001820236038313156106f2576106f1610692565b5b509250929050565b600082905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061077b57607f821691505b60208210810361078e5761078d610734565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026107f67fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826107b9565b61080086836107b9565b95508019841693508086168417925050509392505050565b6000819050919050565b600061083d61083861083384610467565b610818565b610467565b9050919050565b6000819050919050565b61085783610822565b61086b61086382610844565b8484546107c6565b825550505050565b600090565b610880610873565b61088b81848461084e565b505050565b5b818110156108af576108a4600082610878565b600181019050610891565b5050565b601f8211156108f4576108c581610794565b6108ce846107a9565b810160208510156108dd578190505b6108f16108e9856107a9565b830182610890565b50505b505050565b600082821c905092915050565b6000610917600019846008026108f9565b1980831691505092915050565b60006109308383610906565b9150826002028217905092915050565b61094a83836106fa565b67ffffffffffffffff81111561096357610962610705565b5b61096d8254610763565b6109788282856108b3565b6000601f8311600181146109a75760008415610995578287013590505b61099f8582610924565b865550610a07565b601f1984166109b586610794565b60005b828110156109dd578489013582556001820191506020850194506020810190506109b8565b868310156109fa57848901356109f6601f891682610906565b8355505b6001600288020188555050505b50505050505050565b610a198161059a565b8114610a2457600080fd5b50565b600081359050610a3681610a10565b92915050565b600060208284031215610a5257610a5161049b565b5b6000610a6084828501610a27565b91505092915050565b60008160601b9050919050565b6000610a8182610a69565b9050919050565b6000610a9382610a76565b9050919050565b610aab610aa68261059a565b610a88565b82525050565b6000610abd8284610a9a565b60148201915081905092915050565b610ad5826105d6565b67ffffffffffffffff811115610aee57610aed610705565b5b610af88254610763565b610b038282856108b3565b600060209050601f831160018114610b365760008415610b24578287015190505b610b2e8582610924565b865550610b96565b601f198416610b4486610794565b60005b82811015610b6c57848901518255600182019150602085019450602081019050610b47565b86831015610b895784890151610b85601f891682610906565b8355505b6001600288020188555050505b505050505050565b600081905092915050565b82818337600083830152505050565b6000610bc48385610b9e565b9350610bd1838584610ba9565b82840190509392505050565b6000610bea828486610bb8565b9150819050939250505056fea26469706673582212207c5ed9b805f7e22d563799330b1c6e310dd5b1625dc35c9598846e17a8a5686664736f6c63430008190033", +} + +// DappABI is the input ABI used to generate the binding from. +// Deprecated: Use DappMetaData.ABI instead. +var DappABI = DappMetaData.ABI + +// DappBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use DappMetaData.Bin instead. +var DappBin = DappMetaData.Bin + +// DeployDapp deploys a new Ethereum contract, binding an instance of Dapp to it. +func DeployDapp(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Dapp, error) { + parsed, err := DappMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(DappBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &Dapp{DappCaller: DappCaller{contract: contract}, DappTransactor: DappTransactor{contract: contract}, DappFilterer: DappFilterer{contract: contract}}, nil +} + +// Dapp is an auto generated Go binding around an Ethereum contract. +type Dapp struct { + DappCaller // Read-only binding to the contract + DappTransactor // Write-only binding to the contract + DappFilterer // Log filterer for contract events +} + +// DappCaller is an auto generated read-only Go binding around an Ethereum contract. +type DappCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// DappTransactor is an auto generated write-only Go binding around an Ethereum contract. +type DappTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// DappFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type DappFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// DappSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type DappSession struct { + Contract *Dapp // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// DappCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type DappCallerSession struct { + Contract *DappCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// DappTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type DappTransactorSession struct { + Contract *DappTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// DappRaw is an auto generated low-level Go binding around an Ethereum contract. +type DappRaw struct { + Contract *Dapp // Generic contract binding to access the raw methods on +} + +// DappCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type DappCallerRaw struct { + Contract *DappCaller // Generic read-only contract binding to access the raw methods on +} + +// DappTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type DappTransactorRaw struct { + Contract *DappTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewDapp creates a new instance of Dapp, bound to a specific deployed contract. +func NewDapp(address common.Address, backend bind.ContractBackend) (*Dapp, error) { + contract, err := bindDapp(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Dapp{DappCaller: DappCaller{contract: contract}, DappTransactor: DappTransactor{contract: contract}, DappFilterer: DappFilterer{contract: contract}}, nil +} + +// NewDappCaller creates a new read-only instance of Dapp, bound to a specific deployed contract. +func NewDappCaller(address common.Address, caller bind.ContractCaller) (*DappCaller, error) { + contract, err := bindDapp(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &DappCaller{contract: contract}, nil +} + +// NewDappTransactor creates a new write-only instance of Dapp, bound to a specific deployed contract. +func NewDappTransactor(address common.Address, transactor bind.ContractTransactor) (*DappTransactor, error) { + contract, err := bindDapp(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &DappTransactor{contract: contract}, nil +} + +// NewDappFilterer creates a new log filterer instance of Dapp, bound to a specific deployed contract. +func NewDappFilterer(address common.Address, filterer bind.ContractFilterer) (*DappFilterer, error) { + contract, err := bindDapp(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &DappFilterer{contract: contract}, nil +} + +// bindDapp binds a generic wrapper to an already deployed contract. +func bindDapp(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(DappABI)) + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Dapp *DappRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Dapp.Contract.DappCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Dapp *DappRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Dapp.Contract.DappTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Dapp *DappRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Dapp.Contract.DappTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Dapp *DappCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Dapp.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Dapp *DappTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Dapp.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Dapp *DappTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Dapp.Contract.contract.Transact(opts, method, params...) +} + +// DestinationAddress is a free data retrieval call binding the contract method 0xca325469. +// +// Solidity: function destinationAddress() view returns(address) +func (_Dapp *DappCaller) DestinationAddress(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Dapp.contract.Call(opts, &out, "destinationAddress") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// DestinationAddress is a free data retrieval call binding the contract method 0xca325469. +// +// Solidity: function destinationAddress() view returns(address) +func (_Dapp *DappSession) DestinationAddress() (common.Address, error) { + return _Dapp.Contract.DestinationAddress(&_Dapp.CallOpts) +} + +// DestinationAddress is a free data retrieval call binding the contract method 0xca325469. +// +// Solidity: function destinationAddress() view returns(address) +func (_Dapp *DappCallerSession) DestinationAddress() (common.Address, error) { + return _Dapp.Contract.DestinationAddress(&_Dapp.CallOpts) +} + +// DestinationChainId is a free data retrieval call binding the contract method 0xb0750611. +// +// Solidity: function destinationChainId() view returns(uint256) +func (_Dapp *DappCaller) DestinationChainId(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Dapp.contract.Call(opts, &out, "destinationChainId") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// DestinationChainId is a free data retrieval call binding the contract method 0xb0750611. +// +// Solidity: function destinationChainId() view returns(uint256) +func (_Dapp *DappSession) DestinationChainId() (*big.Int, error) { + return _Dapp.Contract.DestinationChainId(&_Dapp.CallOpts) +} + +// DestinationChainId is a free data retrieval call binding the contract method 0xb0750611. +// +// Solidity: function destinationChainId() view returns(uint256) +func (_Dapp *DappCallerSession) DestinationChainId() (*big.Int, error) { + return _Dapp.Contract.DestinationChainId(&_Dapp.CallOpts) +} + +// Message is a free data retrieval call binding the contract method 0xe21f37ce. +// +// Solidity: function message() view returns(bytes) +func (_Dapp *DappCaller) Message(opts *bind.CallOpts) ([]byte, error) { + var out []interface{} + err := _Dapp.contract.Call(opts, &out, "message") + + if err != nil { + return *new([]byte), err + } + + out0 := *abi.ConvertType(out[0], new([]byte)).(*[]byte) + + return out0, err + +} + +// Message is a free data retrieval call binding the contract method 0xe21f37ce. +// +// Solidity: function message() view returns(bytes) +func (_Dapp *DappSession) Message() ([]byte, error) { + return _Dapp.Contract.Message(&_Dapp.CallOpts) +} + +// Message is a free data retrieval call binding the contract method 0xe21f37ce. +// +// Solidity: function message() view returns(bytes) +func (_Dapp *DappCallerSession) Message() ([]byte, error) { + return _Dapp.Contract.Message(&_Dapp.CallOpts) +} + +// SourceChainId is a free data retrieval call binding the contract method 0x1544298e. +// +// Solidity: function sourceChainId() view returns(uint256) +func (_Dapp *DappCaller) SourceChainId(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Dapp.contract.Call(opts, &out, "sourceChainId") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// SourceChainId is a free data retrieval call binding the contract method 0x1544298e. +// +// Solidity: function sourceChainId() view returns(uint256) +func (_Dapp *DappSession) SourceChainId() (*big.Int, error) { + return _Dapp.Contract.SourceChainId(&_Dapp.CallOpts) +} + +// SourceChainId is a free data retrieval call binding the contract method 0x1544298e. +// +// Solidity: function sourceChainId() view returns(uint256) +func (_Dapp *DappCallerSession) SourceChainId() (*big.Int, error) { + return _Dapp.Contract.SourceChainId(&_Dapp.CallOpts) +} + +// ZetaTxSenderAddress is a free data retrieval call binding the contract method 0xed6b866b. +// +// Solidity: function zetaTxSenderAddress() view returns(bytes) +func (_Dapp *DappCaller) ZetaTxSenderAddress(opts *bind.CallOpts) ([]byte, error) { + var out []interface{} + err := _Dapp.contract.Call(opts, &out, "zetaTxSenderAddress") + + if err != nil { + return *new([]byte), err + } + + out0 := *abi.ConvertType(out[0], new([]byte)).(*[]byte) + + return out0, err + +} + +// ZetaTxSenderAddress is a free data retrieval call binding the contract method 0xed6b866b. +// +// Solidity: function zetaTxSenderAddress() view returns(bytes) +func (_Dapp *DappSession) ZetaTxSenderAddress() ([]byte, error) { + return _Dapp.Contract.ZetaTxSenderAddress(&_Dapp.CallOpts) +} + +// ZetaTxSenderAddress is a free data retrieval call binding the contract method 0xed6b866b. +// +// Solidity: function zetaTxSenderAddress() view returns(bytes) +func (_Dapp *DappCallerSession) ZetaTxSenderAddress() ([]byte, error) { + return _Dapp.Contract.ZetaTxSenderAddress(&_Dapp.CallOpts) +} + +// ZetaValue is a free data retrieval call binding the contract method 0x050337a2. +// +// Solidity: function zetaValue() view returns(uint256) +func (_Dapp *DappCaller) ZetaValue(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Dapp.contract.Call(opts, &out, "zetaValue") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// ZetaValue is a free data retrieval call binding the contract method 0x050337a2. +// +// Solidity: function zetaValue() view returns(uint256) +func (_Dapp *DappSession) ZetaValue() (*big.Int, error) { + return _Dapp.Contract.ZetaValue(&_Dapp.CallOpts) +} + +// ZetaValue is a free data retrieval call binding the contract method 0x050337a2. +// +// Solidity: function zetaValue() view returns(uint256) +func (_Dapp *DappCallerSession) ZetaValue() (*big.Int, error) { + return _Dapp.Contract.ZetaValue(&_Dapp.CallOpts) +} + +// OnZetaMessage is a paid mutator transaction binding the contract method 0x3749c51a. +// +// Solidity: function onZetaMessage((bytes,uint256,address,uint256,bytes) zetaMessage) returns() +func (_Dapp *DappTransactor) OnZetaMessage(opts *bind.TransactOpts, zetaMessage ZetaInterfacesZetaMessage) (*types.Transaction, error) { + return _Dapp.contract.Transact(opts, "onZetaMessage", zetaMessage) +} + +// OnZetaMessage is a paid mutator transaction binding the contract method 0x3749c51a. +// +// Solidity: function onZetaMessage((bytes,uint256,address,uint256,bytes) zetaMessage) returns() +func (_Dapp *DappSession) OnZetaMessage(zetaMessage ZetaInterfacesZetaMessage) (*types.Transaction, error) { + return _Dapp.Contract.OnZetaMessage(&_Dapp.TransactOpts, zetaMessage) +} + +// OnZetaMessage is a paid mutator transaction binding the contract method 0x3749c51a. +// +// Solidity: function onZetaMessage((bytes,uint256,address,uint256,bytes) zetaMessage) returns() +func (_Dapp *DappTransactorSession) OnZetaMessage(zetaMessage ZetaInterfacesZetaMessage) (*types.Transaction, error) { + return _Dapp.Contract.OnZetaMessage(&_Dapp.TransactOpts, zetaMessage) +} + +// OnZetaRevert is a paid mutator transaction binding the contract method 0x3ff0693c. +// +// Solidity: function onZetaRevert((address,uint256,bytes,uint256,uint256,bytes) zetaRevert) returns() +func (_Dapp *DappTransactor) OnZetaRevert(opts *bind.TransactOpts, zetaRevert ZetaInterfacesZetaRevert) (*types.Transaction, error) { + return _Dapp.contract.Transact(opts, "onZetaRevert", zetaRevert) +} + +// OnZetaRevert is a paid mutator transaction binding the contract method 0x3ff0693c. +// +// Solidity: function onZetaRevert((address,uint256,bytes,uint256,uint256,bytes) zetaRevert) returns() +func (_Dapp *DappSession) OnZetaRevert(zetaRevert ZetaInterfacesZetaRevert) (*types.Transaction, error) { + return _Dapp.Contract.OnZetaRevert(&_Dapp.TransactOpts, zetaRevert) +} + +// OnZetaRevert is a paid mutator transaction binding the contract method 0x3ff0693c. +// +// Solidity: function onZetaRevert((address,uint256,bytes,uint256,uint256,bytes) zetaRevert) returns() +func (_Dapp *DappTransactorSession) OnZetaRevert(zetaRevert ZetaInterfacesZetaRevert) (*types.Transaction, error) { + return _Dapp.Contract.OnZetaRevert(&_Dapp.TransactOpts, zetaRevert) +} diff --git a/testutil/contracts/Dapp.json b/testutil/contracts/Dapp.json new file mode 100644 index 0000000000..b2bbb3a299 --- /dev/null +++ b/testutil/contracts/Dapp.json @@ -0,0 +1,173 @@ +{ + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "destinationAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "destinationChainId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "message", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes", + "name": "zetaTxSenderAddress", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "sourceChainId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "destinationAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "zetaValue", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "message", + "type": "bytes" + } + ], + "internalType": "struct ZetaInterfaces.ZetaMessage", + "name": "zetaMessage", + "type": "tuple" + } + ], + "name": "onZetaMessage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "zetaTxSenderAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "sourceChainId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "destinationAddress", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "destinationChainId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "remainingZetaValue", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "message", + "type": "bytes" + } + ], + "internalType": "struct ZetaInterfaces.ZetaRevert", + "name": "zetaRevert", + "type": "tuple" + } + ], + "name": "onZetaRevert", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "sourceChainId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "zetaTxSenderAddress", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "zetaValue", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bin": "608060405234801561001057600080fd5b50604051806020016040528060008152506000908161002f91906102fe565b5060006001819055506000600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600381905550600060048190555060405180602001604052806000815250600590816100a891906102fe565b506103d0565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061012f57607f821691505b602082108103610142576101416100e8565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026101aa7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8261016d565b6101b4868361016d565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b60006101fb6101f66101f1846101cc565b6101d6565b6101cc565b9050919050565b6000819050919050565b610215836101e0565b61022961022182610202565b84845461017a565b825550505050565b600090565b61023e610231565b61024981848461020c565b505050565b5b8181101561026d57610262600082610236565b60018101905061024f565b5050565b601f8211156102b25761028381610148565b61028c8461015d565b8101602085101561029b578190505b6102af6102a78561015d565b83018261024e565b50505b505050565b600082821c905092915050565b60006102d5600019846008026102b7565b1980831691505092915050565b60006102ee83836102c4565b9150826002028217905092915050565b610307826100ae565b67ffffffffffffffff8111156103205761031f6100b9565b5b61032a8254610117565b610335828285610271565b600060209050601f8311600181146103685760008415610356578287015190505b61036085826102e2565b8655506103c8565b601f19841661037686610148565b60005b8281101561039e57848901518255600182019150602085019450602081019050610379565b868310156103bb57848901516103b7601f8916826102c4565b8355505b6001600288020188555050505b505050505050565b610c2c806103df6000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c8063b07506111161005b578063b075061114610101578063ca3254691461011f578063e21f37ce1461013d578063ed6b866b1461015b57610088565b8063050337a21461008d5780631544298e146100ab5780633749c51a146100c95780633ff0693c146100e5575b600080fd5b610095610179565b6040516100a29190610480565b60405180910390f35b6100b361017f565b6040516100c09190610480565b60405180910390f35b6100e360048036038101906100de91906104c9565b610185565b005b6100ff60048036038101906100fa9190610531565b610231565b005b61010961031f565b6040516101169190610480565b60405180910390f35b610127610325565b60405161013491906105bb565b60405180910390f35b61014561034b565b6040516101529190610666565b60405180910390f35b6101636103d9565b6040516101709190610666565b60405180910390f35b60045481565b60015481565b8080600001906101959190610697565b600091826101a4929190610940565b5080602001356001819055508060400160208101906101c39190610a3c565b600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550806060013560048190555080806080019061021e9190610697565b6005918261022d929190610940565b5050565b8060000160208101906102449190610a3c565b6040516020016102549190610ab1565b604051602081830303815290604052600090816102719190610acc565b50806020013560018190555080806040019061028d9190610697565b60405161029b929190610bdd565b604051809103902060001c600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080606001356003819055508060800135600481905550808060a0019061030c9190610697565b6005918261031b929190610940565b5050565b60035481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6005805461035890610763565b80601f016020809104026020016040519081016040528092919081815260200182805461038490610763565b80156103d15780601f106103a6576101008083540402835291602001916103d1565b820191906000526020600020905b8154815290600101906020018083116103b457829003601f168201915b505050505081565b600080546103e690610763565b80601f016020809104026020016040519081016040528092919081815260200182805461041290610763565b801561045f5780601f106104345761010080835404028352916020019161045f565b820191906000526020600020905b81548152906001019060200180831161044257829003601f168201915b505050505081565b6000819050919050565b61047a81610467565b82525050565b60006020820190506104956000830184610471565b92915050565b600080fd5b600080fd5b600080fd5b600060a082840312156104c0576104bf6104a5565b5b81905092915050565b6000602082840312156104df576104de61049b565b5b600082013567ffffffffffffffff8111156104fd576104fc6104a0565b5b610509848285016104aa565b91505092915050565b600060c08284031215610528576105276104a5565b5b81905092915050565b6000602082840312156105475761054661049b565b5b600082013567ffffffffffffffff811115610565576105646104a0565b5b61057184828501610512565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006105a58261057a565b9050919050565b6105b58161059a565b82525050565b60006020820190506105d060008301846105ac565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156106105780820151818401526020810190506105f5565b60008484015250505050565b6000601f19601f8301169050919050565b6000610638826105d6565b61064281856105e1565b93506106528185602086016105f2565b61065b8161061c565b840191505092915050565b60006020820190508181036000830152610680818461062d565b905092915050565b600080fd5b600080fd5b600080fd5b600080833560016020038436030381126106b4576106b3610688565b5b80840192508235915067ffffffffffffffff8211156106d6576106d561068d565b5b6020830192506001820236038313156106f2576106f1610692565b5b509250929050565b600082905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061077b57607f821691505b60208210810361078e5761078d610734565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026107f67fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826107b9565b61080086836107b9565b95508019841693508086168417925050509392505050565b6000819050919050565b600061083d61083861083384610467565b610818565b610467565b9050919050565b6000819050919050565b61085783610822565b61086b61086382610844565b8484546107c6565b825550505050565b600090565b610880610873565b61088b81848461084e565b505050565b5b818110156108af576108a4600082610878565b600181019050610891565b5050565b601f8211156108f4576108c581610794565b6108ce846107a9565b810160208510156108dd578190505b6108f16108e9856107a9565b830182610890565b50505b505050565b600082821c905092915050565b6000610917600019846008026108f9565b1980831691505092915050565b60006109308383610906565b9150826002028217905092915050565b61094a83836106fa565b67ffffffffffffffff81111561096357610962610705565b5b61096d8254610763565b6109788282856108b3565b6000601f8311600181146109a75760008415610995578287013590505b61099f8582610924565b865550610a07565b601f1984166109b586610794565b60005b828110156109dd578489013582556001820191506020850194506020810190506109b8565b868310156109fa57848901356109f6601f891682610906565b8355505b6001600288020188555050505b50505050505050565b610a198161059a565b8114610a2457600080fd5b50565b600081359050610a3681610a10565b92915050565b600060208284031215610a5257610a5161049b565b5b6000610a6084828501610a27565b91505092915050565b60008160601b9050919050565b6000610a8182610a69565b9050919050565b6000610a9382610a76565b9050919050565b610aab610aa68261059a565b610a88565b82525050565b6000610abd8284610a9a565b60148201915081905092915050565b610ad5826105d6565b67ffffffffffffffff811115610aee57610aed610705565b5b610af88254610763565b610b038282856108b3565b600060209050601f831160018114610b365760008415610b24578287015190505b610b2e8582610924565b865550610b96565b601f198416610b4486610794565b60005b82811015610b6c57848901518255600182019150602085019450602081019050610b47565b86831015610b895784890151610b85601f891682610906565b8355505b6001600288020188555050505b505050505050565b600081905092915050565b82818337600083830152505050565b6000610bc48385610b9e565b9350610bd1838584610ba9565b82840190509392505050565b6000610bea828486610bb8565b9150819050939250505056fea26469706673582212207c5ed9b805f7e22d563799330b1c6e310dd5b1625dc35c9598846e17a8a5686664736f6c63430008190033" +} diff --git a/testutil/contracts/Dapp.sol b/testutil/contracts/Dapp.sol new file mode 100644 index 0000000000..c8deef9e6b --- /dev/null +++ b/testutil/contracts/Dapp.sol @@ -0,0 +1,83 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.7; + +interface ZetaInterfaces { + /** + * @dev Use SendInput to interact with the Connector: connector.send(SendInput) + */ + struct SendInput { + /// @dev Chain id of the destination chain. More about chain ids https://docs.zetachain.com/learn/glossary#chain-id + uint256 destinationChainId; + /// @dev Address receiving the message on the destination chain (expressed in bytes since it can be non-EVM) + bytes destinationAddress; + /// @dev Gas limit for the destination chain's transaction + uint256 destinationGasLimit; + /// @dev An encoded, arbitrary message to be parsed by the destination contract + bytes message; + /// @dev ZETA to be sent cross-chain + ZetaChain gas fees + destination chain gas fees (expressed in ZETA) + uint256 zetaValueAndGas; + /// @dev Optional parameters for the ZetaChain protocol + bytes zetaParams; + } + + /** + * @dev Our Connector calls onZetaMessage with this struct as argument + */ + struct ZetaMessage { + bytes zetaTxSenderAddress; + uint256 sourceChainId; + address destinationAddress; + /// @dev Remaining ZETA from zetaValueAndGas after subtracting ZetaChain gas fees and destination gas fees + uint256 zetaValue; + bytes message; + } + + /** + * @dev Our Connector calls onZetaRevert with this struct as argument + */ + struct ZetaRevert { + address zetaTxSenderAddress; + uint256 sourceChainId; + bytes destinationAddress; + uint256 destinationChainId; + /// @dev Equals to: zetaValueAndGas - ZetaChain gas fees - destination chain gas fees - source chain revert tx gas fees + uint256 remainingZetaValue; + bytes message; + } +} + +// Dapp is a sample comtract that implements ZetaReceiver and is used for unit testing +// It sets the values of the ZetaMessage struct to its public variables which can then be queried to check if the function was called correctly +contract Dapp { + bytes public zetaTxSenderAddress; + uint256 public sourceChainId; + address public destinationAddress; + uint256 public destinationChainId; + uint256 public zetaValue; + bytes public message; + + constructor() { + zetaTxSenderAddress = ""; + sourceChainId = 0; + destinationAddress = address(0); + destinationChainId = 0; + zetaValue = 0; + message = ""; + } + + function onZetaMessage(ZetaInterfaces.ZetaMessage calldata zetaMessage) external{ + zetaTxSenderAddress = zetaMessage.zetaTxSenderAddress; + sourceChainId = zetaMessage.sourceChainId; + destinationAddress = zetaMessage.destinationAddress; + zetaValue = zetaMessage.zetaValue; + message = zetaMessage.message; + } + function onZetaRevert(ZetaInterfaces.ZetaRevert calldata zetaRevert) external { + zetaTxSenderAddress = abi.encodePacked(zetaRevert.zetaTxSenderAddress); + sourceChainId = zetaRevert.sourceChainId; + destinationAddress = address(uint160(uint256(keccak256(zetaRevert.destinationAddress)))); + destinationChainId = zetaRevert.destinationChainId; + zetaValue = zetaRevert.remainingZetaValue; + message = zetaRevert.message; + } +} \ No newline at end of file diff --git a/testutil/contracts/DappReverter.abi b/testutil/contracts/DappReverter.abi new file mode 100644 index 0000000000..8d7a270e57 --- /dev/null +++ b/testutil/contracts/DappReverter.abi @@ -0,0 +1,16 @@ +[ + { + "inputs": [], + "name": "onZetaMessage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "onZetaRevert", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/testutil/contracts/DappReverter.bin b/testutil/contracts/DappReverter.bin new file mode 100644 index 0000000000..8971240dc6 --- /dev/null +++ b/testutil/contracts/DappReverter.bin @@ -0,0 +1 @@ +6080604052348015600f57600080fd5b50608180601d6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c8063705847b71460375780639a19074914603f575b600080fd5b603d6047565b005b60456049565b005b565b56fea26469706673582212202ae32d3809d629fd01d309562a51297d761f547f4633bf45c73bf33c9955651164736f6c63430008190033 diff --git a/testutil/contracts/DappReverter.go b/testutil/contracts/DappReverter.go new file mode 100644 index 0000000000..590b28f515 --- /dev/null +++ b/testutil/contracts/DappReverter.go @@ -0,0 +1,244 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package contracts + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription +) + +// DappReverterMetaData contains all meta data concerning the DappReverter contract. +var DappReverterMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"name\":\"onZetaMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"onZetaRevert\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x6080604052348015600f57600080fd5b50608180601d6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c8063705847b71460375780639a19074914603f575b600080fd5b603d6047565b005b60456049565b005b565b56fea26469706673582212202ae32d3809d629fd01d309562a51297d761f547f4633bf45c73bf33c9955651164736f6c63430008190033", +} + +// DappReverterABI is the input ABI used to generate the binding from. +// Deprecated: Use DappReverterMetaData.ABI instead. +var DappReverterABI = DappReverterMetaData.ABI + +// DappReverterBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use DappReverterMetaData.Bin instead. +var DappReverterBin = DappReverterMetaData.Bin + +// DeployDappReverter deploys a new Ethereum contract, binding an instance of DappReverter to it. +func DeployDappReverter(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *DappReverter, error) { + parsed, err := DappReverterMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(DappReverterBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &DappReverter{DappReverterCaller: DappReverterCaller{contract: contract}, DappReverterTransactor: DappReverterTransactor{contract: contract}, DappReverterFilterer: DappReverterFilterer{contract: contract}}, nil +} + +// DappReverter is an auto generated Go binding around an Ethereum contract. +type DappReverter struct { + DappReverterCaller // Read-only binding to the contract + DappReverterTransactor // Write-only binding to the contract + DappReverterFilterer // Log filterer for contract events +} + +// DappReverterCaller is an auto generated read-only Go binding around an Ethereum contract. +type DappReverterCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// DappReverterTransactor is an auto generated write-only Go binding around an Ethereum contract. +type DappReverterTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// DappReverterFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type DappReverterFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// DappReverterSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type DappReverterSession struct { + Contract *DappReverter // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// DappReverterCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type DappReverterCallerSession struct { + Contract *DappReverterCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// DappReverterTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type DappReverterTransactorSession struct { + Contract *DappReverterTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// DappReverterRaw is an auto generated low-level Go binding around an Ethereum contract. +type DappReverterRaw struct { + Contract *DappReverter // Generic contract binding to access the raw methods on +} + +// DappReverterCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type DappReverterCallerRaw struct { + Contract *DappReverterCaller // Generic read-only contract binding to access the raw methods on +} + +// DappReverterTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type DappReverterTransactorRaw struct { + Contract *DappReverterTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewDappReverter creates a new instance of DappReverter, bound to a specific deployed contract. +func NewDappReverter(address common.Address, backend bind.ContractBackend) (*DappReverter, error) { + contract, err := bindDappReverter(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &DappReverter{DappReverterCaller: DappReverterCaller{contract: contract}, DappReverterTransactor: DappReverterTransactor{contract: contract}, DappReverterFilterer: DappReverterFilterer{contract: contract}}, nil +} + +// NewDappReverterCaller creates a new read-only instance of DappReverter, bound to a specific deployed contract. +func NewDappReverterCaller(address common.Address, caller bind.ContractCaller) (*DappReverterCaller, error) { + contract, err := bindDappReverter(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &DappReverterCaller{contract: contract}, nil +} + +// NewDappReverterTransactor creates a new write-only instance of DappReverter, bound to a specific deployed contract. +func NewDappReverterTransactor(address common.Address, transactor bind.ContractTransactor) (*DappReverterTransactor, error) { + contract, err := bindDappReverter(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &DappReverterTransactor{contract: contract}, nil +} + +// NewDappReverterFilterer creates a new log filterer instance of DappReverter, bound to a specific deployed contract. +func NewDappReverterFilterer(address common.Address, filterer bind.ContractFilterer) (*DappReverterFilterer, error) { + contract, err := bindDappReverter(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &DappReverterFilterer{contract: contract}, nil +} + +// bindDappReverter binds a generic wrapper to an already deployed contract. +func bindDappReverter(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(DappReverterABI)) + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_DappReverter *DappReverterRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _DappReverter.Contract.DappReverterCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_DappReverter *DappReverterRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _DappReverter.Contract.DappReverterTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_DappReverter *DappReverterRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _DappReverter.Contract.DappReverterTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_DappReverter *DappReverterCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _DappReverter.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_DappReverter *DappReverterTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _DappReverter.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_DappReverter *DappReverterTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _DappReverter.Contract.contract.Transact(opts, method, params...) +} + +// OnZetaMessage is a paid mutator transaction binding the contract method 0x705847b7. +// +// Solidity: function onZetaMessage() returns() +func (_DappReverter *DappReverterTransactor) OnZetaMessage(opts *bind.TransactOpts) (*types.Transaction, error) { + return _DappReverter.contract.Transact(opts, "onZetaMessage") +} + +// OnZetaMessage is a paid mutator transaction binding the contract method 0x705847b7. +// +// Solidity: function onZetaMessage() returns() +func (_DappReverter *DappReverterSession) OnZetaMessage() (*types.Transaction, error) { + return _DappReverter.Contract.OnZetaMessage(&_DappReverter.TransactOpts) +} + +// OnZetaMessage is a paid mutator transaction binding the contract method 0x705847b7. +// +// Solidity: function onZetaMessage() returns() +func (_DappReverter *DappReverterTransactorSession) OnZetaMessage() (*types.Transaction, error) { + return _DappReverter.Contract.OnZetaMessage(&_DappReverter.TransactOpts) +} + +// OnZetaRevert is a paid mutator transaction binding the contract method 0x9a190749. +// +// Solidity: function onZetaRevert() returns() +func (_DappReverter *DappReverterTransactor) OnZetaRevert(opts *bind.TransactOpts) (*types.Transaction, error) { + return _DappReverter.contract.Transact(opts, "onZetaRevert") +} + +// OnZetaRevert is a paid mutator transaction binding the contract method 0x9a190749. +// +// Solidity: function onZetaRevert() returns() +func (_DappReverter *DappReverterSession) OnZetaRevert() (*types.Transaction, error) { + return _DappReverter.Contract.OnZetaRevert(&_DappReverter.TransactOpts) +} + +// OnZetaRevert is a paid mutator transaction binding the contract method 0x9a190749. +// +// Solidity: function onZetaRevert() returns() +func (_DappReverter *DappReverterTransactorSession) OnZetaRevert() (*types.Transaction, error) { + return _DappReverter.Contract.OnZetaRevert(&_DappReverter.TransactOpts) +} diff --git a/testutil/contracts/DappReverter.json b/testutil/contracts/DappReverter.json new file mode 100644 index 0000000000..25f594b048 --- /dev/null +++ b/testutil/contracts/DappReverter.json @@ -0,0 +1,19 @@ +{ + "abi": [ + { + "inputs": [], + "name": "onZetaMessage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "onZetaRevert", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bin": "6080604052348015600f57600080fd5b50608180601d6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c8063705847b71460375780639a19074914603f575b600080fd5b603d6047565b005b60456049565b005b565b56fea26469706673582212202ae32d3809d629fd01d309562a51297d761f547f4633bf45c73bf33c9955651164736f6c63430008190033" +} diff --git a/testutil/contracts/DappReverter.sol b/testutil/contracts/DappReverter.sol new file mode 100644 index 0000000000..781a9b5cc5 --- /dev/null +++ b/testutil/contracts/DappReverter.sol @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.7; + +// DappReverter is a contract that can be used to test the reversion of a cross-chain call. +// It implements the onZetaMessage and onZetaRevert functions, which are called the ZEVM connector +contract DappReverter { + function onZetaMessage() external{} + function onZetaRevert() external {} +} \ No newline at end of file diff --git a/testutil/contracts/Depositor.bin b/testutil/contracts/Depositor.bin index ee38821756..ecf83280fc 100644 --- a/testutil/contracts/Depositor.bin +++ b/testutil/contracts/Depositor.bin @@ -1 +1 @@ -60a060405234801561001057600080fd5b5060405161073c38038061073c833981810160405281019061003291906100cf565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050506100fc565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061009c82610071565b9050919050565b6100ac81610091565b81146100b757600080fd5b50565b6000815190506100c9816100a3565b92915050565b6000602082840312156100e5576100e461006c565b5b60006100f3848285016100ba565b91505092915050565b60805161061f61011d6000396000818160e4015261016b015261061f6000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80633d496c9314610030575b600080fd5b61004a6004803603810190610045919061032a565b61004c565b005b8473ffffffffffffffffffffffffffffffffffffffff166323b872dd333084886100769190610415565b6040518463ffffffff1660e01b815260040161009493929190610475565b600060405180830381600087803b1580156100ae57600080fd5b505af11580156100c2573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000838761010f9190610415565b6040518363ffffffff1660e01b815260040161012c9291906104ac565b600060405180830381600087803b15801561014657600080fd5b505af115801561015a573d6000803e3d6000fd5b5050505060005b8181101561020b577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663e609055e8989898989896040518763ffffffff1660e01b81526004016101cc96959493929190610592565b600060405180830381600087803b1580156101e657600080fd5b505af11580156101fa573d6000803e3d6000fd5b505050508080600101915050610161565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126102445761024361021f565b5b8235905067ffffffffffffffff81111561026157610260610224565b5b60208301915083600182028301111561027d5761027c610229565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006102af82610284565b9050919050565b60006102c1826102a4565b9050919050565b6102d1816102b6565b81146102dc57600080fd5b50565b6000813590506102ee816102c8565b92915050565b6000819050919050565b610307816102f4565b811461031257600080fd5b50565b600081359050610324816102fe565b92915050565b600080600080600080600060a0888a03121561034957610348610215565b5b600088013567ffffffffffffffff8111156103675761036661021a565b5b6103738a828b0161022e565b975097505060206103868a828b016102df565b95505060406103978a828b01610315565b945050606088013567ffffffffffffffff8111156103b8576103b761021a565b5b6103c48a828b0161022e565b935093505060806103d78a828b01610315565b91505092959891949750929550565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610420826102f4565b915061042b836102f4565b9250828202610439816102f4565b915082820484148315176104505761044f6103e6565b5b5092915050565b610460816102a4565b82525050565b61046f816102f4565b82525050565b600060608201905061048a6000830186610457565b6104976020830185610457565b6104a46040830184610466565b949350505050565b60006040820190506104c16000830185610457565b6104ce6020830184610466565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b600061051283856104d5565b935061051f8385846104e6565b610528836104f5565b840190509392505050565b6000819050919050565b600061055861055361054e84610284565b610533565b610284565b9050919050565b600061056a8261053d565b9050919050565b600061057c8261055f565b9050919050565b61058c81610571565b82525050565b600060808201905081810360008301526105ad81888a610506565b90506105bc6020830187610583565b6105c96040830186610466565b81810360608301526105dc818486610506565b905097965050505050505056fea2646970667358221220760a7fe17b2cb5c1149915eaca64e78bee5636d1a85f4e43d923d0c1e246d44864736f6c63430008170033 +60a060405234801561001057600080fd5b5060405161073c38038061073c833981810160405281019061003291906100cf565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050506100fc565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061009c82610071565b9050919050565b6100ac81610091565b81146100b757600080fd5b50565b6000815190506100c9816100a3565b92915050565b6000602082840312156100e5576100e461006c565b5b60006100f3848285016100ba565b91505092915050565b60805161061f61011d6000396000818160e4015261016b015261061f6000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80633d496c9314610030575b600080fd5b61004a6004803603810190610045919061032a565b61004c565b005b8473ffffffffffffffffffffffffffffffffffffffff166323b872dd333084886100769190610415565b6040518463ffffffff1660e01b815260040161009493929190610475565b600060405180830381600087803b1580156100ae57600080fd5b505af11580156100c2573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000838761010f9190610415565b6040518363ffffffff1660e01b815260040161012c9291906104ac565b600060405180830381600087803b15801561014657600080fd5b505af115801561015a573d6000803e3d6000fd5b5050505060005b8181101561020b577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663e609055e8989898989896040518763ffffffff1660e01b81526004016101cc96959493929190610592565b600060405180830381600087803b1580156101e657600080fd5b505af11580156101fa573d6000803e3d6000fd5b505050508080600101915050610161565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126102445761024361021f565b5b8235905067ffffffffffffffff81111561026157610260610224565b5b60208301915083600182028301111561027d5761027c610229565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006102af82610284565b9050919050565b60006102c1826102a4565b9050919050565b6102d1816102b6565b81146102dc57600080fd5b50565b6000813590506102ee816102c8565b92915050565b6000819050919050565b610307816102f4565b811461031257600080fd5b50565b600081359050610324816102fe565b92915050565b600080600080600080600060a0888a03121561034957610348610215565b5b600088013567ffffffffffffffff8111156103675761036661021a565b5b6103738a828b0161022e565b975097505060206103868a828b016102df565b95505060406103978a828b01610315565b945050606088013567ffffffffffffffff8111156103b8576103b761021a565b5b6103c48a828b0161022e565b935093505060806103d78a828b01610315565b91505092959891949750929550565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610420826102f4565b915061042b836102f4565b9250828202610439816102f4565b915082820484148315176104505761044f6103e6565b5b5092915050565b610460816102a4565b82525050565b61046f816102f4565b82525050565b600060608201905061048a6000830186610457565b6104976020830185610457565b6104a46040830184610466565b949350505050565b60006040820190506104c16000830185610457565b6104ce6020830184610466565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b600061051283856104d5565b935061051f8385846104e6565b610528836104f5565b840190509392505050565b6000819050919050565b600061055861055361054e84610284565b610533565b610284565b9050919050565b600061056a8261053d565b9050919050565b600061057c8261055f565b9050919050565b61058c81610571565b82525050565b600060808201905081810360008301526105ad81888a610506565b90506105bc6020830187610583565b6105c96040830186610466565b81810360608301526105dc818486610506565b905097965050505050505056fea2646970667358221220a5a92c8f323a5a31ee98d3f743848cbaba73616e237bfd5f78b15847c3c0abb864736f6c63430008190033 diff --git a/testutil/contracts/Depositor.go b/testutil/contracts/Depositor.go index dafc33060e..6c85c24c5e 100644 --- a/testutil/contracts/Depositor.go +++ b/testutil/contracts/Depositor.go @@ -26,13 +26,12 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = event.NewSubscription - _ = abi.ConvertType ) // DepositorMetaData contains all meta data concerning the Depositor contract. var DepositorMetaData = &bind.MetaData{ ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"custody_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"recipient\",\"type\":\"bytes\"},{\"internalType\":\"contractIERC20\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"count\",\"type\":\"uint256\"}],\"name\":\"runDeposits\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x60a060405234801561001057600080fd5b5060405161073c38038061073c833981810160405281019061003291906100cf565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050506100fc565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061009c82610071565b9050919050565b6100ac81610091565b81146100b757600080fd5b50565b6000815190506100c9816100a3565b92915050565b6000602082840312156100e5576100e461006c565b5b60006100f3848285016100ba565b91505092915050565b60805161061f61011d6000396000818160e4015261016b015261061f6000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80633d496c9314610030575b600080fd5b61004a6004803603810190610045919061032a565b61004c565b005b8473ffffffffffffffffffffffffffffffffffffffff166323b872dd333084886100769190610415565b6040518463ffffffff1660e01b815260040161009493929190610475565b600060405180830381600087803b1580156100ae57600080fd5b505af11580156100c2573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000838761010f9190610415565b6040518363ffffffff1660e01b815260040161012c9291906104ac565b600060405180830381600087803b15801561014657600080fd5b505af115801561015a573d6000803e3d6000fd5b5050505060005b8181101561020b577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663e609055e8989898989896040518763ffffffff1660e01b81526004016101cc96959493929190610592565b600060405180830381600087803b1580156101e657600080fd5b505af11580156101fa573d6000803e3d6000fd5b505050508080600101915050610161565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126102445761024361021f565b5b8235905067ffffffffffffffff81111561026157610260610224565b5b60208301915083600182028301111561027d5761027c610229565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006102af82610284565b9050919050565b60006102c1826102a4565b9050919050565b6102d1816102b6565b81146102dc57600080fd5b50565b6000813590506102ee816102c8565b92915050565b6000819050919050565b610307816102f4565b811461031257600080fd5b50565b600081359050610324816102fe565b92915050565b600080600080600080600060a0888a03121561034957610348610215565b5b600088013567ffffffffffffffff8111156103675761036661021a565b5b6103738a828b0161022e565b975097505060206103868a828b016102df565b95505060406103978a828b01610315565b945050606088013567ffffffffffffffff8111156103b8576103b761021a565b5b6103c48a828b0161022e565b935093505060806103d78a828b01610315565b91505092959891949750929550565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610420826102f4565b915061042b836102f4565b9250828202610439816102f4565b915082820484148315176104505761044f6103e6565b5b5092915050565b610460816102a4565b82525050565b61046f816102f4565b82525050565b600060608201905061048a6000830186610457565b6104976020830185610457565b6104a46040830184610466565b949350505050565b60006040820190506104c16000830185610457565b6104ce6020830184610466565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b600061051283856104d5565b935061051f8385846104e6565b610528836104f5565b840190509392505050565b6000819050919050565b600061055861055361054e84610284565b610533565b610284565b9050919050565b600061056a8261053d565b9050919050565b600061057c8261055f565b9050919050565b61058c81610571565b82525050565b600060808201905081810360008301526105ad81888a610506565b90506105bc6020830187610583565b6105c96040830186610466565b81810360608301526105dc818486610506565b905097965050505050505056fea2646970667358221220760a7fe17b2cb5c1149915eaca64e78bee5636d1a85f4e43d923d0c1e246d44864736f6c63430008170033", + Bin: "0x60a060405234801561001057600080fd5b5060405161073c38038061073c833981810160405281019061003291906100cf565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050506100fc565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061009c82610071565b9050919050565b6100ac81610091565b81146100b757600080fd5b50565b6000815190506100c9816100a3565b92915050565b6000602082840312156100e5576100e461006c565b5b60006100f3848285016100ba565b91505092915050565b60805161061f61011d6000396000818160e4015261016b015261061f6000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80633d496c9314610030575b600080fd5b61004a6004803603810190610045919061032a565b61004c565b005b8473ffffffffffffffffffffffffffffffffffffffff166323b872dd333084886100769190610415565b6040518463ffffffff1660e01b815260040161009493929190610475565b600060405180830381600087803b1580156100ae57600080fd5b505af11580156100c2573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000838761010f9190610415565b6040518363ffffffff1660e01b815260040161012c9291906104ac565b600060405180830381600087803b15801561014657600080fd5b505af115801561015a573d6000803e3d6000fd5b5050505060005b8181101561020b577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663e609055e8989898989896040518763ffffffff1660e01b81526004016101cc96959493929190610592565b600060405180830381600087803b1580156101e657600080fd5b505af11580156101fa573d6000803e3d6000fd5b505050508080600101915050610161565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126102445761024361021f565b5b8235905067ffffffffffffffff81111561026157610260610224565b5b60208301915083600182028301111561027d5761027c610229565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006102af82610284565b9050919050565b60006102c1826102a4565b9050919050565b6102d1816102b6565b81146102dc57600080fd5b50565b6000813590506102ee816102c8565b92915050565b6000819050919050565b610307816102f4565b811461031257600080fd5b50565b600081359050610324816102fe565b92915050565b600080600080600080600060a0888a03121561034957610348610215565b5b600088013567ffffffffffffffff8111156103675761036661021a565b5b6103738a828b0161022e565b975097505060206103868a828b016102df565b95505060406103978a828b01610315565b945050606088013567ffffffffffffffff8111156103b8576103b761021a565b5b6103c48a828b0161022e565b935093505060806103d78a828b01610315565b91505092959891949750929550565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610420826102f4565b915061042b836102f4565b9250828202610439816102f4565b915082820484148315176104505761044f6103e6565b5b5092915050565b610460816102a4565b82525050565b61046f816102f4565b82525050565b600060608201905061048a6000830186610457565b6104976020830185610457565b6104a46040830184610466565b949350505050565b60006040820190506104c16000830185610457565b6104ce6020830184610466565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b600061051283856104d5565b935061051f8385846104e6565b610528836104f5565b840190509392505050565b6000819050919050565b600061055861055361054e84610284565b610533565b610284565b9050919050565b600061056a8261053d565b9050919050565b600061057c8261055f565b9050919050565b61058c81610571565b82525050565b600060808201905081810360008301526105ad81888a610506565b90506105bc6020830187610583565b6105c96040830186610466565b81810360608301526105dc818486610506565b905097965050505050505056fea2646970667358221220a5a92c8f323a5a31ee98d3f743848cbaba73616e237bfd5f78b15847c3c0abb864736f6c63430008190033", } // DepositorABI is the input ABI used to generate the binding from. @@ -157,11 +156,11 @@ func NewDepositorFilterer(address common.Address, filterer bind.ContractFilterer // bindDepositor binds a generic wrapper to an already deployed contract. func bindDepositor(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := DepositorMetaData.GetAbi() + parsed, err := abi.JSON(strings.NewReader(DepositorABI)) if err != nil { return nil, err } - return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil } // Call invokes the (constant) contract method with params as input values and diff --git a/testutil/contracts/Depositor.json b/testutil/contracts/Depositor.json index 93a4dd6c1e..f54b3e932f 100644 --- a/testutil/contracts/Depositor.json +++ b/testutil/contracts/Depositor.json @@ -45,5 +45,5 @@ "type": "function" } ], - "bin": "60a060405234801561001057600080fd5b5060405161073c38038061073c833981810160405281019061003291906100cf565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050506100fc565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061009c82610071565b9050919050565b6100ac81610091565b81146100b757600080fd5b50565b6000815190506100c9816100a3565b92915050565b6000602082840312156100e5576100e461006c565b5b60006100f3848285016100ba565b91505092915050565b60805161061f61011d6000396000818160e4015261016b015261061f6000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80633d496c9314610030575b600080fd5b61004a6004803603810190610045919061032a565b61004c565b005b8473ffffffffffffffffffffffffffffffffffffffff166323b872dd333084886100769190610415565b6040518463ffffffff1660e01b815260040161009493929190610475565b600060405180830381600087803b1580156100ae57600080fd5b505af11580156100c2573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000838761010f9190610415565b6040518363ffffffff1660e01b815260040161012c9291906104ac565b600060405180830381600087803b15801561014657600080fd5b505af115801561015a573d6000803e3d6000fd5b5050505060005b8181101561020b577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663e609055e8989898989896040518763ffffffff1660e01b81526004016101cc96959493929190610592565b600060405180830381600087803b1580156101e657600080fd5b505af11580156101fa573d6000803e3d6000fd5b505050508080600101915050610161565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126102445761024361021f565b5b8235905067ffffffffffffffff81111561026157610260610224565b5b60208301915083600182028301111561027d5761027c610229565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006102af82610284565b9050919050565b60006102c1826102a4565b9050919050565b6102d1816102b6565b81146102dc57600080fd5b50565b6000813590506102ee816102c8565b92915050565b6000819050919050565b610307816102f4565b811461031257600080fd5b50565b600081359050610324816102fe565b92915050565b600080600080600080600060a0888a03121561034957610348610215565b5b600088013567ffffffffffffffff8111156103675761036661021a565b5b6103738a828b0161022e565b975097505060206103868a828b016102df565b95505060406103978a828b01610315565b945050606088013567ffffffffffffffff8111156103b8576103b761021a565b5b6103c48a828b0161022e565b935093505060806103d78a828b01610315565b91505092959891949750929550565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610420826102f4565b915061042b836102f4565b9250828202610439816102f4565b915082820484148315176104505761044f6103e6565b5b5092915050565b610460816102a4565b82525050565b61046f816102f4565b82525050565b600060608201905061048a6000830186610457565b6104976020830185610457565b6104a46040830184610466565b949350505050565b60006040820190506104c16000830185610457565b6104ce6020830184610466565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b600061051283856104d5565b935061051f8385846104e6565b610528836104f5565b840190509392505050565b6000819050919050565b600061055861055361054e84610284565b610533565b610284565b9050919050565b600061056a8261053d565b9050919050565b600061057c8261055f565b9050919050565b61058c81610571565b82525050565b600060808201905081810360008301526105ad81888a610506565b90506105bc6020830187610583565b6105c96040830186610466565b81810360608301526105dc818486610506565b905097965050505050505056fea2646970667358221220760a7fe17b2cb5c1149915eaca64e78bee5636d1a85f4e43d923d0c1e246d44864736f6c63430008170033" + "bin": "60a060405234801561001057600080fd5b5060405161073c38038061073c833981810160405281019061003291906100cf565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050506100fc565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061009c82610071565b9050919050565b6100ac81610091565b81146100b757600080fd5b50565b6000815190506100c9816100a3565b92915050565b6000602082840312156100e5576100e461006c565b5b60006100f3848285016100ba565b91505092915050565b60805161061f61011d6000396000818160e4015261016b015261061f6000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80633d496c9314610030575b600080fd5b61004a6004803603810190610045919061032a565b61004c565b005b8473ffffffffffffffffffffffffffffffffffffffff166323b872dd333084886100769190610415565b6040518463ffffffff1660e01b815260040161009493929190610475565b600060405180830381600087803b1580156100ae57600080fd5b505af11580156100c2573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000838761010f9190610415565b6040518363ffffffff1660e01b815260040161012c9291906104ac565b600060405180830381600087803b15801561014657600080fd5b505af115801561015a573d6000803e3d6000fd5b5050505060005b8181101561020b577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663e609055e8989898989896040518763ffffffff1660e01b81526004016101cc96959493929190610592565b600060405180830381600087803b1580156101e657600080fd5b505af11580156101fa573d6000803e3d6000fd5b505050508080600101915050610161565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126102445761024361021f565b5b8235905067ffffffffffffffff81111561026157610260610224565b5b60208301915083600182028301111561027d5761027c610229565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006102af82610284565b9050919050565b60006102c1826102a4565b9050919050565b6102d1816102b6565b81146102dc57600080fd5b50565b6000813590506102ee816102c8565b92915050565b6000819050919050565b610307816102f4565b811461031257600080fd5b50565b600081359050610324816102fe565b92915050565b600080600080600080600060a0888a03121561034957610348610215565b5b600088013567ffffffffffffffff8111156103675761036661021a565b5b6103738a828b0161022e565b975097505060206103868a828b016102df565b95505060406103978a828b01610315565b945050606088013567ffffffffffffffff8111156103b8576103b761021a565b5b6103c48a828b0161022e565b935093505060806103d78a828b01610315565b91505092959891949750929550565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610420826102f4565b915061042b836102f4565b9250828202610439816102f4565b915082820484148315176104505761044f6103e6565b5b5092915050565b610460816102a4565b82525050565b61046f816102f4565b82525050565b600060608201905061048a6000830186610457565b6104976020830185610457565b6104a46040830184610466565b949350505050565b60006040820190506104c16000830185610457565b6104ce6020830184610466565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b600061051283856104d5565b935061051f8385846104e6565b610528836104f5565b840190509392505050565b6000819050919050565b600061055861055361054e84610284565b610533565b610284565b9050919050565b600061056a8261053d565b9050919050565b600061057c8261055f565b9050919050565b61058c81610571565b82525050565b600060808201905081810360008301526105ad81888a610506565b90506105bc6020830187610583565b6105c96040830186610466565b81810360608301526105dc818486610506565b905097965050505050505056fea2646970667358221220a5a92c8f323a5a31ee98d3f743848cbaba73616e237bfd5f78b15847c3c0abb864736f6c63430008190033" } diff --git a/testutil/contracts/Example.bin b/testutil/contracts/Example.bin index 99664eb481..2243b22b87 100644 --- a/testutil/contracts/Example.bin +++ b/testutil/contracts/Example.bin @@ -1 +1 @@ -608060405234801561001057600080fd5b506000808190555061043f806100276000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c8063afc874d214610067578063d720cb4514610071578063dd8e556c1461007b578063de43156e14610085578063fd5ad965146100a1578063febb0f7e146100ab575b600080fd5b61006f6100c9565b005b6100796100fb565b005b610083610136565b005b61009f600480360381019061009a91906102be565b610179565b005b6100a9610187565b005b6100b3610191565b6040516100c09190610371565b60405180910390f35b6040517fbfb4ebcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161012d906103e9565b60405180910390fd5b6000610177576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161016e906103e9565b60405180910390fd5b565b826000819055505050505050565b6001600081905550565b60005481565b600080fd5b600080fd5b600080fd5b6000606082840312156101bc576101bb6101a1565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006101f0826101c5565b9050919050565b610200816101e5565b811461020b57600080fd5b50565b60008135905061021d816101f7565b92915050565b6000819050919050565b61023681610223565b811461024157600080fd5b50565b6000813590506102538161022d565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261027e5761027d610259565b5b8235905067ffffffffffffffff81111561029b5761029a61025e565b5b6020830191508360018202830111156102b7576102b6610263565b5b9250929050565b6000806000806000608086880312156102da576102d9610197565b5b600086013567ffffffffffffffff8111156102f8576102f761019c565b5b610304888289016101a6565b95505060206103158882890161020e565b945050604061032688828901610244565b935050606086013567ffffffffffffffff8111156103475761034661019c565b5b61035388828901610268565b92509250509295509295909350565b61036b81610223565b82525050565b60006020820190506103866000830184610362565b92915050565b600082825260208201905092915050565b7f666f6f0000000000000000000000000000000000000000000000000000000000600082015250565b60006103d360038361038c565b91506103de8261039d565b602082019050919050565b60006020820190508181036000830152610402816103c6565b905091905056fea2646970667358221220938fb59316eb3dc6f80fe78e4272acbfc1f7115cdb0203223aeea348212973f764736f6c63430008170033 +6080604052348015600f57600080fd5b506000808190555061043f806100266000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c8063afc874d214610067578063d720cb4514610071578063dd8e556c1461007b578063de43156e14610085578063fd5ad965146100a1578063febb0f7e146100ab575b600080fd5b61006f6100c9565b005b6100796100fb565b005b610083610136565b005b61009f600480360381019061009a91906102be565b610179565b005b6100a9610187565b005b6100b3610191565b6040516100c09190610371565b60405180910390f35b6040517fbfb4ebcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161012d906103e9565b60405180910390fd5b6000610177576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161016e906103e9565b60405180910390fd5b565b826000819055505050505050565b6001600081905550565b60005481565b600080fd5b600080fd5b600080fd5b6000606082840312156101bc576101bb6101a1565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006101f0826101c5565b9050919050565b610200816101e5565b811461020b57600080fd5b50565b60008135905061021d816101f7565b92915050565b6000819050919050565b61023681610223565b811461024157600080fd5b50565b6000813590506102538161022d565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261027e5761027d610259565b5b8235905067ffffffffffffffff81111561029b5761029a61025e565b5b6020830191508360018202830111156102b7576102b6610263565b5b9250929050565b6000806000806000608086880312156102da576102d9610197565b5b600086013567ffffffffffffffff8111156102f8576102f761019c565b5b610304888289016101a6565b95505060206103158882890161020e565b945050604061032688828901610244565b935050606086013567ffffffffffffffff8111156103475761034661019c565b5b61035388828901610268565b92509250509295509295909350565b61036b81610223565b82525050565b60006020820190506103866000830184610362565b92915050565b600082825260208201905092915050565b7f666f6f0000000000000000000000000000000000000000000000000000000000600082015250565b60006103d360038361038c565b91506103de8261039d565b602082019050919050565b60006020820190508181036000830152610402816103c6565b905091905056fea2646970667358221220c9cedad580b18532a00be1e615813af1c20bb609a0a69b5f36d49ed76cc20b5064736f6c63430008190033 diff --git a/testutil/contracts/Example.go b/testutil/contracts/Example.go index feb9153d4e..ce9cab5826 100644 --- a/testutil/contracts/Example.go +++ b/testutil/contracts/Example.go @@ -26,7 +26,6 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = event.NewSubscription - _ = abi.ConvertType ) // ExamplezContext is an auto generated low-level Go binding around an user-defined struct. @@ -39,7 +38,7 @@ type ExamplezContext struct { // ExampleMetaData contains all meta data concerning the Example contract. var ExampleMetaData = &bind.MetaData{ ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"Foo\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"bar\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"doRevert\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"doRevertWithMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"doRevertWithRequire\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"doSucceed\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes\",\"name\":\"origin\",\"type\":\"bytes\"},{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"}],\"internalType\":\"structExample.zContext\",\"name\":\"context\",\"type\":\"tuple\"},{\"internalType\":\"address\",\"name\":\"zrc20\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"onCrossChainCall\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x608060405234801561001057600080fd5b506000808190555061043f806100276000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c8063afc874d214610067578063d720cb4514610071578063dd8e556c1461007b578063de43156e14610085578063fd5ad965146100a1578063febb0f7e146100ab575b600080fd5b61006f6100c9565b005b6100796100fb565b005b610083610136565b005b61009f600480360381019061009a91906102be565b610179565b005b6100a9610187565b005b6100b3610191565b6040516100c09190610371565b60405180910390f35b6040517fbfb4ebcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161012d906103e9565b60405180910390fd5b6000610177576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161016e906103e9565b60405180910390fd5b565b826000819055505050505050565b6001600081905550565b60005481565b600080fd5b600080fd5b600080fd5b6000606082840312156101bc576101bb6101a1565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006101f0826101c5565b9050919050565b610200816101e5565b811461020b57600080fd5b50565b60008135905061021d816101f7565b92915050565b6000819050919050565b61023681610223565b811461024157600080fd5b50565b6000813590506102538161022d565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261027e5761027d610259565b5b8235905067ffffffffffffffff81111561029b5761029a61025e565b5b6020830191508360018202830111156102b7576102b6610263565b5b9250929050565b6000806000806000608086880312156102da576102d9610197565b5b600086013567ffffffffffffffff8111156102f8576102f761019c565b5b610304888289016101a6565b95505060206103158882890161020e565b945050604061032688828901610244565b935050606086013567ffffffffffffffff8111156103475761034661019c565b5b61035388828901610268565b92509250509295509295909350565b61036b81610223565b82525050565b60006020820190506103866000830184610362565b92915050565b600082825260208201905092915050565b7f666f6f0000000000000000000000000000000000000000000000000000000000600082015250565b60006103d360038361038c565b91506103de8261039d565b602082019050919050565b60006020820190508181036000830152610402816103c6565b905091905056fea2646970667358221220938fb59316eb3dc6f80fe78e4272acbfc1f7115cdb0203223aeea348212973f764736f6c63430008170033", + Bin: "0x6080604052348015600f57600080fd5b506000808190555061043f806100266000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c8063afc874d214610067578063d720cb4514610071578063dd8e556c1461007b578063de43156e14610085578063fd5ad965146100a1578063febb0f7e146100ab575b600080fd5b61006f6100c9565b005b6100796100fb565b005b610083610136565b005b61009f600480360381019061009a91906102be565b610179565b005b6100a9610187565b005b6100b3610191565b6040516100c09190610371565b60405180910390f35b6040517fbfb4ebcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161012d906103e9565b60405180910390fd5b6000610177576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161016e906103e9565b60405180910390fd5b565b826000819055505050505050565b6001600081905550565b60005481565b600080fd5b600080fd5b600080fd5b6000606082840312156101bc576101bb6101a1565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006101f0826101c5565b9050919050565b610200816101e5565b811461020b57600080fd5b50565b60008135905061021d816101f7565b92915050565b6000819050919050565b61023681610223565b811461024157600080fd5b50565b6000813590506102538161022d565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261027e5761027d610259565b5b8235905067ffffffffffffffff81111561029b5761029a61025e565b5b6020830191508360018202830111156102b7576102b6610263565b5b9250929050565b6000806000806000608086880312156102da576102d9610197565b5b600086013567ffffffffffffffff8111156102f8576102f761019c565b5b610304888289016101a6565b95505060206103158882890161020e565b945050604061032688828901610244565b935050606086013567ffffffffffffffff8111156103475761034661019c565b5b61035388828901610268565b92509250509295509295909350565b61036b81610223565b82525050565b60006020820190506103866000830184610362565b92915050565b600082825260208201905092915050565b7f666f6f0000000000000000000000000000000000000000000000000000000000600082015250565b60006103d360038361038c565b91506103de8261039d565b602082019050919050565b60006020820190508181036000830152610402816103c6565b905091905056fea2646970667358221220c9cedad580b18532a00be1e615813af1c20bb609a0a69b5f36d49ed76cc20b5064736f6c63430008190033", } // ExampleABI is the input ABI used to generate the binding from. @@ -164,11 +163,11 @@ func NewExampleFilterer(address common.Address, filterer bind.ContractFilterer) // bindExample binds a generic wrapper to an already deployed contract. func bindExample(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := ExampleMetaData.GetAbi() + parsed, err := abi.JSON(strings.NewReader(ExampleABI)) if err != nil { return nil, err } - return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil } // Call invokes the (constant) contract method with params as input values and diff --git a/testutil/contracts/Example.json b/testutil/contracts/Example.json index 8276007384..9c67ba2186 100644 --- a/testutil/contracts/Example.json +++ b/testutil/contracts/Example.json @@ -97,5 +97,5 @@ "type": "function" } ], - "bin": "608060405234801561001057600080fd5b506000808190555061043f806100276000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c8063afc874d214610067578063d720cb4514610071578063dd8e556c1461007b578063de43156e14610085578063fd5ad965146100a1578063febb0f7e146100ab575b600080fd5b61006f6100c9565b005b6100796100fb565b005b610083610136565b005b61009f600480360381019061009a91906102be565b610179565b005b6100a9610187565b005b6100b3610191565b6040516100c09190610371565b60405180910390f35b6040517fbfb4ebcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161012d906103e9565b60405180910390fd5b6000610177576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161016e906103e9565b60405180910390fd5b565b826000819055505050505050565b6001600081905550565b60005481565b600080fd5b600080fd5b600080fd5b6000606082840312156101bc576101bb6101a1565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006101f0826101c5565b9050919050565b610200816101e5565b811461020b57600080fd5b50565b60008135905061021d816101f7565b92915050565b6000819050919050565b61023681610223565b811461024157600080fd5b50565b6000813590506102538161022d565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261027e5761027d610259565b5b8235905067ffffffffffffffff81111561029b5761029a61025e565b5b6020830191508360018202830111156102b7576102b6610263565b5b9250929050565b6000806000806000608086880312156102da576102d9610197565b5b600086013567ffffffffffffffff8111156102f8576102f761019c565b5b610304888289016101a6565b95505060206103158882890161020e565b945050604061032688828901610244565b935050606086013567ffffffffffffffff8111156103475761034661019c565b5b61035388828901610268565b92509250509295509295909350565b61036b81610223565b82525050565b60006020820190506103866000830184610362565b92915050565b600082825260208201905092915050565b7f666f6f0000000000000000000000000000000000000000000000000000000000600082015250565b60006103d360038361038c565b91506103de8261039d565b602082019050919050565b60006020820190508181036000830152610402816103c6565b905091905056fea2646970667358221220938fb59316eb3dc6f80fe78e4272acbfc1f7115cdb0203223aeea348212973f764736f6c63430008170033" + "bin": "6080604052348015600f57600080fd5b506000808190555061043f806100266000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c8063afc874d214610067578063d720cb4514610071578063dd8e556c1461007b578063de43156e14610085578063fd5ad965146100a1578063febb0f7e146100ab575b600080fd5b61006f6100c9565b005b6100796100fb565b005b610083610136565b005b61009f600480360381019061009a91906102be565b610179565b005b6100a9610187565b005b6100b3610191565b6040516100c09190610371565b60405180910390f35b6040517fbfb4ebcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161012d906103e9565b60405180910390fd5b6000610177576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161016e906103e9565b60405180910390fd5b565b826000819055505050505050565b6001600081905550565b60005481565b600080fd5b600080fd5b600080fd5b6000606082840312156101bc576101bb6101a1565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006101f0826101c5565b9050919050565b610200816101e5565b811461020b57600080fd5b50565b60008135905061021d816101f7565b92915050565b6000819050919050565b61023681610223565b811461024157600080fd5b50565b6000813590506102538161022d565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261027e5761027d610259565b5b8235905067ffffffffffffffff81111561029b5761029a61025e565b5b6020830191508360018202830111156102b7576102b6610263565b5b9250929050565b6000806000806000608086880312156102da576102d9610197565b5b600086013567ffffffffffffffff8111156102f8576102f761019c565b5b610304888289016101a6565b95505060206103158882890161020e565b945050604061032688828901610244565b935050606086013567ffffffffffffffff8111156103475761034661019c565b5b61035388828901610268565b92509250509295509295909350565b61036b81610223565b82525050565b60006020820190506103866000830184610362565b92915050565b600082825260208201905092915050565b7f666f6f0000000000000000000000000000000000000000000000000000000000600082015250565b60006103d360038361038c565b91506103de8261039d565b602082019050919050565b60006020820190508181036000830152610402816103c6565b905091905056fea2646970667358221220c9cedad580b18532a00be1e615813af1c20bb609a0a69b5f36d49ed76cc20b5064736f6c63430008190033" } diff --git a/testutil/contracts/Reverter.bin b/testutil/contracts/Reverter.bin index 99f23ea6b2..582d94be71 100644 --- a/testutil/contracts/Reverter.bin +++ b/testutil/contracts/Reverter.bin @@ -1 +1 @@ -608060405234801561001057600080fd5b5061027f806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063de43156e14610030575b600080fd5b61004a600480360381019061004591906101a5565b61004c565b005b6040517fbfb4ebcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080fd5b600080fd5b600080fd5b6000606082840312156100a3576100a2610088565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100d7826100ac565b9050919050565b6100e7816100cc565b81146100f257600080fd5b50565b600081359050610104816100de565b92915050565b6000819050919050565b61011d8161010a565b811461012857600080fd5b50565b60008135905061013a81610114565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261016557610164610140565b5b8235905067ffffffffffffffff81111561018257610181610145565b5b60208301915083600182028301111561019e5761019d61014a565b5b9250929050565b6000806000806000608086880312156101c1576101c061007e565b5b600086013567ffffffffffffffff8111156101df576101de610083565b5b6101eb8882890161008d565b95505060206101fc888289016100f5565b945050604061020d8882890161012b565b935050606086013567ffffffffffffffff81111561022e5761022d610083565b5b61023a8882890161014f565b9250925050929550929590935056fea26469706673582212205caf3458b11aefa34e575c056a968a87419cba0e852d4f512f684f63a45c509c64736f6c63430008170033 +6080604052348015600f57600080fd5b5061027f8061001f6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063de43156e14610030575b600080fd5b61004a600480360381019061004591906101a5565b61004c565b005b6040517fbfb4ebcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080fd5b600080fd5b600080fd5b6000606082840312156100a3576100a2610088565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100d7826100ac565b9050919050565b6100e7816100cc565b81146100f257600080fd5b50565b600081359050610104816100de565b92915050565b6000819050919050565b61011d8161010a565b811461012857600080fd5b50565b60008135905061013a81610114565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261016557610164610140565b5b8235905067ffffffffffffffff81111561018257610181610145565b5b60208301915083600182028301111561019e5761019d61014a565b5b9250929050565b6000806000806000608086880312156101c1576101c061007e565b5b600086013567ffffffffffffffff8111156101df576101de610083565b5b6101eb8882890161008d565b95505060206101fc888289016100f5565b945050604061020d8882890161012b565b935050606086013567ffffffffffffffff81111561022e5761022d610083565b5b61023a8882890161014f565b9250925050929550929590935056fea26469706673582212209d6fef8c2cffe61b2d6b1a5bf4d6f71d1ade0e1a1e6a8c8e9f09fe1c28a520d164736f6c63430008190033 diff --git a/testutil/contracts/Reverter.go b/testutil/contracts/Reverter.go index 57c46137f4..1e551e9362 100644 --- a/testutil/contracts/Reverter.go +++ b/testutil/contracts/Reverter.go @@ -26,7 +26,6 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = event.NewSubscription - _ = abi.ConvertType ) // ReverterzContext is an auto generated low-level Go binding around an user-defined struct. @@ -39,7 +38,7 @@ type ReverterzContext struct { // ReverterMetaData contains all meta data concerning the Reverter contract. var ReverterMetaData = &bind.MetaData{ ABI: "[{\"inputs\":[],\"name\":\"Foo\",\"type\":\"error\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes\",\"name\":\"origin\",\"type\":\"bytes\"},{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"}],\"internalType\":\"structReverter.zContext\",\"name\":\"context\",\"type\":\"tuple\"},{\"internalType\":\"address\",\"name\":\"zrc20\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"onCrossChainCall\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x608060405234801561001057600080fd5b5061027f806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063de43156e14610030575b600080fd5b61004a600480360381019061004591906101a5565b61004c565b005b6040517fbfb4ebcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080fd5b600080fd5b600080fd5b6000606082840312156100a3576100a2610088565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100d7826100ac565b9050919050565b6100e7816100cc565b81146100f257600080fd5b50565b600081359050610104816100de565b92915050565b6000819050919050565b61011d8161010a565b811461012857600080fd5b50565b60008135905061013a81610114565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261016557610164610140565b5b8235905067ffffffffffffffff81111561018257610181610145565b5b60208301915083600182028301111561019e5761019d61014a565b5b9250929050565b6000806000806000608086880312156101c1576101c061007e565b5b600086013567ffffffffffffffff8111156101df576101de610083565b5b6101eb8882890161008d565b95505060206101fc888289016100f5565b945050604061020d8882890161012b565b935050606086013567ffffffffffffffff81111561022e5761022d610083565b5b61023a8882890161014f565b9250925050929550929590935056fea26469706673582212205caf3458b11aefa34e575c056a968a87419cba0e852d4f512f684f63a45c509c64736f6c63430008170033", + Bin: "0x6080604052348015600f57600080fd5b5061027f8061001f6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063de43156e14610030575b600080fd5b61004a600480360381019061004591906101a5565b61004c565b005b6040517fbfb4ebcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080fd5b600080fd5b600080fd5b6000606082840312156100a3576100a2610088565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100d7826100ac565b9050919050565b6100e7816100cc565b81146100f257600080fd5b50565b600081359050610104816100de565b92915050565b6000819050919050565b61011d8161010a565b811461012857600080fd5b50565b60008135905061013a81610114565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261016557610164610140565b5b8235905067ffffffffffffffff81111561018257610181610145565b5b60208301915083600182028301111561019e5761019d61014a565b5b9250929050565b6000806000806000608086880312156101c1576101c061007e565b5b600086013567ffffffffffffffff8111156101df576101de610083565b5b6101eb8882890161008d565b95505060206101fc888289016100f5565b945050604061020d8882890161012b565b935050606086013567ffffffffffffffff81111561022e5761022d610083565b5b61023a8882890161014f565b9250925050929550929590935056fea26469706673582212209d6fef8c2cffe61b2d6b1a5bf4d6f71d1ade0e1a1e6a8c8e9f09fe1c28a520d164736f6c63430008190033", } // ReverterABI is the input ABI used to generate the binding from. @@ -164,11 +163,11 @@ func NewReverterFilterer(address common.Address, filterer bind.ContractFilterer) // bindReverter binds a generic wrapper to an already deployed contract. func bindReverter(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := ReverterMetaData.GetAbi() + parsed, err := abi.JSON(strings.NewReader(ReverterABI)) if err != nil { return nil, err } - return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil } // Call invokes the (constant) contract method with params as input values and diff --git a/testutil/contracts/Reverter.json b/testutil/contracts/Reverter.json index d644ed825d..c6ac51dde4 100644 --- a/testutil/contracts/Reverter.json +++ b/testutil/contracts/Reverter.json @@ -51,5 +51,5 @@ "type": "function" } ], - "bin": "608060405234801561001057600080fd5b5061027f806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063de43156e14610030575b600080fd5b61004a600480360381019061004591906101a5565b61004c565b005b6040517fbfb4ebcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080fd5b600080fd5b600080fd5b6000606082840312156100a3576100a2610088565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100d7826100ac565b9050919050565b6100e7816100cc565b81146100f257600080fd5b50565b600081359050610104816100de565b92915050565b6000819050919050565b61011d8161010a565b811461012857600080fd5b50565b60008135905061013a81610114565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261016557610164610140565b5b8235905067ffffffffffffffff81111561018257610181610145565b5b60208301915083600182028301111561019e5761019d61014a565b5b9250929050565b6000806000806000608086880312156101c1576101c061007e565b5b600086013567ffffffffffffffff8111156101df576101de610083565b5b6101eb8882890161008d565b95505060206101fc888289016100f5565b945050604061020d8882890161012b565b935050606086013567ffffffffffffffff81111561022e5761022d610083565b5b61023a8882890161014f565b9250925050929550929590935056fea26469706673582212205caf3458b11aefa34e575c056a968a87419cba0e852d4f512f684f63a45c509c64736f6c63430008170033" + "bin": "6080604052348015600f57600080fd5b5061027f8061001f6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063de43156e14610030575b600080fd5b61004a600480360381019061004591906101a5565b61004c565b005b6040517fbfb4ebcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080fd5b600080fd5b600080fd5b6000606082840312156100a3576100a2610088565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100d7826100ac565b9050919050565b6100e7816100cc565b81146100f257600080fd5b50565b600081359050610104816100de565b92915050565b6000819050919050565b61011d8161010a565b811461012857600080fd5b50565b60008135905061013a81610114565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261016557610164610140565b5b8235905067ffffffffffffffff81111561018257610181610145565b5b60208301915083600182028301111561019e5761019d61014a565b5b9250929050565b6000806000806000608086880312156101c1576101c061007e565b5b600086013567ffffffffffffffff8111156101df576101de610083565b5b6101eb8882890161008d565b95505060206101fc888289016100f5565b945050604061020d8882890161012b565b935050606086013567ffffffffffffffff81111561022e5761022d610083565b5b61023a8882890161014f565b9250925050929550929590935056fea26469706673582212209d6fef8c2cffe61b2d6b1a5bf4d6f71d1ade0e1a1e6a8c8e9f09fe1c28a520d164736f6c63430008190033" } diff --git a/testutil/contracts/Withdrawer.bin b/testutil/contracts/Withdrawer.bin index 3962c86387..b618dfb11d 100644 --- a/testutil/contracts/Withdrawer.bin +++ b/testutil/contracts/Withdrawer.bin @@ -1 +1 @@ -608060405234801561001057600080fd5b50610756806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e3be6f6814610030575b600080fd5b61004a600480360381019061004591906103ff565b61004c565b005b6000808473ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b815260040160408051808303816000875af115801561009b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100bf91906104c8565b915091508173ffffffffffffffffffffffffffffffffffffffff166323b872dd33306001876100ee9190610537565b856100f9919061056b565b6040518463ffffffff1660e01b8152600401610117939291906105cb565b600060405180830381600087803b15801561013157600080fd5b505af1158015610145573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b3866001866101739190610537565b8461017e919061056b565b6040518363ffffffff1660e01b815260040161019b929190610602565b600060405180830381600087803b1580156101b557600080fd5b505af11580156101c9573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff166323b872dd333086886101f7919061056b565b6040518463ffffffff1660e01b8152600401610215939291906105cb565b600060405180830381600087803b15801561022f57600080fd5b505af1158015610243573d6000803e3d6000fd5b5050505060005b838110156102e0578573ffffffffffffffffffffffffffffffffffffffff1663c70126268989886040518463ffffffff1660e01b815260040161028f93929190610689565b6020604051808303816000875af11580156102ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102d291906106f3565b50808060010191505061024a565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610319576103186102f4565b5b8235905067ffffffffffffffff811115610336576103356102f9565b5b602083019150836001820283011115610352576103516102fe565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061038482610359565b9050919050565b600061039682610379565b9050919050565b6103a68161038b565b81146103b157600080fd5b50565b6000813590506103c38161039d565b92915050565b6000819050919050565b6103dc816103c9565b81146103e757600080fd5b50565b6000813590506103f9816103d3565b92915050565b60008060008060006080868803121561041b5761041a6102ea565b5b600086013567ffffffffffffffff811115610439576104386102ef565b5b61044588828901610303565b95509550506020610458888289016103b4565b9350506040610469888289016103ea565b925050606061047a888289016103ea565b9150509295509295909350565b61049081610379565b811461049b57600080fd5b50565b6000815190506104ad81610487565b92915050565b6000815190506104c2816103d3565b92915050565b600080604083850312156104df576104de6102ea565b5b60006104ed8582860161049e565b92505060206104fe858286016104b3565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610542826103c9565b915061054d836103c9565b925082820190508082111561056557610564610508565b5b92915050565b6000610576826103c9565b9150610581836103c9565b925082820261058f816103c9565b915082820484148315176105a6576105a5610508565b5b5092915050565b6105b681610379565b82525050565b6105c5816103c9565b82525050565b60006060820190506105e060008301866105ad565b6105ed60208301856105ad565b6105fa60408301846105bc565b949350505050565b600060408201905061061760008301856105ad565b61062460208301846105bc565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b6000610668838561062b565b935061067583858461063c565b61067e8361064b565b840190509392505050565b600060408201905081810360008301526106a481858761065c565b90506106b360208301846105bc565b949350505050565b60008115159050919050565b6106d0816106bb565b81146106db57600080fd5b50565b6000815190506106ed816106c7565b92915050565b600060208284031215610709576107086102ea565b5b6000610717848285016106de565b9150509291505056fea26469706673582212204ea5580fd884f66b08516c0cea46d9e71553f966a77e2954832ccf2d9abe611b64736f6c63430008170033 +6080604052348015600f57600080fd5b506107568061001f6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e3be6f6814610030575b600080fd5b61004a600480360381019061004591906103ff565b61004c565b005b6000808473ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b815260040160408051808303816000875af115801561009b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100bf91906104c8565b915091508173ffffffffffffffffffffffffffffffffffffffff166323b872dd33306001876100ee9190610537565b856100f9919061056b565b6040518463ffffffff1660e01b8152600401610117939291906105cb565b600060405180830381600087803b15801561013157600080fd5b505af1158015610145573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b3866001866101739190610537565b8461017e919061056b565b6040518363ffffffff1660e01b815260040161019b929190610602565b600060405180830381600087803b1580156101b557600080fd5b505af11580156101c9573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff166323b872dd333086886101f7919061056b565b6040518463ffffffff1660e01b8152600401610215939291906105cb565b600060405180830381600087803b15801561022f57600080fd5b505af1158015610243573d6000803e3d6000fd5b5050505060005b838110156102e0578573ffffffffffffffffffffffffffffffffffffffff1663c70126268989886040518463ffffffff1660e01b815260040161028f93929190610689565b6020604051808303816000875af11580156102ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102d291906106f3565b50808060010191505061024a565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610319576103186102f4565b5b8235905067ffffffffffffffff811115610336576103356102f9565b5b602083019150836001820283011115610352576103516102fe565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061038482610359565b9050919050565b600061039682610379565b9050919050565b6103a68161038b565b81146103b157600080fd5b50565b6000813590506103c38161039d565b92915050565b6000819050919050565b6103dc816103c9565b81146103e757600080fd5b50565b6000813590506103f9816103d3565b92915050565b60008060008060006080868803121561041b5761041a6102ea565b5b600086013567ffffffffffffffff811115610439576104386102ef565b5b61044588828901610303565b95509550506020610458888289016103b4565b9350506040610469888289016103ea565b925050606061047a888289016103ea565b9150509295509295909350565b61049081610379565b811461049b57600080fd5b50565b6000815190506104ad81610487565b92915050565b6000815190506104c2816103d3565b92915050565b600080604083850312156104df576104de6102ea565b5b60006104ed8582860161049e565b92505060206104fe858286016104b3565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610542826103c9565b915061054d836103c9565b925082820190508082111561056557610564610508565b5b92915050565b6000610576826103c9565b9150610581836103c9565b925082820261058f816103c9565b915082820484148315176105a6576105a5610508565b5b5092915050565b6105b681610379565b82525050565b6105c5816103c9565b82525050565b60006060820190506105e060008301866105ad565b6105ed60208301856105ad565b6105fa60408301846105bc565b949350505050565b600060408201905061061760008301856105ad565b61062460208301846105bc565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b6000610668838561062b565b935061067583858461063c565b61067e8361064b565b840190509392505050565b600060408201905081810360008301526106a481858761065c565b90506106b360208301846105bc565b949350505050565b60008115159050919050565b6106d0816106bb565b81146106db57600080fd5b50565b6000815190506106ed816106c7565b92915050565b600060208284031215610709576107086102ea565b5b6000610717848285016106de565b9150509291505056fea264697066735822122041c37b70ead002476ecfdd58a860341299d12b3a46089a50bd573e25dbb8af3a64736f6c63430008190033 diff --git a/testutil/contracts/Withdrawer.go b/testutil/contracts/Withdrawer.go index 182335fe9b..3fb88de4aa 100644 --- a/testutil/contracts/Withdrawer.go +++ b/testutil/contracts/Withdrawer.go @@ -26,13 +26,12 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = event.NewSubscription - _ = abi.ConvertType ) // WithdrawerMetaData contains all meta data concerning the Withdrawer contract. var WithdrawerMetaData = &bind.MetaData{ ABI: "[{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"recipient\",\"type\":\"bytes\"},{\"internalType\":\"contractIZRC20\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"count\",\"type\":\"uint256\"}],\"name\":\"runWithdraws\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x608060405234801561001057600080fd5b50610756806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e3be6f6814610030575b600080fd5b61004a600480360381019061004591906103ff565b61004c565b005b6000808473ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b815260040160408051808303816000875af115801561009b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100bf91906104c8565b915091508173ffffffffffffffffffffffffffffffffffffffff166323b872dd33306001876100ee9190610537565b856100f9919061056b565b6040518463ffffffff1660e01b8152600401610117939291906105cb565b600060405180830381600087803b15801561013157600080fd5b505af1158015610145573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b3866001866101739190610537565b8461017e919061056b565b6040518363ffffffff1660e01b815260040161019b929190610602565b600060405180830381600087803b1580156101b557600080fd5b505af11580156101c9573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff166323b872dd333086886101f7919061056b565b6040518463ffffffff1660e01b8152600401610215939291906105cb565b600060405180830381600087803b15801561022f57600080fd5b505af1158015610243573d6000803e3d6000fd5b5050505060005b838110156102e0578573ffffffffffffffffffffffffffffffffffffffff1663c70126268989886040518463ffffffff1660e01b815260040161028f93929190610689565b6020604051808303816000875af11580156102ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102d291906106f3565b50808060010191505061024a565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610319576103186102f4565b5b8235905067ffffffffffffffff811115610336576103356102f9565b5b602083019150836001820283011115610352576103516102fe565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061038482610359565b9050919050565b600061039682610379565b9050919050565b6103a68161038b565b81146103b157600080fd5b50565b6000813590506103c38161039d565b92915050565b6000819050919050565b6103dc816103c9565b81146103e757600080fd5b50565b6000813590506103f9816103d3565b92915050565b60008060008060006080868803121561041b5761041a6102ea565b5b600086013567ffffffffffffffff811115610439576104386102ef565b5b61044588828901610303565b95509550506020610458888289016103b4565b9350506040610469888289016103ea565b925050606061047a888289016103ea565b9150509295509295909350565b61049081610379565b811461049b57600080fd5b50565b6000815190506104ad81610487565b92915050565b6000815190506104c2816103d3565b92915050565b600080604083850312156104df576104de6102ea565b5b60006104ed8582860161049e565b92505060206104fe858286016104b3565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610542826103c9565b915061054d836103c9565b925082820190508082111561056557610564610508565b5b92915050565b6000610576826103c9565b9150610581836103c9565b925082820261058f816103c9565b915082820484148315176105a6576105a5610508565b5b5092915050565b6105b681610379565b82525050565b6105c5816103c9565b82525050565b60006060820190506105e060008301866105ad565b6105ed60208301856105ad565b6105fa60408301846105bc565b949350505050565b600060408201905061061760008301856105ad565b61062460208301846105bc565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b6000610668838561062b565b935061067583858461063c565b61067e8361064b565b840190509392505050565b600060408201905081810360008301526106a481858761065c565b90506106b360208301846105bc565b949350505050565b60008115159050919050565b6106d0816106bb565b81146106db57600080fd5b50565b6000815190506106ed816106c7565b92915050565b600060208284031215610709576107086102ea565b5b6000610717848285016106de565b9150509291505056fea26469706673582212204ea5580fd884f66b08516c0cea46d9e71553f966a77e2954832ccf2d9abe611b64736f6c63430008170033", + Bin: "0x6080604052348015600f57600080fd5b506107568061001f6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e3be6f6814610030575b600080fd5b61004a600480360381019061004591906103ff565b61004c565b005b6000808473ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b815260040160408051808303816000875af115801561009b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100bf91906104c8565b915091508173ffffffffffffffffffffffffffffffffffffffff166323b872dd33306001876100ee9190610537565b856100f9919061056b565b6040518463ffffffff1660e01b8152600401610117939291906105cb565b600060405180830381600087803b15801561013157600080fd5b505af1158015610145573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b3866001866101739190610537565b8461017e919061056b565b6040518363ffffffff1660e01b815260040161019b929190610602565b600060405180830381600087803b1580156101b557600080fd5b505af11580156101c9573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff166323b872dd333086886101f7919061056b565b6040518463ffffffff1660e01b8152600401610215939291906105cb565b600060405180830381600087803b15801561022f57600080fd5b505af1158015610243573d6000803e3d6000fd5b5050505060005b838110156102e0578573ffffffffffffffffffffffffffffffffffffffff1663c70126268989886040518463ffffffff1660e01b815260040161028f93929190610689565b6020604051808303816000875af11580156102ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102d291906106f3565b50808060010191505061024a565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610319576103186102f4565b5b8235905067ffffffffffffffff811115610336576103356102f9565b5b602083019150836001820283011115610352576103516102fe565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061038482610359565b9050919050565b600061039682610379565b9050919050565b6103a68161038b565b81146103b157600080fd5b50565b6000813590506103c38161039d565b92915050565b6000819050919050565b6103dc816103c9565b81146103e757600080fd5b50565b6000813590506103f9816103d3565b92915050565b60008060008060006080868803121561041b5761041a6102ea565b5b600086013567ffffffffffffffff811115610439576104386102ef565b5b61044588828901610303565b95509550506020610458888289016103b4565b9350506040610469888289016103ea565b925050606061047a888289016103ea565b9150509295509295909350565b61049081610379565b811461049b57600080fd5b50565b6000815190506104ad81610487565b92915050565b6000815190506104c2816103d3565b92915050565b600080604083850312156104df576104de6102ea565b5b60006104ed8582860161049e565b92505060206104fe858286016104b3565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610542826103c9565b915061054d836103c9565b925082820190508082111561056557610564610508565b5b92915050565b6000610576826103c9565b9150610581836103c9565b925082820261058f816103c9565b915082820484148315176105a6576105a5610508565b5b5092915050565b6105b681610379565b82525050565b6105c5816103c9565b82525050565b60006060820190506105e060008301866105ad565b6105ed60208301856105ad565b6105fa60408301846105bc565b949350505050565b600060408201905061061760008301856105ad565b61062460208301846105bc565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b6000610668838561062b565b935061067583858461063c565b61067e8361064b565b840190509392505050565b600060408201905081810360008301526106a481858761065c565b90506106b360208301846105bc565b949350505050565b60008115159050919050565b6106d0816106bb565b81146106db57600080fd5b50565b6000815190506106ed816106c7565b92915050565b600060208284031215610709576107086102ea565b5b6000610717848285016106de565b9150509291505056fea264697066735822122041c37b70ead002476ecfdd58a860341299d12b3a46089a50bd573e25dbb8af3a64736f6c63430008190033", } // WithdrawerABI is the input ABI used to generate the binding from. @@ -157,11 +156,11 @@ func NewWithdrawerFilterer(address common.Address, filterer bind.ContractFiltere // bindWithdrawer binds a generic wrapper to an already deployed contract. func bindWithdrawer(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := WithdrawerMetaData.GetAbi() + parsed, err := abi.JSON(strings.NewReader(WithdrawerABI)) if err != nil { return nil, err } - return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil } // Call invokes the (constant) contract method with params as input values and diff --git a/testutil/contracts/Withdrawer.json b/testutil/contracts/Withdrawer.json index 58e8ec35b6..75e65977fa 100644 --- a/testutil/contracts/Withdrawer.json +++ b/testutil/contracts/Withdrawer.json @@ -29,5 +29,5 @@ "type": "function" } ], - "bin": "608060405234801561001057600080fd5b50610756806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e3be6f6814610030575b600080fd5b61004a600480360381019061004591906103ff565b61004c565b005b6000808473ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b815260040160408051808303816000875af115801561009b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100bf91906104c8565b915091508173ffffffffffffffffffffffffffffffffffffffff166323b872dd33306001876100ee9190610537565b856100f9919061056b565b6040518463ffffffff1660e01b8152600401610117939291906105cb565b600060405180830381600087803b15801561013157600080fd5b505af1158015610145573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b3866001866101739190610537565b8461017e919061056b565b6040518363ffffffff1660e01b815260040161019b929190610602565b600060405180830381600087803b1580156101b557600080fd5b505af11580156101c9573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff166323b872dd333086886101f7919061056b565b6040518463ffffffff1660e01b8152600401610215939291906105cb565b600060405180830381600087803b15801561022f57600080fd5b505af1158015610243573d6000803e3d6000fd5b5050505060005b838110156102e0578573ffffffffffffffffffffffffffffffffffffffff1663c70126268989886040518463ffffffff1660e01b815260040161028f93929190610689565b6020604051808303816000875af11580156102ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102d291906106f3565b50808060010191505061024a565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610319576103186102f4565b5b8235905067ffffffffffffffff811115610336576103356102f9565b5b602083019150836001820283011115610352576103516102fe565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061038482610359565b9050919050565b600061039682610379565b9050919050565b6103a68161038b565b81146103b157600080fd5b50565b6000813590506103c38161039d565b92915050565b6000819050919050565b6103dc816103c9565b81146103e757600080fd5b50565b6000813590506103f9816103d3565b92915050565b60008060008060006080868803121561041b5761041a6102ea565b5b600086013567ffffffffffffffff811115610439576104386102ef565b5b61044588828901610303565b95509550506020610458888289016103b4565b9350506040610469888289016103ea565b925050606061047a888289016103ea565b9150509295509295909350565b61049081610379565b811461049b57600080fd5b50565b6000815190506104ad81610487565b92915050565b6000815190506104c2816103d3565b92915050565b600080604083850312156104df576104de6102ea565b5b60006104ed8582860161049e565b92505060206104fe858286016104b3565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610542826103c9565b915061054d836103c9565b925082820190508082111561056557610564610508565b5b92915050565b6000610576826103c9565b9150610581836103c9565b925082820261058f816103c9565b915082820484148315176105a6576105a5610508565b5b5092915050565b6105b681610379565b82525050565b6105c5816103c9565b82525050565b60006060820190506105e060008301866105ad565b6105ed60208301856105ad565b6105fa60408301846105bc565b949350505050565b600060408201905061061760008301856105ad565b61062460208301846105bc565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b6000610668838561062b565b935061067583858461063c565b61067e8361064b565b840190509392505050565b600060408201905081810360008301526106a481858761065c565b90506106b360208301846105bc565b949350505050565b60008115159050919050565b6106d0816106bb565b81146106db57600080fd5b50565b6000815190506106ed816106c7565b92915050565b600060208284031215610709576107086102ea565b5b6000610717848285016106de565b9150509291505056fea26469706673582212204ea5580fd884f66b08516c0cea46d9e71553f966a77e2954832ccf2d9abe611b64736f6c63430008170033" + "bin": "6080604052348015600f57600080fd5b506107568061001f6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e3be6f6814610030575b600080fd5b61004a600480360381019061004591906103ff565b61004c565b005b6000808473ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b815260040160408051808303816000875af115801561009b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100bf91906104c8565b915091508173ffffffffffffffffffffffffffffffffffffffff166323b872dd33306001876100ee9190610537565b856100f9919061056b565b6040518463ffffffff1660e01b8152600401610117939291906105cb565b600060405180830381600087803b15801561013157600080fd5b505af1158015610145573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b3866001866101739190610537565b8461017e919061056b565b6040518363ffffffff1660e01b815260040161019b929190610602565b600060405180830381600087803b1580156101b557600080fd5b505af11580156101c9573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff166323b872dd333086886101f7919061056b565b6040518463ffffffff1660e01b8152600401610215939291906105cb565b600060405180830381600087803b15801561022f57600080fd5b505af1158015610243573d6000803e3d6000fd5b5050505060005b838110156102e0578573ffffffffffffffffffffffffffffffffffffffff1663c70126268989886040518463ffffffff1660e01b815260040161028f93929190610689565b6020604051808303816000875af11580156102ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102d291906106f3565b50808060010191505061024a565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610319576103186102f4565b5b8235905067ffffffffffffffff811115610336576103356102f9565b5b602083019150836001820283011115610352576103516102fe565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061038482610359565b9050919050565b600061039682610379565b9050919050565b6103a68161038b565b81146103b157600080fd5b50565b6000813590506103c38161039d565b92915050565b6000819050919050565b6103dc816103c9565b81146103e757600080fd5b50565b6000813590506103f9816103d3565b92915050565b60008060008060006080868803121561041b5761041a6102ea565b5b600086013567ffffffffffffffff811115610439576104386102ef565b5b61044588828901610303565b95509550506020610458888289016103b4565b9350506040610469888289016103ea565b925050606061047a888289016103ea565b9150509295509295909350565b61049081610379565b811461049b57600080fd5b50565b6000815190506104ad81610487565b92915050565b6000815190506104c2816103d3565b92915050565b600080604083850312156104df576104de6102ea565b5b60006104ed8582860161049e565b92505060206104fe858286016104b3565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610542826103c9565b915061054d836103c9565b925082820190508082111561056557610564610508565b5b92915050565b6000610576826103c9565b9150610581836103c9565b925082820261058f816103c9565b915082820484148315176105a6576105a5610508565b5b5092915050565b6105b681610379565b82525050565b6105c5816103c9565b82525050565b60006060820190506105e060008301866105ad565b6105ed60208301856105ad565b6105fa60408301846105bc565b949350505050565b600060408201905061061760008301856105ad565b61062460208301846105bc565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b6000610668838561062b565b935061067583858461063c565b61067e8361064b565b840190509392505050565b600060408201905081810360008301526106a481858761065c565b90506106b360208301846105bc565b949350505050565b60008115159050919050565b6106d0816106bb565b81146106db57600080fd5b50565b6000815190506106ed816106c7565b92915050565b600060208284031215610709576107086102ea565b5b6000610717848285016106de565b9150509291505056fea264697066735822122041c37b70ead002476ecfdd58a860341299d12b3a46089a50bd573e25dbb8af3a64736f6c63430008190033" } diff --git a/testutil/contracts/bindings.go b/testutil/contracts/bindings.go index 88052fa2b2..70db08dca4 100644 --- a/testutil/contracts/bindings.go +++ b/testutil/contracts/bindings.go @@ -22,4 +22,17 @@ //go:generate sh -c "cat Withdrawer.json | jq .bin | tr -d '\"' > Withdrawer.bin" //go:generate sh -c "abigen --abi Withdrawer.abi --bin Withdrawer.bin --pkg contracts --type Withdrawer --out Withdrawer.go" +// Dapp +// +//go:generate sh -c "solc --evm-version paris Dapp.sol --combined-json abi,bin | jq '.contracts.\"Dapp.sol:Dapp\"' > Dapp.json" +//go:generate sh -c "cat Dapp.json | jq .abi > Dapp.abi" +//go:generate sh -c "cat Dapp.json | jq .bin | tr -d '\"' > Dapp.bin" +//go:generate sh -c "abigen --abi Dapp.abi --bin Dapp.bin --pkg contracts --type Dapp --out Dapp.go" + +// DappReverter +//go:generate sh -c "solc --evm-version paris DappReverter.sol --combined-json abi,bin | jq '.contracts.\"DappReverter.sol:DappReverter\"' > DappReverter.json" +//go:generate sh -c "cat DappReverter.json | jq .abi > DappReverter.abi" +//go:generate sh -c "cat DappReverter.json | jq .bin | tr -d '\"' > DappReverter.bin" +//go:generate sh -c "abigen --abi DappReverter.abi --bin DappReverter.bin --pkg contracts --type DappReverter --out DappReverter.go" + package contracts diff --git a/testutil/keeper/mocks/crosschain/fungible.go b/testutil/keeper/mocks/crosschain/fungible.go index 0b7fc53c89..1380308910 100644 --- a/testutil/keeper/mocks/crosschain/fungible.go +++ b/testutil/keeper/mocks/crosschain/fungible.go @@ -597,6 +597,66 @@ func (_m *CrosschainFungibleKeeper) WithdrawFromGasStabilityPool(ctx types.Conte return r0 } +// ZEVMDepositAndCallContract provides a mock function with given fields: ctx, sender, to, inboundSenderChainID, inboundAmount, data, indexBytes +func (_m *CrosschainFungibleKeeper) ZETADepositAndCallContract(ctx types.Context, sender common.Address, to common.Address, inboundSenderChainID int64, inboundAmount *big.Int, data []byte, indexBytes [32]byte) (*evmtypes.MsgEthereumTxResponse, error) { + ret := _m.Called(ctx, sender, to, inboundSenderChainID, inboundAmount, data, indexBytes) + + if len(ret) == 0 { + panic("no return value specified for ZETADepositAndCallContract") + } + + var r0 *evmtypes.MsgEthereumTxResponse + var r1 error + if rf, ok := ret.Get(0).(func(types.Context, common.Address, common.Address, int64, *big.Int, []byte, [32]byte) (*evmtypes.MsgEthereumTxResponse, error)); ok { + return rf(ctx, sender, to, inboundSenderChainID, inboundAmount, data, indexBytes) + } + if rf, ok := ret.Get(0).(func(types.Context, common.Address, common.Address, int64, *big.Int, []byte, [32]byte) *evmtypes.MsgEthereumTxResponse); ok { + r0 = rf(ctx, sender, to, inboundSenderChainID, inboundAmount, data, indexBytes) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*evmtypes.MsgEthereumTxResponse) + } + } + + if rf, ok := ret.Get(1).(func(types.Context, common.Address, common.Address, int64, *big.Int, []byte, [32]byte) error); ok { + r1 = rf(ctx, sender, to, inboundSenderChainID, inboundAmount, data, indexBytes) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ZEVMRevertAndCallContract provides a mock function with given fields: ctx, sender, to, inboundSenderChainID, destinationChainID, remainingAmount, data, indexBytes +func (_m *CrosschainFungibleKeeper) ZETARevertAndCallContract(ctx types.Context, sender common.Address, to common.Address, inboundSenderChainID int64, destinationChainID int64, remainingAmount *big.Int, data []byte, indexBytes [32]byte) (*evmtypes.MsgEthereumTxResponse, error) { + ret := _m.Called(ctx, sender, to, inboundSenderChainID, destinationChainID, remainingAmount, data, indexBytes) + + if len(ret) == 0 { + panic("no return value specified for ZETARevertAndCallContract") + } + + var r0 *evmtypes.MsgEthereumTxResponse + var r1 error + if rf, ok := ret.Get(0).(func(types.Context, common.Address, common.Address, int64, int64, *big.Int, []byte, [32]byte) (*evmtypes.MsgEthereumTxResponse, error)); ok { + return rf(ctx, sender, to, inboundSenderChainID, destinationChainID, remainingAmount, data, indexBytes) + } + if rf, ok := ret.Get(0).(func(types.Context, common.Address, common.Address, int64, int64, *big.Int, []byte, [32]byte) *evmtypes.MsgEthereumTxResponse); ok { + r0 = rf(ctx, sender, to, inboundSenderChainID, destinationChainID, remainingAmount, data, indexBytes) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*evmtypes.MsgEthereumTxResponse) + } + } + + if rf, ok := ret.Get(1).(func(types.Context, common.Address, common.Address, int64, int64, *big.Int, []byte, [32]byte) error); ok { + r1 = rf(ctx, sender, to, inboundSenderChainID, destinationChainID, remainingAmount, data, indexBytes) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // ZRC20DepositAndCallContract provides a mock function with given fields: ctx, from, to, amount, senderChainID, data, coinType, asset func (_m *CrosschainFungibleKeeper) ZRC20DepositAndCallContract(ctx types.Context, from []byte, to common.Address, amount *big.Int, senderChainID int64, data []byte, coinType coin.CoinType, asset string) (*evmtypes.MsgEthereumTxResponse, bool, error) { ret := _m.Called(ctx, from, to, amount, senderChainID, data, coinType, asset) diff --git a/testutil/sample/crosschain.go b/testutil/sample/crosschain.go index f7b563d2bf..5a0d8aafdb 100644 --- a/testutil/sample/crosschain.go +++ b/testutil/sample/crosschain.go @@ -1,6 +1,7 @@ package sample import ( + "encoding/base64" "encoding/json" "math/rand" "testing" @@ -208,7 +209,7 @@ func InboundVote(coinType coin.CoinType, from, to int64) types.MsgVoteOnObserved Receiver: EthAddress().String(), ReceiverChain: Chain(to).GetChainId(), Amount: UintInRange(10000000, 1000000000), - Message: String(), + Message: base64.StdEncoding.EncodeToString(Bytes()), InBlockHeight: Uint64InRange(1, 10000), GasLimit: 1000000000, InTxHash: Hash().String(), diff --git a/x/crosschain/keeper/cctx.go b/x/crosschain/keeper/cctx.go index 10613e2d6c..42604c9098 100644 --- a/x/crosschain/keeper/cctx.go +++ b/x/crosschain/keeper/cctx.go @@ -16,12 +16,26 @@ import ( // 3. set the mapping nonce => cctx // 4. update the zeta accounting func (k Keeper) SetCctxAndNonceToCctxAndInTxHashToCctx(ctx sdk.Context, cctx types.CrossChainTx) { - k.SetCrossChainTx(ctx, cctx) + tss, found := k.zetaObserverKeeper.GetTSS(ctx) + if !found { + return + } + // set mapping nonce => cctxIndex + if cctx.CctxStatus.Status == types.CctxStatus_PendingOutbound || cctx.CctxStatus.Status == types.CctxStatus_PendingRevert { + k.GetObserverKeeper().SetNonceToCctx(ctx, observerTypes.NonceToCctx{ + ChainId: cctx.GetCurrentOutTxParam().ReceiverChainId, + // #nosec G701 always in range + Nonce: int64(cctx.GetCurrentOutTxParam().OutboundTxTssNonce), + CctxIndex: cctx.Index, + Tss: tss.TssPubkey, + }) + } + k.SetCrossChainTx(ctx, cctx) // set mapping inTxHash -> cctxIndex in, _ := k.GetInTxHashToCctx(ctx, cctx.InboundTxParams.InboundTxObservedHash) in.InTxHash = cctx.InboundTxParams.InboundTxObservedHash - found := false + found = false for _, cctxIndex := range in.CctxIndex { if cctxIndex == cctx.Index { found = true @@ -33,20 +47,6 @@ func (k Keeper) SetCctxAndNonceToCctxAndInTxHashToCctx(ctx sdk.Context, cctx typ } k.SetInTxHashToCctx(ctx, in) - tss, found := k.zetaObserverKeeper.GetTSS(ctx) - if !found { - return - } - // set mapping nonce => cctxIndex - if cctx.CctxStatus.Status == types.CctxStatus_PendingOutbound || cctx.CctxStatus.Status == types.CctxStatus_PendingRevert { - k.GetObserverKeeper().SetNonceToCctx(ctx, observerTypes.NonceToCctx{ - ChainId: cctx.GetCurrentOutTxParam().ReceiverChainId, - // #nosec G701 always in range - Nonce: int64(cctx.GetCurrentOutTxParam().OutboundTxTssNonce), - CctxIndex: cctx.Index, - Tss: tss.TssPubkey, - }) - } if cctx.CctxStatus.Status == types.CctxStatus_Aborted && cctx.InboundTxParams.CoinType == coin.CoinType_Zeta { k.AddZetaAbortedAmount(ctx, GetAbortedAmount(cctx)) } diff --git a/x/crosschain/keeper/evm_deposit.go b/x/crosschain/keeper/evm_deposit.go index 0ce56a829c..5b04c7d3b3 100644 --- a/x/crosschain/keeper/evm_deposit.go +++ b/x/crosschain/keeper/evm_deposit.go @@ -1,6 +1,7 @@ package keeper import ( + "encoding/base64" "encoding/hex" "fmt" @@ -21,11 +22,13 @@ import ( // (true, non-nil) means CallEVM() reverted func (k Keeper) HandleEVMDeposit(ctx sdk.Context, cctx *types.CrossChainTx) (bool, error) { to := ethcommon.HexToAddress(cctx.GetCurrentOutTxParam().Receiver) + sender := ethcommon.HexToAddress(cctx.InboundTxParams.Sender) var ethTxHash ethcommon.Hash inboundAmount := cctx.GetInboundTxParams().Amount.BigInt() inboundSender := cctx.GetInboundTxParams().Sender inboundSenderChainID := cctx.GetInboundTxParams().SenderChainId inboundCoinType := cctx.InboundTxParams.CoinType + if len(ctx.TxBytes()) > 0 { // add event for tendermint transaction hash format hash := tmbytes.HexBytes(tmtypes.Tx(ctx.TxBytes()).Hash()) @@ -36,9 +39,22 @@ func (k Keeper) HandleEVMDeposit(ctx sdk.Context, cctx *types.CrossChainTx) (boo } if inboundCoinType == coin.CoinType_Zeta { - // if coin type is Zeta, this is a deposit ZETA to zEVM cctx. - err := k.fungibleKeeper.DepositCoinZeta(ctx, to, inboundAmount) + // In case of an error + // - Return true will revert the cctx and create a revert cctx with status PendingRevert + // - Return false will abort the cctx + indexBytes, err := cctx.GetCCTXIndexBytes() + if err != nil { + return false, err + } + data, err := base64.StdEncoding.DecodeString(cctx.RelayedMessage) if err != nil { + return true, errors.Wrap(types.ErrUnableToDecodeMessageString, err.Error()) + } + // if coin type is Zeta, this is a deposit ZETA to zEVM cctx. + evmTxResponse, err := k.fungibleKeeper.ZETADepositAndCallContract(ctx, sender, to, inboundSenderChainID, inboundAmount, data, indexBytes) + if fungibletypes.IsContractReverted(evmTxResponse, err) || errShouldRevertCctx(err) { + return true, err + } else if err != nil { return false, err } } else { diff --git a/x/crosschain/keeper/evm_deposit_test.go b/x/crosschain/keeper/evm_deposit_test.go index f82872566a..1f6cd4fad4 100644 --- a/x/crosschain/keeper/evm_deposit_test.go +++ b/x/crosschain/keeper/evm_deposit_test.go @@ -7,6 +7,7 @@ import ( "testing" "cosmossdk.io/math" + ethcommon "github.com/ethereum/go-ethereum/common" evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -26,16 +27,19 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) receiver := sample.EthAddress() amount := big.NewInt(42) + sender := sample.EthAddress() + senderChainId := int64(0) // expect DepositCoinZeta to be called - fungibleMock.On("DepositCoinZeta", ctx, receiver, amount).Return(nil) + fungibleMock.On("ZETADepositAndCallContract", ctx, ethcommon.HexToAddress(sender.String()), receiver, senderChainId, amount, mock.Anything, mock.Anything).Return(nil, nil) // call HandleEVMDeposit cctx := sample.CrossChainTx(t, "foo") cctx.GetCurrentOutTxParam().Receiver = receiver.String() cctx.GetInboundTxParams().Amount = math.NewUintFromBigInt(amount) cctx.GetInboundTxParams().CoinType = coin.CoinType_Zeta - cctx.GetInboundTxParams().SenderChainId = 0 + cctx.GetInboundTxParams().SenderChainId = senderChainId + cctx.InboundTxParams.Sender = sender.String() reverted, err := k.HandleEVMDeposit( ctx, cctx, @@ -52,19 +56,20 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) receiver := sample.EthAddress() + sender := sample.EthAddress() + senderChainId := int64(0) amount := big.NewInt(42) - + cctx := sample.CrossChainTx(t, "foo") // expect DepositCoinZeta to be called errDeposit := errors.New("deposit failed") - fungibleMock.On("DepositCoinZeta", ctx, receiver, amount).Return(errDeposit) - + fungibleMock.On("ZETADepositAndCallContract", ctx, ethcommon.HexToAddress(sender.String()), receiver, senderChainId, amount, mock.Anything, mock.Anything).Return(nil, errDeposit) // call HandleEVMDeposit - cctx := sample.CrossChainTx(t, "foo") + cctx.InboundTxParams.Sender = sender.String() cctx.GetCurrentOutTxParam().Receiver = receiver.String() cctx.GetInboundTxParams().Amount = math.NewUintFromBigInt(amount) cctx.GetInboundTxParams().CoinType = coin.CoinType_Zeta - cctx.GetInboundTxParams().SenderChainId = 0 + cctx.GetInboundTxParams().SenderChainId = senderChainId reverted, err := k.HandleEVMDeposit( ctx, cctx, diff --git a/x/crosschain/keeper/evm_hooks.go b/x/crosschain/keeper/evm_hooks.go index 5ca8c8e814..0bdda7a6ae 100644 --- a/x/crosschain/keeper/evm_hooks.go +++ b/x/crosschain/keeper/evm_hooks.go @@ -1,6 +1,7 @@ package keeper import ( + "encoding/base64" "encoding/hex" "fmt" "math/big" @@ -13,7 +14,7 @@ import ( "github.com/ethereum/go-ethereum/core" ethtypes "github.com/ethereum/go-ethereum/core/types" evmtypes "github.com/evmos/ethermint/x/evm/types" - connectorzevm "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/connectorzevm.sol" + connectorzevm "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zetaconnectorzevm.sol" zrc20 "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" "github.com/zeta-chain/zetacore/cmd/zetacored/config" "github.com/zeta-chain/zetacore/pkg/chains" @@ -224,7 +225,7 @@ func (k Keeper) ProcessZetaSentEvent(ctx sdk.Context, event *connectorzevm.ZetaC return fmt.Errorf("ProcessZetaSentEvent: failed to convert chainID: %s", err.Error()) } amount := math.NewUintFromBigInt(event.ZetaValueAndGas) - + messageString := base64.StdEncoding.EncodeToString(event.Message) // Bump gasLimit by event index (which is very unlikely to be larger than 1000) to always have different ZetaSent events msgs. msg := types.NewMsgVoteOnObservedInboundTx( "", @@ -233,7 +234,7 @@ func (k Keeper) ProcessZetaSentEvent(ctx sdk.Context, event *connectorzevm.ZetaC txOrigin, toAddr, receiverChain.ChainId, amount, - "", + messageString, event.Raw.TxHash.String(), event.Raw.BlockNumber, 90000, diff --git a/x/crosschain/keeper/gas_payment.go b/x/crosschain/keeper/gas_payment.go index fe51187199..a26658534c 100644 --- a/x/crosschain/keeper/gas_payment.go +++ b/x/crosschain/keeper/gas_payment.go @@ -295,7 +295,6 @@ func (k Keeper) PayGasInZetaAndUpdateCctx( return cosmoserrors.Wrap(err, "PayGasInZetaAndUpdateCctx: unable to QueryUniswapV2RouterGetZetaAmountsIn") } feeInZeta := types.GetProtocolFee().Add(math.NewUintFromBigInt(outTxGasFeeInZeta)) - // reduce the amount of the outbound tx if feeInZeta.GT(zetaBurnt) { return cosmoserrors.Wrap(types.ErrNotEnoughZetaBurnt, fmt.Sprintf("feeInZeta(%s) more than zetaBurnt (%s) | Identifiers : %s ", diff --git a/x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx_test.go b/x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx_test.go index 5704fdc54a..306b977ed9 100644 --- a/x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx_test.go +++ b/x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx_test.go @@ -6,6 +6,7 @@ import ( "testing" "cosmossdk.io/math" + "github.com/zeta-chain/zetacore/testutil/sample" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" @@ -134,6 +135,7 @@ func createInTxHashToCctxWithCctxs(keeper *crosschainkeeper.Keeper, ctx sdk.Cont cctxs[i].Index = fmt.Sprintf("0x123%d", i) cctxs[i].ZetaFees = math.OneUint() cctxs[i].InboundTxParams = &types.InboundTxParams{InboundTxObservedHash: fmt.Sprintf("%d", i), Amount: math.OneUint()} + cctxs[i].CctxStatus = &types.Status{Status: types.CctxStatus_PendingInbound} keeper.SetCctxAndNonceToCctxAndInTxHashToCctx(ctx, cctxs[i]) } @@ -148,9 +150,9 @@ func createInTxHashToCctxWithCctxs(keeper *crosschainkeeper.Keeper, ctx sdk.Cont } func TestKeeper_InTxHashToCctxDataQuery(t *testing.T) { - keeper, ctx, _, _ := keepertest.CrosschainKeeper(t) + keeper, ctx, _, zk := keepertest.CrosschainKeeper(t) wctx := sdk.WrapSDKContext(ctx) - + zk.ObserverKeeper.SetTSS(ctx, sample.Tss()) t.Run("can query all cctxs data with in tx hash", func(t *testing.T) { cctxs, inTxHashToCctx := createInTxHashToCctxWithCctxs(keeper, ctx) req := &types.QueryInTxHashToCctxDataRequest{ diff --git a/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go b/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go index 87ff60e729..f8d6a4bcb8 100644 --- a/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go +++ b/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go @@ -10,6 +10,8 @@ import ( sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" ethcommon "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" + "github.com/evmos/ethermint/x/evm/statedb" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/pkg/chains" @@ -45,7 +47,7 @@ func setObservers(t *testing.T, k *keeper.Keeper, ctx sdk.Context, zk keepertest // https://github.com/zeta-chain/node/issues/1542 func TestKeeper_VoteOnObservedInboundTx(t *testing.T) { t.Run("successfully vote on evm deposit", func(t *testing.T) { - k, ctx, _, zk := keepertest.CrosschainKeeper(t) + k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) msgServer := keeper.NewMsgServerImpl(*k) validatorList := setObservers(t, k, ctx, zk) to, from := int64(1337), int64(101) @@ -61,6 +63,13 @@ func TestKeeper_VoteOnObservedInboundTx(t *testing.T) { zk.ObserverKeeper.SetTSS(ctx, sample.Tss()) msg := sample.InboundVote(0, from, to) + + err := sdkk.EvmKeeper.SetAccount(ctx, ethcommon.HexToAddress(msg.Receiver), statedb.Account{ + Nonce: 0, + Balance: big.NewInt(0), + CodeHash: crypto.Keccak256(nil), + }) + require.NoError(t, err) for _, validatorAddr := range validatorList { msg.Creator = validatorAddr _, err := msgServer.VoteOnObservedInboundTx( @@ -78,7 +87,7 @@ func TestKeeper_VoteOnObservedInboundTx(t *testing.T) { require.Equal(t, ballot.BallotStatus, observertypes.BallotStatus_BallotFinalized_SuccessObservation) cctx, found := k.GetCrossChainTx(ctx, msg.Digest()) require.True(t, found) - require.Equal(t, cctx.CctxStatus.Status, types.CctxStatus_OutboundMined) + require.Equal(t, types.CctxStatus_OutboundMined, cctx.CctxStatus.Status) require.Equal(t, cctx.InboundTxParams.TxFinalizationStatus, types.TxFinalizationStatus_Executed) }) @@ -299,7 +308,8 @@ func TestStatus_ChangeStatus(t *testing.T) { func TestKeeper_SaveInbound(t *testing.T) { t.Run("should save the cctx", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeper(t) + k, ctx, _, zk := keepertest.CrosschainKeeper(t) + zk.ObserverKeeper.SetTSS(ctx, sample.Tss()) receiver := sample.EthAddress() amount := big.NewInt(42) senderChain := getValidEthChain(t) @@ -313,7 +323,7 @@ func TestKeeper_SaveInbound(t *testing.T) { }) t.Run("should save the cctx and remove tracker", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeper(t) + k, ctx, _, zk := keepertest.CrosschainKeeper(t) receiver := sample.EthAddress() amount := big.NewInt(42) senderChain := getValidEthChain(t) @@ -326,6 +336,7 @@ func TestKeeper_SaveInbound(t *testing.T) { CoinType: 0, }) eventIndex := sample.Uint64InRange(1, 100) + zk.ObserverKeeper.SetTSS(ctx, sample.Tss()) k.SaveInbound(ctx, cctx, eventIndex) require.Equal(t, types.TxFinalizationStatus_Executed, cctx.InboundTxParams.TxFinalizationStatus) diff --git a/x/crosschain/keeper/msg_server_vote_outbound_tx.go b/x/crosschain/keeper/msg_server_vote_outbound_tx.go index 22afff1218..fd0c462e4e 100644 --- a/x/crosschain/keeper/msg_server_vote_outbound_tx.go +++ b/x/crosschain/keeper/msg_server_vote_outbound_tx.go @@ -154,6 +154,7 @@ SaveFailedOutbound saves a failed outbound transaction.It does the following thi 2. Save the outbound */ + func (k Keeper) SaveFailedOutbound(ctx sdk.Context, cctx *types.CrossChainTx, errMessage string, ballotIndex string) { cctx.SetAbort(errMessage) ctx.Logger().Error(errMessage) @@ -162,6 +163,8 @@ func (k Keeper) SaveFailedOutbound(ctx sdk.Context, cctx *types.CrossChainTx, er } // SaveSuccessfulOutbound saves a successful outbound transaction. +// This function does not set the CCTX status, therefore all successful outbound transactions need +// to have their status set during processing func (k Keeper) SaveSuccessfulOutbound(ctx sdk.Context, cctx *types.CrossChainTx, ballotIndex string) { k.SaveOutbound(ctx, cctx, ballotIndex) } diff --git a/x/crosschain/keeper/process_inbound.go b/x/crosschain/keeper/process_inbound.go index 3178ee34b0..9b2eddbffd 100644 --- a/x/crosschain/keeper/process_inbound.go +++ b/x/crosschain/keeper/process_inbound.go @@ -37,21 +37,20 @@ func (k Keeper) processZEVMDeposit(ctx sdk.Context, cctx *types.CrossChainTx) { if err != nil && !isContractReverted { // exceptional case; internal error; should abort CCTX cctx.SetAbort(err.Error()) return - } else if err != nil && isContractReverted { // contract call reverted; should refund + } else if err != nil && isContractReverted { // contract call reverted; should refund via a revert tx revertMessage := err.Error() senderChain := k.zetaObserverKeeper.GetSupportedChainFromChainID(ctx, cctx.InboundTxParams.SenderChainId) if senderChain == nil { cctx.SetAbort(fmt.Sprintf("invalid sender chain id %d", cctx.InboundTxParams.SenderChainId)) return } - gasLimit, err := k.GetRevertGasLimit(ctx, *cctx) if err != nil { cctx.SetAbort(fmt.Sprintf("revert gas limit error: %s", err.Error())) return } if gasLimit == 0 { - // use same gas limit of outbound as a fallback -- should not happen + // use same gas limit of outbound as a fallback -- should not be required gasLimit = cctx.GetCurrentOutTxParam().OutboundTxGasLimit } @@ -60,7 +59,6 @@ func (k Keeper) processZEVMDeposit(ctx sdk.Context, cctx *types.CrossChainTx) { cctx.SetAbort(fmt.Sprintf("revert outbound error: %s", err.Error())) return } - // we create a new cached context, and we don't commit the previous one with EVM deposit tmpCtxRevert, commitRevert := ctx.CacheContext() err = func() error { diff --git a/x/crosschain/keeper/process_inbound_test.go b/x/crosschain/keeper/process_inbound_test.go index 491e362f78..ec3bcaea94 100644 --- a/x/crosschain/keeper/process_inbound_test.go +++ b/x/crosschain/keeper/process_inbound_test.go @@ -29,8 +29,9 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { amount := big.NewInt(42) // expect DepositCoinZeta to be called - fungibleMock.On("DepositCoinZeta", mock.Anything, receiver, amount). - Return(nil) + fungibleMock.On("ZETADepositAndCallContract", mock.Anything, + mock.Anything, + receiver, int64(0), amount, mock.Anything, mock.Anything).Return(nil, nil) // call ProcessInbound cctx := sample.CrossChainTx(t, "test") @@ -55,8 +56,8 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { amount := big.NewInt(42) // mock unsuccessful HandleEVMDeposit which does not revert - fungibleMock.On("DepositCoinZeta", mock.Anything, receiver, amount). - Return(fmt.Errorf("deposit error"), false) + + fungibleMock.On("ZETADepositAndCallContract", mock.Anything, mock.Anything, receiver, int64(0), amount, mock.Anything, mock.Anything).Return(nil, fmt.Errorf("deposit error")) // call ProcessInbound cctx := sample.CrossChainTx(t, "test") diff --git a/x/crosschain/keeper/process_outbound_test.go b/x/crosschain/keeper/process_outbound_test.go index 90837f17d8..2bd17818c6 100644 --- a/x/crosschain/keeper/process_outbound_test.go +++ b/x/crosschain/keeper/process_outbound_test.go @@ -1,13 +1,17 @@ package keeper_test import ( + "encoding/base64" "math/big" "testing" + ethcommon "github.com/ethereum/go-ethereum/common" + "github.com/evmos/ethermint/x/evm/statedb" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/coin" + "github.com/zeta-chain/zetacore/testutil/contracts" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/types" @@ -42,14 +46,84 @@ func TestKeeper_ProcessFailedOutbound(t *testing.T) { require.Equal(t, cctx.GetCurrentOutTxParam().TxFinalizationStatus, types.TxFinalizationStatus_Executed) }) - t.Run("successfully process failed outbound set to aborted for withdraw tx", func(t *testing.T) { + t.Run("successfully process failed outbound if original sender is a address", func(t *testing.T) { + k, ctx, sdkk, _ := keepertest.CrosschainKeeper(t) + receiver := sample.EthAddress() + cctx := GetERC20Cctx(t, receiver, chains.GoerliChain(), "", big.NewInt(42)) + err := sdkk.EvmKeeper.SetAccount(ctx, ethcommon.HexToAddress(cctx.InboundTxParams.Sender), *statedb.NewEmptyAccount()) + require.NoError(t, err) + cctx.InboundTxParams.SenderChainId = chains.ZetaChainMainnet().ChainId + err = k.ProcessFailedOutbound(ctx, cctx, sample.String()) + require.NoError(t, err) + require.Equal(t, types.CctxStatus_Reverted, cctx.CctxStatus.Status) + require.Equal(t, cctx.GetCurrentOutTxParam().TxFinalizationStatus, types.TxFinalizationStatus_Executed) + }) + t.Run("unable to process failed outbound if GetCCTXIndexBytes fails", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeper(t) + receiver := sample.EthAddress() + cctx := GetERC20Cctx(t, receiver, chains.GoerliChain(), "", big.NewInt(42)) + cctx.Index = "" + cctx.InboundTxParams.SenderChainId = chains.ZetaChainMainnet().ChainId + err := k.ProcessFailedOutbound(ctx, cctx, sample.String()) + require.ErrorContains(t, err, "failed reverting GetCCTXIndexBytes") + }) + + t.Run("unable to process failed outbound if Adding Revert fails", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) cctx := sample.CrossChainTx(t, "test") cctx.InboundTxParams.SenderChainId = chains.ZetaChainMainnet().ChainId err := k.ProcessFailedOutbound(ctx, cctx, sample.String()) + require.ErrorContains(t, err, "failed AddRevertOutbound") + }) + + t.Run("unable to process failed outbound if ZETARevertAndCallContract fails", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeper(t) + receiver := sample.EthAddress() + cctx := GetERC20Cctx(t, receiver, chains.GoerliChain(), "", big.NewInt(42)) + cctx.InboundTxParams.SenderChainId = chains.ZetaChainMainnet().ChainId + err := k.ProcessFailedOutbound(ctx, cctx, sample.String()) + require.ErrorContains(t, err, "failed ZETARevertAndCallContract") + }) + + t.Run("successfully revert failed outbound if original sender is a contract", func(t *testing.T) { + k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) + _ = zk.FungibleKeeper.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) + + cctx := GetERC20Cctx(t, sample.EthAddress(), chains.GoerliChain(), "", big.NewInt(42)) + cctx.RelayedMessage = base64.StdEncoding.EncodeToString([]byte("sample message")) + + deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) + dAppContract, err := zk.FungibleKeeper.DeployContract(ctx, contracts.DappMetaData) require.NoError(t, err) - require.Equal(t, cctx.CctxStatus.Status, types.CctxStatus_Aborted) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, dAppContract) + cctx.InboundTxParams.Sender = dAppContract.String() + cctx.InboundTxParams.SenderChainId = chains.ZetaChainMainnet().ChainId + + err = k.ProcessFailedOutbound(ctx, cctx, sample.String()) + require.NoError(t, err) + require.Equal(t, types.CctxStatus_Reverted, cctx.CctxStatus.Status) require.Equal(t, cctx.GetCurrentOutTxParam().TxFinalizationStatus, types.TxFinalizationStatus_Executed) + + dappAbi, err := contracts.DappMetaData.GetAbi() + require.NoError(t, err) + res, err := zk.FungibleKeeper.CallEVM( + ctx, + *dappAbi, + fungibletypes.ModuleAddressEVM, + dAppContract, + big.NewInt(0), + nil, + false, + false, + "zetaTxSenderAddress", + ) + require.NoError(t, err) + unpacked, err := dappAbi.Unpack("zetaTxSenderAddress", res.Ret) + require.NoError(t, err) + require.NotZero(t, len(unpacked)) + valSenderAddress, ok := unpacked[0].([]byte) + require.True(t, ok) + require.Equal(t, dAppContract.Bytes(), valSenderAddress) }) t.Run("successfully process failed outbound set to pending revert", func(t *testing.T) { diff --git a/x/crosschain/keeper/processs_outbound.go b/x/crosschain/keeper/processs_outbound.go index b10df821cc..a6ae80fca3 100644 --- a/x/crosschain/keeper/processs_outbound.go +++ b/x/crosschain/keeper/processs_outbound.go @@ -1,11 +1,18 @@ package keeper import ( + "encoding/base64" + "fmt" + cosmoserrors "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" + ethcommon "github.com/ethereum/go-ethereum/common" + tmbytes "github.com/tendermint/tendermint/libs/bytes" + tmtypes "github.com/tendermint/tendermint/types" "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/x/crosschain/types" + fungiblekeeper "github.com/zeta-chain/zetacore/x/fungible/keeper" observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -20,6 +27,10 @@ import ( 3. Emit an event for the successful outbound transaction */ +// This function sets CCTX status , in cases where the outbound tx is successful, but tx itself fails +// This is done because SaveSuccessfulOutbound does not set the cctx status +// For cases where the outbound tx is unsuccessful, the cctx status is automatically set to Aborted in the ProcessFailedOutbound function, so we can just return and error to trigger that + func (k Keeper) ProcessSuccessfulOutbound(ctx sdk.Context, cctx *types.CrossChainTx, valueReceived string) { oldStatus := cctx.CctxStatus.Status switch oldStatus { @@ -48,54 +59,133 @@ ProcessFailedOutbound processes a failed outbound transaction. It does the follo 4. Set the finalization status of the current outbound tx to executed. If a revert tx is is created, the finalization status is not set, it would get set when the revert is processed via a subsequent transaction */ + +// This function sets CCTX status , in cases where the outbound tx is successful, but tx itself fails +// This is done because SaveSuccessfulOutbound does not set the cctx status +// For cases where the outbound tx is unsuccessful, the cctx status is automatically set to Aborted in the ProcessFailedOutbound function, so we can just return and error to trigger that func (k Keeper) ProcessFailedOutbound(ctx sdk.Context, cctx *types.CrossChainTx, valueReceived string) error { oldStatus := cctx.CctxStatus.Status - if cctx.InboundTxParams.CoinType == coin.CoinType_Cmd || chains.IsZetaChain(cctx.InboundTxParams.SenderChainId) { + // The following logic is used to handler the mentioned conditions separately. The reason being + // All admin tx is created using a policy message , there is no associated inbound tx , therefore we do not need any revert logic + // For transactions which originated from ZEVM , we can process the outbound in the same block as there is no TSS signing required for the revert + // For all other transactions we need to create a revert tx and set the status to pending revert + + if cctx.InboundTxParams.CoinType == coin.CoinType_Cmd { // if the cctx is of coin type cmd or the sender chain is zeta chain, then we do not revert, the cctx is aborted cctx.GetCurrentOutTxParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed - cctx.CctxStatus.ChangeStatus(types.CctxStatus_Aborted, "") + cctx.SetAbort("Outbound failed") + } else if chains.IsZetaChain(cctx.InboundTxParams.SenderChainId) { + err := k.processFailedOutboundForZEVMTx(ctx, cctx) + if err != nil { + return cosmoserrors.Wrap(err, "ProcessFailedOutboundForZEVMTx") + } } else { - switch oldStatus { - case types.CctxStatus_PendingOutbound: + err := k.processFailedOutBoundForExternalChainTx(ctx, cctx, oldStatus) + if err != nil { + return cosmoserrors.Wrap(err, "ProcessFailedOutBoundForExternalChainTx") + } + } + newStatus := cctx.CctxStatus.Status.String() + EmitOutboundFailure(ctx, valueReceived, oldStatus.String(), newStatus, cctx.Index) + return nil +} - gasLimit, err := k.GetRevertGasLimit(ctx, *cctx) - if err != nil { - return cosmoserrors.Wrap(err, "GetRevertGasLimit") - } - if gasLimit == 0 { - // use same gas limit of outbound as a fallback -- should not happen - gasLimit = cctx.OutboundTxParams[0].OutboundTxGasLimit - } +func (k Keeper) processFailedOutBoundForExternalChainTx(ctx sdk.Context, cctx *types.CrossChainTx, oldStatus types.CctxStatus) error { + switch oldStatus { + case types.CctxStatus_PendingOutbound: - // create new OutboundTxParams for the revert - err = cctx.AddRevertOutbound(gasLimit) - if err != nil { - return cosmoserrors.Wrap(err, "AddRevertOutbound") - } + gasLimit, err := k.GetRevertGasLimit(ctx, *cctx) + if err != nil { + return cosmoserrors.Wrap(err, "GetRevertGasLimit") + } + if gasLimit == 0 { + // use same gas limit of outbound as a fallback -- should not happen + gasLimit = cctx.OutboundTxParams[0].OutboundTxGasLimit + } - err = k.PayGasAndUpdateCctx( - ctx, - cctx.InboundTxParams.SenderChainId, - cctx, - cctx.OutboundTxParams[0].Amount, - false, - ) - if err != nil { - return err - } - err = k.UpdateNonce(ctx, cctx.InboundTxParams.SenderChainId, cctx) - if err != nil { - return err - } - // Not setting the finalization status here, the required changes have been made while creating the revert tx - cctx.SetPendingRevert("Outbound failed, start revert") - case types.CctxStatus_PendingRevert: - cctx.GetCurrentOutTxParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed - cctx.SetAbort("Outbound failed: revert failed; abort TX") + // create new OutboundTxParams for the revert + err = cctx.AddRevertOutbound(gasLimit) + if err != nil { + return cosmoserrors.Wrap(err, "AddRevertOutbound") + } + + err = k.PayGasAndUpdateCctx( + ctx, + cctx.InboundTxParams.SenderChainId, + cctx, + cctx.OutboundTxParams[0].Amount, + false, + ) + if err != nil { + return err + } + err = k.UpdateNonce(ctx, cctx.InboundTxParams.SenderChainId, cctx) + if err != nil { + return err } + // Not setting the finalization status here, the required changes have been made while creating the revert tx + cctx.SetPendingRevert("Outbound failed, start revert") + case types.CctxStatus_PendingRevert: + cctx.GetCurrentOutTxParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed + cctx.SetAbort("Outbound failed: revert failed; abort TX") } - newStatus := cctx.CctxStatus.Status.String() - EmitOutboundFailure(ctx, valueReceived, oldStatus.String(), newStatus, cctx.Index) + return nil +} +func (k Keeper) processFailedOutboundForZEVMTx(ctx sdk.Context, cctx *types.CrossChainTx) error { + indexBytes, err := cctx.GetCCTXIndexBytes() + if err != nil { + // Return err to save the failed outbound ad set to aborted + return fmt.Errorf("failed reverting GetCCTXIndexBytes: %s", err.Error()) + } + // Finalize the older outbound tx + cctx.GetCurrentOutTxParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed + + // create new OutboundTxParams for the revert. We use the fixed gas limit for revert when calling zEVM + err = cctx.AddRevertOutbound(fungiblekeeper.ZEVMGasLimitDepositAndCall.Uint64()) + if err != nil { + // Return err to save the failed outbound ad set to aborted + return fmt.Errorf("failed AddRevertOutbound: %s", err.Error()) + } + + // Trying to revert the transaction this would get set to a finalized status in the same block as this does not need a TSS singing + cctx.SetPendingRevert("Outbound failed, trying revert") + data, err := base64.StdEncoding.DecodeString(cctx.RelayedMessage) + if err != nil { + return fmt.Errorf("failed decoding relayed message: %s", err.Error()) + } + + // Fetch the original sender and receiver from the CCTX , since this is a revert the sender with be the receiver in the new tx + originalSender := ethcommon.HexToAddress(cctx.InboundTxParams.Sender) + // This transaction will always have two outbounds, the following logic is just an added precaution. + // The contract call or token deposit would go the original sender. + originalReceiver := ethcommon.HexToAddress(cctx.GetCurrentOutTxParam().Receiver) + orginalReceiverChainID := cctx.GetCurrentOutTxParam().ReceiverChainId + if len(cctx.OutboundTxParams) == 2 { + // If there are 2 outbound tx, then the original receiver is the receiver in the first outbound tx + originalReceiver = ethcommon.HexToAddress(cctx.OutboundTxParams[0].Receiver) + orginalReceiverChainID = cctx.OutboundTxParams[0].ReceiverChainId + } + // Call evm to revert the transaction + _, err = k.fungibleKeeper.ZETARevertAndCallContract(ctx, + originalSender, + originalReceiver, + cctx.InboundTxParams.SenderChainId, + orginalReceiverChainID, + cctx.GetCurrentOutTxParam().Amount.BigInt(), data, indexBytes) + // If revert fails, we set it to abort directly there is no way to refund here as the revert failed + if err != nil { + return fmt.Errorf("failed ZETARevertAndCallContract: %s", err.Error()) + } + cctx.SetReverted("Outbound failed, revert executed") + if len(ctx.TxBytes()) > 0 { + // add event for tendermint transaction hash format + hash := tmbytes.HexBytes(tmtypes.Tx(ctx.TxBytes()).Hash()) + ethTxHash := ethcommon.BytesToHash(hash) + cctx.GetCurrentOutTxParam().OutboundTxHash = ethTxHash.String() + // #nosec G701 always positive + cctx.GetCurrentOutTxParam().OutboundTxObservedExternalHeight = uint64(ctx.BlockHeight()) + } + cctx.GetCurrentOutTxParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed return nil } diff --git a/x/crosschain/types/cctx.go b/x/crosschain/types/cctx.go index 45138232fc..98fedf0d5d 100644 --- a/x/crosschain/types/cctx.go +++ b/x/crosschain/types/cctx.go @@ -1,6 +1,7 @@ package types import ( + "encoding/hex" "fmt" cosmoserrors "cosmossdk.io/errors" @@ -82,10 +83,14 @@ func (m *CrossChainTx) AddRevertOutbound(gasLimit uint64) error { if m.IsCurrentOutTxRevert() { return fmt.Errorf("cannot revert a revert tx") } + if len(m.OutboundTxParams) == 0 { + return fmt.Errorf("cannot revert before trying to process an outbound tx") + } + revertTxParams := &OutboundTxParams{ Receiver: m.InboundTxParams.Sender, ReceiverChainId: m.InboundTxParams.SenderChainId, - Amount: m.InboundTxParams.Amount, + Amount: m.GetCurrentOutTxParam().Amount, OutboundTxGasLimit: gasLimit, TssPubkey: m.GetCurrentOutTxParam().TssPubkey, } @@ -140,6 +145,23 @@ func (m CrossChainTx) SetReverted(message string) { m.CctxStatus.ChangeStatus(CctxStatus_Reverted, message) } +func (m CrossChainTx) GetCCTXIndexBytes() ([32]byte, error) { + sendHash := [32]byte{} + if len(m.Index) < 2 { + return [32]byte{}, fmt.Errorf("decode CCTX %s index too short", m.Index) + } + decodedIndex, err := hex.DecodeString(m.Index[2:]) // remove the leading 0x + if err != nil || len(decodedIndex) != 32 { + return [32]byte{}, fmt.Errorf("decode CCTX %s error", m.Index) + } + copy(sendHash[:32], decodedIndex[:32]) + return sendHash, nil +} + +func GetCctxIndexFromBytes(sendHash [32]byte) string { + return fmt.Sprintf("0x%s", hex.EncodeToString(sendHash[:])) +} + // NewCCTX creates a new CCTX.From a MsgVoteOnObservedInboundTx message and a TSS pubkey. // It also validates the created cctx func NewCCTX(ctx sdk.Context, msg MsgVoteOnObservedInboundTx, tssPubkey string) (CrossChainTx, error) { diff --git a/x/crosschain/types/cctx_test.go b/x/crosschain/types/cctx_test.go index 15df60238e..0b7f267d2d 100644 --- a/x/crosschain/types/cctx_test.go +++ b/x/crosschain/types/cctx_test.go @@ -15,6 +15,13 @@ import ( observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) +func TestCrossChainTx_GetCCTXIndexBytes(t *testing.T) { + cctx := sample.CrossChainTx(t, "sample") + indexBytes, err := cctx.GetCCTXIndexBytes() + require.NoError(t, err) + require.Equal(t, cctx.Index, types.GetCctxIndexFromBytes(indexBytes)) +} + func Test_InitializeCCTX(t *testing.T) { t.Run("should return a cctx with correct values", func(t *testing.T) { _, ctx, _, _ := keepertest.CrosschainKeeper(t) @@ -245,7 +252,7 @@ func Test_SetRevertOutboundValues(t *testing.T) { require.Len(t, cctx.OutboundTxParams, 2) require.Equal(t, cctx.GetCurrentOutTxParam().Receiver, cctx.InboundTxParams.Sender) require.Equal(t, cctx.GetCurrentOutTxParam().ReceiverChainId, cctx.InboundTxParams.SenderChainId) - require.Equal(t, cctx.GetCurrentOutTxParam().Amount, cctx.InboundTxParams.Amount) + require.Equal(t, cctx.GetCurrentOutTxParam().Amount, cctx.OutboundTxParams[0].Amount) require.Equal(t, cctx.GetCurrentOutTxParam().OutboundTxGasLimit, uint64(100)) require.Equal(t, cctx.GetCurrentOutTxParam().TssPubkey, cctx.OutboundTxParams[0].TssPubkey) require.Equal(t, types.TxFinalizationStatus_Executed, cctx.OutboundTxParams[0].TxFinalizationStatus) @@ -256,6 +263,13 @@ func Test_SetRevertOutboundValues(t *testing.T) { err := cctx.AddRevertOutbound(100) require.ErrorContains(t, err, "cannot revert a revert tx") }) + + t.Run("failed to set revert outbound values if revert outbound already exists", func(t *testing.T) { + cctx := sample.CrossChainTx(t, "test") + cctx.OutboundTxParams = make([]*types.OutboundTxParams, 0) + err := cctx.AddRevertOutbound(100) + require.ErrorContains(t, err, "cannot revert before trying to process an outbound tx") + }) } func TestCrossChainTx_SetAbort(t *testing.T) { diff --git a/x/crosschain/types/errors.go b/x/crosschain/types/errors.go index 1b80e4fe19..edde41849d 100644 --- a/x/crosschain/types/errors.go +++ b/x/crosschain/types/errors.go @@ -41,6 +41,7 @@ var ( ErrUnableProcessRefund = errorsmod.Register(ModuleName, 1148, "unable to process refund") ErrUnableToFindZetaAccounting = errorsmod.Register(ModuleName, 1149, "unable to find zeta accounting") ErrInsufficientZetaAmount = errorsmod.Register(ModuleName, 1150, "insufficient zeta amount") - ErrInvalidRateLimiterFlags = errorsmod.Register(ModuleName, 1151, "invalid rate limiter flags") - ErrMaxTxOutTrackerHashesReached = errorsmod.Register(ModuleName, 1152, "max tx out tracker hashes reached") + ErrUnableToDecodeMessageString = errorsmod.Register(ModuleName, 1151, "unable to decode message string") + ErrInvalidRateLimiterFlags = errorsmod.Register(ModuleName, 1152, "invalid rate limiter flags") + ErrMaxTxOutTrackerHashesReached = errorsmod.Register(ModuleName, 1153, "max tx out tracker hashes reached") ) diff --git a/x/crosschain/types/expected_keepers.go b/x/crosschain/types/expected_keepers.go index 3fbea3a483..ed5aacb267 100644 --- a/x/crosschain/types/expected_keepers.go +++ b/x/crosschain/types/expected_keepers.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - eth "github.com/ethereum/go-ethereum/common" + ethcommon "github.com/ethereum/go-ethereum/common" evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/coin" @@ -100,24 +100,24 @@ type FungibleKeeper interface { GetForeignCoinFromAsset(ctx sdk.Context, asset string, chainID int64) (fungibletypes.ForeignCoins, bool) GetGasCoinForForeignCoin(ctx sdk.Context, chainID int64) (fungibletypes.ForeignCoins, bool) GetSystemContract(ctx sdk.Context) (val fungibletypes.SystemContract, found bool) - QuerySystemContractGasCoinZRC20(ctx sdk.Context, chainID *big.Int) (eth.Address, error) - GetUniswapV2Router02Address(ctx sdk.Context) (eth.Address, error) - QueryUniswapV2RouterGetZetaAmountsIn(ctx sdk.Context, amountOut *big.Int, outZRC4 eth.Address) (*big.Int, error) - QueryUniswapV2RouterGetZRC4ToZRC4AmountsIn(ctx sdk.Context, amountOut *big.Int, inZRC4, outZRC4 eth.Address) (*big.Int, error) - QueryGasLimit(ctx sdk.Context, contract eth.Address) (*big.Int, error) - QueryProtocolFlatFee(ctx sdk.Context, contract eth.Address) (*big.Int, error) + QuerySystemContractGasCoinZRC20(ctx sdk.Context, chainID *big.Int) (ethcommon.Address, error) + GetUniswapV2Router02Address(ctx sdk.Context) (ethcommon.Address, error) + QueryUniswapV2RouterGetZetaAmountsIn(ctx sdk.Context, amountOut *big.Int, outZRC4 ethcommon.Address) (*big.Int, error) + QueryUniswapV2RouterGetZRC4ToZRC4AmountsIn(ctx sdk.Context, amountOut *big.Int, inZRC4, outZRC4 ethcommon.Address) (*big.Int, error) + QueryGasLimit(ctx sdk.Context, contract ethcommon.Address) (*big.Int, error) + QueryProtocolFlatFee(ctx sdk.Context, contract ethcommon.Address) (*big.Int, error) SetGasPrice(ctx sdk.Context, chainID *big.Int, gasPrice *big.Int) (uint64, error) - DepositCoinZeta(ctx sdk.Context, to eth.Address, amount *big.Int) error + DepositCoinZeta(ctx sdk.Context, to ethcommon.Address, amount *big.Int) error DepositZRC20( ctx sdk.Context, - contract eth.Address, - to eth.Address, + contract ethcommon.Address, + to ethcommon.Address, amount *big.Int, ) (*evmtypes.MsgEthereumTxResponse, error) ZRC20DepositAndCallContract( ctx sdk.Context, from []byte, - to eth.Address, + to ethcommon.Address, amount *big.Int, senderChainID int64, data []byte, @@ -126,27 +126,27 @@ type FungibleKeeper interface { ) (*evmtypes.MsgEthereumTxResponse, bool, error) CallUniswapV2RouterSwapExactTokensForTokens( ctx sdk.Context, - sender eth.Address, - to eth.Address, + sender ethcommon.Address, + to ethcommon.Address, amountIn *big.Int, inZRC4, - outZRC4 eth.Address, + outZRC4 ethcommon.Address, noEthereumTxEvent bool, ) (ret []*big.Int, err error) CallUniswapV2RouterSwapExactETHForToken( ctx sdk.Context, - sender eth.Address, - to eth.Address, + sender ethcommon.Address, + to ethcommon.Address, amountIn *big.Int, - outZRC4 eth.Address, + outZRC4 ethcommon.Address, noEthereumTxEvent bool, ) ([]*big.Int, error) - CallZRC20Burn(ctx sdk.Context, sender eth.Address, zrc20address eth.Address, amount *big.Int, noEthereumTxEvent bool) error + CallZRC20Burn(ctx sdk.Context, sender ethcommon.Address, zrc20address ethcommon.Address, amount *big.Int, noEthereumTxEvent bool) error CallZRC20Approve( ctx sdk.Context, - owner eth.Address, - zrc20address eth.Address, - spender eth.Address, + owner ethcommon.Address, + zrc20address ethcommon.Address, + spender ethcommon.Address, amount *big.Int, noEthereumTxEvent bool, ) error @@ -158,9 +158,24 @@ type FungibleKeeper interface { coinType coin.CoinType, erc20Contract string, gasLimit *big.Int, - ) (eth.Address, error) + ) (ethcommon.Address, error) FundGasStabilityPool(ctx sdk.Context, chainID int64, amount *big.Int) error WithdrawFromGasStabilityPool(ctx sdk.Context, chainID int64, amount *big.Int) error + ZETADepositAndCallContract(ctx sdk.Context, + sender ethcommon.Address, + to ethcommon.Address, + inboundSenderChainID int64, + inboundAmount *big.Int, + data []byte, + indexBytes [32]byte) (*evmtypes.MsgEthereumTxResponse, error) + ZETARevertAndCallContract(ctx sdk.Context, + sender ethcommon.Address, + to ethcommon.Address, + inboundSenderChainID int64, + destinationChainID int64, + remainingAmount *big.Int, + data []byte, + indexBytes [32]byte) (*evmtypes.MsgEthereumTxResponse, error) } type AuthorityKeeper interface { diff --git a/x/fungible/keeper/deposits.go b/x/fungible/keeper/deposits.go index c7d786db18..695386fd01 100644 --- a/x/fungible/keeper/deposits.go +++ b/x/fungible/keeper/deposits.go @@ -18,6 +18,10 @@ func (k Keeper) DepositCoinZeta(ctx sdk.Context, to eth.Address, amount *big.Int return k.MintZetaToEVMAccount(ctx, zetaToAddress, amount) } +func (k Keeper) DepositCoinsToFungibleModule(ctx sdk.Context, amount *big.Int) error { + return k.MintZetaToFungibleModule(ctx, amount) +} + // ZRC20DepositAndCallContract deposits ZRC20 to the EVM account and calls the contract // returns [txResponse, isContractCall, error] // isContractCall is true if the receiver is a contract and a contract call was made diff --git a/x/fungible/keeper/deposits_test.go b/x/fungible/keeper/deposits_test.go index dc69febd24..0e6f245173 100644 --- a/x/fungible/keeper/deposits_test.go +++ b/x/fungible/keeper/deposits_test.go @@ -4,15 +4,16 @@ import ( "math/big" "testing" + "cosmossdk.io/errors" "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/cmd/zetacored/config" "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/testutil/contracts" - testkeeper "github.com/zeta-chain/zetacore/testutil/keeper" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" "github.com/zeta-chain/zetacore/x/fungible/types" @@ -21,7 +22,7 @@ import ( func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { t.Run("can deposit gas coin for transfers", func(t *testing.T) { // setup gas coin - k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) chainList := chains.DefaultChainsList() @@ -52,7 +53,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { }) t.Run("can deposit non-gas coin for transfers", func(t *testing.T) { - k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) chainList := chains.DefaultChainsList() @@ -84,7 +85,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { }) t.Run("should fail if trying to call a contract with data to a EOC", func(t *testing.T) { - k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) chainList := chains.DefaultChainsList() @@ -112,7 +113,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { t.Run("can deposit coin for transfers with liquidity cap not reached", func(t *testing.T) { // setup gas coin - k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) chainList := chains.DefaultChainsList() @@ -158,7 +159,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { t.Run("should fail if coin paused", func(t *testing.T) { // setup gas coin - k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) chainList := chains.DefaultChainsList() @@ -190,7 +191,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { t.Run("should fail if liquidity cap reached", func(t *testing.T) { // setup gas coin - k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) chainList := chains.DefaultChainsList() @@ -231,7 +232,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { t.Run("should fail if gas coin not found", func(t *testing.T) { // setup gas coin - k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) chainList := chains.DefaultChainsList() @@ -256,7 +257,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { }) t.Run("should fail if zrc20 not found", func(t *testing.T) { - k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) chainList := chains.DefaultChainsList() @@ -283,7 +284,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { t.Run("should return contract call if receiver is a contract", func(t *testing.T) { // setup gas coin - k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) chainList := chains.DefaultChainsList() @@ -321,7 +322,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { t.Run("should fail if call contract fails", func(t *testing.T) { // setup gas coin - k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) chainList := chains.DefaultChainsList() @@ -356,16 +357,34 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { } func TestKeeper_DepositCoinZeta(t *testing.T) { - k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) - to := sample.EthAddress() - amount := big.NewInt(1) - zetaToAddress := sdk.AccAddress(to.Bytes()) - - b := sdkk.BankKeeper.GetBalance(ctx, zetaToAddress, config.BaseDenom) - require.Equal(t, int64(0), b.Amount.Int64()) - - err := k.DepositCoinZeta(ctx, to, amount) - require.NoError(t, err) - b = sdkk.BankKeeper.GetBalance(ctx, zetaToAddress, config.BaseDenom) - require.Equal(t, amount.Int64(), b.Amount.Int64()) + t.Run("successfully deposit coin", func(t *testing.T) { + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) + to := sample.EthAddress() + amount := big.NewInt(1) + zetaToAddress := sdk.AccAddress(to.Bytes()) + + b := sdkk.BankKeeper.GetBalance(ctx, zetaToAddress, config.BaseDenom) + require.Equal(t, int64(0), b.Amount.Int64()) + + err := k.DepositCoinZeta(ctx, to, amount) + require.NoError(t, err) + b = sdkk.BankKeeper.GetBalance(ctx, zetaToAddress, config.BaseDenom) + require.Equal(t, amount.Int64(), b.Amount.Int64()) + }) + + t.Run("should fail if MintZetaToEVMAccount fails", func(t *testing.T) { + k, ctx, sdkk, _ := keepertest.FungibleKeeperWithMocks(t, keepertest.FungibleMockOptions{UseBankMock: true}) + bankMock := keepertest.GetFungibleBankMock(t, k) + to := sample.EthAddress() + amount := big.NewInt(1) + zetaToAddress := sdk.AccAddress(to.Bytes()) + + b := sdkk.BankKeeper.GetBalance(ctx, zetaToAddress, config.BaseDenom) + require.Equal(t, int64(0), b.Amount.Int64()) + errorMint := errors.New("", 1, "error minting coins") + bankMock.On("MintCoins", ctx, types.ModuleName, mock.Anything).Return(errorMint).Once() + err := k.DepositCoinZeta(ctx, to, amount) + require.ErrorIs(t, err, errorMint) + + }) } diff --git a/x/fungible/keeper/evm.go b/x/fungible/keeper/evm.go index 427849f19c..04dda559e9 100644 --- a/x/fungible/keeper/evm.go +++ b/x/fungible/keeper/evm.go @@ -20,12 +20,12 @@ import ( evmtypes "github.com/evmos/ethermint/x/evm/types" tmbytes "github.com/tendermint/tendermint/libs/bytes" tmtypes "github.com/tendermint/tendermint/types" - connectorzevm "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/connectorzevm.sol" - systemcontract "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/systemcontract.sol" + "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/systemcontract.sol" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/wzeta.sol" - zrc20 "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" - uniswapv2factory "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-core/contracts/uniswapv2factory.sol" - uniswapv2router02 "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-periphery/contracts/uniswapv2router02.sol" + zevmconnectercontract "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zetaconnectorzevm.sol" + "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" + "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-core/contracts/uniswapv2factory.sol" + "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-periphery/contracts/uniswapv2router02.sol" "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/server/config" @@ -37,6 +37,8 @@ import ( var ( BigIntZero = big.NewInt(0) ZEVMGasLimitDepositAndCall = big.NewInt(1_000_000) + + ZEVMGasLimitConnectorCall = big.NewInt(1_000_000) ) // DeployContract deploys a new contract in the ZEVM @@ -179,7 +181,7 @@ func (k Keeper) DeployWZETA(ctx sdk.Context) (common.Address, error) { } func (k Keeper) DeployConnectorZEVM(ctx sdk.Context, wzeta common.Address) (common.Address, error) { - contractAddr, err := k.DeployContract(ctx, connectorzevm.ZetaConnectorZEVMMetaData, wzeta) + contractAddr, err := k.DeployContract(ctx, zevmconnectercontract.ZetaConnectorZEVMMetaData, wzeta) if err != nil { return common.Address{}, cosmoserrors.Wrapf(err, "ZetaConnectorZEVM") } @@ -305,6 +307,99 @@ func (k Keeper) DepositZRC20AndCallContract(ctx sdk.Context, ) } +// CallOnReceiveZevmConnector calls the onReceive function of the ZevmConnector contract +// Before calling it mints the zetaValue tokens to the fungible module , and this amount is then provided as value to the onReceive function +// The onReceive function will then wrap this native zeta into WZETA and call the onReceive function of the destination contract specified by the destinationAddress +func (k Keeper) CallOnReceiveZevmConnector(ctx sdk.Context, + zetaTxSenderAddress []byte, + sourceChainID *big.Int, + destinationAddress common.Address, + zetaValue *big.Int, + message []byte, + internalSendHash [32]byte, +) (*evmtypes.MsgEthereumTxResponse, error) { + system, found := k.GetSystemContract(ctx) + if !found { + return nil, cosmoserrors.Wrapf(types.ErrContractNotFound, "GetSystemContract address not found") + } + connectorAddress := common.HexToAddress(system.ConnectorZevm) + + zevmConnecterAbi, err := zevmconnectercontract.ZetaConnectorZEVMMetaData.GetAbi() + if err != nil { + return nil, err + } + + err = k.DepositCoinsToFungibleModule(ctx, zetaValue) + if err != nil { + return nil, err + } + + return k.CallEVM( + ctx, + *zevmConnecterAbi, + types.ModuleAddressEVM, + connectorAddress, + zetaValue, + ZEVMGasLimitConnectorCall, + true, + false, + "onReceive", + zetaTxSenderAddress, + sourceChainID, + destinationAddress, + zetaValue, + message, + internalSendHash, + ) +} + +// CallOnRevertZevmConnector calls the onRevert function of the ZevmConnector contract +// Before calling it mints the remainingZetaValue tokens to the fungible module , and this amount is then provided as value to the onRevert function +// The onRevert function will then wrap this native zeta into WZETA and call the onRevert function of the contract specified by the zetaTxSenderAddress +// Note the destination address is the original destination address of the transaction and not the current destination . +func (k Keeper) CallOnRevertZevmConnector(ctx sdk.Context, + zetaTxSenderAddress common.Address, + sourceChainID *big.Int, + destinationAddress []byte, + destinationChainID *big.Int, + remainingZetaValue *big.Int, + message []byte, + internalSendHash [32]byte, +) (*evmtypes.MsgEthereumTxResponse, error) { + system, found := k.GetSystemContract(ctx) + if !found { + return nil, cosmoserrors.Wrapf(types.ErrContractNotFound, "GetSystemContract address not found") + } + connectorAddress := common.HexToAddress(system.ConnectorZevm) + + zevmConnecterAbi, err := zevmconnectercontract.ZetaConnectorZEVMMetaData.GetAbi() + if err != nil { + return nil, err + } + err = k.DepositCoinsToFungibleModule(ctx, remainingZetaValue) + if err != nil { + return nil, err + } + return k.CallEVM( + ctx, + *zevmConnecterAbi, + types.ModuleAddressEVM, + connectorAddress, + remainingZetaValue, + ZEVMGasLimitConnectorCall, + true, + false, + "onRevert", + zetaTxSenderAddress, + sourceChainID, + destinationAddress, + destinationChainID, + remainingZetaValue, + message, + internalSendHash, + ) +} + // QueryProtocolFlatFee returns the protocol flat fee associated with a given zrc20 func (k Keeper) QueryProtocolFlatFee(ctx sdk.Context, contract common.Address) (*big.Int, error) { zrc20ABI, err := zrc20.ZRC20MetaData.GetAbi() diff --git a/x/fungible/keeper/evm_test.go b/x/fungible/keeper/evm_test.go index 753d82e7e6..1ca8b7cbe4 100644 --- a/x/fungible/keeper/evm_test.go +++ b/x/fungible/keeper/evm_test.go @@ -1326,3 +1326,158 @@ func TestKeeper_QueryZRC20Data(t *testing.T) { require.Equal(t, "symbol", res.Symbol) }) } + +func TestKeeper_CallOnReceiveZevmConnector(t *testing.T) { + t.Run("should call on receive on connector which calls onZetaMessage on sample DAPP", func(t *testing.T) { + k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) + dAppContract, err := k.DeployContract(ctx, contracts.DappMetaData) + require.NoError(t, err) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, dAppContract) + + senderAddress := sample.EthAddress().Bytes() + sourceChainID := big.NewInt(1) + destinationAddress := dAppContract + zetaValue := big.NewInt(45) + data := []byte("message") + internalSendHash := [32]byte{} + + _, err = k.CallOnReceiveZevmConnector(ctx, senderAddress, sourceChainID, destinationAddress, zetaValue, data, internalSendHash) + require.NoError(t, err) + + require.NoError(t, err) + + dappAbi, err := contracts.DappMetaData.GetAbi() + require.NoError(t, err) + res, err := k.CallEVM( + ctx, + *dappAbi, + types.ModuleAddressEVM, + dAppContract, + big.NewInt(0), + nil, + false, + false, + "zetaTxSenderAddress", + ) + require.NoError(t, err) + unpacked, err := dappAbi.Unpack("zetaTxSenderAddress", res.Ret) + require.NoError(t, err) + require.NotZero(t, len(unpacked)) + valSenderAddress, ok := unpacked[0].([]byte) + require.True(t, ok) + require.Equal(t, senderAddress, valSenderAddress) + }) + + t.Run("should error if system contract not found", func(t *testing.T) { + k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + dAppContract, err := k.DeployContract(ctx, contracts.DappMetaData) + require.NoError(t, err) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, dAppContract) + + _, err = k.CallOnReceiveZevmConnector(ctx, + sample.EthAddress().Bytes(), + big.NewInt(1), + dAppContract, + big.NewInt(45), []byte("message"), [32]byte{}) + require.ErrorIs(t, err, types.ErrContractNotFound) + }) + + t.Run("should error in contract call reverts", func(t *testing.T) { + k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) + dAppContract, err := k.DeployContract(ctx, contracts.DappReverterMetaData) + require.NoError(t, err) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, dAppContract) + + _, err = k.CallOnReceiveZevmConnector(ctx, + sample.EthAddress().Bytes(), + big.NewInt(1), + dAppContract, + big.NewInt(45), []byte("message"), [32]byte{}) + require.ErrorContains(t, err, "execution reverted") + }) +} + +func TestKeeper_CallOnRevertZevmConnector(t *testing.T) { + t.Run("should call on revert on connector which calls onZetaRevert on sample DAPP", func(t *testing.T) { + k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) + dAppContract, err := k.DeployContract(ctx, contracts.DappMetaData) + require.NoError(t, err) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, dAppContract) + senderAddress := dAppContract + sourceChainID := big.NewInt(1) + destinationAddress := sample.EthAddress().Bytes() + destinationChainID := big.NewInt(1) + zetaValue := big.NewInt(45) + data := []byte("message") + internalSendHash := [32]byte{} + _, err = k.CallOnRevertZevmConnector(ctx, senderAddress, sourceChainID, destinationAddress, destinationChainID, zetaValue, data, internalSendHash) + require.NoError(t, err) + + dappAbi, err := contracts.DappMetaData.GetAbi() + require.NoError(t, err) + res, err := k.CallEVM( + ctx, + *dappAbi, + types.ModuleAddressEVM, + dAppContract, + big.NewInt(0), + nil, + false, + false, + "zetaTxSenderAddress", + ) + require.NoError(t, err) + unpacked, err := dappAbi.Unpack("zetaTxSenderAddress", res.Ret) + require.NoError(t, err) + require.NotZero(t, len(unpacked)) + valSenderAddress, ok := unpacked[0].([]byte) + require.True(t, ok) + require.Equal(t, senderAddress.Bytes(), valSenderAddress) + }) + + t.Run("should error if system contract not found", func(t *testing.T) { + k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + dAppContract, err := k.DeployContract(ctx, contracts.DappMetaData) + require.NoError(t, err) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, dAppContract) + + _, err = k.CallOnRevertZevmConnector(ctx, + dAppContract, + big.NewInt(1), + sample.EthAddress().Bytes(), + big.NewInt(1), + big.NewInt(45), []byte("message"), [32]byte{}) + require.ErrorIs(t, err, types.ErrContractNotFound) + }) + + t.Run("should error in contract call reverts", func(t *testing.T) { + k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) + dAppContract, err := k.DeployContract(ctx, contracts.DappReverterMetaData) + require.NoError(t, err) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, dAppContract) + + _, err = k.CallOnRevertZevmConnector(ctx, + dAppContract, + big.NewInt(1), + sample.EthAddress().Bytes(), + big.NewInt(1), + big.NewInt(45), []byte("message"), [32]byte{}) + require.ErrorContains(t, err, "execution reverted") + }) +} diff --git a/x/fungible/keeper/system_contract.go b/x/fungible/keeper/system_contract.go index af36727f54..822bccf766 100644 --- a/x/fungible/keeper/system_contract.go +++ b/x/fungible/keeper/system_contract.go @@ -1,6 +1,7 @@ package keeper import ( + "fmt" "math/big" cosmoserrors "cosmossdk.io/errors" @@ -533,7 +534,8 @@ func (k *Keeper) QueryUniswapV2RouterGetZetaAmountsIn(ctx sdk.Context, amountOut []ethcommon.Address{wzetaAddr, outZRC4}, ) if err != nil { - return nil, cosmoserrors.Wrapf(types.ErrContractCall, "failed to CallEVM method getAmountsIn (%s)", err.Error()) + fmt.Println(err.Error()) + return nil, cosmoserrors.Wrap(types.ErrContractCall, fmt.Sprintf("failed to CallEVM method getAmountsIn (%s)", err.Error())) } amounts := new([2]*big.Int) diff --git a/x/fungible/keeper/zeta.go b/x/fungible/keeper/zeta.go index 0a5e72b31d..33f3d81486 100644 --- a/x/fungible/keeper/zeta.go +++ b/x/fungible/keeper/zeta.go @@ -20,3 +20,9 @@ func (k *Keeper) MintZetaToEVMAccount(ctx sdk.Context, to sdk.AccAddress, amount // Send minted coins to the receiver return k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, to, coins) } + +func (k *Keeper) MintZetaToFungibleModule(ctx sdk.Context, amount *big.Int) error { + coins := sdk.NewCoins(sdk.NewCoin(config.BaseDenom, sdk.NewIntFromBigInt(amount))) + // Mint coins + return k.bankKeeper.MintCoins(ctx, types.ModuleName, coins) +} diff --git a/x/fungible/keeper/zevm_message_passing_test.go b/x/fungible/keeper/zevm_message_passing_test.go new file mode 100644 index 0000000000..b37621667d --- /dev/null +++ b/x/fungible/keeper/zevm_message_passing_test.go @@ -0,0 +1,263 @@ +package keeper_test + +import ( + "math/big" + "testing" + + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/crypto" + "github.com/evmos/ethermint/x/evm/statedb" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/cmd/zetacored/config" + "github.com/zeta-chain/zetacore/testutil/contracts" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/fungible/types" +) + +func TestKeeper_ZEVMDepositAndCallContract(t *testing.T) { + t.Run("successfully call ZETADepositAndCallContract on connector contract ", func(t *testing.T) { + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) + dAppContract, err := k.DeployContract(ctx, contracts.DappMetaData) + require.NoError(t, err) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, dAppContract) + + zetaTxSender := sample.EthAddress() + zetaTxReceiver := dAppContract + inboundSenderChainID := int64(1) + inboundAmount := big.NewInt(45) + data := []byte("message") + cctxIndexBytes := [32]byte{} + + _, err = k.ZETADepositAndCallContract(ctx, zetaTxSender, zetaTxReceiver, inboundSenderChainID, inboundAmount, data, cctxIndexBytes) + require.NoError(t, err) + + dappAbi, err := contracts.DappMetaData.GetAbi() + require.NoError(t, err) + res, err := k.CallEVM( + ctx, + *dappAbi, + types.ModuleAddressEVM, + dAppContract, + big.NewInt(0), + nil, + false, + false, + "zetaTxSenderAddress", + ) + require.NoError(t, err) + unpacked, err := dappAbi.Unpack("zetaTxSenderAddress", res.Ret) + require.NoError(t, err) + require.NotZero(t, len(unpacked)) + valSenderAddress, ok := unpacked[0].([]byte) + require.True(t, ok) + require.Equal(t, zetaTxSender.Bytes(), valSenderAddress) + }) + + t.Run("successfully deposit coin if account is not a contract", func(t *testing.T) { + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) + zetaTxSender := sample.EthAddress() + zetaTxReceiver := sample.EthAddress() + inboundSenderChainID := int64(1) + inboundAmount := big.NewInt(45) + data := []byte("message") + cctxIndexBytes := [32]byte{} + + err := sdkk.EvmKeeper.SetAccount(ctx, zetaTxReceiver, statedb.Account{ + Nonce: 0, + Balance: big.NewInt(0), + CodeHash: crypto.Keccak256(nil), + }) + require.NoError(t, err) + + _, err = k.ZETADepositAndCallContract(ctx, zetaTxSender, zetaTxReceiver, inboundSenderChainID, inboundAmount, data, cctxIndexBytes) + require.NoError(t, err) + b := sdkk.BankKeeper.GetBalance(ctx, sdk.AccAddress(zetaTxReceiver.Bytes()), config.BaseDenom) + require.Equal(t, inboundAmount.Int64(), b.Amount.Int64()) + }) + + t.Run("fail ZETADepositAndCallContract if account not found", func(t *testing.T) { + k, ctx, _, _ := keepertest.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + zetaTxSender := sample.EthAddress() + zetaTxReceiver := sample.EthAddress() + inboundSenderChainID := int64(1) + inboundAmount := big.NewInt(45) + data := []byte("message") + cctxIndexBytes := [32]byte{} + + _, err := k.ZETADepositAndCallContract(ctx, zetaTxSender, zetaTxReceiver, inboundSenderChainID, inboundAmount, data, cctxIndexBytes) + require.ErrorIs(t, err, types.ErrAccountNotFound) + require.ErrorContains(t, err, "account not found") + }) + + t.Run("fail ZETADepositAndCallContract id Deposit Fails", func(t *testing.T) { + k, ctx, sdkk, _ := keepertest.FungibleKeeperWithMocks(t, keepertest.FungibleMockOptions{UseBankMock: true}) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + bankMock := keepertest.GetFungibleBankMock(t, k) + deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) + zetaTxSender := sample.EthAddress() + zetaTxReceiver := sample.EthAddress() + inboundSenderChainID := int64(1) + inboundAmount := big.NewInt(45) + data := []byte("message") + cctxIndexBytes := [32]byte{} + + err := sdkk.EvmKeeper.SetAccount(ctx, zetaTxReceiver, statedb.Account{ + Nonce: 0, + Balance: big.NewInt(0), + CodeHash: crypto.Keccak256(nil), + }) + require.NoError(t, err) + errorMint := errors.New("", 10, "error minting coins") + bankMock.On("MintCoins", ctx, types.ModuleName, mock.Anything).Return(errorMint).Once() + + _, err = k.ZETADepositAndCallContract(ctx, zetaTxSender, zetaTxReceiver, inboundSenderChainID, inboundAmount, data, cctxIndexBytes) + require.ErrorIs(t, err, errorMint) + }) +} + +func TestKeeper_ZEVMRevertAndCallContract(t *testing.T) { + t.Run("successfully call ZETARevertAndCallContract if receiver is a contract", func(t *testing.T) { + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) + dAppContract, err := k.DeployContract(ctx, contracts.DappMetaData) + require.NoError(t, err) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, dAppContract) + + zetaTxSender := dAppContract + senderChainID := big.NewInt(1) + destinationChainID := big.NewInt(2) + zetaTxReceiver := sample.EthAddress() + amount := big.NewInt(45) + data := []byte("message") + cctxIndexBytes := [32]byte{} + + _, err = k.ZETARevertAndCallContract(ctx, zetaTxSender, zetaTxReceiver, senderChainID.Int64(), destinationChainID.Int64(), amount, data, cctxIndexBytes) + require.NoError(t, err) + + dappAbi, err := contracts.DappMetaData.GetAbi() + require.NoError(t, err) + res, err := k.CallEVM( + ctx, + *dappAbi, + types.ModuleAddressEVM, + dAppContract, + big.NewInt(0), + nil, + false, + false, + "zetaTxSenderAddress", + ) + require.NoError(t, err) + unpacked, err := dappAbi.Unpack("zetaTxSenderAddress", res.Ret) + require.NoError(t, err) + require.NotZero(t, len(unpacked)) + valSenderAddress, ok := unpacked[0].([]byte) + require.True(t, ok) + require.Equal(t, zetaTxSender.Bytes(), valSenderAddress) + }) + + t.Run("successfully deposit coin if account is not a contract", func(t *testing.T) { + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) + zetaTxSender := sample.EthAddress() + zetaTxReceiver := sample.EthAddress() + senderChainID := big.NewInt(1) + destinationChainID := big.NewInt(2) + amount := big.NewInt(45) + data := []byte("message") + cctxIndexBytes := [32]byte{} + + err := sdkk.EvmKeeper.SetAccount(ctx, zetaTxSender, statedb.Account{ + Nonce: 0, + Balance: big.NewInt(0), + CodeHash: crypto.Keccak256(nil), + }) + require.NoError(t, err) + + _, err = k.ZETARevertAndCallContract(ctx, zetaTxSender, zetaTxReceiver, senderChainID.Int64(), destinationChainID.Int64(), amount, data, cctxIndexBytes) + require.NoError(t, err) + b := sdkk.BankKeeper.GetBalance(ctx, sdk.AccAddress(zetaTxSender.Bytes()), config.BaseDenom) + require.Equal(t, amount.Int64(), b.Amount.Int64()) + }) + + t.Run("fail ZETARevertAndCallContract if account not found", func(t *testing.T) { + k, ctx, _, _ := keepertest.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + zetaTxSender := sample.EthAddress() + zetaTxReceiver := sample.EthAddress() + senderChainID := big.NewInt(1) + destinationChainID := big.NewInt(2) + amount := big.NewInt(45) + data := []byte("message") + cctxIndexBytes := [32]byte{} + + _, err := k.ZETARevertAndCallContract(ctx, zetaTxSender, zetaTxReceiver, senderChainID.Int64(), destinationChainID.Int64(), amount, data, cctxIndexBytes) + require.ErrorIs(t, err, types.ErrAccountNotFound) + require.ErrorContains(t, err, "account not found") + }) + + t.Run("fail ZETARevertAndCallContract if Deposit Fails", func(t *testing.T) { + k, ctx, sdkk, _ := keepertest.FungibleKeeperWithMocks(t, keepertest.FungibleMockOptions{UseBankMock: true}) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + bankMock := keepertest.GetFungibleBankMock(t, k) + deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) + zetaTxSender := sample.EthAddress() + zetaTxReceiver := sample.EthAddress() + senderChainID := big.NewInt(1) + destinationChainID := big.NewInt(2) + amount := big.NewInt(45) + data := []byte("message") + cctxIndexBytes := [32]byte{} + + err := sdkk.EvmKeeper.SetAccount(ctx, zetaTxSender, statedb.Account{ + Nonce: 0, + Balance: big.NewInt(0), + CodeHash: crypto.Keccak256(nil), + }) + require.NoError(t, err) + errorMint := errors.New("", 101, "error minting coins") + bankMock.On("MintCoins", ctx, types.ModuleName, mock.Anything).Return(errorMint).Once() + + _, err = k.ZETARevertAndCallContract(ctx, zetaTxSender, zetaTxReceiver, senderChainID.Int64(), destinationChainID.Int64(), amount, data, cctxIndexBytes) + require.ErrorIs(t, err, errorMint) + }) + + t.Run("fail ZETARevertAndCallContract if ZevmOnRevert fails", func(t *testing.T) { + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + dAppContract, err := k.DeployContract(ctx, contracts.DappReverterMetaData) + require.NoError(t, err) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, dAppContract) + + zetaTxSender := dAppContract + zetaTxReceiver := sample.EthAddress() + senderChainID := big.NewInt(1) + destinationChainID := big.NewInt(2) + amount := big.NewInt(45) + data := []byte("message") + cctxIndexBytes := [32]byte{} + + _, err = k.ZETARevertAndCallContract(ctx, zetaTxSender, zetaTxReceiver, senderChainID.Int64(), destinationChainID.Int64(), amount, data, cctxIndexBytes) + require.ErrorIs(t, err, types.ErrContractNotFound) + require.ErrorContains(t, err, "GetSystemContract address not found") + }) +} diff --git a/x/fungible/keeper/zevm_msg_passing.go b/x/fungible/keeper/zevm_msg_passing.go new file mode 100644 index 0000000000..ab3210c002 --- /dev/null +++ b/x/fungible/keeper/zevm_msg_passing.go @@ -0,0 +1,61 @@ +package keeper + +import ( + "fmt" + "math/big" + + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + ethcommon "github.com/ethereum/go-ethereum/common" + evmtypes "github.com/evmos/ethermint/x/evm/types" + "github.com/zeta-chain/zetacore/x/fungible/types" +) + +// ZEVMDepositAndCallContract deposits ZETA to the to address if its an account +// If it's not an account it calls onReceive function of the connector contract and provides the address as the destinationAddress +func (k Keeper) ZETADepositAndCallContract(ctx sdk.Context, + sender ethcommon.Address, + to ethcommon.Address, + inboundSenderChainID int64, + inboundAmount *big.Int, + data []byte, + indexBytes [32]byte) (*evmtypes.MsgEthereumTxResponse, error) { + acc := k.evmKeeper.GetAccount(ctx, to) + if acc == nil { + return nil, errors.Wrap(types.ErrAccountNotFound, fmt.Sprintf("address: %s", to.String())) + } + if !acc.IsContract() { + err := k.DepositCoinZeta(ctx, to, inboundAmount) + if err != nil { + return nil, err + } + return nil, nil + } + // Call onReceive function of the connector contract. The connector contract will then call the onReceive function of the destination contract which is the to address + return k.CallOnReceiveZevmConnector(ctx, sender.Bytes(), big.NewInt(inboundSenderChainID), to, inboundAmount, data, indexBytes) +} + +// ZEVMRevertAndCallContract deposits ZETA to the sender address if its an account +// If it's not an account it calls onRevert function of the connector contract and provides the sender address as the zetaTxSenderAddress +func (k Keeper) ZETARevertAndCallContract(ctx sdk.Context, + sender ethcommon.Address, + to ethcommon.Address, + inboundSenderChainID int64, + destinationChainID int64, + remainingAmount *big.Int, + data []byte, + indexBytes [32]byte) (*evmtypes.MsgEthereumTxResponse, error) { + acc := k.evmKeeper.GetAccount(ctx, sender) + if acc == nil { + return nil, errors.Wrap(types.ErrAccountNotFound, fmt.Sprintf("address: %s", to.String())) + } + if !acc.IsContract() { + err := k.DepositCoinZeta(ctx, sender, remainingAmount) + if err != nil { + return nil, err + } + return nil, nil + } + // Call onRevert function of the connector contract. The connector contract will then call the onRevert function of the zetaTxSender contract which is the sender address + return k.CallOnRevertZevmConnector(ctx, sender, big.NewInt(inboundSenderChainID), to.Bytes(), big.NewInt(destinationChainID), remainingAmount, data, indexBytes) +} diff --git a/x/fungible/types/errors.go b/x/fungible/types/errors.go index bee52cae17..dad99cfd9b 100644 --- a/x/fungible/types/errors.go +++ b/x/fungible/types/errors.go @@ -27,4 +27,5 @@ var ( ErrCallNonContract = cosmoserrors.Register(ModuleName, 1124, "can't call a non-contract address") ErrForeignCoinAlreadyExist = cosmoserrors.Register(ModuleName, 1125, "foreign coin already exist") ErrNilGasPrice = cosmoserrors.Register(ModuleName, 1127, "nil gas price") + ErrAccountNotFound = cosmoserrors.Register(ModuleName, 1128, "account not found") ) diff --git a/x/observer/keeper/nonce_to_cctx_test.go b/x/observer/keeper/nonce_to_cctx_test.go index a16a21f5ec..e72d076a1e 100644 --- a/x/observer/keeper/nonce_to_cctx_test.go +++ b/x/observer/keeper/nonce_to_cctx_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/require" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/observer/types" ) func TestKeeper_GetNonceToCctx(t *testing.T) { @@ -29,6 +30,17 @@ func TestKeeper_GetNonceToCctx(t *testing.T) { require.False(t, found) } }) + t.Run("test nonce to cctx", func(t *testing.T) { + k, ctx, _, _ := keepertest.ObserverKeeper(t) + k.SetNonceToCctx(ctx, types.NonceToCctx{ + ChainId: 1337, + Nonce: 0, + CctxIndex: "0x705b88814b2a049e75b591fd80595c53f3bd9ddfb67ad06aa6965ed91023ee9a", + Tss: "zetapub1addwnpepq0akz8ene4z2mg3tghamr0m5eg3eeuqtjcfamkh5ecetua9u0pcyvjeyerd", + }) + _, found := k.GetNonceToCctx(ctx, "zetapub1addwnpepq0akz8ene4z2mg3tghamr0m5eg3eeuqtjcfamkh5ecetua9u0pcyvjeyerd", 1337, 0) + require.True(t, found) + }) t.Run("Get nonce to cctx not found", func(t *testing.T) { k, ctx, _, _ := keepertest.ObserverKeeper(t) nonceToCctxList := sample.NonceToCctxList(t, "sample", 1) diff --git a/zetaclient/evm/evm_signer.go b/zetaclient/evm/evm_signer.go index e077d19fe2..c0de8ea40b 100644 --- a/zetaclient/evm/evm_signer.go +++ b/zetaclient/evm/evm_signer.go @@ -359,7 +359,7 @@ func (signer *Signer) TryProcessOutTx( // Get cross-chain flags crossChainflags := signer.coreContext.GetCrossChainFlags() - + // https://github.com/zeta-chain/node/issues/2050 var tx *ethtypes.Transaction // compliance check goes first if compliance.IsCctxRestricted(cctx) { @@ -410,6 +410,11 @@ func (signer *Signer) TryProcessOutTx( } } else if cctx.CctxStatus.Status == types.CctxStatus_PendingRevert && cctx.OutboundTxParams[0].ReceiverChainId == zetaBridge.ZetaChain().ChainId { switch cctx.InboundTxParams.CoinType { + case coin.CoinType_Zeta: + logger.Info().Msgf("SignRevertTx: %d => %s, nonce %d, gasPrice %d", cctx.InboundTxParams.SenderChainId, toChain, cctx.GetCurrentOutTxParam().OutboundTxTssNonce, txData.gasPrice) + txData.srcChainID = big.NewInt(cctx.OutboundTxParams[0].ReceiverChainId) + txData.toChainID = big.NewInt(cctx.GetCurrentOutTxParam().ReceiverChainId) + tx, err = signer.SignRevertTx(txData) case coin.CoinType_Gas: logger.Info().Msgf("SignWithdrawTx: %d => %s, nonce %d, gasPrice %d", cctx.InboundTxParams.SenderChainId, toChain, cctx.GetCurrentOutTxParam().OutboundTxTssNonce, txData.gasPrice) tx, err = signer.SignWithdrawTx(txData) @@ -456,7 +461,9 @@ func (signer *Signer) BroadcastOutTx( txData *OutBoundTransactionData) { // Get destination chain for logging toChain := chains.GetChainFromChainID(txData.toChainID.Int64()) - + if tx == nil { + logger.Warn().Msgf("BroadcastOutTx: no tx to broadcast %s", cctx.Index) + } // Try to broadcast transaction if tx != nil { outTxHash := tx.Hash().Hex() diff --git a/zetaclient/zetabridge/tx_vote_inbound.go b/zetaclient/zetabridge/tx_vote_inbound.go index 43bbd4aaaf..f75a409a1c 100644 --- a/zetaclient/zetabridge/tx_vote_inbound.go +++ b/zetaclient/zetabridge/tx_vote_inbound.go @@ -15,7 +15,7 @@ const ( PostVoteInboundExecutionGasLimit = 4_000_000 // PostVoteInboundMessagePassingExecutionGasLimit is the gas limit for voting on, and executing ,observed inbound tx related to message passing (coin_type == zeta) - PostVoteInboundMessagePassingExecutionGasLimit = 1_000_000 + PostVoteInboundMessagePassingExecutionGasLimit = 4_000_000 ) // GetInBoundVoteMessage returns a new MsgVoteOnObservedInboundTx