Skip to content

Commit

Permalink
chore(consensus): add network config
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-starkware committed Nov 4, 2024
1 parent 3705f80 commit bd4dcc9
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
80 changes: 80 additions & 0 deletions config/mempool/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 10 additions & 0 deletions crates/sequencing/papyrus_consensus/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 {
Expand Down Expand Up @@ -70,19 +74,25 @@ 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(),
start_height: BlockNumber::default(),
num_validators: 1,
consensus_delay: Duration::from_secs(5),
timeouts: TimeoutsConfig::default(),
network_config,
}
}
}
Expand Down

0 comments on commit bd4dcc9

Please sign in to comment.