From b4304b17a52e4909d36c9977905f36ce62c76f04 Mon Sep 17 00:00:00 2001 From: Victor Pham Date: Sun, 17 Jul 2022 14:12:28 +0700 Subject: [PATCH 1/3] 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 --- x/evm/keeper/grpc_query.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/x/evm/keeper/grpc_query.go b/x/evm/keeper/grpc_query.go index 76b79301a2..c6fc35c55c 100644 --- a/x/evm/keeper/grpc_query.go +++ b/x/evm/keeper/grpc_query.go @@ -399,6 +399,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) < 1 { + txConfig.TxIndex = 0 + } + result, _, err := k.traceTx(ctx, cfg, txConfig, signer, tx, req.TraceConfig, false) if err != nil { // error will be returned with detail status from traceTx From 8d498540096dec12cb8a2f581154d2270fd75943 Mon Sep 17 00:00:00 2001 From: VictorTrustyDev Date: Mon, 18 Jul 2022 16:20:43 +0700 Subject: [PATCH 2/3] apply suggestion and add change-log --- CHANGELOG.md | 4 ++++ x/evm/keeper/grpc_query.go | 7 +++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72ce2c60f5..92178f27bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (feemarket) [\#1165](https://github.com/evmos/ethermint/pull/1165) Add hint in specs about different gas terminology for gas in Cosmos and Ethereum. * (rpc) [\#1169](https://github.com/evmos/ethermint/pull/1169) Remove unnecessary queries from `getBlockNumber` function +### Bug Fixes + +* (evm) [\#1187](https://github.com/evmos/ethermint/pull/1187) Fix `TxIndex` value (expected 0, actual 1) when call `debug_traceTransaction` + ## [v0.17.0] - 2022-06-27 ### State Machine Breaking diff --git a/x/evm/keeper/grpc_query.go b/x/evm/keeper/grpc_query.go index c6fc35c55c..f05b16f119 100644 --- a/x/evm/keeper/grpc_query.go +++ b/x/evm/keeper/grpc_query.go @@ -398,11 +398,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) < 1 { - txConfig.TxIndex = 0 + 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 From 567766029a67f5c47567f2576e53ce405093df89 Mon Sep 17 00:00:00 2001 From: VictorTrustyDev Date: Mon, 18 Jul 2022 16:22:57 +0700 Subject: [PATCH 3/3] fix comment --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92178f27bf..fca4b2e264 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,7 +50,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 call `debug_traceTransaction` +* (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 ## [v0.17.0] - 2022-06-27