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

Increases staking delays #1030

Merged
merged 8 commits into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from 5 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
22 changes: 11 additions & 11 deletions runtime/moonbase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,19 +703,19 @@ impl parachain_info::Config for Runtime {}
parameter_types! {
/// Minimum round length is 2 minutes (10 * 12 second block times)
pub const MinBlocksPerRound: u32 = 10;
/// Default BlocksPerRound is every hour (300 * 12 second block times)
pub const DefaultBlocksPerRound: u32 = 300;
/// Collator candidate exits are delayed by 2 hours (2 * 300 * block_time)
/// Blocks per round
pub const DefaultBlocksPerRound: u32 = 2 * HOURS;
/// Rounds before the collator leaving the candidates request can be executed
pub const LeaveCandidatesDelay: u32 = 2;
/// Collator candidate bond increases/decreases are delayed by 2 hours (2 * 300 block_time)
/// Rounds before the candidate bond increase/decrease can be executed
pub const CandidateBondDelay: u32 = 2;
/// Delegator exits are delayed by 2 hours (2 * 300 * block_time)
/// Rounds before the delegator exit can be executed
pub const LeaveDelegatorsDelay: u32 = 2;
/// Delegation revocations are delayed by 2 hours (2 * 300 * block_time)
/// Rounds before the delegator revocation can be executed
pub const RevokeDelegationDelay: u32 = 2;
/// Delegation bond increases/decreases are delayed by 2 hours (2 * 300 * block_time)
/// Rounds before the delegator bond increase/decrease can be executed
pub const DelegationBondDelay: u32 = 2;
/// Reward payments are delayed by 2 hours (2 * 300 * block_time)
/// Rounds before the reward is paid
pub const RewardPaymentDelay: u32 = 2;
/// Minimum collators selected per round, default at genesis and minimum forever after
pub const MinSelectedCandidates: u32 = 8;
Expand All @@ -728,9 +728,9 @@ parameter_types! {
/// Default percent of inflation set aside for parachain bond every round
pub const DefaultParachainBondReservePercent: Percent = Percent::from_percent(30);
/// Minimum stake required to become a collator
pub const MinCollatorStk: u128 = 1 * currency::KILOUNIT * currency::SUPPLY_FACTOR;
pub const MinCollatorStk: u128 = 1000 * currency::UNIT * currency::SUPPLY_FACTOR;
/// Minimum stake required to be reserved to be a candidate
pub const MinCandidateStk: u128 = 1 * currency::KILOUNIT * currency::SUPPLY_FACTOR;
pub const MinCandidateStk: u128 = 500 * currency::UNIT * currency::SUPPLY_FACTOR;
/// Minimum stake required to be reserved to be a delegator
pub const MinDelegatorStk: u128 = 5 * currency::UNIT * currency::SUPPLY_FACTOR;
}
Expand Down Expand Up @@ -1670,7 +1670,7 @@ mod tests {

// staking minimums
assert_eq!(MinCollatorStk::get(), Balance::from(1 * KILOUNIT));
assert_eq!(MinCandidateStk::get(), Balance::from(1 * KILOUNIT));
assert_eq!(MinCandidateStk::get(), Balance::from(500 * UNIT));
assert_eq!(MinDelegatorStk::get(), Balance::from(5 * UNIT));

// crowdloan min reward
Expand Down
8 changes: 4 additions & 4 deletions runtime/moonbase/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,15 +407,15 @@ fn reward_block_authors() {
.build()
.execute_with(|| {
set_parachain_inherent_data();
for x in 2..599 {
for x in 2..1199 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to express these in terms of the configuration values like 5 * LeaveDelegatorsDelay or whatever value this is. But that can be for a followup.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my deferred staking PR (#1035 ) I added a roll_to_round_begin which takes a round number rather than a block number. That's only loosely related to this...

set_author(NimbusId::from_slice(&ALICE_NIMBUS));
run_to_block(x);
}
// no rewards doled out yet
assert_eq!(Balances::free_balance(AccountId::from(ALICE)), 1_000 * UNIT,);
assert_eq!(Balances::free_balance(AccountId::from(BOB)), 500 * UNIT,);
set_author(NimbusId::from_slice(&ALICE_NIMBUS));
run_to_block(600);
run_to_block(1200);
// rewards minted and distributed
assert_eq!(
Balances::free_balance(AccountId::from(ALICE)),
Expand Down Expand Up @@ -454,7 +454,7 @@ fn reward_block_authors_with_parachain_bond_reserved() {
root_origin(),
AccountId::from(CHARLIE),
),);
for x in 2..599 {
for x in 2..1199 {
set_author(NimbusId::from_slice(&ALICE_NIMBUS));
run_to_block(x);
}
Expand All @@ -463,7 +463,7 @@ fn reward_block_authors_with_parachain_bond_reserved() {
assert_eq!(Balances::free_balance(AccountId::from(BOB)), 500 * UNIT,);
assert_eq!(Balances::free_balance(AccountId::from(CHARLIE)), UNIT,);
set_author(NimbusId::from_slice(&ALICE_NIMBUS));
run_to_block(600);
run_to_block(1200);
// rewards minted and distributed
assert_eq!(
Balances::free_balance(AccountId::from(ALICE)),
Expand Down
30 changes: 15 additions & 15 deletions runtime/moonbeam/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,19 +665,19 @@ impl parachain_info::Config for Runtime {}
parameter_types! {
/// Minimum round length is 2 minutes (10 * 12 second block times)
pub const MinBlocksPerRound: u32 = 10;
/// Default BlocksPerRound is every 4 hours (1200 * 12 second block times)
pub const DefaultBlocksPerRound: u32 = 4 * HOURS;
/// Collator candidate exit delay (number of rounds)
pub const LeaveCandidatesDelay: u32 = 2;
/// Collator candidate bond increases/decreases delay (number of rounds)
pub const CandidateBondDelay: u32 = 2;
/// Delegator exit delay (number of rounds)
pub const LeaveDelegatorsDelay: u32 = 2;
/// Delegation revocations delay (number of rounds)
pub const RevokeDelegationDelay: u32 = 2;
/// Delegation bond increases/decreases delay (number of rounds)
pub const DelegationBondDelay: u32 = 2;
/// Reward payments delay (number of rounds)
/// Blocks per round
pub const DefaultBlocksPerRound: u32 = 6 * HOURS;
/// Rounds before the collator leaving the candidates request can be executed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Rounds before the collator leaving the candidates request can be executed
/// Rounds before the candidate's request to leave can be executed

My rewording makes it clear that this applies to all candidates, not just the selected collators. But after writing it, I wasn't sure that was actually true.

pub const LeaveCandidatesDelay: u32 = 4 * 7;
/// Rounds before the candidate bond increase/decrease can be executed
pub const CandidateBondDelay: u32 = 4 * 7;
/// Rounds before the delegator exit can be executed
pub const LeaveDelegatorsDelay: u32 = 4 * 7;
/// Rounds before the delegator revocation can be executed
pub const RevokeDelegationDelay: u32 = 4 * 7;
/// Rounds before the delegator bond increase/decrease can be executed
pub const DelegationBondDelay: u32 = 4 * 7;
/// Rounds before the reward is paid
pub const RewardPaymentDelay: u32 = 2;
/// Minimum collators selected per round, default at genesis and minimum forever after
pub const MinSelectedCandidates: u32 = 8;
Expand All @@ -690,10 +690,10 @@ parameter_types! {
/// Default percent of inflation set aside for parachain bond every round
pub const DefaultParachainBondReservePercent: Percent = Percent::from_percent(30);
/// Minimum stake required to become a collator
pub const MinCollatorStk: u128 = 1 * currency::KILOGLMR * currency::SUPPLY_FACTOR;
pub const MinCollatorStk: u128 = 1000 * currency::GLMR * currency::SUPPLY_FACTOR;
// TODO: Restore to 100_000 for Phase 2 (remove the division by 10)
/// Minimum stake required to be reserved to be a candidate
pub const MinCandidateStk: u128 = currency::KILOGLMR * currency::SUPPLY_FACTOR / 10;
pub const MinCandidateStk: u128 = 1000 * currency::GLMR * currency::SUPPLY_FACTOR / 10;
4meta5 marked this conversation as resolved.
Show resolved Hide resolved
/// Minimum stake required to be reserved to be a delegator
pub const MinDelegatorStk: u128 = 5 * currency::GLMR * currency::SUPPLY_FACTOR;
}
Expand Down
8 changes: 4 additions & 4 deletions runtime/moonbeam/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ fn reward_block_authors() {
.build()
.execute_with(|| {
set_parachain_inherent_data();
for x in 2..2399 {
for x in 2..3599 {
set_author(NimbusId::from_slice(&ALICE_NIMBUS));
run_to_block(x);
}
Expand All @@ -424,7 +424,7 @@ fn reward_block_authors() {
);
assert_eq!(Balances::free_balance(AccountId::from(BOB)), 50_000 * GLMR,);
set_author(NimbusId::from_slice(&ALICE_NIMBUS));
run_to_block(2400);
run_to_block(3600);
// rewards minted and distributed
assert_eq!(
Balances::free_balance(AccountId::from(ALICE)),
Expand Down Expand Up @@ -463,7 +463,7 @@ fn reward_block_authors_with_parachain_bond_reserved() {
root_origin(),
AccountId::from(CHARLIE),
),);
for x in 2..2399 {
for x in 2..3599 {
set_author(NimbusId::from_slice(&ALICE_NIMBUS));
run_to_block(x);
}
Expand All @@ -475,7 +475,7 @@ fn reward_block_authors_with_parachain_bond_reserved() {
assert_eq!(Balances::free_balance(AccountId::from(BOB)), 50_000 * GLMR,);
assert_eq!(Balances::free_balance(AccountId::from(CHARLIE)), 100 * GLMR,);
set_author(NimbusId::from_slice(&ALICE_NIMBUS));
run_to_block(2400);
run_to_block(3600);
// rewards minted and distributed
assert_eq!(
Balances::free_balance(AccountId::from(ALICE)),
Expand Down
32 changes: 16 additions & 16 deletions runtime/moonriver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,19 +646,19 @@ impl parachain_info::Config for Runtime {}
parameter_types! {
/// Minimum round length is 2 minutes (10 * 12 second block times)
pub const MinBlocksPerRound: u32 = 10;
/// Default BlocksPerRound is every hour (300 * 12 second block times)
pub const DefaultBlocksPerRound: u32 = 300;
/// Collator candidate exits are delayed by 2 hours (2 * 300 * block_time)
pub const LeaveCandidatesDelay: u32 = 2;
/// Collator candidate bond increases/decreases are delayed by 2 hours (2 * 300 block_time)
pub const CandidateBondDelay: u32 = 2;
/// Delegator exits are delayed by 2 hours (2 * 300 * block_time)
pub const LeaveDelegatorsDelay: u32 = 2;
/// Delegation revocations are delayed by 2 hours (2 * 300 * block_time)
pub const RevokeDelegationDelay: u32 = 2;
/// Delegation bond increases/decreases are delayed by 2 hours (2 * 300 * block_time)
pub const DelegationBondDelay: u32 = 2;
/// Reward payments are delayed by 2 hours (2 * 300 * block_time)
/// Blocks per round
pub const DefaultBlocksPerRound: u32 = 2 * HOURS;
/// Rounds before the collator leaving the candidates request can be executed
pub const LeaveCandidatesDelay: u32 = 24;
/// Rounds before the candidate bond increase/decrease can be executed
pub const CandidateBondDelay: u32 = 24;
/// Rounds before the delegator exit can be executed
pub const LeaveDelegatorsDelay: u32 = 24;
/// Rounds before the delegator revocation can be executed
pub const RevokeDelegationDelay: u32 = 24;
/// Rounds before the delegator bond increase/decrease can be executed
pub const DelegationBondDelay: u32 = 24;
/// Rounds before the reward is paid
pub const RewardPaymentDelay: u32 = 2;
/// Minimum collators selected per round, default at genesis and minimum forever after
pub const MinSelectedCandidates: u32 = 8;
Expand All @@ -671,9 +671,9 @@ parameter_types! {
/// Default percent of inflation set aside for parachain bond every round
pub const DefaultParachainBondReservePercent: Percent = Percent::from_percent(30);
/// Minimum stake required to become a collator
pub const MinCollatorStk: u128 = 1 * currency::KILOMOVR * currency::SUPPLY_FACTOR;
pub const MinCollatorStk: u128 = 1000 * currency::MOVR * currency::SUPPLY_FACTOR;
/// Minimum stake required to be reserved to be a candidate
pub const MinCandidateStk: u128 = 1 * currency::KILOMOVR * currency::SUPPLY_FACTOR;
pub const MinCandidateStk: u128 = 500 * currency::MOVR * currency::SUPPLY_FACTOR;
/// Minimum stake required to be reserved to be a delegator
pub const MinDelegatorStk: u128 = 5 * currency::MOVR * currency::SUPPLY_FACTOR;
}
Expand Down Expand Up @@ -1137,7 +1137,7 @@ mod tests {

// staking minimums
assert_eq!(MinCollatorStk::get(), Balance::from(1 * KILOMOVR));
assert_eq!(MinCandidateStk::get(), Balance::from(1 * KILOMOVR));
assert_eq!(MinCandidateStk::get(), Balance::from(500 * MOVR));
assert_eq!(MinDelegatorStk::get(), Balance::from(5 * MOVR));

// crowdloan min reward
Expand Down
8 changes: 4 additions & 4 deletions runtime/moonriver/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,15 +394,15 @@ fn reward_block_authors() {
.build()
.execute_with(|| {
set_parachain_inherent_data();
for x in 2..599 {
for x in 2..1199 {
set_author(NimbusId::from_slice(&ALICE_NIMBUS));
run_to_block(x);
}
// no rewards doled out yet
assert_eq!(Balances::free_balance(AccountId::from(ALICE)), 1_000 * MOVR,);
assert_eq!(Balances::free_balance(AccountId::from(BOB)), 500 * MOVR,);
set_author(NimbusId::from_slice(&ALICE_NIMBUS));
run_to_block(600);
run_to_block(1200);
// rewards minted and distributed
assert_eq!(
Balances::free_balance(AccountId::from(ALICE)),
Expand Down Expand Up @@ -441,7 +441,7 @@ fn reward_block_authors_with_parachain_bond_reserved() {
root_origin(),
AccountId::from(CHARLIE),
),);
for x in 2..599 {
for x in 2..1199 {
set_author(NimbusId::from_slice(&ALICE_NIMBUS));
run_to_block(x);
}
Expand All @@ -450,7 +450,7 @@ fn reward_block_authors_with_parachain_bond_reserved() {
assert_eq!(Balances::free_balance(AccountId::from(BOB)), 500 * MOVR,);
assert_eq!(Balances::free_balance(AccountId::from(CHARLIE)), MOVR,);
set_author(NimbusId::from_slice(&ALICE_NIMBUS));
run_to_block(600);
run_to_block(1200);
// rewards minted and distributed
assert_eq!(
Balances::free_balance(AccountId::from(ALICE)),
Expand Down