diff --git a/bin/ethlambda/src/main.rs b/bin/ethlambda/src/main.rs index bc5c9a1..f23ea58 100644 --- a/bin/ethlambda/src/main.rs +++ b/bin/ethlambda/src/main.rs @@ -54,6 +54,9 @@ struct CliOptions { /// Whether this node acts as a committee aggregator #[arg(long, default_value = "false")] is_aggregator: bool, + /// Number of attestation committees (subnets) per slot + #[arg(long, default_value = "1", value_parser = clap::value_parser!(u64).range(1..))] + attestation_committee_count: u64, } #[tokio::main] @@ -130,6 +133,7 @@ async fn main() -> eyre::Result<()> { p2p_rx, store.clone(), first_validator_id, + options.attestation_committee_count, )); ethlambda_rpc::start_rpc_server(metrics_socket, store) diff --git a/crates/blockchain/src/lib.rs b/crates/blockchain/src/lib.rs index d30c72e..ad0b9ea 100644 --- a/crates/blockchain/src/lib.rs +++ b/crates/blockchain/src/lib.rs @@ -48,9 +48,6 @@ pub const MILLISECONDS_PER_SLOT: u64 = 4_000; pub const MILLISECONDS_PER_INTERVAL: u64 = 800; /// Number of intervals per slot (5 intervals of 800ms = 4 seconds). pub const INTERVALS_PER_SLOT: u64 = 5; -/// Number of attestation committees per slot. -pub const ATTESTATION_COMMITTEE_COUNT: u64 = 1; - impl BlockChain { pub fn spawn( store: Store, diff --git a/crates/net/p2p/src/lib.rs b/crates/net/p2p/src/lib.rs index 697fa6d..4e2a465 100644 --- a/crates/net/p2p/src/lib.rs +++ b/crates/net/p2p/src/lib.rs @@ -4,7 +4,7 @@ use std::{ time::Duration, }; -use ethlambda_blockchain::{ATTESTATION_COMMITTEE_COUNT, BlockChain, P2PMessage}; +use ethlambda_blockchain::{BlockChain, P2PMessage}; use ethlambda_storage::Store; use ethlambda_types::primitives::H256; use ethrex_common::H264; @@ -56,6 +56,7 @@ pub(crate) struct PendingRequest { pub(crate) last_peer: Option, } +#[allow(clippy::too_many_arguments)] pub async fn start_p2p( node_key: Vec, bootnodes: Vec, @@ -64,6 +65,7 @@ pub async fn start_p2p( p2p_rx: mpsc::UnboundedReceiver, store: Store, validator_id: Option, + attestation_committee_count: u64, ) { let config = libp2p::gossipsub::ConfigBuilder::default() // d @@ -175,9 +177,8 @@ pub async fn start_p2p( .unwrap(); // Subscribe to attestation subnet topic (validators subscribe to their committee's subnet) - // ATTESTATION_COMMITTEE_COUNT is 1 for devnet-3 but will increase in future devnets. - #[allow(clippy::modulo_one)] - let subnet_id = validator_id.map(|vid| vid % ATTESTATION_COMMITTEE_COUNT); + // attestation_committee_count is validated to be >= 1 by clap at CLI parse time. + let subnet_id = validator_id.map(|vid| vid % attestation_committee_count); let attestation_topic_kind = match subnet_id { Some(id) => format!("{ATTESTATION_SUBNET_TOPIC_PREFIX}_{id}"), // Non-validators subscribe to subnet 0 to receive attestations