Skip to content

Commit 230a8b0

Browse files
authored
apollo_node: add local committer server (#11564)
1 parent 1555210 commit 230a8b0

File tree

4 files changed

+48
-3
lines changed

4 files changed

+48
-3
lines changed

crates/apollo_committer/src/committer.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ use apollo_committer_types::committer_types::{
1010
RevertBlockResponse,
1111
};
1212
use apollo_committer_types::errors::{CommitterError, CommitterResult};
13+
use apollo_infra::component_definitions::{default_component_start_fn, ComponentStarter};
14+
use async_trait::async_trait;
1315
use starknet_api::block::BlockNumber;
1416
use starknet_api::block_hash::state_diff_hash::calculate_state_diff_hash;
1517
use starknet_api::core::{GlobalRoot, StateDiffCommitment};
@@ -33,6 +35,8 @@ use starknet_patricia_storage::map_storage::MapStorage;
3335
use starknet_patricia_storage::storage_trait::{DbValue, Storage};
3436
use tracing::{debug, error, info, warn};
3537

38+
use crate::metrics::register_metrics;
39+
3640
#[cfg(test)]
3741
#[path = "committer_test.rs"]
3842
mod committer_test;
@@ -289,3 +293,11 @@ impl<S: StorageConstructor, CB: CommitBlockTrait> Committer<S, CB> {
289293
CommitterError::Internal { height: self.offset, message: error_message }
290294
}
291295
}
296+
297+
#[async_trait]
298+
impl ComponentStarter for ApolloCommitter {
299+
async fn start(&mut self) {
300+
default_component_start_fn::<Self>().await;
301+
register_metrics();
302+
}
303+
}

crates/apollo_committer/src/communication.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use apollo_infra::component_server::{LocalComponentServer, RemoteComponentServer
44
use async_trait::async_trait;
55
use starknet_committer::block_committer::commit::CommitBlockTrait;
66

7-
use crate::committer::{Committer, StorageConstructor};
7+
use crate::committer::{ApolloCommitter, Committer, StorageConstructor};
88

9-
pub type LocalCommitterServer<S, CB> =
10-
LocalComponentServer<Committer<S, CB>, CommitterRequest, CommitterResponse>;
9+
pub type LocalCommitterServer =
10+
LocalComponentServer<ApolloCommitter, CommitterRequest, CommitterResponse>;
1111
pub type RemoteCommitterServer = RemoteComponentServer<CommitterRequest, CommitterResponse>;
1212

1313
#[async_trait]

crates/apollo_committer/src/metrics.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ use apollo_metrics::define_infra_metrics;
1010

1111
// TODO(Yoav): Add the committer metrics and panels.
1212
define_infra_metrics!(committer);
13+
14+
pub fn register_metrics() {}

crates/apollo_node/src/servers.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ use apollo_batcher::communication::{LocalBatcherServer, RemoteBatcherServer};
55
use apollo_batcher::metrics::BATCHER_INFRA_METRICS;
66
use apollo_class_manager::communication::{LocalClassManagerServer, RemoteClassManagerServer};
77
use apollo_class_manager::metrics::CLASS_MANAGER_INFRA_METRICS;
8+
use apollo_committer::communication::{LocalCommitterServer, RemoteCommitterServer};
9+
use apollo_committer::metrics::COMMITTER_INFRA_METRICS;
810
use apollo_compile_to_casm::communication::{
911
LocalSierraCompilerServer,
1012
RemoteSierraCompilerServer,
@@ -73,6 +75,7 @@ use crate::components::SequencerNodeComponents;
7375
struct LocalServers {
7476
pub(crate) batcher: Option<Box<LocalBatcherServer>>,
7577
pub(crate) class_manager: Option<Box<LocalClassManagerServer>>,
78+
pub(crate) committer: Option<Box<LocalCommitterServer>>,
7679
pub(crate) config_manager: Option<Box<LocalConfigManagerServer>>,
7780
pub(crate) gateway: Option<Box<LocalGatewayServer>>,
7881
pub(crate) l1_provider: Option<Box<LocalL1ProviderServer>>,
@@ -103,6 +106,7 @@ struct WrapperServers {
103106
pub struct RemoteServers {
104107
pub batcher: Option<Box<RemoteBatcherServer>>,
105108
pub class_manager: Option<Box<RemoteClassManagerServer>>,
109+
pub committer: Option<Box<RemoteCommitterServer>>,
106110
// Note: we explicitly avoid adding a config manager runner server to the remote servers as it
107111
// is not used for remote connections.
108112
pub gateway: Option<Box<RemoteGatewayServer>>,
@@ -316,6 +320,20 @@ fn create_local_servers(
316320
config.components.class_manager.max_concurrency
317321
);
318322

323+
let committer_server = create_local_server!(
324+
REGULAR_LOCAL_SERVER,
325+
&config.components.committer.execution_mode,
326+
&mut components.committer,
327+
&config
328+
.components
329+
.committer
330+
.local_server_config
331+
.as_ref()
332+
.expect("Committer local server config should be available."),
333+
communication.take_committer_rx(),
334+
&COMMITTER_INFRA_METRICS.get_local_server_metrics()
335+
);
336+
319337
let config_manager_server = create_local_server!(
320338
CONCURRENT_LOCAL_SERVER,
321339
&config.components.config_manager.execution_mode,
@@ -450,6 +468,7 @@ fn create_local_servers(
450468
LocalServers {
451469
batcher: batcher_server,
452470
class_manager: class_manager_server,
471+
committer: committer_server,
453472
config_manager: config_manager_server,
454473
gateway: gateway_server,
455474
l1_provider: l1_provider_server,
@@ -477,6 +496,7 @@ impl LocalServers {
477496
create_servers(vec![
478497
server_future_and_label(self.batcher, "Local Batcher"),
479498
server_future_and_label(self.class_manager, "Local Class Manager"),
499+
server_future_and_label(self.committer, "Local Committer"),
480500
server_future_and_label(self.config_manager, "Local Config Manager"),
481501
server_future_and_label(self.gateway, "Local Gateway"),
482502
server_future_and_label(self.l1_provider, "Local L1 Provider"),
@@ -513,6 +533,15 @@ pub fn create_remote_servers(
513533
CLASS_MANAGER_INFRA_METRICS.get_remote_server_metrics()
514534
);
515535

536+
let committer_server = create_remote_server!(
537+
&config.components.committer.execution_mode,
538+
|| { clients.get_committer_local_client() },
539+
config.components.committer.remote_server_config,
540+
config.components.committer.port,
541+
config.components.committer.max_concurrency,
542+
COMMITTER_INFRA_METRICS.get_remote_server_metrics()
543+
);
544+
516545
let gateway_server = create_remote_server!(
517546
&config.components.gateway.execution_mode,
518547
|| { clients.get_gateway_local_client() },
@@ -588,6 +617,7 @@ pub fn create_remote_servers(
588617
RemoteServers {
589618
batcher: batcher_server,
590619
class_manager: class_manager_server,
620+
committer: committer_server,
591621
gateway: gateway_server,
592622
l1_provider: l1_provider_server,
593623
l1_gas_price_provider: l1_gas_price_provider_server,
@@ -604,6 +634,7 @@ impl RemoteServers {
604634
create_servers(vec![
605635
server_future_and_label(self.batcher, "Remote Batcher"),
606636
server_future_and_label(self.class_manager, "Remote Class Manager"),
637+
server_future_and_label(self.committer, "Remote Committer"),
607638
server_future_and_label(self.gateway, "Remote Gateway"),
608639
server_future_and_label(self.l1_provider, "Remote L1 Provider"),
609640
server_future_and_label(self.l1_gas_price_provider, "Remote L1 Gas Price Provider"),

0 commit comments

Comments
 (0)