Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix benchmarks #2733

Merged
merged 2 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions pallets/parachain-staking/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ benchmarks! {
assert_eq!(Pallet::<T>::collator_commission(), Perbill::from_percent(33));
}

set_blocks_per_round {}: _(RawOrigin::Root, 1200u32)
set_blocks_per_round {}: _(RawOrigin::Root, 600u32)
verify {
assert_eq!(Pallet::<T>::round().length, 1200u32);
assert_eq!(Pallet::<T>::round().length, 600u32);
}

// USER DISPATCHABLES
Expand Down Expand Up @@ -419,7 +419,7 @@ benchmarks! {
RawOrigin::Signed(candidate.clone()).into(),
3u32
)?;
roll_to_and_author::<T>(2, candidate.clone());
roll_to_and_author::<T>(T::LeaveCandidatesDelay::get(), candidate.clone());
}: {
<Pallet<T>>::execute_leave_candidates(
RawOrigin::Signed(candidate.clone()).into(),
Expand Down Expand Up @@ -507,7 +507,7 @@ benchmarks! {
RawOrigin::Signed(candidate.clone()).into(),
3u32
)?;
roll_to_and_author::<T>(2, candidate.clone());
roll_to_and_author::<T>(T::LeaveCandidatesDelay::get(), candidate.clone());
}: {
<Pallet<T>>::execute_leave_candidates_inner(candidate.clone())?;
}
Expand Down Expand Up @@ -665,7 +665,7 @@ benchmarks! {
state.request,
Some(CandidateBondLessRequest {
amount: min_candidate_stk,
when_executable: 3,
when_executable: T::CandidateBondLessDelay::get() + 1,
})
);
}
Expand Down Expand Up @@ -700,7 +700,7 @@ benchmarks! {
RawOrigin::Signed(caller.clone()).into(),
min_candidate_stk
)?;
roll_to_and_author::<T>(2, caller.clone());
roll_to_and_author::<T>(T::CandidateBondLessDelay::get(), caller.clone());
}: {
Pallet::<T>::execute_candidate_bond_less(
RawOrigin::Signed(caller.clone()).into(),
Expand Down Expand Up @@ -1188,7 +1188,7 @@ benchmarks! {
caller.clone()).into(),
collator.clone()
)?;
roll_to_and_author::<T>(2, collator.clone());
roll_to_and_author::<T>(T::RevokeDelegationDelay::get(), collator.clone());
}: {
Pallet::<T>::execute_delegation_request(
RawOrigin::Signed(caller.clone()).into(),
Expand Down Expand Up @@ -1310,7 +1310,7 @@ benchmarks! {
.map(|bd| bd.delegations.iter().any(|d| d.owner == highest_bottom_delegator))
.unwrap_or_default(),
);
roll_to_and_author::<T>(2, collator.clone());
roll_to_and_author::<T>(T::RevokeDelegationDelay::get(), collator.clone());
}: {
Pallet::<T>::execute_delegation_request(
RawOrigin::Signed(last_top_delegator.clone()).into(),
Expand Down Expand Up @@ -1371,11 +1371,10 @@ benchmarks! {
}

let last_top_delegator_bond_less = 1_000u32.into();
let last_top_delegator_total = decreasing_balance.take();
let last_top_delegator = create_account::<T>(
"delegator",
seed.take(),
AccountBalance::Value(last_top_delegator_total),
AccountBalance::Value(decreasing_balance.take()),
AccountAction::Delegate{
collator: collator.clone(),
amount: Amount::All,
Expand Down Expand Up @@ -1443,7 +1442,10 @@ benchmarks! {
.map(|bd| bd.delegations.iter().any(|d| d.owner == highest_bottom_delegator))
.unwrap_or_default(),
);
roll_to_and_author::<T>(2, collator.clone());
roll_to_and_author::<T>(T::DelegationBondLessDelay::get(), collator.clone());

let last_top_delegator_total = Pallet::<T>::delegator_state(&last_top_delegator)
.expect("could not get delegator state").total;
}: {
Pallet::<T>::execute_delegation_request(
RawOrigin::Signed(last_top_delegator.clone()).into(),
Expand All @@ -1453,7 +1455,7 @@ benchmarks! {
} verify {
let expected = last_top_delegator_total - last_top_delegator_bond_less;
assert_eq!(
Pallet::<T>::delegator_state(&last_top_delegator).expect("candidate was created, qed").total,
Pallet::<T>::delegator_state(&last_top_delegator).expect("could not get delegator state").total,
expected,
);
assert!(
Expand Down
12 changes: 10 additions & 2 deletions runtime/moonbase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,13 +596,17 @@ impl pallet_treasury::Config for Runtime {
type WeightInfo = moonbeam_weights::pallet_treasury::WeightInfo<Runtime>;
type SpendFunds = ();
type ProposalBondMaximum = ();
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>; // Same as Polkadot
#[cfg(not(feature = "runtime-benchmarks"))]
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>; // Disabled, no spending
#[cfg(feature = "runtime-benchmarks")]
type SpendOrigin =
frame_system::EnsureWithSuccess<EnsureRoot<AccountId>, AccountId, benches::MaxBalance>;
type AssetKind = ();
type Beneficiary = AccountId;
type BeneficiaryLookup = IdentityLookup<AccountId>;
type Paymaster = PayFromAccount<Balances, TreasuryAccount>;
type BalanceConverter = UnityAssetBalanceConversion;
type PayoutPeriod = ConstU32<0>;
type PayoutPeriod = ConstU32<{ 30 * DAYS }>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = BenchmarkHelper;
}
Expand Down Expand Up @@ -1452,6 +1456,10 @@ use {
};
#[cfg(feature = "runtime-benchmarks")]
mod benches {
frame_support::parameter_types! {
pub const MaxBalance: crate::Balance = crate::Balance::max_value();
}

frame_benchmarking::define_benchmarks!(
[pallet_utility, Utility]
[pallet_timestamp, Timestamp]
Expand Down
12 changes: 10 additions & 2 deletions runtime/moonbeam/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,13 +579,17 @@ impl pallet_treasury::Config for Runtime {
type WeightInfo = moonbeam_weights::pallet_treasury::WeightInfo<Runtime>;
type SpendFunds = ();
type ProposalBondMaximum = ();
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>; // Same as Polkadot
#[cfg(not(feature = "runtime-benchmarks"))]
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>; // Disabled, no spending
#[cfg(feature = "runtime-benchmarks")]
type SpendOrigin =
frame_system::EnsureWithSuccess<EnsureRoot<AccountId>, AccountId, benches::MaxBalance>;
type AssetKind = ();
type Beneficiary = AccountId;
type BeneficiaryLookup = IdentityLookup<AccountId>;
type Paymaster = PayFromAccount<Balances, TreasuryAccount>;
type BalanceConverter = UnityAssetBalanceConversion;
type PayoutPeriod = ConstU32<0>;
type PayoutPeriod = ConstU32<{ 30 * DAYS }>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = BenchmarkHelper;
}
Expand Down Expand Up @@ -1401,6 +1405,10 @@ use {
};
#[cfg(feature = "runtime-benchmarks")]
mod benches {
frame_support::parameter_types! {
pub const MaxBalance: crate::Balance = crate::Balance::max_value();
}

frame_benchmarking::define_benchmarks!(
[pallet_utility, Utility]
[pallet_timestamp, Timestamp]
Expand Down
12 changes: 10 additions & 2 deletions runtime/moonriver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,13 +580,17 @@ impl pallet_treasury::Config for Runtime {
type WeightInfo = moonbeam_weights::pallet_treasury::WeightInfo<Runtime>;
type SpendFunds = ();
type ProposalBondMaximum = ();
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>; // Same as Polkadot
#[cfg(not(feature = "runtime-benchmarks"))]
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>; // Disabled, no spending
#[cfg(feature = "runtime-benchmarks")]
type SpendOrigin =
frame_system::EnsureWithSuccess<EnsureRoot<AccountId>, AccountId, benches::MaxBalance>;
type AssetKind = ();
type Beneficiary = AccountId;
type BeneficiaryLookup = IdentityLookup<AccountId>;
type Paymaster = PayFromAccount<Balances, TreasuryAccount>;
type BalanceConverter = UnityAssetBalanceConversion;
type PayoutPeriod = ConstU32<0>;
type PayoutPeriod = ConstU32<{ 30 * DAYS }>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = BenchmarkHelper;
}
Expand Down Expand Up @@ -1403,6 +1407,10 @@ use {
};
#[cfg(feature = "runtime-benchmarks")]
mod benches {
frame_support::parameter_types! {
pub const MaxBalance: crate::Balance = crate::Balance::max_value();
}

frame_benchmarking::define_benchmarks!(
[pallet_utility, Utility]
[pallet_timestamp, Timestamp]
Expand Down
Loading