Skip to content

Commit 1d06f3f

Browse files
kchojnjakub-freebit
authored andcommitted
core/tracing, core/vm: add ContractCode to the OpContext (ethereum#30466)
Extends the opcontext interface to include accessor for code being executed in current context. While it is possible to get the code via `statedb.GetCode`, that approach doesn't work for initcode.
1 parent 2b17c85 commit 1d06f3f

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

core/tracing/hooks.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type OpContext interface {
3434
Address() common.Address
3535
CallValue() *uint256.Int
3636
CallInput() []byte
37+
ContractCode() []byte
3738
}
3839

3940
// StateDB gives tracers access to the whole state.

core/vm/interpreter.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ func (ctx *ScopeContext) CallInput() []byte {
8484
return ctx.Contract.Input
8585
}
8686

87+
// ContractCode returns the code of the contract being executed.
88+
func (ctx *ScopeContext) ContractCode() []byte {
89+
return ctx.Contract.Code
90+
}
91+
8792
// EVMInterpreter represents an EVM interpreter
8893
type EVMInterpreter struct {
8994
evm *EVM

0 commit comments

Comments
 (0)