Skip to content

Commit

Permalink
randomness #5: consensus update from randomnet (#12225)
Browse files Browse the repository at this point in the history
* consensus update from randomnet

* update
  • Loading branch information
zjma committed Mar 1, 2024
1 parent 87b5e28 commit 4c16d01
Show file tree
Hide file tree
Showing 7 changed files with 416 additions and 50 deletions.
21 changes: 19 additions & 2 deletions config/src/config/identity_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
// SPDX-License-Identifier: Apache-2.0

use crate::{config::SecureBackend, keys::ConfigKey};
use anyhow::anyhow;
use aptos_crypto::{
bls12381,
ed25519::Ed25519PrivateKey,
x25519::{self, PRIVATE_KEY_SIZE},
ValidCryptoMaterial,
};
use aptos_types::account_address::{
from_identity_public_key, AccountAddress, AccountAddress as PeerId,
use aptos_types::{
account_address::{from_identity_public_key, AccountAddress, AccountAddress as PeerId},
dkg::{real_dkg::maybe_dk_from_bls_sk, DKGTrait, DefaultDKG},
};
use serde::{Deserialize, Serialize};
use std::{
Expand Down Expand Up @@ -43,6 +45,21 @@ impl IdentityBlob {
let mut file = File::open(path)?;
Ok(file.write_all(serde_yaml::to_string(self)?.as_bytes())?)
}

pub fn try_into_dkg_dealer_private_key(
self,
) -> Option<<DefaultDKG as DKGTrait>::DealerPrivateKey> {
self.consensus_private_key
}

pub fn try_into_dkg_new_validator_decrypt_key(
self,
) -> anyhow::Result<<DefaultDKG as DKGTrait>::NewValidatorDecryptKey> {
let consensus_sk = self.consensus_private_key.as_ref().ok_or_else(|| {
anyhow!("try_into_dkg_new_validator_decrypt_key failed with missing consensus key")
})?;
maybe_dk_from_bls_sk(consensus_sk)
}
}

#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
Expand Down
5 changes: 5 additions & 0 deletions consensus/src/consensus_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::{
persistent_liveness_storage::StorageWriteProxy,
pipeline::execution_client::ExecutionProxyClient,
quorum_store::quorum_store_db::QuorumStoreDB,
rand::rand_gen::storage::db::RandDb,
state_computer::ExecutionProxy,
transaction_filter::TransactionFilter,
txn_notifier::MempoolNotifier,
Expand Down Expand Up @@ -66,13 +67,16 @@ pub fn start_consensus(
aptos_channels::new_unbounded(&counters::PENDING_SELF_MESSAGES);
let consensus_network_client = ConsensusNetworkClient::new(network_client);
let bounded_executor = BoundedExecutor::new(32, runtime.handle().clone());
let rand_storage = Arc::new(RandDb::new(node_config.storage.dir()));

let execution_client = Arc::new(ExecutionProxyClient::new(
node_config.consensus.clone(),
Arc::new(execution_proxy),
node_config.validator_network.as_ref().unwrap().peer_id(),
self_sender.clone(),
consensus_network_client.clone(),
bounded_executor.clone(),
rand_storage.clone(),
));

let epoch_mgr = EpochManager::new(
Expand All @@ -89,6 +93,7 @@ pub fn start_consensus(
bounded_executor,
aptos_time_service::TimeService::real(),
vtxn_pool,
rand_storage,
);

let (network_task, network_receiver) = NetworkTask::new(network_service_events, self_receiver);
Expand Down
Loading

0 comments on commit 4c16d01

Please sign in to comment.