Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: emit events on revert #2466

Merged
merged 9 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions rpc/backend/blocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
18 changes: 9 additions & 9 deletions rpc/backend/tx_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions rpc/types/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@
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)),

Check warning on line 261 in rpc/types/utils.go

View check run for this annotation

Codecov / codecov/patch

rpc/types/utils.go#L259-L261

Added lines #L259 - L261 were not covered by tests
lumtis marked this conversation as resolved.
Show resolved Hide resolved
ChainID: (*hexutil.Big)(chainID),
}
if blockHash != (common.Hash{}) {
Expand Down
2 changes: 1 addition & 1 deletion x/crosschain/keeper/cctx_gateway_zevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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_Aborted {
skosito marked this conversation as resolved.
Show resolved Hide resolved
commit()
}

Expand Down
8 changes: 4 additions & 4 deletions x/fungible/keeper/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -825,5 +821,9 @@ func (k Keeper) CallEVMWithData(
}
}

if res.Failed() {
lumtis marked this conversation as resolved.
Show resolved Hide resolved
return res, cosmoserrors.Wrap(evmtypes.ErrVMExecution, fmt.Sprintf("%s: ret 0x%x", res.VmError, res.Ret))
skosito marked this conversation as resolved.
Show resolved Hide resolved
}

return res, nil
}
Loading