Skip to content

Commit

Permalink
chore(starknet_sequencer_node): remove option from local server config (
Browse files Browse the repository at this point in the history
starkware-libs#3246)

* chore(starknet_sequencer_node): remove optional from remote client config

commit-id:d7eb969e

* chore(starknet_sequencer_node): remove option from local server config

commit-id:27bc311b
  • Loading branch information
nadin-Starkware authored Jan 12, 2025
1 parent c337e9f commit ca1a932
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 106 deletions.
60 changes: 0 additions & 60 deletions config/sequencer/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -314,21 +314,11 @@
"privacy": "Public",
"value": "LocalExecutionWithRemoteDisabled"
},
"components.batcher.local_server_config.#is_none": {
"description": "Flag for an optional field.",
"privacy": "TemporaryValue",
"value": false
},
"components.batcher.local_server_config.channel_buffer_size": {
"description": "The communication channel buffer size.",
"privacy": "Public",
"value": 32
},
"components.batcher.remote_client_config.#is_none": {
"description": "Flag for an optional field.",
"privacy": "TemporaryValue",
"value": true
},
"components.batcher.remote_client_config.idle_connections": {
"description": "The maximum number of idle connections to keep alive.",
"privacy": "Public",
Expand Down Expand Up @@ -359,21 +349,11 @@
"privacy": "Public",
"value": "LocalExecutionWithRemoteDisabled"
},
"components.gateway.local_server_config.#is_none": {
"description": "Flag for an optional field.",
"privacy": "TemporaryValue",
"value": false
},
"components.gateway.local_server_config.channel_buffer_size": {
"description": "The communication channel buffer size.",
"privacy": "Public",
"value": 32
},
"components.gateway.remote_client_config.#is_none": {
"description": "Flag for an optional field.",
"privacy": "TemporaryValue",
"value": true
},
"components.gateway.remote_client_config.idle_connections": {
"description": "The maximum number of idle connections to keep alive.",
"privacy": "Public",
Expand Down Expand Up @@ -404,21 +384,11 @@
"privacy": "Public",
"value": "LocalExecutionWithRemoteDisabled"
},
"components.l1_provider.local_server_config.#is_none": {
"description": "Flag for an optional field.",
"privacy": "TemporaryValue",
"value": false
},
"components.l1_provider.local_server_config.channel_buffer_size": {
"description": "The communication channel buffer size.",
"privacy": "Public",
"value": 32
},
"components.l1_provider.remote_client_config.#is_none": {
"description": "Flag for an optional field.",
"privacy": "TemporaryValue",
"value": true
},
"components.l1_provider.remote_client_config.idle_connections": {
"description": "The maximum number of idle connections to keep alive.",
"privacy": "Public",
Expand Down Expand Up @@ -449,21 +419,11 @@
"privacy": "Public",
"value": "LocalExecutionWithRemoteDisabled"
},
"components.mempool.local_server_config.#is_none": {
"description": "Flag for an optional field.",
"privacy": "TemporaryValue",
"value": false
},
"components.mempool.local_server_config.channel_buffer_size": {
"description": "The communication channel buffer size.",
"privacy": "Public",
"value": 32
},
"components.mempool.remote_client_config.#is_none": {
"description": "Flag for an optional field.",
"privacy": "TemporaryValue",
"value": true
},
"components.mempool.remote_client_config.idle_connections": {
"description": "The maximum number of idle connections to keep alive.",
"privacy": "Public",
Expand All @@ -489,21 +449,11 @@
"privacy": "Public",
"value": "LocalExecutionWithRemoteDisabled"
},
"components.mempool_p2p.local_server_config.#is_none": {
"description": "Flag for an optional field.",
"privacy": "TemporaryValue",
"value": false
},
"components.mempool_p2p.local_server_config.channel_buffer_size": {
"description": "The communication channel buffer size.",
"privacy": "Public",
"value": 32
},
"components.mempool_p2p.remote_client_config.#is_none": {
"description": "Flag for an optional field.",
"privacy": "TemporaryValue",
"value": true
},
"components.mempool_p2p.remote_client_config.idle_connections": {
"description": "The maximum number of idle connections to keep alive.",
"privacy": "Public",
Expand Down Expand Up @@ -534,21 +484,11 @@
"privacy": "Public",
"value": "LocalExecutionWithRemoteDisabled"
},
"components.state_sync.local_server_config.#is_none": {
"description": "Flag for an optional field.",
"privacy": "TemporaryValue",
"value": false
},
"components.state_sync.local_server_config.channel_buffer_size": {
"description": "The communication channel buffer size.",
"privacy": "Public",
"value": 32
},
"components.state_sync.remote_client_config.#is_none": {
"description": "Flag for an optional field.",
"privacy": "TemporaryValue",
"value": true
},
"components.state_sync.remote_client_config.idle_connections": {
"description": "The maximum number of idle connections to keep alive.",
"privacy": "Public",
Expand Down
12 changes: 5 additions & 7 deletions crates/starknet_sequencer_node/src/clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,11 @@ macro_rules! create_client {
let local_client = Some(<$local_client_type>::new($channel_expr));
Client::new(local_client, None)
}
ReactiveComponentExecutionMode::Remote => match $remote_client_config {
Some(config) => {
let remote_client = Some(<$remote_client_type>::new(config.clone(), $socket));
Client::new(None, remote_client)
}
None => panic!("Remote client configuration is missing."),
},
ReactiveComponentExecutionMode::Remote => {
let remote_client =
Some(<$remote_client_type>::new($remote_client_config.clone(), $socket));
Client::new(None, remote_client)
}
ReactiveComponentExecutionMode::Disabled => Client::new(None, None),
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::BTreeMap;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};

use papyrus_config::dumping::{ser_optional_sub_config, ser_param, SerializeConfig};
use papyrus_config::dumping::{append_sub_config_name, ser_param, SerializeConfig};
use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam};
use serde::{Deserialize, Serialize};
use starknet_sequencer_infra::component_definitions::{LocalServerConfig, RemoteClientConfig};
Expand Down Expand Up @@ -33,8 +33,8 @@ pub enum ActiveComponentExecutionMode {
#[validate(schema(function = "validate_reactive_component_execution_config"))]
pub struct ReactiveComponentExecutionConfig {
pub execution_mode: ReactiveComponentExecutionMode,
pub local_server_config: Option<LocalServerConfig>,
pub remote_client_config: Option<RemoteClientConfig>,
pub local_server_config: LocalServerConfig,
pub remote_client_config: RemoteClientConfig,
pub socket: SocketAddr,
}

Expand All @@ -56,8 +56,8 @@ impl SerializeConfig for ReactiveComponentExecutionConfig {
]);
vec![
members,
ser_optional_sub_config(&self.local_server_config, "local_server_config"),
ser_optional_sub_config(&self.remote_client_config, "remote_client_config"),
append_sub_config_name(self.local_server_config.dump(), "local_server_config"),
append_sub_config_name(self.remote_client_config.dump(), "remote_client_config"),
]
.into_iter()
.flatten()
Expand All @@ -76,26 +76,26 @@ impl ReactiveComponentExecutionConfig {
pub fn disabled() -> Self {
Self {
execution_mode: ReactiveComponentExecutionMode::Disabled,
local_server_config: None,
remote_client_config: None,
local_server_config: LocalServerConfig::default(),
remote_client_config: RemoteClientConfig::default(),
socket: DEFAULT_INVALID_SOCKET,
}
}

pub fn remote(socket: SocketAddr) -> Self {
Self {
execution_mode: ReactiveComponentExecutionMode::Remote,
local_server_config: None,
remote_client_config: Some(RemoteClientConfig::default()),
local_server_config: LocalServerConfig::default(),
remote_client_config: RemoteClientConfig::default(),
socket,
}
}

pub fn local_with_remote_enabled(socket: SocketAddr) -> Self {
Self {
execution_mode: ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled,
local_server_config: Some(LocalServerConfig::default()),
remote_client_config: None,
local_server_config: LocalServerConfig::default(),
remote_client_config: RemoteClientConfig::default(),
socket,
}
}
Expand All @@ -105,8 +105,8 @@ impl ReactiveComponentExecutionConfig {
pub fn local_with_remote_disabled() -> Self {
Self {
execution_mode: ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled,
local_server_config: Some(LocalServerConfig::default()),
remote_client_config: None,
local_server_config: LocalServerConfig::default(),
remote_client_config: RemoteClientConfig::default(),
socket: DEFAULT_INVALID_SOCKET,
}
}
Expand Down Expand Up @@ -152,25 +152,15 @@ impl ActiveComponentExecutionConfig {
fn validate_reactive_component_execution_config(
component_config: &ReactiveComponentExecutionConfig,
) -> Result<(), ValidationError> {
match (
component_config.execution_mode.clone(),
component_config.local_server_config.is_some(),
component_config.remote_client_config.is_some(),
component_config.is_valid_socket(),
) {
(ReactiveComponentExecutionMode::Disabled, false, false, _) => Ok(()),
(ReactiveComponentExecutionMode::Remote, false, true, true) => Ok(()),
(ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled, true, false, true) => {
Ok(())
}
(ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled, true, false, _) => {
Ok(())
}
(mode, local_server_config, remote_client_config, socket) => {
match (component_config.execution_mode.clone(), component_config.is_valid_socket()) {
(ReactiveComponentExecutionMode::Disabled, _) => Ok(()),
(ReactiveComponentExecutionMode::Remote, true) => Ok(()),
(ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled, true) => Ok(()),
(ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled, _) => Ok(()),
(mode, socket) => {
error!(
"Invalid reactive component execution configuration: mode: {:?}, \
local_server_config: {:?}, remote_client_config: {:?}, socket: {:?}",
mode, local_server_config, remote_client_config, socket
"Invalid reactive component execution configuration: mode: {:?}, socket: {:?}",
mode, socket
);
let mut error =
ValidationError::new("Invalid reactive component execution configuration.");
Expand Down
26 changes: 18 additions & 8 deletions crates/starknet_sequencer_node/src/config/config_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,34 @@ const VALID_SOCKET: SocketAddr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0,
/// Test the validation of the struct ReactiveComponentExecutionConfig.
/// Validates that execution mode of the component and the local/remote config are at sync.
#[rstest]
#[case::local(ReactiveComponentExecutionMode::Disabled, None, None, VALID_SOCKET)]
#[case::local(
ReactiveComponentExecutionMode::Disabled,
LocalServerConfig::default(),
RemoteClientConfig::default(),
VALID_SOCKET
)]
#[case::local(
ReactiveComponentExecutionMode::Remote,
None,
Some(RemoteClientConfig::default()),
LocalServerConfig::default(),
RemoteClientConfig::default(),
VALID_SOCKET
)]
#[case::local(
LOCAL_EXECUTION_MODE,
LocalServerConfig::default(),
RemoteClientConfig::default(),
VALID_SOCKET
)]
#[case::local(LOCAL_EXECUTION_MODE, Some(LocalServerConfig::default()), None, VALID_SOCKET)]
#[case::remote(
ENABLE_REMOTE_CONNECTION_MODE,
Some(LocalServerConfig::default()),
None,
LocalServerConfig::default(),
RemoteClientConfig::default(),
VALID_SOCKET
)]
fn test_valid_component_execution_config(
#[case] execution_mode: ReactiveComponentExecutionMode,
#[case] local_server_config: Option<LocalServerConfig>,
#[case] remote_client_config: Option<RemoteClientConfig>,
#[case] local_server_config: LocalServerConfig,
#[case] remote_client_config: RemoteClientConfig,
#[case] socket: SocketAddr,
) {
let component_exe_config = ReactiveComponentExecutionConfig {
Expand Down

0 comments on commit ca1a932

Please sign in to comment.