diff --git a/config/mempool/default_config.json b/config/mempool/default_config.json index 0525672a8b..9f113d5f54 100644 --- a/config/mempool/default_config.json +++ b/config/mempool/default_config.json @@ -559,6 +559,86 @@ "privacy": "Public", "value": 5 }, + "consensus_manager_config.consensus_config.network_config.advertised_multiaddr": { + "description": "The external address other peers see this node. If this is set, the node will not try to find out which addresses it has and will write this address as external instead", + "privacy": "Public", + "value": "" + }, + "consensus_manager_config.consensus_config.network_config.advertised_multiaddr.#is_none": { + "description": "Flag for an optional field.", + "privacy": "TemporaryValue", + "value": true + }, + "consensus_manager_config.consensus_config.network_config.bootstrap_peer_multiaddr": { + "description": "The multiaddress of the peer node. It should include the peer's id. For more info: https://docs.libp2p.io/concepts/fundamentals/peers/", + "privacy": "Public", + "value": "" + }, + "consensus_manager_config.consensus_config.network_config.bootstrap_peer_multiaddr.#is_none": { + "description": "Flag for an optional field.", + "privacy": "TemporaryValue", + "value": true + }, + "consensus_manager_config.consensus_config.network_config.chain_id": { + "description": "The chain to follow. For more details see https://docs.starknet.io/documentation/architecture_and_concepts/Blocks/transactions/#chain-id.", + "pointer_target": "chain_id", + "privacy": "Public" + }, + "consensus_manager_config.consensus_config.network_config.discovery_config.bootstrap_dial_retry_config.base_delay_millis": { + "description": "The base delay in milliseconds for the exponential backoff strategy.", + "privacy": "Public", + "value": 2 + }, + "consensus_manager_config.consensus_config.network_config.discovery_config.bootstrap_dial_retry_config.factor": { + "description": "The factor for the exponential backoff strategy.", + "privacy": "Public", + "value": 5 + }, + "consensus_manager_config.consensus_config.network_config.discovery_config.bootstrap_dial_retry_config.max_delay": { + "description": "The maximum delay in seconds for the exponential backoff strategy.", + "privacy": "Public", + "value": 5 + }, + "consensus_manager_config.consensus_config.network_config.discovery_config.heartbeat_interval": { + "description": "The interval between each discovery (Kademlia) query in milliseconds.", + "privacy": "Public", + "value": 100 + }, + "consensus_manager_config.consensus_config.network_config.idle_connection_timeout": { + "description": "Amount of time in seconds that a connection with no active sessions will stay alive.", + "privacy": "Public", + "value": 120 + }, + "consensus_manager_config.consensus_config.network_config.peer_manager_config.malicious_timeout": { + "description": "The duration a peer is blacklisted after being marked as malicious.", + "privacy": "Public", + "value": 31536000 + }, + "consensus_manager_config.consensus_config.network_config.peer_manager_config.unstable_timeout": { + "description": "The duration a peer blacklisted after being reported as unstable.", + "privacy": "Public", + "value": 1 + }, + "consensus_manager_config.consensus_config.network_config.quic_port": { + "description": "The port that the node listens on for incoming quic connections.", + "privacy": "Public", + "value": 10101 + }, + "consensus_manager_config.consensus_config.network_config.secret_key": { + "description": "The secret key used for building the peer id. If it's an empty string a random one will be used.", + "privacy": "Private", + "value": "" + }, + "consensus_manager_config.consensus_config.network_config.session_timeout": { + "description": "Maximal time in seconds that each session can take before failing on timeout.", + "privacy": "Public", + "value": 120 + }, + "consensus_manager_config.consensus_config.network_config.tcp_port": { + "description": "The port that the node listens on for incoming tcp connections.", + "privacy": "Public", + "value": 10100 + }, "consensus_manager_config.consensus_config.network_topic": { "description": "The network topic of the consensus.", "privacy": "Public", diff --git a/config/papyrus/default_config.json b/config/papyrus/default_config.json index 12f7ed668f..e2a382053c 100644 --- a/config/papyrus/default_config.json +++ b/config/papyrus/default_config.json @@ -84,6 +84,86 @@ "privacy": "Public", "value": 5 }, + "consensus.network_config.advertised_multiaddr": { + "description": "The external address other peers see this node. If this is set, the node will not try to find out which addresses it has and will write this address as external instead", + "privacy": "Public", + "value": "" + }, + "consensus.network_config.advertised_multiaddr.#is_none": { + "description": "Flag for an optional field.", + "privacy": "TemporaryValue", + "value": true + }, + "consensus.network_config.bootstrap_peer_multiaddr": { + "description": "The multiaddress of the peer node. It should include the peer's id. For more info: https://docs.libp2p.io/concepts/fundamentals/peers/", + "privacy": "Public", + "value": "" + }, + "consensus.network_config.bootstrap_peer_multiaddr.#is_none": { + "description": "Flag for an optional field.", + "privacy": "TemporaryValue", + "value": true + }, + "consensus.network_config.chain_id": { + "description": "The chain to follow. For more details see https://docs.starknet.io/documentation/architecture_and_concepts/Blocks/transactions/#chain-id.", + "pointer_target": "chain_id", + "privacy": "Public" + }, + "consensus.network_config.discovery_config.bootstrap_dial_retry_config.base_delay_millis": { + "description": "The base delay in milliseconds for the exponential backoff strategy.", + "privacy": "Public", + "value": 2 + }, + "consensus.network_config.discovery_config.bootstrap_dial_retry_config.factor": { + "description": "The factor for the exponential backoff strategy.", + "privacy": "Public", + "value": 5 + }, + "consensus.network_config.discovery_config.bootstrap_dial_retry_config.max_delay": { + "description": "The maximum delay in seconds for the exponential backoff strategy.", + "privacy": "Public", + "value": 5 + }, + "consensus.network_config.discovery_config.heartbeat_interval": { + "description": "The interval between each discovery (Kademlia) query in milliseconds.", + "privacy": "Public", + "value": 100 + }, + "consensus.network_config.idle_connection_timeout": { + "description": "Amount of time in seconds that a connection with no active sessions will stay alive.", + "privacy": "Public", + "value": 120 + }, + "consensus.network_config.peer_manager_config.malicious_timeout": { + "description": "The duration a peer is blacklisted after being marked as malicious.", + "privacy": "Public", + "value": 31536000 + }, + "consensus.network_config.peer_manager_config.unstable_timeout": { + "description": "The duration a peer blacklisted after being reported as unstable.", + "privacy": "Public", + "value": 1 + }, + "consensus.network_config.quic_port": { + "description": "The port that the node listens on for incoming quic connections.", + "privacy": "Public", + "value": 10101 + }, + "consensus.network_config.secret_key": { + "description": "The secret key used for building the peer id. If it's an empty string a random one will be used.", + "privacy": "Private", + "value": "" + }, + "consensus.network_config.session_timeout": { + "description": "Maximal time in seconds that each session can take before failing on timeout.", + "privacy": "Public", + "value": 120 + }, + "consensus.network_config.tcp_port": { + "description": "The port that the node listens on for incoming tcp connections.", + "privacy": "Public", + "value": 10100 + }, "consensus.network_topic": { "description": "The network topic of the consensus.", "privacy": "Public", diff --git a/crates/papyrus_node/src/config/snapshots/papyrus_node__config__config_test__dump_default_config.snap b/crates/papyrus_node/src/config/snapshots/papyrus_node__config__config_test__dump_default_config.snap index 824b775cb5..7499810c42 100644 --- a/crates/papyrus_node/src/config/snapshots/papyrus_node__config__config_test__dump_default_config.snap +++ b/crates/papyrus_node/src/config/snapshots/papyrus_node__config__config_test__dump_default_config.snap @@ -1,6 +1,5 @@ --- source: crates/papyrus_node/src/config/config_test.rs -assertion_line: 101 expression: dumped_default_config --- { @@ -97,6 +96,106 @@ expression: dumped_default_config }, "privacy": "Public" }, + "consensus.network_config.advertised_multiaddr": { + "description": "The external address other peers see this node. If this is set, the node will not try to find out which addresses it has and will write this address as external instead", + "value": "", + "privacy": "Public" + }, + "consensus.network_config.advertised_multiaddr.#is_none": { + "description": "Flag for an optional field.", + "value": true, + "privacy": "TemporaryValue" + }, + "consensus.network_config.bootstrap_peer_multiaddr": { + "description": "The multiaddress of the peer node. It should include the peer's id. For more info: https://docs.libp2p.io/concepts/fundamentals/peers/", + "value": "", + "privacy": "Public" + }, + "consensus.network_config.bootstrap_peer_multiaddr.#is_none": { + "description": "Flag for an optional field.", + "value": true, + "privacy": "TemporaryValue" + }, + "consensus.network_config.chain_id": { + "description": "The chain to follow. For more details see https://docs.starknet.io/documentation/architecture_and_concepts/Blocks/transactions/#chain-id.", + "value": "SN_MAIN", + "privacy": "Public" + }, + "consensus.network_config.discovery_config.bootstrap_dial_retry_config.base_delay_millis": { + "description": "The base delay in milliseconds for the exponential backoff strategy.", + "value": { + "$serde_json::private::Number": "2" + }, + "privacy": "Public" + }, + "consensus.network_config.discovery_config.bootstrap_dial_retry_config.factor": { + "description": "The factor for the exponential backoff strategy.", + "value": { + "$serde_json::private::Number": "5" + }, + "privacy": "Public" + }, + "consensus.network_config.discovery_config.bootstrap_dial_retry_config.max_delay": { + "description": "The maximum delay in seconds for the exponential backoff strategy.", + "value": { + "$serde_json::private::Number": "5" + }, + "privacy": "Public" + }, + "consensus.network_config.discovery_config.heartbeat_interval": { + "description": "The interval between each discovery (Kademlia) query in milliseconds.", + "value": { + "$serde_json::private::Number": "100" + }, + "privacy": "Public" + }, + "consensus.network_config.idle_connection_timeout": { + "description": "Amount of time in seconds that a connection with no active sessions will stay alive.", + "value": { + "$serde_json::private::Number": "120" + }, + "privacy": "Public" + }, + "consensus.network_config.peer_manager_config.malicious_timeout": { + "description": "The duration a peer is blacklisted after being marked as malicious.", + "value": { + "$serde_json::private::Number": "31536000" + }, + "privacy": "Public" + }, + "consensus.network_config.peer_manager_config.unstable_timeout": { + "description": "The duration a peer blacklisted after being reported as unstable.", + "value": { + "$serde_json::private::Number": "1" + }, + "privacy": "Public" + }, + "consensus.network_config.quic_port": { + "description": "The port that the node listens on for incoming quic connections.", + "value": { + "$serde_json::private::Number": "10101" + }, + "privacy": "Public" + }, + "consensus.network_config.secret_key": { + "description": "The secret key used for building the peer id. If it's an empty string a random one will be used.", + "value": "", + "privacy": "Private" + }, + "consensus.network_config.session_timeout": { + "description": "Maximal time in seconds that each session can take before failing on timeout.", + "value": { + "$serde_json::private::Number": "120" + }, + "privacy": "Public" + }, + "consensus.network_config.tcp_port": { + "description": "The port that the node listens on for incoming tcp connections.", + "value": { + "$serde_json::private::Number": "10100" + }, + "privacy": "Public" + }, "consensus.network_topic": { "description": "The network topic of the consensus.", "value": "consensus", diff --git a/crates/sequencing/papyrus_consensus/src/config.rs b/crates/sequencing/papyrus_consensus/src/config.rs index e748891d17..03ef73f065 100644 --- a/crates/sequencing/papyrus_consensus/src/config.rs +++ b/crates/sequencing/papyrus_consensus/src/config.rs @@ -11,6 +11,7 @@ use papyrus_config::converters::{ }; use papyrus_config::dumping::{append_sub_config_name, ser_param, SerializeConfig}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; +use papyrus_network::NetworkConfig; use serde::{Deserialize, Serialize}; use starknet_api::block::BlockNumber; @@ -33,6 +34,9 @@ pub struct ConsensusConfig { pub consensus_delay: Duration, /// Timeouts configuration for consensus. pub timeouts: TimeoutsConfig, + // TODO(Dan/Matan): validate configs (#[validate]). + /// The network configuration for the consensus. + pub network_config: NetworkConfig, } impl SerializeConfig for ConsensusConfig { @@ -70,12 +74,17 @@ impl SerializeConfig for ConsensusConfig { ), ]); config.extend(append_sub_config_name(self.timeouts.dump(), "timeouts")); + config.extend(append_sub_config_name(self.network_config.dump(), "network_config")); config } } impl Default for ConsensusConfig { fn default() -> Self { + let mut network_config = NetworkConfig::default(); + // TODO(Dan/Shahak): consider something nicer, maybe a builder? + network_config.tcp_port = 10100; + network_config.quic_port = 10101; Self { validator_id: ValidatorId::default(), network_topic: "consensus".to_string(), @@ -83,6 +92,7 @@ impl Default for ConsensusConfig { num_validators: 1, consensus_delay: Duration::from_secs(5), timeouts: TimeoutsConfig::default(), + network_config, } } }