scope DKG round 5 lookup and storage cleanup to active curve/index
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
parent
2a10db05c5
commit
279b71832b
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ghost-exodus"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
description = "Threshold signature generation with DKG included"
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
|
||||
@ -2189,7 +2189,8 @@ impl<T: Config> Pallet<T> {
|
||||
network_curve,
|
||||
maybe_cursor,
|
||||
|cursor_slice, weight| {
|
||||
let result = Round0Packages::<T>::clear(
|
||||
let result = Round0Packages::<T>::clear_prefix(
|
||||
network_curve,
|
||||
T::RemovalLimit::get(),
|
||||
cursor_slice,
|
||||
);
|
||||
@ -2279,15 +2280,12 @@ impl<T: Config> Pallet<T> {
|
||||
dkg_qualification: &mut PendingDkgAuthorities<T>,
|
||||
maybe_cursor: Option<BoundedVec<u8, T::MaxCursorLen>>,
|
||||
) -> (Weight, bool) {
|
||||
let dkg_index = dkg_qualification.get_dkg_index();
|
||||
|
||||
Self::prepare_round_storage(
|
||||
network_curve,
|
||||
maybe_cursor,
|
||||
|cursor_slice, weight| {
|
||||
let prev_dkg_index = dkg_index.saturating_sub(1);
|
||||
let result = Verifications::<T>::clear_prefix(
|
||||
(network_curve, prev_dkg_index),
|
||||
(network_curve,),
|
||||
T::RemovalLimit::get(),
|
||||
cursor_slice,
|
||||
);
|
||||
@ -2354,17 +2352,24 @@ impl<T: Config> Pallet<T> {
|
||||
dkg_qualification: &mut PendingDkgAuthorities<T>,
|
||||
maybe_cursor: Option<BoundedVec<u8, T::MaxCursorLen>>,
|
||||
) -> (Weight, bool) {
|
||||
let dkg_index = dkg_qualification.get_dkg_index();
|
||||
|
||||
Self::prepare_round_storage(
|
||||
network_curve,
|
||||
maybe_cursor,
|
||||
|_, weight| {
|
||||
let prev_dkg_index = dkg_index.saturating_sub(1);
|
||||
|cursor_slice, weight| {
|
||||
let result = VerifyingKeyConsensus::<T>::clear_prefix(
|
||||
network_curve,
|
||||
T::RemovalLimit::get(),
|
||||
cursor_slice,
|
||||
);
|
||||
|
||||
weight.saturating_accrue(T::DbWeight::get().writes(1));
|
||||
VerifyingKeyConsensus::<T>::remove(network_curve, &prev_dkg_index);
|
||||
None
|
||||
weight.saturating_accrue(
|
||||
T::DbWeight::get().reads_writes(
|
||||
(result.backend as u64).saturating_add(1),
|
||||
result.backend as u64
|
||||
)
|
||||
);
|
||||
|
||||
result.maybe_cursor
|
||||
},
|
||||
|weight| {
|
||||
weight.saturating_accrue(T::DbWeight::get().reads(2));
|
||||
@ -2375,7 +2380,7 @@ impl<T: Config> Pallet<T> {
|
||||
let mut number_of_leaked_keys = 0;
|
||||
|
||||
let qualified_indexes = dkg_qualification.get_indexes();
|
||||
let total_authorities_len = qualified_indexes.count_ones::<usize>();
|
||||
let total_authorities_len = qualified_indexes.active_bits_count() as usize;
|
||||
|
||||
let mut failed_authorities = ParticipantsBitmap::<T>::empty_from(
|
||||
&qualified_indexes,
|
||||
@ -2463,7 +2468,6 @@ impl<T: Config> Pallet<T> {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
||||
let result = VerifyingShares::<T>::clear_prefix(
|
||||
(network_curve, previous_dkg_index),
|
||||
T::RemovalLimit::get(),
|
||||
@ -4574,6 +4578,7 @@ impl<T: Config> Pallet<T> {
|
||||
) -> ExodusResult<ExodusOk<NetworkCurve, NetworkIdOf<T>>> {
|
||||
let network_curve = dkg_storage.network_curve;
|
||||
let authority_index = dkg_storage.authority_index;
|
||||
let dkg_index = qualification_state.get_dkg_index();
|
||||
|
||||
if !qualification_state.contains_index(authority_index) {
|
||||
return Ok(ExodusOk::DkgNotPartOfRound(
|
||||
@ -4584,8 +4589,10 @@ impl<T: Config> Pallet<T> {
|
||||
}
|
||||
|
||||
let verification_found_for_self =
|
||||
VerifyingKeyConsensus::<T>::iter_values()
|
||||
.any(|consensus| consensus.state.participants.contains(authority_index));
|
||||
VerifyingKeyConsensus::<T>::get(&network_curve, &dkg_index)
|
||||
.state
|
||||
.participants
|
||||
.contains(authority_index);
|
||||
|
||||
if verification_found_for_self {
|
||||
return Ok(ExodusOk::DkgRoundAlreadyPassed(
|
||||
@ -4595,7 +4602,6 @@ impl<T: Config> Pallet<T> {
|
||||
));
|
||||
}
|
||||
|
||||
let dkg_index = qualification_state.get_dkg_index();
|
||||
let dkg_based_prefix = Self::create_dkg_based_prefix(dkg_index);
|
||||
|
||||
let mut round_metadata = dkg_storage.read_local_storage(
|
||||
@ -5120,14 +5126,10 @@ impl<T: Config> Pallet<T> {
|
||||
.ok()
|
||||
.filter(|b| b.len() == max_size);
|
||||
|
||||
match maybe_encoded_bytes {
|
||||
Some(encoded) => {
|
||||
if let Some(_) = bitmask.insert(receiver_index) {
|
||||
blob.extend_from_slice(&encoded);
|
||||
}
|
||||
},
|
||||
None => {
|
||||
blob.extend_from_slice(&vec![0u8; max_size]);
|
||||
if let Some(_) = bitmask.insert(receiver_index) {
|
||||
match maybe_encoded_bytes {
|
||||
Some(encoded) => blob.extend_from_slice(&encoded),
|
||||
None => blob.extend_from_slice(&vec![0u8; max_size]),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user