diff --git a/baseapp/abci.go b/baseapp/abci.go index c005111ea..3965d73fa 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -317,6 +317,7 @@ func (app *BaseApp) DeliverTx(ctx sdk.Context, req abci.RequestDeliverTx, tx sdk res.EvmTxInfo = &abci.EvmTxInfo{ SenderAddress: resCtx.EVMSenderAddress(), Nonce: resCtx.EVMNonce(), + TxHash: resCtx.EVMTxHash(), } } return diff --git a/baseapp/deliver_tx_test.go b/baseapp/deliver_tx_test.go index 11e451c36..308921fc2 100644 --- a/baseapp/deliver_tx_test.go +++ b/baseapp/deliver_tx_test.go @@ -1498,6 +1498,8 @@ func TestDeliverTx(t *testing.T) { app.BeginBlock(app.deliverState.ctx, abci.RequestBeginBlock{Header: header}) for i := 0; i < txPerHeight; i++ { + // every even i is an evm tx + isEvm := i%2 == 0 counter := int64(blockN*txPerHeight + i) tx := newTxCounter(counter, counter) @@ -1505,12 +1507,30 @@ func TestDeliverTx(t *testing.T) { require.NoError(t, err) decoded, _ := app.txDecoder(txBytes) - res := app.DeliverTx(app.deliverState.ctx, abci.RequestDeliverTx{Tx: txBytes}, decoded, sha256.Sum256(txBytes)) + + ctx := app.deliverState.ctx + + if isEvm { + ctx = ctx.WithIsEVM(true) + ctx = ctx.WithEVMNonce(12345) + ctx = ctx.WithEVMTxHash("hash") + ctx = ctx.WithEVMSenderAddress("address") + } + + res := app.DeliverTx(ctx, abci.RequestDeliverTx{Tx: txBytes}, decoded, sha256.Sum256(txBytes)) require.True(t, res.IsOK(), fmt.Sprintf("%v", res)) events := res.GetEvents() require.Len(t, events, 3, "should contain ante handler, message type and counter events respectively") require.Equal(t, sdk.MarkEventsToIndex(counterEvent("ante_handler", counter).ToABCIEvents(), map[string]struct{}{})[0], events[0], "ante handler event") require.Equal(t, sdk.MarkEventsToIndex(counterEvent(sdk.EventTypeMessage, counter).ToABCIEvents(), map[string]struct{}{})[0], events[2], "msg handler update counter event") + + if isEvm { + require.Equal(t, uint64(12345), res.EvmTxInfo.Nonce) + require.Equal(t, "hash", res.EvmTxInfo.TxHash) + require.Equal(t, "address", res.EvmTxInfo.SenderAddress) + } else { + require.Nil(t, res.EvmTxInfo) + } } app.EndBlock(app.deliverState.ctx, abci.RequestEndBlock{}) diff --git a/go.mod b/go.mod index 2337ab3ed..4c1d4fac6 100644 --- a/go.mod +++ b/go.mod @@ -190,7 +190,7 @@ replace ( github.com/sei-protocol/sei-db => github.com/sei-protocol/sei-db v0.0.31 // 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.38-evm-rebase-2 + github.com/tendermint/tendermint => github.com/sei-protocol/sei-tendermint v0.2.43-seiv2 // latest grpc doesn't work with with our modified proto compiler, so we need to enforce // the following version across all dependencies. google.golang.org/grpc => google.golang.org/grpc v1.33.2 diff --git a/go.sum b/go.sum index e9399f4a3..8dae52d2b 100644 --- a/go.sum +++ b/go.sum @@ -954,8 +954,8 @@ github.com/sei-protocol/sei-db v0.0.31 h1:UW9skaXnaXfi9mp60EbAJ2ijyr1Hnu9WYatMNr github.com/sei-protocol/sei-db v0.0.31/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-tendermint v0.2.38-evm-rebase-2 h1:y740HdzTehlJaBrwy/T1ncwJ9D10xu4r6gSHtNRzqF0= -github.com/sei-protocol/sei-tendermint v0.2.38-evm-rebase-2/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/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= diff --git a/types/context.go b/types/context.go index b2c467257..5cfab7a26 100644 --- a/types/context.go +++ b/types/context.go @@ -53,6 +53,7 @@ type Context struct { evm bool // EVM transaction flag evmNonce uint64 // EVM Transaction nonce evmSenderAddress string // EVM Sender address + evmTxHash string // EVM TX hash msgValidator *acltypes.MsgValidator messageIndex int // Used to track current message being processed @@ -137,6 +138,10 @@ func (c Context) EVMNonce() uint64 { return c.evmNonce } +func (c Context) EVMTxHash() string { + return c.evmTxHash +} + func (c Context) IsEVM() bool { return c.evm } @@ -397,6 +402,11 @@ func (c Context) WithIsEVM(isEVM bool) Context { return c } +func (c Context) WithEVMTxHash(txHash string) Context { + c.evmTxHash = txHash + return c +} + func (c Context) WithPendingTxChecker(checker abci.PendingTxChecker) Context { c.pendingTxChecker = checker return c