Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions crates/pathfinder/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ pub mod integration_testing;
pub mod p2p;

#[cfg(feature = "p2p")]
use p2p::cli::{P2PConsensusCli, P2PSyncCli};
use p2p::{P2PConsensusConfig, P2PSyncConfig};
use p2p::cli::{P2PConsensusCli, P2PPreconfirmedCli, P2PSyncCli};
use p2p::{P2PConsensusConfig, P2PPreconfirmedConfig, P2PSyncConfig};

const COMPILER_MEMORY_USAGE_ALLOWED_RANGE: std::ops::RangeInclusive<u64> =
(pathfinder_compiler::ResourceLimits::RECOMMENDED_MEMORY_USAGE_LIMIT_MIB / 2)
Expand Down Expand Up @@ -279,6 +279,14 @@ Examples:
#[clap(flatten)]
consensus: ConsensusCli,

#[cfg(feature = "p2p")]
#[clap(flatten)]
p2p_preconfirmed: P2PPreconfirmedCli,

#[cfg(not(feature = "p2p"))]
#[clap(skip)]
p2p_preconfirmed: (),

#[cfg(not(feature = "p2p"))]
#[clap(skip)]
consensus: (),
Expand Down Expand Up @@ -1078,6 +1086,7 @@ pub struct Config {
pub disable_version_update_check: bool,
pub sync_p2p: P2PSyncConfig,
pub consensus_p2p: P2PConsensusConfig,
pub preconfirmed_p2p: P2PPreconfirmedConfig,
pub debug: DebugConfig,
pub verify_tree_hashes: bool,
pub rpc_batch_concurrency_limit: NonZeroUsize,
Expand Down Expand Up @@ -1373,6 +1382,7 @@ impl Config {
disable_version_update_check: args.disable_version_update_check,
sync_p2p: P2PSyncConfig::parse_or_exit(args.p2p_sync),
consensus_p2p: P2PConsensusConfig::parse_or_exit(args.p2p_consensus),
preconfirmed_p2p: P2PPreconfirmedConfig::parse_or_exit(args.p2p_preconfirmed),
debug: DebugConfig::parse(args.debug),
verify_tree_hashes: args.verify_tree_node_data,
rpc_batch_concurrency_limit: args.rpc_batch_concurrency_limit,
Expand Down
13 changes: 12 additions & 1 deletion crates/pathfinder/src/config/p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod config;
#[cfg(feature = "p2p")]
pub use cli::P2PConsensusCli;
#[cfg(feature = "p2p")]
pub use config::{P2PConsensusConfig, P2PSyncConfig};
pub use config::{P2PConsensusConfig, P2PPreconfirmedConfig, P2PSyncConfig};

#[cfg(not(feature = "p2p"))]
#[derive(Clone)]
Expand All @@ -16,6 +16,10 @@ pub struct P2PSyncConfig;
#[derive(Clone)]
pub struct P2PConsensusConfig;

#[cfg(not(feature = "p2p"))]
#[derive(Clone)]
pub struct P2PPreconfirmedConfig;

#[cfg(not(feature = "p2p"))]
impl P2PSyncConfig {
pub(super) fn parse_or_exit(_: ()) -> Self {
Expand All @@ -29,3 +33,10 @@ impl P2PConsensusConfig {
Self
}
}

#[cfg(not(feature = "p2p"))]
impl P2PPreconfirmedConfig {
pub(super) fn parse_or_exit(_: ()) -> Self {
Self
}
}
7 changes: 7 additions & 0 deletions crates/pathfinder/src/config/p2p/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ Example:

define_p2p_core_cli! {"sync"}
define_p2p_core_cli! {"consensus"}
define_p2p_core_cli! {"preconfirmed"}

#[derive(clap::Args)]
pub(crate) struct P2PSyncCli {
Expand Down Expand Up @@ -208,3 +209,9 @@ pub struct P2PConsensusCli {
#[clap(flatten)]
pub(super) core: P2PConsensusCoreCli,
}

#[derive(clap::Args)]
pub struct P2PPreconfirmedCli {
#[clap(flatten)]
pub(super) core: P2PPreconfirmedCoreCli,
}
26 changes: 24 additions & 2 deletions crates/pathfinder/src/config/p2p/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ use clap::CommandFactory;
use ipnet::IpNet;
use p2p::libp2p::Multiaddr;

use super::cli::{P2PConsensusCli, P2PConsensusCoreCli, P2PSyncCli, P2PSyncCoreCli};
use super::cli::{
P2PConsensusCli,
P2PConsensusCoreCli,
P2PPreconfirmedCli,
P2PPreconfirmedCoreCli,
P2PSyncCli,
P2PSyncCoreCli,
};
use crate::config::Cli;

#[derive(Clone)]
Expand Down Expand Up @@ -40,6 +47,11 @@ pub struct P2PConsensusConfig {
pub core: P2PCoreConfig,
}

#[derive(Clone)]
pub struct P2PPreconfirmedConfig {
pub core: P2PCoreConfig,
}

/// Generates an `impl From` implementation for a given `target` that converts
/// a `P2PTargetCoreCli` struct into a `P2PCoreConfig` struct.
macro_rules! impl_from_p2p_cli {
Expand Down Expand Up @@ -143,8 +155,9 @@ Note: this is the minimum value that should provide normal P2P behaviour and avo
};
}

impl_from_p2p_cli! {"sync"}
impl_from_p2p_cli!("sync");
impl_from_p2p_cli!("consensus");
impl_from_p2p_cli!("preconfirmed");

impl P2PSyncConfig {
pub(crate) fn parse_or_exit(args: P2PSyncCli) -> Self {
Expand Down Expand Up @@ -202,3 +215,12 @@ impl P2PConsensusConfig {
}
}
}

impl P2PPreconfirmedConfig {
pub fn parse_or_exit(args: P2PPreconfirmedCli) -> Self {
Self {
// SAFETY: core conversion is safe because we exit the process on error
core: args.core.into(),
}
}
}
Loading