Skip to content

Commit

Permalink
cleanup sov-sdk codes (#1594)
Browse files Browse the repository at this point in the history
  • Loading branch information
eyusufatik authored Dec 12, 2024
1 parent 716f9c4 commit 435dba1
Show file tree
Hide file tree
Showing 56 changed files with 12 additions and 3,925 deletions.
23 changes: 0 additions & 23 deletions Cargo.lock

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

3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ members = [
"crates/sovereign-sdk/full-node/sov-ledger-rpc",
"crates/sovereign-sdk/full-node/sov-stf-runner",
"crates/sovereign-sdk/full-node/sov-prover-storage-manager",
# Utils
"crates/sovereign-sdk/utils/zk-cycle-macros",
"crates/sovereign-sdk/utils/zk-cycle-utils",
# Module System
"crates/sovereign-sdk/module-system/sov-modules-stf-blueprint",
"crates/sovereign-sdk/module-system/sov-modules-rollup-blueprint",
Expand Down
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ lint: ## cargo check and clippy. Skip clippy on guest code since it's not suppo
dprint check
cargo +nightly fmt --all --check
cargo check --all-targets --all-features
$(MAKE) check-fuzz
SKIP_GUEST_BUILD=1 cargo clippy --all-targets --all-features

lint-fix: ## dprint fmt, cargo fmt, fix and clippy. Skip clippy on guest code since it's not supported by risc0
Expand All @@ -96,9 +95,6 @@ lint-fix: ## dprint fmt, cargo fmt, fix and clippy. Skip clippy on guest code s
check-features: ## Checks that project compiles with all combinations of features.
cargo hack check --workspace --feature-powerset --exclude-features default --all-targets

check-fuzz: ## Checks that fuzz member compiles
$(MAKE) -C crates/sovereign-sdk/fuzz check

check-no-std: ## Checks that project compiles without std
$(MAKE) -C crates/sovereign-sdk/rollup-interface $@
$(MAKE) -C crates/sovereign-sdk/module-system/sov-modules-core $@
Expand Down
14 changes: 7 additions & 7 deletions bin/citrea/src/test_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ use reqwest::header::CONTENT_TYPE;
use sha2::Digest;
use sov_db::ledger_db::{LedgerDB, SharedLedgerOps};
use sov_db::rocks_db_config::RocksdbConfig;
use sov_db::schema::types::StoredTransaction;
use sov_mock_da::MockDaSpec;
#[cfg(test)]
use sov_modules_api::DaSpec;
use sov_rollup_interface::stf::{SoftConfirmationReceipt, TransactionReceipt};
use sov_rollup_interface::stf::SoftConfirmationReceipt;

struct TestExpect {
payload: serde_json::Value,
Expand Down Expand Up @@ -100,12 +101,11 @@ fn test_helper(
});
}

fn batch2_tx_receipts() -> (Vec<TransactionReceipt<u32>>, Vec<Vec<u8>>) {
fn batch2_tx_receipts() -> (Vec<StoredTransaction>, Vec<Vec<u8>>) {
let receipts = (0..260u64)
.map(|i| TransactionReceipt::<u32> {
tx_hash: sha2::Sha256::digest(i.to_string()).into(),
events: vec![],
receipt: 0,
.map(|i| StoredTransaction {
hash: sha2::Sha256::digest(i.to_string()).into(),
body: Some(b"tx body".to_vec()),
})
.collect();
let bodies = (0..260u64).map(|_| b"tx body".to_vec()).collect();
Expand Down Expand Up @@ -144,7 +144,7 @@ fn regular_test_helper(payload: serde_json::Value, expected: &serde_json::Value)
soft_confirmation_signature: vec![],
hash: ::sha2::Sha256::digest(b"batch_receipt2").into(),
prev_hash: ::sha2::Sha256::digest(b"prev_batch_receipt2").into(),
tx_hashes: batch_2_receipts.iter().map(|r| r.tx_hash).collect(),
tx_hashes: batch_2_receipts.iter().map(|r| r.hash).collect(),
pub_key: vec![],
deposit_data: vec!["c44444".as_bytes().to_vec()],
l1_fee_rate: 0,
Expand Down
1 change: 0 additions & 1 deletion crates/fullnode/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use sov_rollup_interface::da::{BlockHeaderTrait, DaSpec};
use sov_rollup_interface::fork::ForkManager;
use sov_rollup_interface::services::da::{DaService, SlotData};
use sov_rollup_interface::spec::SpecId;
pub use sov_rollup_interface::stf::BatchReceipt;
use sov_rollup_interface::stf::StateTransitionFunction;
use sov_rollup_interface::zk::{Zkvm, ZkvmHost};
use sov_stf_runner::InitVariant;
Expand Down
2 changes: 0 additions & 2 deletions crates/sovereign-sdk/adapters/mock-da/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ borsh = { workspace = true, features = ["bytes"] }
bytes = { workspace = true, features = ["serde"] }
serde = { workspace = true }
hex = { workspace = true }
lazy_static = { version = "1.4.0", optional = true }
sha2 = { workspace = true }
tokio = { workspace = true, optional = true }
tokio-util = { workspace = true, optional = true }
Expand All @@ -41,7 +40,6 @@ native = [
"dep:serde_json",
"dep:tokio",
"dep:tokio-util",
"dep:lazy_static",
"dep:tokio-stream",
"dep:futures",
"dep:pin-project",
Expand Down
41 changes: 1 addition & 40 deletions crates/sovereign-sdk/full-node/db/sov-db/src/ledger_db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use serde::de::DeserializeOwned;
use serde::Serialize;
use sov_rollup_interface::da::{DaSpec, SequencerCommitment};
use sov_rollup_interface::fork::{Fork, ForkMigration};
use sov_rollup_interface::services::da::SlotData;
use sov_rollup_interface::stf::{BatchReceipt, SoftConfirmationReceipt, StateDiff};
use sov_rollup_interface::stf::{SoftConfirmationReceipt, StateDiff};
use sov_rollup_interface::zk::Proof;
use sov_schema_db::{Schema, SchemaBatch, SeekKeyEncoder, DB};
use tracing::instrument;
Expand Down Expand Up @@ -63,44 +62,6 @@ pub struct ItemNumbers {
pub batch_number: u64,
}

/// All of the data to be committed to the ledger db for a single slot.
#[derive(Debug)]
pub struct SlotCommit<S: SlotData, B, T> {
slot_data: S,
batch_receipts: Vec<BatchReceipt<B, T>>,
num_txs: usize,
num_events: usize,
}

impl<S: SlotData, B, T> SlotCommit<S, B, T> {
/// Returns a reference to the commit's slot_data
pub fn slot_data(&self) -> &S {
&self.slot_data
}

/// Returns a reference to the commit's batch_receipts
pub fn batch_receipts(&self) -> &[BatchReceipt<B, T>] {
&self.batch_receipts
}

/// Create a new SlotCommit from the given slot data
pub fn new(slot_data: S) -> Self {
Self {
slot_data,
batch_receipts: vec![],
num_txs: 0,
num_events: 0,
}
}
/// Add a `batch` (of transactions) to the commit
pub fn add_batch(&mut self, batch: BatchReceipt<B, T>) {
self.num_txs += batch.tx_receipts.len();
let events_this_batch: usize = batch.tx_receipts.iter().map(|r| r.events.len()).sum();
self.batch_receipts.push(batch);
self.num_events += events_this_batch;
}
}

impl LedgerDB {
/// Open a [`LedgerDB`] (backed by RocksDB) at the specified path.
/// Will take optional column families, used for migration purposes.
Expand Down
38 changes: 2 additions & 36 deletions crates/sovereign-sdk/full-node/sov-stf-runner/src/mock/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
use std::marker::PhantomData;

use sov_modules_api::default_context::DefaultContext;
use sov_modules_api::transaction::Transaction;
use sov_rollup_interface::da::DaSpec;
use sov_rollup_interface::spec::SpecId;
use sov_rollup_interface::stf::{
ApplySequencerCommitmentsOutput, BatchReceipt, SlotResult, SoftConfirmationResult,
StateTransitionError, StateTransitionFunction,
ApplySequencerCommitmentsOutput, SoftConfirmationResult, StateTransitionError,
StateTransitionFunction,
};

/// A mock implementation of the [`StateTransitionFunction`]
Expand All @@ -32,38 +30,6 @@ impl<Da: DaSpec> StateTransitionFunction<Da> for MockStf {
([], ())
}

fn apply_slot<'a, I>(
&self,
_current_spec: SpecId,
_pre_state_root: &[u8; 0],
_base_state: Self::PreState,
_witness: Self::Witness,
_slot_header: &Da::BlockHeader,
_blobs: I,
) -> SlotResult<
Self::StateRoot,
Self::ChangeSet,
Self::BatchReceiptContents,
Self::TxReceiptContents,
Self::Witness,
>
where
I: IntoIterator<Item = &'a mut Da::BlobTransaction>,
{
SlotResult {
state_root: [],
change_set: (),
batch_receipts: vec![BatchReceipt {
hash: [0; 32],
prev_hash: [0; 32],
tx_receipts: vec![],
phantom_data: PhantomData,
}],
witness: (),
state_diff: vec![],
}
}

fn apply_soft_confirmation(
&mut self,
_current_spec: SpecId,
Expand Down
Loading

0 comments on commit 435dba1

Please sign in to comment.