Skip to content
This repository has been archived by the owner on Jul 7, 2021. It is now read-only.

Revamp parachain-selection part 2 #43

Merged
merged 19 commits into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions Cargo.lock

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

21 changes: 13 additions & 8 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub type ChainSpec = sc_service::GenericChainSpec<statemint_runtime::GenesisConf
pub type StatemineChainSpec = sc_service::GenericChainSpec<statemine_runtime::GenesisConfig, Extensions>;

/// Helper function to generate a crypto pair from seed
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
pub fn get_pair_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
TPublic::Pair::from_string(&format!("//{}", seed), None)
.expect("static values are valid; qed")
.public()
Expand All @@ -36,13 +36,12 @@ impl Extensions {
}

type AccountPublic = <Signature as Verify>::Signer;

/// Helper function to generate an account ID from seed
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
where
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
{
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
AccountPublic::from(get_pair_from_seed::<TPublic>(seed)).into_account()
}

pub fn statemint_development_config(id: ParaId) -> ChainSpec {
Expand Down Expand Up @@ -126,12 +125,14 @@ fn statemint_testnet_genesis(
},
pallet_sudo: statemint_runtime::SudoConfig { key: root_key.clone() },
parachain_info: statemint_runtime::ParachainInfoConfig { parachain_id: id },
pallet_collator_selection: statemint_runtime::CollatorSelectionConfig { invulnerables: vec![root_key] },
pallet_collator_selection: statemint_runtime::CollatorSelectionConfig {
invulnerables: vec![root_key],
kianenigma marked this conversation as resolved.
Show resolved Hide resolved
candidacy_bond: 1 << 60,
..Default::default()
},
}
}



pub fn statemine_development_config(id: ParaId) -> StatemineChainSpec {
StatemineChainSpec::from_genesis(
// Name
Expand Down Expand Up @@ -200,7 +201,6 @@ pub fn statemine_local_config(id: ParaId) -> StatemineChainSpec {
)
}


fn statemine_testnet_genesis(
root_key: AccountId,
endowed_accounts: Vec<AccountId>,
Expand All @@ -222,6 +222,11 @@ fn statemine_testnet_genesis(
},
pallet_sudo: statemine_runtime::SudoConfig { key: root_key.clone() },
parachain_info: statemine_runtime::ParachainInfoConfig { parachain_id: id },
pallet_collator_selection: statemine_runtime::CollatorSelectionConfig { invulnerables: vec![root_key] },
pallet_aura: statemine_runtime::AuraConfig { authorities: vec![] },
pallet_collator_selection: statemine_runtime::CollatorSelectionConfig {
invulnerables: vec![root_key],
candidacy_bond: 1 << 60,
..Default::default()
},
}
}
100 changes: 21 additions & 79 deletions pallets/collator-selection/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,85 +12,26 @@ version = '3.0.0'
[package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu']

[dependencies.log]
default-features = false
version = "0.4.0"

[dependencies.codec]
default-features = false
features = ['derive']
package = 'parity-scale-codec'
version = '2.0.0'

[dependencies.pallet-authorship]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
branch = 'rococo-v1'
version = '3.0.0'

[dependencies.frame-benchmarking]
default-features = false
optional = true
git = 'https://github.com/paritytech/substrate.git'
branch = 'rococo-v1'
version = '3.0.0'

[dependencies.frame-support]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
branch = 'rococo-v1'
version = '3.0.0'

[dependencies.frame-system]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
branch = 'rococo-v1'
version = '3.0.0'

[dependencies.sp-std]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
branch = 'rococo-v1'
version = '3.0.0'

[dependencies.serde]
version = "1.0.119"
default-features = false

[dev-dependencies.sp-core]
git = 'https://github.com/paritytech/substrate.git'
branch = 'rococo-v1'
version = '3.0.0'

[dev-dependencies.sp-io]
git = 'https://github.com/paritytech/substrate.git'
branch = 'rococo-v1'
version = '3.0.0'

[dev-dependencies.sp-runtime]
git = 'https://github.com/paritytech/substrate.git'
branch = 'rococo-v1'
version = '3.0.0'

[dev-dependencies.pallet-aura]
git = 'https://github.com/paritytech/substrate.git'
branch = 'rococo-v1'
version = '3.0.0'

[dev-dependencies.pallet-timestamp]
git = 'https://github.com/paritytech/substrate.git'
branch = 'rococo-v1'
version = '3.0.0'

[dev-dependencies.sp-consensus-aura]
git = 'https://github.com/paritytech/substrate.git'
branch = 'rococo-v1'
version = '0.9.0'

[dev-dependencies.pallet-balances]
git = 'https://github.com/paritytech/substrate.git'
branch = 'rococo-v1'
version = '3.0.0'
[dependencies]
log = { version = "0.4.0", default-features = false }
codec = { default-features = false, features = ['derive'], package = 'parity-scale-codec', version = '2.0.0' }
serde = { version = "1.0.119", default-features = false }
sp-std = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'rococo-v1', version = '3.0.0' }
frame-support = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'rococo-v1', version = '3.0.0' }
frame-system = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'rococo-v1', version = '3.0.0' }
pallet-authorship = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'rococo-v1', version = '3.0.0' }
pallet-session = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'rococo-v1', version = '3.0.0' }

frame-benchmarking = { default-features = false, optional = true, git = 'https://github.com/paritytech/substrate.git', branch = 'rococo-v1', version = '3.0.0' }

[dev-dependencies]
sp-core = { git = 'https://github.com/paritytech/substrate.git', branch = 'rococo-v1', version = '3.0.0' }
sp-io = { git = 'https://github.com/paritytech/substrate.git', branch = 'rococo-v1', version = '3.0.0' }
sp-runtime = { git = 'https://github.com/paritytech/substrate.git', branch = 'rococo-v1', version = '3.0.0' }
pallet-timestamp = { git = 'https://github.com/paritytech/substrate.git', branch = 'rococo-v1', version = '3.0.0' }
sp-consensus-aura = { git = 'https://github.com/paritytech/substrate.git', branch = 'rococo-v1', version = '0.9.0' }
pallet-balances = { git = 'https://github.com/paritytech/substrate.git', branch = 'rococo-v1', version = '3.0.0' }
pallet-aura = { git = 'https://github.com/paritytech/substrate.git', branch = 'rococo-v1', version = '3.0.0' }

[features]
default = ['std']
Expand All @@ -107,4 +48,5 @@ std = [
'frame-system/std',
'frame-benchmarking/std',
'pallet-authorship/std',
'pallet-session/std',
]
8 changes: 4 additions & 4 deletions pallets/collator-selection/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ benchmarks! {
let origin = T::UpdateOrigin::successful_origin();
}: {
assert_ok!(
<CollatorSelection<T>>::set_max_candidates(origin, max.clone())
<CollatorSelection<T>>::set_desired_candidates(origin, max.clone())
);
}
verify {
assert_last_event::<T>(Event::NewDesiredCandidate(max).into());
assert_last_event::<T>(Event::NewDesiredCandidates(max).into());
}

set_candidacy_bond {
Expand All @@ -105,7 +105,7 @@ benchmarks! {
let c in 1 .. T::MaxCandidates::get();

<CandidacyBond<T>>::put(T::Currency::minimum_balance());
<DesiredCandidate<T>>::put(c + 1);
<DesiredCandidates<T>>::put(c + 1);
register_candidates::<T>(c);

let caller: T::AccountId = whitelisted_caller();
Expand All @@ -121,7 +121,7 @@ benchmarks! {
leave_intent {
let c in 1 .. T::MaxCandidates::get();
<CandidacyBond<T>>::put(T::Currency::minimum_balance());
<DesiredCandidate<T>>::put(c);
<DesiredCandidates<T>>::put(c);
register_candidates::<T>(c);

let leaving = <Candidates<T>>::get().last().unwrap().who.clone();
Expand Down
Loading