Removed prev in OnNewAccount as it was unsued

This commit is contained in:
Matthieu Vachon 2025-02-20 10:19:05 -05:00
parent b20db144a2
commit 69a64b2b78
4 changed files with 5 additions and 15 deletions

View file

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

View file

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

View file

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

View file

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