fix governance benchmarking; make id dependant on the proof length

Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
Uncle Stinky 2026-09-05 23:36:27 +03:00
parent c7637d8ce6
commit 554bc4499f
Signed by: st1nky
GPG Key ID: 016064BD97603B40
2 changed files with 11 additions and 16 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "ghost-governance" name = "ghost-governance"
version = "0.3.2" version = "0.3.3"
description = "Full-chain and cross-chain governance pallet with early adopter share claims" description = "Full-chain and cross-chain governance pallet with early adopter share claims"
license.workspace = true license.workspace = true
authors.workspace = true authors.workspace = true

View File

@ -31,7 +31,7 @@ mod benchmarks {
evm_addr_bytes.copy_from_slice(&pubkey_hash.as_ref()[12..32]); evm_addr_bytes.copy_from_slice(&pubkey_hash.as_ref()[12..32]);
let dummy_evm_address = EvmAddress::from(evm_addr_bytes); let dummy_evm_address = EvmAddress::from(evm_addr_bytes);
let target_index = 0u32; let target_index = max_proof_depth - 1;
let claim_package_init = ClaimPackage { let claim_package_init = ClaimPackage {
shares: dummy_shares, shares: dummy_shares,
merkle_proof: Default::default(), merkle_proof: Default::default(),
@ -40,7 +40,8 @@ mod benchmarks {
}; };
let preimage_init = claim_package_init.get_preimage(&dummy_evm_address, network_id); let preimage_init = claim_package_init.get_preimage(&dummy_evm_address, network_id);
let mut current_hash = SubstrateKeccakHasher::hash(&preimage_init); let some_hash = SubstrateKeccakHasher::hash(&preimage_init);
let mut current_hash = some_hash;
let mut proof_hashes = Vec::with_capacity(max_proof_depth as usize); let mut proof_hashes = Vec::with_capacity(max_proof_depth as usize);
let mut current_index = target_index as usize; let mut current_index = target_index as usize;
@ -48,21 +49,15 @@ mod benchmarks {
let hash_len = SubstrateKeccakHasher::hash_len(); let hash_len = SubstrateKeccakHasher::hash_len();
let mut combined = sp_std::vec![0u8; hash_len * 2]; let mut combined = sp_std::vec![0u8; hash_len * 2];
for i in 0..max_proof_depth { for _ in 0..max_proof_depth {
let mut sibling_bytes = [0u8; 32]; proof_hashes.push(some_hash);
sibling_bytes[24..32].copy_from_slice(&(i as u64).to_be_bytes());
let sibling_hash = EvmHash::from_slice(&sibling_bytes);
proof_hashes.push(sibling_hash);
let sibling_bytes_ref = sibling_hash.as_ref();
let hash_bytes = current_hash.as_ref();
if current_index % 2 == 0 { if current_index % 2 == 0 {
combined[..hash_len].copy_from_slice(hash_bytes); combined[..hash_len].copy_from_slice(&current_hash.to_fixed_bytes());
combined[hash_len..].copy_from_slice(sibling_bytes_ref); combined[hash_len..].copy_from_slice(&some_hash.to_fixed_bytes());
} else { } else {
combined[..hash_len].copy_from_slice(sibling_bytes_ref); combined[..hash_len].copy_from_slice(&some_hash.to_fixed_bytes());
combined[hash_len..].copy_from_slice(hash_bytes); combined[hash_len..].copy_from_slice(&current_hash.to_fixed_bytes());
} }
current_hash = SubstrateKeccakHasher::hash(&combined); current_hash = SubstrateKeccakHasher::hash(&combined);
@ -89,7 +84,7 @@ mod benchmarks {
GlobalShares::<T>::put(global_state); GlobalShares::<T>::put(global_state);
let claim_package = ClaimPackage { let claim_package = ClaimPackage {
index: 0, index: target_index,
merkle_proof: BoundedVec::try_from(proof_hashes).unwrap(), merkle_proof: BoundedVec::try_from(proof_hashes).unwrap(),
shares: dummy_shares, shares: dummy_shares,
token_id: 0 token_id: 0