Skip to content

Commit

Permalink
Based Sequencer with Soft Confirmations: deferring blob from execution (
Browse files Browse the repository at this point in the history
#596)

* Introducing blob deferring
* Exposing is_allowed_sequencer method. Filter non registered sequencers
* Add next-test as default runner for `make test`
  • Loading branch information
citizen-stig authored Aug 14, 2023
1 parent f41765a commit 5b634a1
Show file tree
Hide file tree
Showing 22 changed files with 837 additions and 37 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock

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

6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ build: ## Build the the project
clean: ## Cleans compiled
@cargo clean

test: ## Runs test suite with output from tests printed
test-legacy: ## Runs test suite with output from tests printed
@cargo test -- --nocapture -Zunstable-options --report-time

test: ## Runs test suite using next test
@cargo nextest run --workspace --all-features

install-dev-tools: ## Installs all necessary cargo helpers
cargo install cargo-llvm-cov
cargo install cargo-hack
cargo install cargo-udeps
cargo install flaky-finder
cargo install cargo-nextest --locked

lint: ## cargo check and clippy
## fmt first, because it's the cheapest
Expand Down
27 changes: 25 additions & 2 deletions examples/demo-prover/Cargo.lock

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

17 changes: 17 additions & 0 deletions examples/demo-prover/methods/guest/Cargo.lock

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

2 changes: 2 additions & 0 deletions examples/demo-stf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const-rollup-config = { path = "../const-rollup-config" }
sov-rollup-interface = { path = "../../rollup-interface" }
sov-election = { path = "../../module-system/module-implementations/examples/sov-election", default-features = false }
sov-sequencer-registry = { path = "../../module-system/module-implementations/sov-sequencer-registry", default-features = false }
sov-blob-storage = { path = "../../module-system/module-implementations/sov-blob-storage", default-features = false }
sov-bank = { path = "../../module-system/module-implementations/sov-bank", default-features = false }
sov-modules-stf-template = { path = "../../module-system/sov-modules-stf-template" } # no features available
sov-value-setter = { path = "../../module-system/module-implementations/examples/sov-value-setter", default-features = false }
Expand All @@ -56,6 +57,7 @@ native = [
"sov-accounts/native",
"sov-election/native",
"sov-sequencer-registry/native",
"sov-blob-storage/native",
"sov-value-setter/native",
"sov-modules-api/native",
"sov-rollup-interface/mocks",
Expand Down
1 change: 1 addition & 0 deletions examples/demo-stf/src/genesis_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ pub fn create_demo_genesis_config<C: Context>(
GenesisConfig::new(
bank_config,
sequencer_registry_config,
(),
election_config,
value_setter_config,
sov_accounts::AccountConfig { pub_keys: vec![] },
Expand Down
30 changes: 28 additions & 2 deletions examples/demo-stf/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@ use sov_accounts::{AccountsRpcImpl, AccountsRpcServer};
#[cfg(feature = "native")]
use sov_bank::{BankRpcImpl, BankRpcServer};
#[cfg(feature = "native")]
use sov_blob_storage::{BlobStorageRpcImpl, BlobStorageRpcServer};
#[cfg(feature = "native")]
use sov_election::{ElectionRpcImpl, ElectionRpcServer};
#[cfg(feature = "native")]
#[cfg(feature = "experimental")]
use sov_evm::query::{EvmRpcImpl, EvmRpcServer};
use sov_modules_api::capabilities::{BlobRefOrOwned, BlobSelector};
#[cfg(feature = "native")]
pub use sov_modules_api::default_context::DefaultContext;
use sov_modules_api::hooks::SlotHooks;
use sov_modules_api::macros::DefaultRuntime;
#[cfg(feature = "native")]
use sov_modules_api::macros::{expose_rpc, CliWallet};
use sov_modules_api::{Context, DispatchCall, Genesis, MessageCodec};
use sov_modules_api::{Context, DispatchCall, Genesis, MessageCodec, Spec};
use sov_rollup_interface::da::BlobReaderTrait;
use sov_rollup_interface::zk::ValidityCondition;
#[cfg(feature = "native")]
use sov_sequencer_registry::{SequencerRegistryRpcImpl, SequencerRegistryRpcServer};
use sov_state::WorkingSet;
#[cfg(feature = "native")]
use sov_value_setter::{ValueSetterRpcImpl, ValueSetterRpcServer};

Expand All @@ -25,7 +30,7 @@ use sov_value_setter::{ValueSetterRpcImpl, ValueSetterRpcServer};
/// On a high level, the rollup node receives serialized call messages from the DA layer and executes them as atomic transactions.
/// Upon reception, the message has to be deserialized and forwarded to an appropriate module.
///
/// The module specific logic is implemented by module creators, but all the glue code responsible for message
/// The module-specific logic is implemented by module creators, but all the glue code responsible for message
/// deserialization/forwarding is handled by a rollup `runtime`.
///
/// In order to define the runtime we need to specify all the modules supported by our rollup (see the `Runtime` struct bellow)
Expand Down Expand Up @@ -66,6 +71,8 @@ use sov_value_setter::{ValueSetterRpcImpl, ValueSetterRpcServer};
pub struct Runtime<C: Context> {
pub bank: sov_bank::Bank<C>,
pub sequencer_registry: sov_sequencer_registry::SequencerRegistry<C>,
#[cfg_attr(feature = "native", cli_skip)]
pub blob_storage: sov_blob_storage::BlobStorage<C>,
pub election: sov_election::Election<C>,
pub value_setter: sov_value_setter::ValueSetter<C>,
pub accounts: sov_accounts::Accounts<C>,
Expand All @@ -82,6 +89,8 @@ pub struct Runtime<C: Context> {
pub struct Runtime<C: Context> {
pub bank: sov_bank::Bank<C>,
pub sequencer_registry: sov_sequencer_registry::SequencerRegistry<C>,
#[cfg_attr(feature = "native", cli_skip)]
pub blob_storage: sov_blob_storage::BlobStorage<C>,
pub election: sov_election::Election<C>,
pub value_setter: sov_value_setter::ValueSetter<C>,
pub accounts: sov_accounts::Accounts<C>,
Expand Down Expand Up @@ -110,3 +119,20 @@ impl<C: Context, Cond: ValidityCondition> sov_modules_stf_template::Runtime<C, C
for Runtime<C>
{
}

impl<C: Context> BlobSelector for Runtime<C> {
type Context = C;

fn get_blobs_for_this_slot<'a, I, B>(
&self,
current_blobs: I,
working_set: &mut WorkingSet<<Self::Context as Spec>::Storage>,
) -> anyhow::Result<Vec<BlobRefOrOwned<'a, B>>>
where
B: BlobReaderTrait,
I: IntoIterator<Item = &'a mut B>,
{
self.blob_storage
.get_blobs_for_this_slot(current_blobs, working_set)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use sov_chain_state::{ChainState, ChainStateConfig};
use sov_modules_api::capabilities::{BlobRefOrOwned, BlobSelector};
use sov_modules_api::default_context::DefaultContext;
use sov_modules_api::hooks::{ApplyBlobHooks, SlotHooks, TxHooks};
use sov_modules_api::transaction::Transaction;
Expand Down Expand Up @@ -73,6 +74,22 @@ impl<C: Context, Cond: ValidityCondition> SlotHooks<Cond> for TestRuntime<C, Con
fn end_slot_hook(&self, _working_set: &mut WorkingSet<<Self::Context as Spec>::Storage>) {}
}

impl<C: Context, Cond: ValidityCondition> BlobSelector for TestRuntime<C, Cond> {
type Context = C;

fn get_blobs_for_this_slot<'a, I, B>(
&self,
current_blobs: I,
_working_set: &mut WorkingSet<<Self::Context as Spec>::Storage>,
) -> anyhow::Result<Vec<BlobRefOrOwned<'a, B>>>
where
B: BlobReaderTrait,
I: IntoIterator<Item = &'a mut B>,
{
Ok(current_blobs.into_iter().map(Into::into).collect())
}
}

impl<C: Context, Cond: ValidityCondition> Runtime<C, Cond> for TestRuntime<C, Cond> {}

pub(crate) fn create_demo_genesis_config<C: Context, Cond: ValidityCondition>(
Expand Down
28 changes: 26 additions & 2 deletions module-system/module-implementations/sov-blob-storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,40 @@ resolver = "2"

[dependencies]
anyhow = { workspace = true }
borsh = { workspace = true }
bincode = { workspace = true }
tracing = { workspace = true }
hex = { workspace = true }

sov-rollup-interface = { path = "../../../rollup-interface", version = "0.1" }
sov-modules-api = { path = "../../sov-modules-api", version = "0.1", default-features = false, features = ["macros"] }
sov-modules-macros = { path = "../../sov-modules-macros", version = "0.1" }
sov-state = { path = "../../sov-state", version = "0.1", default-features = false }
sov-rollup-interface = { path = "../../../rollup-interface", version = "0.1" }
sov-sequencer-registry = { path = "../sov-sequencer-registry", version = "0.1", default-features = false }


# TODO: these 5 can be deleted, after: https://github.com/Sovereign-Labs/sovereign-sdk/issues/524
serde = { workspace = true, optional = true }
schemars = { workspace = true, optional = true }
serde_json = { workspace = true, optional = true }
jsonrpsee = { workspace = true, optional = true }
clap = { workspace = true, optional = true }

[dev-dependencies]
sov-modules-api = { path = "../../sov-modules-api", version = "0.1" }
sov-rollup-interface = { path = "../../../rollup-interface", features = ["mocks"] }
sov-bank = { path = "../sov-bank", version = "0.1" }
tempfile = { workspace = true }

[features]
default = ["native"]
native = ["sov-modules-api/native", "sov-state/native"]
native = [
"sov-modules-api/native",
"sov-state/native",
"sov-modules-macros/native",
"sov-sequencer-registry/native",
"jsonrpsee",
"schemars",
"serde",
"serde_json",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Blob Storage Module

This module provides a blob storage for a blob that have been deferred from their original slot.

Main purpose of this module is to implement `BlobSelector` rollup capability.

It has no RPC calls and only single RPC query to get module address.
Loading

0 comments on commit 5b634a1

Please sign in to comment.