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
512 changes: 266 additions & 246 deletions Cargo.lock

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,34 +82,34 @@ strata-test-utils-arb = { path = "crates/test-utils/arb" }
strata-test-utils-btc = { path = "crates/test-utils/btc" }
strata-test-utils-btcio = { path = "crates/test-utils/btcio" }

# Dependencies from alpenlabs/alpen pinned to commit 787b804 (main @ 2026-03-17)
# NOTE: keep `typed-sled` pinned in Cargo.lock to 9062bff for compatibility with this alpen rev.
# Newer typed-sled commits can break transitive crates (e.g. `strata-db-store-sled`) in test builds.
strata-bridge-types = { git = "https://github.com/alpenlabs/alpen.git", rev = "787b804c41800bbbf8d3632637a7eda332fc9f39" }
strata-btc-types = { git = "https://github.com/alpenlabs/alpen.git", rev = "787b804c41800bbbf8d3632637a7eda332fc9f39" }
strata-checkpoint-types = { git = "https://github.com/alpenlabs/alpen.git", rev = "787b804c41800bbbf8d3632637a7eda332fc9f39" }
strata-checkpoint-types-ssz = { git = "https://github.com/alpenlabs/alpen.git", rev = "787b804c41800bbbf8d3632637a7eda332fc9f39" }
strata-codec-utils = { git = "https://github.com/alpenlabs/alpen.git", rev = "787b804c41800bbbf8d3632637a7eda332fc9f39" }
strata-crypto = { git = "https://github.com/alpenlabs/alpen.git", rev = "787b804c41800bbbf8d3632637a7eda332fc9f39" }
strata-db-store-sled = { git = "https://github.com/alpenlabs/alpen.git", rev = "787b804c41800bbbf8d3632637a7eda332fc9f39" }
strata-identifiers = { git = "https://github.com/alpenlabs/alpen.git", rev = "787b804c41800bbbf8d3632637a7eda332fc9f39" }
strata-ol-chain-types-new = { git = "https://github.com/alpenlabs/alpen.git", rev = "787b804c41800bbbf8d3632637a7eda332fc9f39" }
strata-ol-chainstate-types = { git = "https://github.com/alpenlabs/alpen.git", rev = "787b804c41800bbbf8d3632637a7eda332fc9f39" }
strata-ol-stf = { git = "https://github.com/alpenlabs/alpen.git", rev = "787b804c41800bbbf8d3632637a7eda332fc9f39" }
strata-primitives = { git = "https://github.com/alpenlabs/alpen.git", rev = "787b804c41800bbbf8d3632637a7eda332fc9f39" }
strata-state = { git = "https://github.com/alpenlabs/alpen.git", rev = "787b804c41800bbbf8d3632637a7eda332fc9f39" }
strata-storage = { git = "https://github.com/alpenlabs/alpen.git", rev = "787b804c41800bbbf8d3632637a7eda332fc9f39" }
strata-test-utils-l2 = { git = "https://github.com/alpenlabs/alpen.git", rev = "787b804c41800bbbf8d3632637a7eda332fc9f39" }
strata-test-utils-ssz = { git = "https://github.com/alpenlabs/alpen.git", rev = "787b804c41800bbbf8d3632637a7eda332fc9f39" }
# Dependencies from alpenlabs/alpen pinned to commit 1cadb7b (main @ 2026-03-20)
strata-acct-types = { git = "https://github.com/alpenlabs/alpen.git", rev = "1cadb7b23a640726d66408dc94c5b60358056b51" }
strata-bridge-types = { git = "https://github.com/alpenlabs/alpen.git", rev = "1cadb7b23a640726d66408dc94c5b60358056b51" }
strata-btc-types = { git = "https://github.com/alpenlabs/alpen.git", rev = "1cadb7b23a640726d66408dc94c5b60358056b51" }
strata-checkpoint-types = { git = "https://github.com/alpenlabs/alpen.git", rev = "1cadb7b23a640726d66408dc94c5b60358056b51" }
strata-checkpoint-types-ssz = { git = "https://github.com/alpenlabs/alpen.git", rev = "1cadb7b23a640726d66408dc94c5b60358056b51" }
strata-codec-utils = { git = "https://github.com/alpenlabs/alpen.git", rev = "1cadb7b23a640726d66408dc94c5b60358056b51" }
strata-crypto = { git = "https://github.com/alpenlabs/alpen.git", rev = "1cadb7b23a640726d66408dc94c5b60358056b51" }
strata-db-store-sled = { git = "https://github.com/alpenlabs/alpen.git", rev = "1cadb7b23a640726d66408dc94c5b60358056b51" }
strata-identifiers = { git = "https://github.com/alpenlabs/alpen.git", rev = "1cadb7b23a640726d66408dc94c5b60358056b51" }
strata-ol-chain-types-new = { git = "https://github.com/alpenlabs/alpen.git", rev = "1cadb7b23a640726d66408dc94c5b60358056b51" }
strata-ol-chainstate-types = { git = "https://github.com/alpenlabs/alpen.git", rev = "1cadb7b23a640726d66408dc94c5b60358056b51" }
strata-ol-stf = { git = "https://github.com/alpenlabs/alpen.git", rev = "1cadb7b23a640726d66408dc94c5b60358056b51" }
strata-primitives = { git = "https://github.com/alpenlabs/alpen.git", rev = "1cadb7b23a640726d66408dc94c5b60358056b51" }
strata-state = { git = "https://github.com/alpenlabs/alpen.git", rev = "1cadb7b23a640726d66408dc94c5b60358056b51" }
strata-storage = { git = "https://github.com/alpenlabs/alpen.git", rev = "1cadb7b23a640726d66408dc94c5b60358056b51" }
strata-test-utils = { git = "https://github.com/alpenlabs/alpen.git", rev = "1cadb7b23a640726d66408dc94c5b60358056b51" }
strata-test-utils-l2 = { git = "https://github.com/alpenlabs/alpen.git", rev = "1cadb7b23a640726d66408dc94c5b60358056b51" }
strata-test-utils-ssz = { git = "https://github.com/alpenlabs/alpen.git", rev = "1cadb7b23a640726d66408dc94c5b60358056b51" }

# Dependencies from alpenlabs/strata-bridge pinned to commit fc966d5 (STR-2598-asm-stf-proof-statements @ 2026-03-17)
btc-tracker = { git = "https://github.com/alpenlabs/strata-bridge.git", rev = "fc966d5f81c773de10a4ef3a66666687ec11d715" }
strata-bridge-common = { git = "https://github.com/alpenlabs/strata-bridge.git", rev = "fc966d5f81c773de10a4ef3a66666687ec11d715" }

# Dependencies from alpenlabs/moho pinned to commit 97e9d28 (main @ 2026-03-12)
moho-runtime-impl = { git = "https://github.com/alpenlabs/moho", rev = "97e9d281f310e9c2e60cf80448c95e855be589b9" }
moho-runtime-interface = { git = "https://github.com/alpenlabs/moho", rev = "97e9d281f310e9c2e60cf80448c95e855be589b9" }
moho-types = { git = "https://github.com/alpenlabs/moho", rev = "97e9d281f310e9c2e60cf80448c95e855be589b9" }
# Dependencies from alpenlabs/moho pinned to commit 97b9f2a (main @ 2026-03-14)
moho-runtime-impl = { git = "https://github.com/alpenlabs/moho", rev = "97b9f2af3bc292857e53b7ab9852ae385d5eff2d" }
moho-runtime-interface = { git = "https://github.com/alpenlabs/moho", rev = "97b9f2af3bc292857e53b7ab9852ae385d5eff2d" }
moho-types = { git = "https://github.com/alpenlabs/moho", rev = "97b9f2af3bc292857e53b7ab9852ae385d5eff2d" }

# dependencies from alpenlabs/strata-common
strata-codec = { git = "https://github.com/alpenlabs/strata-common", features = [
Expand Down
2 changes: 1 addition & 1 deletion bin/asm-runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ anyhow.workspace = true
async-trait.workspace = true
bitcoin.workspace = true
bitcoind-async-client.workspace = true
borsh.workspace = true
clap.workspace = true
futures.workspace = true
jsonrpsee = { workspace = true, features = ["server", "macros"] }
serde.workspace = true
serde_json.workspace = true
ssz.workspace = true
threadpool = "1.8"
tokio.workspace = true
toml.workspace = true
Expand Down
5 changes: 3 additions & 2 deletions bin/asm-runner/src/rpc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use jsonrpsee::{
server::ServerBuilder,
types::{ErrorObject, ErrorObjectOwned},
};
use ssz::Decode;
use strata_asm_proto_bridge_v1::{AssignmentEntry, BridgeV1State, DepositEntry};
use strata_asm_rpc::traits::AssignmentsApiServer;
use strata_asm_txs_bridge_v1::BRIDGE_V1_SUBPROTOCOL_ID;
Expand Down Expand Up @@ -73,8 +74,8 @@ impl AsmRpcServer {
.find_section(BRIDGE_V1_SUBPROTOCOL_ID)
.expect("bridge subprotocol should be enabled");

let bridge_state: BridgeV1State = borsh::from_slice(&bridge_state.data)
.expect("borsh deserialization should be infallible");
let bridge_state = BridgeV1State::from_ssz_bytes(&bridge_state.data)
.expect("bridge state deserialization should be infallible");

Ok(Some(bridge_state))
}
Expand Down
40 changes: 40 additions & 0 deletions crates/btc-verification/src/header_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,46 @@ impl HeaderVerificationState {
}
}

/// Splits the verification state into its raw components.
pub fn into_parts(
self,
) -> (
BtcParams,
L1BlockCommitment,
u32,
u32,
TimestampStore,
BtcWork,
) {
(
self.params,
self.last_verified_block,
self.next_block_target,
self.epoch_start_timestamp,
self.block_timestamp_history,
self.total_accumulated_pow,
)
}

/// Reconstructs the verification state from its raw components.
pub fn from_parts(
params: BtcParams,
last_verified_block: L1BlockCommitment,
next_block_target: u32,
epoch_start_timestamp: u32,
block_timestamp_history: TimestampStore,
total_accumulated_pow: BtcWork,
) -> Self {
Self {
params,
last_verified_block,
next_block_target,
epoch_start_timestamp,
block_timestamp_history,
total_accumulated_pow,
}
}

/// Calculates the next difficulty target based on the current header.
///
/// If this is a difficulty adjustment block (height + 1 is multiple of adjustment interval),
Expand Down
15 changes: 15 additions & 0 deletions crates/btc-verification/src/timestamp_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ impl TimestampStore {
}
}

/// Splits the ring buffer into its raw contents.
pub fn into_parts(self) -> ([u32; TIMESTAMPS_FOR_MEDIAN], usize) {
(self.buffer, self.head)
}

/// Reconstructs the ring buffer from its raw contents.
pub fn from_parts(buffer: [u32; TIMESTAMPS_FOR_MEDIAN], head: usize) -> Self {
assert!(
head < TIMESTAMPS_FOR_MEDIAN,
"timestamp store head must be within buffer bounds"
);

Self { buffer, head }
}

/// Inserts a new timestamp into the buffer, overwriting the oldest timestamp.
/// After insertion, the `head` is advanced in a circular manner.
pub fn insert(&mut self, timestamp: u32) {
Expand Down
12 changes: 12 additions & 0 deletions crates/btc-verification/src/work.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ impl From<Work> for BtcWork {
}
}

impl BtcWork {
/// Returns the wrapped work value as little-endian bytes.
pub fn to_le_bytes(&self) -> [u8; 32] {
self.0.to_le_bytes()
}

/// Reconstructs wrapped work from little-endian bytes.
pub fn from_le_bytes(bytes: [u8; 32]) -> Self {
Self(Work::from_le_bytes(bytes))
}
}

impl AddAssign for BtcWork {
fn add_assign(&mut self, rhs: Self) {
self.0 = self.0 + rhs.0;
Expand Down
10 changes: 10 additions & 0 deletions crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2024"
workspace = true

[dependencies]
strata-acct-types.workspace = true
strata-asm-manifest-types.workspace = true
strata-btc-types.workspace = true
strata-btc-verification.workspace = true
Expand All @@ -18,8 +19,17 @@ strata-msg-fmt.workspace = true
bitcoin.workspace = true
borsh.workspace = true
serde.workspace = true
ssz.workspace = true
ssz_derive.workspace = true
ssz_primitives.workspace = true
ssz_types = { workspace = true, features = ["serde"] }
thiserror.workspace = true
tracing.workspace = true
tree_hash.workspace = true
tree_hash_derive.workspace = true

[build-dependencies]
ssz_codegen.workspace = true

[dev-dependencies]
strata-identifiers.workspace = true
Expand Down
24 changes: 24 additions & 0 deletions crates/common/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use std::{env::var, path::Path};

use ssz_codegen::{ModuleGeneration, build_ssz_files};

fn main() {
let out_dir = var("OUT_DIR").expect("OUT_DIR not set by cargo");
let output_path = Path::new(&out_dir).join("generated.rs");

let entry_points = ["pow.ssz", "state.ssz"];
let base_dir = "ssz";
let crates = ["strata_acct_types", "strata_identifiers"];

build_ssz_files(
&entry_points,
base_dir,
&crates,
output_path.to_str().expect("output path is valid UTF-8"),
ModuleGeneration::NestedModules,
)
.expect("Failed to generate SSZ types");

println!("cargo:rerun-if-changed=ssz/pow.ssz");
println!("cargo:rerun-if-changed=ssz/state.ssz");
}
Loading
Loading