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

fix: template contract test passing #5

Merged
merged 2 commits into from
Jul 11, 2024
Merged

fix: template contract test passing #5

merged 2 commits into from
Jul 11, 2024

Conversation

alxiong
Copy link
Collaborator

@alxiong alxiong commented Jul 10, 2024

Also closes #3

This PR:

This PR fixed some contract setup so that forge test now all passes

@alxiong alxiong changed the title contract passing fix: template contract test passing Jul 10, 2024
@alxiong
Copy link
Collaborator Author

alxiong commented Jul 10, 2024

@akonring you raised a good question, I wasn't too sure about how the Gateway contract works before.

based the doc here, i think we should use Gateway to auto-select the right verifier in practice.

so the vm.mockCall basically says the next call is not actually being executed, just return a mock answer, so the fact that our forge test passes doesn't mean the Plonk proof is being verified. (but simply trivially skipped)

That said, it's tricky to switch to an actual verifier in our test, because we use the fixture.json directly introduced in succinctlabs/sp1-project-template#4, and the first 4 bytes of proof, supposed to be the identifier for the verifier, but we don't control that. None of the existing Verifier contract matches that.
(e.g. the v1.0.7-testnet is expecting a hash of 0x8c5bc5e4 from here, yet the fixture uploaded by succinct team has proof that starts with 0x1b24bf0e)

I also did a quick try to replace the first 4 bytes of the proof in the current fixture.json, but I would get wrong proof size:

[FAIL. Reason: revert: wrong proof size] test_ValidFibonacciProof() (gas: 42733)

So in short, Succint team just uploaded a useless, out of nowhere proof that cannot be verified by any of their existing PlonkVerifier.
This could be fixed once we actually run the 256GB RAM of proof gen, and repopulate the fixture.json.

Maybe leave this PR open, and I will ask Mat for a machine to do that.

@akonring
Copy link
Contributor

That said, it's tricky to switch to an actual verifier in our test, because we use the fixture.json directly introduced in succinctlabs/sp1-project-template#4, and the first 4 bytes of proof, supposed to be the identifier for the verifier, but we don't control that. None of the existing Verifier contract matches that. (e.g. the v1.0.7-testnet is expecting a hash of 0x8c5bc5e4 from here, yet the fixture uploaded by succinct team has proof that starts with 0x1b24bf0e)

I see. Thanks for checking this out.

So in short, Succint team just uploaded a useless, out of nowhere proof that cannot be verified by any of their existing PlonkVerifier. This could be fixed once we actually run the 256GB RAM of proof gen, and repopulate the fixture.json.

Yes, it seems like they only generated the fixture.json for the initial version (v1.0.4-testnet) and "forgot" to generate the the same fixture with subsequent versions (including the versions where the 4-byte verifier check has been introduced).

Maybe leave this PR open, and I will ask Mat for a machine to do that.

Yes, agree. There might be a couple of options/things to keep in mind:

  1. We could make as much progress as possible w/o the fixture and just mock contract verification (as we do now).
  2. We could ask Succinct Labs to generate the fixture.json for newer versions. This would give us something concrete for a e2e setup with actual verification.
  3. We could try to set up a beefy server and generate the proof ourselves using existing SP1 tooling. We'll have to do this eventually so this could give us a head start on potential issues in this process.

@alxiong
Copy link
Collaborator Author

alxiong commented Jul 11, 2024

Yes, it seems like they only generated the fixture.json for the initial version (v1.0.4-testnet) and "forgot" to generate the the same fixture with subsequent versions (including the versions where the 4-byte verifier check has been introduced).

amazing, I didn't find their v1.0.4-testnet yesterday, didn't know that it comes from there. Glad you dig into this rabit hole.

We could try to set up a beefy server and generate the proof ourselves using existing SP1 tooling. We'll have to do this eventually so this could give us a head start on potential issues in this process.

I prefer this.

@alxiong alxiong marked this pull request as draft July 11, 2024 05:05
@alxiong alxiong marked this pull request as ready for review July 11, 2024 06:17
@alxiong
Copy link
Collaborator Author

alxiong commented Jul 11, 2024

I spent some time improving on it and got rid of the annoying script/build.rs that's causing the problem.
in 87d8799

now we should merge this soon as it will affect @mrain 's PR.

I will address the outdated fixture.json for contract test in a separate PR

@alxiong alxiong merged commit a76f418 into main Jul 11, 2024
@alxiong alxiong deleted the fix-contract branch July 11, 2024 06:20
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.

impove sp1 setup
3 participants