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