-
Notifications
You must be signed in to change notification settings - Fork 0
feat(proof): add proof types crate and remote proof tracking DBs #10
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0b2ac5c
refactor(asm-proof-impl): move ASM proof statements into a separate p…
prajwolrg 090a5cf
feat: create a new crate for asm proof types
prajwolrg 2e90b31
refactor: move proof-db inside of proof directory
prajwolrg e389157
feat(proof-types): add moho proof and asm proof
prajwolrg 93ba128
refactor!(proof-types): use ProofReceiptWithMetadata instead of Vec<u8>
prajwolrg 108a818
feat: add remote proof mapping db and status db
prajwolrg 734f293
feat(db): implement remote proof mapping db
prajwolrg 4aeeec8
feat(db): implement remote proof status db
prajwolrg 3cb9d4c
refactor(db): reorganize traits and impls
prajwolrg 3dd88e0
refactor(db): rename strata-bridge-proof-db to strata-asm-proof-db
prajwolrg 04e4df4
refactor(db): extract encode/decode_block_commitment as key encoding …
prajwolrg 25dcda4
fix(db): use atomic sled operations in remote proof status db
prajwolrg 90db650
style: normalize indentation in cargo audit config
prajwolrg 654cb2b
fix(txs): cap arbitrary destination len to work around strata-common bug
prajwolrg ba91010
fix lints
prajwolrg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| [advisories] | ||
| ignore = [ | ||
| # NOTE: cargo-audit reads config from .cargo/audit.toml. | ||
| # RUSTSEC-2025-0055 (tracing-subscriber 0.2.25) | ||
| # Pulled in via ark-relations. | ||
| # Upgrade blocked until upstream bumps tracing-subscriber >= 0.3.20. | ||
| # Low risk: affects ANSI escape sequences in logs only. | ||
| "RUSTSEC-2025-0055", | ||
| # NOTE: cargo-audit reads config from .cargo/audit.toml. | ||
| # RUSTSEC-2025-0055 (tracing-subscriber 0.2.25) | ||
| # Pulled in via ark-relations. | ||
| # Upgrade blocked until upstream bumps tracing-subscriber >= 0.3.20. | ||
| # Low risk: affects ANSI escape sequences in logs only. | ||
| "RUSTSEC-2025-0055", | ||
| ] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| //! Persistence layer for ASM and Moho proofs. | ||
| //! | ||
| //! This crate defines three storage traits that together cover the full | ||
| //! lifecycle of a proof — from submission to a remote prover, through status | ||
| //! tracking, to final local storage: | ||
| //! | ||
| //! - [`ProofDb`] — stores and retrieves finalised ASM step proofs and Moho recursive proofs, keyed | ||
| //! by their L1 block range or commitment. | ||
| //! - [`RemoteProofMappingDb`] — maintains a bidirectional mapping between local | ||
| //! [`ProofId`](strata_asm_proof_types::ProofId)s and opaque | ||
| //! [`RemoteProofId`](strata_asm_proof_types::RemoteProofId)s assigned by the remote prover | ||
| //! service. | ||
| //! - [`RemoteProofStatusDb`] — tracks the execution status of in-flight remote proof jobs until | ||
| //! their results are retrieved and stored locally. | ||
| //! | ||
| //! A sled-backed implementation ([`SledProofDb`]) is provided out of the box. | ||
|
|
||
| mod proof_db; | ||
| mod remote_mapping; | ||
| mod remote_status; | ||
| mod sled; | ||
|
|
||
| pub use self::{ | ||
| proof_db::ProofDb, | ||
| remote_mapping::RemoteProofMappingDb, | ||
| remote_status::RemoteProofStatusDb, | ||
| sled::{RemoteProofMappingError, RemoteProofStatusError, SledProofDb}, | ||
| }; |
11 changes: 5 additions & 6 deletions
11
crates/proof-db/src/lib.rs → crates/proof/db/src/proof_db.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| //! Bidirectional mapping between local proof identifiers and remote prover | ||
| //! identifiers. | ||
| //! | ||
| //! This mapping is used to prevent duplicate proof submissions and to recover | ||
| //! the association between local and remote identifiers after restarts. | ||
|
|
||
| use std::fmt::Debug; | ||
|
|
||
| use strata_asm_proof_types::{ProofId, RemoteProofId}; | ||
|
|
||
| /// Persistent bidirectional mapping between local [`ProofId`]s and | ||
| /// [`RemoteProofId`]s assigned by the remote prover service. | ||
| /// | ||
| /// Used to prevent duplicate proof submissions and to recover the association | ||
| /// between local and remote identifiers after restarts. | ||
| pub trait RemoteProofMappingDb { | ||
| /// The error type returned by database operations. | ||
| type Error: Debug; | ||
|
|
||
| /// Returns the remote proof ID associated with the given local proof ID, if one exists. | ||
| fn get_remote_proof_id( | ||
| &self, | ||
| id: ProofId, | ||
| ) -> impl Future<Output = Result<Option<RemoteProofId>, Self::Error>> + Send; | ||
|
|
||
| /// Returns the local proof ID associated with the given remote proof ID, if one exists. | ||
| fn get_proof_id( | ||
| &self, | ||
| remote_id: &RemoteProofId, | ||
| ) -> impl Future<Output = Result<Option<ProofId>, Self::Error>> + Send; | ||
|
|
||
| /// Stores a mapping between a local proof ID and a remote proof ID. | ||
| /// | ||
| /// A single [`ProofId`] may be associated with multiple [`RemoteProofId`]s | ||
| /// (e.g. when a proof is resubmitted), so calling this with the same | ||
| /// `id` but a different `remote_id` is allowed — only the forward lookup | ||
| /// (`ProofId → RemoteProofId`) is updated to point to the latest remote ID. | ||
| /// | ||
| /// However, a [`RemoteProofId`] must map to exactly one [`ProofId`]. | ||
| /// If `remote_id` is already associated with a **different** proof ID, | ||
| /// this method returns an error. | ||
| fn put_remote_proof_id( | ||
| &self, | ||
| id: ProofId, | ||
| remote_id: RemoteProofId, | ||
| ) -> impl Future<Output = Result<(), Self::Error>> + Send; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| //! Status tracking for in-flight remote proof jobs. | ||
| //! | ||
| //! Entries are created when a proof is submitted to the remote prover and | ||
| //! removed once the result has been retrieved and stored locally via | ||
| //! [`ProofDb`](crate::ProofDb). | ||
|
|
||
| use std::fmt::Debug; | ||
|
|
||
| use strata_asm_proof_types::RemoteProofId; | ||
| use zkaleido::RemoteProofStatus; | ||
|
|
||
| /// Persistent store for the execution status of remote proof jobs. | ||
| /// | ||
| /// Tracks only proofs whose results have **not yet been retrieved and stored | ||
| /// locally**. Once a proof is stored via [`ProofDb`](crate::ProofDb), the corresponding status | ||
| /// entry should be removed. | ||
| pub trait RemoteProofStatusDb { | ||
| /// The error type returned by database operations. | ||
| type Error: Debug; | ||
|
|
||
| /// Inserts a new status entry for the given remote proof ID. | ||
| /// | ||
| /// Returns an error if an entry already exists for this ID. | ||
| fn put_status( | ||
| &self, | ||
| remote_id: &RemoteProofId, | ||
| status: RemoteProofStatus, | ||
| ) -> impl Future<Output = Result<(), Self::Error>> + Send; | ||
|
|
||
| /// Updates the status of an existing remote proof entry. | ||
| /// | ||
| /// Returns an error if no entry exists for this ID. | ||
| fn update_status( | ||
| &self, | ||
| remote_id: &RemoteProofId, | ||
| status: RemoteProofStatus, | ||
| ) -> impl Future<Output = Result<(), Self::Error>> + Send; | ||
|
|
||
| /// Returns the current status of the given remote proof, if tracked. | ||
| fn get_status( | ||
| &self, | ||
| remote_id: &RemoteProofId, | ||
| ) -> impl Future<Output = Result<Option<RemoteProofStatus>, Self::Error>> + Send; | ||
|
|
||
| /// Returns all remote proofs that are currently active (i.e. `Requested` or `InProgress`). | ||
| fn get_all_in_progress( | ||
| &self, | ||
| ) -> impl Future<Output = Result<Vec<(RemoteProofId, RemoteProofStatus)>, Self::Error>> + Send; | ||
|
|
||
| /// Removes the status entry for the given remote proof ID. | ||
| fn remove( | ||
| &self, | ||
| remote_id: &RemoteProofId, | ||
| ) -> impl Future<Output = Result<(), Self::Error>> + Send; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.