Skip to content

Commit

Permalink
[EVM] Add tx hash to context for evm info (#1563)
Browse files Browse the repository at this point in the history
add tx hash to context
  • Loading branch information
stevenlanders authored Apr 18, 2024
1 parent df899bb commit aa0aca9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,15 @@ require (
replace (
github.com/CosmWasm/wasmd => github.com/sei-protocol/sei-wasmd v0.1.0
github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0
github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.2.81-seiv2
github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.2.82-seiv2
github.com/cosmos/iavl => github.com/sei-protocol/sei-iavl v0.1.9
github.com/cosmos/ibc-go/v3 => github.com/sei-protocol/sei-ibc-go/v3 v3.3.0
github.com/ethereum/go-ethereum => github.com/sei-protocol/go-ethereum v1.13.5-sei-15
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/sei-protocol/sei-db => github.com/sei-protocol/sei-db v0.0.35
// Latest goleveldb is broken, we have to stick to this version
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
github.com/tendermint/tendermint => github.com/sei-protocol/sei-tendermint v0.2.42-seiv2
github.com/tendermint/tendermint => github.com/sei-protocol/sei-tendermint v0.2.43-seiv2
github.com/tendermint/tm-db => github.com/sei-protocol/tm-db v0.0.4
google.golang.org/grpc => google.golang.org/grpc v1.33.2
)
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1347,16 +1347,16 @@ github.com/sei-protocol/go-ethereum v1.13.5-sei-15 h1:VSFQrbWnSDCPCQzsYDW3k07EP3
github.com/sei-protocol/go-ethereum v1.13.5-sei-15/go.mod h1:kcRZmuzRn1lVejiFNTz4l4W7imnpq1bDAnuKS/RyhbQ=
github.com/sei-protocol/goutils v0.0.2 h1:Bfa7Sv+4CVLNM20QcpvGb81B8C5HkQC/kW1CQpIbXDA=
github.com/sei-protocol/goutils v0.0.2/go.mod h1:iYE2DuJfEnM+APPehr2gOUXfuLuPsVxorcDO+Tzq9q8=
github.com/sei-protocol/sei-cosmos v0.2.81-seiv2 h1:C9fUcLhUGWITAWuuug2dwTHkFiE+1BiolbWgxlDZUyc=
github.com/sei-protocol/sei-cosmos v0.2.81-seiv2/go.mod h1:ib/gp0gCxN7FXUZ40j5+x8BeyoI7AcX+rTvf53JoDsY=
github.com/sei-protocol/sei-cosmos v0.2.82-seiv2 h1:UyZp55yBCefGmcl48aCaZFkHb97+7jChfsd8+6Y77SE=
github.com/sei-protocol/sei-cosmos v0.2.82-seiv2/go.mod h1:HLpjyCHtzl7WbxXVpjWNrTCzFR/n6UTIzLQU1lWqvbo=
github.com/sei-protocol/sei-db v0.0.35 h1:BNHv0gtKE4J5kq1Mhxt9dpop3lI4W2I5WurgWYIYa4E=
github.com/sei-protocol/sei-db v0.0.35/go.mod h1:F/ZKZA8HJPcUzSZPA8yt6pfwlGriJ4RDR4eHKSGLStI=
github.com/sei-protocol/sei-iavl v0.1.9 h1:y4mVYftxLNRs6533zl7N0/Ch+CzRQc04JDfHolIxgBE=
github.com/sei-protocol/sei-iavl v0.1.9/go.mod h1:7PfkEVT5dcoQE+s/9KWdoXJ8VVVP1QpYYPLdxlkSXFk=
github.com/sei-protocol/sei-ibc-go/v3 v3.3.0 h1:/mjpTuCSEVDJ51nUDSHU92N0bRSwt49r1rmdC/lqgp8=
github.com/sei-protocol/sei-ibc-go/v3 v3.3.0/go.mod h1:VwB/vWu4ysT5DN2aF78d17LYmx3omSAdq6gpKvM7XRA=
github.com/sei-protocol/sei-tendermint v0.2.42-seiv2 h1:1biDAPS50q188kjFoMyomQceHDJm+KYCyxAFoZ8bMIM=
github.com/sei-protocol/sei-tendermint v0.2.42-seiv2/go.mod h1:4LSlJdhl3nf3OmohliwRNUFLOB1XWlrmSodrIP7fLh4=
github.com/sei-protocol/sei-tendermint v0.2.43-seiv2 h1:aSyMTWLcj3xsqMhIndipy9NJSgwwODmXnqmbnsab+nc=
github.com/sei-protocol/sei-tendermint v0.2.43-seiv2/go.mod h1:4LSlJdhl3nf3OmohliwRNUFLOB1XWlrmSodrIP7fLh4=
github.com/sei-protocol/sei-tm-db v0.0.5 h1:3WONKdSXEqdZZeLuWYfK5hP37TJpfaUa13vAyAlvaQY=
github.com/sei-protocol/sei-tm-db v0.0.5/go.mod h1:Cpa6rGyczgthq7/0pI31jys2Fw0Nfrc+/jKdP1prVqY=
github.com/sei-protocol/sei-wasmd v0.1.0 h1:YCJ8SzJYMUR6hYOtgfjETFmSX1qx6cfLCmRAav2KMIs=
Expand Down
1 change: 1 addition & 0 deletions x/evm/ante/sig.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func (svd *EVMSigVerifyDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulat
ctx = ctx.WithIsEVM(true)
ctx = ctx.WithEVMNonce(txNonce)
ctx = ctx.WithEVMSenderAddress(evmAddr.Hex())
ctx = ctx.WithEVMTxHash(ethTx.Hash().Hex())

if ctx.IsCheckTx() {
if txNonce < nextNonce {
Expand Down
9 changes: 8 additions & 1 deletion x/evm/ante/sig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ func TestEVMSigVerifyDecorator(t *testing.T) {
signer := ethtypes.MakeSigner(ethCfg, blockNum, uint64(ctx.BlockTime().Unix()))
tx, err := ethtypes.SignTx(ethtypes.NewTx(&txData), signer, key)
require.Nil(t, err)
sender, err := signer.Sender(tx)
require.Nil(t, err)
typedTx, err := ethtx.NewLegacyTx(tx)
require.Nil(t, err)
msg, err := types.NewMsgEVMTransaction(typedTx)
Expand All @@ -52,11 +54,16 @@ func TestEVMSigVerifyDecorator(t *testing.T) {
require.Nil(t, err)

// should return error because nonce is incorrect
_, err = handler.AnteHandle(ctx, mockTx{msgs: []sdk.Msg{msg}}, false, func(ctx sdk.Context, _ sdk.Tx, _ bool) (sdk.Context, error) {
resCtx, err := handler.AnteHandle(ctx, mockTx{msgs: []sdk.Msg{msg}}, false, func(ctx sdk.Context, _ sdk.Tx, _ bool) (sdk.Context, error) {
return ctx, nil
})
require.NotNil(t, err)

require.Equal(t, uint64(1), resCtx.EVMNonce())
require.Equal(t, sender.Hex(), resCtx.EVMSenderAddress())
require.Equal(t, tx.Hash().Hex(), resCtx.EVMTxHash())
require.Equal(t, true, resCtx.IsEVM())

// should return error if acc is not found (i.e. preprocess not called)
txData.Nonce = 0
tx, err = ethtypes.SignTx(ethtypes.NewTx(&txData), signer, key)
Expand Down

0 comments on commit aa0aca9

Please sign in to comment.