-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor rollup initialization #1714
Open
rakanalh
wants to merge
12
commits into
nightly
Choose a base branch
from
rakanalh/refactor-rollup
base: nightly
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0f6f838
Refactor rollup initialization
rakanalh 59d3d3d
Move sync_l1 to common
rakanalh c508688
WIP move instantiation of L1BlockHandler
rakanalh 83c440f
Remove unnecessary comment
rakanalh e534f81
Lots of changes
rakanalh 700a794
Better way to spawn multiple services
rakanalh dfb8cb5
Finalize node initialization
rakanalh 61f9ba7
Fix tests
rakanalh 96f8fab
Fix clippy
rakanalh 108f165
Rename argument
rakanalh e5f028a
Merge remote-tracking branch 'origin/nightly' into rakanalh/refactor-…
rakanalh 9ac87b6
Move native stuff in light client to services
rakanalh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
use anyhow::Context; | ||
use citrea::NetworkArg; | ||
use citrea_common::{ | ||
from_toml_path, BatchProverConfig, FromEnv, LightClientProverConfig, SequencerConfig, | ||
}; | ||
use clap::{command, Parser}; | ||
|
||
#[derive(clap::ValueEnum, Clone, Debug)] | ||
pub(crate) enum SupportedDaLayer { | ||
Mock, | ||
Bitcoin, | ||
} | ||
|
||
#[derive(Parser, Debug)] | ||
#[command(author, version, about, long_about = None)] | ||
pub(crate) struct Args { | ||
/// The mode in which the node runs. | ||
/// This determines which guest code to use. | ||
/// Default is Mainnet. | ||
#[clap(short, long, default_value_t, value_enum)] | ||
pub(crate) network: NetworkArg, | ||
|
||
/// Run the development chain | ||
#[arg(long, default_value_t)] | ||
pub(crate) dev: bool, | ||
|
||
/// Run the regtest chain | ||
#[arg(long, default_value_t, conflicts_with = "dev")] | ||
pub(crate) dev_all_forks: bool, | ||
|
||
/// Path to the genesis configuration. | ||
/// Defines the genesis of module states like evm. | ||
#[arg(long)] | ||
pub(crate) genesis_paths: String, | ||
|
||
/// The data layer type. | ||
#[arg(long, default_value = "mock")] | ||
pub(crate) da_layer: SupportedDaLayer, | ||
|
||
/// The path to the rollup config, if a string is provided, it will be used as the path to the rollup config, otherwise environment variables will be used. | ||
#[arg(long)] | ||
pub(crate) rollup_config_path: Option<String>, | ||
|
||
/// The option to run the node in sequencer mode, if a string is provided, it will be used as the path to the sequencer config, otherwise environment variables will be used. | ||
#[arg(long, conflicts_with_all = ["batch_prover", "light_client_prover"])] | ||
pub(crate) sequencer: Option<Option<String>>, | ||
|
||
/// The option to run the node in batch prover mode, if a string is provided, it will be used as the path to the batch prover config, otherwise the environment variables will be used. | ||
#[arg(long, conflicts_with_all = ["sequencer", "light_client_prover"])] | ||
pub(crate) batch_prover: Option<Option<String>>, | ||
|
||
/// The option to run the node in light client prover mode, if a string is provided, it will be used as the path to the light client prover config, otherwise the environment variables will be used. | ||
#[arg(long, conflicts_with_all = ["sequencer", "batch_prover"])] | ||
pub(crate) light_client_prover: Option<Option<String>>, | ||
|
||
/// Logging verbosity | ||
#[arg(long, short = 'v', action = clap::ArgAction::Count, default_value = "2")] | ||
pub(crate) verbose: u8, | ||
/// Logging verbosity | ||
#[arg(long, short = 'q', action)] | ||
pub(crate) quiet: bool, | ||
} | ||
|
||
pub(crate) enum NodeType { | ||
Sequencer(SequencerConfig), | ||
FullNode, | ||
BatchProver(BatchProverConfig), | ||
LightClientProver(LightClientProverConfig), | ||
} | ||
|
||
pub(crate) fn node_type_from_args(args: &Args) -> anyhow::Result<NodeType> { | ||
let sequencer_config = match &args.sequencer { | ||
Some(Some(path)) => Some( | ||
from_toml_path(path) | ||
.context("Failed to read sequencer configuration from the config file")?, | ||
), | ||
Some(None) => Some( | ||
SequencerConfig::from_env() | ||
.context("Failed to read sequencer configuration from the environment")?, | ||
), | ||
None => None, | ||
}; | ||
|
||
let batch_prover_config = match &args.batch_prover { | ||
Some(Some(path)) => Some( | ||
from_toml_path(path) | ||
.context("Failed to read prover configuration from the config file")?, | ||
), | ||
Some(None) => Some( | ||
BatchProverConfig::from_env() | ||
.context("Failed to read prover configuration from the environment")?, | ||
), | ||
None => None, | ||
}; | ||
|
||
let light_client_prover_config = match &args.light_client_prover { | ||
Some(Some(path)) => Some( | ||
from_toml_path(path) | ||
.context("Failed to read prover configuration from the config file")?, | ||
), | ||
Some(None) => Some( | ||
LightClientProverConfig::from_env() | ||
.context("Failed to read prover configuration from the environment")?, | ||
), | ||
None => None, | ||
}; | ||
|
||
if let Some(sequencer_config) = sequencer_config { | ||
return Ok(NodeType::Sequencer(sequencer_config)); | ||
} else if let Some(batch_prover_config) = batch_prover_config { | ||
return Ok(NodeType::BatchProver(batch_prover_config)); | ||
} else if let Some(light_client_prover_config) = light_client_prover_config { | ||
return Ok(NodeType::LightClientProver(light_client_prover_config)); | ||
} | ||
Ok(NodeType::FullNode) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wish we had it the other way round and passed a
--kind
arg or something. Would let us have a single config field (+ the rollup config) and not be implicit about which node kind is running.We would match on the kind here and get the config accordingly.