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

VM, Common: Add EIP-3670 (EOF - Code Validation) #1743

Merged
merged 5 commits into from
Feb 28, 2022
Merged

Conversation

acolytec3
Copy link
Contributor

Implements EIP-3670 on top of EIP-3540 PR

https://eips.ethereum.org/EIPS/eip-3670

@codecov
Copy link

codecov bot commented Feb 24, 2022

Codecov Report

Merging #1743 (0368488) into implement-eip3540 (c23c721) will increase coverage by 0.02%.
The diff coverage is 88.00%.

Impacted file tree graph

Flag Coverage Δ
block 85.89% <ø> (ø)
blockchain 83.55% <ø> (ø)
client 73.57% <ø> (ø)
common 93.40% <ø> (ø)
devp2p 82.96% <ø> (+0.06%) ⬆️
ethash 90.76% <ø> (ø)
trie 86.53% <ø> (ø)
tx 90.97% <ø> (ø)
util 89.91% <ø> (ø)
vm 81.79% <88.00%> (?)

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

@holgerd77 holgerd77 changed the title Add EIP3670 VM, Common: Add EIP-3670 (EOF - Code Validation) Feb 25, 2022
"minimumHardfork": "london",
"requiredEIPs": [
3540,
3541
Copy link
Member

Choose a reason for hiding this comment

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

Please do not add 3541 here, this should be only in 3540, otherwise this will be redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood. What about 3860? I just noticed that EIP3670 says its requires that one as well which would notionally make this PR dependent on #1619.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, yes, then it makes sense to add here as well.

Copy link
Member

Choose a reason for hiding this comment

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

I will finish 3860 this week, once that is merged then we should also add 3860 there (and rebase/merge master into #1719)

@acolytec3
Copy link
Contributor Author

Any thoughts on what will determine the definition of done for this PR and letting it safely be merged into the EIP-3540 PR? I've got tests written that reflect the test scenarios identified in the EIP (excluding ones already testing EIP3540). The
ethereum/tests for these EIPs are still unfinished and seems like they may require an upgrade to our test runner to work correctly anyway so not sure that my code passing the current tests should be the right decision point.

@acolytec3
Copy link
Contributor Author

Any thoughts on what will determine the definition of done for this PR and letting it safely be merged into the EIP-3540 PR? I've got tests written that reflect the test scenarios identified in the EIP (excluding ones already testing EIP3540). The ethereum/tests for these EIPs are still unfinished and seems like they may require an upgrade to our test runner to work correctly anyway so not sure that my code passing the current tests should be the right decision point.

I was able to get some of the new tests to pass after finding a bug in the PUSH handler that has now been fixed. Given that geth seems to be implementing the two EIPs (3540 and 3670) together as well as the tests for these EIPs being worked together for ethereum/tests, I'm inclined to merge this PR into the EIP-3540 one. Any objections at this point?

@holgerd77
Copy link
Member

I'm inclined to merge this PR into the EIP-3540 one. Any objections at this point?

No (objection 🙂), I guess that makes sense. We now have this cleanly separated - which is nice - and it now makes a lot of sense to continue to work on this together.

Maybe @jochem-brouwer can give this some post-merge review at some point during the week? That would be nice.

@acolytec3 acolytec3 merged commit d96f2de into implement-eip3540 Feb 28, 2022
@acolytec3 acolytec3 deleted the eip3670 branch February 28, 2022 13:30
)
) {
result = {
...result,
Copy link
Member

Choose a reason for hiding this comment

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

This branch is not covered by tests

// Skip data block following push
x += opcode - 0x5f
if (x > code.length - 1) {
// Push blocks mmust not exceed end of code section
Copy link
Member

Choose a reason for hiding this comment

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

Nit: spelling mistake mmust -> must

Copy link
Member

@jochem-brouwer jochem-brouwer left a comment

Choose a reason for hiding this comment

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

LGTM, but I think tests need some love here:

  • Add a test for the uncovered codecov line (code section does not end with a terminating instruction)
  • Add a test where the code section ends with 0xFE (INVALID) (this is a sanity check)
  • Add a check for each terminating instruction (00, F3, FD, FF) (also a sanity check)
  • Tests for a "create transaction" (so a transaction from an EOA which to field is empty) which tries to deploy a contract using invalid code (so it does not stop with a trunacting opcode, truncated PUSHn instruction, or it has a non-assigned instrucition besides INVALID/0xFE) and verifies that this consumes all gas
  • Same as above but now the code is contained in CREATE/CREATE2

Also, the "test cases" section of the EIP has a few test cases not mentioned here and also not covered in tests yet. (All of them seem like sanity checks to me)

@acolytec3
Copy link
Contributor Author

Thanks for the review! Will work on adding the additional tests in the other PR

acolytec3 added a commit that referenced this pull request Feb 28, 2022
* EIP3670 EOF1 code validation changes
acolytec3 added a commit that referenced this pull request Feb 28, 2022
* EIP3670 EOF1 code validation changes
holgerd77 added a commit that referenced this pull request Mar 15, 2022
* Add EIP json

* Partial changes to enable EIp3540 and start code checks

* Finish code validation checks and API tests

* Move eof params to common

* Code execution context updates

* Add exception for invalid EOF format

* Various fixes

* Gate push handler changes behind EIP

* Remove ethereum/tests tests

* Clarify eof helper variable names

* more naming clarifications

* rename bytecode to container

* check that section sizes are greater than 0

* VM, Common: Add EIP-3670 (EOF - Code Validation) (#1743)

* EIP3670 EOF1 code validation changes

* Fix typos, add tests, update error EOF handler

* EIP3540 tests

* Lint fixes

* Fix tests

* Lint/uncomment tests

* More adjustments to EOF1 logic

* compartmentalize tests

* Add checks for newly deployed contract code

* Fix state test runner for specified EIPs

* vm: add eip3540 tests invalid eof initcode

* vm: lint

* vm/tests: cleanup 3540 tests

* Address feedback

* lint

Co-authored-by: Jochem Brouwer <jochembrouwer96@gmail.com>
Co-authored-by: Holger Drewes <Holger.Drewes@gmail.com>
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