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

Add EIP-1884 support for Istanbul #581

Merged
merged 1 commit into from
Aug 29, 2019
Merged

Add EIP-1884 support for Istanbul #581

merged 1 commit into from
Aug 29, 2019

Conversation

s1na
Copy link
Contributor

@s1na s1na commented Aug 26, 2019

I just added a basic test case to see SELFBALANCE works. It should be tested more thoroughly when Istanbul tests are merged into ethereumjs-testing.

Fixes #579

@s1na
Copy link
Contributor Author

s1na commented Aug 26, 2019

Tests are failing because I changed the base cost of SLOAD, BALANCE and EXTCODEHASH and base costs are not currently HF-dependent.

One naive solution would be to keep base costs as they are and in the opcode handler, charge the extra gas when current HF is greater than Istanbul.

I think what I'll do is have a list of opcodes modified (or added) in Istanbul as a separate array merge that with the base array if current HF is greater than Istanbul. This goes along the plan of having HF-configurable opcodes (#543).

@s1na
Copy link
Contributor Author

s1na commented Aug 27, 2019

Apparently there has been some discussion on the last ACD about the SLOAD gas repricing freezing some contracts. For now it doesn't seem to affect the EIP, but we should keep an eye on it.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 95.157% when pulling 56350e1 on istanbul/eip-1884 into edffcde on master.

@s1na s1na requested a review from holgerd77 August 29, 2019 08:24
0x46: ['CHAINID', 2, false],
0x47: ['SELFBALANCE', 5, false],
0x54: ['SLOAD', 800, true],
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, this breaks with the concept of having gas price changes collected in the Common library (e.g. for SLOAD), I only expected the Istanbul opcode list to include the newly introduced opcodes (SELFBALANCE).

For the moment this would introduce a lot of inconsistency - we also have added other gas price changes for Istanbul in the istanbul.json file.

Do you have a bigger plan for a complete transition here respectively a strong reasoning for this break apart? Otherwise I would very much suggest we add the price changes to the Common library.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I didn't know the base cost of opcodes are also updated in Common (in addition to extra gas parameters like ecAdd). If that has been the intention, there's no corresponding code in the VM to read those base gas costs from Common:

https://github.com/ethereumjs/ethereumjs-vm/blob/edffcde9696283799efc4ab17d0c3e481618c727/lib/evm/interpreter.ts#L105-L112

If we want to keep base gas costs in Common we'd have to:

  • Make sure costs for all opcodes are in Common (not the case now, searching swap in ethereumjs-common returned empty)
  • Remove them from opcodes.ts to only have one source of truth
  • Modify Interpreter to read costs from Common

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, maybe we are talking side by side a bit? What is with SLOAD e.g. - the EIP is stating that this is changing gas costs from 200 to 800 - and the 200 price is just "normally" defined in the tangerine whistle json file in the Common library (see link above).

This is just a "normal" gas price change, isn't it?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, just had another look. See the point, these gas costs are not taken by Common at all atm. Maybe this is just more of some inconsistency/incompleteness in the Common library.

Anyhow, you are right. Will approve here.

Copy link
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.

@holgerd77
Copy link
Member

Ok, I would relatively quickly target a v4.1 release after this is merged, eventually waiting for #577 from @alcuadrado.

What is with the stateless execution prototype #556 (not urgent), do you want to have that included?

@s1na
Copy link
Contributor Author

s1na commented Aug 29, 2019

The stateless execution prototype we can defer to a future release.

It should be however possible to include EIP-2028 (#570) also in the release. It depends on ethereumjs-tx updating its ethereumjs-common dependency, and then updating both in the VM. Or do you think we should include it in the next release?

@s1na s1na merged commit d60699d into master Aug 29, 2019
@s1na s1na deleted the istanbul/eip-1884 branch August 29, 2019 12:20
@holgerd77
Copy link
Member

Makes very much sense to also include EIP-2028.

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.

[Istanbul] EIP-1884: Trie-size-dependent Opcode Repricing > SELFBALANCE Opcode
4 participants