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
22 changes: 22 additions & 0 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Shellcheck

on:
pull_request:
branches: ["**"]

permissions: {}

jobs:
shellcheck:
name: Verify shell scripts with Shellcheck
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
with:
persist-credentials: false

- name: Run ShellCheck
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38
env:
SHELLCHECK_OPTS: -x # allow outside sources
18 changes: 17 additions & 1 deletion .justfile
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ ensure-codespell:
exit 1
fi

# Check if shellcheck is installed
[group('prerequisites')]
ensure-shellcheck:
#!/usr/bin/env bash
if ! command -v shellcheck &> /dev/null;
then
echo "shellcheck not found. Please install it. See: https://www.shellcheck.net/"
exit 1
fi

# Check if uv is installed
[group('prerequisites')]
ensure-uv:
Expand Down Expand Up @@ -262,14 +272,20 @@ lint-check-toml: ensure-taplo
lint-check-func-tests: ensure-uv activate-uv
cd {{functional_tests_dir}} && uv run ruff check

# Lints shell scripts
[group('code-quality')]
lint-check-shell: ensure-shellcheck
@echo "Linting shell scripts..."
@find . -type f \( -name '*.sh' -o -name '*.bash' \) -not -path "./target/*" -not -path "./.git/*" -not -path "./.ropeproject/*" -not -path "./functional-tests/.venv/*" -execdir shellcheck -x {} +

# Lints the functional tests and applies fixes where possible
[group('code-quality')]
lint-fix-func-tests: ensure-uv activate-uv
cd {{functional_tests_dir}} && uv run ruff check --fix

# Runs all lints and checks for issues without trying to fix them
[group('code-quality')]
lint: fmt-check-ws fmt-check-func-tests fmt-check-toml lint-check-ws lint-check-func-tests lint-check-codespell
lint: fmt-check-ws fmt-check-func-tests fmt-check-toml lint-check-ws lint-check-func-tests lint-check-codespell lint-check-shell
@echo "\n\033[36m======== OK: Lints and Formatting ========\033[0m\n"

# Runs all lints and applies fixes where possible
Expand Down
55 changes: 55 additions & 0 deletions Cargo.lock

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

14 changes: 13 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
resolver = "2"

members = [
"crates/acct-types",
"crates/asm/common",
"crates/asm/logs",
"crates/asm/stf",
Expand All @@ -25,6 +26,9 @@ members = [
"crates/db-store-sled",
"crates/db-store-rocksdb",
"crates/db-tests",
"crates/ee-acct-runtime",
"crates/ee-acct-types",
"crates/ee-chain-types",
"crates/eectl",
"crates/evmexec",
"crates/key-derivation",
Expand All @@ -47,6 +51,8 @@ members = [
"crates/rpc/utils",
"crates/sequencer",
"crates/service",
"crates/snark-acct-types",
"crates/services/stf-runner",
"crates/state",
"crates/status",
"crates/storage",
Expand Down Expand Up @@ -109,7 +115,7 @@ alpen-reth-node = { path = "crates/reth/node" }
alpen-reth-primitives = { path = "crates/reth/primitives" }
alpen-reth-rpc = { path = "crates/reth/rpc" }
alpen-reth-statediff = { path = "crates/reth/statediff" }
rlp = "0.5.2"
strata-acct-types = { path = "crates/acct-types" }
strata-asm-common = { path = "crates/asm/common" }
strata-asm-logs = { path = "crates/asm/logs" }
strata-asm-moho-program-impl = { path = "crates/asm/moho-program" }
Expand All @@ -134,6 +140,9 @@ strata-db = { path = "crates/db" }
strata-db-store-rocksdb = { path = "crates/db-store-rocksdb" }
strata-db-store-sled = { path = "crates/db-store-sled" }
strata-db-tests = { path = "crates/db-tests" }
strata-ee-acct-runtime = { path = "crates/ee-acct-runtime" }
strata-ee-acct-types = { path = "crates/ee-acct-types" }
strata-ee-chain-types = { path = "crates/ee-chain-types" }
strata-eectl = { path = "crates/eectl" }
strata-evmexec = { path = "crates/evmexec" }
strata-key-derivation = { path = "crates/key-derivation" }
Expand All @@ -150,8 +159,10 @@ strata-rpc-types = { path = "crates/rpc/types" }
strata-rpc-utils = { path = "crates/rpc/utils" }
strata-sequencer = { path = "crates/sequencer" }
strata-service = { path = "crates/service" }
strata-snark-acct-types = { path = "crates/snark-acct-types" }
strata-state = { path = "crates/state" }
strata-status = { path = "crates/status" }
strata-stf-runner = { path = "crates/services/stf-runner" }
strata-storage = { path = "crates/storage" }
strata-sync = { path = "crates/sync" }
strata-tasks = { path = "crates/tasks" }
Expand Down Expand Up @@ -334,6 +345,7 @@ reqwest = { version = "0.12.7", default-features = false, features = [
"zstd",
"json",
] }
rlp = "0.5.2"
rockbound = { git = "https://github.com/alpenlabs/rockbound", rev = "v2.0.1-alpen.3" }
secp256k1 = { version = "0.29.1", features = ["global-context", "std"] }
serde = { version = "1.0", features = ["derive"] }
Expand Down
9 changes: 9 additions & 0 deletions crates/acct-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "strata-acct-types"
version = "0.1.0"
edition = "2024"

[dependencies]

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/acct-types/src/constants.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/// Total number of system reserved accounts, which is the space where we do special casing of
/// things.
pub const SYSTEM_RESERVED_ACCTS: u32 = 128;
11 changes: 11 additions & 0 deletions crates/acct-types/src/id.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// Universal account identifier.
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct AcctId([u8; 32]);

/// Incrementally assigned account serial number.
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct AcctSerial(u32);

/// Identifier for a "subject" within the scope of an execution environment.
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct SubjectId([u8; 32]);
7 changes: 7 additions & 0 deletions crates/acct-types/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mod constants;
mod id;
mod messages;

pub use constants::SYSTEM_RESERVED_ACCTS;
pub use id::{AcctId, AcctSerial, SubjectId};
pub use messages::{AcctMessage, MessageData};
18 changes: 18 additions & 0 deletions crates/acct-types/src/messages.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//! Account message types.

use crate::id::AcctId;

/// General message type, not designed for a particular context.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct AcctMessage {
sender: AcctId,
receiver: AcctId,
data: MessageData,
}

/// "Contents" of a message, the payload and sent value.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct MessageData {
value: u64, // TODO convert to BitcoinAmount
payload: Vec<u8>,
}
6 changes: 6 additions & 0 deletions crates/asm/common/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ where
pub actual: T,
}

impl<T: Debug + Display> Mismatched<T> {
pub fn new(expected: T, actual: T) -> Self {
Self { expected, actual }
}
}

/// Errors that can occur while working with ASM subprotocols.
#[derive(Debug, Error)]
pub enum AsmError {
Expand Down
16 changes: 8 additions & 8 deletions crates/asm/logs/src/checkpoint.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
use borsh::{BorshDeserialize, BorshSerialize};
use strata_asm_common::AsmLog;
use strata_msg_fmt::TypeId;
use strata_primitives::{l1::L1BlockCommitment, l2::L2BlockCommitment};
use strata_primitives::{epoch::EpochCommitment, l1::L1BlockCommitment};

use crate::constants::CHECKPOINT_UPDATE_LOG_TYPE;

/// Details for a checkpoint update event.
#[derive(Debug, Clone, BorshSerialize, BorshDeserialize)]
pub struct CheckpointUpdate {
pub struct CheckpointUpdateLog {
/// L1 block commitment reference.
pub l1_ref: L1BlockCommitment,
/// Verified L2 block commitment reference.
pub verified_blk: L2BlockCommitment,
/// Epoch Commitment
pub epoch_commitment: EpochCommitment,
}

impl CheckpointUpdate {
impl CheckpointUpdateLog {
/// Create a new CheckpointUpdate instance.
pub fn new(l1_ref: L1BlockCommitment, verified_blk: L2BlockCommitment) -> Self {
pub fn new(l1_ref: L1BlockCommitment, epoch_commitment: EpochCommitment) -> Self {
Self {
l1_ref,
verified_blk,
epoch_commitment,
}
}
}

impl AsmLog for CheckpointUpdate {
impl AsmLog for CheckpointUpdateLog {
const TY: TypeId = CHECKPOINT_UPDATE_LOG_TYPE;
}
2 changes: 1 addition & 1 deletion crates/asm/logs/src/deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::constants::DEPOSIT_LOG_TYPE_ID;
#[derive(Debug, Clone, BorshSerialize, BorshDeserialize)]
pub struct DepositLog {
/// Identifier of the target execution environment.
pub ee_id: u64,
pub ee_id: u64, // TODO: rename to acc_id/acc_serial. And type to u32 ?
/// Amount in satoshis.
pub amount: u64,
/// Serialized address for the operation.
Expand Down
2 changes: 1 addition & 1 deletion crates/asm/logs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub mod export;
pub mod forced_inclusion;

pub use asm_stf::AsmStfUpdate;
pub use checkpoint::CheckpointUpdate;
pub use checkpoint::CheckpointUpdateLog;
pub use deposit::DepositLog;
pub use export::NewExportEntry;
pub use forced_inclusion::ForcedInclusionData;
6 changes: 2 additions & 4 deletions crates/chain-worker/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,6 @@ impl<W: WorkerContext + Send + Sync + 'static> ChainWorkerServiceState<W> {
.fetch_block(block.blkid())?
.ok_or(WorkerError::MissingL2Block(*block.blkid()))?;

let is_epoch_terminal = !bundle.body().l1_segment().new_manifests().is_empty();

let parent_blkid = bundle.header().header().parent();
let parent_header = context
.fetch_header(parent_blkid)?
Expand All @@ -201,8 +199,8 @@ impl<W: WorkerContext + Send + Sync + 'static> ChainWorkerServiceState<W> {

let output = chain_exec.verify_block(&header_ctx, bundle.body(), &exec_ctx)?;

if is_epoch_terminal {
debug!(%is_epoch_terminal);
if bundle.is_terminal() {
debug!("terminal block");
self.handle_complete_epoch(block.blkid(), bundle.block(), &output)?;
}

Expand Down
16 changes: 16 additions & 0 deletions crates/chain-worker/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ impl StateAccessor for WbStateAccessorImpl {
self.toplevel_chs_cache.set_cur_epoch(epoch);
}

fn set_recorded_epoch(&mut self, _epoch_commitment: EpochCommitment) {
todo!()
}

fn set_l1_view(&mut self, l1_view: ()) {
todo!()
}

fn prev_epoch(&self) -> EpochCommitment {
*self.toplevel_chs_cache.state().prev_epoch()
}
Expand Down Expand Up @@ -80,4 +88,12 @@ impl StateAccessor for WbStateAccessorImpl {
fn set_epoch_finishing_flag(&mut self, flag: bool) {
self.toplevel_chs_cache.set_epoch_finishing_flag(flag);
}

fn get_toplevel_state(&mut self) -> &Chainstate {
self.toplevel_chs_cache.state()
}

fn set_accounts_root(&mut self, _root: Buf32) {
todo!()
}
}
Loading