Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
413b111
add new runtime and remove unnecessary pallets
joepetrowski May 23, 2022
f2e20ae
make runtime build
joepetrowski May 23, 2022
77f7d65
add collectives to collator node
joepetrowski May 23, 2022
75e7d74
sketch alliance config in runtime
joepetrowski May 23, 2022
0cb20d9
Slash handler was supposed to be commented out (for now)
joepetrowski May 23, 2022
f8843aa
correct signature
joepetrowski May 23, 2022
5e65175
move to impls
joepetrowski May 23, 2022
755f5f3
Merge remote-tracking branch 'origin' into joe-alliance
joepetrowski Jun 10, 2022
628cad6
add alliance to runtime
joepetrowski Jun 11, 2022
1b82389
rustfmt
joepetrowski Jun 11, 2022
3de8e69
IsReserve, remove Ping, update fn deposit
joepetrowski Jun 17, 2022
0d3a72f
merge master
joepetrowski Jun 17, 2022
0f82205
add transaction_payment event
joepetrowski Jun 17, 2022
5dededb
Update parachains/runtimes/collectives/collectives-polkadot/src/lib.rs
joepetrowski Jun 17, 2022
315560b
fmt
joepetrowski Jun 17, 2022
d0d190b
add genesis config to chain spec
joepetrowski Jun 17, 2022
408aedb
try merge master
joepetrowski Jun 17, 2022
24cdf21
fix merge
joepetrowski Jun 17, 2022
0461bb6
local and dev configs only (for now)
joepetrowski Jun 17, 2022
f2704ad
merge cargo.lock
joepetrowski Jun 17, 2022
3657e78
merge master
joepetrowski Jun 18, 2022
7413c46
remove duplicate imports
joepetrowski Jun 19, 2022
e4433f2
Collectives polkadot runtime to cargo workspace members (#1397)
muharem Jun 21, 2022
1b3440e
Collectives polkadot runtime: use unit type impl for identity verifie…
muharem Jun 21, 2022
b507e86
Merge remote-tracking branch 'origin' into joe-alliance
joepetrowski Jun 21, 2022
426b9d7
apply fn rename
joepetrowski Jun 21, 2022
2290b5b
fmt
joepetrowski Jun 21, 2022
db78514
Merge branch 'master' into joe-alliance
gilescope Jun 23, 2022
8adf0e5
one less todo
gilescope Jun 23, 2022
aeeaea5
Merge remote-tracking branch 'origin' into joe-alliance
joepetrowski Jun 29, 2022
cbf45d4
Less code in magic macros (#1407)
gilescope Jul 1, 2022
4a0662a
Merge remote-tracking branch 'origin' into joe-alliance
joepetrowski Jul 7, 2022
26301ad
Bench alliance (#1427)
gilescope Jul 12, 2022
938a8b8
enable ci jobs
alvicsam Jul 12, 2022
6db029b
fix publish bench results jobs
alvicsam Jul 12, 2022
9163d64
Merge branch 'master' into joe-alliance
gilescope Jul 12, 2022
6d5d16e
chainspecs for collectives-westend (#1441)
gilescope Jul 19, 2022
60b48f0
lock
joepetrowski Jul 21, 2022
7061e23
merge master
joepetrowski Jul 21, 2022
6087ae8
Collectives: teleport slashed assets (#1433)
muharem Jul 21, 2022
4ea4992
Move alliance proposal provider to impls.rs (#1464)
muharem Jul 21, 2022
a36dc29
Bumping spec version
gilescope Jul 25, 2022
177783d
merge master
joepetrowski Aug 3, 2022
95f4d86
cargo lock
joepetrowski Aug 4, 2022
8d104b6
slurp collectives digest to make appear in release notes (#1473)
gilescope Aug 4, 2022
450e398
Merge remote-tracking branch 'origin' into joe-alliance
joepetrowski Aug 9, 2022
4194b2e
reorder barrier
joepetrowski Aug 9, 2022
01107b2
Update parachains/runtimes/collectives/collectives-polkadot/src/xcm_c…
joepetrowski Aug 9, 2022
930a76a
Merge remote-tracking branch 'origin' into joe-alliance
joepetrowski Aug 11, 2022
659ecd3
address review
joepetrowski Aug 11, 2022
f5237a9
clean construct runtime
joepetrowski Aug 11, 2022
bc62984
fmt
joepetrowski Aug 11, 2022
c22d6b6
looks pretty but brings in too much
joepetrowski Aug 11, 2022
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
Prev Previous commit
Next Next commit
add collectives to collator node
  • Loading branch information
joepetrowski committed May 23, 2022
commit 77f7d6564a0dad1a19f28edb5f6841dd453112ec
146 changes: 145 additions & 1 deletion polkadot-parachain/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
// Copyright 2019-2022 Parity Technologies (UK) Ltd.
// This file is part of Cumulus.

// Cumulus is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -235,10 +235,14 @@ pub type StatemineChainSpec =
sc_service::GenericChainSpec<statemine_runtime::GenesisConfig, Extensions>;
pub type WestmintChainSpec =
sc_service::GenericChainSpec<westmint_runtime::GenesisConfig, Extensions>;
pub type CollectivesPolkadotChainSpec =
sc_service::GenericChainSpec<collectives_polkadot_runtime::GenesisConfig, Extensions>;

const STATEMINT_ED: StatemintBalance = statemint_runtime::constants::currency::EXISTENTIAL_DEPOSIT;
const STATEMINE_ED: StatemintBalance = statemine_runtime::constants::currency::EXISTENTIAL_DEPOSIT;
const WESTMINT_ED: StatemintBalance = westmint_runtime::constants::currency::EXISTENTIAL_DEPOSIT;
const COLLECTIVES_POLKADOT_ED: StatemintBalance =
collectives_polkadot_runtime::constants::currency::EXISTENTIAL_DEPOSIT;

/// Helper function to generate a crypto pair from seed
pub fn get_public_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
Expand Down Expand Up @@ -275,6 +279,13 @@ pub fn westmint_session_keys(keys: AuraId) -> westmint_runtime::SessionKeys {
westmint_runtime::SessionKeys { aura: keys }
}

/// Generate the session keys from individual elements.
///
/// The input must be a tuple of individual keys (a single arg for now since we have just one key).
pub fn collectives_polkadot_session_keys(keys: AuraId) -> collectives_polkadot_runtime::SessionKeys {
collectives_polkadot_runtime::SessionKeys { aura: keys }
}

pub fn statemint_development_config() -> StatemintChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("ss58Format".into(), 0.into());
Expand Down Expand Up @@ -835,6 +846,139 @@ fn westmint_genesis(
}
}

pub fn collectives_polkadot_development_config() -> CollectivesPolkadotChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("ss58Format".into(), 0.into());
properties.insert("tokenSymbol".into(), "DOT".into());
properties.insert("tokenDecimals".into(), 10.into());

CollectivesPolkadotChainSpec::from_genesis(
// Name
"Polkadot Collectives Development",
// ID
"collectives_polkadot_dev",
ChainType::Local,
move || {
collectives_polkadot_genesis(
// initial collators.
vec![(
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_collator_keys_from_seed::<AuraId>("Alice"),
)],
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
],
// 1002 avoids a potential collision with Kusama-1001 (Encointer) should there ever
// be a collective para on Kusama.
1002.into(),
)
},
Vec::new(),
None,
None,
None,
Some(properties),
Extensions { relay_chain: "polkadot-dev".into(), para_id: 1002 },
)
}

pub fn collectives_polkadot_config() -> CollectivesPolkadotChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("ss58Format".into(), 0.into());
properties.insert("tokenSymbol".into(), "DOT".into());
properties.insert("tokenDecimals".into(), 10.into());

CollectivesPolkadotChainSpec::from_genesis(
// Name
"Polkadot Collectives Local",
// ID
"collectives_polkadot_local",
ChainType::Local,
move || {
collectives_polkadot_genesis(
// initial collators.
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_collator_keys_from_seed::<AuraId>("Alice"),
),
(
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_collator_keys_from_seed::<AuraId>("Bob"),
),
],
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
1002.into(),
)
},
Vec::new(),
None,
None,
None,
Some(properties),
Extensions { relay_chain: "polkadot-local".into(), para_id: 1002 },
)
}

fn collectives_polkadot_genesis(
invulnerables: Vec<(AccountId, AuraId)>,
endowed_accounts: Vec<AccountId>,
id: ParaId,
) -> collectives_polkadot_runtime::GenesisConfig {
collectives_polkadot_runtime::GenesisConfig {
system: collectives_polkadot_runtime::SystemConfig {
code: collectives_polkadot_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
.to_vec(),
},
balances: collectives_polkadot_runtime::BalancesConfig {
balances: endowed_accounts.iter().cloned().map(|k| (k, COLLECTIVES_POLKADOT_ED * 4096)).collect(),
},
parachain_info: collectives_polkadot_runtime::ParachainInfoConfig { parachain_id: id },
collator_selection: collectives_polkadot_runtime::CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: COLLECTIVES_POLKADOT_ED * 16,
..Default::default()
},
session: collectives_polkadot_runtime::SessionConfig {
keys: invulnerables
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
collectives_polkadot_session_keys(aura), // session keys
)
})
.collect(),
},
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
// of this.
aura: Default::default(),
aura_ext: Default::default(),
parachain_system: Default::default(),
polkadot_xcm: collectives_polkadot_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
},
}
}

pub type ContractsRococoChainSpec =
sc_service::GenericChainSpec<contracts_rococo_runtime::GenesisConfig, Extensions>;

Expand Down
62 changes: 60 additions & 2 deletions polkadot-parachain/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use crate::{
chain_spec,
cli::{Cli, RelayChainCli, Subcommand},
service::{
new_partial, Block, ShellRuntimeExecutor, StatemineRuntimeExecutor,
StatemintRuntimeExecutor, WestmintRuntimeExecutor,
new_partial, Block, CollectivesPolkadotRuntimeExecutor, ShellRuntimeExecutor,
StatemineRuntimeExecutor, StatemintRuntimeExecutor, WestmintRuntimeExecutor,
},
};
use codec::Encode;
Expand All @@ -46,6 +46,7 @@ trait IdentifyChain {
fn is_statemint(&self) -> bool;
fn is_statemine(&self) -> bool;
fn is_westmint(&self) -> bool;
fn is_polkadot_collectives(&self) -> bool;
fn is_contracts_rococo(&self) -> bool;
}

Expand All @@ -65,6 +66,9 @@ impl IdentifyChain for dyn sc_service::ChainSpec {
fn is_westmint(&self) -> bool {
self.id().starts_with("westmint")
}
fn is_polkadot_collectives(&self) -> bool {
self.id().starts_with("collective-polkadot")
}
fn is_contracts_rococo(&self) -> bool {
self.id().starts_with("contracts-rococo")
}
Expand All @@ -86,6 +90,9 @@ impl<T: sc_service::ChainSpec + 'static> IdentifyChain for T {
fn is_westmint(&self) -> bool {
<dyn sc_service::ChainSpec>::is_westmint(self)
}
fn is_polkadot_collectives(&self) -> bool {
<dyn sc_service::ChainSpec>::is_polkadot_collectives(self)
}
fn is_contracts_rococo(&self) -> bool {
<dyn sc_service::ChainSpec>::is_contracts_rococo(self)
}
Expand All @@ -104,6 +111,7 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, St
&include_bytes!("../../parachains/chain-specs/track.json")[..],
)?),
"shell" => Box::new(chain_spec::get_shell_chain_spec()),

// -- Statemint
"seedling" => Box::new(chain_spec::get_seedling_chain_spec()),
"statemint-dev" => Box::new(chain_spec::statemint_development_config()),
Expand All @@ -114,6 +122,7 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, St
"statemint" => Box::new(chain_spec::ChainSpec::from_json_bytes(
&include_bytes!("../../parachains/chain-specs/statemint.json")[..],
)?),

// -- Statemine
"statemine-dev" => Box::new(chain_spec::statemine_development_config()),
"statemine-local" => Box::new(chain_spec::statemine_local_config()),
Expand All @@ -123,6 +132,7 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, St
"statemine" => Box::new(chain_spec::ChainSpec::from_json_bytes(
&include_bytes!("../../parachains/chain-specs/statemine.json")[..],
)?),

// -- Westmint
"westmint-dev" => Box::new(chain_spec::westmint_development_config()),
"westmint-local" => Box::new(chain_spec::westmint_local_config()),
Expand All @@ -132,15 +142,27 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, St
"westmint" => Box::new(chain_spec::ChainSpec::from_json_bytes(
&include_bytes!("../../parachains/chain-specs/westmint.json")[..],
)?),

// -- Polkadot Collectives
"collective-polkadot-dev" => Box::new(chain_spec::collectives_polkadot_development_config()),
"collective-polkadot-local" => Box::new(chain_spec::collectives_polkadot_config()),
/* TODO:COLLECTIVES
"collective-polkadot" => Box::new(chain_spec::ChainSpec::from_json_bytes(
&include_bytes!("../../parachains/chain-specs/westmint.json")[..],
)?),
*/

// -- Contracts on Rococo
"contracts-rococo-dev" => Box::new(chain_spec::contracts_rococo_development_config()),
"contracts-rococo-local" => Box::new(chain_spec::contracts_rococo_local_config()),
"contracts-rococo-genesis" => Box::new(chain_spec::contracts_rococo_config()),
"contracts-rococo" => Box::new(chain_spec::ChainSpec::from_json_bytes(
&include_bytes!("../../parachains/chain-specs/contracts-rococo.json")[..],
)?),

// -- Fallback (generic chainspec)
"" => Box::new(chain_spec::get_chain_spec()),

// -- Loading a specific spec from disk
path => {
let chain_spec = chain_spec::ChainSpec::from_json_file(path.into())?;
Expand All @@ -150,6 +172,8 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, St
Box::new(chain_spec::StatemineChainSpec::from_json_file(path.into())?)
} else if chain_spec.is_westmint() {
Box::new(chain_spec::WestmintChainSpec::from_json_file(path.into())?)
} else if chain_spec.is_polkadot_collectives() {
Box::new(chain_spec::CollectivesPolkadotChainSpec::from_json_file(path.into())?)
} else if chain_spec.is_shell() {
Box::new(chain_spec::ShellChainSpec::from_json_file(path.into())?)
} else if chain_spec.is_seedling() {
Expand Down Expand Up @@ -205,6 +229,8 @@ impl SubstrateCli for Cli {
&statemine_runtime::VERSION
} else if chain_spec.is_westmint() {
&westmint_runtime::VERSION
} else if chain_spec.is_polkadot_collectives() {
&collectives_polkadot_runtime::VERSION
} else if chain_spec.is_shell() {
&shell_runtime::VERSION
} else if chain_spec.is_seedling() {
Expand Down Expand Up @@ -288,6 +314,12 @@ macro_rules! construct_benchmark_partials {
crate::service::statemint_build_import_queue::<_, StatemintAuraId>,
)?;
$code
} else if $config.chain_spec.is_polkadot_collectives() {
let $partials = new_partial::<collectives_polkadot_runtime::RuntimeApi, _>(
&$config,
crate::service::statemint_build_import_queue::<_, AuraId>, // TODO:COLLECTIVES Rename
)?;
$code
} else {
Err("The chain is not supported".into())
}
Expand Down Expand Up @@ -324,6 +356,15 @@ macro_rules! construct_async_run {
let task_manager = $components.task_manager;
{ $( $code )* }.map(|v| (v, task_manager))
})
} else if runner.config().chain_spec.is_polkadot_collectives() {
runner.async_run(|$config| {
let $components = new_partial::<collectives_polkadot_runtime::RuntimeApi, _>(
&$config,
crate::service::statemint_build_import_queue::<_, AuraId>, // TODO:COLLECTIVES Rename
)?;
let task_manager = $components.task_manager;
{ $( $code )* }.map(|v| (v, task_manager))
})
} else if runner.config().chain_spec.is_shell() {
runner.async_run(|$config| {
let $components = new_partial::<shell_runtime::RuntimeApi, _>(
Expand Down Expand Up @@ -479,6 +520,8 @@ pub fn run() -> Result<()> {
cmd.run::<Block, WestmintRuntimeExecutor>(config)
} else if config.chain_spec.is_statemint() {
cmd.run::<Block, StatemintRuntimeExecutor>(config)
} else if config.chain_spec.is_polkadot_collectives() {
cmd.run::<Block, CollectivesPolkadotRuntimeExecutor>(config)
} else {
Err("Chain doesn't support benchmarking".into())
}
Expand Down Expand Up @@ -525,6 +568,10 @@ pub fn run() -> Result<()> {
runner.async_run(|config| {
Ok((cmd.run::<Block, StatemintRuntimeExecutor>(config), task_manager))
})
} else if runner.config().chain_spec.is_polkadot_collectives() {
runner.async_run(|config| {
Ok((cmd.run::<Block, CollectivesPolkadotRuntimeExecutor>(config), task_manager))
})
} else if runner.config().chain_spec.is_shell() {
runner.async_run(|config| {
Ok((cmd.run::<Block, ShellRuntimeExecutor>(config), task_manager))
Expand Down Expand Up @@ -615,6 +662,17 @@ pub fn run() -> Result<()> {
.await
.map(|r| r.0)
.map_err(Into::into)
} else if config.chain_spec.is_polkadot_collectives() {
crate::service::start_statemint_node::<collectives_polkadot_runtime::RuntimeApi, AuraId>(
config,
polkadot_config,
collator_options,
id,
hwbench,
)
.await
.map(|r| r.0)
.map_err(Into::into)
} else if config.chain_spec.is_shell() {
crate::service::start_shell_node::<shell_runtime::RuntimeApi>(
config,
Expand Down
15 changes: 15 additions & 0 deletions polkadot-parachain/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,21 @@ impl sc_executor::NativeExecutionDispatch for WestmintRuntimeExecutor {
}
}

// Native Polkadot Collectives executor instance.
pub struct CollectivesPolkadotRuntimeExecutor;

impl sc_executor::NativeExecutionDispatch for CollectivesPolkadotRuntimeExecutor {
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;

fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
collectives_polkadot_runtime::api::dispatch(method, data)
}

fn native_version() -> sc_executor::NativeVersion {
collectives_polkadot_runtime::native_version()
}
}

/// Native Contracts on Rococo executor instance.
pub struct ContractsRococoRuntimeExecutor;

Expand Down