rm OnCodeSizeRead

This commit is contained in:
Sina Mahmoodi 2024-12-03 16:28:44 +01:00
parent 1dda30d353
commit 4acea3bc8a
4 changed files with 5 additions and 13 deletions

View file

@ -87,8 +87,10 @@ func (s *hookedStateDB) GetCode(addr common.Address) []byte {
func (s *hookedStateDB) GetCodeSize(addr common.Address) int { func (s *hookedStateDB) GetCodeSize(addr common.Address) int {
size := s.inner.GetCodeSize(addr) size := s.inner.GetCodeSize(addr)
if s.hooks.OnCodeSizeRead != nil { if s.hooks.OnCodeRead != nil {
s.hooks.OnCodeSizeRead(addr, size) // 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 size
} }

View file

@ -94,7 +94,7 @@ func TestHooks(t *testing.T) {
"0xaa00000000000000000000000000000000000000.nonce read: 1337", "0xaa00000000000000000000000000000000000000.nonce read: 1337",
"0xaa00000000000000000000000000000000000000.code read: [19 37]", "0xaa00000000000000000000000000000000000000.code read: [19 37]",
"0xaa00000000000000000000000000000000000000.storage read 0x0000000000000000000000000000000000000000000000000000000000000001: 0x0000000000000000000000000000000000000000000000000000000000000022", "0xaa00000000000000000000000000000000000000.storage read 0x0000000000000000000000000000000000000000000000000000000000000001: 0x0000000000000000000000000000000000000000000000000000000000000022",
"0xaa00000000000000000000000000000000000000.code size read: 2", "0xaa00000000000000000000000000000000000000.code read: [19 37]",
"0xaa00000000000000000000000000000000000000.code hash read: 0xa12ae05590de0c93a00bc7ac773c2fdb621e44f814985e72194f921c0050f728", "0xaa00000000000000000000000000000000000000.code hash read: 0xa12ae05590de0c93a00bc7ac773c2fdb621e44f814985e72194f921c0050f728",
} }
emitF := func(format string, a ...any) { 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) { OnStorageRead: func(addr common.Address, slot common.Hash, value common.Hash) {
emitF("%v.storage read %v: %v", addr, slot, value) 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) { OnCodeHashRead: func(addr common.Address, hash common.Hash) {
emitF("%v.code hash read: %v", addr, hash) emitF("%v.code hash read: %v", addr, hash)
}, },

View file

@ -186,9 +186,6 @@ type (
// CodeReadHook is called when EVM reads the code of an account. // CodeReadHook is called when EVM reads the code of an account.
CodeReadHook = func(addr common.Address, code []byte) 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 is called when EVM reads the code hash of an account.
CodeHashReadHook = func(addr common.Address, hash common.Hash) CodeHashReadHook = func(addr common.Address, hash common.Hash)
@ -228,7 +225,6 @@ type Hooks struct {
OnBalanceRead BalanceReadHook OnBalanceRead BalanceReadHook
OnNonceRead NonceReadHook OnNonceRead NonceReadHook
OnCodeRead CodeReadHook OnCodeRead CodeReadHook
OnCodeSizeRead CodeSizeReadHook
OnCodeHashRead CodeHashReadHook OnCodeHashRead CodeHashReadHook
OnStorageRead StorageReadHook OnStorageRead StorageReadHook
// Block hash read // Block hash read

View file

@ -60,7 +60,6 @@ func newNoopTracer(_ json.RawMessage) (*tracing.Hooks, error) {
OnBalanceRead: t.OnBalanceRead, OnBalanceRead: t.OnBalanceRead,
OnNonceRead: t.OnNonceRead, OnNonceRead: t.OnNonceRead,
OnCodeRead: t.OnCodeRead, OnCodeRead: t.OnCodeRead,
OnCodeSizeRead: t.OnCodeSizeRead,
OnCodeHashRead: t.OnCodeHashRead, OnCodeHashRead: t.OnCodeHashRead,
OnStorageRead: t.OnStorageRead, OnStorageRead: t.OnStorageRead,
OnBlockHashRead: t.OnBlockHashRead, 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) 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) OnCodeHashRead(addr common.Address, hash common.Hash) {}
func (t *noop) OnStorageRead(addr common.Address, slot, val common.Hash) {} func (t *noop) OnStorageRead(addr common.Address, slot, val common.Hash) {}