diff --git a/core/state/statedb_hooked.go b/core/state/statedb_hooked.go index 2314a02989..b647a50fbb 100644 --- a/core/state/statedb_hooked.go +++ b/core/state/statedb_hooked.go @@ -87,8 +87,10 @@ func (s *hookedStateDB) GetCode(addr common.Address) []byte { func (s *hookedStateDB) GetCodeSize(addr common.Address) int { size := s.inner.GetCodeSize(addr) - if s.hooks.OnCodeSizeRead != nil { - s.hooks.OnCodeSizeRead(addr, size) + 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 } diff --git a/core/state/statedb_hooked_test.go b/core/state/statedb_hooked_test.go index 3651cc3d0a..864434a25f 100644 --- a/core/state/statedb_hooked_test.go +++ b/core/state/statedb_hooked_test.go @@ -94,7 +94,7 @@ func TestHooks(t *testing.T) { "0xaa00000000000000000000000000000000000000.nonce read: 1337", "0xaa00000000000000000000000000000000000000.code read: [19 37]", "0xaa00000000000000000000000000000000000000.storage read 0x0000000000000000000000000000000000000000000000000000000000000001: 0x0000000000000000000000000000000000000000000000000000000000000022", - "0xaa00000000000000000000000000000000000000.code size read: 2", + "0xaa00000000000000000000000000000000000000.code read: [19 37]", "0xaa00000000000000000000000000000000000000.code hash read: 0xa12ae05590de0c93a00bc7ac773c2fdb621e44f814985e72194f921c0050f728", } emitF := func(format string, a ...any) { @@ -128,9 +128,6 @@ func TestHooks(t *testing.T) { OnStorageRead: func(addr common.Address, slot common.Hash, value common.Hash) { emitF("%v.storage read %v: %v", addr, slot, value) }, - OnCodeSizeRead: func(addr common.Address, size int) { - emitF("%v.code size read: %v", addr, size) - }, OnCodeHashRead: func(addr common.Address, hash common.Hash) { emitF("%v.code hash read: %v", addr, hash) }, diff --git a/core/tracing/hooks.go b/core/tracing/hooks.go index d8816921e3..d31763665a 100644 --- a/core/tracing/hooks.go +++ b/core/tracing/hooks.go @@ -186,9 +186,6 @@ type ( // CodeReadHook is called when EVM reads the code of an account. CodeReadHook = func(addr common.Address, code []byte) - // CodeSizeReadHook is called when EVM reads the code size of an account. - CodeSizeReadHook = func(addr common.Address, size int) - // CodeHashReadHook is called when EVM reads the code hash of an account. CodeHashReadHook = func(addr common.Address, hash common.Hash) @@ -228,7 +225,6 @@ type Hooks struct { OnBalanceRead BalanceReadHook OnNonceRead NonceReadHook OnCodeRead CodeReadHook - OnCodeSizeRead CodeSizeReadHook OnCodeHashRead CodeHashReadHook OnStorageRead StorageReadHook // Block hash read diff --git a/eth/tracers/live/noop.go b/eth/tracers/live/noop.go index a430b86296..97dbbbbecb 100644 --- a/eth/tracers/live/noop.go +++ b/eth/tracers/live/noop.go @@ -60,7 +60,6 @@ func newNoopTracer(_ json.RawMessage) (*tracing.Hooks, error) { OnBalanceRead: t.OnBalanceRead, OnNonceRead: t.OnNonceRead, OnCodeRead: t.OnCodeRead, - OnCodeSizeRead: t.OnCodeSizeRead, OnCodeHashRead: t.OnCodeHashRead, OnStorageRead: t.OnStorageRead, OnBlockHashRead: t.OnBlockHashRead, @@ -121,8 +120,6 @@ func (t *noop) OnNonceRead(addr common.Address, nonce uint64) {} func (t *noop) OnCodeRead(addr common.Address, code []byte) {} -func (t *noop) OnCodeSizeRead(addr common.Address, size int) {} - func (t *noop) OnCodeHashRead(addr common.Address, hash common.Hash) {} func (t *noop) OnStorageRead(addr common.Address, slot, val common.Hash) {}