Skip to content
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

common/vm: add EIP-3855, PUSH0 instruction #1616

Merged
merged 2 commits into from
Dec 27, 2021
Merged

common/vm: add EIP-3855, PUSH0 instruction #1616

merged 2 commits into from
Dec 27, 2021

Conversation

jochem-brouwer
Copy link
Member

@jochem-brouwer jochem-brouwer commented Dec 23, 2021

@@ -83,7 +83,7 @@ export default function runCode(this: VM, opts: RunCodeOpts): Promise<ExecResult
new Message({
code: opts.code,
data: opts.data,
gasLimit: opts.gasLimit,
gasLimit: opts.gasLimit ?? new BN(0),
Copy link
Member Author

Choose a reason for hiding this comment

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

Might look a bit out of place in this PR, but I noticed that gasLimit is optional, but if no gasLimit is provided it is thus undefined in the context, which causes the EVM to throw internally here. (cannot clone() the undefined gasLimit).

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it always go OOG if provided with gasLimit of 0?

If so maybe we should throw with an error, or make it default to e.g. the last block's gasLimit?

Should we consider making it non-optional in a next breaking change release? (We can add to our list)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah right I did not give this a lot of thought. I think an error here is cleaner (non-breaking) but I think we should make gasLimit mandatory in the breaking release.

There are a few edge cases where it does not go OOG: either if you run no code, or if you run a code which uses 0 gas (STOP). All other opcodes which have 0 gas cannot be used AFAIK since these need stack items and you would thus need to push items on the stack, which costs gas.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually thinking about this, if we make it error in case that we do not provide gasLimit, then that's breaking as well right?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's true, well if the behavior is correct then we can leave it as be and consider the error for a breaking change release.

Copy link
Contributor

Choose a reason for hiding this comment

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

It didn't work without providing the gasLimit anyway.

We can check if the typedoc for Message has information about providing a gasLimit otherwise default: 0

Copy link
Member Author

Choose a reason for hiding this comment

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

I have removed this change; if we default it to 0 then the behavior is slightly different than if we do not provide a gasLimit; in the case that we just send eth OR we run the 00 code, the code will run and finish if we default it to 0, while if we don't do this it would throw, so this is somewhat a breaking change. (I also should not have added this whole thing since this is out of scope of this PR). Will add this thing to the tiny fixes / breaking issue.

@codecov
Copy link

codecov bot commented Dec 23, 2021

Codecov Report

Merging #1616 (be1ae09) into master (0c7bdfc) will decrease coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

Flag Coverage Δ
block 84.96% <ø> (ø)
blockchain 85.08% <ø> (ø)
client 71.27% <ø> (ø)
common 100.00% <ø> (ø)
devp2p 82.75% <ø> (-0.28%) ⬇️
ethash ∅ <ø> (∅)
trie 86.09% <ø> (ø)
tx 88.62% <ø> (ø)
util 91.84% <ø> (ø)
vm 79.89% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Copy link
Contributor

@ryanio ryanio left a comment

Choose a reason for hiding this comment

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

lgtm!

@jochem-brouwer jochem-brouwer merged commit 3751bbd into master Dec 27, 2021
@jochem-brouwer
Copy link
Member Author

Thanks @ryanio 😄

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

Successfully merging this pull request may close these issues.

2 participants