Skip to content

Commit c85fbcb

Browse files
authored
feat(proof): add proof types crate and remote proof tracking DBs (#10)
* refactor(asm-proof-impl): move ASM proof statements into a separate proof directory * feat: create a new crate for asm proof types * refactor: move proof-db inside of proof directory * feat(proof-types): add moho proof and asm proof * refactor!(proof-types): use ProofReceiptWithMetadata instead of Vec<u8> * feat: add remote proof mapping db and status db * feat(db): implement remote proof mapping db * feat(db): implement remote proof status db * refactor(db): reorganize traits and impls * refactor(db): rename strata-bridge-proof-db to strata-asm-proof-db * refactor(db): extract encode/decode_block_commitment as key encoding primitive * fix(db): use atomic sled operations in remote proof status db * style: normalize indentation in cargo audit config * fix(txs): cap arbitrary destination len to work around strata-common bug * fix lints
1 parent 1d4a95a commit c85fbcb

File tree

22 files changed

+1091
-140
lines changed

22 files changed

+1091
-140
lines changed

.cargo/audit.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[advisories]
22
ignore = [
3-
# NOTE: cargo-audit reads config from .cargo/audit.toml.
4-
# RUSTSEC-2025-0055 (tracing-subscriber 0.2.25)
5-
# Pulled in via ark-relations.
6-
# Upgrade blocked until upstream bumps tracing-subscriber >= 0.3.20.
7-
# Low risk: affects ANSI escape sequences in logs only.
8-
"RUSTSEC-2025-0055",
3+
# NOTE: cargo-audit reads config from .cargo/audit.toml.
4+
# RUSTSEC-2025-0055 (tracing-subscriber 0.2.25)
5+
# Pulled in via ark-relations.
6+
# Upgrade blocked until upstream bumps tracing-subscriber >= 0.3.20.
7+
# Low risk: affects ANSI escape sequences in logs only.
8+
"RUSTSEC-2025-0055",
99
]

Cargo.lock

Lines changed: 27 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ members = [
88
"crates/msgs/bridge",
99
"crates/msgs/checkpoint",
1010
"crates/params",
11-
"crates/proof-db",
12-
"crates/proof-impl",
11+
"crates/proof/db",
12+
"crates/proof/statements",
13+
"crates/proof/types",
1314
"crates/rpc",
1415
"crates/spec",
1516
"crates/spec-debug",
@@ -49,7 +50,9 @@ strata-asm-common = { path = "crates/common" }
4950
strata-asm-logs = { path = "crates/logs" }
5051
strata-asm-manifest-types = { path = "crates/manifest-types" }
5152
strata-asm-params = { path = "crates/params" }
52-
strata-asm-proof-impl = { path = "crates/proof-impl" }
53+
strata-asm-proof-db = { path = "crates/proof/db" }
54+
strata-asm-proof-impl = { path = "crates/proof/statements" }
55+
strata-asm-proof-types = { path = "crates/proof/types" }
5356
strata-asm-proto-administration = { path = "crates/subprotocols/admin" }
5457
strata-asm-proto-bridge-v1 = { path = "crates/subprotocols/bridge-v1" }
5558
strata-asm-proto-checkpoint = { path = "crates/subprotocols/checkpoint" }
@@ -65,7 +68,6 @@ strata-asm-txs-checkpoint = { path = "crates/txs/checkpoint" }
6568
strata-asm-txs-checkpoint-v0 = { path = "crates/txs/checkpoint-v0" }
6669
strata-asm-txs-test-utils = { path = "crates/txs/test-utils" }
6770
strata-asm-worker = { path = "crates/worker" }
68-
strata-bridge-proof-db = { path = "crates/proof-db" }
6971

7072
# Dependencies from alpenlabs/alpen pinned to commit 787b804 (main @ 2026-03-17)
7173
# NOTE: keep `typed-sled` pinned in Cargo.lock to 9062bff for compatibility with this alpen rev.
@@ -94,7 +96,6 @@ strata-test-utils-ssz = { git = "https://github.com/alpenlabs/alpen.git", rev =
9496
# Dependencies from alpenlabs/strata-bridge pinned to commit fc966d5 (STR-2598-asm-stf-proof-statements @ 2026-03-17)
9597
btc-tracker = { git = "https://github.com/alpenlabs/strata-bridge.git", rev = "fc966d5f81c773de10a4ef3a66666687ec11d715" }
9698
strata-bridge-common = { git = "https://github.com/alpenlabs/strata-bridge.git", rev = "fc966d5f81c773de10a4ef3a66666687ec11d715" }
97-
strata-bridge-primitives = { git = "https://github.com/alpenlabs/strata-bridge.git", rev = "fc966d5f81c773de10a4ef3a66666687ec11d715" }
9899

99100
# Dependencies from alpenlabs/moho pinned to commit 97e9d28 (main @ 2026-03-12)
100101
moho-runtime-impl = { git = "https://github.com/alpenlabs/moho", rev = "97e9d281f310e9c2e60cf80448c95e855be589b9" }
@@ -123,8 +124,11 @@ tree_hash = { git = "https://github.com/alpenlabs/ssz-gen", tag = "v0.14.0" }
123124
tree_hash_derive = { git = "https://github.com/alpenlabs/ssz-gen", tag = "v0.14.0" }
124125

125126
# dependencies from alpenlabs/zkaleido
126-
zkaleido = { git = "https://github.com/alpenlabs/zkaleido", tag = "v0.1.0-alpha-rc21" }
127-
zkaleido-native-adapter = { git = "https://github.com/alpenlabs/zkaleido", tag = "v0.1.0-alpha-rc21" }
127+
# FIXME: (@prajwolrg) use a proper tag
128+
zkaleido = { git = "https://github.com/alpenlabs/zkaleido", rev = "750c209f5850af29e34c39c250c24e1c69ffa2aa", features = [
129+
"borsh",
130+
] }
131+
zkaleido-native-adapter = { git = "https://github.com/alpenlabs/zkaleido", rev = "750c209f5850af29e34c39c250c24e1c69ffa2aa" }
128132

129133
# external dependencies
130134
anyhow = "1.0.86"
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
[package]
2-
name = "strata-bridge-proof-db"
2+
name = "strata-asm-proof-db"
33
version = "0.1.0"
44
edition = "2024"
55

66
[dependencies]
7-
strata-bridge-primitives.workspace = true
8-
strata-identifiers = { git = "https://github.com/alpenlabs/alpen.git", rev = "201c3fa0af3b1a2173e8e5ae3cdb5d20c311ed17" }
7+
strata-asm-proof-types.workspace = true
8+
strata-identifiers.workspace = true
99

10+
borsh.workspace = true
1011
sled.workspace = true
12+
zkaleido.workspace = true
1113

1214
[dev-dependencies]
1315
proptest.workspace = true

crates/proof/db/src/lib.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//! Persistence layer for ASM and Moho proofs.
2+
//!
3+
//! This crate defines three storage traits that together cover the full
4+
//! lifecycle of a proof — from submission to a remote prover, through status
5+
//! tracking, to final local storage:
6+
//!
7+
//! - [`ProofDb`] — stores and retrieves finalised ASM step proofs and Moho recursive proofs, keyed
8+
//! by their L1 block range or commitment.
9+
//! - [`RemoteProofMappingDb`] — maintains a bidirectional mapping between local
10+
//! [`ProofId`](strata_asm_proof_types::ProofId)s and opaque
11+
//! [`RemoteProofId`](strata_asm_proof_types::RemoteProofId)s assigned by the remote prover
12+
//! service.
13+
//! - [`RemoteProofStatusDb`] — tracks the execution status of in-flight remote proof jobs until
14+
//! their results are retrieved and stored locally.
15+
//!
16+
//! A sled-backed implementation ([`SledProofDb`]) is provided out of the box.
17+
18+
mod proof_db;
19+
mod remote_mapping;
20+
mod remote_status;
21+
mod sled;
22+
23+
pub use self::{
24+
proof_db::ProofDb,
25+
remote_mapping::RemoteProofMappingDb,
26+
remote_status::RemoteProofStatusDb,
27+
sled::{RemoteProofMappingError, RemoteProofStatusError, SledProofDb},
28+
};
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
//! Sled-based proof storage.
1+
//! Storage trait for finalised ASM step proofs and Moho recursive proofs.
2+
//!
3+
//! Proofs are keyed by L1 block range (ASM) or L1 block commitment (Moho) and
4+
//! support height-based pruning to reclaim space for old entries.
25
36
use std::fmt::Debug;
47

5-
use strata_bridge_primitives::proof::{AsmProof, L1Range, MohoProof};
8+
use strata_asm_proof_types::{AsmProof, L1Range, MohoProof};
69
use strata_identifiers::L1BlockCommitment;
710

8-
mod sled;
9-
10-
pub use self::sled::SledProofDb;
11-
1211
/// Persistence interface for proof storage.
1312
pub trait ProofDb {
1413
/// The error type returned by the database operations.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//! Bidirectional mapping between local proof identifiers and remote prover
2+
//! identifiers.
3+
//!
4+
//! This mapping is used to prevent duplicate proof submissions and to recover
5+
//! the association between local and remote identifiers after restarts.
6+
7+
use std::fmt::Debug;
8+
9+
use strata_asm_proof_types::{ProofId, RemoteProofId};
10+
11+
/// Persistent bidirectional mapping between local [`ProofId`]s and
12+
/// [`RemoteProofId`]s assigned by the remote prover service.
13+
///
14+
/// Used to prevent duplicate proof submissions and to recover the association
15+
/// between local and remote identifiers after restarts.
16+
pub trait RemoteProofMappingDb {
17+
/// The error type returned by database operations.
18+
type Error: Debug;
19+
20+
/// Returns the remote proof ID associated with the given local proof ID, if one exists.
21+
fn get_remote_proof_id(
22+
&self,
23+
id: ProofId,
24+
) -> impl Future<Output = Result<Option<RemoteProofId>, Self::Error>> + Send;
25+
26+
/// Returns the local proof ID associated with the given remote proof ID, if one exists.
27+
fn get_proof_id(
28+
&self,
29+
remote_id: &RemoteProofId,
30+
) -> impl Future<Output = Result<Option<ProofId>, Self::Error>> + Send;
31+
32+
/// Stores a mapping between a local proof ID and a remote proof ID.
33+
///
34+
/// A single [`ProofId`] may be associated with multiple [`RemoteProofId`]s
35+
/// (e.g. when a proof is resubmitted), so calling this with the same
36+
/// `id` but a different `remote_id` is allowed — only the forward lookup
37+
/// (`ProofId → RemoteProofId`) is updated to point to the latest remote ID.
38+
///
39+
/// However, a [`RemoteProofId`] must map to exactly one [`ProofId`].
40+
/// If `remote_id` is already associated with a **different** proof ID,
41+
/// this method returns an error.
42+
fn put_remote_proof_id(
43+
&self,
44+
id: ProofId,
45+
remote_id: RemoteProofId,
46+
) -> impl Future<Output = Result<(), Self::Error>> + Send;
47+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//! Status tracking for in-flight remote proof jobs.
2+
//!
3+
//! Entries are created when a proof is submitted to the remote prover and
4+
//! removed once the result has been retrieved and stored locally via
5+
//! [`ProofDb`](crate::ProofDb).
6+
7+
use std::fmt::Debug;
8+
9+
use strata_asm_proof_types::RemoteProofId;
10+
use zkaleido::RemoteProofStatus;
11+
12+
/// Persistent store for the execution status of remote proof jobs.
13+
///
14+
/// Tracks only proofs whose results have **not yet been retrieved and stored
15+
/// locally**. Once a proof is stored via [`ProofDb`](crate::ProofDb), the corresponding status
16+
/// entry should be removed.
17+
pub trait RemoteProofStatusDb {
18+
/// The error type returned by database operations.
19+
type Error: Debug;
20+
21+
/// Inserts a new status entry for the given remote proof ID.
22+
///
23+
/// Returns an error if an entry already exists for this ID.
24+
fn put_status(
25+
&self,
26+
remote_id: &RemoteProofId,
27+
status: RemoteProofStatus,
28+
) -> impl Future<Output = Result<(), Self::Error>> + Send;
29+
30+
/// Updates the status of an existing remote proof entry.
31+
///
32+
/// Returns an error if no entry exists for this ID.
33+
fn update_status(
34+
&self,
35+
remote_id: &RemoteProofId,
36+
status: RemoteProofStatus,
37+
) -> impl Future<Output = Result<(), Self::Error>> + Send;
38+
39+
/// Returns the current status of the given remote proof, if tracked.
40+
fn get_status(
41+
&self,
42+
remote_id: &RemoteProofId,
43+
) -> impl Future<Output = Result<Option<RemoteProofStatus>, Self::Error>> + Send;
44+
45+
/// Returns all remote proofs that are currently active (i.e. `Requested` or `InProgress`).
46+
fn get_all_in_progress(
47+
&self,
48+
) -> impl Future<Output = Result<Vec<(RemoteProofId, RemoteProofStatus)>, Self::Error>> + Send;
49+
50+
/// Removes the status entry for the given remote proof ID.
51+
fn remove(
52+
&self,
53+
remote_id: &RemoteProofId,
54+
) -> impl Future<Output = Result<(), Self::Error>> + Send;
55+
}

0 commit comments

Comments
 (0)