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

Enable verifying proofs based on the fork #1011

Merged
merged 16 commits into from
Aug 20, 2024

Conversation

yaziciahmet
Copy link
Contributor

Description

This PR adds a mapping from the fork spec id to risc0 code commitment. This will enable full-nodes to verify the proofs retrospectively.

Also, this PR clears up the ForkManager implementation a bit.

There exists couple of concerns and potential future issues:

  1. Our current fork implementation does not account for different environments (devnet, testnet, mainnet, local etc.). It is out of the scope of this PR, but we should keep this in mind.
  2. Currently, since we have only one fork, Genesis, its corresponding method id is just read from the build output of the guest code. But we need it hardcoded in order to be able to not lose the previous fork. During development phase it is prone to change, so it seems ok to keep it like this for now. But before testnet, we need to have it as hardcoded, and also have some way to verify that these hardcoded values actually match.

Linked Issues

@yaziciahmet yaziciahmet force-pushed the yaziciahmet/risc0-method-ids-in-forks branch from 00c76bb to b646105 Compare August 19, 2024 07:49
Copy link

codecov bot commented Aug 19, 2024

Codecov Report

Attention: Patch coverage is 64.49704% with 60 lines in your changes missing coverage. Please review.

Project coverage is 77.9%. Comparing base (dcf4b3a) to head (e2ecd77).
Report is 2 commits behind head on nightly.

Files Patch % Lines
crates/fullnode/src/runner.rs 47.6% 11 Missing ⚠️
crates/sovereign-sdk/adapters/risc0/src/host.rs 0.0% 11 Missing ⚠️
...module-system/sov-modules-stf-blueprint/src/lib.rs 0.0% 9 Missing ⚠️
crates/prover/src/runner.rs 46.1% 7 Missing ⚠️
crates/risc0-bonsai/src/host.rs 0.0% 7 Missing ⚠️
crates/sovereign-sdk/adapters/mock-zkvm/src/lib.rs 44.4% 5 Missing ⚠️
...ates/sovereign-sdk/adapters/risc0/src/guest/mod.rs 0.0% 3 Missing ⚠️
crates/citrea-stf/src/verifier.rs 0.0% 2 Missing ⚠️
...reign-sdk/full-node/sov-stf-runner/src/mock/mod.rs 0.0% 2 Missing ⚠️
crates/primitives/src/fork/manager.rs 96.9% 1 Missing ⚠️
... and 2 more
Additional details and impacted files
Files Coverage Δ
bin/citrea/src/rollup/bitcoin.rs 0.0% <ø> (ø)
bin/citrea/src/rollup/mock.rs 95.5% <100.0%> (+0.1%) ⬆️
bin/citrea/src/rollup/mod.rs 96.8% <100.0%> (-0.1%) ⬇️
crates/primitives/src/fork/tests.rs 96.7% <100.0%> (+0.5%) ⬆️
crates/sequencer/src/sequencer.rs 90.7% <100.0%> (+<0.1%) ⬆️
...reign-sdk/full-node/db/sov-db/src/schema/tables.rs 91.9% <ø> (ø)
...ule-system/sov-modules-rollup-blueprint/src/lib.rs 100.0% <ø> (ø)
crates/sovereign-sdk/rollup-interface/src/fork.rs 100.0% <100.0%> (ø)
crates/sovereign-sdk/rollup-interface/src/spec.rs 16.6% <ø> (+16.6%) ⬆️
...eign-sdk/rollup-interface/src/state_machine/stf.rs 41.3% <ø> (ø)
... and 13 more

... and 10 files with indirect coverage changes

@yaziciahmet yaziciahmet force-pushed the yaziciahmet/risc0-method-ids-in-forks branch from a27a641 to add64e0 Compare August 19, 2024 09:57
@yaziciahmet yaziciahmet force-pushed the yaziciahmet/risc0-method-ids-in-forks branch from ea238c1 to af90bb8 Compare August 19, 2024 20:44
Copy link
Contributor

@rakanalh rakanalh left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@eyusufatik eyusufatik left a comment

Choose a reason for hiding this comment

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

LGTM
left a few nits

crates/fullnode/src/runner.rs Show resolved Hide resolved
@yaziciahmet yaziciahmet merged commit 1bacc1e into nightly Aug 20, 2024
12 checks passed
@yaziciahmet yaziciahmet deleted the yaziciahmet/risc0-method-ids-in-forks branch August 20, 2024 13:13
) -> Result<Vec<u8>, Self::Error> {
let receipt: Receipt = bincode::deserialize(serialized_proof)?;

#[allow(clippy::clone_on_copy)]
Copy link
Contributor

Choose a reason for hiding this comment

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

What's that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CodeCommitment type is copyable (inner is [u32;8]), but we are calling clone on it. Hence it is unnecessary and can be just dereferenced with *. It was like that previously hence didn't give much attention just copy-pasted.

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.

Native fork spec for method ids
4 participants