diff --git a/core/state/statedb_hooked.go b/core/state/statedb_hooked.go index b647a50fbb..20f2bdc15f 100644 --- a/core/state/statedb_hooked.go +++ b/core/state/statedb_hooked.go @@ -54,45 +54,24 @@ func (s *hookedStateDB) CreateContract(addr common.Address) { } func (s *hookedStateDB) GetBalance(addr common.Address) *uint256.Int { - bal := s.inner.GetBalance(addr) - if s.hooks.OnBalanceRead != nil { - s.hooks.OnBalanceRead(addr, bal.ToBig()) - } - return bal + return s.inner.GetBalance(addr) } func (s *hookedStateDB) GetNonce(addr common.Address) uint64 { - nonce := s.inner.GetNonce(addr) - if s.hooks.OnNonceRead != nil { - s.hooks.OnNonceRead(addr, nonce) - } - return nonce + return s.inner.GetNonce(addr) } func (s *hookedStateDB) GetCodeHash(addr common.Address) common.Hash { - codeHash := s.inner.GetCodeHash(addr) - if s.hooks.OnCodeHashRead != nil { - s.hooks.OnCodeHashRead(addr, codeHash) - } - return codeHash + return s.inner.GetCodeHash(addr) + } func (s *hookedStateDB) GetCode(addr common.Address) []byte { - code := s.inner.GetCode(addr) - if s.hooks.OnCodeRead != nil { - s.hooks.OnCodeRead(addr, code) - } - return code + return s.inner.GetCode(addr) } func (s *hookedStateDB) GetCodeSize(addr common.Address) int { - size := s.inner.GetCodeSize(addr) - if s.hooks.OnCodeRead != nil { - // GetCodeSize caches the code within the reader so this call is free. - code := s.inner.GetCode(addr) - s.hooks.OnCodeRead(addr, code) - } - return size + return s.inner.GetCodeSize(addr) } func (s *hookedStateDB) AddRefund(u uint64) { @@ -112,11 +91,7 @@ func (s *hookedStateDB) GetCommittedState(addr common.Address, hash common.Hash) } func (s *hookedStateDB) GetState(addr common.Address, hash common.Hash) common.Hash { - val := s.inner.GetState(addr, hash) - if s.hooks.OnStorageRead != nil { - s.hooks.OnStorageRead(addr, hash, val) - } - return val + return s.inner.GetState(addr, hash) } func (s *hookedStateDB) GetStorageRoot(addr common.Address) common.Hash { diff --git a/core/state/statedb_hooked_test.go b/core/state/statedb_hooked_test.go index 864434a25f..5f82ed06d0 100644 --- a/core/state/statedb_hooked_test.go +++ b/core/state/statedb_hooked_test.go @@ -90,12 +90,6 @@ func TestHooks(t *testing.T) { "0xaa00000000000000000000000000000000000000.storage slot 0x0000000000000000000000000000000000000000000000000000000000000001: 0x0000000000000000000000000000000000000000000000000000000000000000 ->0x0000000000000000000000000000000000000000000000000000000000000011", "0xaa00000000000000000000000000000000000000.storage slot 0x0000000000000000000000000000000000000000000000000000000000000001: 0x0000000000000000000000000000000000000000000000000000000000000011 ->0x0000000000000000000000000000000000000000000000000000000000000022", "log 100", - "0xaa00000000000000000000000000000000000000.balance read: 50", - "0xaa00000000000000000000000000000000000000.nonce read: 1337", - "0xaa00000000000000000000000000000000000000.code read: [19 37]", - "0xaa00000000000000000000000000000000000000.storage read 0x0000000000000000000000000000000000000000000000000000000000000001: 0x0000000000000000000000000000000000000000000000000000000000000022", - "0xaa00000000000000000000000000000000000000.code read: [19 37]", - "0xaa00000000000000000000000000000000000000.code hash read: 0xa12ae05590de0c93a00bc7ac773c2fdb621e44f814985e72194f921c0050f728", } emitF := func(format string, a ...any) { result = append(result, fmt.Sprintf(format, a...)) @@ -116,21 +110,6 @@ func TestHooks(t *testing.T) { OnLog: func(log *types.Log) { emitF("log %v", log.TxIndex) }, - OnBalanceRead: func(addr common.Address, bal *big.Int) { - emitF("%v.balance read: %v", addr, bal) - }, - OnNonceRead: func(addr common.Address, nonce uint64) { - emitF("%v.nonce read: %v", addr, nonce) - }, - OnCodeRead: func(addr common.Address, code []byte) { - emitF("%v.code read: %v", addr, code) - }, - OnStorageRead: func(addr common.Address, slot common.Hash, value common.Hash) { - emitF("%v.storage read %v: %v", addr, slot, value) - }, - OnCodeHashRead: func(addr common.Address, hash common.Hash) { - emitF("%v.code hash read: %v", addr, hash) - }, }) sdb.AddBalance(common.Address{0xaa}, uint256.NewInt(100), tracing.BalanceChangeUnspecified) sdb.SubBalance(common.Address{0xaa}, uint256.NewInt(50), tracing.BalanceChangeTransfer) @@ -143,12 +122,6 @@ func TestHooks(t *testing.T) { sdb.AddLog(&types.Log{ Address: common.Address{0xbb}, }) - sdb.GetBalance(common.Address{0xaa}) - sdb.GetNonce(common.Address{0xaa}) - sdb.GetCode(common.Address{0xaa}) - sdb.GetState(common.Address{0xaa}, common.HexToHash("0x01")) - sdb.GetCodeSize(common.Address{0xaa}) - sdb.GetCodeHash(common.Address{0xaa}) for i, want := range wants { if have := result[i]; have != want { t.Fatalf("error event %d, have\n%v\nwant%v\n", i, have, want) diff --git a/core/tracing/hooks.go b/core/tracing/hooks.go index d5703ffdec..6b9b3e03e8 100644 --- a/core/tracing/hooks.go +++ b/core/tracing/hooks.go @@ -174,21 +174,6 @@ type ( // LogHook is called when a log is emitted. LogHook = func(log *types.Log) - // BalanceReadHook is called when EVM reads the balance of an account. - BalanceReadHook = func(addr common.Address, bal *big.Int) - - // NonceReadHook is called when EVM reads the nonce of an account. - NonceReadHook = func(addr common.Address, nonce uint64) - - // CodeReadHook is called when EVM reads the code of an account. - CodeReadHook = func(addr common.Address, code []byte) - - // CodeHashReadHook is called when EVM reads the code hash of an account. - CodeHashReadHook = func(addr common.Address, hash common.Hash) - - // StorageReadHook is called when EVM reads a storage slot of an account. - StorageReadHook = func(addr common.Address, slot, value common.Hash) - // BlockHashReadHook is called when EVM reads the blockhash of a block. BlockHashReadHook = func(blockNumber uint64, hash common.Hash) ) @@ -218,12 +203,6 @@ type Hooks struct { OnCodeChange CodeChangeHook OnStorageChange StorageChangeHook OnLog LogHook - // State reads - OnBalanceRead BalanceReadHook - OnNonceRead NonceReadHook - OnCodeRead CodeReadHook - OnCodeHashRead CodeHashReadHook - OnStorageRead StorageReadHook // Block hash read OnBlockHashRead BlockHashReadHook } diff --git a/eth/tracers/live/noop.go b/eth/tracers/live/noop.go index 97dbbbbecb..f3def85606 100644 --- a/eth/tracers/live/noop.go +++ b/eth/tracers/live/noop.go @@ -57,11 +57,6 @@ func newNoopTracer(_ json.RawMessage) (*tracing.Hooks, error) { OnCodeChange: t.OnCodeChange, OnStorageChange: t.OnStorageChange, OnLog: t.OnLog, - OnBalanceRead: t.OnBalanceRead, - OnNonceRead: t.OnNonceRead, - OnCodeRead: t.OnCodeRead, - OnCodeHashRead: t.OnCodeHashRead, - OnStorageRead: t.OnStorageRead, OnBlockHashRead: t.OnBlockHashRead, }, nil } @@ -114,16 +109,6 @@ func (t *noop) OnLog(l *types.Log) { } -func (t *noop) OnBalanceRead(addr common.Address, bal *big.Int) {} - -func (t *noop) OnNonceRead(addr common.Address, nonce uint64) {} - -func (t *noop) OnCodeRead(addr common.Address, code []byte) {} - -func (t *noop) OnCodeHashRead(addr common.Address, hash common.Hash) {} - -func (t *noop) OnStorageRead(addr common.Address, slot, val common.Hash) {} - func (t *noop) OnBlockHashRead(number uint64, hash common.Hash) {} func (t *noop) OnGasChange(old, new uint64, reason tracing.GasChangeReason) {