Skip to content

Commit

Permalink
chore(starknet_sequencer_node): set mempool p2p runner as active comp…
Browse files Browse the repository at this point in the history
…onent

commit-id:b6858d67
  • Loading branch information
Itay-Tsabary-Starkware committed Dec 9, 2024
1 parent 0d606d7 commit 1fe52d8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,21 @@ fn validate_active_component_execution_config(
_ => Ok(()),
}
}

// There are components that are described with a reactive mode setting, however, result in the
// creation of two components: one reactive and one active. The defined behavior is such that
// the active component is active if and only if the local component is running locally. The
// following function applies this logic.
impl From<ReactiveComponentExecutionMode> for ActiveComponentExecutionMode {
fn from(mode: ReactiveComponentExecutionMode) -> Self {
match mode {
ReactiveComponentExecutionMode::Disabled | ReactiveComponentExecutionMode::Remote => {
ActiveComponentExecutionMode::Disabled
}
ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled
| ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled => {
ActiveComponentExecutionMode::Enabled
}
}
}
}
29 changes: 4 additions & 25 deletions crates/starknet_sequencer_node/src/servers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,27 +197,6 @@ macro_rules! create_local_server {
/// }
/// ```
macro_rules! create_wrapper_server {
($execution_mode:expr, $component:expr) => {
match *$execution_mode {
ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled
| ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled => {
Some(Box::new(WrapperServer::new(
$component
.take()
.expect(concat!(stringify!($component), " is not initialized.")),
)))
}
ReactiveComponentExecutionMode::Disabled | ReactiveComponentExecutionMode::Remote => {
None
}
}
};
}

// TODO(Tsabary): the following macro is a copy-pasted version of `create_wrapper_server!` macro,
// with the execution mode types changed. Once all active components have been marked as such, unify
// these.
macro_rules! create_wrapper_server_for_active_component {
($execution_mode:expr, $component:expr) => {
match *$execution_mode {
ActiveComponentExecutionMode::Enabled => Some(Box::new(WrapperServer::new(
Expand Down Expand Up @@ -304,22 +283,22 @@ fn create_wrapper_servers(
config: &SequencerNodeConfig,
components: &mut SequencerNodeComponents,
) -> WrapperServers {
let consensus_manager_server = create_wrapper_server_for_active_component!(
let consensus_manager_server = create_wrapper_server!(
&config.components.consensus_manager.execution_mode,
components.consensus_manager
);
let http_server = create_wrapper_server_for_active_component!(
let http_server = create_wrapper_server!(
&config.components.http_server.execution_mode,
components.http_server
);

let monitoring_endpoint_server = create_wrapper_server_for_active_component!(
let monitoring_endpoint_server = create_wrapper_server!(
&config.components.monitoring_endpoint.execution_mode,
components.monitoring_endpoint
);

let mempool_p2p_runner_server = create_wrapper_server!(
&config.components.mempool_p2p.execution_mode,
&config.components.mempool_p2p.execution_mode.clone().into(),
components.mempool_p2p_runner
);
WrapperServers {
Expand Down

0 comments on commit 1fe52d8

Please sign in to comment.