-
Notifications
You must be signed in to change notification settings - Fork 21.9k
[WIP] cmd/evm: prestate config and json trace fixes #14900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -112,17 +112,21 @@ func (in *Interpreter) Run(snapshot int, contract *Contract, input []byte) (ret | |||
| op OpCode // current opcode | ||||
| mem = NewMemory() // bound memory | ||||
| stack = newstack() // local stack | ||||
| stackCopy = newstack() | ||||
| logged = bool(false) | ||||
| // For optimisation reason we're using uint64 as the program counter. | ||||
| // It's theoretically possible to go above 2^64. The YP defines the PC | ||||
| // to be uint256. Practically much less so feasible. | ||||
| pc = uint64(0) // program counter | ||||
| pcCopy = uint64(0) | ||||
| gasCopy = uint64(0) | ||||
| cost uint64 | ||||
| ) | ||||
| contract.Input = input | ||||
|
|
||||
| defer func() { | ||||
| if err != nil && in.cfg.Debug { | ||||
| in.cfg.Tracer.CaptureState(in.evm, pc, op, contract.Gas, cost, mem, stack, contract, in.evm.depth, err) | ||||
| if err != nil && !logged && in.cfg.Debug { | ||||
| in.cfg.Tracer.CaptureState(in.evm, pcCopy, op, gasCopy, cost, mem, stackCopy, contract, in.evm.depth, err) | ||||
| } | ||||
| }() | ||||
|
|
||||
|
|
@@ -133,13 +137,23 @@ func (in *Interpreter) Run(snapshot int, contract *Contract, input []byte) (ret | |||
| for atomic.LoadInt32(&in.evm.abort) == 0 { | ||||
| // Get the memory location of pc | ||||
| op = contract.GetOp(pc) | ||||
| logged = false | ||||
|
|
||||
| // get the operation from the jump table matching the opcode | ||||
| operation := in.cfg.JumpTable[op] | ||||
| if err := in.enforceRestrictions(op, operation, stack); err != nil { | ||||
| return nil, err | ||||
| } | ||||
|
|
||||
| if in.cfg.Debug { | ||||
| pcCopy = uint64(pc) | ||||
| gasCopy = uint64(contract.Gas) | ||||
| stackCopy = newstack() | ||||
| for _, val := range stack.data { | ||||
| stackCopy.push(val) | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the intent here? The
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know how the memory management works, but I tested it again to check. Changing it to: reproduces the bug where the mutated stack is logged (from stBoundsTest/CALL_BoundsOOG.json): The Using
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, so apparently the 63/64-th handling does not operate on the actual
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Happens here: go-ethereum/core/vm/gas_table.go Line 329 in dfd0762
|
||||
| } | ||||
| } | ||||
|
|
||||
| // if the op is invalid abort the process and return an error | ||||
| if !operation.valid { | ||||
| return nil, fmt.Errorf("invalid opcode 0x%x", int(op)) | ||||
|
|
@@ -179,7 +193,9 @@ func (in *Interpreter) Run(snapshot int, contract *Contract, input []byte) (ret | |||
| } | ||||
|
|
||||
| if in.cfg.Debug { | ||||
| in.cfg.Tracer.CaptureState(in.evm, pc, op, contract.Gas, cost, mem, stack, contract, in.evm.depth, err) | ||||
| // trace needs to be called before operation.execute for CALLs etc | ||||
| in.cfg.Tracer.CaptureState(in.evm, pcCopy, op, gasCopy, cost, mem, stackCopy, contract, in.evm.depth, err) | ||||
| logged = true | ||||
| } | ||||
|
|
||||
| // execute the operation | ||||
|
|
||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does
stackCopyreally need to exist in this scope? Can't it just be created on the fly when needed?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried removing this line and changing L151 to
stackCopy := newstack(), but I get:core/vm/interpreter.go:129: undefined: stackCopy
core/vm/interpreter.go:197: undefined: stackCopy