Skip to content

Commit

Permalink
Use benchmark result in pallet
Browse files Browse the repository at this point in the history
  • Loading branch information
HCastano committed Dec 16, 2024
1 parent b689d7d commit 3b9055d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pallets/staking/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ use frame_support::{
};
use frame_system::{EventRecord, RawOrigin};
use pallet_parameters::{SignersInfo, SignersSize};
use pallet_slashing::Event as SlashingEvent;
use pallet_staking::{
Event as FrameStakingEvent, MaxNominationsOf, MaxValidatorsCount, Nominations,
Pallet as FrameStaking, RewardDestination, ValidatorPrefs,
};
use pallet_slashing::Event as SlashingEvent;
use sp_std::{vec, vec::Vec};

const NULL_ARR: [u8; 32] = [0; 32];
Expand Down
9 changes: 5 additions & 4 deletions pallets/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,13 +738,12 @@ pub mod pallet {
Ok(Pays::No.into())
}

// TODO (Nando): Real weight
#[pallet::call_index(7)]
#[pallet::weight(<T as Config>::WeightInfo::validate())]
#[pallet::weight(<T as Config>::WeightInfo::report_unstable_peer(MAX_SIGNERS as u32))]
pub fn report_unstable_peer(
origin: OriginFor<T>,
offender_tss_account: T::AccountId,
) -> DispatchResult {
) -> DispatchResultWithPostInfo {
let reporter_tss_account = ensure_signed(origin)?;

// For reporting purposes we need to know the validator account tied to the TSS account.
Expand Down Expand Up @@ -780,7 +779,9 @@ pub mod pallet {
offending_peer_validator_account,
)?;

Ok(())
let actual_weight =
<T as Config>::WeightInfo::report_unstable_peer(signers.len() as u32);
Ok(Some(actual_weight).into())
}
}

Expand Down

0 comments on commit 3b9055d

Please sign in to comment.