mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
Fixed missing OnNewAccount hook
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.
This commit is contained in:
parent
2cfff4e562
commit
421cc2a76d
1 changed files with 15 additions and 0 deletions
|
|
@ -474,7 +474,22 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
|
||||||
snapshot := evm.StateDB.Snapshot()
|
snapshot := evm.StateDB.Snapshot()
|
||||||
if !evm.StateDB.Exist(address) {
|
if !evm.StateDB.Exist(address) {
|
||||||
evm.StateDB.CreateAccount(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
|
// CreateContract means that regardless of whether the account previously existed
|
||||||
// in the state trie or not, it _now_ becomes created as a _contract_ account.
|
// 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
|
// This is performed _prior_ to executing the initcode, since the initcode
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue