diff --git a/core/state/statedb.go b/core/state/statedb.go index 6fdf341c61..bbaa7791ea 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -635,6 +635,9 @@ func (s *StateDB) getOrNewStateObject(addr common.Address) *stateObject { func (s *StateDB) createObject(addr common.Address) (newobj, prev *stateObject) { prev = s.getDeletedStateObject(addr) // Note, prev might have been deleted, we need that! newobj = newObject(s, addr, nil) + if s.logger != nil && s.logger.OnNewAccount != nil { + s.logger.OnNewAccount(addr, prev != nil) + } if prev == nil { s.journal.append(createObjectChange{account: &addr}) } else { diff --git a/core/tracing/hooks.go b/core/tracing/hooks.go index 48cb4d2027..ad738a3fed 100644 --- a/core/tracing/hooks.go +++ b/core/tracing/hooks.go @@ -163,6 +163,13 @@ type Hooks struct { OnCodeChange CodeChangeHook OnStorageChange StorageChangeHook OnLog LogHook + + // Firehose backward compatibility + // This hook exist because some current Firehose supported chains requires it + // 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) } // BalanceChangeReason is used to indicate the reason for a balance change, useful diff --git a/eth/tracers/firehose.go b/eth/tracers/firehose.go index 97a5340ad1..dbb96f51e6 100644 --- a/eth/tracers/firehose.go +++ b/eth/tracers/firehose.go @@ -80,6 +80,7 @@ func newFirehoseTracer(cfg json.RawMessage) (*tracing.Hooks, error) { OnStorageChange: tracer.OnStorageChange, OnGasChange: tracer.OnGasChange, OnLog: tracer.OnLog, + OnNewAccount: tracer.OnNewAccount, }, nil }