Skip to content

Commit

Permalink
Use parachain-staking for collator selection, delegation, and inflati…
Browse files Browse the repository at this point in the history
…on-based payouts (#131)

This pr replaces collator-selection with parachain-staking. This migrates our chain from PoA (proof of authority) to dPoS (delegated proof of stake). Parachain-staking handles the mechanics of collator bonding and delegation, selection of the active set of collators, and payouts (through inflation) for successful block production.
  • Loading branch information
nvengal committed May 5, 2022
1 parent 6180a0f commit ba513a7
Show file tree
Hide file tree
Showing 8 changed files with 189 additions and 144 deletions.
76 changes: 48 additions & 28 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,7 @@ polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "relea
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.18" }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.18" }
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.18" }
polkadot-test-service = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.18" }
polkadot-test-service = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.18" }

# Moonbeam Dependencies
parachain-staking = { git = "https://github.com/OAK-Foundation/moonbeam", default-features = false, branch = "oak-polkadot-v0.9.18" }
24 changes: 4 additions & 20 deletions node/src/chain_spec/neumann.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use sp_core::{crypto::UncheckedInto, sr25519};

use super::TELEMETRY_URL;
use crate::chain_spec::{
get_account_id_from_seed, get_collator_keys_from_seed, validate_allocation,
validate_vesting, Extensions,
get_account_id_from_seed, get_collator_keys_from_seed, validate_allocation, validate_vesting,
Extensions,
};
use neumann_runtime::{
CouncilConfig, SudoConfig, TechnicalMembershipConfig, ValveConfig, VestingConfig, DOLLAR,
Expand Down Expand Up @@ -59,8 +59,6 @@ pub fn development_config() -> ChainSpec {
let endowed_accounts: Vec<(AccountId, Balance)> =
accounts.iter().cloned().map(|k| (k, initial_balance)).collect();

let collator_bond = EXISTENTIAL_DEPOSIT * 16;

testnet_genesis(
// initial collators.
vec![
Expand All @@ -80,7 +78,6 @@ pub fn development_config() -> ChainSpec {
vec![],
vec![get_account_id_from_seed::<sr25519::Public>("Alice")],
vec![get_account_id_from_seed::<sr25519::Public>("Alice")],
collator_bond,
)
},
Vec::new(),
Expand Down Expand Up @@ -127,8 +124,6 @@ pub fn local_testnet_config() -> ChainSpec {
let initial_vesting: Vec<(u64, Vec<(AccountId, Balance)>)> =
serde_json::from_slice(vesting_json).unwrap();

let collator_bond = EXISTENTIAL_DEPOSIT * 16;

testnet_genesis(
// initial collators.
vec![
Expand All @@ -148,7 +143,6 @@ pub fn local_testnet_config() -> ChainSpec {
initial_vesting,
vec![get_account_id_from_seed::<sr25519::Public>("Alice")],
vec![get_account_id_from_seed::<sr25519::Public>("Alice")],
collator_bond,
)
},
// Bootnodes
Expand Down Expand Up @@ -209,8 +203,6 @@ pub fn neumann_staging_testnet_config() -> ChainSpec {
vest_ending_time,
);

let collator_bond = EXISTENTIAL_DEPOSIT * 16;

testnet_genesis(
// initial collators.
vec![
Expand Down Expand Up @@ -257,7 +249,6 @@ pub fn neumann_staging_testnet_config() -> ChainSpec {
// 669ocRxey7vxUJs1TTRWe31zwrpGr8B13zRfAHB6yhhfcMud
hex!["001fbcefa8c96f3d2e236688da5485a0af67988b78d61ea952f461255d1f4267"].into(),
],
collator_bond,
)
},
// Bootnodes
Expand Down Expand Up @@ -302,8 +293,6 @@ pub fn neumann_latest() -> ChainSpec {
EXISTENTIAL_DEPOSIT,
);

let collator_bond = EXISTENTIAL_DEPOSIT * 16;

testnet_genesis(
// initial collators.
vec![
Expand Down Expand Up @@ -350,7 +339,6 @@ pub fn neumann_latest() -> ChainSpec {
// 669ocRxey7vxUJs1TTRWe31zwrpGr8B13zRfAHB6yhhfcMud
hex!["001fbcefa8c96f3d2e236688da5485a0af67988b78d61ea952f461255d1f4267"].into(),
],
collator_bond,
)
},
// Bootnodes
Expand Down Expand Up @@ -379,7 +367,6 @@ fn testnet_genesis(
vesting_schedule: Vec<(u64, Vec<(AccountId, Balance)>)>,
general_councils: Vec<AccountId>,
technical_memberships: Vec<AccountId>,
collator_bond: u128,
) -> neumann_runtime::GenesisConfig {
neumann_runtime::GenesisConfig {
system: neumann_runtime::SystemConfig {
Expand All @@ -389,11 +376,6 @@ fn testnet_genesis(
},
balances: neumann_runtime::BalancesConfig { balances: endowed_accounts },
parachain_info: neumann_runtime::ParachainInfoConfig { parachain_id: para_id },
collator_selection: neumann_runtime::CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: collator_bond,
..Default::default()
},
session: neumann_runtime::SessionConfig {
keys: invulnerables
.into_iter()
Expand All @@ -406,6 +388,8 @@ fn testnet_genesis(
})
.collect(),
},
// Defaults to active collators from session pallet unless configured otherwise
parachain_staking: Default::default(),
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
// of this.
aura: Default::default(),
Expand Down
21 changes: 4 additions & 17 deletions node/src/chain_spec/turing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use sp_core::{crypto::UncheckedInto, sr25519};

use super::TELEMETRY_URL;
use crate::chain_spec::{
get_account_id_from_seed, get_collator_keys_from_seed, validate_allocation,
validate_vesting, Extensions,
get_account_id_from_seed, get_collator_keys_from_seed, validate_allocation, validate_vesting,
Extensions,
};
use primitives::{AccountId, AuraId, Balance};
use turing_runtime::{
Expand Down Expand Up @@ -60,8 +60,6 @@ pub fn turing_development_config() -> ChainSpec {
let endowed_accounts: Vec<(AccountId, Balance)> =
accounts.iter().cloned().map(|k| (k, initial_balance)).collect();

let collator_bond = EXISTENTIAL_DEPOSIT * 16;

testnet_genesis(
// initial collators.
vec![
Expand All @@ -81,7 +79,6 @@ pub fn turing_development_config() -> ChainSpec {
vec![],
vec![get_account_id_from_seed::<sr25519::Public>("Alice")],
vec![get_account_id_from_seed::<sr25519::Public>("Alice")],
collator_bond,
)
},
Vec::new(),
Expand Down Expand Up @@ -135,8 +132,6 @@ pub fn turing_staging() -> ChainSpec {
vest_ending_time,
);

let collator_bond = 400_000 * DOLLAR;

testnet_genesis(
// initial collators.
vec![
Expand Down Expand Up @@ -185,7 +180,6 @@ pub fn turing_staging() -> ChainSpec {
// 669ocRxey7vxUJs1TTRWe31zwrpGr8B13zRfAHB6yhhfcMud
hex!["001fbcefa8c96f3d2e236688da5485a0af67988b78d61ea952f461255d1f4267"].into(),
],
collator_bond,
)
},
// Bootnodes
Expand Down Expand Up @@ -246,8 +240,6 @@ pub fn turing_live() -> ChainSpec {
vest_ending_time,
);

let collator_bond = 400_000 * DOLLAR;

testnet_genesis(
// initial collators.
vec![
Expand Down Expand Up @@ -296,7 +288,6 @@ pub fn turing_live() -> ChainSpec {
// 669ocRxey7vxUJs1TTRWe31zwrpGr8B13zRfAHB6yhhfcMud
hex!["001fbcefa8c96f3d2e236688da5485a0af67988b78d61ea952f461255d1f4267"].into(),
],
collator_bond,
)
},
// Bootnodes
Expand Down Expand Up @@ -325,7 +316,6 @@ fn testnet_genesis(
vesting_schedule: Vec<(u64, Vec<(AccountId, Balance)>)>,
general_councils: Vec<AccountId>,
technical_memberships: Vec<AccountId>,
collator_bond: u128,
) -> turing_runtime::GenesisConfig {
turing_runtime::GenesisConfig {
system: turing_runtime::SystemConfig {
Expand All @@ -335,11 +325,6 @@ fn testnet_genesis(
},
balances: turing_runtime::BalancesConfig { balances: endowed_accounts },
parachain_info: turing_runtime::ParachainInfoConfig { parachain_id: para_id },
collator_selection: turing_runtime::CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: collator_bond,
..Default::default()
},
session: turing_runtime::SessionConfig {
keys: invulnerables
.into_iter()
Expand All @@ -352,6 +337,8 @@ fn testnet_genesis(
})
.collect(),
},
// Defaults to active collators from session pallet unless configured otherwise
parachain_staking: Default::default(),
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
// of this.
aura: Default::default(),
Expand Down
Loading

0 comments on commit ba513a7

Please sign in to comment.