Skip to content

Commit

Permalink
consensus update from randomnet
Browse files Browse the repository at this point in the history
  • Loading branch information
zjma committed Feb 25, 2024
1 parent ac14b75 commit 911292f
Show file tree
Hide file tree
Showing 7 changed files with 413 additions and 55 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
}

Check warning on line 53 in config/src/config/identity_config.rs

View check run for this annotation

Codecov / codecov/patch

config/src/config/identity_config.rs#L49-L53

Added lines #L49 - L53 were not covered by tests

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)
}

Check warning on line 62 in config/src/config/identity_config.rs

View check run for this annotation

Codecov / codecov/patch

config/src/config/identity_config.rs#L55-L62

Added lines #L55 - L62 were not covered by tests
}

#[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(8, runtime.handle().clone());
let rand_storage = Arc::new(RandDb::new(node_config.storage.dir()));

Check warning on line 70 in consensus/src/consensus_provider.rs

View check run for this annotation

Codecov / codecov/patch

consensus/src/consensus_provider.rs#L70

Added line #L70 was not covered by tests

let execution_client = Arc::new(ExecutionProxyClient::new(
node_config.consensus.clone(),

Check warning on line 73 in consensus/src/consensus_provider.rs

View check run for this annotation

Codecov / codecov/patch

consensus/src/consensus_provider.rs#L73

Added line #L73 was not covered by tests
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(),

Check warning on line 79 in consensus/src/consensus_provider.rs

View check run for this annotation

Codecov / codecov/patch

consensus/src/consensus_provider.rs#L79

Added line #L79 was not covered by tests
));

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,

Check warning on line 96 in consensus/src/consensus_provider.rs

View check run for this annotation

Codecov / codecov/patch

consensus/src/consensus_provider.rs#L96

Added line #L96 was not covered by tests
);

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

0 comments on commit 911292f

Please sign in to comment.