diff --git a/base_layer/core/src/base_node/chain_metadata_service/initializer.rs b/base_layer/core/src/base_node/chain_metadata_service/initializer.rs index 2409b86e75..bb93dfd601 100644 --- a/base_layer/core/src/base_node/chain_metadata_service/initializer.rs +++ b/base_layer/core/src/base_node/chain_metadata_service/initializer.rs @@ -36,7 +36,6 @@ pub struct ChainMetadataServiceInitializer; impl ServiceInitializer for ChainMetadataServiceInitializer { async fn initialize(&mut self, context: ServiceInitializerContext) -> Result<(), ServiceInitializationError> { debug!(target: LOG_TARGET, "Initializing Chain Metadata Service"); - // Buffer size set to 1 because only the most recent metadata is applicable let (publisher, _) = broadcast::channel(20); let handle = ChainMetadataHandle::new(publisher.clone()); diff --git a/base_layer/core/src/base_node/chain_metadata_service/service.rs b/base_layer/core/src/base_node/chain_metadata_service/service.rs index e7450aa8ff..dc33240737 100644 --- a/base_layer/core/src/base_node/chain_metadata_service/service.rs +++ b/base_layer/core/src/base_node/chain_metadata_service/service.rs @@ -56,6 +56,7 @@ impl ChainMetadataService { /// ## Arguments /// `liveness` - the liveness service handle /// `base_node` - the base node service handle + /// `event_publisher` - A broadcast sender for chain metadata events pub fn new( liveness: LivenessHandle, base_node: LocalNodeCommsInterface, diff --git a/base_layer/core/src/base_node/state_machine_service/states/listening.rs b/base_layer/core/src/base_node/state_machine_service/states/listening.rs index a3eb32cd9f..5c21ef5ee6 100644 --- a/base_layer/core/src/base_node/state_machine_service/states/listening.rs +++ b/base_layer/core/src/base_node/state_machine_service/states/listening.rs @@ -21,6 +21,7 @@ // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use std::{ + convert::TryFrom, fmt::{Display, Formatter}, ops::Deref, time::{Duration, Instant}, @@ -67,9 +68,9 @@ pub struct PeerMetadata { impl PeerMetadata { pub fn to_bytes(&self) -> Vec { - let size = bincode::serialized_size(self).unwrap(); - #[allow(clippy::cast_possible_truncation)] - let mut buf = Vec::with_capacity(size as usize); + let size = usize::try_from(bincode::serialized_size(self).unwrap()) + .expect("The serialized size is larger than the platform allows"); + let mut buf = Vec::with_capacity(size); bincode::serialize_into(&mut buf, self).unwrap(); // this should not fail buf } diff --git a/base_layer/core/src/transactions/key_manager/inner.rs b/base_layer/core/src/transactions/key_manager/inner.rs index ca36b77bf2..78b746ed34 100644 --- a/base_layer/core/src/transactions/key_manager/inner.rs +++ b/base_layer/core/src/transactions/key_manager/inner.rs @@ -84,7 +84,10 @@ use crate::{ }, }; -hash_domain!(KeyManagerHashingDomain, "base_layer.core.key_manager"); +hash_domain!( + KeyManagerHashingDomain, + "com.tari.base_layer.core.transactions.key_manager" +); pub struct TransactionKeyManagerInner { key_managers: HashMap>>, @@ -288,8 +291,7 @@ where TBackend: KeyManagerBackend + 'static Ok(key_id) } - // Note!: This method may not be made public - pub async fn get_private_key(&self, key_id: &TariKeyId) -> Result { + pub(crate) async fn get_private_key(&self, key_id: &TariKeyId) -> Result { match key_id { KeyId::Managed { branch, index } => { let km = self @@ -523,7 +525,6 @@ where TBackend: KeyManagerBackend + 'static Ok(script_offset) } - // Note!: This method may not be made public async fn get_metadata_signature_ephemeral_private_key_pair( &self, nonce_id: &TariKeyId, @@ -764,7 +765,7 @@ where TBackend: KeyManagerBackend + 'static private_key - &self.get_txo_private_kernel_offset(spending_key_id, nonce_id).await? }; - // We need to check if its in put or output for which we are singing. Signing with an input, we need to sign + // We need to check if its input or output for which we are singing. Signing with an input, we need to sign // with `-k` while outputs are `k` let final_signing_key = if txo_type == TxoStage::Output { private_signing_key @@ -799,7 +800,6 @@ where TBackend: KeyManagerBackend + 'static // Encrypted data section (transactions > transaction_components > encrypted_data) // ----------------------------------------------------------------------------------------------------------------- - // Note!: This method may not be made public async fn get_recovery_key(&self) -> Result { let recovery_id = KeyId::Managed { branch: TransactionKeyManagerBranch::DataEncryption.get_branch_key(), diff --git a/base_layer/core/src/transactions/transaction_components/side_chain/mod.rs b/base_layer/core/src/transactions/transaction_components/side_chain/mod.rs index 741faa347f..7970e5c506 100644 --- a/base_layer/core/src/transactions/transaction_components/side_chain/mod.rs +++ b/base_layer/core/src/transactions/transaction_components/side_chain/mod.rs @@ -36,7 +36,7 @@ pub use validator_node_signature::{ValidatorNodeHashDomain, ValidatorNodeSignatu hash_domain!( ContractAcceptanceHashDomain, - "com.tari.tari-project.base_layer.core.transactions.side_chain.contract_acceptance_challenge", + "com.tari.base_layer.core.transactions.side_chain.contract_acceptance_challenge", 1 ); @@ -44,7 +44,7 @@ pub type ContractAcceptanceHasherBlake256 = DomainSeparatedHasher Self { let (secret_nonce, public_nonce) = PublicKey::random_keypair(&mut OsRng); let public_key = PublicKey::from_secret_key(private_key); diff --git a/base_layer/core/src/transactions/transaction_protocol/mod.rs b/base_layer/core/src/transactions/transaction_protocol/mod.rs index e0c57266c2..d9f0f92e64 100644 --- a/base_layer/core/src/transactions/transaction_protocol/mod.rs +++ b/base_layer/core/src/transactions/transaction_protocol/mod.rs @@ -188,7 +188,7 @@ pub struct RecoveryData { // hash domain hash_domain!( CalculateTxIdTransactionProtocolHashDomain, - "com.tari.tari-project.base_layer.core.transactions.transaction_protocol.calculate_tx_id", + "com.tari.base_layer.core.transactions.transaction_protocol.calculate_tx_id", 1 ); diff --git a/base_layer/core/src/validation/aggregate_body/aggregate_body_chain_validator.rs b/base_layer/core/src/validation/aggregate_body/aggregate_body_chain_validator.rs index c6e37b6e48..979a64b1cd 100644 --- a/base_layer/core/src/validation/aggregate_body/aggregate_body_chain_validator.rs +++ b/base_layer/core/src/validation/aggregate_body/aggregate_body_chain_validator.rs @@ -254,7 +254,7 @@ pub fn check_outputs( Ok(()) } -/// This function checks the at the body contains no duplicated inputs or outputs. +/// This function checks the body contains no duplicated inputs or outputs. fn verify_no_duplicated_inputs_outputs(body: &AggregateBody) -> Result<(), ValidationError> { if body.contains_duplicated_inputs() { warn!( @@ -273,7 +273,7 @@ fn verify_no_duplicated_inputs_outputs(body: &AggregateBody) -> Result<(), Valid Ok(()) } -/// THis function checks the total burned sum in the header ensuring that every burned output is counted in the total +/// This function checks the total burned sum in the header ensuring that every burned output is counted in the total /// sum. #[allow(clippy::mutable_key_type)] fn check_total_burned(body: &AggregateBody) -> Result<(), ValidationError> { diff --git a/base_layer/core/src/validation/aggregate_body/aggregate_body_internal_validator.rs b/base_layer/core/src/validation/aggregate_body/aggregate_body_internal_validator.rs index 342df9eace..5eed945eb3 100644 --- a/base_layer/core/src/validation/aggregate_body/aggregate_body_internal_validator.rs +++ b/base_layer/core/src/validation/aggregate_body/aggregate_body_internal_validator.rs @@ -346,7 +346,7 @@ fn check_maturity(height: u64, inputs: &[TransactionInput]) -> Result<(), Transa Ok(()) } -/// THis function checks the total burned sum in the header ensuring that every burned output is counted in the total +/// This function checks the total burned sum in the header ensuring that every burned output is counted in the total /// sum. #[allow(clippy::mutable_key_type)] fn check_total_burned(body: &AggregateBody) -> Result<(), ValidationError> {