diff --git a/Cargo.lock b/Cargo.lock index 42fbe5ae72..eda062ceca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9011,6 +9011,7 @@ dependencies = [ "serde_json", "starknet_batcher", "starknet_batcher_types", + "starknet_consensus_manager", "starknet_gateway", "starknet_mempool", "starknet_mempool_infra", diff --git a/config/mempool/default_config.json b/config/mempool/default_config.json index 2d8f6831c8..dfa3b6f36d 100644 --- a/config/mempool/default_config.json +++ b/config/mempool/default_config.json @@ -54,6 +54,51 @@ "privacy": "Public", "value": 3 }, + "components.consensus_manager.component_type": { + "description": "The component type.", + "privacy": "Public", + "value": "AsynchronousComponent" + }, + "components.consensus_manager.execute": { + "description": "The component execution flag.", + "privacy": "Public", + "value": true + }, + "components.consensus_manager.local_config.#is_none": { + "description": "Flag for an optional field.", + "privacy": "TemporaryValue", + "value": false + }, + "components.consensus_manager.local_config.channel_buffer_size": { + "description": "The communication channel buffer size.", + "privacy": "Public", + "value": 32 + }, + "components.consensus_manager.location": { + "description": "The component location.", + "privacy": "Public", + "value": "Local" + }, + "components.consensus_manager.remote_config.#is_none": { + "description": "Flag for an optional field.", + "privacy": "TemporaryValue", + "value": true + }, + "components.consensus_manager.remote_config.ip": { + "description": "The remote component server ip.", + "privacy": "Public", + "value": "0.0.0.0" + }, + "components.consensus_manager.remote_config.port": { + "description": "The remote component server port.", + "privacy": "Public", + "value": 8080 + }, + "components.consensus_manager.remote_config.retries": { + "description": "The max number of retries for sending a message.", + "privacy": "Public", + "value": 3 + }, "components.gateway.component_type": { "description": "The component type.", "privacy": "Public", @@ -144,6 +189,11 @@ "privacy": "Public", "value": 3 }, + "consensus_manager_config.consensus_config_param_1": { + "description": "The first consensus manager configuration parameter", + "privacy": "Public", + "value": 1 + }, "gateway_config.network_config.ip": { "description": "The gateway server ip.", "privacy": "Public", diff --git a/crates/mempool_node/Cargo.toml b/crates/mempool_node/Cargo.toml index ab746499ec..9a7f959429 100644 --- a/crates/mempool_node/Cargo.toml +++ b/crates/mempool_node/Cargo.toml @@ -18,6 +18,7 @@ rstest.workspace = true serde.workspace = true starknet_batcher.workspace = true starknet_batcher_types.workspace = true +starknet_consensus_manager.workspace = true starknet_gateway.workspace = true starknet_mempool.workspace = true starknet_mempool_infra.workspace = true diff --git a/crates/mempool_node/src/config/config_test.rs b/crates/mempool_node/src/config/config_test.rs index a520bc5445..70919b0f26 100644 --- a/crates/mempool_node/src/config/config_test.rs +++ b/crates/mempool_node/src/config/config_test.rs @@ -124,6 +124,10 @@ fn test_invalid_components_config() { // Initialize an invalid config and check that the validator finds an error. let component_config = ComponentConfig { batcher: ComponentExecutionConfig { execute: false, ..ComponentExecutionConfig::default() }, + consensus_manager: ComponentExecutionConfig { + execute: false, + ..ComponentExecutionConfig::default() + }, gateway: ComponentExecutionConfig { execute: false, ..ComponentExecutionConfig::default() }, mempool: ComponentExecutionConfig { execute: false, ..ComponentExecutionConfig::default() }, }; @@ -138,11 +142,13 @@ fn test_invalid_components_config() { /// Test the validation of the struct ComponentConfig. /// The validation validates at least one of the components is set with execute: true. #[rstest] -#[case(true, false, false)] -#[case(false, true, false)] -#[case(false, false, true)] +#[case(true, false, false, false)] +#[case(false, true, false, false)] +#[case(false, false, true, false)] +#[case(false, false, false, true)] fn test_valid_components_config( #[case] batcher_component_execute: bool, + #[case] consensus_manager_component_execute: bool, #[case] gateway_component_execute: bool, #[case] mempool_component_execute: bool, ) { @@ -152,6 +158,10 @@ fn test_valid_components_config( execute: batcher_component_execute, ..ComponentExecutionConfig::default() }, + consensus_manager: ComponentExecutionConfig { + execute: consensus_manager_component_execute, + ..ComponentExecutionConfig::default() + }, gateway: ComponentExecutionConfig { execute: gateway_component_execute, ..ComponentExecutionConfig::default() diff --git a/crates/mempool_node/src/config/mod.rs b/crates/mempool_node/src/config/mod.rs index e045ac7d34..9f7ff51809 100644 --- a/crates/mempool_node/src/config/mod.rs +++ b/crates/mempool_node/src/config/mod.rs @@ -16,6 +16,7 @@ use papyrus_config::loading::load_and_process_config; use papyrus_config::{ConfigError, ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use starknet_batcher::config::BatcherConfig; +use starknet_consensus_manager::config::ConsensusManagerConfig; use starknet_gateway::config::{GatewayConfig, RpcStateReaderConfig}; use starknet_mempool_infra::component_definitions::{ LocalComponentCommunicationConfig, @@ -137,6 +138,16 @@ impl ComponentExecutionConfig { remote_config: None, } } + + pub fn consensus_manager_default_config() -> Self { + Self { + execute: true, + location: LocationType::Local, + component_type: ComponentType::AsynchronousComponent, + local_config: Some(LocalComponentCommunicationConfig::default()), + remote_config: None, + } + } } pub fn validate_single_component_config( @@ -169,6 +180,8 @@ pub struct ComponentConfig { #[validate] pub batcher: ComponentExecutionConfig, #[validate] + pub consensus_manager: ComponentExecutionConfig, + #[validate] pub gateway: ComponentExecutionConfig, #[validate] pub mempool: ComponentExecutionConfig, @@ -178,6 +191,7 @@ impl Default for ComponentConfig { fn default() -> Self { Self { batcher: ComponentExecutionConfig::batcher_default_config(), + consensus_manager: ComponentExecutionConfig::consensus_manager_default_config(), gateway: ComponentExecutionConfig::gateway_default_config(), mempool: ComponentExecutionConfig::mempool_default_config(), } @@ -189,6 +203,7 @@ impl SerializeConfig for ComponentConfig { #[allow(unused_mut)] let mut sub_configs = vec![ append_sub_config_name(self.batcher.dump(), "batcher"), + append_sub_config_name(self.consensus_manager.dump(), "consensus_manager"), append_sub_config_name(self.gateway.dump(), "gateway"), append_sub_config_name(self.mempool.dump(), "mempool"), ]; @@ -198,7 +213,11 @@ impl SerializeConfig for ComponentConfig { } pub fn validate_components_config(components: &ComponentConfig) -> Result<(), ValidationError> { - if components.gateway.execute || components.mempool.execute || components.batcher.execute { + if components.gateway.execute + || components.mempool.execute + || components.batcher.execute + || components.consensus_manager.execute + { return Ok(()); } @@ -215,6 +234,8 @@ pub struct MempoolNodeConfig { #[validate] pub batcher_config: BatcherConfig, #[validate] + pub consensus_manager_config: ConsensusManagerConfig, + #[validate] pub gateway_config: GatewayConfig, #[validate] pub rpc_state_reader_config: RpcStateReaderConfig, @@ -228,6 +249,10 @@ impl SerializeConfig for MempoolNodeConfig { let mut sub_configs = vec![ append_sub_config_name(self.components.dump(), "components"), append_sub_config_name(self.batcher_config.dump(), "batcher_config"), + append_sub_config_name( + self.consensus_manager_config.dump(), + "consensus_manager_config", + ), append_sub_config_name(self.gateway_config.dump(), "gateway_config"), append_sub_config_name(self.rpc_state_reader_config.dump(), "rpc_state_reader_config"), append_sub_config_name(self.compiler_config.dump(), "compiler_config"),