Skip to content

Commit 2866ea8

Browse files
committed
ensure share price is calculated for operators who had a received rewards but not in next operator set
1 parent 6d64c9c commit 2866ea8

File tree

4 files changed

+231
-38
lines changed

4 files changed

+231
-38
lines changed

crates/pallet-domains/src/benchmarking.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ mod benchmarks {
490490

491491
#[block]
492492
{
493-
do_finalize_domain_epoch_staking::<T>(domain_id)
493+
do_finalize_domain_epoch_staking::<T>(domain_id, Default::default())
494494
.expect("finalize domain staking should success");
495495
}
496496

@@ -676,7 +676,7 @@ mod benchmarks {
676676
let (operator_owner, operator_id) =
677677
register_helper_operator::<T>(domain_id, T::MinNominatorStake::get());
678678

679-
do_finalize_domain_epoch_staking::<T>(domain_id)
679+
do_finalize_domain_epoch_staking::<T>(domain_id, Default::default())
680680
.expect("finalize domain staking should success");
681681

682682
#[extrinsic_call]
@@ -712,7 +712,7 @@ mod benchmarks {
712712
operator_id,
713713
withdraw_amount * 3u32.into(),
714714
));
715-
do_finalize_domain_epoch_staking::<T>(domain_id)
715+
do_finalize_domain_epoch_staking::<T>(domain_id, Default::default())
716716
.expect("finalize domain staking should success");
717717

718718
// Add one more withdraw and deposit to the previous epoch
@@ -726,7 +726,7 @@ mod benchmarks {
726726
operator_id,
727727
withdraw_amount,
728728
));
729-
do_finalize_domain_epoch_staking::<T>(domain_id)
729+
do_finalize_domain_epoch_staking::<T>(domain_id, Default::default())
730730
.expect("finalize domain staking should success");
731731

732732
#[extrinsic_call]
@@ -757,7 +757,7 @@ mod benchmarks {
757757
operator_id,
758758
staking_amount,
759759
));
760-
do_finalize_domain_epoch_staking::<T>(domain_id)
760+
do_finalize_domain_epoch_staking::<T>(domain_id, Default::default())
761761
.expect("finalize domain staking should success");
762762

763763
// Request `w` withdrawals in different epochs, this removes slightly under (or exactly)
@@ -768,7 +768,7 @@ mod benchmarks {
768768
operator_id,
769769
(T::MinOperatorStake::get() / w.into()).into(),
770770
));
771-
do_finalize_domain_epoch_staking::<T>(domain_id)
771+
do_finalize_domain_epoch_staking::<T>(domain_id, Default::default())
772772
.expect("finalize domain staking should success");
773773
}
774774
// Withdraw all the remaining stake.
@@ -790,7 +790,7 @@ mod benchmarks {
790790
operator_id,
791791
remaining_stake,
792792
));
793-
do_finalize_domain_epoch_staking::<T>(domain_id)
793+
do_finalize_domain_epoch_staking::<T>(domain_id, Default::default())
794794
.expect("finalize domain staking should success");
795795

796796
let current_domain_epoch_index = DomainStakingSummary::<T>::get(domain_id)

crates/pallet-domains/src/nominator_position.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ mod tests {
302302
setup.operator_stake,
303303
setup.min_nominator_stake,
304304
pair.public(),
305+
Default::default(),
305306
BTreeMap::from_iter(vec![(
306307
setup.nominator_account,
307308
(setup.nominator_free_balance, setup.nominator_stake),

crates/pallet-domains/src/staking.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,7 +1442,7 @@ pub(crate) fn do_mark_invalid_bundle_authors<T: Config>(
14421442
Ok(())
14431443
}
14441444

1445-
fn mark_invalid_bundle_author<T: Config>(
1445+
pub(crate) fn mark_invalid_bundle_author<T: Config>(
14461446
operator_id: OperatorId,
14471447
er_hash: ReceiptHashFor<T>,
14481448
stake_summary: &mut StakingSummary<OperatorId, BalanceOf<T>>,
@@ -1573,7 +1573,7 @@ pub(crate) mod tests {
15731573
OperatorRewardSource,
15741574
};
15751575
use sp_runtime::traits::Zero;
1576-
use sp_runtime::{PerThing, Perquintill};
1576+
use sp_runtime::{PerThing, Percent, Perquintill};
15771577
use std::collections::{BTreeMap, BTreeSet};
15781578
use std::ops::RangeInclusive;
15791579
use std::vec;
@@ -1592,6 +1592,7 @@ pub(crate) mod tests {
15921592
operator_stake: BalanceOf<Test>,
15931593
minimum_nominator_stake: BalanceOf<Test>,
15941594
signing_key: OperatorPublicKey,
1595+
nomination_tax: Percent,
15951596
mut nominators: BTreeMap<NominatorId<Test>, (BalanceOf<Test>, BalanceOf<Test>)>,
15961597
) -> (OperatorId, OperatorConfig<BalanceOf<Test>>) {
15971598
nominators.insert(operator_account, (operator_free_balance, operator_stake));
@@ -1640,7 +1641,7 @@ pub(crate) mod tests {
16401641
let operator_config = OperatorConfig {
16411642
signing_key,
16421643
minimum_nominator_stake,
1643-
nomination_tax: Default::default(),
1644+
nomination_tax,
16441645
};
16451646

16461647
let res = Domains::register_operator(
@@ -1741,6 +1742,7 @@ pub(crate) mod tests {
17411742
operator_total_stake,
17421743
AI3,
17431744
pair.public(),
1745+
Default::default(),
17441746
BTreeMap::new(),
17451747
);
17461748

@@ -1826,6 +1828,7 @@ pub(crate) mod tests {
18261828
operator_total_stake,
18271829
10 * AI3,
18281830
pair.public(),
1831+
Default::default(),
18291832
BTreeMap::from_iter(vec![(
18301833
nominator_account,
18311834
(nominator_free_balance, nominator_total_stake),
@@ -1929,6 +1932,7 @@ pub(crate) mod tests {
19291932
operator_stake,
19301933
AI3,
19311934
pair.public(),
1935+
Default::default(),
19321936
BTreeMap::new(),
19331937
);
19341938

@@ -2084,6 +2088,7 @@ pub(crate) mod tests {
20842088
operator_stake,
20852089
minimum_nominator_stake,
20862090
pair.public(),
2091+
Default::default(),
20872092
nominators,
20882093
);
20892094

@@ -3244,6 +3249,7 @@ pub(crate) mod tests {
32443249
operator_stake,
32453250
10 * AI3,
32463251
pair.public(),
3252+
Default::default(),
32473253
BTreeMap::from_iter(nominators),
32483254
);
32493255

@@ -3372,6 +3378,7 @@ pub(crate) mod tests {
33723378
operator_stake,
33733379
10 * AI3,
33743380
pair.public(),
3381+
Default::default(),
33753382
BTreeMap::from_iter(nominators),
33763383
);
33773384

@@ -3538,6 +3545,7 @@ pub(crate) mod tests {
35383545
operator_stake,
35393546
10 * AI3,
35403547
pair.public(),
3548+
Default::default(),
35413549
BTreeMap::from_iter(nominators),
35423550
);
35433551

@@ -3700,6 +3708,7 @@ pub(crate) mod tests {
37003708
10 * AI3,
37013709
pair_1.public(),
37023710
Default::default(),
3711+
Default::default(),
37033712
);
37043713

37053714
let (operator_id_2, _) = register_operator(
@@ -3710,6 +3719,7 @@ pub(crate) mod tests {
37103719
10 * AI3,
37113720
pair_2.public(),
37123721
Default::default(),
3722+
Default::default(),
37133723
);
37143724

37153725
let (operator_id_3, _) = register_operator(
@@ -3720,6 +3730,7 @@ pub(crate) mod tests {
37203730
10 * AI3,
37213731
pair_3.public(),
37223732
Default::default(),
3733+
Default::default(),
37233734
);
37243735

37253736
do_finalize_domain_current_epoch::<Test>(domain_id).unwrap();
@@ -3830,6 +3841,7 @@ pub(crate) mod tests {
38303841
operator_total_stake,
38313842
AI3,
38323843
pair.public(),
3844+
Default::default(),
38333845
BTreeMap::default(),
38343846
);
38353847

@@ -3919,6 +3931,7 @@ pub(crate) mod tests {
39193931
operator_stake,
39203932
10 * AI3,
39213933
pair.public(),
3934+
Default::default(),
39223935
BTreeMap::from_iter(nominators),
39233936
);
39243937

@@ -3978,6 +3991,7 @@ pub(crate) mod tests {
39783991
operator_stake,
39793992
10 * AI3,
39803993
pair.public(),
3994+
Default::default(),
39813995
BTreeMap::from_iter(nominators),
39823996
);
39833997

0 commit comments

Comments
 (0)