From 29026c1fbdc13a1b288d5b4c18c6becf0e5f8ef8 Mon Sep 17 00:00:00 2001 From: yaziciahmet Date: Mon, 7 Oct 2024 15:56:35 +0200 Subject: [PATCH 1/9] Rename Prover namespace to BatchProver --- src/{prover.rs => batch_prover.rs} | 10 ++++----- src/bitcoin.rs | 2 +- src/config/mod.rs | 6 ++--- src/config/test.rs | 4 ++-- src/config/test_case.rs | 10 ++++----- src/framework.rs | 28 +++++++++++------------ src/lib.rs | 2 +- src/node.rs | 4 ++-- src/test_case.rs | 36 +++++++++++++++--------------- src/traits.rs | 2 +- 10 files changed, 52 insertions(+), 52 deletions(-) rename src/{prover.rs => batch_prover.rs} (71%) diff --git a/src/prover.rs b/src/batch_prover.rs similarity index 71% rename from src/prover.rs rename to src/batch_prover.rs index 8824be6..2c318da 100644 --- a/src/prover.rs +++ b/src/batch_prover.rs @@ -1,19 +1,19 @@ use std::time::SystemTime; -use super::{config::FullProverConfig, Result}; +use super::{config::FullBatchProverConfig, Result}; use crate::node::Node; use anyhow::bail; use log::debug; use tokio::time::{sleep, Duration}; -pub type Prover = Node; +pub type BatchProver = Node; -impl Prover { +impl BatchProver { pub async fn wait_for_l1_height(&self, height: u64, timeout: Option) -> Result<()> { let start = SystemTime::now(); let timeout = timeout.unwrap_or(Duration::from_secs(600)); loop { - debug!("Waiting for prover height {}", height); + debug!("Waiting for batch prover height {}", height); let latest_block = self.client.ledger_get_last_scanned_l1_height().await?; if latest_block >= height { @@ -22,7 +22,7 @@ impl Prover { let now = SystemTime::now(); if start + timeout <= now { - bail!("Timeout. Latest prover L1 height is {}", latest_block); + bail!("Timeout. Latest batch prover L1 height is {}", latest_block); } sleep(Duration::from_secs(1)).await; diff --git a/src/bitcoin.rs b/src/bitcoin.rs index 25dfc90..0b630d5 100644 --- a/src/bitcoin.rs +++ b/src/bitcoin.rs @@ -128,7 +128,7 @@ impl BitcoinNode { async fn load_wallets(&self) { let _ = self.load_wallet(&NodeKind::Bitcoin.to_string()).await; let _ = self.load_wallet(&NodeKind::Sequencer.to_string()).await; - let _ = self.load_wallet(&NodeKind::Prover.to_string()).await; + let _ = self.load_wallet(&NodeKind::BatchProver.to_string()).await; } // Switch this over to Node signature once we add support for docker to citrea nodes diff --git a/src/config/mod.rs b/src/config/mod.rs index d036ef8..ea74762 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -33,7 +33,7 @@ pub struct FullL2NodeConfig { } pub type FullSequencerConfig = FullL2NodeConfig; -pub type FullProverConfig = FullL2NodeConfig; +pub type FullBatchProverConfig = FullL2NodeConfig; pub type FullFullNodeConfig = FullL2NodeConfig<()>; pub trait NodeKindMarker { @@ -44,8 +44,8 @@ impl NodeKindMarker for FullSequencerConfig { const KIND: NodeKind = NodeKind::Sequencer; } -impl NodeKindMarker for FullProverConfig { - const KIND: NodeKind = NodeKind::Prover; +impl NodeKindMarker for FullBatchProverConfig { + const KIND: NodeKind = NodeKind::BatchProver; } impl NodeKindMarker for FullFullNodeConfig { diff --git a/src/config/test.rs b/src/config/test.rs index ae7ea58..7c0d9f1 100644 --- a/src/config/test.rs +++ b/src/config/test.rs @@ -1,5 +1,5 @@ use super::{ - bitcoin::BitcoinConfig, test_case::TestCaseConfig, FullFullNodeConfig, FullProverConfig, + bitcoin::BitcoinConfig, test_case::TestCaseConfig, FullFullNodeConfig, FullBatchProverConfig, FullSequencerConfig, }; @@ -8,6 +8,6 @@ pub struct TestConfig { pub test_case: TestCaseConfig, pub bitcoin: Vec, pub sequencer: FullSequencerConfig, - pub prover: FullProverConfig, + pub batch_prover: FullBatchProverConfig, pub full_node: FullFullNodeConfig, } diff --git a/src/config/test_case.rs b/src/config/test_case.rs index bd7acae..9dfda7a 100644 --- a/src/config/test_case.rs +++ b/src/config/test_case.rs @@ -7,7 +7,7 @@ pub struct TestCaseEnv { pub test: Vec<(&'static str, &'static str)>, pub full_node: Vec<(&'static str, &'static str)>, pub sequencer: Vec<(&'static str, &'static str)>, - pub prover: Vec<(&'static str, &'static str)>, + pub batch_prover: Vec<(&'static str, &'static str)>, pub bitcoin: Vec<(&'static str, &'static str)>, } @@ -25,8 +25,8 @@ impl TestCaseEnv { [self.test_env(), self.sequencer.clone()].concat() } - pub fn prover(&self) -> Vec<(&'static str, &'static str)> { - [self.test_env(), self.prover.clone()].concat() + pub fn batch_prover(&self) -> Vec<(&'static str, &'static str)> { + [self.test_env(), self.batch_prover.clone()].concat() } pub fn full_node(&self) -> Vec<(&'static str, &'static str)> { @@ -43,7 +43,7 @@ pub struct TestCaseConfig { pub n_nodes: usize, pub with_sequencer: bool, pub with_full_node: bool, - pub with_prover: bool, + pub with_batch_prover: bool, #[allow(unused)] pub timeout: Duration, pub dir: PathBuf, @@ -59,7 +59,7 @@ impl Default for TestCaseConfig { TestCaseConfig { n_nodes: 1, with_sequencer: true, - with_prover: false, + with_batch_prover: false, with_full_node: false, timeout: Duration::from_secs(60), dir: TempDir::new() diff --git a/src/framework.rs b/src/framework.rs index a64a73c..a90191b 100644 --- a/src/framework.rs +++ b/src/framework.rs @@ -12,7 +12,7 @@ use super::{ traits::{LogProvider, LogProviderErased, NodeT}, Result, }; -use crate::{prover::Prover, utils::tail_file}; +use crate::{batch_prover::BatchProver, utils::tail_file}; pub struct TestContext { pub config: TestConfig, @@ -37,7 +37,7 @@ pub struct TestFramework { ctx: TestContext, pub bitcoin_nodes: BitcoinNodeCluster, pub sequencer: Option, - pub prover: Option, + pub batch_prover: Option, pub full_node: Option, show_logs: bool, pub initial_da_height: u64, @@ -66,7 +66,7 @@ impl TestFramework { Ok(Self { bitcoin_nodes, sequencer: None, - prover: None, + batch_prover: None, full_node: None, ctx, show_logs: true, @@ -75,17 +75,17 @@ impl TestFramework { } pub async fn init_nodes(&mut self) -> Result<()> { - // Has to initialize sequencer first since prover and full node depend on it + // Has to initialize sequencer first since provers and full node depend on it self.sequencer = create_optional( self.ctx.config.test_case.with_sequencer, Sequencer::new(&self.ctx.config.sequencer), ) .await?; - (self.prover, self.full_node) = tokio::try_join!( + (self.batch_prover, self.full_node) = tokio::try_join!( create_optional( - self.ctx.config.test_case.with_prover, - Prover::new(&self.ctx.config.prover) + self.ctx.config.test_case.with_batch_prover, + BatchProver::new(&self.ctx.config.batch_prover) ), create_optional( self.ctx.config.test_case.with_full_node, @@ -101,7 +101,7 @@ impl TestFramework { self.bitcoin_nodes.get(0).map(LogProvider::as_erased), self.sequencer.as_ref().map(LogProvider::as_erased), self.full_node.as_ref().map(LogProvider::as_erased), - self.prover.as_ref().map(LogProvider::as_erased), + self.batch_prover.as_ref().map(LogProvider::as_erased), ] .into_iter() .flatten() @@ -149,9 +149,9 @@ impl TestFramework { println!("Successfully stopped sequencer"); } - if let Some(prover) = &mut self.prover { - let _ = prover.stop().await; - println!("Successfully stopped prover"); + if let Some(batch_prover) = &mut self.batch_prover { + let _ = batch_prover.stop().await; + println!("Successfully stopped batch_prover"); } if let Some(full_node) = &mut self.full_node { @@ -175,7 +175,7 @@ impl TestFramework { da.create_wallet(&NodeKind::Sequencer.to_string(), None, None, None, None) .await?; - da.create_wallet(&NodeKind::Prover.to_string(), None, None, None, None) + da.create_wallet(&NodeKind::BatchProver.to_string(), None, None, None, None) .await?; da.create_wallet(&NodeKind::Bitcoin.to_string(), None, None, None, None) .await?; @@ -187,8 +187,8 @@ impl TestFramework { .await?; } - if self.ctx.config.test_case.with_prover { - da.fund_wallet(NodeKind::Prover.to_string(), blocks_to_fund) + if self.ctx.config.test_case.with_batch_prover { + da.fund_wallet(NodeKind::BatchProver.to_string(), blocks_to_fund) .await?; } da.fund_wallet(NodeKind::Bitcoin.to_string(), blocks_to_fund) diff --git a/src/lib.rs b/src/lib.rs index 119cf52..33892ef 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,7 @@ mod docker; pub mod framework; pub mod full_node; pub mod node; -pub mod prover; +pub mod batch_prover; pub mod sequencer; pub mod test_case; pub mod traits; diff --git a/src/node.rs b/src/node.rs index ccc5cea..1e91d9d 100644 --- a/src/node.rs +++ b/src/node.rs @@ -26,7 +26,7 @@ use crate::{ #[derive(Debug, Clone)] pub enum NodeKind { Bitcoin, - Prover, + BatchProver, Sequencer, FullNode, } @@ -35,7 +35,7 @@ impl fmt::Display for NodeKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { NodeKind::Bitcoin => write!(f, "bitcoin"), - NodeKind::Prover => write!(f, "prover"), + NodeKind::BatchProver => write!(f, "batch-prover"), NodeKind::Sequencer => write!(f, "sequencer"), NodeKind::FullNode => write!(f, "full-node"), } diff --git a/src/test_case.rs b/src/test_case.rs index 7123c2d..da3633f 100644 --- a/src/test_case.rs +++ b/src/test_case.rs @@ -13,7 +13,7 @@ use futures::FutureExt; use super::{ config::{ - default_rollup_config, BitcoinConfig, FullFullNodeConfig, FullProverConfig, + default_rollup_config, BitcoinConfig, FullFullNodeConfig, FullBatchProverConfig, FullSequencerConfig, RollupConfig, TestCaseConfig, TestCaseEnv, TestConfig, }, framework::TestFramework, @@ -53,8 +53,8 @@ impl TestCaseRunner { .wait_for_ready(Some(Duration::from_secs(5))) .await?; } - if let Some(prover) = &f.prover { - prover.wait_for_ready(Some(Duration::from_secs(5))).await?; + if let Some(batch_prover) = &f.batch_prover { + batch_prover.wait_for_ready(Some(Duration::from_secs(5))).await?; } Ok(()) @@ -110,13 +110,13 @@ impl TestCaseRunner { let test_case = T::test_config(); let env = T::test_env(); let bitcoin = T::bitcoin_config(); - let prover = T::prover_config(); + let batch_prover = T::batch_prover_config(); let sequencer = T::sequencer_config(); let sequencer_rollup = default_rollup_config(); - let prover_rollup = default_rollup_config(); + let batch_prover_rollup = default_rollup_config(); let full_node_rollup = default_rollup_config(); - let [bitcoin_dir, dbs_dir, prover_dir, sequencer_dir, full_node_dir, genesis_dir, tx_backup_dir] = + let [bitcoin_dir, dbs_dir, batch_prover_dir, sequencer_dir, full_node_dir, genesis_dir, tx_backup_dir] = create_dirs(&test_case.dir)?; copy_genesis_dir(&test_case.genesis_dir, &genesis_dir)?; @@ -178,9 +178,9 @@ impl TestCaseRunner { sync_blocks_count: 10, }); - let prover_rollup = { + let batch_prover_rollup = { let bind_port = get_available_port()?; - let node_kind = NodeKind::Prover.to_string(); + let node_kind = NodeKind::BatchProver.to_string(); RollupConfig { da: BitcoinServiceConfig { da_private_key: Some( @@ -197,10 +197,10 @@ impl TestCaseRunner { }, rpc: RpcConfig { bind_port, - ..prover_rollup.rpc + ..batch_prover_rollup.rpc }, runner: runner_config.clone(), - ..prover_rollup + ..batch_prover_rollup } }; @@ -239,12 +239,12 @@ impl TestCaseRunner { node: sequencer, env: env.sequencer(), }, - prover: FullProverConfig { - rollup: prover_rollup, - dir: prover_dir, + batch_prover: FullBatchProverConfig { + rollup: batch_prover_rollup, + dir: batch_prover_dir, docker_image: None, - node: prover, - env: env.prover(), + node: batch_prover, + env: env.batch_prover(), }, full_node: FullFullNodeConfig { rollup: full_node_rollup, @@ -289,9 +289,9 @@ pub trait TestCase: Send + Sync + 'static { SequencerConfig::default() } - /// Returns the prover configuration for the test. + /// Returns the batch prover configuration for the test. /// Override this method to provide a custom prover configuration. - fn prover_config() -> ProverConfig { + fn batch_prover_config() -> ProverConfig { ProverConfig::default() } @@ -319,7 +319,7 @@ fn create_dirs(base_dir: &Path) -> Result<[PathBuf; 7]> { let paths = [ NodeKind::Bitcoin.to_string(), "dbs".to_string(), - NodeKind::Prover.to_string(), + NodeKind::BatchProver.to_string(), NodeKind::Sequencer.to_string(), NodeKind::FullNode.to_string(), "genesis".to_string(), diff --git a/src/traits.rs b/src/traits.rs index 945d7fa..51835d4 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -21,7 +21,7 @@ pub enum SpawnOutput { } /// The Node trait defines the common interface shared between -/// BitcoinNode, Prover, Sequencer and FullNode +/// BitcoinNode, BatchProver, Sequencer and FullNode #[async_trait] pub trait NodeT: Send { type Config: Send; From c56dee9d9b02201b2eb923acd16bac0470fe01f1 Mon Sep 17 00:00:00 2001 From: yaziciahmet Date: Mon, 7 Oct 2024 16:30:11 +0200 Subject: [PATCH 2/9] Add light client type --- Cargo.toml | 2 +- src/batch_prover.rs | 5 +-- src/client.rs | 2 +- src/config/mod.rs | 2 ++ src/config/test.rs | 5 +-- src/config/test_case.rs | 8 ++++- src/framework.rs | 32 +++++++++++++++++-- src/lib.rs | 3 +- src/light_client_prover.rs | 37 ++++++++++++++++++++++ src/node.rs | 2 ++ src/sequencer.rs | 3 +- src/test_case.rs | 64 ++++++++++++++++++++++++++++++++++---- 12 files changed, 147 insertions(+), 18 deletions(-) create mode 100644 src/light_client_prover.rs diff --git a/Cargo.toml b/Cargo.toml index 19dd3b4..a07d10a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ bitcoin = { version = "0.32.2", features = ["serde", "rand"] } bitcoincore-rpc = { version = "0.18.0" } bollard = { version = "0.17.1" } futures = "0.3" +jsonrpsee = { version = "0.24.2", features = ["http-client", "ws-client"] } log = "0.4" rand = "0.8" serde = { version = "1.0.192", default-features = false, features = ["alloc", "derive"] } @@ -19,7 +20,6 @@ tempfile = "3.8" tokio = { version = "1.39", features = ["full"] } toml = "0.8.0" which = "6.0.1" -jsonrpsee = { version = "0.24.2", features = ["http-client", "ws-client"] } hex = { version = "0.4.3", default-features = false, features = ["serde"] } # Citrea dependencies diff --git a/src/batch_prover.rs b/src/batch_prover.rs index 2c318da..c7f33df 100644 --- a/src/batch_prover.rs +++ b/src/batch_prover.rs @@ -1,11 +1,12 @@ use std::time::SystemTime; -use super::{config::FullBatchProverConfig, Result}; -use crate::node::Node; use anyhow::bail; use log::debug; use tokio::time::{sleep, Duration}; +use super::{config::FullBatchProverConfig, Result}; +use crate::node::Node; + pub type BatchProver = Node; impl BatchProver { diff --git a/src/client.rs b/src/client.rs index fe87110..a8d3633 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1,8 +1,8 @@ use std::time::{Duration, SystemTime}; use anyhow::{bail, Result}; -use jsonrpsee::core::client::ClientT; use jsonrpsee::{ + core::client::ClientT, http_client::{HttpClient, HttpClientBuilder}, rpc_params, }; diff --git a/src/config/mod.rs b/src/config/mod.rs index ea74762..a12244d 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -34,6 +34,8 @@ pub struct FullL2NodeConfig { pub type FullSequencerConfig = FullL2NodeConfig; pub type FullBatchProverConfig = FullL2NodeConfig; +// TODO: use LightClientProverConfig +pub type FullLightClientProverConfig = FullL2NodeConfig; pub type FullFullNodeConfig = FullL2NodeConfig<()>; pub trait NodeKindMarker { diff --git a/src/config/test.rs b/src/config/test.rs index 7c0d9f1..f67755d 100644 --- a/src/config/test.rs +++ b/src/config/test.rs @@ -1,6 +1,6 @@ use super::{ - bitcoin::BitcoinConfig, test_case::TestCaseConfig, FullFullNodeConfig, FullBatchProverConfig, - FullSequencerConfig, + bitcoin::BitcoinConfig, test_case::TestCaseConfig, FullBatchProverConfig, FullFullNodeConfig, + FullLightClientProverConfig, FullSequencerConfig, }; #[derive(Clone)] @@ -9,5 +9,6 @@ pub struct TestConfig { pub bitcoin: Vec, pub sequencer: FullSequencerConfig, pub batch_prover: FullBatchProverConfig, + pub light_client_prover: FullLightClientProverConfig, pub full_node: FullFullNodeConfig, } diff --git a/src/config/test_case.rs b/src/config/test_case.rs index 9dfda7a..bc081a8 100644 --- a/src/config/test_case.rs +++ b/src/config/test_case.rs @@ -8,6 +8,7 @@ pub struct TestCaseEnv { pub full_node: Vec<(&'static str, &'static str)>, pub sequencer: Vec<(&'static str, &'static str)>, pub batch_prover: Vec<(&'static str, &'static str)>, + pub light_client_prover: Vec<(&'static str, &'static str)>, pub bitcoin: Vec<(&'static str, &'static str)>, } @@ -29,6 +30,10 @@ impl TestCaseEnv { [self.test_env(), self.batch_prover.clone()].concat() } + pub fn light_client_prover(&self) -> Vec<(&'static str, &'static str)> { + [self.test_env(), self.light_client_prover.clone()].concat() + } + pub fn full_node(&self) -> Vec<(&'static str, &'static str)> { [self.test_env(), self.full_node.clone()].concat() } @@ -44,7 +49,7 @@ pub struct TestCaseConfig { pub with_sequencer: bool, pub with_full_node: bool, pub with_batch_prover: bool, - #[allow(unused)] + pub with_light_client_prover: bool, pub timeout: Duration, pub dir: PathBuf, pub docker: bool, @@ -60,6 +65,7 @@ impl Default for TestCaseConfig { n_nodes: 1, with_sequencer: true, with_batch_prover: false, + with_light_client_prover: false, with_full_node: false, timeout: Duration::from_secs(60), dir: TempDir::new() diff --git a/src/framework.rs b/src/framework.rs index a90191b..a56a480 100644 --- a/src/framework.rs +++ b/src/framework.rs @@ -12,7 +12,7 @@ use super::{ traits::{LogProvider, LogProviderErased, NodeT}, Result, }; -use crate::{batch_prover::BatchProver, utils::tail_file}; +use crate::{batch_prover::BatchProver, light_client_prover::LightClientProver, utils::tail_file}; pub struct TestContext { pub config: TestConfig, @@ -38,6 +38,7 @@ pub struct TestFramework { pub bitcoin_nodes: BitcoinNodeCluster, pub sequencer: Option, pub batch_prover: Option, + pub light_client_prover: Option, pub full_node: Option, show_logs: bool, pub initial_da_height: u64, @@ -67,6 +68,7 @@ impl TestFramework { bitcoin_nodes, sequencer: None, batch_prover: None, + light_client_prover: None, full_node: None, ctx, show_logs: true, @@ -82,11 +84,15 @@ impl TestFramework { ) .await?; - (self.batch_prover, self.full_node) = tokio::try_join!( + (self.batch_prover, self.light_client_prover, self.full_node) = tokio::try_join!( create_optional( self.ctx.config.test_case.with_batch_prover, BatchProver::new(&self.ctx.config.batch_prover) ), + create_optional( + self.ctx.config.test_case.with_light_client_prover, + LightClientProver::new(&self.ctx.config.light_client_prover) + ), create_optional( self.ctx.config.test_case.with_full_node, FullNode::new(&self.ctx.config.full_node) @@ -102,6 +108,9 @@ impl TestFramework { self.sequencer.as_ref().map(LogProvider::as_erased), self.full_node.as_ref().map(LogProvider::as_erased), self.batch_prover.as_ref().map(LogProvider::as_erased), + self.light_client_prover + .as_ref() + .map(LogProvider::as_erased), ] .into_iter() .flatten() @@ -154,6 +163,11 @@ impl TestFramework { println!("Successfully stopped batch_prover"); } + if let Some(light_client_prover) = &mut self.light_client_prover { + let _ = light_client_prover.stop().await; + println!("Successfully stopped light_client_prover"); + } + if let Some(full_node) = &mut self.full_node { let _ = full_node.stop().await; println!("Successfully stopped full_node"); @@ -177,6 +191,14 @@ impl TestFramework { .await?; da.create_wallet(&NodeKind::BatchProver.to_string(), None, None, None, None) .await?; + da.create_wallet( + &NodeKind::LightClientProver.to_string(), + None, + None, + None, + None, + ) + .await?; da.create_wallet(&NodeKind::Bitcoin.to_string(), None, None, None, None) .await?; @@ -191,6 +213,12 @@ impl TestFramework { da.fund_wallet(NodeKind::BatchProver.to_string(), blocks_to_fund) .await?; } + + if self.ctx.config.test_case.with_light_client_prover { + da.fund_wallet(NodeKind::LightClientProver.to_string(), blocks_to_fund) + .await?; + } + da.fund_wallet(NodeKind::Bitcoin.to_string(), blocks_to_fund) .await?; diff --git a/src/lib.rs b/src/lib.rs index 33892ef..3a11f88 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,4 @@ +pub mod batch_prover; pub mod bitcoin; mod citrea_config; mod client; @@ -5,8 +6,8 @@ pub mod config; mod docker; pub mod framework; pub mod full_node; +pub mod light_client_prover; pub mod node; -pub mod batch_prover; pub mod sequencer; pub mod test_case; pub mod traits; diff --git a/src/light_client_prover.rs b/src/light_client_prover.rs new file mode 100644 index 0000000..df4f48a --- /dev/null +++ b/src/light_client_prover.rs @@ -0,0 +1,37 @@ +use std::time::SystemTime; + +use anyhow::bail; +use log::debug; +use tokio::time::{sleep, Duration}; + +use super::{config::FullLightClientProverConfig, Result}; +use crate::node::Node; + +pub type LightClientProver = Node; + +impl LightClientProver { + // TODO: remove _l at the end + pub async fn wait_for_l1_height_l(&self, height: u64, timeout: Option) -> Result<()> { + let start = SystemTime::now(); + let timeout = timeout.unwrap_or(Duration::from_secs(600)); + loop { + debug!("Waiting for light client prover height {}", height); + let latest_block = self.client.ledger_get_last_scanned_l1_height().await?; + + if latest_block >= height { + break; + } + + let now = SystemTime::now(); + if start + timeout <= now { + bail!( + "Timeout. Latest light client prover L1 height is {}", + latest_block + ); + } + + sleep(Duration::from_secs(1)).await; + } + Ok(()) + } +} diff --git a/src/node.rs b/src/node.rs index 1e91d9d..b6f5d55 100644 --- a/src/node.rs +++ b/src/node.rs @@ -27,6 +27,7 @@ use crate::{ pub enum NodeKind { Bitcoin, BatchProver, + LightClientProver, Sequencer, FullNode, } @@ -36,6 +37,7 @@ impl fmt::Display for NodeKind { match self { NodeKind::Bitcoin => write!(f, "bitcoin"), NodeKind::BatchProver => write!(f, "batch-prover"), + NodeKind::LightClientProver => write!(f, "light-client-prover"), NodeKind::Sequencer => write!(f, "sequencer"), NodeKind::FullNode => write!(f, "full-node"), } diff --git a/src/sequencer.rs b/src/sequencer.rs index 73bb2e0..50a352f 100644 --- a/src/sequencer.rs +++ b/src/sequencer.rs @@ -1,8 +1,7 @@ use std::path::PathBuf; use super::config::FullSequencerConfig; -use crate::node::Node; -use crate::traits::NodeT; +use crate::{node::Node, traits::NodeT}; pub type Sequencer = Node; diff --git a/src/test_case.rs b/src/test_case.rs index da3633f..ff70f81 100644 --- a/src/test_case.rs +++ b/src/test_case.rs @@ -13,7 +13,7 @@ use futures::FutureExt; use super::{ config::{ - default_rollup_config, BitcoinConfig, FullFullNodeConfig, FullBatchProverConfig, + default_rollup_config, BitcoinConfig, FullBatchProverConfig, FullFullNodeConfig, FullSequencerConfig, RollupConfig, TestCaseConfig, TestCaseEnv, TestConfig, }, framework::TestFramework, @@ -23,7 +23,8 @@ use super::{ }; use crate::{ config::{ - BitcoinServiceConfig, ProverConfig, RpcConfig, RunnerConfig, SequencerConfig, StorageConfig, + BitcoinServiceConfig, FullLightClientProverConfig, ProverConfig, RpcConfig, RunnerConfig, + SequencerConfig, StorageConfig, }, traits::NodeT, utils::{get_default_genesis_path, get_workspace_root}, @@ -54,7 +55,19 @@ impl TestCaseRunner { .await?; } if let Some(batch_prover) = &f.batch_prover { - batch_prover.wait_for_ready(Some(Duration::from_secs(5))).await?; + batch_prover + .wait_for_ready(Some(Duration::from_secs(5))) + .await?; + } + if let Some(light_client_prover) = &f.light_client_prover { + light_client_prover + .wait_for_ready(Some(Duration::from_secs(5))) + .await?; + } + if let Some(full_node) = &f.full_node { + full_node + .wait_for_ready(Some(Duration::from_secs(5))) + .await?; } Ok(()) @@ -111,12 +124,14 @@ impl TestCaseRunner { let env = T::test_env(); let bitcoin = T::bitcoin_config(); let batch_prover = T::batch_prover_config(); + let light_client_prover = T::light_client_prover_config(); let sequencer = T::sequencer_config(); let sequencer_rollup = default_rollup_config(); let batch_prover_rollup = default_rollup_config(); + let light_client_prover_rollup = default_rollup_config(); let full_node_rollup = default_rollup_config(); - let [bitcoin_dir, dbs_dir, batch_prover_dir, sequencer_dir, full_node_dir, genesis_dir, tx_backup_dir] = + let [bitcoin_dir, dbs_dir, batch_prover_dir, light_client_prover_dir, sequencer_dir, full_node_dir, genesis_dir, tx_backup_dir] = create_dirs(&test_case.dir)?; copy_genesis_dir(&test_case.genesis_dir, &genesis_dir)?; @@ -204,6 +219,29 @@ impl TestCaseRunner { } }; + let light_client_prover_rollup = { + let bind_port = get_available_port()?; + let node_kind = NodeKind::LightClientProver.to_string(); + RollupConfig { + da: BitcoinServiceConfig { + da_private_key: None, + node_url: format!("http://{}/wallet/{}", da_config.node_url, node_kind), + tx_backup_dir: tx_backup_dir.display().to_string(), + ..da_config.clone() + }, + storage: StorageConfig { + path: dbs_dir.join(format!("{node_kind}-db")), + db_max_open_files: None, + }, + rpc: RpcConfig { + bind_port, + ..light_client_prover_rollup.rpc + }, + runner: runner_config.clone(), + ..light_client_prover_rollup + } + }; + let full_node_rollup = { let bind_port = get_available_port()?; let node_kind = NodeKind::FullNode.to_string(); @@ -246,6 +284,13 @@ impl TestCaseRunner { node: batch_prover, env: env.batch_prover(), }, + light_client_prover: FullLightClientProverConfig { + rollup: light_client_prover_rollup, + dir: light_client_prover_dir, + docker_image: None, + node: light_client_prover, + env: env.light_client_prover(), + }, full_node: FullFullNodeConfig { rollup: full_node_rollup, dir: full_node_dir, @@ -290,11 +335,17 @@ pub trait TestCase: Send + Sync + 'static { } /// Returns the batch prover configuration for the test. - /// Override this method to provide a custom prover configuration. + /// Override this method to provide a custom batch prover configuration. fn batch_prover_config() -> ProverConfig { ProverConfig::default() } + /// Returns the light client prover configuration for the test. + /// Override this method to provide a custom light client prover configuration. + fn light_client_prover_config() -> ProverConfig { + ProverConfig::default() + } + /// Returns the test setup /// Override this method to add custom initialization logic async fn setup(&self, _framework: &mut TestFramework) -> Result<()> { @@ -315,11 +366,12 @@ pub trait TestCase: Send + Sync + 'static { } } -fn create_dirs(base_dir: &Path) -> Result<[PathBuf; 7]> { +fn create_dirs(base_dir: &Path) -> Result<[PathBuf; 8]> { let paths = [ NodeKind::Bitcoin.to_string(), "dbs".to_string(), NodeKind::BatchProver.to_string(), + NodeKind::LightClientProver.to_string(), NodeKind::Sequencer.to_string(), NodeKind::FullNode.to_string(), "genesis".to_string(), From 89140b8c39c2749960cb18dad1b59f6bb70a27f2 Mon Sep 17 00:00:00 2001 From: yaziciahmet Date: Mon, 7 Oct 2024 17:58:17 +0200 Subject: [PATCH 3/9] Separate batch and light client prover configs --- Cargo.toml | 2 +- src/config/mod.rs | 8 ++++++-- src/test_case.rs | 13 +++++++------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a07d10a..f2a3b97 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,11 +21,11 @@ tokio = { version = "1.39", features = ["full"] } toml = "0.8.0" which = "6.0.1" hex = { version = "0.4.3", default-features = false, features = ["serde"] } +syn = { version = "1.0", features = ["full", "extra-traits"] } # Citrea dependencies sov-ledger-rpc = { git = "https://github.com/chainwayxyz/citrea", rev = "82bf52d", default-features = false, features = ["client"] } sov-rollup-interface = { git = "https://github.com/chainwayxyz/citrea", rev = "82bf52d" } -syn = { version = "1.0", features = ["full", "extra-traits"] } [patch.crates-io] bitcoincore-rpc = { version = "0.18.0", git = "https://github.com/chainwayxyz/rust-bitcoincore-rpc.git", rev = "0ae498d" } diff --git a/src/config/mod.rs b/src/config/mod.rs index a12244d..6c4a442 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -33,9 +33,9 @@ pub struct FullL2NodeConfig { } pub type FullSequencerConfig = FullL2NodeConfig; -pub type FullBatchProverConfig = FullL2NodeConfig; +pub type FullBatchProverConfig = FullL2NodeConfig; // TODO: use LightClientProverConfig -pub type FullLightClientProverConfig = FullL2NodeConfig; +pub type FullLightClientProverConfig = FullL2NodeConfig; pub type FullFullNodeConfig = FullL2NodeConfig<()>; pub trait NodeKindMarker { @@ -50,6 +50,10 @@ impl NodeKindMarker for FullBatchProverConfig { const KIND: NodeKind = NodeKind::BatchProver; } +impl NodeKindMarker for FullLightClientProverConfig { + const KIND: NodeKind = NodeKind::LightClientProver; +} + impl NodeKindMarker for FullFullNodeConfig { const KIND: NodeKind = NodeKind::FullNode; } diff --git a/src/test_case.rs b/src/test_case.rs index ff70f81..a553cc2 100644 --- a/src/test_case.rs +++ b/src/test_case.rs @@ -23,8 +23,8 @@ use super::{ }; use crate::{ config::{ - BitcoinServiceConfig, FullLightClientProverConfig, ProverConfig, RpcConfig, RunnerConfig, - SequencerConfig, StorageConfig, + BatchProverConfig, BitcoinServiceConfig, FullLightClientProverConfig, + LightClientProverConfig, RpcConfig, RunnerConfig, SequencerConfig, StorageConfig, }, traits::NodeT, utils::{get_default_genesis_path, get_workspace_root}, @@ -191,6 +191,7 @@ impl TestCaseRunner { include_tx_body: true, accept_public_input_as_proven: Some(true), sync_blocks_count: 10, + pruning_config: None, }); let batch_prover_rollup = { @@ -336,14 +337,14 @@ pub trait TestCase: Send + Sync + 'static { /// Returns the batch prover configuration for the test. /// Override this method to provide a custom batch prover configuration. - fn batch_prover_config() -> ProverConfig { - ProverConfig::default() + fn batch_prover_config() -> BatchProverConfig { + BatchProverConfig::default() } /// Returns the light client prover configuration for the test. /// Override this method to provide a custom light client prover configuration. - fn light_client_prover_config() -> ProverConfig { - ProverConfig::default() + fn light_client_prover_config() -> LightClientProverConfig { + LightClientProverConfig::default() } /// Returns the test setup From 03e3195dd2150ecabe9dc18fa10851ec9cbc261f Mon Sep 17 00:00:00 2001 From: yaziciahmet Date: Tue, 8 Oct 2024 09:55:23 +0200 Subject: [PATCH 4/9] Add citrea light client proving config --- .../{prover.rs => batch_prover.rs} | 8 +- src/citrea_config/light_client_prover.rs | 74 +++++++++++++++++++ src/citrea_config/mod.rs | 3 +- src/citrea_config/rollup.rs | 15 ++++ src/config/mod.rs | 4 +- src/light_client_prover.rs | 2 +- 6 files changed, 98 insertions(+), 8 deletions(-) rename src/citrea_config/{prover.rs => batch_prover.rs} (93%) create mode 100644 src/citrea_config/light_client_prover.rs diff --git a/src/citrea_config/prover.rs b/src/citrea_config/batch_prover.rs similarity index 93% rename from src/citrea_config/prover.rs rename to src/citrea_config/batch_prover.rs index 367674d..f0e78a0 100644 --- a/src/citrea_config/prover.rs +++ b/src/citrea_config/batch_prover.rs @@ -32,7 +32,7 @@ impl<'de> Deserialize<'de> for ProverGuestRunConfig { /// Prover configuration #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] -pub struct ProverConfig { +pub struct BatchProverConfig { /// Prover run mode pub proving_mode: ProverGuestRunConfig, /// Average number of commitments to prove @@ -41,7 +41,7 @@ pub struct ProverConfig { pub enable_recovery: bool, } -impl Default for ProverConfig { +impl Default for BatchProverConfig { fn default() -> Self { Self { proving_mode: ProverGuestRunConfig::Execute, @@ -91,8 +91,8 @@ mod tests { let config_file = create_config_from(config); - let config: ProverConfig = from_toml_path(config_file.path()).unwrap(); - let expected = ProverConfig { + let config: BatchProverConfig = from_toml_path(config_file.path()).unwrap(); + let expected = BatchProverConfig { proving_mode: ProverGuestRunConfig::Skip, proof_sampling_number: 500, enable_recovery: true, diff --git a/src/citrea_config/light_client_prover.rs b/src/citrea_config/light_client_prover.rs new file mode 100644 index 0000000..5557f5b --- /dev/null +++ b/src/citrea_config/light_client_prover.rs @@ -0,0 +1,74 @@ +use serde::{Deserialize, Serialize}; + +use super::batch_prover::ProverGuestRunConfig; + +/// Light client prover configuration +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] +pub struct LightClientProverConfig { + /// Prover run mode + pub proving_mode: ProverGuestRunConfig, + /// Average number of commitments to prove + pub proof_sampling_number: usize, + /// If true prover will try to recover ongoing proving sessions + pub enable_recovery: bool, +} + +impl Default for LightClientProverConfig { + fn default() -> Self { + Self { + proving_mode: ProverGuestRunConfig::Execute, + proof_sampling_number: 0, + enable_recovery: true, + } + } +} + +#[cfg(test)] +mod tests { + use std::io::Write; + + use serde::de::DeserializeOwned; + use std::fs::File; + use std::io::Read; + use std::path::Path; + use tempfile::NamedTempFile; + + use super::*; + + /// Reads toml file as a specific type. + pub fn from_toml_path, R: DeserializeOwned>(path: P) -> anyhow::Result { + let mut contents = String::new(); + { + let mut file = File::open(path)?; + file.read_to_string(&mut contents)?; + } + let result: R = toml::from_str(&contents)?; + + Ok(result) + } + + fn create_config_from(content: &str) -> NamedTempFile { + let mut config_file = NamedTempFile::new().unwrap(); + config_file.write_all(content.as_bytes()).unwrap(); + config_file + } + + #[test] + fn test_correct_prover_config() { + let config = r#" + proving_mode = "skip" + proof_sampling_number = 500 + enable_recovery = true + "#; + + let config_file = create_config_from(config); + + let config: LightClientProverConfig = from_toml_path(config_file.path()).unwrap(); + let expected = LightClientProverConfig { + proving_mode: ProverGuestRunConfig::Skip, + proof_sampling_number: 500, + enable_recovery: true, + }; + assert_eq!(config, expected); + } +} diff --git a/src/citrea_config/mod.rs b/src/citrea_config/mod.rs index 27e0d70..eac31ca 100644 --- a/src/citrea_config/mod.rs +++ b/src/citrea_config/mod.rs @@ -4,7 +4,8 @@ // Configs are stable and not expected to change much. pub(crate) mod bitcoin; -pub(crate) mod prover; +pub(crate) mod batch_prover; +pub(crate) mod light_client_prover; pub(crate) mod rollup; pub(crate) mod sequencer; diff --git a/src/citrea_config/rollup.rs b/src/citrea_config/rollup.rs index 1e39c6d..59d9ae0 100644 --- a/src/citrea_config/rollup.rs +++ b/src/citrea_config/rollup.rs @@ -14,6 +14,8 @@ pub struct RunnerConfig { /// Number of blocks to request during sync #[serde(default = "default_sync_blocks_count")] pub sync_blocks_count: u64, + /// Configurations for pruning + pub pruning_config: Option, } /// RPC configuration. @@ -118,3 +120,16 @@ pub struct FullNodeConfig { /// Important pubkeys pub public_keys: RollupPublicKeys, } + +/// A configuration type to define the behaviour of the pruner. +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +pub struct PruningConfig { + /// Defines the number of blocks from the tip of the chain to remove. + pub distance: u64, +} + +impl Default for PruningConfig { + fn default() -> Self { + Self { distance: 256 } + } +} \ No newline at end of file diff --git a/src/config/mod.rs b/src/config/mod.rs index 6c4a442..43f46d5 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -8,7 +8,8 @@ mod utils; use std::path::PathBuf; pub use crate::citrea_config::bitcoin::BitcoinServiceConfig; -pub use crate::citrea_config::prover::ProverConfig; +pub use crate::citrea_config::batch_prover::BatchProverConfig; +pub use crate::citrea_config::light_client_prover::LightClientProverConfig; pub use crate::citrea_config::rollup::{ FullNodeConfig, RollupPublicKeys, RpcConfig, RunnerConfig, StorageConfig, }; @@ -34,7 +35,6 @@ pub struct FullL2NodeConfig { pub type FullSequencerConfig = FullL2NodeConfig; pub type FullBatchProverConfig = FullL2NodeConfig; -// TODO: use LightClientProverConfig pub type FullLightClientProverConfig = FullL2NodeConfig; pub type FullFullNodeConfig = FullL2NodeConfig<()>; diff --git a/src/light_client_prover.rs b/src/light_client_prover.rs index df4f48a..5ca6bfc 100644 --- a/src/light_client_prover.rs +++ b/src/light_client_prover.rs @@ -11,7 +11,7 @@ pub type LightClientProver = Node; impl LightClientProver { // TODO: remove _l at the end - pub async fn wait_for_l1_height_l(&self, height: u64, timeout: Option) -> Result<()> { + pub async fn wait_for_l1_height(&self, height: u64, timeout: Option) -> Result<()> { let start = SystemTime::now(); let timeout = timeout.unwrap_or(Duration::from_secs(600)); loop { From 0583e159ea2be97c9e38d624ba71e1a61c6edd9a Mon Sep 17 00:00:00 2001 From: yaziciahmet Date: Tue, 8 Oct 2024 09:55:44 +0200 Subject: [PATCH 5/9] lint --- Cargo.toml | 4 ++-- src/citrea_config/batch_prover.rs | 9 +++++---- src/citrea_config/light_client_prover.rs | 9 +++++---- src/citrea_config/mod.rs | 2 +- src/citrea_config/rollup.rs | 2 +- src/citrea_config/sequencer.rs | 3 +-- src/config/mod.rs | 14 +++++++------- 7 files changed, 22 insertions(+), 21 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f2a3b97..0e2052b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,17 +11,17 @@ bitcoin = { version = "0.32.2", features = ["serde", "rand"] } bitcoincore-rpc = { version = "0.18.0" } bollard = { version = "0.17.1" } futures = "0.3" +hex = { version = "0.4.3", default-features = false, features = ["serde"] } jsonrpsee = { version = "0.24.2", features = ["http-client", "ws-client"] } log = "0.4" rand = "0.8" serde = { version = "1.0.192", default-features = false, features = ["alloc", "derive"] } serde_json = { version = "1.0", default-features = false } +syn = { version = "1.0", features = ["full", "extra-traits"] } tempfile = "3.8" tokio = { version = "1.39", features = ["full"] } toml = "0.8.0" which = "6.0.1" -hex = { version = "0.4.3", default-features = false, features = ["serde"] } -syn = { version = "1.0", features = ["full", "extra-traits"] } # Citrea dependencies sov-ledger-rpc = { git = "https://github.com/chainwayxyz/citrea", rev = "82bf52d", default-features = false, features = ["client"] } diff --git a/src/citrea_config/batch_prover.rs b/src/citrea_config/batch_prover.rs index f0e78a0..c72a86c 100644 --- a/src/citrea_config/batch_prover.rs +++ b/src/citrea_config/batch_prover.rs @@ -53,12 +53,13 @@ impl Default for BatchProverConfig { #[cfg(test)] mod tests { - use std::io::Write; + use std::{ + fs::File, + io::{Read, Write}, + path::Path, + }; use serde::de::DeserializeOwned; - use std::fs::File; - use std::io::Read; - use std::path::Path; use tempfile::NamedTempFile; use super::*; diff --git a/src/citrea_config/light_client_prover.rs b/src/citrea_config/light_client_prover.rs index 5557f5b..f4c225f 100644 --- a/src/citrea_config/light_client_prover.rs +++ b/src/citrea_config/light_client_prover.rs @@ -25,12 +25,13 @@ impl Default for LightClientProverConfig { #[cfg(test)] mod tests { - use std::io::Write; + use std::{ + fs::File, + io::{Read, Write}, + path::Path, + }; use serde::de::DeserializeOwned; - use std::fs::File; - use std::io::Read; - use std::path::Path; use tempfile::NamedTempFile; use super::*; diff --git a/src/citrea_config/mod.rs b/src/citrea_config/mod.rs index eac31ca..7a9ecf2 100644 --- a/src/citrea_config/mod.rs +++ b/src/citrea_config/mod.rs @@ -3,8 +3,8 @@ // Should ideally be automatically kept in sync somehow but manually copied here for the time being. // Configs are stable and not expected to change much. -pub(crate) mod bitcoin; pub(crate) mod batch_prover; +pub(crate) mod bitcoin; pub(crate) mod light_client_prover; pub(crate) mod rollup; pub(crate) mod sequencer; diff --git a/src/citrea_config/rollup.rs b/src/citrea_config/rollup.rs index 59d9ae0..cc8fcf9 100644 --- a/src/citrea_config/rollup.rs +++ b/src/citrea_config/rollup.rs @@ -132,4 +132,4 @@ impl Default for PruningConfig { fn default() -> Self { Self { distance: 256 } } -} \ No newline at end of file +} diff --git a/src/citrea_config/sequencer.rs b/src/citrea_config/sequencer.rs index 4c8dfa8..03babd8 100644 --- a/src/citrea_config/sequencer.rs +++ b/src/citrea_config/sequencer.rs @@ -74,9 +74,8 @@ mod tests { use tempfile::NamedTempFile; - use crate::citrea_config::from_toml_path; - use super::*; + use crate::citrea_config::from_toml_path; fn create_config_from(content: &str) -> NamedTempFile { let mut config_file = NamedTempFile::new().unwrap(); diff --git a/src/config/mod.rs b/src/config/mod.rs index 43f46d5..f515993 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -7,13 +7,6 @@ mod utils; use std::path::PathBuf; -pub use crate::citrea_config::bitcoin::BitcoinServiceConfig; -pub use crate::citrea_config::batch_prover::BatchProverConfig; -pub use crate::citrea_config::light_client_prover::LightClientProverConfig; -pub use crate::citrea_config::rollup::{ - FullNodeConfig, RollupPublicKeys, RpcConfig, RunnerConfig, StorageConfig, -}; -pub use crate::citrea_config::sequencer::SequencerConfig; pub use bitcoin::BitcoinConfig; pub use docker::DockerConfig; pub use rollup::{default_rollup_config, RollupConfig}; @@ -22,6 +15,13 @@ pub use test::TestConfig; pub use test_case::{TestCaseConfig, TestCaseEnv}; pub use utils::config_to_file; +pub use crate::citrea_config::{ + batch_prover::BatchProverConfig, + bitcoin::BitcoinServiceConfig, + light_client_prover::LightClientProverConfig, + rollup::{FullNodeConfig, RollupPublicKeys, RpcConfig, RunnerConfig, StorageConfig}, + sequencer::SequencerConfig, +}; use crate::node::{Config, NodeKind}; #[derive(Clone, Debug)] From 0aefd5bef5dc6a66ceb113bb263813adddecfc6c Mon Sep 17 00:00:00 2001 From: yaziciahmet Date: Tue, 8 Oct 2024 09:59:14 +0200 Subject: [PATCH 6/9] Remove unused dep --- Cargo.toml | 1 - Makefile | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0e2052b..f9557b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,6 @@ log = "0.4" rand = "0.8" serde = { version = "1.0.192", default-features = false, features = ["alloc", "derive"] } serde_json = { version = "1.0", default-features = false } -syn = { version = "1.0", features = ["full", "extra-traits"] } tempfile = "3.8" tokio = { version = "1.39", features = ["full"] } toml = "0.8.0" diff --git a/Makefile b/Makefile index 8d63166..7ff3079 100644 --- a/Makefile +++ b/Makefile @@ -29,14 +29,13 @@ lint: ## cargo check and clippy. Skip clippy on guest code since it's not suppo dprint check cargo +nightly fmt --all --check cargo check --all-targets --all-features - $(MAKE) check-fuzz - SKIP_GUEST_BUILD=1 cargo clippy --all-targets --all-features + cargo clippy --all-targets --all-features lint-fix: ## dprint fmt, cargo fmt, fix and clippy. Skip clippy on guest code since it's not supported by risc0 dprint fmt cargo +nightly fmt --all cargo fix --allow-dirty - SKIP_GUEST_BUILD=1 cargo clippy --fix --allow-dirty + cargo clippy --fix --allow-dirty docs: ## Generates documentation locally cargo doc --open From 76cd7a9dc69bd9150f09619c98f48fc008673d19 Mon Sep 17 00:00:00 2001 From: yaziciahmet Date: Tue, 8 Oct 2024 10:02:26 +0200 Subject: [PATCH 7/9] Minor cleanup --- src/bitcoin.rs | 1 + src/light_client_prover.rs | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoin.rs b/src/bitcoin.rs index 0b630d5..e37fbfe 100644 --- a/src/bitcoin.rs +++ b/src/bitcoin.rs @@ -129,6 +129,7 @@ impl BitcoinNode { let _ = self.load_wallet(&NodeKind::Bitcoin.to_string()).await; let _ = self.load_wallet(&NodeKind::Sequencer.to_string()).await; let _ = self.load_wallet(&NodeKind::BatchProver.to_string()).await; + let _ = self.load_wallet(&NodeKind::LightClientProver.to_string()).await; } // Switch this over to Node signature once we add support for docker to citrea nodes diff --git a/src/light_client_prover.rs b/src/light_client_prover.rs index 5ca6bfc..b97e9f7 100644 --- a/src/light_client_prover.rs +++ b/src/light_client_prover.rs @@ -10,7 +10,6 @@ use crate::node::Node; pub type LightClientProver = Node; impl LightClientProver { - // TODO: remove _l at the end pub async fn wait_for_l1_height(&self, height: u64, timeout: Option) -> Result<()> { let start = SystemTime::now(); let timeout = timeout.unwrap_or(Duration::from_secs(600)); From dce3ea30d7abacfca11f2505970b0eafc09fd7ec Mon Sep 17 00:00:00 2001 From: yaziciahmet Date: Tue, 8 Oct 2024 10:04:15 +0200 Subject: [PATCH 8/9] Fix comment --- src/traits.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/traits.rs b/src/traits.rs index 51835d4..ad897fe 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -21,7 +21,7 @@ pub enum SpawnOutput { } /// The Node trait defines the common interface shared between -/// BitcoinNode, BatchProver, Sequencer and FullNode +/// BitcoinNode, BatchProver, LightClientProver, Sequencer and FullNode #[async_trait] pub trait NodeT: Send { type Config: Send; From 2797a2199669e79d24f14d260ebc5cb5970c6a99 Mon Sep 17 00:00:00 2001 From: yaziciahmet Date: Tue, 8 Oct 2024 10:05:04 +0200 Subject: [PATCH 9/9] Lint --- src/bitcoin.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bitcoin.rs b/src/bitcoin.rs index e37fbfe..39194a9 100644 --- a/src/bitcoin.rs +++ b/src/bitcoin.rs @@ -129,7 +129,9 @@ impl BitcoinNode { let _ = self.load_wallet(&NodeKind::Bitcoin.to_string()).await; let _ = self.load_wallet(&NodeKind::Sequencer.to_string()).await; let _ = self.load_wallet(&NodeKind::BatchProver.to_string()).await; - let _ = self.load_wallet(&NodeKind::LightClientProver.to_string()).await; + let _ = self + .load_wallet(&NodeKind::LightClientProver.to_string()) + .await; } // Switch this over to Node signature once we add support for docker to citrea nodes