From f744e86dd778e5bf8c42073c7228b72b7f769c47 Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Sat, 7 Feb 2026 02:45:38 +0800 Subject: [PATCH] feat(core): add ContractCode to the OpContext #30466 (#2030) --- 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 12a436dff1..de5d06a8fd 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 a566537d0e..c4041b31b8 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -80,6 +80,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 +} + // Run loops and evaluates the contract's code with the given input data and returns // the return byte-slice and an error if one occurred. //