core/tracing, core/vm: add ContractCode to the OpContext (#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.
This commit is contained in:
Karol Chojnowski 2024-09-24 13:18:36 +02:00 committed by GitHub
parent f2e13c7e33
commit 55ed8fef0b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View File

@ -34,6 +34,7 @@ type OpContext interface {
Address() common.Address Address() common.Address
CallValue() *uint256.Int CallValue() *uint256.Int
CallInput() []byte CallInput() []byte
ContractCode() []byte
} }
// StateDB gives tracers access to the whole state. // StateDB gives tracers access to the whole state.

View File

@ -84,6 +84,11 @@ func (ctx *ScopeContext) CallInput() []byte {
return ctx.Contract.Input 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 // EVMInterpreter represents an EVM interpreter
type EVMInterpreter struct { type EVMInterpreter struct {
evm *EVM evm *EVM