Skip to content

Fix getOpcodesForHF for when HF > istanbul#647

Merged
holgerd77 merged 2 commits into
masterfrom
fix/getOpcodesForHF
Jan 8, 2020
Merged

Fix getOpcodesForHF for when HF > istanbul#647
holgerd77 merged 2 commits into
masterfrom
fix/getOpcodesForHF

Conversation

@s1na
Copy link
Copy Markdown
Contributor

@s1na s1na commented Jan 8, 2020

When adding support for Istanbul opcode changes in #582, I had taken an approach that was prone to errors when adding new hardforks, and this has happened. Muir Glacier doesn't inherit the opcode changes from istanbul.

I think it's still open how to approach opcode info for HFs, but for now I've changed the condition in getOpcodesForHF to apply istanbul changes to every HF gte Istanbul. Also added tests.

This needs to be released soon as it affects evm execution in Muir Glacier.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 8, 2020

Codecov Report

Merging #647 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master    #647   +/-   ##
======================================
  Coverage    91.4%   91.4%           
======================================
  Files          31      31           
  Lines        1978    1978           
  Branches      326     326           
======================================
  Hits         1808    1808           
  Misses         90      90           
  Partials       80      80
Flag Coverage Δ
#vm 91.4% <100%> (ø) ⬆️
Impacted Files Coverage Δ
lib/evm/opcodes.ts 100% <100%> (ø) ⬆️
lib/index.ts 98.11% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d5475fa...57f2915. Read the comment docs.

Copy link
Copy Markdown
Member

@holgerd77 holgerd77 left a comment

Choose a reason for hiding this comment

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

Looks good, I would tend to only release this as a patch release if it it changes the method signature here. Think this is not yet very much in use yet. Would you go along with this?

Comment thread lib/evm/opcodes.ts
export function getOpcodesForHF(hf: string) {
if (hf === 'istanbul') {
export function getOpcodesForHF(common: Common) {
if (common.gteHardfork('istanbul')) {
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.

Ups. Yeah, well. 🙃

@holgerd77 holgerd77 merged commit 2d9c923 into master Jan 8, 2020
@holgerd77 holgerd77 deleted the fix/getOpcodesForHF branch January 8, 2020 21:09
@holgerd77
Copy link
Copy Markdown
Member

Update: this isn't even part of the official API, is it?

@s1na
Copy link
Copy Markdown
Contributor Author

s1na commented Jan 9, 2020

Yeah I think a patch release is fine. This is not part of the API as you said

Comment thread lib/index.ts
// Set list of opcodes based on HF
this._opcodes = getOpcodesForHF(this._common.hardfork()!)
this._opcodes = getOpcodesForHF(this._common)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks for fixing this, @s1na :)

@evertonfraga
Copy link
Copy Markdown
Contributor

Just for reference, how did you detect this bug, @s1na?

@s1na
Copy link
Copy Markdown
Contributor Author

s1na commented Jan 9, 2020

@evertonfraga I was running mainnet blocks with ethereumjs-vm and the gas usage was off.

I have a setup to fetch blocks from geth's rpc endpoint and run them. I'll let you know when I push it to git. It might be useful for testing the VM with realistic blocks/txes.

@evertonfraga
Copy link
Copy Markdown
Contributor

Sure, thanks! Will be glad to do that kind of sanity checks as well.

we can even use one of the live instances from EF to have an online monitor for the VM.

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.

3 participants