Skip to content
Draft
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
112 changes: 70 additions & 42 deletions Cargo.lock

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

10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ members = [
"crates/logs",
"crates/manifest-types",
"crates/params",
"crates/proof/db",
"crates/extensions/prover/storage",
"crates/extensions/prover/types",
"crates/extensions/prover/worker",
"crates/proof/statements",
"crates/proof/types",
"crates/rpc",
"crates/spec",
"crates/spec-debug",
Expand Down Expand Up @@ -62,9 +63,7 @@ strata-asm-common = { path = "crates/common" }
strata-asm-logs = { path = "crates/logs" }
strata-asm-manifest-types = { path = "crates/manifest-types" }
strata-asm-params = { path = "crates/params" }
strata-asm-proof-db = { path = "crates/proof/db" }
strata-asm-proof-impl = { path = "crates/proof/statements" }
strata-asm-proof-types = { path = "crates/proof/types" }
strata-asm-proto-admin = { path = "crates/subprotocols/admin/subprotocol" }
strata-asm-proto-admin-txs = { path = "crates/subprotocols/admin/txs" }
strata-asm-proto-bridge-v1 = { path = "crates/subprotocols/bridge-v1/subprotocol" }
Expand All @@ -77,6 +76,9 @@ strata-asm-proto-checkpoint-txs = { path = "crates/subprotocols/checkpoint/txs"
strata-asm-proto-checkpoint-types = { path = "crates/subprotocols/checkpoint/types" }
strata-asm-proto-debug-v1 = { path = "crates/subprotocols/debug-v1/subprotocol" }
strata-asm-proto-txs-test-utils = { path = "crates/subprotocols/txs-test-utils" }
strata-asm-prover-storage = { path = "crates/extensions/prover/storage" }
strata-asm-prover-types = { path = "crates/extensions/prover/types" }
strata-asm-prover-worker = { path = "crates/extensions/prover/worker" }
strata-asm-rpc = { path = "crates/rpc" }
strata-asm-spec = { path = "crates/spec" }
strata-asm-spec-debug = { path = "crates/spec-debug" }
Expand Down
25 changes: 4 additions & 21 deletions bin/asm-runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,23 @@ edition = "2024"
workspace = true

[dependencies]
moho-recursive-proof.workspace = true
moho-runtime-impl.workspace = true
moho-runtime-interface.workspace = true
moho-types.workspace = true
strata-asm-rpc.workspace = true
strata-btc-verification.workspace = true

strata-asm-common.workspace = true
strata-asm-logs.workspace = true
strata-asm-params.workspace = true
strata-asm-proof-db.workspace = true
strata-asm-proof-impl.workspace = true
strata-asm-proof-types.workspace = true
strata-asm-proto-bridge-v1.workspace = true
strata-asm-proto-bridge-v1-txs.workspace = true
strata-asm-proto-bridge-v1-types.workspace = true
strata-asm-proto-checkpoint.workspace = true
strata-asm-proto-checkpoint-txs.workspace = true
strata-asm-proto-checkpoint-types.workspace = true
strata-asm-prover-storage.workspace = true
strata-asm-prover-types.workspace = true
strata-asm-prover-worker.workspace = true
strata-asm-spec.workspace = true
strata-asm-worker.workspace = true
strata-btc-types.workspace = true
Expand All @@ -37,43 +35,28 @@ strata-identifiers.workspace = true
strata-merkle.workspace = true
strata-predicate.workspace = true
strata-tasks.workspace = true
tree_hash.workspace = true

anyhow.workspace = true
async-trait.workspace = true
bincode = { workspace = true, optional = true }
bitcoin.workspace = true
bitcoincore-zmq = { version = "1.5.2", features = ["async"] }
bitcoind-async-client.workspace = true
clap.workspace = true
futures.workspace = true
hex.workspace = true
jsonrpsee = { workspace = true, features = ["server", "macros"] }
k256 = { workspace = true, features = ["schnorr"] }
serde.workspace = true
serde_json.workspace = true
sled.workspace = true
sp1-sdk = { workspace = true, optional = true }
sp1-verifier = { workspace = true, optional = true }
ssz.workspace = true
thiserror.workspace = true
tokio.workspace = true
toml.workspace = true
tracing.workspace = true
zkaleido.workspace = true
zkaleido-native-adapter.workspace = true
zkaleido-sp1-groth16-verifier = { workspace = true, optional = true }
zkaleido-sp1-host = { workspace = true, optional = true }

[dev-dependencies]
tempfile.workspace = true

[features]
default = []
sp1 = [
"dep:zkaleido-sp1-host",
"dep:zkaleido-sp1-groth16-verifier",
"dep:sp1-verifier",
"dep:sp1-sdk",
"dep:bincode",
]
sp1 = ["strata-asm-prover-worker/sp1"]
31 changes: 9 additions & 22 deletions bin/asm-runner/src/block_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ use bitcoin::Block;
use bitcoincore_zmq::{Message, SocketMessage, subscribe_async_wait_handshake};
use bitcoind_async_client::{Client, traits::Reader};
use futures::StreamExt;
use strata_asm_proof_types::{L1Range, ProofId};
use strata_asm_worker::AsmWorkerHandle;
use strata_btc_types::BlockHashExt;
use strata_identifiers::L1BlockCommitment;
use strata_tasks::ShutdownGuard;
use tokio::{sync::mpsc, time::timeout};
use tokio::time::timeout;
use tracing::{debug, error, info, warn};

use crate::config::BitcoinConfig;
Expand All @@ -37,7 +36,6 @@ pub(crate) async fn drive_asm_from_bitcoin(
bitcoin_client: Arc<Client>,
asm_worker: Arc<AsmWorkerHandle>,
start_height: u64,
proof_tx: Option<mpsc::UnboundedSender<ProofId>>,
shutdown: ShutdownGuard,
) -> Result<()> {
info!(%start_height, "starting ASM block watcher");
Expand Down Expand Up @@ -105,7 +103,7 @@ pub(crate) async fn drive_asm_from_bitcoin(
for height in cursor..received_height {
match fetch_block_at_height(&bitcoin_client, height).await {
Ok(fetched) => {
if let Err(err) = submit_block(&asm_worker, &proof_tx, fetched).await {
if let Err(err) = submit_block(&asm_worker, fetched).await {
error!(%height, ?err, "failed to submit backfill block");
// Stop backfilling on failure so we don't hand the
// worker a gap. The next ZMQ event will retry.
Expand All @@ -120,7 +118,7 @@ pub(crate) async fn drive_asm_from_bitcoin(
}
}

if let Err(err) = submit_block(&asm_worker, &proof_tx, block).await {
if let Err(err) = submit_block(&asm_worker, block).await {
error!(%received_height, ?err, "failed to submit block from ZMQ");
}
cursor = received_height + 1;
Expand All @@ -140,12 +138,12 @@ async fn fetch_block_at_height(client: &Client, height: u64) -> Result<Block> {
Ok(block)
}

/// Submit a block to the ASM worker and, optionally, enqueue a proof request.
async fn submit_block(
asm_worker: &AsmWorkerHandle,
proof_tx: &Option<mpsc::UnboundedSender<ProofId>>,
block: Block,
) -> Result<()> {
/// Submit a block to the ASM worker.
///
/// Proof requests are not issued here: the prover worker subscribes to the ASM
/// worker's commit stream and derives them from each *committed* block, so they
/// fire only after the block is durably stored.
async fn submit_block(asm_worker: &AsmWorkerHandle, block: Block) -> Result<()> {
let height = block.bip34_block_height().unwrap_or(0);
let hash = block.block_hash();
let block_id = hash.to_l1_block_id();
Expand All @@ -158,16 +156,5 @@ async fn submit_block(

debug!(%height, %hash, "submitted block to ASM worker");

if let Some(tx) = proof_tx {
let asm_proof_id = ProofId::Asm(L1Range::single(commitment));
if let Err(err) = tx.send(asm_proof_id) {
warn!(%height, %hash, ?err, "failed to enqueue ASM proof request");
}
let moho_proof_id = ProofId::Moho(commitment);
if let Err(err) = tx.send(moho_proof_id) {
warn!(%height, %hash, ?err, "failed to enqueue Moho proof request");
}
}

Ok(())
}
Loading
Loading