From 85df9c27325d0b2f3baffec3e7bfb9f0dc3af70c Mon Sep 17 00:00:00 2001 From: kchojn Date: Thu, 19 Sep 2024 11:27:26 +0200 Subject: [PATCH] feat(tracing/hooks.go): add ContractCode method to OpContext interface to provide access to contract code feat(vm/interpreter.go): add ContractCode method to ScopeContext to return the code of the contract being executed --- core/tracing/hooks.go | 1 + core/vm/interpreter.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/core/tracing/hooks.go b/core/tracing/hooks.go index 987dfa7a1e..882eb52837 100644 --- a/core/tracing/hooks.go +++ b/core/tracing/hooks.go @@ -34,6 +34,7 @@ type OpContext interface { Address() common.Address CallValue() *uint256.Int CallInput() []byte + ContractCode() []byte } // StateDB gives tracers access to the whole state. diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 6e7d28a0ce..4f4028b725 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -83,6 +83,11 @@ func (ctx *ScopeContext) CallInput() []byte { return ctx.Contract.Input } +// ContractCode returns the code of the contract being executed. +func (ctx *ScopeContext) ContractCode() []byte { + return ctx.Contract.Code +} + // EVMInterpreter represents an EVM interpreter type EVMInterpreter struct { evm *EVM