Skip to content

Commit 7a30efc

Browse files
committed
apollo_consensus_orchestrator: use the config manager client to update consensus context config
1 parent 1fd82a4 commit 7a30efc

File tree

12 files changed

+52
-2
lines changed

12 files changed

+52
-2
lines changed

Cargo.lock

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/apollo_config_manager/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ apollo_config.workspace = true
1616
apollo_config_manager_config.workspace = true
1717
apollo_config_manager_types.workspace = true
1818
apollo_consensus_config.workspace = true
19+
apollo_consensus_orchestrator_config.workspace = true
1920
apollo_infra.workspace = true
2021
apollo_mempool_config.workspace = true
2122
apollo_metrics.workspace = true

crates/apollo_config_manager/src/config_manager.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use apollo_config_manager_config::config::ConfigManagerConfig;
22
use apollo_config_manager_types::communication::{ConfigManagerRequest, ConfigManagerResponse};
33
use apollo_config_manager_types::config_manager_types::ConfigManagerResult;
44
use apollo_consensus_config::config::ConsensusDynamicConfig;
5+
use apollo_consensus_orchestrator_config::config::ContextDynamicConfig;
56
use apollo_infra::component_definitions::{ComponentRequestHandler, ComponentStarter};
67
use apollo_mempool_config::config::MempoolDynamicConfig;
78
use apollo_node_config::node_config::NodeDynamicConfig;
@@ -38,6 +39,10 @@ impl ConfigManager {
3839
Ok(self.latest_node_dynamic_config.consensus_dynamic_config.as_ref().unwrap().clone())
3940
}
4041

42+
pub(crate) fn get_context_dynamic_config(&self) -> ConfigManagerResult<ContextDynamicConfig> {
43+
Ok(self.latest_node_dynamic_config.context_dynamic_config.as_ref().unwrap().clone())
44+
}
45+
4146
pub(crate) fn get_mempool_dynamic_config(&self) -> ConfigManagerResult<MempoolDynamicConfig> {
4247
Ok(self.latest_node_dynamic_config.mempool_dynamic_config.as_ref().unwrap().clone())
4348
}
@@ -54,6 +59,9 @@ impl ComponentRequestHandler<ConfigManagerRequest, ConfigManagerResponse> for Co
5459
self.get_consensus_dynamic_config(),
5560
)
5661
}
62+
ConfigManagerRequest::GetContextDynamicConfig => {
63+
ConfigManagerResponse::GetContextDynamicConfig(self.get_context_dynamic_config())
64+
}
5765
ConfigManagerRequest::GetMempoolDynamicConfig => {
5866
ConfigManagerResponse::GetMempoolDynamicConfig(self.get_mempool_dynamic_config())
5967
}

crates/apollo_config_manager_types/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ workspace = true
1010

1111
[dependencies]
1212
apollo_consensus_config.workspace = true
13+
apollo_consensus_orchestrator_config.workspace = true
1314
apollo_infra.workspace = true
1415
apollo_mempool_config.workspace = true
1516
apollo_metrics.workspace = true

crates/apollo_config_manager_types/src/communication.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::sync::Arc;
22

33
use apollo_consensus_config::config::ConsensusDynamicConfig;
4+
use apollo_consensus_orchestrator_config::config::ContextDynamicConfig;
45
use apollo_infra::component_client::{ClientError, LocalComponentClient, RemoteComponentClient};
56
use apollo_infra::component_definitions::{ComponentClient, PrioritizedRequest, RequestWrapper};
67
use apollo_infra::{impl_debug_for_infra_requests_and_responses, impl_labeled_request};
@@ -32,6 +33,8 @@ pub trait ConfigManagerClient: Send + Sync {
3233
&self,
3334
) -> ConfigManagerClientResult<ConsensusDynamicConfig>;
3435

36+
async fn get_context_dynamic_config(&self) -> ConfigManagerClientResult<ContextDynamicConfig>;
37+
3538
async fn get_mempool_dynamic_config(&self) -> ConfigManagerClientResult<MempoolDynamicConfig>;
3639

3740
async fn set_node_dynamic_config(
@@ -48,6 +51,7 @@ pub trait ConfigManagerClient: Send + Sync {
4851
)]
4952
pub enum ConfigManagerRequest {
5053
GetConsensusDynamicConfig,
54+
GetContextDynamicConfig,
5155
GetMempoolDynamicConfig,
5256
SetNodeDynamicConfig(NodeDynamicConfig),
5357
}
@@ -65,6 +69,7 @@ generate_permutation_labels! {
6569
#[derive(Clone, Serialize, Deserialize, AsRefStr)]
6670
pub enum ConfigManagerResponse {
6771
GetConsensusDynamicConfig(ConfigManagerResult<ConsensusDynamicConfig>),
72+
GetContextDynamicConfig(ConfigManagerResult<ContextDynamicConfig>),
6873
GetMempoolDynamicConfig(ConfigManagerResult<MempoolDynamicConfig>),
6974
SetNodeDynamicConfig(ConfigManagerResult<()>),
7075
}
@@ -96,6 +101,17 @@ where
96101
)
97102
}
98103

104+
async fn get_context_dynamic_config(&self) -> ConfigManagerClientResult<ContextDynamicConfig> {
105+
let request = ConfigManagerRequest::GetContextDynamicConfig;
106+
handle_all_response_variants!(
107+
ConfigManagerResponse,
108+
GetContextDynamicConfig,
109+
ConfigManagerClientError,
110+
ConfigManagerError,
111+
Direct
112+
)
113+
}
114+
99115
async fn get_mempool_dynamic_config(&self) -> ConfigManagerClientResult<MempoolDynamicConfig> {
100116
let request = ConfigManagerRequest::GetMempoolDynamicConfig;
101117
handle_all_response_variants!(

crates/apollo_consensus_manager/src/consensus_manager.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ impl ConsensusManager {
144144
let consensus_context = self.create_sequencer_consensus_context(
145145
&votes_broadcast_channels,
146146
outbound_internal_sender,
147+
self.config_manager_client.clone(),
147148
);
148149

149150
let current_height =
@@ -264,6 +265,7 @@ impl ConsensusManager {
264265
&self,
265266
votes_broadcast_channels: &BroadcastTopicChannels<Vote>,
266267
outbound_internal_sender: mpsc::Sender<(HeightAndRound, mpsc::Receiver<ProposalPart>)>,
268+
config_manager_client: SharedConfigManagerClient,
267269
) -> SequencerConsensusContext {
268270
SequencerConsensusContext::new(
269271
self.config.context_config.clone(),
@@ -282,6 +284,7 @@ impl ConsensusManager {
282284
clock: Arc::new(DefaultClock),
283285
outbound_proposal_sender: outbound_internal_sender,
284286
vote_broadcast_client: votes_broadcast_channels.broadcast_topic_client.clone(),
287+
config_manager_client: Some(Arc::clone(&config_manager_client)),
285288
},
286289
)
287290
}

crates/apollo_consensus_orchestrator/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ apollo_batcher.workspace = true
1111
apollo_batcher_types.workspace = true
1212
apollo_class_manager_types.workspace = true
1313
apollo_config.workspace = true
14+
apollo_config_manager_types.workspace = true
1415
apollo_consensus.workspace = true
1516
apollo_consensus_orchestrator_config.workspace = true
1617
apollo_infra_utils.workspace = true

crates/apollo_consensus_orchestrator/src/build_proposal_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use apollo_class_manager_types::transaction_converter::{
1313
TransactionConverterError,
1414
};
1515
use apollo_consensus::types::{ProposalCommitment as ConsensusProposalCommitment, Round};
16-
use apollo_consensus_orchestrator_config::config::{ContextConfig, ContextDynamicConfig};
16+
use apollo_consensus_orchestrator_config::config::ContextConfig;
1717
use apollo_infra::component_client::ClientError;
1818
use apollo_protobuf::consensus::{ConsensusBlockInfo, ProposalInit, ProposalPart};
1919
use apollo_state_sync_types::communication::StateSyncClientError;

crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use apollo_batcher_types::batcher_types::{
1818
};
1919
use apollo_batcher_types::communication::BatcherClient;
2020
use apollo_class_manager_types::transaction_converter::TransactionConverterTrait;
21+
use apollo_config_manager_types::communication::SharedConfigManagerClient;
2122
use apollo_consensus::types::{
2223
ConsensusContext,
2324
ConsensusError,
@@ -177,6 +178,7 @@ pub struct SequencerConsensusContextDeps {
177178
pub outbound_proposal_sender: mpsc::Sender<(HeightAndRound, mpsc::Receiver<ProposalPart>)>,
178179
// Used to broadcast votes to other consensus nodes.
179180
pub vote_broadcast_client: BroadcastTopicClient<Vote>,
181+
pub config_manager_client: Option<SharedConfigManagerClient>,
180182
}
181183

182184
impl SequencerConsensusContext {
@@ -726,6 +728,10 @@ impl ConsensusContext for SequencerConsensusContext {
726728
assert!(round > self.current_round);
727729
self.interrupt_active_proposal().await;
728730
self.current_round = round;
731+
if let Some(config_manager_client) = self.deps.config_manager_client.clone() {
732+
self.config.dynamic_config =
733+
config_manager_client.get_context_dynamic_config().await.unwrap();
734+
}
729735
let mut to_process = None;
730736
while let Some(entry) = self.queued_proposals.first_entry() {
731737
match self.current_round.cmp(entry.key()) {

crates/apollo_consensus_orchestrator/src/test_utils.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ impl From<TestDeps> for SequencerConsensusContextDeps {
107107
clock: deps.clock,
108108
outbound_proposal_sender: deps.outbound_proposal_sender,
109109
vote_broadcast_client: deps.vote_broadcast_client,
110+
config_manager_client: None,
110111
}
111112
}
112113
}

0 commit comments

Comments
 (0)