2025-12-31 04:02:25 +03:00
|
|
|
use std::{
|
|
|
|
|
fs::File,
|
|
|
|
|
io::BufReader,
|
|
|
|
|
path::{Path, PathBuf},
|
|
|
|
|
};
|
2024-11-25 07:26:16 +02:00
|
|
|
|
2025-12-31 04:02:25 +03:00
|
|
|
use anyhow::Result;
|
2026-01-29 22:20:42 +03:00
|
|
|
pub use bedrock_client::BackoffConfig;
|
|
|
|
|
use common::config::BasicAuth;
|
2026-01-27 08:13:53 +02:00
|
|
|
use logos_blockchain_core::mantle::ops::channel::ChannelId;
|
2026-01-29 22:20:42 +03:00
|
|
|
use nssa::AccountId;
|
2025-11-26 00:27:20 +03:00
|
|
|
use serde::{Deserialize, Serialize};
|
2026-01-29 22:20:42 +03:00
|
|
|
use url::Url;
|
2025-11-26 00:27:20 +03:00
|
|
|
|
2025-07-29 14:20:03 +03:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2025-11-26 00:27:20 +03:00
|
|
|
/// Helperstruct for account serialization
|
2025-07-29 14:20:03 +03:00
|
|
|
pub struct AccountInitialData {
|
2026-01-29 22:20:42 +03:00
|
|
|
pub account_id: AccountId,
|
2025-08-07 15:19:06 -03:00
|
|
|
pub balance: u128,
|
2025-07-29 14:20:03 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-24 14:29:56 +03:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2025-11-24 17:09:30 +03:00
|
|
|
/// Helperstruct to initialize commitments
|
2025-09-24 14:29:56 +03:00
|
|
|
pub struct CommitmentsInitialData {
|
|
|
|
|
pub npk: nssa_core::NullifierPublicKey,
|
|
|
|
|
pub account: nssa_core::account::Account,
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-18 19:31:03 +03:00
|
|
|
// TODO: Provide default values
|
2025-07-25 10:00:27 +03:00
|
|
|
#[derive(Clone, Serialize, Deserialize)]
|
2024-11-25 07:26:16 +02:00
|
|
|
pub struct SequencerConfig {
|
2025-11-26 00:27:20 +03:00
|
|
|
/// Home dir of sequencer storage
|
2024-11-25 07:26:16 +02:00
|
|
|
pub home: PathBuf,
|
2025-11-26 00:27:20 +03:00
|
|
|
/// Override rust log (env var logging level)
|
2024-11-28 22:05:14 +02:00
|
|
|
pub override_rust_log: Option<String>,
|
2025-11-26 00:27:20 +03:00
|
|
|
/// Genesis id
|
2024-11-25 07:26:16 +02:00
|
|
|
pub genesis_id: u64,
|
2025-11-26 00:27:20 +03:00
|
|
|
/// If `True`, then adds random sequence of bytes to genesis block
|
2024-11-25 07:26:16 +02:00
|
|
|
pub is_genesis_random: bool,
|
2025-11-26 00:27:20 +03:00
|
|
|
/// Maximum number of transactions in block
|
2024-11-25 07:26:16 +02:00
|
|
|
pub max_num_tx_in_block: usize,
|
2025-11-26 00:27:20 +03:00
|
|
|
/// Mempool maximum size
|
2025-10-23 16:23:47 -03:00
|
|
|
pub mempool_max_size: usize,
|
2025-11-26 00:27:20 +03:00
|
|
|
/// Interval in which blocks produced
|
2024-12-29 14:11:47 +02:00
|
|
|
pub block_create_timeout_millis: u64,
|
2026-01-27 13:27:52 -03:00
|
|
|
/// Interval in which pending blocks are retried
|
|
|
|
|
pub retry_pending_blocks_timeout_millis: u64,
|
2025-11-26 00:27:20 +03:00
|
|
|
/// Port to listen
|
2024-12-29 14:11:47 +02:00
|
|
|
pub port: u16,
|
2025-11-26 00:27:20 +03:00
|
|
|
/// List of initial accounts data
|
2025-07-29 14:20:03 +03:00
|
|
|
pub initial_accounts: Vec<AccountInitialData>,
|
2025-11-26 00:27:20 +03:00
|
|
|
/// List of initial commitments
|
2025-09-24 14:29:56 +03:00
|
|
|
pub initial_commitments: Vec<CommitmentsInitialData>,
|
2025-11-26 00:27:20 +03:00
|
|
|
/// Sequencer own signing key
|
2025-09-03 10:29:51 +03:00
|
|
|
pub signing_key: [u8; 32],
|
2026-01-13 16:53:00 -03:00
|
|
|
/// Bedrock configuration options
|
2026-01-29 22:20:42 +03:00
|
|
|
pub bedrock_config: BedrockConfig,
|
|
|
|
|
/// Indexer RPC URL
|
|
|
|
|
pub indexer_rpc_url: Url,
|
2026-01-13 16:53:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Serialize, Deserialize)]
|
|
|
|
|
pub struct BedrockConfig {
|
2026-01-29 22:20:42 +03:00
|
|
|
/// Fibonacci backoff retry strategy configuration
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub backoff: BackoffConfig,
|
2026-01-13 16:53:00 -03:00
|
|
|
/// Bedrock channel ID
|
2026-01-15 15:44:48 +02:00
|
|
|
pub channel_id: ChannelId,
|
2026-01-13 16:53:00 -03:00
|
|
|
/// Bedrock Url
|
2026-01-29 22:20:42 +03:00
|
|
|
pub node_url: Url,
|
2026-01-27 09:46:31 +02:00
|
|
|
/// Bedrock auth
|
|
|
|
|
pub auth: Option<BasicAuth>,
|
2024-11-25 07:26:16 +02:00
|
|
|
}
|
2025-12-31 04:02:25 +03:00
|
|
|
|
|
|
|
|
impl SequencerConfig {
|
|
|
|
|
pub fn from_path(config_home: &Path) -> Result<SequencerConfig> {
|
|
|
|
|
let file = File::open(config_home)?;
|
|
|
|
|
let reader = BufReader::new(file);
|
|
|
|
|
|
|
|
|
|
Ok(serde_json::from_reader(reader)?)
|
|
|
|
|
}
|
|
|
|
|
}
|