From 69a64b2b78e4cbea4357da22c59ab5adade61276 Mon Sep 17 00:00:00 2001 From: Matthieu Vachon Date: Thu, 20 Feb 2025 10:19:05 -0500 Subject: [PATCH] Removed prev in `OnNewAccount` as it was unsued --- core/state/statedb.go | 7 +------ core/tracing/hooks.go | 2 +- core/vm/evm.go | 2 +- eth/tracers/firehose.go | 9 ++------- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/core/state/statedb.go b/core/state/statedb.go index 62ab94af85..027b83dae3 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -623,14 +623,9 @@ func (s *StateDB) getOrNewStateObject(addr common.Address) *stateObject { // createObject creates a new state object. The assumption is held there is no // existing account with the given address, otherwise it will be silently overwritten. func (s *StateDB) createObject(addr common.Address) *stateObject { - var prev *stateObject - if s.hooks != nil && s.hooks.OnNewAccount != nil { - prev = s.getStateObject(addr) - } - obj := newObject(s, addr, nil) if s.hooks != nil && s.hooks.OnNewAccount != nil { - s.hooks.OnNewAccount(addr, prev != nil) + s.hooks.OnNewAccount(addr) } s.journal.createObject(addr) diff --git a/core/tracing/hooks.go b/core/tracing/hooks.go index 6a1e4b4c00..ef163ea89d 100644 --- a/core/tracing/hooks.go +++ b/core/tracing/hooks.go @@ -221,7 +221,7 @@ type Hooks struct { // but this field is going to be deprecated and newer chains will not produced // those events anymore. The hook is registered conditionally based on the // tracer configuration. - OnNewAccount func(address common.Address, previousExisted bool) + OnNewAccount func(address common.Address) } // BalanceChangeReason is used to indicate the reason for a balance change, useful diff --git a/core/vm/evm.go b/core/vm/evm.go index 9f82ab41a7..664dd17b75 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -491,7 +491,7 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64, // To keep the same tracing behavior as before, we call the `OnNewAccount` // manually here if the account was previously existing. if evm.Config.Tracer != nil && evm.Config.Tracer.OnNewAccount != nil { - evm.Config.Tracer.OnNewAccount(address, true) + evm.Config.Tracer.OnNewAccount(address) } } diff --git a/eth/tracers/firehose.go b/eth/tracers/firehose.go index 573c99c727..b5ef9fa5f7 100644 --- a/eth/tracers/firehose.go +++ b/eth/tracers/firehose.go @@ -1240,7 +1240,7 @@ func (f *Firehose) OnGenesisBlock(b *types.Block, alloc types.GenesisAlloc) { account := alloc[addr] if *f.applyBackwardCompatibility { - f.OnNewAccount(addr, false) + f.OnNewAccount(addr) } if account.Balance != nil && account.Balance.Sign() != 0 { @@ -1444,18 +1444,13 @@ func (f *Firehose) OnLog(l *types.Log) { f.transactionLogIndex++ } -func (f *Firehose) OnNewAccount(a common.Address, previousDataExists bool) { +func (f *Firehose) OnNewAccount(a common.Address) { // Newer Firehose instrumentation does not track OnNewAccount anymore since it's bogus // and was removed from the Geth live tracer. if !*f.applyBackwardCompatibility { return } - // Known Firehose issue: The current Firehose instrumentation emits multiple - // time the same `OnNewAccount` event for the same account when such account - // exists in the past. For now, do nothing and keep the legacy behavior. - _ = previousDataExists - f.ensureInBlockOrTrx() if f.transaction == nil { // We receive OnNewAccount on finalization of the block which means there is no