compute round 6 merkle proof depth from highest authority index and preserve proof on retry

Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
Uncle Stinky 2026-11-19 16:05:27 +03:00
parent c0286574ac
commit 26372deadb
Signed by: st1nky
GPG Key ID: 016064BD97603B40
2 changed files with 11 additions and 10 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "ghost-exodus" name = "ghost-exodus"
version = "0.1.9" version = "0.1.10"
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

View File

@ -3206,8 +3206,12 @@ impl<T: Config> Pallet<T> {
return Err(InvalidTransaction::BadProof); return Err(InvalidTransaction::BadProof);
} }
let estimated_proof_count = state let leaf_capacity = state
.count_ones::<usize>() .highest_bit::<usize>()
.map(|bit| bit.saturating_add(1))
.unwrap_or(0);
let estimated_proof_count = leaf_capacity
.next_power_of_two() .next_power_of_two()
.trailing_zeros(); .trailing_zeros();
@ -3802,17 +3806,14 @@ impl<T: Config> Pallet<T> {
.get_release_block() .get_release_block()
.saturating_sub(current_block); .saturating_sub(current_block);
if blocks_remaining <= 2u32.into() { if blocks_remaining <= 2u32.into() { return false; }
return false;
}
let elapsed_blocks = dkg_round_period let elapsed_blocks = dkg_round_period
.saturating_sub(blocks_remaining) .saturating_sub(blocks_remaining)
.saturating_add(One::one()); .saturating_add(One::one());
let total_authorities = if dkg_phase == DkgPhase::Round0 { let total_authorities = if dkg_phase == DkgPhase::Round0 {
let indexes = qualification_authorities.get_indexes(); QualificationAuthorities::<T>::decode_len(&network_curve).unwrap_or_default()
indexes.active_bits_count() as usize
} else { } else {
qualification_authorities.count_ones::<usize>() qualification_authorities.count_ones::<usize>()
}; };
@ -4835,7 +4836,7 @@ impl<T: Config> Pallet<T> {
} }
let Some(DkgStorageEnum::Round5 { secret_share, merkle_proof }) = let Some(DkgStorageEnum::Round5 { secret_share, merkle_proof }) =
round_metadata.into_inner_mut() else { round_metadata.into_inner() else {
return Ok(ExodusOk::DkgRoundNothingStored( return Ok(ExodusOk::DkgRoundNothingStored(
ROUND_NUMBER_6, ROUND_NUMBER_6,
authority_index, authority_index,
@ -4846,7 +4847,7 @@ impl<T: Config> Pallet<T> {
let verifying_share = network_curve let verifying_share = network_curve
.dkg_derive_verifying_share(secret_share)?; .dkg_derive_verifying_share(secret_share)?;
let owned_merkle_proof = core::mem::take(merkle_proof); let owned_merkle_proof = merkle_proof.clone();
let current_dkg_index = qualification_state.get_dkg_index(); let current_dkg_index = qualification_state.get_dkg_index();
dkg_storage.prepare_signed_call_with_context( dkg_storage.prepare_signed_call_with_context(