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

Delay nominator revocations and exits #610

Merged
merged 32 commits into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a72fa49
init
4meta5 Jul 13, 2021
3bee0f8
save
4meta5 Jul 14, 2021
2bd14b6
Merge branch 'master' into amar-delay-nominator-exits
4meta5 Jul 14, 2021
80b0fdc
save
4meta5 Jul 14, 2021
64c8975
save
4meta5 Jul 15, 2021
ed37abc
log::trace -> log::warn, drop errors, and fix compile errors
4meta5 Jul 15, 2021
bdef907
commit migrationss design will revert for simpler impl
4meta5 Jul 15, 2021
14ddec0
minimal migration impl instead
4meta5 Jul 15, 2021
753c1ff
delay leave nominators with all unit tests passing
4meta5 Jul 16, 2021
1dc6721
delayed revoke_nomination with all tests passing
4meta5 Jul 17, 2021
828ccfe
unit tests
4meta5 Jul 17, 2021
3dfaa37
split BondDuration into 4 constants and update runtimes
4meta5 Jul 18, 2021
e47cbff
try green
4meta5 Jul 18, 2021
5b402f6
green
4meta5 Jul 18, 2021
7ead86a
rm revoke nomination TS test because it expects revocation to be imme…
4meta5 Jul 18, 2021
b4b1c5f
add types to moonbeam types bundle and update test instead of comment…
4meta5 Jul 18, 2021
dc39836
fix
4meta5 Jul 18, 2021
48fa23c
fix
4meta5 Jul 18, 2021
b81d122
try fix TS test
4meta5 Jul 19, 2021
c4a70cd
try again
4meta5 Jul 19, 2021
cddd23d
every byte counts
4meta5 Jul 19, 2021
b0060fb
x
4meta5 Jul 19, 2021
7ecd21e
y
4meta5 Jul 19, 2021
15fb7dd
z
4meta5 Jul 19, 2021
fc793dc
update weights
4meta5 Jul 19, 2021
d86eb2f
Merge branch 'master' into amar-delay-nominator-exits
4meta5 Jul 19, 2021
f90f0b3
ready for review
4meta5 Jul 20, 2021
94183d8
rm unused errors
4meta5 Jul 20, 2021
32f0985
more accurate weight returned in on runtime upgrade
4meta5 Jul 20, 2021
1eed8ab
fix weight, one read to check if migration has run before
4meta5 Jul 20, 2021
bf7af99
Merge branch 'master' into amar-delay-nominator-exits
4meta5 Jul 22, 2021
8855011
Update pallets/parachain-staking/src/lib.rs
4meta5 Jul 22, 2021
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
54 changes: 53 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 18 additions & 1 deletion moonbeam-types-bundle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,17 @@ export const moonbeamDefinitions = {
nominations: "Vec<Bond>",
total: "Balance",
},
NominatorStatus: {
_enum: ["Active", { Leaving: "RoundIndex" }],
},
Nominator2: {
nominations: "Vec<Bond>",
revocations: "Vec<AccountId>",
total: "Balance",
scheduled_revocations_count: "u32",
scheduled_revocations_total: "Balance",
status: "NominatorStatus",
},
Bond: {
owner: "AccountId",
amount: "Balance",
Expand Down Expand Up @@ -680,7 +691,7 @@ export const moonbeamDefinitions = {
state: "CollatorStatus",
},
NominatorAdded: {
_enum: ["AddedToBottom", { AddedToTop: "Balance" }],
_enum: [{ AddedToTop: "Balance" }, "AddedToBottom"],
4meta5 marked this conversation as resolved.
Show resolved Hide resolved
},
CollatorSnapshot: {
bond: "Balance",
Expand Down Expand Up @@ -716,6 +727,12 @@ export const moonbeamDefinitions = {
s: "H256",
v: "U8",
},
ExitQ: {
candidates: "Vec<AccountId>",
nominators_leaving: "Vec<AccountId>",
candidate_schedule: "Vec<(AccountId, RoundIndex)>",
nominator_schedule: "Vec<(AccountId, Option<AccountId>, RoundIndex)>",
},
},
},
],
Expand Down
15 changes: 8 additions & 7 deletions pallets/parachain-staking/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
[package]
name = "parachain-staking"
version = "2.1.0"
version = "2.1.1"
authors = ["PureStake"]
edition = "2018"
description = "parachain staking pallet for collator selection and reward distribution"

[dependencies]
nimbus-primitives = { git = "https://github.com/purestake/cumulus", branch = "joshy-np098", default-features = false }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false, optional = true }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
log = "0.4"
nimbus-primitives = { git = "https://github.com/purestake/cumulus", branch = "joshy-np098", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
parity-scale-codec = { version = "2.0.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.101", optional = true }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
substrate-fixed = { default-features = false, git = "https://github.com/encointer/substrate-fixed" }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false, optional = true }

[dev-dependencies]
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
similar-asserts = "1.1.0"
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }

[features]
default = ["std"]
std = [
"frame-benchmarking/std",
"frame-support/std",
"frame-system/std",
"frame-benchmarking/std",
"nimbus-primitives/std",
"pallet-balances/std",
"parity-scale-codec/std",
Expand Down
6 changes: 6 additions & 0 deletions pallets/parachain-staking/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# DPoS Pallet for Parachain Staking

## Formatting Rules

- dependencies in alphabetical order in the `Cargo.toml` and at the top of each file
- prefer explicit imports to glob import syntax i.e. prefer `use::crate::{Ex1, Ex2, ..};` to `use super::*;`
13 changes: 8 additions & 5 deletions pallets/parachain-staking/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ benchmarks! {
}
}: _(RawOrigin::Signed(caller.clone()), nomination_count)
verify {
assert!(!Pallet::<T>::is_nominator(&caller));
assert!(Pallet::<T>::nominator_state2(&caller).unwrap().is_leaving());
}

revoke_nomination {
Expand All @@ -363,9 +363,12 @@ benchmarks! {
0u32,
0u32
)?;
}: _(RawOrigin::Signed(caller.clone()), collator)
}: _(RawOrigin::Signed(caller.clone()), collator.clone())
verify {
assert!(!Pallet::<T>::is_nominator(&caller));
assert_eq!(
Pallet::<T>::nominator_state2(&caller).unwrap().revocations.0[0],
collator
);
}

nominator_bond_more {
Expand Down Expand Up @@ -520,7 +523,7 @@ benchmarks! {
// PREPARE RUN_TO_BLOCK LOOP
let before_running_round_index = Pallet::<T>::round().current;
let round_length: T::BlockNumber = Pallet::<T>::round().length.into();
let reward_delay = <<T as Config>::BondDuration as Get<u32>>::get() + 2u32;
let reward_delay = <<T as Config>::RewardPaymentDelay as Get<u32>>::get() + 2u32;
let mut now = <frame_system::Pallet<T>>::block_number();
let mut counter = 0usize;
let end = Pallet::<T>::round().first + (round_length * reward_delay.into());
Expand Down Expand Up @@ -581,7 +584,7 @@ benchmarks! {

#[cfg(test)]
mod tests {
use super::*;
use crate::benchmarks::*;
use crate::mock::Test;
use frame_support::assert_ok;
use sp_io::TestExternalities;
Expand Down
Loading