Skip to content

Commit c61cf86

Browse files
committed
config: Add clementine node to config.
1 parent 04c6ea2 commit c61cf86

File tree

2 files changed

+82
-7
lines changed

2 files changed

+82
-7
lines changed

src/config/mod.rs

Lines changed: 80 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ mod utils;
88

99
use std::path::PathBuf;
1010

11-
pub use clementine::{ClementineClient, ClementineConfig};
1211
pub use bitcoin::BitcoinConfig;
12+
pub use clementine::{ClementineClient, ClementineConfig};
1313
pub use docker::DockerConfig;
1414
pub use rollup::{default_rollup_config, RollupConfig};
1515
use serde::Serialize;
@@ -41,7 +41,6 @@ pub struct FullL2NodeConfig<T> {
4141
pub type FullSequencerConfig = FullL2NodeConfig<SequencerConfig>;
4242
pub type FullBatchProverConfig = FullL2NodeConfig<BatchProverConfig>;
4343
pub type FullLightClientProverConfig = FullL2NodeConfig<LightClientProverConfig>;
44-
pub type FullVerifierConfig = FullL2NodeConfig<ClementineConfig>;
4544
pub type FullFullNodeConfig = FullL2NodeConfig<()>;
4645

4746
pub trait NodeKindMarker {
@@ -64,10 +63,6 @@ impl NodeKindMarker for FullFullNodeConfig {
6463
const KIND: NodeKind = NodeKind::FullNode;
6564
}
6665

67-
impl NodeKindMarker for FullVerifierConfig {
68-
const KIND: NodeKind = NodeKind::Verifier;
69-
}
70-
7166
impl<T: Clone + Serialize> Config for FullL2NodeConfig<T>
7267
where
7368
FullL2NodeConfig<T>: NodeKindMarker,
@@ -105,6 +100,10 @@ where
105100
fn rollup_config(&self) -> &RollupConfig {
106101
&self.rollup
107102
}
103+
104+
fn clementine_config(&self) -> &ClementineConfig {
105+
unimplemented!()
106+
}
108107
}
109108

110109
impl<T: Clone + Serialize> LogPathProvider for FullL2NodeConfig<T>
@@ -123,3 +122,78 @@ where
123122
self.dir().join("stderr.log")
124123
}
125124
}
125+
126+
#[derive(Clone, Debug)]
127+
pub struct ClementineNodeConfig<T> {
128+
pub node: T,
129+
pub config: ClementineConfig,
130+
pub docker_image: Option<String>,
131+
pub dir: PathBuf,
132+
pub env: Vec<(&'static str, &'static str)>,
133+
}
134+
135+
pub type FullVerifierConfig = ClementineNodeConfig<ClementineConfig>;
136+
137+
impl NodeKindMarker for FullVerifierConfig {
138+
const KIND: NodeKind = NodeKind::Verifier;
139+
}
140+
141+
impl<T: Clone + Serialize> Config for ClementineNodeConfig<T>
142+
where
143+
ClementineNodeConfig<T>: NodeKindMarker,
144+
{
145+
type NodeConfig = T;
146+
147+
fn dir(&self) -> &PathBuf {
148+
&self.dir
149+
}
150+
151+
fn rpc_bind_host(&self) -> &str {
152+
&self.config.client.host
153+
}
154+
155+
fn rpc_bind_port(&self) -> u16 {
156+
self.config.client.port
157+
}
158+
159+
fn env(&self) -> Vec<(&'static str, &'static str)> {
160+
self.env.clone()
161+
}
162+
163+
fn node_config(&self) -> Option<&Self::NodeConfig> {
164+
if std::mem::size_of::<T>() == 0 {
165+
None
166+
} else {
167+
Some(&self.node)
168+
}
169+
}
170+
171+
fn node_kind() -> NodeKind {
172+
<Self as NodeKindMarker>::KIND
173+
}
174+
175+
fn rollup_config(&self) -> &RollupConfig {
176+
unimplemented!()
177+
}
178+
179+
fn clementine_config(&self) -> &ClementineConfig {
180+
&self.config
181+
}
182+
}
183+
184+
impl<T: Clone + Serialize> LogPathProvider for ClementineNodeConfig<T>
185+
where
186+
ClementineNodeConfig<T>: Config,
187+
{
188+
fn kind() -> NodeKind {
189+
Self::node_kind()
190+
}
191+
192+
fn log_path(&self) -> PathBuf {
193+
self.dir().join("stdout.log")
194+
}
195+
196+
fn stderr_path(&self) -> PathBuf {
197+
self.dir().join("stderr.log")
198+
}
199+
}

src/node.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use tracing::{info, trace};
1717

1818
use crate::{
1919
client::Client,
20-
config::{config_to_file, RollupConfig},
20+
config::{config_to_file, ClementineConfig, RollupConfig},
2121
log_provider::LogPathProvider,
2222
traits::{NodeT, Restart, SpawnOutput},
2323
utils::{get_citrea_path, get_genesis_path},
@@ -57,6 +57,7 @@ pub trait Config: Clone {
5757
fn node_config(&self) -> Option<&Self::NodeConfig>;
5858
fn node_kind() -> NodeKind;
5959
fn rollup_config(&self) -> &RollupConfig;
60+
fn clementine_config(&self) -> &ClementineConfig;
6061
}
6162

6263
pub struct Node<C: Config + LogPathProvider> {

0 commit comments

Comments
 (0)