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

update qs key loading #15401

Merged
merged 4 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
16 changes: 14 additions & 2 deletions consensus/src/epoch_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ impl<P: OnChainConfigProvider> EpochManager<P> {
epoch_state: &EpochState,
network_sender: NetworkSender,
consensus_config: &OnChainConsensusConfig,
consensus_key: Option<Arc<PrivateKey>>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this is required, can we remove the Option?

) -> (
Arc<dyn TPayloadManager>,
QuorumStoreClient,
Expand Down Expand Up @@ -701,6 +702,7 @@ impl<P: OnChainConfigProvider> EpochManager<P> {
self.config.safety_rules.backend.clone(),
self.quorum_store_storage.clone(),
!consensus_config.is_dag_enabled(),
consensus_key,
))
} else {
info!("Building DirectMempool");
Expand Down Expand Up @@ -1199,7 +1201,11 @@ impl<P: OnChainConfigProvider> EpochManager<P> {
);

let (network_sender, payload_client, payload_manager) = self
.initialize_shared_component(&epoch_state, &consensus_config)
.initialize_shared_component(
&epoch_state,
&consensus_config,
loaded_consensus_key.clone(),
)
.await;

let (rand_msg_tx, rand_msg_rx) = aptos_channel::new::<AccountAddress, IncomingRandGenRequest>(
Expand Down Expand Up @@ -1249,6 +1255,7 @@ impl<P: OnChainConfigProvider> EpochManager<P> {
&mut self,
epoch_state: &EpochState,
consensus_config: &OnChainConsensusConfig,
consensus_key: Option<Arc<PrivateKey>>,
) -> (
NetworkSender,
Arc<dyn PayloadClient>,
Expand All @@ -1258,7 +1265,12 @@ impl<P: OnChainConfigProvider> EpochManager<P> {
self.quorum_store_enabled = self.enable_quorum_store(consensus_config);
let network_sender = self.create_network_sender(epoch_state);
let (payload_manager, quorum_store_client, quorum_store_builder) = self
.init_payload_provider(epoch_state, network_sender.clone(), consensus_config)
.init_payload_provider(
epoch_state,
network_sender.clone(),
consensus_config,
consensus_key,
)
.await;
let effective_vtxn_config = consensus_config.effective_validator_txn_config();
debug!("effective_vtxn_config={:?}", effective_vtxn_config);
Expand Down
20 changes: 9 additions & 11 deletions consensus/src/quorum_store/quorum_store_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ use aptos_config::config::{QuorumStoreConfig, SecureBackend};
use aptos_consensus_types::{
common::Author, proof_of_store::ProofCache, request_response::GetPayloadCommand,
};
use aptos_global_constants::CONSENSUS_KEY;
use aptos_crypto::bls12381::PrivateKey;
use aptos_logger::prelude::*;
use aptos_mempool::QuorumStoreRequest;
use aptos_secure_storage::{KVStorage, Storage};
use aptos_storage_interface::DbReader;
use aptos_types::{
account_address::AccountAddress, validator_signer::ValidatorSigner,
Expand Down Expand Up @@ -148,9 +147,11 @@ pub struct InnerBuilder {
batch_store: Option<Arc<BatchStore>>,
batch_reader: Option<Arc<dyn BatchReader>>,
broadcast_proofs: bool,
consensus_key: Option<Arc<PrivateKey>>,
}

impl InnerBuilder {
#[allow(clippy::too_many_arguments)]
pub(crate) fn new(
epoch: u64,
author: Author,
Expand All @@ -166,6 +167,7 @@ impl InnerBuilder {
backend: SecureBackend,
quorum_store_storage: Arc<dyn QuorumStoreStorage>,
broadcast_proofs: bool,
consensus_key: Option<Arc<PrivateKey>>,
) -> Self {
let (coordinator_tx, coordinator_rx) = futures_channel::mpsc::channel(config.channel_size);
let (batch_generator_cmd_tx, batch_generator_cmd_rx) =
Expand Down Expand Up @@ -221,19 +223,15 @@ impl InnerBuilder {
batch_store: None,
batch_reader: None,
broadcast_proofs,
consensus_key,
}
}

fn create_batch_store(&mut self) -> Arc<BatchReaderImpl<NetworkSender>> {
let backend = &self.backend;
let storage: Storage = backend.into();
if let Err(error) = storage.available() {
panic!("Storage is not available: {:?}", error);
}
let private_key = storage
.get(CONSENSUS_KEY)
.map(|v| v.value)
.expect("Unable to get private key");
let private_key = self
.consensus_key
.clone()
.expect("Consensus key is not available!");
let signer = ValidatorSigner::new(self.author, private_key);

let latest_ledger_info_with_sigs = self
Expand Down
Loading