mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-02-18 20:33:13 +00:00
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:
commit
dee3f7fa6f
15
README.md
15
README.md
@ -129,9 +129,8 @@ RUST_LOG=info RISC0_DEV_MODE=1 cargo run $(pwd)/configs/debug all
|
|||||||
|
|
||||||
|
|
||||||
## Running Manually
|
## Running Manually
|
||||||
|
### Normal mode
|
||||||
The sequencer and node can be run locally:
|
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:
|
1. On one terminal go to the `logos-blockchain/logos-blockchain` repo and run a local logos blockchain node:
|
||||||
- `git checkout master; git pull`
|
- `git checkout master; git pull`
|
||||||
- `cargo clean`
|
- `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`
|
- `./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:
|
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:
|
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
|
## Running with Docker
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,9 @@ pub mod indexer_client;
|
|||||||
#[cfg(feature = "mock")]
|
#[cfg(feature = "mock")]
|
||||||
pub mod mock;
|
pub mod mock;
|
||||||
|
|
||||||
|
#[cfg(feature = "mock")]
|
||||||
|
pub use mock::SequencerCoreWithMockClients;
|
||||||
|
|
||||||
pub struct SequencerCore<
|
pub struct SequencerCore<
|
||||||
BC: BlockSettlementClientTrait = BlockSettlementClient,
|
BC: BlockSettlementClientTrait = BlockSettlementClient,
|
||||||
IC: IndexerClientTrait = IndexerClient,
|
IC: IndexerClientTrait = IndexerClient,
|
||||||
|
|||||||
@ -27,3 +27,8 @@ borsh.workspace = true
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
sequencer_core = { workspace = true, features = ["mock"] }
|
sequencer_core = { workspace = true, features = ["mock"] }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = []
|
||||||
|
# Includes types to run the sequencer in standalone mode
|
||||||
|
standalone = ["sequencer_core/mock"]
|
||||||
|
|||||||
@ -49,3 +49,9 @@ pub fn rpc_error_responce_inverter(err: RpcError) -> RpcError {
|
|||||||
data: content,
|
data: content,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "standalone")]
|
||||||
|
use sequencer_core::mock::{MockBlockSettlementClient, MockIndexerClient};
|
||||||
|
|
||||||
|
#[cfg(feature = "standalone")]
|
||||||
|
pub type JsonHandlerWithMockClients = JsonHandler<MockBlockSettlementClient, MockIndexerClient>;
|
||||||
|
|||||||
@ -9,10 +9,19 @@ use common::{
|
|||||||
use futures::{Future, FutureExt};
|
use futures::{Future, FutureExt};
|
||||||
use log::info;
|
use log::info;
|
||||||
use mempool::MemPoolHandle;
|
use mempool::MemPoolHandle;
|
||||||
|
#[cfg(not(feature = "standalone"))]
|
||||||
use sequencer_core::SequencerCore;
|
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 tokio::sync::Mutex;
|
||||||
|
|
||||||
use super::JsonHandler;
|
|
||||||
use crate::process::Process;
|
use crate::process::Process;
|
||||||
|
|
||||||
pub const SHUTDOWN_TIMEOUT_SECS: u64 = 10;
|
pub const SHUTDOWN_TIMEOUT_SECS: u64 = 10;
|
||||||
|
|||||||
@ -18,3 +18,8 @@ actix.workspace = true
|
|||||||
actix-web.workspace = true
|
actix-web.workspace = true
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
futures.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"]
|
||||||
|
|||||||
@ -5,11 +5,14 @@ use anyhow::{Context as _, Result};
|
|||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use common::rpc_primitives::RpcConfig;
|
use common::rpc_primitives::RpcConfig;
|
||||||
use futures::{FutureExt as _, never::Never};
|
use futures::{FutureExt as _, never::Never};
|
||||||
use log::{error, info, warn};
|
#[cfg(not(feature = "standalone"))]
|
||||||
use sequencer_core::{
|
use log::warn;
|
||||||
SequencerCore, block_settlement_client::BlockSettlementClientTrait as _,
|
use log::{error, info};
|
||||||
config::SequencerConfig,
|
#[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 sequencer_rpc::new_http_server;
|
||||||
use tokio::{sync::Mutex, task::JoinHandle};
|
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(
|
async fn retry_pending_blocks_loop(
|
||||||
seq_core: Arc<Mutex<SequencerCore>>,
|
seq_core: Arc<Mutex<SequencerCore>>,
|
||||||
retry_pending_blocks_timeout: Duration,
|
retry_pending_blocks_timeout: Duration,
|
||||||
@ -180,8 +184,8 @@ async fn retry_pending_blocks_loop(
|
|||||||
"Resubmitting pending block with id {}",
|
"Resubmitting pending block with id {}",
|
||||||
block.header.block_id
|
block.header.block_id
|
||||||
);
|
);
|
||||||
// TODO: We could cache the inscribe tx for each pending block to avoid re-creating it
|
// TODO: We could cache the inscribe tx for each pending block to avoid re-creating
|
||||||
// on every retry.
|
// it on every retry.
|
||||||
let (tx, _msg_id) = block_settlement_client
|
let (tx, _msg_id) = block_settlement_client
|
||||||
.create_inscribe_tx(block)
|
.create_inscribe_tx(block)
|
||||||
.context("Failed to create inscribe tx for pending 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> {
|
async fn listen_for_bedrock_blocks_loop(seq_core: Arc<Mutex<SequencerCore>>) -> Result<Never> {
|
||||||
use indexer_service_rpc::RpcClient as _;
|
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<()> {
|
pub async fn main_runner() -> Result<()> {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user