Merge pull request #337 from logos-blockchain/schouhy/standalone-sequencer-with-mock

Add `standalone` feature for running sequencer without Bedrock and indexer services.
This commit is contained in:
Moudy 2026-02-18 09:11:15 +01:00 committed by GitHub
commit dee3f7fa6f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 64 additions and 13 deletions

View File

@ -129,9 +129,8 @@ RUST_LOG=info RISC0_DEV_MODE=1 cargo run $(pwd)/configs/debug all
## Running Manually
The sequencer and node can be run locally:
### Normal mode
The sequencer and logos blockchain node can be run locally:
1. On one terminal go to the `logos-blockchain/logos-blockchain` repo and run a local logos blockchain node:
- `git checkout master; git pull`
- `cargo clean`
@ -141,10 +140,16 @@ The sequencer and node can be run locally:
- `./target/debug/logos-blockchain-node --deployment nodes/node/standalone-deployment-config.yaml nodes/node/standalone-node-config.yaml`
2. On another terminal go to the `logos-blockchain/lssa` repo and run indexer service:
- `RUST_LOG=info cargo run --release -p indexer_service indexer/service/configs/indexer_config.json`
- `RUST_LOG=info cargo run -p indexer_service indexer/service/configs/indexer_config.json`
3. On another terminal go to the `logos-blockchain/lssa` repo and run the sequencer:
- `RUST_LOG=info RISC0_DEV_MODE=1 cargo run --release -p sequencer_runner sequencer_runner/configs/debug`
- `RUST_LOG=info cargo run -p sequencer_runner sequencer_runner/configs/debug`
### Standalone mode
The sequencer can be run in standalone mode with:
```bash
RUST_LOG=info cargo run --features standalone -p sequencer_runner sequencer_runner/configs/debug
```
## Running with Docker

View File

@ -28,6 +28,9 @@ pub mod indexer_client;
#[cfg(feature = "mock")]
pub mod mock;
#[cfg(feature = "mock")]
pub use mock::SequencerCoreWithMockClients;
pub struct SequencerCore<
BC: BlockSettlementClientTrait = BlockSettlementClient,
IC: IndexerClientTrait = IndexerClient,

View File

@ -27,3 +27,8 @@ borsh.workspace = true
[dev-dependencies]
sequencer_core = { workspace = true, features = ["mock"] }
[features]
default = []
# Includes types to run the sequencer in standalone mode
standalone = ["sequencer_core/mock"]

View File

@ -49,3 +49,9 @@ pub fn rpc_error_responce_inverter(err: RpcError) -> RpcError {
data: content,
}
}
#[cfg(feature = "standalone")]
use sequencer_core::mock::{MockBlockSettlementClient, MockIndexerClient};
#[cfg(feature = "standalone")]
pub type JsonHandlerWithMockClients = JsonHandler<MockBlockSettlementClient, MockIndexerClient>;

View File

@ -9,10 +9,19 @@ use common::{
use futures::{Future, FutureExt};
use log::info;
use mempool::MemPoolHandle;
#[cfg(not(feature = "standalone"))]
use sequencer_core::SequencerCore;
#[cfg(feature = "standalone")]
use sequencer_core::SequencerCoreWithMockClients as SequencerCore;
#[cfg(not(feature = "standalone"))]
use super::JsonHandler;
#[cfg(feature = "standalone")]
type JsonHandler = super::JsonHandlerWithMockClients;
use tokio::sync::Mutex;
use super::JsonHandler;
use crate::process::Process;
pub const SHUTDOWN_TIMEOUT_SECS: u64 = 10;

View File

@ -18,3 +18,8 @@ actix.workspace = true
actix-web.workspace = true
tokio.workspace = true
futures.workspace = true
[features]
default = []
# Runs the sequencer in standalone mode without depending on Bedrock and Indexer services.
standalone = ["sequencer_core/mock", "sequencer_rpc/standalone"]

View File

@ -5,11 +5,14 @@ use anyhow::{Context as _, Result};
use clap::Parser;
use common::rpc_primitives::RpcConfig;
use futures::{FutureExt as _, never::Never};
use log::{error, info, warn};
use sequencer_core::{
SequencerCore, block_settlement_client::BlockSettlementClientTrait as _,
config::SequencerConfig,
};
#[cfg(not(feature = "standalone"))]
use log::warn;
use log::{error, info};
#[cfg(feature = "standalone")]
use sequencer_core::SequencerCoreWithMockClients as SequencerCore;
use sequencer_core::config::SequencerConfig;
#[cfg(not(feature = "standalone"))]
use sequencer_core::{SequencerCore, block_settlement_client::BlockSettlementClientTrait as _};
use sequencer_rpc::new_http_server;
use tokio::{sync::Mutex, task::JoinHandle};
@ -156,6 +159,7 @@ async fn main_loop(seq_core: Arc<Mutex<SequencerCore>>, block_timeout: Duration)
}
}
#[cfg(not(feature = "standalone"))]
async fn retry_pending_blocks_loop(
seq_core: Arc<Mutex<SequencerCore>>,
retry_pending_blocks_timeout: Duration,
@ -180,8 +184,8 @@ async fn retry_pending_blocks_loop(
"Resubmitting pending block with id {}",
block.header.block_id
);
// TODO: We could cache the inscribe tx for each pending block to avoid re-creating it
// on every retry.
// TODO: We could cache the inscribe tx for each pending block to avoid re-creating
// it on every retry.
let (tx, _msg_id) = block_settlement_client
.create_inscribe_tx(block)
.context("Failed to create inscribe tx for pending block")?;
@ -199,6 +203,7 @@ async fn retry_pending_blocks_loop(
}
}
#[cfg(not(feature = "standalone"))]
async fn listen_for_bedrock_blocks_loop(seq_core: Arc<Mutex<SequencerCore>>) -> Result<Never> {
use indexer_service_rpc::RpcClient as _;
@ -235,6 +240,19 @@ async fn listen_for_bedrock_blocks_loop(seq_core: Arc<Mutex<SequencerCore>>) ->
}
}
#[cfg(feature = "standalone")]
async fn listen_for_bedrock_blocks_loop(_seq_core: Arc<Mutex<SequencerCore>>) -> Result<Never> {
std::future::pending::<Result<Never>>().await
}
#[cfg(feature = "standalone")]
async fn retry_pending_blocks_loop(
_seq_core: Arc<Mutex<SequencerCore>>,
_retry_pending_blocks_timeout: Duration,
) -> Result<Never> {
std::future::pending::<Result<Never>>().await
}
pub async fn main_runner() -> Result<()> {
env_logger::init();