Skip to content

Commit

Permalink
Update Manta Runtime (#946)
Browse files Browse the repository at this point in the history
* wip: first compiling manta RT

Signed-off-by: Adam Reif <Garandor@manta.network>

* wip: remove service_aura since manta RT no longer uses it

Signed-off-by: Adam Reif <Garandor@manta.network>

* wip: move `from_seed_unchecked` from primitives into runtime, Manta RT has 2 keys, Calamari/Dolphin have AuraId as extra key

Signed-off-by: Adam Reif <Garandor@manta.network>

* make from_seed_unchecked std only instead

Signed-off-by: Adam Reif <Garandor@manta.network>

* Add dmp queeu and subscriptions

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* fmt

Signed-off-by: Adam Reif <Garandor@manta.network>

* Add xcm_config.rs file

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

Signed-off-by: Adam Reif <Garandor@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Co-authored-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
  • Loading branch information
Adam Reif and ghzlatarev authored Dec 29, 2022
1 parent aea95e2 commit d55f236
Show file tree
Hide file tree
Showing 27 changed files with 1,681 additions and 1,618 deletions.
52 changes: 7 additions & 45 deletions Cargo.lock

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

14 changes: 7 additions & 7 deletions node/src/chain_specs/calamari.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use calamari_runtime::{
currency::KMA, opaque::SessionKeys, CouncilConfig, DemocracyConfig, GenesisConfig,
ParachainStakingConfig, TechnicalCommitteeConfig,
};
use session_key_primitives::util::{unchecked_account_id, unchecked_collator_keys};
use session_key_primitives::util::unchecked_account_id;
/// Calamari Protocol Identifier
pub const CALAMARI_PROTOCOL_ID: &str = "calamari";

Expand Down Expand Up @@ -61,7 +61,7 @@ pub fn calamari_development_config() -> CalamariChainSpec {
calamari_dev_genesis(
vec![(
unchecked_account_id::<sr25519::Public>("Alice"),
SessionKeys::new(unchecked_collator_keys("Alice")),
SessionKeys::from_seed_unchecked("Alice"),
)],
// Delegations
vec![],
Expand Down Expand Up @@ -96,23 +96,23 @@ pub fn calamari_local_config() -> CalamariChainSpec {
vec![
(
unchecked_account_id::<sr25519::Public>("Alice"),
SessionKeys::new(unchecked_collator_keys("Alice")),
SessionKeys::from_seed_unchecked("Alice"),
),
(
unchecked_account_id::<sr25519::Public>("Bob"),
SessionKeys::new(unchecked_collator_keys("Bob")),
SessionKeys::from_seed_unchecked("Bob"),
),
(
unchecked_account_id::<sr25519::Public>("Charlie"),
SessionKeys::new(unchecked_collator_keys("Charlie")),
SessionKeys::from_seed_unchecked("Charlie"),
),
(
unchecked_account_id::<sr25519::Public>("Dave"),
SessionKeys::new(unchecked_collator_keys("Dave")),
SessionKeys::from_seed_unchecked("Dave"),
),
(
unchecked_account_id::<sr25519::Public>("Eve"),
SessionKeys::new(unchecked_collator_keys("Eve")),
SessionKeys::from_seed_unchecked("Eve"),
),
],
// Delegations
Expand Down
14 changes: 7 additions & 7 deletions node/src/chain_specs/dolphin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::command::{DOLPHIN_ON_BAIKAL_PARACHAIN_ID, DOLPHIN_PARACHAIN_ID};
use dolphin_runtime::{
opaque::SessionKeys, CouncilConfig, DemocracyConfig, GenesisConfig, TechnicalCommitteeConfig,
};
use session_key_primitives::util::{unchecked_account_id, unchecked_collator_keys};
use session_key_primitives::util::unchecked_account_id;

/// Dolphin Protocol Identifier
pub const DOLPHIN_PROTOCOL_ID: &str = "dolphin";
Expand Down Expand Up @@ -56,7 +56,7 @@ pub fn dolphin_development_config() -> DolphinChainSpec {
dolphin_dev_genesis(
vec![(
unchecked_account_id::<sr25519::Public>("Alice"),
SessionKeys::new(unchecked_collator_keys("Alice")),
SessionKeys::from_seed_unchecked("Alice"),
)],
unchecked_account_id::<sr25519::Public>("Alice"),
vec![
Expand Down Expand Up @@ -90,23 +90,23 @@ pub fn dolphin_local_config() -> DolphinChainSpec {
vec![
(
unchecked_account_id::<sr25519::Public>("Alice"),
SessionKeys::new(unchecked_collator_keys("Alice")),
SessionKeys::from_seed_unchecked("Alice"),
),
(
unchecked_account_id::<sr25519::Public>("Bob"),
SessionKeys::new(unchecked_collator_keys("Bob")),
SessionKeys::from_seed_unchecked("Bob"),
),
(
unchecked_account_id::<sr25519::Public>("Charlie"),
SessionKeys::new(unchecked_collator_keys("Charlie")),
SessionKeys::from_seed_unchecked("Charlie"),
),
(
unchecked_account_id::<sr25519::Public>("Dave"),
SessionKeys::new(unchecked_collator_keys("Dave")),
SessionKeys::from_seed_unchecked("Dave"),
),
(
unchecked_account_id::<sr25519::Public>("Eve"),
SessionKeys::new(unchecked_collator_keys("Eve")),
SessionKeys::from_seed_unchecked("Eve"),
),
],
unchecked_account_id::<sr25519::Public>("Alice"),
Expand Down
67 changes: 45 additions & 22 deletions node/src/chain_specs/manta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
use super::*;
use crate::command::MANTA_PARACHAIN_ID;
use manta_runtime::opaque::SessionKeys;
use session_key_primitives::util::{unchecked_account_id, unchecked_collator_keys};
use manta_runtime::{opaque::SessionKeys, GenesisConfig, ParachainStakingConfig};
use session_key_primitives::util::unchecked_account_id;
/// Manta Protocol Identifier
pub const MANTA_PROTOCOL_ID: &str = "manta";

Expand All @@ -35,13 +35,6 @@ pub const SAFE_XCM_VERSION: u32 = 2;
/// Manta Chain Specification
pub type MantaChainSpec = sc_service::GenericChainSpec<manta_runtime::GenesisConfig, Extensions>;

/// Generate the manta 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 manta_session_keys(keys: AuraId) -> SessionKeys {
SessionKeys { aura: keys }
}

/// Returns the [`Properties`] for the Manta parachain.
pub fn manta_properties() -> Properties {
let mut p = Properties::new();
Expand All @@ -61,9 +54,11 @@ pub fn manta_development_config() -> MantaChainSpec {
manta_dev_genesis(
vec![(
unchecked_account_id::<sr25519::Public>("Alice"),
unchecked_collator_keys("Alice").0,
SessionKeys::from_seed_unchecked("Alice"),
)],
unchecked_account_id::<sr25519::Public>("Alice"),
// Delegations
vec![],
vec![
unchecked_account_id::<sr25519::Public>("Alice"),
unchecked_account_id::<sr25519::Public>("Bob"),
Expand Down Expand Up @@ -95,14 +90,28 @@ pub fn manta_local_config() -> MantaChainSpec {
vec![
(
unchecked_account_id::<sr25519::Public>("Alice"),
unchecked_collator_keys("Alice").0,
SessionKeys::from_seed_unchecked("Alice"),
),
(
unchecked_account_id::<sr25519::Public>("Bob"),
unchecked_collator_keys("Bob").0,
SessionKeys::from_seed_unchecked("Bob"),
),
(
unchecked_account_id::<sr25519::Public>("Charlie"),
SessionKeys::from_seed_unchecked("Charlie"),
),
(
unchecked_account_id::<sr25519::Public>("Dave"),
SessionKeys::from_seed_unchecked("Dave"),
),
(
unchecked_account_id::<sr25519::Public>("Eve"),
SessionKeys::from_seed_unchecked("Eve"),
),
],
unchecked_account_id::<sr25519::Public>("Alice"),
// Delegations
vec![],
vec![
unchecked_account_id::<sr25519::Public>("Alice"),
unchecked_account_id::<sr25519::Public>("Bob"),
Expand Down Expand Up @@ -130,11 +139,12 @@ pub fn manta_local_config() -> MantaChainSpec {
}

fn manta_dev_genesis(
invulnerables: Vec<(AccountId, AuraId)>,
invulnerables: Vec<(AccountId, SessionKeys)>,
root_key: AccountId,
delegations: Vec<(AccountId, AccountId, Balance)>,
endowed_accounts: Vec<AccountId>,
) -> manta_runtime::GenesisConfig {
manta_runtime::GenesisConfig {
) -> GenesisConfig {
GenesisConfig {
system: manta_runtime::SystemConfig {
code: manta_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
Expand All @@ -157,30 +167,43 @@ fn manta_dev_genesis(
sudo: manta_runtime::SudoConfig {
key: Some(root_key),
},
parachain_staking: ParachainStakingConfig {
candidates: invulnerables
.iter()
.cloned()
.map(|(account, _)| {
(
account,
manta_runtime::staking::NORMAL_COLLATOR_MINIMUM_STAKE,
)
})
.collect(),
delegations,
inflation_config: manta_runtime::staking::inflation_config::<manta_runtime::Runtime>(),
},
parachain_info: manta_runtime::ParachainInfoConfig {
parachain_id: MANTA_PARACHAIN_ID.into(),
},
collator_selection: manta_runtime::CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: MANTA * 10000, // How many tokens will be reserved as collator
candidacy_bond: 10_000 * MANTA, // How many tokens will be reserved as collator
..Default::default()
},
session: manta_runtime::SessionConfig {
keys: invulnerables
.iter()
.cloned()
.map(|(acc, aura)| {
.map(|(acc, session_keys)| {
(
acc.clone(), // account id
acc, // validator id
manta_session_keys(aura), // session keys
acc.clone(), // account id
acc, // validator id
session_keys, // collator session keys
)
})
.collect(),
},
aura_ext: Default::default(),
parachain_system: Default::default(),
polkadot_xcm: manta_runtime::PolkadotXcmConfig {
polkadot_xcm: calamari_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
},
}
Expand Down
1 change: 0 additions & 1 deletion node/src/chain_specs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use manta_primitives::{
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::{ChainType, Properties};
use serde::{Deserialize, Serialize};
use session_key_primitives::AuraId;
use sp_core::sr25519;

pub mod calamari;
Expand Down
14 changes: 4 additions & 10 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ use crate::{
chain_specs,
cli::{Cli, RelayChainCli, Subcommand},
rpc,
service::{new_partial, CalamariRuntimeExecutor, DolphinRuntimeExecutor},
service_aura::MantaRuntimeExecutor,
service::{new_partial, CalamariRuntimeExecutor, DolphinRuntimeExecutor, MantaRuntimeExecutor},
};
use codec::Encode;
use cumulus_client_cli::generate_genesis_block;
Expand All @@ -34,7 +33,6 @@ use sc_cli::{
NetworkParams, RuntimeVersion, SharedParams, SubstrateCli,
};
use sc_service::config::{BasePath, PrometheusConfig};
use session_key_primitives::AuraId;
use sp_core::hexdisplay::HexDisplay;
use sp_runtime::{
generic,
Expand Down Expand Up @@ -223,10 +221,7 @@ impl SubstrateCli for RelayChainCli {
macro_rules! construct_benchmark_partials {
($config:expr, |$partials:ident| $code:expr) => {
if $config.chain_spec.is_manta() {
let $partials = crate::service_aura::new_partial::<manta_runtime::RuntimeApi, _>(
&$config,
crate::service_aura::parachain_build_import_queue::<_, AuraId>,
)?;
let $partials = new_partial::<manta_runtime::RuntimeApi>(&$config)?;
$code
} else if $config.chain_spec.is_calamari() {
let $partials = new_partial::<calamari_runtime::RuntimeApi>(&$config)?;
Expand All @@ -245,9 +240,8 @@ macro_rules! construct_async_run {
let runner = $cli.create_runner($cmd)?;
if runner.config().chain_spec.is_manta() {
runner.async_run(|$config| {
let $components = crate::service_aura::new_partial::<manta_runtime::RuntimeApi, _>(
let $components = crate::service::new_partial::<manta_runtime::RuntimeApi>(
&$config,
crate::service_aura::parachain_build_import_queue::<_, AuraId>,
)?;
let task_manager = $components.task_manager;
{ $( $code )* }.map(|v| (v, task_manager))
Expand Down Expand Up @@ -471,7 +465,7 @@ pub fn run_with(cli: Cli) -> Result {
);

if config.chain_spec.is_manta() {
crate::service_aura::start_parachain_node::<manta_runtime::RuntimeApi, AuraId, _>(
crate::service::start_parachain_node::<manta_runtime::RuntimeApi, _>(
config,
polkadot_config,
collator_options,
Expand Down
1 change: 0 additions & 1 deletion node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ pub mod client;
pub mod command;
pub mod rpc;
pub mod service;
pub mod service_aura;
Loading

0 comments on commit d55f236

Please sign in to comment.