Skip to content

Commit

Permalink
fix(evm): TxIndex is wrong when trace is the first tx of a block (e…
Browse files Browse the repository at this point in the history
…vmos#1187)

* Fix TxIndex wrongly when trace first Tx of a block

If `Predecessors` is empty, `txConfig.TxIndex` originally = 0 and when it reachs line 401 `txConfig.TxIndex++`, it will becomes 1. It should be 0

* apply suggestion and add change-log

* fix comment

Co-authored-by: Federico Kunze Küllmer <[email protected]>
  • Loading branch information
2 people authored and devon-chain committed Aug 2, 2022
1 parent 788818b commit 51c7f22
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

* (evm) [\#1187](https://github.com/evmos/ethermint/pull/1187) Fix `TxIndex` value (expected 0, actual 1) when trace the first tx of a block via `debug_traceTransaction` api
* (rpc) [\#1190](https://github.com/evmos/ethermint/issues/1190) Fix `UnmarshalJSON` panig of breaking EVM and fee market `Params`.
* (rpc) [#1179](https://github.com/evmos/ethermint/pull/1179) Fix gas used in traceTransaction response.

Expand Down
5 changes: 4 additions & 1 deletion x/evm/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,10 @@ func (k Keeper) TraceTx(c context.Context, req *types.QueryTraceTxRequest) (*typ

tx := req.Msg.AsTransaction()
txConfig.TxHash = tx.Hash()
txConfig.TxIndex++
if len(req.Predecessors) > 0 {
txConfig.TxIndex++
}

result, _, err := k.traceTx(ctx, cfg, txConfig, signer, tx, req.TraceConfig, false)
if err != nil {
// error will be returned with detail status from traceTx
Expand Down

0 comments on commit 51c7f22

Please sign in to comment.