Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
66ad361
fix: evm tx index and log indexes are not patched
mmsqe Nov 7, 2025
68ef5bc
patch
mmsqe Nov 7, 2025
f5c9459
cleanup ResetTransientGasUsed
mmsqe Nov 7, 2025
2440987
add fallback
mmsqe Nov 7, 2025
b49d6be
more test
mmsqe Nov 7, 2025
64209c6
Merge branch 'main' into patch
aljo242 Nov 7, 2025
13bca57
Merge branch 'main' into patch
mmsqe Nov 12, 2025
0c9db23
Merge branch 'main' into patch
aljo242 Nov 12, 2025
108b10d
Merge branch 'main' into patch
mmsqe Nov 13, 2025
d566083
Merge branch 'main' into patch
aljo242 Nov 14, 2025
ef90267
Merge branch 'main' into patch
aljo242 Nov 14, 2025
909cd0c
Merge branch 'main' into patch
aljo242 Nov 19, 2025
7bea253
Merge branch 'main' into patch
aljo242 Nov 19, 2025
dfa7810
add doc
mmsqe Nov 20, 2025
5440a1b
Merge remote-tracking branch 'origin/main' into patch
mmsqe Nov 20, 2025
1d0ccfb
only overwrite tx index not found
mmsqe Nov 20, 2025
8019fd0
Merge branch 'main' into patch
aljo242 Nov 21, 2025
0af6bcb
cleanup
mmsqe Nov 22, 2025
c2c5f30
Merge remote-tracking branch 'origin/main' into patch
mmsqe Nov 22, 2025
977a5df
bump sdk
mmsqe Nov 26, 2025
a436262
fix lint later
mmsqe Nov 19, 2025
4a5f69f
Merge branch 'main' into patch
aljo242 Dec 4, 2025
91fa89a
Merge remote-tracking branch 'origin/main' into patch
mmsqe Dec 18, 2025
cddc9cb
Merge remote-tracking branch 'origin/main' into patch
mmsqe Jan 7, 2026
4333aab
Merge branch 'main' into patch
vladjdk Jan 8, 2026
645980c
Merge remote-tracking branch 'origin/main' into patch
mmsqe Mar 9, 2026
9bdc73c
fix resolve
mmsqe Mar 12, 2026
8455a9d
Merge remote-tracking branch 'origin/main' into patch
mmsqe Mar 12, 2026
a996d11
cleanup
mmsqe Mar 12, 2026
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
- [\#774](https://github.com/cosmos/evm/pull/774) Emit proper allowance amount in erc20 event.
- [\#790](https://github.com/cosmos/evm/pull/790) fix panic in historical query due to missing EvmCoinInfo.
- [\#800](https://github.com/cosmos/evm/pull/800) Fix denom exponent validation in virtual fee deduct in vm module.
- [\#812](https://github.com/cosmos/evm/pull/812) Patch evm tx index and log indexes, cleanup EmitTxHashEvent and ResetTransientGasUsed.
- [\#817](https://github.com/cosmos/evm/pull/817) Align GetCoinbaseAddress to handle empty proposer address in contexts like CheckTx where proposer doesn't exist.
- [\#814](https://github.com/cosmos/evm/pull/814) Fix duplicated events in post tx processor.
- [\#816](https://github.com/cosmos/evm/pull/816) Avoid nil pointer when RPC requests execute before evmCoinInfo initialization in PreBlock with defaultEvmCoinInfo fallback.
Expand Down
25 changes: 0 additions & 25 deletions ante/evm/11_emit_event.go

This file was deleted.

3 changes: 0 additions & 3 deletions ante/evm/mono_decorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,6 @@ func (md MonoDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, ne
return ctx, err
}

// Emit event unconditionally - ctx.TxIndex() will be valid during block execution
EmitTxHashEvent(ctx, ethMsg, uint64(ctx.TxIndex())) // #nosec G115 -- no overlfow here

if err := CheckTxFee(txFeeInfo, decUtils.TxFee, decUtils.TxGasLimit); err != nil {
return ctx, err
}
Expand Down
45 changes: 32 additions & 13 deletions evmd/app.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package evmd

import (
"context"
"encoding/json"
"errors"
"fmt"
Expand All @@ -9,17 +10,16 @@ import (

goruntime "runtime"

cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"

"github.com/spf13/cast"

// Force-load the tracer engines to trigger registration due to Go-Ethereum v1.10.15 changes
"github.com/cosmos/cosmos-sdk/baseapp/txnrunner"
"github.com/ethereum/go-ethereum/common"

_ "github.com/ethereum/go-ethereum/eth/tracers/js"
_ "github.com/ethereum/go-ethereum/eth/tracers/native"

abci "github.com/cometbft/cometbft/abci/types"

dbm "github.com/cosmos/cosmos-db"
evmante "github.com/cosmos/evm/ante"
antetypes "github.com/cosmos/evm/ante/types"
Expand Down Expand Up @@ -64,6 +64,7 @@ import (
storetypes "cosmossdk.io/store/types"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/baseapp/txnrunner"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/grpc/cmtservice"
Expand Down Expand Up @@ -147,6 +148,19 @@ var (
_ ibctesting.TestingApp = (*EVMD)(nil)
)

type customRunner struct {
*txnrunner.STMRunner
}

func (r *customRunner) Run(ctx context.Context, ms storetypes.MultiStore, txs [][]byte, deliverTx sdk.DeliverTxFunc) ([]*abci.ExecTxResult, error) {
results, err := r.STMRunner.Run(ctx, ms, txs, deliverTx)
if err != nil {
return nil, err
}

return evmtypes.PatchTxResponses(results), nil
}

// EVMD extends an ABCI application, but with most of its parameters exported.
type EVMD struct {
*baseapp.BaseApp
Expand Down Expand Up @@ -214,6 +228,7 @@ func NewExampleApp(
legacyAmino := encodingConfig.Amino
interfaceRegistry := encodingConfig.InterfaceRegistry
txConfig := encodingConfig.TxConfig
txDecoder := encodingConfig.TxConfig.TxDecoder()

// enable optimistic execution
baseAppOptions = append(
Expand All @@ -226,7 +241,7 @@ func NewExampleApp(
logger,
db,
// use transaction decoder to support the sdk.Tx interface instead of sdk.StdTx
encodingConfig.TxConfig.TxDecoder(),
txDecoder,
baseAppOptions...,
)
bApp.SetCommitMultiStoreTracer(traceStore)
Expand Down Expand Up @@ -254,15 +269,6 @@ func NewExampleApp(
nonTransientKeys = append(nonTransientKeys, k)
}

// enable block stm for parallel execution
bApp.SetBlockSTMTxRunner(txnrunner.NewSTMRunner(
encodingConfig.TxConfig.TxDecoder(),
nonTransientKeys,
min(goruntime.GOMAXPROCS(0), goruntime.NumCPU()),
true,
func(ms storetypes.MultiStore) string { return sdk.DefaultBondDenom },
))

// disable block gas meter
bApp.SetDisableBlockGasMeter(true)

Expand Down Expand Up @@ -780,6 +786,19 @@ func NewExampleApp(
}
}

// enable block stm for parallel execution
bApp.SetBlockSTMTxRunner(&customRunner{
STMRunner: txnrunner.NewSTMRunner(
txDecoder,
nonTransientKeys,
min(goruntime.GOMAXPROCS(0), goruntime.NumCPU()),
true,
func(ms storetypes.MultiStore) string {
return app.EVMKeeper.GetParams(sdk.NewContext(ms, cmtproto.Header{}, false, log.NewNopLogger())).EvmDenom
},
),
})

return app
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (s *BalanceHandlerTestSuite) TestRecursivePrecompileCallsWithDebugPrecompil
s.Require().NoError(err, "callback transaction should succeed")
s.Require().False(res.IsErr(), "callback should not fail: %s", res.Events)

s.Require().Equal(len(res.Events), 15, "callback should have 15 events")
s.Require().Equal(15, len(res.Events), "callback should have 15 events")
debug_count := 0
for _, event := range res.Events {
if event.Type == "debug_precompile" {
Expand Down
1 change: 0 additions & 1 deletion local_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then
sed -i.bak 's/prometheus-retention-time = "0"/prometheus-retention-time = "1000000000000"/g' "$APP_TOML"
sed -i.bak 's/enabled = false/enabled = true/g' "$APP_TOML"
sed -i.bak 's/enable = false/enable = true/g' "$APP_TOML"
sed -i.bak 's/enable-indexer = false/enable-indexer = true/g' "$APP_TOML"

# --------- maybe generate additional users ---------
# start with provided/default list
Expand Down
9 changes: 9 additions & 0 deletions rpc/backend/comet_to_eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,15 @@ func (b *Backend) ReceiptsFromCometBlock(
return nil, fmt.Errorf("failed to convert tx result to eth receipt: %w", err)
}

if txResult.EthTxIndex == -1 {
var err error
// Fallback to find tx index by iterating all valid eth transactions
txResult.EthTxIndex, err = FindEthTxIndexByHash(ctx, ethMsg.Hash(), resBlock, blockRes, b)
if err != nil {
return nil, err
}
}

bloom := ethtypes.CreateBloom(&ethtypes.Receipt{Logs: logs})

receipt := &ethtypes.Receipt{
Expand Down
18 changes: 4 additions & 14 deletions rpc/backend/tx_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"math"
"math/big"
"time"

Expand Down Expand Up @@ -66,22 +65,13 @@ func (b *Backend) GetTransactionByHash(ctx context.Context, txHash common.Hash)
}

if res.EthTxIndex == -1 {
var err error
// Fallback to find tx index by iterating all valid eth transactions
msgs := b.EthMsgsFromCometBlock(ctx, block, blockRes)
for i := range msgs {
if msgs[i].Hash() == txHash {
if i > math.MaxInt32 {
return nil, errors.New("tx index overflow")
}
res.EthTxIndex = int32(i) //#nosec G115 -- checked for int overflow already
break
}
res.EthTxIndex, err = FindEthTxIndexByHash(ctx, txHash, block, blockRes, b)
if err != nil {
return nil, err
}
}
// if we still unable to find the eth tx index, return error, shouldn't happen.
if res.EthTxIndex == -1 {
return nil, errors.New("can't find index of ethereum tx")
}

baseFee, err := b.BaseFee(ctx, blockRes)
if err != nil {
Expand Down
14 changes: 14 additions & 0 deletions rpc/backend/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,17 @@ func unwrapBlockNOrHash(blockNOrHash types.BlockNumberOrHash) string {
}
return ""
}

// Fallback to find tx index by iterating all valid eth transactions for legacy blocks that don't have AttributeKeyTxIndex in events
func FindEthTxIndexByHash(ctx context.Context, txHash common.Hash, block *cmtrpctypes.ResultBlock, blockRes *cmtrpctypes.ResultBlockResults, b *Backend) (int32, error) {
msgs := b.EthMsgsFromCometBlock(ctx, block, blockRes)
for i := range msgs {
if msgs[i].Hash() == txHash {
if i > math.MaxInt32 {
return -1, fmt.Errorf("tx index overflow")
}
return int32(i), nil //#nosec G115 -- checked for int overflow already
}
}
return -1, fmt.Errorf("can't find index of ethereum tx")
}
4 changes: 4 additions & 0 deletions rpc/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ func (p *ParsedTxs) updateTx(eventIndex int, attrs []abci.EventAttribute) error
// if hash is different, index the new one too
p.TxHashes[tx.Hash] = eventIndex
}
// preserve EthTxIndex from the first event set by PatchTxResponses if not set in the second event from msg_server
if tx.EthTxIndex == -1 {
tx.EthTxIndex = p.Txs[eventIndex].EthTxIndex
}
// override the tx because the second event is more trustworthy
p.Txs[eventIndex] = tx
return nil
Expand Down
Loading
Loading