Merge branch 'extended-tracer-backport-1.13.5' into extended-tracer-sei-v1.13.5

This commit is contained in:
Matthieu Vachon 2024-02-08 16:05:19 -05:00
commit c5ebc52461
5 changed files with 8 additions and 22 deletions

View file

@ -193,7 +193,11 @@ type BlockchainLogger interface {
OnBlockchainInit(chainConfig *params.ChainConfig)
// OnBlockStart is called before executing `block`.
// `td` is the total difficulty prior to `block`.
OnBlockStart(block *types.Block, td *big.Int, finalized *types.Header, safe *types.Header)
// `skip` indicates processing of this previously known block
// will be skipped. OnBlockStart and OnBlockEnd will be emitted to
// convey how chain is progressing. E.g. known blocks will be skipped
// when node is started after a crash.
OnBlockStart(block *types.Block, td *big.Int, finalized *types.Header, safe *types.Header, skip bool)
OnBlockEnd(err error)
OnGenesisBlock(genesis *types.Block, alloc GenesisAlloc)
OnBeaconBlockRootStart(root common.Hash)
@ -1808,7 +1812,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
}
stats.processed++
if bc.logger != nil {
bc.logger.OnBlockStart(block, bc.GetTd(block.ParentHash(), block.NumberU64()-1), bc.CurrentFinalBlock(), bc.CurrentSafeBlock())
bc.logger.OnBlockStart(block, bc.GetTd(block.ParentHash(), block.NumberU64()-1), bc.CurrentFinalBlock(), bc.CurrentSafeBlock(), true)
bc.logger.OnBlockEnd(nil)
}
@ -1937,7 +1941,7 @@ type blockProcessingResult struct {
func (bc *BlockChain) processBlock(block *types.Block, statedb *state.StateDB, start time.Time, setHead bool) (_ *blockProcessingResult, blockEndErr error) {
if bc.logger != nil {
td := bc.GetTd(block.ParentHash(), block.NumberU64()-1)
bc.logger.OnBlockStart(block, td, bc.CurrentFinalBlock(), bc.CurrentSafeBlock())
bc.logger.OnBlockStart(block, td, bc.CurrentFinalBlock(), bc.CurrentSafeBlock(), false)
defer func() {
bc.logger.OnBlockEnd(blockEndErr)
}()

View file

@ -59,10 +59,6 @@ type StateLogger interface {
OnCodeChange(addr common.Address, prevCodeHash common.Hash, prevCode []byte, codeHash common.Hash, code []byte)
OnStorageChange(addr common.Address, slot common.Hash, prev, new common.Hash)
OnLog(log *types.Log)
// OnNewAccount is called when a new account is created.
// Reset indicates an account existed at that address
// which will be replaced.
OnNewAccount(addr common.Address, reset bool)
}
// StateDB structs within the ethereum protocol are used to store anything
@ -662,9 +658,6 @@ 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(addr, prev != nil)
}
if prev == nil {
s.journal.append(createObjectChange{account: &addr})
} else {

View file

@ -86,8 +86,6 @@ func (*NoopTracer) OnStorageChange(a common.Address, k, prev, new common.Hash) {
func (*NoopTracer) OnLog(log *types.Log) {}
func (*NoopTracer) OnNewAccount(a common.Address, reset bool) {}
// GetResult returns an empty json object.
func (t *NoopTracer) GetResult() (json.RawMessage, error) {
return json.RawMessage(`{}`), nil

View file

@ -63,7 +63,7 @@ func (t *noop) CaptureTxStart(env *vm.EVM, tx *types.Transaction, from common.Ad
func (t *noop) CaptureTxEnd(receipt *types.Receipt, err error) {
}
func (t *noop) OnBlockStart(b *types.Block, td *big.Int, finalized, safe *types.Header) {
func (t *noop) OnBlockStart(b *types.Block, td *big.Int, finalized, safe *types.Header, skip bool) {
}
func (t *noop) OnBlockEnd(err error) {
@ -91,8 +91,5 @@ func (t *noop) OnLog(l *types.Log) {
}
func (t *noop) OnNewAccount(a common.Address, reset bool) {
}
func (t *noop) OnGasChange(old, new uint64, reason vm.GasChangeReason) {
}

View file

@ -159,12 +159,6 @@ func (t *muxTracer) OnLog(log *types.Log) {
}
}
func (t *muxTracer) OnNewAccount(a common.Address, reset bool) {
for _, t := range t.tracers {
t.OnNewAccount(a, reset)
}
}
// GetResult returns an empty json object.
func (t *muxTracer) GetResult() (json.RawMessage, error) {
resObject := make(map[string]json.RawMessage)