From 1aac509f64b3e59ad8a9c2861b38ef9d93735ea9 Mon Sep 17 00:00:00 2001 From: jfldde <168934971+jfldde@users.noreply.github.com> Date: Mon, 16 Dec 2024 10:41:35 +0100 Subject: [PATCH] Rough validation --- src/citrea_config/sequencer.rs | 16 +++++++++++++++- src/client.rs | 2 +- src/config/mod.rs | 4 ++++ src/framework.rs | 3 +++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/citrea_config/sequencer.rs b/src/citrea_config/sequencer.rs index 412527e..42f296a 100644 --- a/src/citrea_config/sequencer.rs +++ b/src/citrea_config/sequencer.rs @@ -1,5 +1,8 @@ +use anyhow::ensure; use serde::{Deserialize, Serialize}; +use crate::{bitcoin::FINALITY_DEPTH, config::Validate}; + /// Rollup Configuration #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct SequencerConfig { @@ -24,7 +27,7 @@ impl Default for SequencerConfig { SequencerConfig { private_key: "1212121212121212121212121212121212121212121212121212121212121212" .to_string(), - min_soft_confirmations_per_commitment: 4, + min_soft_confirmations_per_commitment: FINALITY_DEPTH * 2, test_mode: true, deposit_mempool_fetch_limit: 10, block_production_interval_ms: 100, @@ -34,6 +37,17 @@ impl Default for SequencerConfig { } } +impl Validate for SequencerConfig { + fn validate(&self) -> anyhow::Result<()> { + ensure!( + self.min_soft_confirmations_per_commitment >= FINALITY_DEPTH * 2, + "min_soft_confirmations_per_commitment should be set higher than FINALITY_DEPTH * 2" + ); + + Ok(()) + } +} + /// Mempool Config for the sequencer /// Read: https://github.com/ledgerwatch/erigon/wiki/Transaction-Pool-Design #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] diff --git a/src/client.rs b/src/client.rs index 92216bd..5e4ec79 100644 --- a/src/client.rs +++ b/src/client.rs @@ -36,7 +36,7 @@ impl Client { .request("citrea_testPublishBlock", rpc_params![]) .await .map_err(Into::into); - sleep(Duration::from_millis(100)).await; + // sleep(Duration::from_millis(100)).await; r } diff --git a/src/config/mod.rs b/src/config/mod.rs index 264788c..18888bf 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -209,3 +209,7 @@ where self.dir().join("stderr.log") } } + +pub trait Validate { + fn validate(&self) -> Result<()>; +} diff --git a/src/framework.rs b/src/framework.rs index 4c81c23..dcd6eb6 100644 --- a/src/framework.rs +++ b/src/framework.rs @@ -27,6 +27,7 @@ use crate::{ batch_prover::BatchProver, config::{ BitcoinServiceConfig, FullLightClientProverConfig, RpcConfig, RunnerConfig, StorageConfig, + Validate, }, light_client_prover::LightClientProver, log_provider::{LogPathProvider, LogPathProviderErased}, @@ -276,6 +277,8 @@ fn generate_test_config( let batch_prover = T::batch_prover_config(); let light_client_prover = T::light_client_prover_config(); let sequencer = T::sequencer_config(); + sequencer.validate()?; + let sequencer_rollup = RollupConfig::default(); let batch_prover_rollup = RollupConfig::default(); let light_client_prover_rollup = RollupConfig::default();