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

Implement Mega EOF #3440

Draft
wants to merge 62 commits into
base: master
Choose a base branch
from
Draft

Implement Mega EOF #3440

wants to merge 62 commits into from

Conversation

jochem-brouwer
Copy link
Member

@jochem-brouwer jochem-brouwer commented May 29, 2024

https://github.com/ipsilon/eof/blob/main/spec/eof.md

https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7692.md

Not ready for review yet, there is still a lot left to do.

I have some local changes which are super dirty and I did not push yet, but will do once I've cleaned that up (mainly in execution).

To run tests: (note: this setups both blockchain/state and header tests)

  1. Download fixtures from latest release in execution-spec-tests, e.g. https://github.com/ethereum/execution-spec-tests/releases/tag/eip7692%40v1.0.4
  2. Untar this and put everything inside ./packages/ethereum-tests, for instance inside the "eof" folder
  3. Now run the blockchain tests from ./packages/vm: npm run test:blockchain -- --fork=Prague --dir=../eof/fixtures/blockchain_tests
  4. Now run the state tests from ./packages/vm: npm run test:blockchain -- --fork=Prague --dir=../eof/fixtures/state_tests
  5. For the eof header tests, first change ./packages/evm/test/eips/eof-header-validation.spec.ts to make testDir point to the right directory, change line 11 to: const testDir = path.resolve('../ethereum-tests/eof/fixtures/eof_tests')
  6. Run the header tests: cd ./packages/evm: npx vitest run ./test/eips/eof-header-validation.spec.ts

Gotchas:

  • The execution tests ALWAYS run on verified EOF code. The execution tests thus ONLY cover the execution part of EOF
  • There are also eof-tests in the above listed fixtures. These are actual header tests, and these verify if the EOF containers are correct

Code gotchas:

  • The "eof code exectution" is somewhat hacked into the current EVM, by setting the program counter to the first part of the code section. Any code section called to (via CALLF) will save the correct pc once returned, and will update the pc to the start of the called code section
  • There are some special cases for EXT*CALL which should put 1 on the stack, this sets a special flag for messageGasLimit of -BIGINT_1 (yes, negative), this is also somewhat a hack (we can provide an extra flag)
  • The code is super unoptimized and will likely need multiple PRs on top to optimize it
  • This code will also likely impact the speed of legacy contracts (since calls such as EXTCODEHASH will now first read the complete EXTCODE to check if it is EOF code)

console.log(JSON.stringify(stackDelta))


*/
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we put this generation code into evm/scripts and then reference from here? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, good point, will do!

@jochem-brouwer
Copy link
Member Author

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.

None yet

2 participants