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

chore(starknet_sequencer_node): add validation function to active com… #2600

Merged
merged 5 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 3 additions & 63 deletions config/sequencer/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,7 @@
"components.consensus_manager.execution_mode": {
"description": "The component execution mode.",
"privacy": "Public",
"value": "LocalExecutionWithRemoteDisabled"
},
"components.consensus_manager.local_server_config.#is_none": {
"description": "Flag for an optional field.",
"privacy": "TemporaryValue",
"value": false
},
"components.consensus_manager.local_server_config.channel_buffer_size": {
"description": "The communication channel buffer size.",
"privacy": "Public",
"value": 32
"value": "Enabled"
},
"components.consensus_manager.remote_client_config.#is_none": {
"description": "Flag for an optional field.",
Expand All @@ -294,16 +284,6 @@
"privacy": "Public",
"value": "0.0.0.0:8080"
},
"components.consensus_manager.remote_server_config.#is_none": {
"description": "Flag for an optional field.",
"privacy": "TemporaryValue",
"value": true
},
"components.consensus_manager.remote_server_config.socket": {
"description": "The remote component server socket.",
"privacy": "Public",
"value": "0.0.0.0:8080"
},
"components.gateway.execution_mode": {
"description": "The component execution mode.",
"privacy": "Public",
Expand Down Expand Up @@ -357,17 +337,7 @@
"components.http_server.execution_mode": {
"description": "The component execution mode.",
"privacy": "Public",
"value": "LocalExecutionWithRemoteEnabled"
},
"components.http_server.local_server_config.#is_none": {
"description": "Flag for an optional field.",
"privacy": "TemporaryValue",
"value": false
},
"components.http_server.local_server_config.channel_buffer_size": {
"description": "The communication channel buffer size.",
"privacy": "Public",
"value": 32
"value": "Enabled"
},
"components.http_server.remote_client_config.#is_none": {
"description": "Flag for an optional field.",
Expand All @@ -394,16 +364,6 @@
"privacy": "Public",
"value": "0.0.0.0:8080"
},
"components.http_server.remote_server_config.#is_none": {
"description": "Flag for an optional field.",
"privacy": "TemporaryValue",
"value": false
},
"components.http_server.remote_server_config.socket": {
"description": "The remote component server socket.",
"privacy": "Public",
"value": "0.0.0.0:8080"
},
"components.mempool.execution_mode": {
"description": "The component execution mode.",
"privacy": "Public",
Expand Down Expand Up @@ -507,17 +467,7 @@
"components.monitoring_endpoint.execution_mode": {
"description": "The component execution mode.",
"privacy": "Public",
"value": "LocalExecutionWithRemoteEnabled"
},
"components.monitoring_endpoint.local_server_config.#is_none": {
"description": "Flag for an optional field.",
"privacy": "TemporaryValue",
"value": false
},
"components.monitoring_endpoint.local_server_config.channel_buffer_size": {
"description": "The communication channel buffer size.",
"privacy": "Public",
"value": 32
"value": "Enabled"
},
"components.monitoring_endpoint.remote_client_config.#is_none": {
"description": "Flag for an optional field.",
Expand All @@ -544,16 +494,6 @@
"privacy": "Public",
"value": "0.0.0.0:8080"
},
"components.monitoring_endpoint.remote_server_config.#is_none": {
"description": "Flag for an optional field.",
"privacy": "TemporaryValue",
"value": false
},
"components.monitoring_endpoint.remote_server_config.socket": {
"description": "The remote component server socket.",
"privacy": "Public",
"value": "0.0.0.0:8080"
},
"components.state_sync.execution_mode": {
"description": "The component execution mode.",
"privacy": "Public",
Expand Down
17 changes: 6 additions & 11 deletions crates/starknet_integration_tests/src/config_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use starknet_sequencer_infra::component_definitions::{
use starknet_sequencer_infra::test_utils::get_available_socket;
use starknet_sequencer_node::config::component_config::ComponentConfig;
use starknet_sequencer_node::config::component_execution_config::{
ActiveComponentExecutionConfig,
ReactiveComponentExecutionConfig,
ReactiveComponentExecutionMode,
};
Expand Down Expand Up @@ -125,28 +126,22 @@ pub fn get_local_with_remote_enabled_component_config(
}

pub async fn get_http_only_component_config(gateway_socket: SocketAddr) -> ComponentConfig {
let monitoring_endpoint_socket = get_available_socket().await;
ComponentConfig {
http_server: ReactiveComponentExecutionConfig::http_server_default_config(),
http_server: ActiveComponentExecutionConfig::default(),
gateway: get_remote_component_config(gateway_socket),
monitoring_endpoint: get_local_with_remote_enabled_component_config(
monitoring_endpoint_socket,
),
monitoring_endpoint: Default::default(),
batcher: get_disabled_component_config(),
consensus_manager: get_disabled_component_config(),
consensus_manager: ActiveComponentExecutionConfig::disabled(),
mempool: get_disabled_component_config(),
mempool_p2p: get_disabled_component_config(),
state_sync: get_disabled_component_config(),
}
}

pub async fn get_non_http_component_config(gateway_socket: SocketAddr) -> ComponentConfig {
let monitoring_endpoint_socket = get_available_socket().await;
ComponentConfig {
http_server: get_disabled_component_config(),
monitoring_endpoint: get_local_with_remote_enabled_component_config(
monitoring_endpoint_socket,
),
http_server: ActiveComponentExecutionConfig::disabled(),
monitoring_endpoint: Default::default(),
gateway: get_local_with_remote_enabled_component_config(gateway_socket),
..ComponentConfig::default()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use starknet_mempool_p2p::config::MempoolP2pConfig;
use starknet_mempool_p2p::MEMPOOL_TOPIC;
use starknet_sequencer_node::config::component_config::ComponentConfig;
use starknet_sequencer_node::config::component_execution_config::{
ActiveComponentExecutionConfig,
ReactiveComponentExecutionConfig,
ReactiveComponentExecutionMode,
};
Expand Down Expand Up @@ -58,11 +59,7 @@ async fn test_mempool_sends_tx_to_other_peer(mut tx_generator: MultiAccountTrans

// Derive the configuration for the mempool node.
let components = ComponentConfig {
consensus_manager: ReactiveComponentExecutionConfig {
execution_mode: ReactiveComponentExecutionMode::Disabled,
local_server_config: None,
..Default::default()
},
consensus_manager: ActiveComponentExecutionConfig::disabled(),
batcher: ReactiveComponentExecutionConfig {
execution_mode: ReactiveComponentExecutionMode::Disabled,
local_server_config: None,
Expand Down
25 changes: 13 additions & 12 deletions crates/starknet_sequencer_node/src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ use starknet_monitoring_endpoint::monitoring_endpoint::{
use starknet_state_sync_types::communication::EmptyStateSyncClient;

use crate::clients::SequencerNodeClients;
use crate::config::component_execution_config::ReactiveComponentExecutionMode;
use crate::config::component_execution_config::{
ActiveComponentExecutionMode,
ReactiveComponentExecutionMode,
};
use crate::config::node_config::SequencerNodeConfig;
use crate::version::VERSION_FULL;

Expand Down Expand Up @@ -44,8 +47,7 @@ pub fn create_node_components(
ReactiveComponentExecutionMode::Disabled | ReactiveComponentExecutionMode::Remote => None,
};
let consensus_manager = match config.components.consensus_manager.execution_mode {
ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled
| ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled => {
ActiveComponentExecutionMode::Enabled => {
let batcher_client =
clients.get_batcher_shared_client().expect("Batcher Client should be available");
// TODO(shahak): Use the real client once we connect state sync to the node.
Expand All @@ -56,7 +58,7 @@ pub fn create_node_components(
state_sync_client,
))
}
ReactiveComponentExecutionMode::Disabled | ReactiveComponentExecutionMode::Remote => None,
ActiveComponentExecutionMode::Disabled => None,
};
let gateway = match config.components.gateway.execution_mode {
ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled
Expand All @@ -74,14 +76,13 @@ pub fn create_node_components(
ReactiveComponentExecutionMode::Disabled | ReactiveComponentExecutionMode::Remote => None,
};
let http_server = match config.components.http_server.execution_mode {
ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled
| ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled => {
ActiveComponentExecutionMode::Enabled => {
let gateway_client =
clients.get_gateway_shared_client().expect("Gateway Client should be available");

Some(create_http_server(config.http_server_config.clone(), gateway_client))
}
ReactiveComponentExecutionMode::Disabled | ReactiveComponentExecutionMode::Remote => None,
ActiveComponentExecutionMode::Disabled => None,
};

let (mempool_p2p_propagator, mempool_p2p_runner) = match config
Expand Down Expand Up @@ -115,11 +116,11 @@ pub fn create_node_components(
};

let monitoring_endpoint = match config.components.monitoring_endpoint.execution_mode {
ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled => Some(
create_monitoring_endpoint(config.monitoring_endpoint_config.clone(), VERSION_FULL),
),
ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled => None,
ReactiveComponentExecutionMode::Disabled | ReactiveComponentExecutionMode::Remote => None,
ActiveComponentExecutionMode::Enabled => Some(create_monitoring_endpoint(
config.monitoring_endpoint_config.clone(),
VERSION_FULL,
)),
ActiveComponentExecutionMode::Disabled => None,
};

SequencerNodeComponents {
Expand Down
29 changes: 18 additions & 11 deletions crates/starknet_sequencer_node/src/config/component_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,48 @@ use papyrus_config::{ParamPath, SerializedParam};
use serde::{Deserialize, Serialize};
use validator::Validate;

use crate::config::component_execution_config::ReactiveComponentExecutionConfig;
use crate::config::component_execution_config::{
ActiveComponentExecutionConfig,
ReactiveComponentExecutionConfig,
};

/// The components configuration.
#[derive(Clone, Debug, Serialize, Deserialize, Validate, PartialEq)]
pub struct ComponentConfig {
// Reactive component configs.
#[validate]
pub batcher: ReactiveComponentExecutionConfig,
#[validate]
pub consensus_manager: ReactiveComponentExecutionConfig,
#[validate]
pub gateway: ReactiveComponentExecutionConfig,
#[validate]
pub http_server: ReactiveComponentExecutionConfig,
#[validate]
pub mempool: ReactiveComponentExecutionConfig,
#[validate]
pub mempool_p2p: ReactiveComponentExecutionConfig,
#[validate]
pub monitoring_endpoint: ReactiveComponentExecutionConfig,
#[validate]
pub state_sync: ReactiveComponentExecutionConfig,

// Active component configs.
#[validate]
pub consensus_manager: ActiveComponentExecutionConfig,
#[validate]
pub http_server: ActiveComponentExecutionConfig,
#[validate]
pub monitoring_endpoint: ActiveComponentExecutionConfig,
}

impl Default for ComponentConfig {
fn default() -> Self {
Self {
// Reactive component configs.
batcher: ReactiveComponentExecutionConfig::batcher_default_config(),
consensus_manager: ReactiveComponentExecutionConfig::consensus_manager_default_config(),
gateway: ReactiveComponentExecutionConfig::gateway_default_config(),
http_server: ReactiveComponentExecutionConfig::http_server_default_config(),
mempool: ReactiveComponentExecutionConfig::mempool_default_config(),
mempool_p2p: ReactiveComponentExecutionConfig::mempool_p2p_default_config(),
monitoring_endpoint:
ReactiveComponentExecutionConfig::monitoring_endpoint_default_config(),
state_sync: ReactiveComponentExecutionConfig::state_sync_default_config(),
// Active component configs.
consensus_manager: Default::default(),
http_server: Default::default(),
monitoring_endpoint: Default::default(),
}
}
}
Expand Down
Loading
Loading