Skip to content

Commit

Permalink
fix: removed tx index updating for non eth txs
Browse files Browse the repository at this point in the history
  • Loading branch information
onikonychev committed Jan 14, 2025
1 parent ef106f5 commit b5d5595
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 8 additions & 2 deletions eth/rpc/backend/tx_logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,26 +203,32 @@ func (s *BackendSuite) TestLogs() {
s.Require().NoError(err)
s.Require().NotNil(blockRes)
txIndex := 0
ethTxIndex := 0
for idx, check := range checks {
if txIndex+1 > len(blockRes.TxsResults) {
blockNumber++
if blockNumber > blockNumLastTx.Int64() {
s.Fail("TX %d not found in block results", idx)
}
txIndex = 0
ethTxIndex = 0
blockRes, err = s.backend.TendermintBlockResultByNumber(&blockNumber)
s.Require().NoError(err)
s.Require().NotNil(blockRes)
}
s.assertTxLogsAndTxIndex(blockRes, txIndex, check.logs, check.expectEthTx, check.txInfo)
s.assertTxLogsAndTxIndex(blockRes, txIndex, ethTxIndex, check.logs, check.expectEthTx, check.txInfo)
txIndex++
if check.expectEthTx {
ethTxIndex++
}
}
}

// assertTxLogsAndTxIndex gets tx results from the block and checks tx logs and tx index.
func (s *BackendSuite) assertTxLogsAndTxIndex(
blockRes *tmrpctypes.ResultBlockResults,
txIndex int,
ethTxIndex int,
expectedTxLogs []*gethcore.Log,
expectedEthTx bool,
txInfo string,
Expand Down Expand Up @@ -252,7 +258,7 @@ func (s *BackendSuite) assertTxLogsAndTxIndex(
ethereumTx, err := evm.EventEthereumTxFromABCIEvent(event)
s.Require().NoError(err)
s.Require().Equal(
fmt.Sprintf("%d", txIndex),
fmt.Sprintf("%d", ethTxIndex),
ethereumTx.Index,
"tx index mismatch, %s", txInfo,
)
Expand Down
2 changes: 0 additions & 2 deletions x/evm/keeper/call_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ func (k Keeper) CallContractWithInput(
if err != nil {
return nil, nil, errors.Wrap(err, "error emitting tx logs")
}

Check warning on line 144 in x/evm/keeper/call_contract.go

View check run for this annotation

Codecov / codecov/patch

x/evm/keeper/call_contract.go#L143-L144

Added lines #L143 - L144 were not covered by tests
blockTxIdx := uint64(txConfig.TxIndex) + 1
k.EvmState.BlockTxIndex.Set(ctx, blockTxIdx)
}
return evmResp, evmObj, nil
}

0 comments on commit b5d5595

Please sign in to comment.