Skip to content

Commit

Permalink
Some weights, and benchmarks modification
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinonard committed May 1, 2024
1 parent 201083d commit 53a9b1a
Show file tree
Hide file tree
Showing 5 changed files with 541 additions and 508 deletions.
3 changes: 3 additions & 0 deletions pallets/dapp-staking-v3/src/benchmarking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,9 @@ mod benchmarks {
prepare_contracts_for_tier_assignment::<T>(x);
force_advance_to_next_era::<T>();

// Need to ensure settings remain unchanged even after the era change
init_tier_settings::<T>();

let reward_era = ActiveProtocolState::<T>::get().era;
let reward_period = ActiveProtocolState::<T>::get().period_number();
let reward_pool = Balance::from(10_000 * UNIT as u128);
Expand Down
10 changes: 7 additions & 3 deletions pallets/dapp-staking-v3/src/benchmarking/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,13 @@ pub(super) fn initial_config<T: Config>() {
maintenance: false,
});

// Init tier params
init_tier_settings::<T>();

Safeguard::<T>::put(false);
}

/// Set initial tier param & config
pub(super) fn init_tier_settings<T: Config>() {
let tier_params = TierParameters::<T::NumberOfTiers> {
reward_portion: BoundedVec::try_from(vec![
Permill::from_percent(40),
Expand Down Expand Up @@ -204,8 +210,6 @@ pub(super) fn initial_config<T: Config>() {

StaticTierParams::<T>::put(tier_params);
TierConfig::<T>::put(init_tier_config.clone());

Safeguard::<T>::put(false);
}

/// Maximum number of contracts that 'makes sense' - considers both contract number limit & number of slots.
Expand Down
2 changes: 1 addition & 1 deletion pallets/dapp-staking-v3/src/test/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2386,7 +2386,7 @@ fn tier_config_recalculation_works() {
#[test]
fn get_dapp_tier_assignment_and_rewards_basic_example_works() {
ExtBuilder::build().execute_with(|| {
// Tier config is specially adapter for this test.
// Tier config is specially adapted for this test.
TierConfig::<Test>::mutate(|config| {
config.number_of_slots = 40;
config.slots_per_tier = BoundedVec::try_from(vec![2, 5, 13, 20]).unwrap();
Expand Down
Loading

0 comments on commit 53a9b1a

Please sign in to comment.