Skip to content
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

feat(cli)!: make committee size configurable in iota start #5162

Merged
merged 12 commits into from
Feb 6, 2025
22 changes: 19 additions & 3 deletions crates/iota/src/iota_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,17 @@ pub enum IotaCommand {
#[arg(long = "no-full-node")]
no_full_node: bool,

/// Set the number of validators in the network. If a genesis was
/// already generated with a specific number of validators, this
/// will not override it; the user should recreate the
/// genesis with the desired number of validators.
#[clap(long)]
committee_size: Option<usize>,

/// The path to local migration snapshot files
#[arg(long, name = "path", num_args(0..))]
local_migration_snapshots: Vec<PathBuf>,

/// Remotely stored migration snapshots.
#[arg(long, name = "iota|<full-url>", num_args(0..))]
remote_migration_snapshots: Vec<SnapshotUrl>,
Expand Down Expand Up @@ -391,6 +399,7 @@ impl IotaCommand {
#[cfg(feature = "indexer")]
data_ingestion_dir,
no_full_node,
committee_size,
epoch_duration_ms,
local_migration_snapshots,
remote_migration_snapshots,
Expand All @@ -408,6 +417,7 @@ impl IotaCommand {
#[cfg(feature = "indexer")]
data_ingestion_dir,
no_full_node,
committee_size,
local_migration_snapshots,
remote_migration_snapshots,
delegator,
Expand Down Expand Up @@ -635,6 +645,7 @@ async fn start(
fullnode_rpc_port: u16,
#[cfg(feature = "indexer")] mut data_ingestion_dir: Option<PathBuf>,
no_full_node: bool,
committee_size: Option<usize>,
local_migration_snapshots: Vec<PathBuf>,
remote_migration_snapshots: Vec<SnapshotUrl>,
delegator: Option<IotaAddress>,
Expand Down Expand Up @@ -682,13 +693,18 @@ async fn start(
let config = config_dir.clone().map_or_else(iota_config_dir, Ok)?;
let network_config_path = config.clone().join(IOTA_NETWORK_CONFIG);

let committee_size = match committee_size {
Some(x) => NonZeroUsize::new(x),
None => NonZeroUsize::new(DEFAULT_NUMBER_OF_AUTHORITIES),
}
.ok_or_else(|| anyhow!("Committee size must be at least 1."))?;

let mut swarm_builder = Swarm::builder();

// If this is set, then no data will be persisted between runs, and a new
// genesis will be generated each run.
if force_regenesis {
swarm_builder =
swarm_builder.committee_size(NonZeroUsize::new(DEFAULT_NUMBER_OF_AUTHORITIES).unwrap());
swarm_builder = swarm_builder.committee_size(committee_size);
let mut genesis_config = GenesisConfig::custom_genesis(1, 100);
let local_snapshots = local_migration_snapshots
.into_iter()
Expand Down Expand Up @@ -722,7 +738,7 @@ async fn start(
epoch_duration_ms,
None,
false,
DEFAULT_NUMBER_OF_AUTHORITIES,
committee_size.into(),
local_migration_snapshots,
remote_migration_snapshots,
delegator,
Expand Down
1 change: 1 addition & 0 deletions crates/iota/tests/cli_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ async fn test_start() -> Result<(), anyhow::Error> {
with_faucet: None,
faucet_amount: None,
fullnode_rpc_port: 9000,
committee_size: None,
epoch_duration_ms: None,
#[cfg(feature = "indexer")]
indexer_feature_args: IndexerFeatureArgs::for_testing(),
Expand Down
Loading