diff --git a/rs/consensus/src/ecdsa.rs b/rs/consensus/src/ecdsa.rs index e44cd796e6e..6262f3e465d 100644 --- a/rs/consensus/src/ecdsa.rs +++ b/rs/consensus/src/ecdsa.rs @@ -217,8 +217,9 @@ pub mod stats; pub(crate) mod test_utils; pub(crate) mod utils; -pub use payload_builder::make_bootstrap_summary; -pub(crate) use payload_builder::{create_data_payload, create_summary_payload}; +pub(crate) use payload_builder::{ + create_data_payload, create_summary_payload, make_bootstrap_summary, +}; pub(crate) use payload_verifier::{validate_payload, PermanentError, TransientError}; pub use stats::EcdsaStatsImpl; @@ -228,7 +229,7 @@ use self::utils::get_context_request_id; const LOOK_AHEAD: u64 = 10; /// Frequency for clearing the inactive key transcripts. -pub const INACTIVE_TRANSCRIPT_PURGE_SECS: Duration = Duration::from_secs(60); +pub(crate) const INACTIVE_TRANSCRIPT_PURGE_SECS: Duration = Duration::from_secs(60); /// `EcdsaImpl` is the consensus component responsible for processing threshold /// ECDSA payloads. diff --git a/rs/consensus/src/ecdsa/payload_builder.rs b/rs/consensus/src/ecdsa/payload_builder.rs index 9cbf7e7c2be..c811414afd5 100644 --- a/rs/consensus/src/ecdsa/payload_builder.rs +++ b/rs/consensus/src/ecdsa/payload_builder.rs @@ -53,7 +53,7 @@ pub(super) mod signatures; /// Builds the very first ecdsa summary block. This would trigger the subsequent /// data blocks to create the initial key transcript. -pub fn make_bootstrap_summary( +pub(crate) fn make_bootstrap_summary( subnet_id: SubnetId, key_id: EcdsaKeyId, height: Height, @@ -77,7 +77,7 @@ pub fn make_bootstrap_summary( /// Builds the very first ecdsa summary block. This would trigger the subsequent /// data blocks to create the initial key transcript. -pub fn make_bootstrap_summary_with_initial_dealings( +pub(crate) fn make_bootstrap_summary_with_initial_dealings( subnet_id: SubnetId, key_id: EcdsaKeyId, height: Height, diff --git a/rs/consensus/src/ecdsa/payload_builder/errors.rs b/rs/consensus/src/ecdsa/payload_builder/errors.rs index 0317a5eadcc..157a58c18c6 100644 --- a/rs/consensus/src/ecdsa/payload_builder/errors.rs +++ b/rs/consensus/src/ecdsa/payload_builder/errors.rs @@ -16,17 +16,15 @@ use ic_types::{ use super::InvalidChainCacheError; #[derive(Clone, Debug)] -pub enum EcdsaPayloadError { +pub(crate) enum EcdsaPayloadError { RegistryClientError(RegistryClientError), MegaKeyFromRegistryError(MegaKeyFromRegistryError), ConsensusSummaryBlockNotFound(Height), - ConsensusRegistryVersionNotFound(Height), StateManagerError(StateManagerError), SubnetWithNoNodes(SubnetId, RegistryVersion), PreSignatureError(PresignatureQuadrupleCreationError), IDkgParamsValidationError(IDkgParamsValidationError), IDkgTranscriptIdError(IDkgTranscriptIdError), - DkgSummaryBlockNotFound(Height), ThresholdEcdsaSigInputsCreationError(ThresholdEcdsaSigInputsCreationError), TranscriptLookupError(ecdsa::TranscriptLookupError), TranscriptCastError(ecdsa::TranscriptCastError), diff --git a/rs/consensus/src/ecdsa/payload_verifier.rs b/rs/consensus/src/ecdsa/payload_verifier.rs index f86590bf0c3..8b02b7766dc 100644 --- a/rs/consensus/src/ecdsa/payload_verifier.rs +++ b/rs/consensus/src/ecdsa/payload_verifier.rs @@ -32,7 +32,6 @@ use crate::ecdsa::payload_builder::{create_data_payload_helper, create_summary_p use crate::ecdsa::utils::build_signature_inputs; use ic_consensus_utils::crypto::ConsensusCrypto; use ic_consensus_utils::pool_reader::PoolReader; -use ic_crypto::MegaKeyFromRegistryError; use ic_interfaces::validation::{ValidationError, ValidationResult}; use ic_interfaces_registry::RegistryClient; use ic_interfaces_state_manager::{StateManager, StateManagerError}; @@ -55,7 +54,7 @@ use ic_types::{ ThresholdEcdsaCombinedSignature, }, registry::RegistryClientError, - Height, RegistryVersion, SubnetId, + Height, SubnetId, }; use prometheus::HistogramVec; use std::collections::BTreeMap; @@ -63,16 +62,14 @@ use std::convert::TryFrom; #[allow(clippy::enum_variant_names)] #[derive(Debug)] -pub enum TransientError { +pub(crate) enum TransientError { RegistryClientError(RegistryClientError), - EcdsaPayloadError(EcdsaPayloadError), StateManagerError(StateManagerError), } #[derive(Debug)] -pub enum PermanentError { +pub(crate) enum PermanentError { // wrapper of other errors - RegistryClientError(RegistryClientError), UnexpectedSummaryPayload(EcdsaPayloadError), UnexpectedDataPayload(Option), InvalidChainCacheError(InvalidChainCacheError), @@ -81,20 +78,16 @@ pub enum PermanentError { ThresholdEcdsaVerifyCombinedSignatureError(ThresholdEcdsaVerifyCombinedSignatureError), IDkgVerifyTranscriptError(IDkgVerifyTranscriptError), IDkgVerifyInitialDealingsError(IDkgVerifyInitialDealingsError), - MegaKeyFromRegistryError(MegaKeyFromRegistryError), // local errors ConsensusRegistryVersionNotFound(Height), - SubnetWithNoNodes(SubnetId, RegistryVersion), EcdsaConfigNotFound, SummaryPayloadMismatch, DataPayloadMismatch, MissingEcdsaDataPayload, - MissingParentDataPayload, NewTranscriptRefWrongHeight(TranscriptRef, Height), NewTranscriptNotFound(IDkgTranscriptId), NewTranscriptMiscount(u64), NewTranscriptMissingParams(IDkgTranscriptId), - NewTranscriptHeightMismatch(IDkgTranscriptId), NewSignatureUnexpected(ecdsa::PseudoRandomId), NewSignatureMissingInput(ecdsa::PseudoRandomId), NewSignatureMissingContext(ecdsa::PseudoRandomId), @@ -157,10 +150,10 @@ impl From for TransientError { } } -pub type EcdsaValidationError = ValidationError; +pub(crate) type EcdsaValidationError = ValidationError; #[allow(clippy::too_many_arguments)] -pub fn validate_payload( +pub(crate) fn validate_payload( subnet_id: SubnetId, registry_client: &dyn RegistryClient, crypto: &dyn ConsensusCrypto, @@ -210,7 +203,7 @@ pub fn validate_payload( /// Validates a threshold ECDSA summary payload. /// This is an entirely deterministic operation, so we can just check if /// the given summary payload matches what we would have created locally. -pub fn validate_summary_payload( +fn validate_summary_payload( subnet_id: SubnetId, registry_client: &dyn RegistryClient, pool_reader: &PoolReader<'_>, @@ -264,7 +257,7 @@ pub fn validate_summary_payload( #[allow(clippy::too_many_arguments)] /// Validates a threshold ECDSA data payload. -pub fn validate_data_payload( +fn validate_data_payload( subnet_id: SubnetId, registry_client: &dyn RegistryClient, crypto: &dyn ConsensusCrypto, diff --git a/rs/consensus/src/ecdsa/utils.rs b/rs/consensus/src/ecdsa/utils.rs index e3465e4f927..58e87497a05 100644 --- a/rs/consensus/src/ecdsa/utils.rs +++ b/rs/consensus/src/ecdsa/utils.rs @@ -36,7 +36,7 @@ use std::convert::TryInto; use std::sync::Arc; #[derive(Clone, Debug)] -pub struct InvalidChainCacheError(String); +pub(crate) struct InvalidChainCacheError(String); pub(super) struct EcdsaBlockReaderImpl { chain: Arc,