Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Eason committed Oct 11, 2023
1 parent 5106bf0 commit f5ebe79
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
7 changes: 5 additions & 2 deletions core/run/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use common_config_parser::types::spec::{ChainSpec, InitialAccount};
use common_config_parser::types::{Config, ConfigMempool};
use common_crypto::{
BlsPrivateKey, BlsPublicKey, Secp256k1, Secp256k1PrivateKey, Secp256k1RecoverablePrivateKey,
ToPublicKey,
ToBlsPublicKey, ToPublicKey,
};

use protocol::tokio::{
Expand Down Expand Up @@ -238,11 +238,14 @@ async fn start<K: KeyProvider>(
let hardfork_info = storage.hardfork_proposal(Default::default()).await?;
let overlord_consensus = {
let consensus_wal_path = config.data_path_for_consensus_wal();
let node_info = Secp256k1PrivateKey::try_from(config.bls_privkey.as_ref())
let bls_priv_key =
BlsPrivateKey::try_from(config.bls_privkey.as_ref()).map_err(MainError::Crypto)?;
let node_info = Secp256k1PrivateKey::try_from(config.net_privkey.as_ref())
.map(|privkey| {
NodeInfo::new(
current_block.header.chain_id,
privkey.pub_key(),
bls_priv_key.pub_key(&Default::default()),
hardfork_info,
)
})
Expand Down
11 changes: 7 additions & 4 deletions protocol/src/traits/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{
sync::{Arc, RwLock},
};

use common_crypto::Secp256k1PublicKey;
use common_crypto::{BlsPublicKey, Secp256k1PublicKey};

use crate::types::{
Address, Block, BlockNumber, Bytes, ExecResp, HardforkInfoInner, Hash, Header, Hex, MerkleRoot,
Expand All @@ -21,20 +21,23 @@ pub enum MessageTarget {
pub struct NodeInfo {
pub chain_id: u64,
pub self_pub_key: Secp256k1PublicKey,
pub self_bls_pub_key: BlsPublicKey,
pub self_address: Address,
pub hardfork_proposals: Arc<RwLock<Option<HardforkInfoInner>>>,
}

impl NodeInfo {
pub fn new(
chain_id: u64,
pubkey: Secp256k1PublicKey,
pub_key: Secp256k1PublicKey,
bls_pub_key: BlsPublicKey,
hardfork_info: Option<HardforkInfoInner>,
) -> Self {
let address = Address::from_pubkey(&pubkey);
let address = Address::from_pubkey(&pub_key);
Self {
chain_id,
self_pub_key: pubkey,
self_pub_key: pub_key,
self_bls_pub_key: bls_pub_key,
self_address: address,
hardfork_proposals: Arc::new(RwLock::new(hardfork_info)),
}
Expand Down

0 comments on commit f5ebe79

Please sign in to comment.