Skip to content

Commit

Permalink
refactoring: more renamings
Browse files Browse the repository at this point in the history
  • Loading branch information
shumkov committed Jun 18, 2024
1 parent 2a47154 commit e2b551f
Show file tree
Hide file tree
Showing 20 changed files with 98 additions and 381 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use crate::platform_types::validator_set::v0::{
use crate::platform_types::validator_set::ValidatorSet;
use crate::rpc::core::CoreRPCLike;

use crate::platform_types::verification_quorum_set::{
VerificationQuorum, VerificationQuorumSet, VerificationQuorumSetV0Methods,
use crate::platform_types::signature_verification_quorum_set::{
SignatureVerificationQuorumSet, SignatureVerificationQuorumSetV0Methods, VerificationQuorum,
};
use dpp::bls_signatures::PublicKey as BlsPublicKey;
use dpp::dashcore::QuorumHash;
Expand Down Expand Up @@ -305,7 +305,7 @@ where
fn update_quorums_from_quorum_list(
&self,
quorum_set_type: &QuorumSetType,
quorum_set: &mut VerificationQuorumSet,
quorum_set: &mut SignatureVerificationQuorumSet,
platform_state: Option<&PlatformState>,
full_quorum_list: &ExtendedQuorumListResult,
last_committed_core_height: u32,
Expand Down Expand Up @@ -416,7 +416,7 @@ where
fn quorum_set_by_type_mut<'p>(
block_platform_state: &'p mut PlatformState,
quorum_set_type: &QuorumSetType,
) -> &'p mut VerificationQuorumSet {
) -> &'p mut SignatureVerificationQuorumSet {
match quorum_set_type {
QuorumSetType::ChainLock(_) => block_platform_state.chain_lock_validating_quorums_mut(),
QuorumSetType::InstantLock(_) => block_platform_state.instant_lock_validating_quorums_mut(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::rpc::core::CoreRPCLike;
use crate::error::execution::ExecutionError;
use crate::platform_types::platform_state::v0::PlatformStateV0Methods;
use crate::platform_types::platform_state::PlatformState;
use crate::platform_types::verification_quorum_set::VerificationQuorumSetV0Methods;
use crate::platform_types::signature_verification_quorum_set::SignatureVerificationQuorumSetV0Methods;
use dpp::version::PlatformVersion;

const CHAIN_LOCK_REQUEST_ID_PREFIX: &str = "clsig";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl VerifyInstantLockSignature for InstantLock {
match platform_version
.drive_abci
.methods
.core_instant_lock
.core_instant_send_lock
.verify_recent_signature_locally
{
0 => v0::verify_recent_instant_lock_signature_locally_v0(self, platform_state),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ use crate::error::Error;
use crate::error::serialization::SerializationError;
use crate::platform_types::platform_state::v0::PlatformStateV0Methods;
use crate::platform_types::platform_state::PlatformState;
use crate::platform_types::verification_quorum_set::{VerificationQuorumSetV0Methods, SIGN_OFFSET};
use crate::platform_types::signature_verification_quorum_set::{
SignatureVerificationQuorumSetV0Methods, SIGN_OFFSET,
};

#[inline(always)]
pub(super) fn verify_recent_instant_lock_signature_locally_v0(
Expand Down
6 changes: 2 additions & 4 deletions packages/rs-drive-abci/src/platform_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ pub mod platform;
pub mod platform_state;
/// Required identity public key set for system identities
pub mod required_identity_public_key_set;
/// Signature verification quorums
pub mod signature_verification_quorums;
/// Signature verification quorums for Core
pub mod signature_verification_quorum_set;
/// The state transition execution result as part of the block execution outcome
pub mod state_transitions_processing_result;
/// System identity public keys
Expand All @@ -58,8 +58,6 @@ pub mod system_identity_public_keys;
pub mod validator;
/// Quorum methods
pub mod validator_set;
/// Signature verification quorums for Core
pub mod verification_quorum_set;
/// Verify chain lock result
pub mod verify_chain_lock_result;
/// Withdrawal types
Expand Down
12 changes: 6 additions & 6 deletions packages/rs-drive-abci/src/platform_types/platform_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use indexmap::IndexMap;

use crate::config::PlatformConfig;
use crate::error::execution::ExecutionError;
use crate::platform_types::verification_quorum_set::VerificationQuorumSet;
use crate::platform_types::signature_verification_quorum_set::SignatureVerificationQuorumSet;
use dpp::block::block_info::BlockInfo;
use dpp::util::hash::hash_double;
use std::collections::BTreeMap;
Expand Down Expand Up @@ -321,7 +321,7 @@ impl PlatformStateV0Methods for PlatformState {
}
}

fn chain_lock_validating_quorums(&self) -> &VerificationQuorumSet {
fn chain_lock_validating_quorums(&self) -> &SignatureVerificationQuorumSet {
match self {
PlatformState::V0(v0) => &v0.chain_lock_validating_quorums,
}
Expand Down Expand Up @@ -387,7 +387,7 @@ impl PlatformStateV0Methods for PlatformState {
}
}

fn set_chain_lock_validating_quorums(&mut self, quorums: VerificationQuorumSet) {
fn set_chain_lock_validating_quorums(&mut self, quorums: SignatureVerificationQuorumSet) {
match self {
PlatformState::V0(v0) => v0.set_chain_lock_validating_quorums(quorums),
}
Expand Down Expand Up @@ -447,7 +447,7 @@ impl PlatformStateV0Methods for PlatformState {
}
}

fn chain_lock_validating_quorums_mut(&mut self) -> &mut VerificationQuorumSet {
fn chain_lock_validating_quorums_mut(&mut self) -> &mut SignatureVerificationQuorumSet {
match self {
PlatformState::V0(v0) => v0.chain_lock_validating_quorums_mut(),
}
Expand Down Expand Up @@ -477,13 +477,13 @@ impl PlatformStateV0Methods for PlatformState {
}
}

fn instant_lock_validating_quorums(&self) -> &VerificationQuorumSet {
fn instant_lock_validating_quorums(&self) -> &SignatureVerificationQuorumSet {
match self {
PlatformState::V0(v0) => v0.instant_lock_validating_quorums(),
}
}

fn instant_lock_validating_quorums_mut(&mut self) -> &mut VerificationQuorumSet {
fn instant_lock_validating_quorums_mut(&mut self) -> &mut SignatureVerificationQuorumSet {
match self {
PlatformState::V0(v0) => v0.instant_lock_validating_quorums_mut(),
}
Expand Down
36 changes: 18 additions & 18 deletions packages/rs-drive-abci/src/platform_types/platform_state/v0/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use dpp::block::extended_block_info::v0::ExtendedBlockInfoV0Getters;
use dpp::version::{PlatformVersion, TryIntoPlatformVersioned};

use crate::config::PlatformConfig;
use crate::platform_types::verification_quorum_set::{
VerificationQuorumSet, VerificationQuorumSetForSaving,
use crate::platform_types::signature_verification_quorum_set::{
SignatureVerificationQuorumSet, SignatureVerificationQuorumSetForSaving,
};
use itertools::Itertools;
use std::collections::BTreeMap;
Expand All @@ -48,10 +48,10 @@ pub struct PlatformStateV0 {
pub validator_sets: IndexMap<QuorumHash, ValidatorSet>,

/// Quorums used for validating chain locks (400 60 for mainnet)
pub chain_lock_validating_quorums: VerificationQuorumSet,
pub chain_lock_validating_quorums: SignatureVerificationQuorumSet,

/// Quorums used for validating instant locks
pub instant_lock_validating_quorums: VerificationQuorumSet,
pub instant_lock_validating_quorums: SignatureVerificationQuorumSet,

/// current full masternode list
pub full_masternode_list: BTreeMap<ProTxHash, MasternodeListItem>,
Expand Down Expand Up @@ -133,10 +133,10 @@ pub struct PlatformStateForSavingV0 {
pub validator_sets: Vec<(Bytes32, ValidatorSet)>,

/// The quorums used for validating chain locks
pub chain_lock_validating_quorums: VerificationQuorumSetForSaving,
pub chain_lock_validating_quorums: SignatureVerificationQuorumSetForSaving,

/// The quorums used for validating instant locks
pub instant_lock_validating_quorums: VerificationQuorumSetForSaving,
pub instant_lock_validating_quorums: SignatureVerificationQuorumSetForSaving,

/// current full masternode list
pub full_masternode_list: BTreeMap<Bytes32, Masternode>,
Expand Down Expand Up @@ -243,11 +243,11 @@ impl PlatformStateV0 {
current_validator_set_quorum_hash: QuorumHash::all_zeros(),
next_validator_set_quorum_hash: None,
validator_sets: Default::default(),
chain_lock_validating_quorums: VerificationQuorumSet::new(
chain_lock_validating_quorums: SignatureVerificationQuorumSet::new(
&config.chain_lock,
platform_version,
)?,
instant_lock_validating_quorums: VerificationQuorumSet::new(
instant_lock_validating_quorums: SignatureVerificationQuorumSet::new(
&config.instant_lock,
platform_version,
)?,
Expand Down Expand Up @@ -307,10 +307,10 @@ pub trait PlatformStateV0Methods {
fn validator_sets(&self) -> &IndexMap<QuorumHash, ValidatorSet>;

/// Returns the quorums used to validate chain locks.
fn chain_lock_validating_quorums(&self) -> &VerificationQuorumSet;
fn chain_lock_validating_quorums(&self) -> &SignatureVerificationQuorumSet;

/// Returns quorums used to validate instant locks.
fn instant_lock_validating_quorums(&self) -> &VerificationQuorumSet;
fn instant_lock_validating_quorums(&self) -> &SignatureVerificationQuorumSet;

/// Returns the full list of masternodes.
fn full_masternode_list(&self) -> &BTreeMap<ProTxHash, MasternodeListItem>;
Expand Down Expand Up @@ -343,7 +343,7 @@ pub trait PlatformStateV0Methods {
fn set_validator_sets(&mut self, sets: IndexMap<QuorumHash, ValidatorSet>);

/// Sets the current chain lock validating quorums.
fn set_chain_lock_validating_quorums(&mut self, quorums: VerificationQuorumSet);
fn set_chain_lock_validating_quorums(&mut self, quorums: SignatureVerificationQuorumSet);

/// Sets the full masternode list.
fn set_full_masternode_list(&mut self, list: BTreeMap<ProTxHash, MasternodeListItem>);
Expand Down Expand Up @@ -372,10 +372,10 @@ pub trait PlatformStateV0Methods {
fn validator_sets_mut(&mut self) -> &mut IndexMap<QuorumHash, ValidatorSet>;

/// Returns a mutable reference to the chain lock validating quorums.
fn chain_lock_validating_quorums_mut(&mut self) -> &mut VerificationQuorumSet;
fn chain_lock_validating_quorums_mut(&mut self) -> &mut SignatureVerificationQuorumSet;

/// Returns a mutable reference to the instant lock validating quorums.
fn instant_lock_validating_quorums_mut(&mut self) -> &mut VerificationQuorumSet;
fn instant_lock_validating_quorums_mut(&mut self) -> &mut SignatureVerificationQuorumSet;

/// Returns a mutable reference to the full masternode list.
fn full_masternode_list_mut(&mut self) -> &mut BTreeMap<ProTxHash, MasternodeListItem>;
Expand Down Expand Up @@ -529,12 +529,12 @@ impl PlatformStateV0Methods for PlatformStateV0 {
}

/// Returns the quorums used to validate chain locks.
fn chain_lock_validating_quorums(&self) -> &VerificationQuorumSet {
fn chain_lock_validating_quorums(&self) -> &SignatureVerificationQuorumSet {
&self.chain_lock_validating_quorums
}

/// Returns the quorums used to validate instant locks.
fn instant_lock_validating_quorums(&self) -> &VerificationQuorumSet {
fn instant_lock_validating_quorums(&self) -> &SignatureVerificationQuorumSet {
&self.instant_lock_validating_quorums
}

Expand Down Expand Up @@ -595,7 +595,7 @@ impl PlatformStateV0Methods for PlatformStateV0 {
}

/// Sets the current chain lock validating quorums.
fn set_chain_lock_validating_quorums(&mut self, quorums: VerificationQuorumSet) {
fn set_chain_lock_validating_quorums(&mut self, quorums: SignatureVerificationQuorumSet) {
self.chain_lock_validating_quorums = quorums;
}

Expand Down Expand Up @@ -638,11 +638,11 @@ impl PlatformStateV0Methods for PlatformStateV0 {
&mut self.validator_sets
}

fn chain_lock_validating_quorums_mut(&mut self) -> &mut VerificationQuorumSet {
fn chain_lock_validating_quorums_mut(&mut self) -> &mut SignatureVerificationQuorumSet {
&mut self.chain_lock_validating_quorums
}

fn instant_lock_validating_quorums_mut(&mut self) -> &mut VerificationQuorumSet {
fn instant_lock_validating_quorums_mut(&mut self) -> &mut SignatureVerificationQuorumSet {
&mut self.instant_lock_validating_quorums
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ mod v0;
use crate::config::QuorumLikeConfig;
use crate::error::execution::ExecutionError;
use crate::error::Error;
use crate::platform_types::verification_quorum_set::v0::for_saving::VerificationQuorumSetForSavingV0;
pub use crate::platform_types::verification_quorum_set::v0::quorum_set::{
QuorumConfig, QuorumsWithConfig, SelectedQuorumSetIterator, VerificationQuorumSetV0,
VerificationQuorumSetV0Methods, SIGN_OFFSET,
use crate::platform_types::signature_verification_quorum_set::v0::for_saving::SignatureVerificationQuorumSetForSavingV0;
pub use crate::platform_types::signature_verification_quorum_set::v0::quorum_set::{
QuorumConfig, QuorumsWithConfig, SelectedQuorumSetIterator, SignatureVerificationQuorumSetV0,
SignatureVerificationQuorumSetV0Methods, SIGN_OFFSET,
};
pub use crate::platform_types::verification_quorum_set::v0::quorums::{
pub use crate::platform_types::signature_verification_quorum_set::v0::quorums::{
Quorum, Quorums, SigningQuorum, ThresholdBlsPublicKey, VerificationQuorum,
};
use bincode::{Decode, Encode};
Expand All @@ -17,29 +17,33 @@ use dpp::version::PlatformVersion;

/// Quorums with keys for signature verification
#[derive(Debug, Clone, From)]
pub enum VerificationQuorumSet {
pub enum SignatureVerificationQuorumSet {
/// Version 0 of the signature verification quorums
V0(VerificationQuorumSetV0),
V0(SignatureVerificationQuorumSetV0),
}

impl VerificationQuorumSet {
impl SignatureVerificationQuorumSet {
/// Create a default SignatureVerificationQuorums
pub fn new(
config: &impl QuorumLikeConfig,
platform_version: &PlatformVersion,
) -> Result<Self, Error> {
match platform_version.drive_abci.structs.verification_quorum_set {
0 => Ok(VerificationQuorumSetV0::new(config).into()),
match platform_version
.drive_abci
.structs
.signature_verification_quorum_set
{
0 => Ok(SignatureVerificationQuorumSetV0::new(config).into()),
version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch {
method: "VerificationQuorumSet.new".to_string(),
method: "SignatureVerificationQuorumSet.new".to_string(),
known_versions: vec![0],
received: version,
})),
}
}
}

impl VerificationQuorumSetV0Methods for VerificationQuorumSet {
impl SignatureVerificationQuorumSetV0Methods for SignatureVerificationQuorumSet {
fn config(&self) -> &QuorumConfig {
match self {
Self::V0(v0) => v0.config(),
Expand Down Expand Up @@ -111,23 +115,27 @@ impl VerificationQuorumSetV0Methods for VerificationQuorumSet {

/// Core Quorum Set structure for saving to the database
#[derive(Debug, Clone, Encode, Decode)]
pub enum VerificationQuorumSetForSaving {
pub enum SignatureVerificationQuorumSetForSaving {
/// Version 0 of the signature verification quorums
V0(VerificationQuorumSetForSavingV0),
V0(SignatureVerificationQuorumSetForSavingV0),
}

impl From<VerificationQuorumSet> for VerificationQuorumSetForSaving {
fn from(value: VerificationQuorumSet) -> Self {
impl From<SignatureVerificationQuorumSet> for SignatureVerificationQuorumSetForSaving {
fn from(value: SignatureVerificationQuorumSet) -> Self {
match value {
VerificationQuorumSet::V0(v0) => VerificationQuorumSetForSaving::V0(v0.into()),
SignatureVerificationQuorumSet::V0(v0) => {
SignatureVerificationQuorumSetForSaving::V0(v0.into())
}
}
}
}

impl From<VerificationQuorumSetForSaving> for VerificationQuorumSet {
fn from(value: VerificationQuorumSetForSaving) -> Self {
impl From<SignatureVerificationQuorumSetForSaving> for SignatureVerificationQuorumSet {
fn from(value: SignatureVerificationQuorumSetForSaving) -> Self {
match value {
VerificationQuorumSetForSaving::V0(v0) => VerificationQuorumSet::V0(v0.into()),
SignatureVerificationQuorumSetForSaving::V0(v0) => {
SignatureVerificationQuorumSet::V0(v0.into())
}
}
}
}
Loading

0 comments on commit e2b551f

Please sign in to comment.