From a7de17ed2141eda8560449f5475a51993a08cc36 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Mon, 26 Jun 2023 17:39:10 +0200 Subject: [PATCH] only emit event for new accounts --- core/blockchain.go | 2 ++ core/state/statedb.go | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index f7af512435..a5f122883b 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -153,6 +153,8 @@ var defaultCacheConfig = &CacheConfig{ SnapshotWait: true, } +// BlockchainLogger is used to collect traces during chain processing. +// Please make a copy of the referenced types if you intend to retain them. type BlockchainLogger interface { vm.EVMLogger state.StateLogger diff --git a/core/state/statedb.go b/core/state/statedb.go index dd80ff5975..67b6da5972 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -648,6 +648,10 @@ func (s *StateDB) createObject(addr common.Address) (newobj, prev *stateObject) newobj = newObject(s, addr, types.StateAccount{}) if prev == nil { s.journal.append(createObjectChange{account: &addr}) + // TODO: add isPrecompile check + if s.logger != nil { + s.logger.OnNewAccount(addr) + } } else { // The original account should be marked as destructed and all cached // account and storage data should be cleared as well. Note, it must @@ -678,11 +682,7 @@ func (s *StateDB) createObject(addr common.Address) (newobj, prev *stateObject) prevStorage: storage, }) } - // TODO: add isPrecompile check - // TODO: should we emit on account reset? - if s.logger != nil { - s.logger.OnNewAccount(addr) - } + s.setStateObject(newobj) if prev != nil && !prev.deleted { return newobj, prev