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

Go back to block based staking rounds and make inflation dynamic (slot based) #2690

Merged
merged 32 commits into from
Mar 4, 2024
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
4cc6ad4
make staking rounds block based again and inflation slot based
librelois Feb 26, 2024
7081f63
remove unused imports
librelois Feb 26, 2024
4bca269
create migration skeleton
librelois Feb 26, 2024
6569530
implement migration
librelois Feb 27, 2024
c767ee5
integrate round migration to common migrations
librelois Feb 27, 2024
6f4ebca
apply proportion duration to the current round
librelois Feb 28, 2024
c552dd5
compile benchs and test
librelois Feb 28, 2024
eac1c7a
add moonbase migration to multiply round length by 2
librelois Feb 28, 2024
7a40e08
compute round duration before round update
librelois Feb 28, 2024
82d249d
fix some bugs
librelois Feb 29, 2024
a55186e
fix some rust tests
librelois Feb 29, 2024
b8074d9
fix migration
librelois Mar 1, 2024
e284107
Merge branch 'master' into elois-rework-staking-rounds
librelois Mar 1, 2024
2dad7f9
apply suggestions
librelois Mar 1, 2024
e6bc039
First staking rewards at round 3
librelois Mar 1, 2024
03c751e
revert moonwall config local changes
librelois Mar 1, 2024
00f1935
fix rounds per year
librelois Mar 1, 2024
09f610b
fix periods calculation in reset_round()
Agusrodri Mar 1, 2024
122681a
fix rustc warning
librelois Mar 1, 2024
77049b8
fmt
librelois Mar 1, 2024
1335e31
rework compute issuance
librelois Mar 1, 2024
43e87c3
Remove Staked storage item
librelois Mar 1, 2024
ef7fdda
Remove Staked storage item on rust tests
librelois Mar 1, 2024
17fa448
fix two rust tests more
Agusrodri Mar 1, 2024
ec43a24
fix test_on_initialize_weights
Agusrodri Mar 1, 2024
9cbe017
fix payouts_follow_delegation_changes test
Agusrodri Mar 3, 2024
2953eb9
Update pallets/parachain-staking/src/lib.rs
librelois Mar 4, 2024
08472ab
Comment moonbase migration
librelois Mar 4, 2024
4b65251
typo
librelois Mar 4, 2024
e9dab8b
Update runtime/moonbase/src/migrations.rs
librelois Mar 4, 2024
96336ef
Update runtime/moonbase/src/migrations.rs
RomarQ Mar 4, 2024
6b2f75c
Update pallets/parachain-staking/src/lib.rs
RomarQ Mar 4, 2024
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
30 changes: 17 additions & 13 deletions pallets/parachain-staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5395,6 +5395,9 @@ fn payouts_follow_delegation_changes() {
])
.build()
.execute_with(|| {
// ~ set block author as 1 for all blocks this round
set_author(1, 1, 100);
RomarQ marked this conversation as resolved.
Show resolved Hide resolved
set_author(2, 1, 100);
roll_to_round_begin(2);
// chooses top TotalSelectedCandidates (5), in order
assert_events_eq!(
Expand Down Expand Up @@ -5425,8 +5428,10 @@ fn payouts_follow_delegation_changes() {
total_balance: 130,
},
);
// ~ set block author as 1 for all blocks this round
set_author(2, 1, 100);

set_author(3, 1, 100);
set_author(4, 1, 100);

roll_to_round_begin(4);
// distribute total issuance to collator 1 and its delegators 6, 7, 19
assert_events_eq!(
Expand Down Expand Up @@ -5477,10 +5482,7 @@ fn payouts_follow_delegation_changes() {
},
);
// ~ set block author as 1 for all blocks this round
set_author(3, 1, 100);
set_author(4, 1, 100);
set_author(5, 1, 100);
set_author(6, 1, 100);

roll_blocks(1);
// 1. ensure delegators are paid for 2 rounds after they leave
Expand Down Expand Up @@ -5547,6 +5549,8 @@ fn payouts_follow_delegation_changes() {
rewards: 8,
},
);

set_author(6, 1, 100);
// keep paying 6 (note: inflation is in terms of total issuance so that's why 1 is 21)
roll_to_round_begin(6);
assert_ok!(ParachainStaking::execute_delegation_request(
Expand Down Expand Up @@ -5663,6 +5667,7 @@ fn payouts_follow_delegation_changes() {
rewards: 10,
},
);
set_author(8, 1, 100);
roll_to_round_begin(8);
assert_events_eq!(
Event::CollatorChosen {
Expand Down Expand Up @@ -5696,7 +5701,7 @@ fn payouts_follow_delegation_changes() {
assert_events_eq!(
Event::Rewarded {
account: 1,
rewards: 33,
rewards: 32,
},
Event::Rewarded {
account: 7,
Expand All @@ -5707,7 +5712,7 @@ fn payouts_follow_delegation_changes() {
rewards: 11,
},
);
set_author(8, 1, 100);
set_author(9, 1, 100);
roll_to_round_begin(9);
// no more paying 6
assert_events_eq!(
Expand Down Expand Up @@ -5754,7 +5759,6 @@ fn payouts_follow_delegation_changes() {
},
);
roll_blocks(1);
set_author(9, 1, 100);
assert_ok!(ParachainStaking::delegate(
RuntimeOrigin::signed(8),
1,
Expand All @@ -5770,6 +5774,7 @@ fn payouts_follow_delegation_changes() {
auto_compound: Percent::zero(),
});

set_author(10, 1, 100);
roll_to_round_begin(10);
// new delegation is not rewarded yet
assert_events_eq!(
Expand Down Expand Up @@ -5815,7 +5820,6 @@ fn payouts_follow_delegation_changes() {
rewards: 12,
},
);
set_author(10, 1, 100);
roll_to_round_begin(11);
// new delegation not rewarded yet
assert_events_eq!(
Expand Down Expand Up @@ -5850,7 +5854,7 @@ fn payouts_follow_delegation_changes() {
assert_events_eq!(
Event::Rewarded {
account: 1,
rewards: 38,
rewards: 37,
},
Event::Rewarded {
account: 7,
Expand Down Expand Up @@ -5900,15 +5904,15 @@ fn payouts_follow_delegation_changes() {
},
Event::Rewarded {
account: 7,
rewards: 11,
rewards: 10,
},
Event::Rewarded {
account: 10,
rewards: 11,
rewards: 10,
},
Event::Rewarded {
account: 8,
rewards: 11,
rewards: 10,
},
);
});
Expand Down
Loading