Skip to content

Commit

Permalink
Rough validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jfldde committed Dec 16, 2024
1 parent efde07d commit 1aac509
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/citrea_config/sequencer.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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,
Expand All @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 4 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,7 @@ where
self.dir().join("stderr.log")
}
}

pub trait Validate {
fn validate(&self) -> Result<()>;
}
3 changes: 3 additions & 0 deletions src/framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use crate::{
batch_prover::BatchProver,
config::{
BitcoinServiceConfig, FullLightClientProverConfig, RpcConfig, RunnerConfig, StorageConfig,
Validate,
},
light_client_prover::LightClientProver,
log_provider::{LogPathProvider, LogPathProviderErased},
Expand Down Expand Up @@ -276,6 +277,8 @@ fn generate_test_config<T: TestCase>(
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();
Expand Down

0 comments on commit 1aac509

Please sign in to comment.