diff --git a/core/vm/evm.go b/core/vm/evm.go index 0593a32a3e..af39638da2 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -474,7 +474,22 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64, snapshot := evm.StateDB.Snapshot() if !evm.StateDB.Exist(address) { evm.StateDB.CreateAccount(address) + } else { + // Firehose: In previous versions of the EVM, there was no `evm.StateDB.Exist` + // above and the `CreateAccount` was always called. This was leading to + // always get a `OnNewAccount` event in the tracer as we were not checking + // previous existence of the account. + // + // With the introduction of the `Exist` method, there is now cases where + // `CreateAccount` is not called if it was previously existing. + // + // 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) + } } + // CreateContract means that regardless of whether the account previously existed // in the state trie or not, it _now_ becomes created as a _contract_ account. // This is performed _prior_ to executing the initcode, since the initcode