ore/state, eth/tracers: fix block access index in trace tx

This commit is contained in:
Gary Rong 2026-05-06 13:22:50 +08:00 committed by Jared Wasinger
parent 4ce3458586
commit 394fe783c6
2 changed files with 12 additions and 15 deletions

View file

@ -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)
}
}

View file

@ -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 {