Skip to content

Commit

Permalink
Get change_threshold_accounts benchmark working
Browse files Browse the repository at this point in the history
  • Loading branch information
HCastano committed Nov 1, 2024
1 parent 70da5e3 commit a4f41c7
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions pallets/staking/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,26 +201,40 @@ benchmarks! {
let s in 0 .. MAX_SIGNERS as u32;
let caller: T::AccountId = whitelisted_caller();
let _bonder: T::AccountId = account("bond", 0, SEED);

let validator_id_res = <T as pallet_session::Config>::ValidatorId::try_from(_bonder.clone()).or(Err(Error::<T>::InvalidValidatorId));
let validator_id_signers = <T as pallet_session::Config>::ValidatorId::try_from(caller.clone()).or(Err(Error::<T>::InvalidValidatorId)).unwrap();
let bonder: T::ValidatorId = validator_id_res.expect("Issue converting account id into validator id");

let threshold: T::AccountId = account("threshold", 0, SEED);
let new_threshold: T::AccountId = account("new_threshold", 0, SEED);

let x25519_public_key: [u8; 32] = NULL_ARR;
let endpoint = vec![20, 20]; // TODO: b"http://localhost:3001";
let pck = BoundedVec::try_from(MOCK_PCK_DERIVED_FROM_NULL_ARRAY.to_vec()).unwrap();
let quote = vec![0];

let validate_also = true;
prep_bond_and_validate::<T>(validate_also, caller.clone(), _bonder.clone(), threshold, x25519_public_key.clone());
prep_bond_and_validate::<T>(validate_also, caller.clone(), _bonder.clone(), threshold.clone(),
x25519_public_key.clone());

// For quote verification this needs to be the _next_ block, and right now we're at block `0`.
let block_number = 1;
let quote = prepare_attestation_for_validate::<T>(
new_threshold.clone(),
x25519_public_key,
endpoint.clone().to_vec(),
block_number,
).0;

let signers = vec![validator_id_signers.clone(); s as usize];
Signers::<T>::put(signers.clone());

}: _(RawOrigin::Signed(_bonder.clone()), _bonder.clone(), x25519_public_key.clone(), pck, quote)
}: _(RawOrigin::Signed(_bonder.clone()), new_threshold.clone(), x25519_public_key.clone(), pck,
quote)
verify {
let server_info = ServerInfo {
endpoint: vec![20, 20],
tss_account: _bonder.clone(),
tss_account: new_threshold.clone(),
x25519_public_key: NULL_ARR,
provisioning_certification_key: MOCK_PCK_DERIVED_FROM_NULL_ARRAY.to_vec().try_into().unwrap(),
};
Expand Down

0 comments on commit a4f41c7

Please sign in to comment.