From f5ebe79192df3e1703f0034caa8312d2a7b7f95b Mon Sep 17 00:00:00 2001 From: Eason Date: Wed, 11 Oct 2023 15:27:59 +0800 Subject: [PATCH] fix --- core/run/src/lib.rs | 7 +++++-- protocol/src/traits/consensus.rs | 11 +++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/core/run/src/lib.rs b/core/run/src/lib.rs index 2ebfdade6..38665147d 100644 --- a/core/run/src/lib.rs +++ b/core/run/src/lib.rs @@ -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::{ @@ -238,11 +238,14 @@ async fn start( 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, ) }) diff --git a/protocol/src/traits/consensus.rs b/protocol/src/traits/consensus.rs index 83f7c0528..fd96bbe57 100644 --- a/protocol/src/traits/consensus.rs +++ b/protocol/src/traits/consensus.rs @@ -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, @@ -21,6 +21,7 @@ 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>>, } @@ -28,13 +29,15 @@ pub struct NodeInfo { impl NodeInfo { pub fn new( chain_id: u64, - pubkey: Secp256k1PublicKey, + pub_key: Secp256k1PublicKey, + bls_pub_key: BlsPublicKey, hardfork_info: Option, ) -> 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)), }