Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 48 additions & 47 deletions Cargo.lock

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,28 +87,28 @@ strata-test-utils-btc = { path = "crates/test-utils/btc" }
strata-test-utils-btcio = { path = "crates/test-utils/btcio" }
strata-test-utils-checkpoint = { path = "crates/test-utils/checkpoint" }

# Dependencies from alpenlabs/moho (dc8e6b5 = strata-common rc13)
moho-recursive-proof = { git = "https://github.com/alpenlabs/moho", rev = "dc8e6b536852ee38aa4280cfda8e7cd009b37eab" }
moho-runtime-impl = { git = "https://github.com/alpenlabs/moho", rev = "dc8e6b536852ee38aa4280cfda8e7cd009b37eab" }
moho-runtime-interface = { git = "https://github.com/alpenlabs/moho", rev = "dc8e6b536852ee38aa4280cfda8e7cd009b37eab" }
moho-types = { git = "https://github.com/alpenlabs/moho", rev = "dc8e6b536852ee38aa4280cfda8e7cd009b37eab" }
# Dependencies from alpenlabs/moho (28ef75c = strata-common rc14)
moho-recursive-proof = { git = "https://github.com/alpenlabs/moho", rev = "28ef75cf39758c4214cb383a4de2b2dcf0a3dd67" }
moho-runtime-impl = { git = "https://github.com/alpenlabs/moho", rev = "28ef75cf39758c4214cb383a4de2b2dcf0a3dd67" }
moho-runtime-interface = { git = "https://github.com/alpenlabs/moho", rev = "28ef75cf39758c4214cb383a4de2b2dcf0a3dd67" }
moho-types = { git = "https://github.com/alpenlabs/moho", rev = "28ef75cf39758c4214cb383a4de2b2dcf0a3dd67" }

# Dependencies from alpenlabs/strata-common
strata-btc-types = { git = "https://github.com/alpenlabs/strata-common", tag = "v0.1.0-alpha-rc13" }
strata-btc-types = { git = "https://github.com/alpenlabs/strata-common", tag = "v0.1.0-alpha-rc14" }
strata-codec = { git = "https://github.com/alpenlabs/strata-common", features = [
"derive",
], tag = "v0.1.0-alpha-rc13" }
strata-codec-utils = { git = "https://github.com/alpenlabs/strata-common", tag = "v0.1.0-alpha-rc13" }
strata-crypto = { git = "https://github.com/alpenlabs/strata-common", tag = "v0.1.0-alpha-rc13" }
strata-identifiers = { git = "https://github.com/alpenlabs/strata-common", tag = "v0.1.0-alpha-rc13" }
strata-l1-envelope-fmt = { git = "https://github.com/alpenlabs/strata-common", tag = "v0.1.0-alpha-rc13" }
strata-l1-txfmt = { git = "https://github.com/alpenlabs/strata-common", tag = "v0.1.0-alpha-rc13" }
strata-merkle = { git = "https://github.com/alpenlabs/strata-common", tag = "v0.1.0-alpha-rc13" }
strata-msg-fmt = { git = "https://github.com/alpenlabs/strata-common", tag = "v0.1.0-alpha-rc13" }
strata-predicate = { git = "https://github.com/alpenlabs/strata-common", tag = "v0.1.0-alpha-rc13" }
strata-service = { git = "https://github.com/alpenlabs/strata-common", tag = "v0.1.0-alpha-rc13" }
strata-ssz-tests = { git = "https://github.com/alpenlabs/strata-common", tag = "v0.1.0-alpha-rc13" }
strata-tasks = { git = "https://github.com/alpenlabs/strata-common", tag = "v0.1.0-alpha-rc13" }
], tag = "v0.1.0-alpha-rc14" }
strata-codec-utils = { git = "https://github.com/alpenlabs/strata-common", tag = "v0.1.0-alpha-rc14" }
strata-crypto = { git = "https://github.com/alpenlabs/strata-common", tag = "v0.1.0-alpha-rc14" }
strata-identifiers = { git = "https://github.com/alpenlabs/strata-common", tag = "v0.1.0-alpha-rc14" }
strata-l1-envelope-fmt = { git = "https://github.com/alpenlabs/strata-common", tag = "v0.1.0-alpha-rc14" }
strata-l1-txfmt = { git = "https://github.com/alpenlabs/strata-common", tag = "v0.1.0-alpha-rc14" }
strata-merkle = { git = "https://github.com/alpenlabs/strata-common", tag = "v0.1.0-alpha-rc14" }
strata-msg-fmt = { git = "https://github.com/alpenlabs/strata-common", tag = "v0.1.0-alpha-rc14" }
strata-predicate = { git = "https://github.com/alpenlabs/strata-common", tag = "v0.1.0-alpha-rc14" }
strata-service = { git = "https://github.com/alpenlabs/strata-common", tag = "v0.1.0-alpha-rc14" }
strata-ssz-tests = { git = "https://github.com/alpenlabs/strata-common", tag = "v0.1.0-alpha-rc14" }
strata-tasks = { git = "https://github.com/alpenlabs/strata-common", tag = "v0.1.0-alpha-rc14" }

# dependencies from alpenlabs/ssz-gen
ssz = { git = "https://github.com/alpenlabs/ssz-gen", tag = "v0.14.0" }
Expand All @@ -120,15 +120,15 @@ tree_hash = { git = "https://github.com/alpenlabs/ssz-gen", tag = "v0.14.0" }
tree_hash_derive = { git = "https://github.com/alpenlabs/ssz-gen", tag = "v0.14.0" }

# dependencies from alpenlabs/zkaleido
zkaleido = { git = "https://github.com/alpenlabs/zkaleido", tag = "v0.1.0-alpha-rc22", features = [
zkaleido = { git = "https://github.com/alpenlabs/zkaleido", tag = "v0.1.0-alpha-rc23", features = [
"borsh",
"remote-prover",
"serde",
] }
zkaleido-native-adapter = { git = "https://github.com/alpenlabs/zkaleido", tag = "v0.1.0-alpha-rc22", features = [
zkaleido-native-adapter = { git = "https://github.com/alpenlabs/zkaleido", tag = "v0.1.0-alpha-rc23", features = [
"remote-prover",
] }
zkaleido-sp1-host = { git = "https://github.com/alpenlabs/zkaleido", tag = "v0.1.0-alpha-rc22" }
zkaleido-sp1-host = { git = "https://github.com/alpenlabs/zkaleido", tag = "v0.1.0-alpha-rc23" }

# external dependencies
anyhow = "1.0.86"
Expand Down
4 changes: 2 additions & 2 deletions bin/prover-perf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ sp1-sdk = "5.2.1"
sp1-verifier = "5.2.1"
ssz.workspace = true
zkaleido = { workspace = true, features = ["perf"] }
zkaleido-sp1-groth16-verifier = { git = "https://github.com/alpenlabs/zkaleido", tag = "v0.1.0-alpha-rc22" }
zkaleido-sp1-host = { git = "https://github.com/alpenlabs/zkaleido", tag = "v0.1.0-alpha-rc22", features = [
zkaleido-sp1-groth16-verifier = { git = "https://github.com/alpenlabs/zkaleido", tag = "v0.1.0-alpha-rc23" }
zkaleido-sp1-host = { git = "https://github.com/alpenlabs/zkaleido", tag = "v0.1.0-alpha-rc23", features = [
"perf",
] }
2 changes: 1 addition & 1 deletion crates/common/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use ssz::DecodeError;
pub use strata_asm_manifest_types::{AsmManifestError, AsmManifestResult, Mismatched};
use strata_btc_verification::{L1BodyError, L1VerificationError};
use strata_l1_txfmt::SubprotocolId;
use strata_merkle::error::MerkleError;
use strata_merkle::MerkleError;
use thiserror::Error;

use crate::aux::AuxError;
Expand Down
9 changes: 2 additions & 7 deletions crates/common/src/mmr.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
//! History accumulator for ASM.

use strata_asm_manifest_types::{AsmManifest, Hash32};
use strata_merkle::{CompactMmr64, Mmr, Mmr64B32, Sha256Hasher, error::MerkleError};
use strata_merkle::{MerkleError, Mmr, Mmr64B32, MmrState, Sha256Hasher};

use crate::AsmHistoryAccumulatorState;

/// Capacity of the ASM MMR as a power of 2.
///
/// With a value of 64, the MMR supports up to 2^64 leaves
const ASM_MMR_CAP_LOG2: u8 = 64;

/// The hasher used for ASM manifest MMR operations.
///
/// Uses SHA-256 with full 32-byte hash output.
Expand All @@ -23,7 +18,7 @@ impl AsmHistoryAccumulatorState {
/// The internal `offset` is set to `genesis_height + 1` since manifests
/// start from the first block after genesis.
pub fn new(genesis_height: u64) -> Self {
let manifest_mmr = Mmr64B32::from_generic(&CompactMmr64::<Hash32>::new(ASM_MMR_CAP_LOG2));
let manifest_mmr = Mmr64B32::new_empty();
Self {
manifest_mmr,
offset: genesis_height + 1,
Expand Down
2 changes: 1 addition & 1 deletion crates/storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ strata-asm-worker.workspace = true
strata-identifiers.workspace = true
strata-merkle = { workspace = true, features = ["ssz"] }


anyhow.workspace = true
borsh.workspace = true
sled.workspace = true
ssz.workspace = true

[dev-dependencies]
tempfile.workspace = true
21 changes: 11 additions & 10 deletions crates/storage/src/mmr.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//! Sled-backed Merkle Mountain Range for manifest hashes.

use anyhow::{Context, Result};
use ssz::{Decode, Encode};
use strata_identifiers::Buf32;
use strata_merkle::{CompactMmr64, MerkleProofB32, Mmr, Sha256Hasher};
use strata_merkle::{MerkleProofB32, Mmr, Mmr64B32, MmrState, Sha256Hasher};

/// Sled-backed MMR for manifest hashes.
///
Expand Down Expand Up @@ -81,7 +82,7 @@ impl MmrDb {
/// Rebuilds the MMR from stored leaves up to `at_leaf_count`, then
/// extracts the proof for the given index.
pub fn generate_proof(&self, index: u64, at_leaf_count: u64) -> Result<MerkleProofB32> {
let mut compact = CompactMmr64::new(64);
let mut compact = Mmr64B32::new_empty();
let mut proof_list = Vec::with_capacity(at_leaf_count as usize);

for i in 0..at_leaf_count {
Expand All @@ -105,15 +106,16 @@ impl MmrDb {
.context(format!("no proof for index {index}"))
}

fn load_compact_mmr(&self) -> Result<CompactMmr64<[u8; 32]>> {
fn load_compact_mmr(&self) -> Result<Mmr64B32> {
match self.meta.get(MMR_STATE_KEY)? {
Some(bytes) => borsh::from_slice(&bytes).context("failed to deserialize compact MMR"),
None => Ok(CompactMmr64::new(64)),
Some(bytes) => Mmr64B32::from_ssz_bytes(bytes.as_ref())
.context("failed to deserialize compact MMR"),
None => Ok(Mmr64B32::new_empty()),
}
}

fn save_compact_mmr(&self, mmr: &CompactMmr64<[u8; 32]>) -> Result<()> {
let bytes = borsh::to_vec(mmr)?;
fn save_compact_mmr(&self, mmr: &Mmr64B32) -> Result<()> {
let bytes = mmr.as_ssz_bytes();
self.meta.insert(MMR_STATE_KEY, bytes)?;
Ok(())
}
Expand All @@ -122,7 +124,6 @@ impl MmrDb {
#[cfg(test)]
mod tests {
use strata_identifiers::Buf32;
use strata_merkle::Mmr64B32;

use super::*;

Expand Down Expand Up @@ -189,7 +190,7 @@ mod tests {
mmr_db.append_leaf(leaf).unwrap();

let proof = mmr_db.generate_proof(0, 1).unwrap();
let compact = Mmr64B32::from_generic(&mmr_db.load_compact_mmr().unwrap());
let compact = mmr_db.load_compact_mmr().unwrap();
assert!(compact.verify(&proof, &leaf.0));
}

Expand Down Expand Up @@ -219,7 +220,7 @@ mod tests {
for i in 0u8..4 {
mmr_db.append_leaf(make_leaf(i)).unwrap();
}
let compact_at_4 = Mmr64B32::from_generic(&mmr_db.load_compact_mmr().unwrap());
let compact_at_4 = mmr_db.load_compact_mmr().unwrap();

// Append 4 more.
for i in 4u8..8 {
Expand Down
2 changes: 1 addition & 1 deletion crates/test-utils/checkpoint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ strata-asm-txs-checkpoint.workspace = true
strata-checkpoint-types-ssz.workspace = true
strata-crypto.workspace = true
strata-identifiers.workspace = true
strata-merkle.workspace = true
strata-merkle = { workspace = true, features = ["ssz"] }
strata-predicate.workspace = true
strata-test-utils-arb.workspace = true
strata-test-utils-btc.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions crates/test-utils/checkpoint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use strata_checkpoint_types_ssz::{
};
use strata_crypto::hash;
use strata_identifiers::{OLBlockCommitment, OLBlockId};
use strata_merkle::{CompactMmr64, Mmr, Sha256Hasher};
use strata_merkle::{Mmr, Mmr64B32, MmrState, Sha256Hasher};
use strata_predicate::{PredicateKey, PredicateTypeId};
use strata_test_utils_arb::ArbitraryGenerator;
use strata_test_utils_btc as _;
Expand Down Expand Up @@ -180,7 +180,7 @@ impl CheckpointTestHarness {
let leaves = self.gen_manifest_leaves(new_tip);
let mut proof_list = Vec::new();

let mut manifest_mmr = CompactMmr64::new(64);
let mut manifest_mmr = Mmr64B32::new_empty();
let mut asm_accumulator_state =
AsmHistoryAccumulatorState::new(self.genesis_l1_height as u64);

Expand Down
Loading
Loading