Skip to content

Commit

Permalink
chore(consensus): change the visibility of several structs/enums/func…
Browse files Browse the repository at this point in the history
…tions in `/rs/consensus/src/ecdsa`
  • Loading branch information
kpop-dfinity committed Feb 21, 2024
1 parent 64e1e12 commit f15d761
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 23 deletions.
7 changes: 4 additions & 3 deletions rs/consensus/src/ecdsa.rs
Expand Up @@ -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;

Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions rs/consensus/src/ecdsa/payload_builder.rs
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions rs/consensus/src/ecdsa/payload_builder/errors.rs
Expand Up @@ -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),
Expand Down
21 changes: 7 additions & 14 deletions rs/consensus/src/ecdsa/payload_verifier.rs
Expand Up @@ -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};
Expand All @@ -55,24 +54,22 @@ use ic_types::{
ThresholdEcdsaCombinedSignature,
},
registry::RegistryClientError,
Height, RegistryVersion, SubnetId,
Height, SubnetId,
};
use prometheus::HistogramVec;
use std::collections::BTreeMap;
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<EcdsaPayloadError>),
InvalidChainCacheError(InvalidChainCacheError),
Expand All @@ -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),
Expand Down Expand Up @@ -157,10 +150,10 @@ impl From<StateManagerError> for TransientError {
}
}

pub type EcdsaValidationError = ValidationError<PermanentError, TransientError>;
pub(crate) type EcdsaValidationError = ValidationError<PermanentError, TransientError>;

#[allow(clippy::too_many_arguments)]
pub fn validate_payload(
pub(crate) fn validate_payload(
subnet_id: SubnetId,
registry_client: &dyn RegistryClient,
crypto: &dyn ConsensusCrypto,
Expand Down Expand Up @@ -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<'_>,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion rs/consensus/src/ecdsa/utils.rs
Expand Up @@ -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<dyn ConsensusBlockChain>,
Expand Down

0 comments on commit f15d761

Please sign in to comment.