Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions core/vm/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,6 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
// as every returning call will return new data anyway.
in.returnData = nil

// Don't bother with the execution if there's no code.
if len(contract.Code) == 0 {
return nil, nil
}

var (
op OpCode // current opcode
mem = NewMemory() // bound memory
Expand All @@ -182,6 +177,20 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
logged bool // deferred Tracer should ignore already logged steps
res []byte // result of the opcode execution function
)

// Don't bother with the execution if there's no code.
if len(contract.Code) == 0 {
if in.cfg.Debug {
// Even if there's nothing to execute, we need to invoke CaptureState here because the
// tracer assumes StateDB is populated when GetResult is invoked.
//
// If a transaction only contains an contract deployment with no code and we don't set CaptureState here, the
// tracer will panic if any db-related methods are invoked.
in.cfg.Tracer.CaptureState(in.evm, pcCopy, op, gasCopy, cost, mem, stack, returns, in.returnData, contract, in.evm.depth, nil)
}
return nil, nil
}

// Don't move this deferrred function, it's placed before the capturestate-deferred method,
// so that it get's executed _after_: the capturestate needs the stacks before
// they are returned to the pools
Expand Down