From 394fe783c6bd372e541319c98d261ba30c0494d9 Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Wed, 6 May 2026 13:22:50 +0800 Subject: [PATCH] ore/state, eth/tracers: fix block access index in trace tx --- core/state/journal.go | 25 +++++++++++-------------- eth/tracers/api.go | 2 +- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/core/state/journal.go b/core/state/journal.go index 27da97702c..5b415e7aa3 100644 --- a/core/state/journal.go +++ b/core/state/journal.go @@ -75,12 +75,16 @@ func (s *journalMutationState) add(kind journalMutationKind) { s.counts.add(kind) } -// remove drops one occurrence of the given mutation kind. It returns two -// booleans: kindEmpty is true when no entries of that kind remain for the -// account, and stateEmpty is true when no entries of any kind remain. -func (s *journalMutationState) remove(kind journalMutationKind) (kindEmpty bool, stateEmpty bool) { - kindEmpty = s.counts.remove(kind) - return kindEmpty, s.counts == (journalMutationCounts{}) +// remove drops one occurrence of the given mutation kind. It returns a flag +// indicating whether no entries of any kind remain. +func (s *journalMutationState) remove(kind journalMutationKind) bool { + if s.counts.remove(kind) { + // No entries of this kind remain for this account; drop the + // corresponding stashed original so the state mirrors the + // live mutation set. + s.clearKind(kind) + } + return s.counts == (journalMutationCounts{}) } // clearKind drops the stashed original for the given mutation kind. It is @@ -295,14 +299,7 @@ func (j *journal) revert(statedb *StateDB, snapshot int) { if state == nil { panic(fmt.Errorf("journal mutation tracking missing for %x", addr[:])) } - kindEmpty, stateEmpty := state.remove(kind) - if kindEmpty { - // No entries of this kind remain for this account; drop the - // corresponding stashed original so the state mirrors the - // live mutation set. - state.clearKind(kind) - } - if stateEmpty { + if state.remove(kind) { delete(j.mutations, addr) } } diff --git a/eth/tracers/api.go b/eth/tracers/api.go index 57f9ebc0d7..0df02388b3 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -1016,7 +1016,7 @@ func (api *API) traceTx(ctx context.Context, tx *types.Transaction, message *cor defer cancel() // Call Prepare to clear out the statedb access list - statedb.SetTxContext(txctx.TxHash, txctx.TxIndex, uint32(txctx.TxIndex)) + statedb.SetTxContext(txctx.TxHash, txctx.TxIndex, uint32(txctx.TxIndex+1)) _, err = core.ApplyTransactionWithEVM(message, core.NewGasPool(message.GasLimit), statedb, vmctx.BlockNumber, txctx.BlockHash, vmctx.Time, tx, evm) if err != nil {