diff --git a/cmd/zetae2e/config/local.yml b/cmd/zetae2e/config/local.yml index ee5e171ccc..f4aa45599c 100644 --- a/cmd/zetae2e/config/local.yml +++ b/cmd/zetae2e/config/local.yml @@ -25,8 +25,10 @@ contracts: uniswap_router: "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe" connector_zevm: "0x239e96c8f17C85c30100AC26F635Ea15f23E9c67" wzeta: "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf" + test_dapp: "0xA8D5060feb6B456e886F023709A2795373691E63" evm: zeta_eth: "0x733aB8b06DDDEf27Eaa72294B0d7c9cEF7f12db9" connector_eth: "0xD28D6A0b8189305551a0A8bd247a6ECa9CE781Ca" custody: "0xff3135df4F2775f4091b81f4c7B6359CfA07862a" - erc20: "0xbD1e64A22B9F92D9Ce81aA9B4b0fFacd80215564" \ No newline at end of file + erc20: "0xbD1e64A22B9F92D9Ce81aA9B4b0fFacd80215564" + test_dapp: "0xBFF76e77D56B3C1202107f059425D56f0AEF87Ed" \ No newline at end of file diff --git a/e2e/e2etests/test_message_passing_evm_to_zevm_revert.go b/e2e/e2etests/test_message_passing_evm_to_zevm_revert.go index 99a49fba56..85aca0caae 100644 --- a/e2e/e2etests/test_message_passing_evm_to_zevm_revert.go +++ b/e2e/e2etests/test_message_passing_evm_to_zevm_revert.go @@ -13,9 +13,15 @@ import ( cctxtypes "github.com/zeta-chain/zetacore/x/crosschain/types" ) +// fungibleModuleAddress is a constant representing the EVM address of the Fungible module account +const fungibleModuleAddress = "0x735b14BB79463307AAcBED86DAf3322B1e6226aB" + func TestMessagePassingEVMtoZEVMRevert(r *runner.E2ERunner, args []string) { require.Len(r, args, 1) + fungibleEthAddress := ethcommon.HexToAddress(fungibleModuleAddress) + require.True(r, fungibleEthAddress != ethcommon.Address{}, "invalid fungible module address") + amount, ok := big.NewInt(0).SetString(args[0], 10) require.True(r, ok) @@ -46,6 +52,9 @@ func TestMessagePassingEVMtoZEVMRevert(r *runner.E2ERunner, args []string) { previousBalanceEVM, err := r.ZetaEth.BalanceOf(&bind.CallOpts{}, r.EvmTestDAppAddr) require.NoError(r, err) + previousFungibleBalance, err := r.WZeta.BalanceOf(&bind.CallOpts{}, fungibleEthAddress) + require.NoError(r, 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) @@ -105,4 +114,17 @@ func TestMessagePassingEVMtoZEVMRevert(r *runner.E2ERunner, args []string) { previousBalanceAndAmountEVM.String(), newBalanceEVM.String(), ) + + // Check ZETA balance on Fungible Module and check new balance is previous balance + newFungibleBalance, err := r.WZeta.BalanceOf(&bind.CallOpts{}, fungibleEthAddress) + require.NoError(r, err) + + require.Equal( + r, + 0, + newFungibleBalance.Cmp(previousFungibleBalance), + "expected new balance to be %s, got %s", + previousFungibleBalance.String(), + newFungibleBalance.String(), + ) } diff --git a/rpc/backend/blocks_test.go b/rpc/backend/blocks_test.go index bec50ff5a5..ef8023e448 100644 --- a/rpc/backend/blocks_test.go +++ b/rpc/backend/blocks_test.go @@ -1716,7 +1716,7 @@ func (suite *BackendTestSuite) TestEthAndSyntheticGetBlockByNumber() { suite.Require().Equal("0x775b87ef5D82ca211811C1a02CE0fE0CA3a455d7", resSyntheticTx.To.Hex()) suite.Require().Equal("0x58", resSyntheticTx.Type.String()) suite.Require().Equal("0x1", resSyntheticTx.Nonce.String()) - suite.Require().Nil(resSyntheticTx.V) - suite.Require().Nil(resSyntheticTx.R) - suite.Require().Nil(resSyntheticTx.S) + suite.Require().Equal((*hexutil.Big)(big.NewInt(0)), resSyntheticTx.V) + suite.Require().Equal((*hexutil.Big)(big.NewInt(0)), resSyntheticTx.R) + suite.Require().Equal((*hexutil.Big)(big.NewInt(0)), resSyntheticTx.S) } diff --git a/rpc/backend/tx_info_test.go b/rpc/backend/tx_info_test.go index 0ceb0160a6..f564494f19 100644 --- a/rpc/backend/tx_info_test.go +++ b/rpc/backend/tx_info_test.go @@ -59,9 +59,9 @@ func (suite *BackendTestSuite) TestGetSyntheticTransactionByHash() { gas, _ := hexutil.DecodeUint64(res.Gas.String()) suite.Require().Equal(uint64(21000), gas) suite.Require().Equal("0x1234", res.Input.String()) - suite.Require().Nil(res.V) - suite.Require().Nil(res.R) - suite.Require().Nil(res.S) + suite.Require().Equal((*hexutil.Big)(big.NewInt(0)), res.V) + suite.Require().Equal((*hexutil.Big)(big.NewInt(0)), res.R) + suite.Require().Equal((*hexutil.Big)(big.NewInt(0)), res.S) } func (suite *BackendTestSuite) TestGetSyntheticTransactionReceiptByHash() { @@ -127,9 +127,9 @@ func (suite *BackendTestSuite) TestGetSyntheticTransactionByBlockNumberAndIndex( suite.Require().Equal(uint64(88), txType) suite.Require().Equal(int64(7001), res.ChainID.ToInt().Int64()) suite.Require().Equal(int64(1000), res.Value.ToInt().Int64()) - suite.Require().Nil(res.V) - suite.Require().Nil(res.R) - suite.Require().Nil(res.S) + suite.Require().Equal((*hexutil.Big)(big.NewInt(0)), res.V) + suite.Require().Equal((*hexutil.Big)(big.NewInt(0)), res.R) + suite.Require().Equal((*hexutil.Big)(big.NewInt(0)), res.S) } func (suite *BackendTestSuite) TestGetSyntheticTransactionByBlockNumberAndIndexWithRealTransaction() { @@ -160,9 +160,9 @@ func (suite *BackendTestSuite) TestGetSyntheticTransactionByBlockNumberAndIndexW suite.Require().Equal(uint64(88), txType) suite.Require().Equal(int64(7001), res.ChainID.ToInt().Int64()) suite.Require().Equal(int64(1000), res.Value.ToInt().Int64()) - suite.Require().Nil(res.V) - suite.Require().Nil(res.R) - suite.Require().Nil(res.S) + suite.Require().Equal((*hexutil.Big)(big.NewInt(0)), res.V) + suite.Require().Equal((*hexutil.Big)(big.NewInt(0)), res.R) + suite.Require().Equal((*hexutil.Big)(big.NewInt(0)), res.S) } func (suite *BackendTestSuite) TestGetTransactionByHash() { diff --git a/rpc/types/utils.go b/rpc/types/utils.go index 7ba3c998da..6064a76de5 100644 --- a/rpc/types/utils.go +++ b/rpc/types/utils.go @@ -256,9 +256,9 @@ func NewRPCTransactionFromIncompleteMsg( Nonce: hexutil.Uint64(txAdditional.Nonce), // TODO: get nonce for "from" from ethermint To: to, Value: (*hexutil.Big)(txAdditional.Value), - V: nil, - R: nil, - S: nil, + V: (*hexutil.Big)(big.NewInt(0)), + R: (*hexutil.Big)(big.NewInt(0)), + S: (*hexutil.Big)(big.NewInt(0)), ChainID: (*hexutil.Big)(chainID), } if blockHash != (common.Hash{}) { diff --git a/x/crosschain/keeper/cctx_gateway_zevm.go b/x/crosschain/keeper/cctx_gateway_zevm.go index 3a6f9a8135..d9061be54a 100644 --- a/x/crosschain/keeper/cctx_gateway_zevm.go +++ b/x/crosschain/keeper/cctx_gateway_zevm.go @@ -33,7 +33,7 @@ func (c CCTXGatewayZEVM) InitiateOutbound( } newCCTXStatus = c.crosschainKeeper.ValidateOutboundZEVM(ctx, config.CCTX, err, isContractReverted) - if newCCTXStatus == types.CctxStatus_OutboundMined { + if newCCTXStatus == types.CctxStatus_OutboundMined || newCCTXStatus == types.CctxStatus_PendingRevert { commit() } diff --git a/x/fungible/keeper/evm.go b/x/fungible/keeper/evm.go index 5a9d950b14..0e5e179626 100644 --- a/x/fungible/keeper/evm.go +++ b/x/fungible/keeper/evm.go @@ -745,10 +745,6 @@ func (k Keeper) CallEVMWithData( return nil, err } - if res.Failed() { - return res, cosmoserrors.Wrap(evmtypes.ErrVMExecution, fmt.Sprintf("%s: ret 0x%x", res.VmError, res.Ret)) - } - // Emit events and log for the transaction if it is committed if commit { msgBytes, err := json.Marshal(msg) @@ -825,5 +821,9 @@ func (k Keeper) CallEVMWithData( } } + if res.Failed() { + return res, cosmoserrors.Wrapf(evmtypes.ErrVMExecution, "%s: ret 0x%x", res.VmError, res.Ret) + } + return res, nil }