fix governance benchmarking; make id dependant on the proof length
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
parent
c7637d8ce6
commit
554bc4499f
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ghost-governance"
|
||||
version = "0.3.2"
|
||||
version = "0.3.3"
|
||||
description = "Full-chain and cross-chain governance pallet with early adopter share claims"
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
|
||||
@ -31,7 +31,7 @@ mod benchmarks {
|
||||
evm_addr_bytes.copy_from_slice(&pubkey_hash.as_ref()[12..32]);
|
||||
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 {
|
||||
shares: dummy_shares,
|
||||
merkle_proof: Default::default(),
|
||||
@ -40,7 +40,8 @@ mod benchmarks {
|
||||
};
|
||||
|
||||
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 current_index = target_index as usize;
|
||||
@ -48,21 +49,15 @@ mod benchmarks {
|
||||
let hash_len = SubstrateKeccakHasher::hash_len();
|
||||
let mut combined = sp_std::vec![0u8; hash_len * 2];
|
||||
|
||||
for i in 0..max_proof_depth {
|
||||
let mut sibling_bytes = [0u8; 32];
|
||||
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();
|
||||
for _ in 0..max_proof_depth {
|
||||
proof_hashes.push(some_hash);
|
||||
|
||||
if current_index % 2 == 0 {
|
||||
combined[..hash_len].copy_from_slice(hash_bytes);
|
||||
combined[hash_len..].copy_from_slice(sibling_bytes_ref);
|
||||
combined[..hash_len].copy_from_slice(¤t_hash.to_fixed_bytes());
|
||||
combined[hash_len..].copy_from_slice(&some_hash.to_fixed_bytes());
|
||||
} else {
|
||||
combined[..hash_len].copy_from_slice(sibling_bytes_ref);
|
||||
combined[hash_len..].copy_from_slice(hash_bytes);
|
||||
combined[..hash_len].copy_from_slice(&some_hash.to_fixed_bytes());
|
||||
combined[hash_len..].copy_from_slice(¤t_hash.to_fixed_bytes());
|
||||
}
|
||||
|
||||
current_hash = SubstrateKeccakHasher::hash(&combined);
|
||||
@ -89,7 +84,7 @@ mod benchmarks {
|
||||
GlobalShares::<T>::put(global_state);
|
||||
|
||||
let claim_package = ClaimPackage {
|
||||
index: 0,
|
||||
index: target_index,
|
||||
merkle_proof: BoundedVec::try_from(proof_hashes).unwrap(),
|
||||
shares: dummy_shares,
|
||||
token_id: 0
|
||||
|
||||
Loading…
Reference in New Issue
Block a user