Skip to content

core/vm: track 63/64 call gas off stack#15563

Merged
karalabe merged 4 commits into
ethereum:masterfrom
fjl:vm-call-gas-off-stack
Nov 28, 2017
Merged

core/vm: track 63/64 call gas off stack#15563
karalabe merged 4 commits into
ethereum:masterfrom
fjl:vm-call-gas-off-stack

Conversation

@fjl
Copy link
Copy Markdown
Contributor

@fjl fjl commented Nov 27, 2017

Gas calculations in gasCall* relayed the available gas for calls by
replacing it on the stack. This lead to inconsistent traces, which we papered
over by copying the pre-execution stack in trace mode.

This change relays available gas using a temporary variable, off the
stack, and allows removing the weird copy.

Gas calculations in gasCall* relayed the available gas for calls by
replacing it on the stack. This lead to inconsistent traces, which we
papered over by copying the pre-execution stack in trace mode.

This change relays available gas using a temporary variable, off the
stack, and allows removing the weird copy.
@fjl fjl force-pushed the vm-call-gas-off-stack branch from c85114e to c11a92a Compare November 27, 2017 15:31
Copy link
Copy Markdown
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two nitpicks, LGTM otherwise.

Comment thread core/vm/instructions.go Outdated
stack.pop()
gas := evm.callGasTemp
// Pop other call parameters.
to, inOffset, inSize, retOffset, retSize := stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps rename to to addr so it's consistent with all the other call* changes?

Comment thread core/vm/evm.go
// callGasTemp holds the gas available for the current call. This is needed because the
// available gas is calculated in gasCall* according to the 63/64 rule and later
// applied in opCall*.
callGasTemp uint64
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps callGasReal (as in the real value, not the requested amount?). Temp seems a bit strange.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose "temp" because the field holds the gas value temporarily, in-between calls to gasCall* and opCall*.

@karalabe karalabe added this to the 1.8.0 milestone Nov 28, 2017
@fjl
Copy link
Copy Markdown
Contributor Author

fjl commented Nov 28, 2017

@karalabe PTAL

Copy link
Copy Markdown
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants