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

E2e test with real verification after forking #133

Merged
merged 5 commits into from
Dec 28, 2023
Merged

Conversation

josojo
Copy link
Collaborator

@josojo josojo commented Dec 27, 2023

/**

  • This test simulates the first proof after a fork
  • The stateRoot and the globalExitRoot of the old state was calculated with an old chainID: 1000
  • The new chainID is 1001. The test shows that the newly generated proof is valid
  • on the real verifier contract. To show this a polygonZkEVM contract is set up
  • with the old state root, as it is done in a fork scenario via forkingManager contract.
  • After this a new batch is sequenced and the proof is verified.
  • The old state root was generated with the zkevm state tool from common-js. See this fork:
  • https://github.com/RealityETH/zkevm-commonjs/pull/1/files
  • and especially this line:
  • https://github.com/RealityETH/zkevm-commonjs/pull/1/files#diff-4d0a534c9be88e9cfd08ea7c2e6d412b9ad1d6501db1900339f19c02fb689922R147
  • It took the genesis state from our deployment script and the first two transactions are
  • some transfers on the chain.
  • Note that we run this "deterministic test" without a fork introduced by the forkingManager,
  • as this would require us to generate a proof for specific inputs (stateHash, globalExitRoot, etc.)
  • that would require us to prover each new test-run (unless one is able to set up the test perfectly deterministic as well).
  • This would be additional work and is not necessary to verify that we can
  • continue to use the old state root and globalExitRoot with a new chainID - as it is done in this test
    */

test can be run via:
npx hardhat test test/e2e/forking.t.js

@josojo josojo requested a review from edmundedgar December 27, 2023 10:44
newNumBatch,
newLocalExitRoot,
newStateRoot,
Array.from(Array(24)).fill('0x0e7073c1e73dfb716c35623b741e4ccfc6290d943f3df60377ad8799373ae439'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this just an arbitrary hash to test that it fails?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes

Copy link
Contributor

@edmundedgar edmundedgar left a comment

Choose a reason for hiding this comment

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

Magnificent. Just one place I didn't understand what the value in the test was (maybe just an arbitrary hash that's supposed to test that things fail?) and left a comment, a comment in the code might be good

@josojo josojo merged commit 5d9f881 into main Dec 28, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants