Skip to content
Open
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
36 changes: 31 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ hex-literal = "1.1"
jsonrpsee = "0.26.0"
k256 = "0.13.4"
musig2 = { version = "0.1.0", features = ["serde"] }
num_enum = "0.7"
proptest = "1.9.0"
rand = "0.8.5"
rand_chacha = { version = "0.9.0", default-features = false }
Expand Down
3 changes: 3 additions & 0 deletions bin/asm-runner/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub(crate) async fn bootstrap(
aux_db,
manifest_db,
mmr_db,
spec_activation_db,
} = create_asm_storage(&config.database.asm_path)?;
let MohoStorage {
state_db: moho_state_db,
Expand Down Expand Up @@ -67,6 +68,7 @@ pub(crate) async fn bootstrap(
aux_db.clone(),
manifest_db.clone(),
mmr_db.clone(),
spec_activation_db,
);

// 5. Launch ASM worker.
Expand All @@ -80,6 +82,7 @@ pub(crate) async fn bootstrap(
.with_context(worker_context)
.with_asm_spec(StrataAsmSpec)
.with_params(params.genesis.clone())
.with_spec_schedule(params.runtime.spec_schedule.clone())
.launch(&executor)
})?;

Expand Down
6 changes: 5 additions & 1 deletion bin/asm-runner/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
use std::{path::Path, sync::Arc};

use anyhow::Result;
use asm_storage::{SledAsmAuxDataDb, SledAsmManifestDb, SledAsmManifestMmrDb, SledAsmStateDb};
use asm_storage::{
SledAsmAuxDataDb, SledAsmManifestDb, SledAsmManifestMmrDb, SledAsmStateDb, SledSpecActivationDb,
};
use strata_asm_moho_storage::{SledExportEntriesDb, SledMohoStateDb};
use strata_asm_prover_storage::SledProofDb;

Expand All @@ -19,6 +21,7 @@ pub(crate) struct AsmStorage {
pub aux_db: Arc<SledAsmAuxDataDb>,
pub manifest_db: Arc<SledAsmManifestDb>,
pub mmr_db: Arc<SledAsmManifestMmrDb>,
pub spec_activation_db: Arc<SledSpecActivationDb>,
}

/// Moho storage backends, both opened on the Moho sled database.
Expand All @@ -35,6 +38,7 @@ pub(crate) fn create_asm_storage(path: &Path) -> Result<AsmStorage> {
aux_db: Arc::new(SledAsmAuxDataDb::open(&db)?),
manifest_db: Arc::new(SledAsmManifestDb::open(&db)?),
mmr_db: Arc::new(SledAsmManifestMmrDb::open(&db)?),
spec_activation_db: Arc::new(SledSpecActivationDb::open(&db)?),
})
}

Expand Down
58 changes: 52 additions & 6 deletions bin/asm-runner/src/worker_context.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
//! Worker-context trait implementations for the ASM runner.
//!
//! Implements the four [`WorkerContext`](strata_asm_worker::WorkerContext)
//! Implements the five [`WorkerContext`](strata_asm_worker::WorkerContext)
//! concern traits ([`L1DataProvider`], [`AnchorStateStore`],
//! [`ManifestMmrStore`], [`AuxDataStore`]) for [`AsmWorkerContext`].
//! [`ManifestMmrStore`], [`AuxDataStore`], [`SpecActivationStore`]) for
//! [`AsmWorkerContext`].

use std::sync::Arc;

use anyhow::Context;
use asm_storage::{SledAsmAuxDataDb, SledAsmManifestDb, SledAsmManifestMmrDb, SledAsmStateDb};
use anyhow::{Context, anyhow};
use asm_storage::{
SledAsmAuxDataDb, SledAsmManifestDb, SledAsmManifestMmrDb, SledAsmStateDb, SledSpecActivationDb,
};
Comment thread
prajwolrg marked this conversation as resolved.
use bitcoin::{Block, BlockHash, Network, block::Header};
use bitcoind_async_client::{Client, traits::Reader};
use strata_asm_common::{AnchorState, AsmManifest, AsmManifestHash, AuxData};
use strata_asm_worker::{
AnchorStateStore, AuxDataStore, L1DataProvider, ManifestMmrStore, WorkerError, WorkerResult,
AnchorStateStore, AuxDataStore, L1DataProvider, ManifestMmrStore, SpecActivationRecord,
SpecActivationStore, WorkerError, WorkerResult,
};
use strata_btc_types::{BitcoinTxid, L1BlockIdBitcoinExt, RawBitcoinTx};
use strata_identifiers::{L1BlockCommitment, L1BlockId};
use strata_identifiers::{L1BlockCommitment, L1BlockId, L1Height};
use strata_merkle::MerkleProofB32;
use tokio::runtime::Handle;

Expand All @@ -37,9 +41,14 @@ pub(crate) struct AsmWorkerContext {
aux_db: Arc<SledAsmAuxDataDb>,
manifest_db: Arc<SledAsmManifestDb>,
mmr_db: Arc<SledAsmManifestMmrDb>,
spec_activation_db: Arc<SledSpecActivationDb>,
}

impl AsmWorkerContext {
#[expect(
clippy::too_many_arguments,
reason = "one argument per storage concern"
)]
pub(crate) fn new(
runtime_handle: Handle,
bitcoin_client: Arc<Client>,
Expand All @@ -48,6 +57,7 @@ impl AsmWorkerContext {
aux_db: Arc<SledAsmAuxDataDb>,
manifest_db: Arc<SledAsmManifestDb>,
mmr_db: Arc<SledAsmManifestMmrDb>,
spec_activation_db: Arc<SledSpecActivationDb>,
) -> Self {
Self {
runtime_handle,
Expand All @@ -58,6 +68,7 @@ impl AsmWorkerContext {
aux_db,
manifest_db,
mmr_db,
spec_activation_db,
}
}
}
Expand Down Expand Up @@ -219,6 +230,41 @@ impl ManifestMmrStore for AsmWorkerContext {
}
}

impl SpecActivationStore for AsmWorkerContext {
fn record_spec_activation(&self, activation: SpecActivationRecord) -> WorkerResult<()> {
self.spec_activation_db
.put(
activation.enacting_height(),
activation.version().into(),
activation.new_predicate(),
)
.map_err(WorkerError::DbError)
}

fn list_spec_activations(&self) -> WorkerResult<Vec<SpecActivationRecord>> {
self.spec_activation_db
.list()
.map_err(WorkerError::DbError)?
.into_iter()
.map(|(enacting_height, version, new_predicate)| {
SpecActivationRecord::from_raw(enacting_height, version, new_predicate).map_err(
|id| {
WorkerError::DbError(anyhow!(
"unknown spec version {id} in spec activation store"
))
},
)
})
.collect()
}

fn prune_spec_activations_after(&self, after_height: L1Height) -> WorkerResult<()> {
self.spec_activation_db
.prune_after(after_height)
.map_err(WorkerError::DbError)
}
}

impl AuxDataStore for AsmWorkerContext {
fn store_aux_data(&self, blockid: &L1BlockCommitment, data: &AuxData) -> WorkerResult<()> {
self.aux_db.put(blockid, data).map_err(WorkerError::DbError)
Expand Down
2 changes: 0 additions & 2 deletions crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ strata-msg-fmt.workspace = true

bitcoin.workspace = true
borsh.workspace = true
serde.workspace = true
ssz.workspace = true
ssz_derive.workspace = true
ssz_types.workspace = true
Expand All @@ -27,6 +26,5 @@ tracing.workspace = true
zkaleido-logging.workspace = true

[dev-dependencies]
serde_json.workspace = true
strata-identifiers.workspace = true
strata-test-utils-arb.workspace = true
2 changes: 0 additions & 2 deletions crates/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ mod msg;
mod section;
pub mod sorted_vec;
mod spec;
mod spec_id;
mod subprotocol;
mod tx;

Expand All @@ -20,7 +19,6 @@ pub use manifest::*;
pub use msg::*;
pub use section::*;
pub use spec::*;
pub use spec_id::*;
// Re-export the anchor state types so downstream crates keep a single import path.
pub use strata_asm_state::*;
pub use subprotocol::*;
Expand Down
Loading
Loading