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

Manta shell chain runtime #250

Merged
merged 15 commits into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions .github/workflows/check_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ name: Check Build
# yamllint disable-line rule:truthy
on:
pull_request:
branches: [manta-pc]
branches: [manta]
push:
branches: [manta-pc]
branches: [manta]

env:
AWS_REGION: us-east-1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/check_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ name: Run Tests
# yamllint disable-line rule:truthy
on:
pull_request:
branches: [manta-pc]
branches: [manta]
push:
branches: [manta-pc]
branches: [manta]

env:
AWS_REGION: us-east-1
Expand Down
217 changes: 92 additions & 125 deletions .github/workflows/publish-draft-releases.yml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
### Features

### Improvements
- [\#250](https://github.com/Manta-Network/Manta/pull/250) Manta initial release
- [\#242](https://github.com/Manta-Network/Manta/pull/242) Update upstream dependencies to `0.9.12`. Various XCM safeguards. Bump runtime version to 5
- [\#244](https://github.com/Manta-Network/Manta/pull/244) Align benchmarking work flow with polkadot/kusama
- [\#245](https://github.com/Manta-Network/Manta/pull/245) Unify manta and calamari client.
Expand Down
16 changes: 0 additions & 16 deletions Cargo.lock

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

95 changes: 95 additions & 0 deletions genesis/manta-genesis.json

Large diffs are not rendered by default.

89 changes: 89 additions & 0 deletions genesis/manta-testnet-genesis.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion node/src/chain_specs/calamari.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub fn calamari_session_keys(keys: AuraId) -> calamari_runtime::opaque::SessionK
pub fn calamari_properties() -> Properties {
let mut p = Properties::new();
p.insert("ss58format".into(), constants::CALAMARI_SS58PREFIX.into());
p.insert("tokenDecimals".into(), constants::MANTA_DECIMAL.into());
p.insert("tokenDecimals".into(), constants::CALAMARI_DECIMAL.into());
p.insert(
"tokenSymbol".into(),
constants::CALAMARI_TOKEN_SYMBOL.into(),
Expand Down
132 changes: 15 additions & 117 deletions node/src/chain_specs/manta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use super::*;

pub type MantaChainSpec = sc_service::GenericChainSpec<manta_runtime::GenesisConfig, Extensions>;

const MANTAPC_PROTOCOL_ID: &str = "manta"; // for p2p network configuration
const MANTA_PROTOCOL_ID: &str = "manta"; // for p2p network configuration
const POLKADOT_RELAYCHAIN_LOCAL_NET: &str = "polkadot-local";
const POLKADOT_RELAYCHAIN_DEV_NET: &str = "polkadot-dev";
#[allow(dead_code)]
Expand All @@ -34,7 +34,7 @@ pub fn manta_session_keys(keys: AuraId) -> manta_runtime::opaque::SessionKeys {
/// Token
pub fn manta_properties() -> Properties {
let mut p = Properties::new();
p.insert("ss58format".into(), constants::MANTAPC_SS58PREFIX.into());
p.insert("ss58format".into(), constants::MANTA_SS58PREFIX.into());
p.insert("tokenDecimals".into(), constants::MANTA_DECIMAL.into());
p.insert("tokenSymbol".into(), constants::MANTA_TOKEN_SYMBOL.into());
p
Expand Down Expand Up @@ -69,7 +69,7 @@ pub fn manta_development_config(id: ParaId) -> MantaChainSpec {
},
vec![],
None,
Some(MANTAPC_PROTOCOL_ID),
Some(MANTA_PROTOCOL_ID),
Some(properties),
Extensions {
relay_chain: POLKADOT_RELAYCHAIN_DEV_NET.into(),
Expand Down Expand Up @@ -118,7 +118,7 @@ pub fn manta_local_config(id: ParaId) -> MantaChainSpec {
},
vec![],
None,
Some(MANTAPC_PROTOCOL_ID),
Some(MANTA_PROTOCOL_ID),
Some(properties),
Extensions {
relay_chain: POLKADOT_RELAYCHAIN_LOCAL_NET.into(),
Expand Down Expand Up @@ -158,7 +158,7 @@ fn manta_dev_genesis(
parachain_info: manta_runtime::ParachainInfoConfig { parachain_id: id },
collator_selection: manta_runtime::CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: MA * 1000, // How many tokens will be reserved as collator
candidacy_bond: MANTA * 10000, // How many tokens will be reserved as collator
..Default::default()
},
session: manta_runtime::SessionConfig {
Expand All @@ -179,118 +179,16 @@ fn manta_dev_genesis(
}
}

pub fn manta_testnet_config(id: ParaId) -> MantaChainSpec {
let properties = manta_properties();

// (controller_account, aura_id)
let initial_authorities: Vec<(AccountId, AuraId)> = vec![
(
// account id: dfcAcdrGMvrhhuVnqsXsCi53rGp9JWzyczHdRxn9THe8TiNNt
hex!["f853f56e9bdec8841c71251dc7c0e4d5160919df9c309907a1d7ab61b35bf530"].into(),
hex!["56bea77a6396efe47022814f7e34d5e8bae80dc89ba28fca9e413e14709b6002"]
.unchecked_into(),
),
(
// account id: dfY7Mi9craRmPdMaW8dNYp7Hj9fc8eP1Ti4hvF5ELsdLk36oN
hex!["44e70b3104b2a6d8140fe0044e1432be8442206e7190a7edd10fa92d365ceb30"].into(),
hex!["fe5329b7da9f11ce5d0ad8a449b197b4f5ca587ebf5a36841d4ca6dfbd2cf951"]
.unchecked_into(),
),
(
// account id: dfXk5vAbd5JyqB7XL5HvooReGxA4QdXZiuS4rPhmSs2NBL4z9
hex!["34adba14c165d5a968dc9e19ec7268c46df418e00a6e4b730a55aa1d58dcce4a"].into(),
hex!["c06f516066d3c99edbffdc55841107d3518830e0080c979f454f06b53c359645"]
.unchecked_into(),
),
(
// account id: dfZY9gDWqu3eunq3feCetwXppVUapUk6tJbPmrQBgUfB2JTzr
hex!["840be78d2675c54f026fd807d2d0da145cf2577689b21cdcfe1a6680c83f9710"].into(),
hex!["d86fc37d2bcfbcbae99eceb6255a5e063f49e9a90d0ea385343dd8805e5bc533"]
.unchecked_into(),
),
(
// account id: dfWnpKTX74uCZrWxPbNUWprLsDTJkdr69kwH3Kan8PFEEV4Go
hex!["0a86b87ebd460a526e5d15f80586f9e0f07310ce6d364bcfe8befba3e742e822"].into(),
hex!["b08921fb75be024361b8fe8291a5f4368b0db136e08b932fa5c769ff5e704912"]
.unchecked_into(),
),
];

// root accout: dfYKP4VdPHmSfNU3gCwb1FXqEZrnkw2fKGfQkh6JT4b2z8X4N
let root_key: AccountId =
hex!["4e128922a811d874f91c219aaa597ee3bd73bcb22910b3b1c57d297b9175336e"].into();

MantaChainSpec::from_genesis(
// Name
"Manta Parachain Testnet",
// ID
"manta_testnet",
ChainType::Local,
move || manta_testnet_genesis(initial_authorities.clone(), root_key.clone(), id),
vec![],
Some(
sc_telemetry::TelemetryEndpoints::new(vec![(STAGING_TELEMETRY_URL.to_string(), 0)])
.expect("Manta testnet telemetry url is valid; qed"),
),
Some(MANTAPC_PROTOCOL_ID),
Some(properties),
Extensions {
relay_chain: POLKADOT_RELAYCHAIN_DEV_NET.into(),
para_id: id.into(),
},
)
pub fn manta_testnet_config(id: ParaId) -> Result<MantaChainSpec, String> {
let mut spec = MantaChainSpec::from_json_bytes(
&include_bytes!("../../../genesis/manta-testnet-genesis.json")[..],
)?;
spec.extensions_mut().para_id = id.into();
Ok(spec)
}

fn manta_testnet_genesis(
initial_authorities: Vec<(AccountId, AuraId)>,
root_key: AccountId,
id: ParaId,
) -> manta_runtime::GenesisConfig {
let mut initial_balances: Vec<(AccountId, Balance)> = initial_authorities
.iter()
.cloned()
.map(|x| (x.0, MANTA_ENDOWMENT))
.collect();
initial_balances.push((root_key.clone(), 500_000_000 * MA));

manta_runtime::GenesisConfig {
system: manta_runtime::SystemConfig {
code: manta_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
.to_vec(),
changes_trie_config: Default::default(),
},
balances: manta_runtime::BalancesConfig {
balances: initial_balances,
},
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
// of this.
aura: Default::default(),
sudo: manta_runtime::SudoConfig { key: root_key },
parachain_info: manta_runtime::ParachainInfoConfig { parachain_id: id },
collator_selection: manta_runtime::CollatorSelectionConfig {
invulnerables: initial_authorities
.iter()
.cloned()
.map(|(acc, _)| acc)
.collect(),
candidacy_bond: MA * 1000, // How many tokens will be reserved as collator
..Default::default()
},
session: manta_runtime::SessionConfig {
keys: initial_authorities
.iter()
.cloned()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
manta_session_keys(aura), // session keys
)
})
.collect(),
},
aura_ext: Default::default(),
parachain_system: Default::default(),
}
pub fn manta_config() -> Result<MantaChainSpec, String> {
MantaChainSpec::from_json_bytes(
&include_bytes!("../../../genesis/manta-genesis.json")[..],
)
}
4 changes: 2 additions & 2 deletions node/src/chain_specs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ pub use self::calamari::*;
pub use calamari_runtime::currency::KMA;
pub mod manta;
pub use self::manta::*;
pub use manta_runtime::currency::MA;
pub use manta_runtime::currency::MANTA;

const CALAMARI_ENDOWMENT: Balance = 1_000_000_000 * KMA; // 10 endowment so that total supply is 10B

const MANTA_ENDOWMENT: Balance = 1_000_000_000 * MA; // 10 endowment so that total supply is 10B
const MANTA_ENDOWMENT: Balance = 100_000_000 * MANTA; // 10 endowment so that total supply is 1B

const STAGING_TELEMETRY_URL: &str = "wss://api.telemetry.manta.systems/submit/";

Expand Down
41 changes: 32 additions & 9 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ use std::{io::Write, net::SocketAddr};

pub type Block = generic::Block<Header, OpaqueExtrinsic>;

// TODO: add Manta parachain ID if available
pub const PARACHAIN_ID: u32 = 2084;
pub const MANTA_PARACHAIN_ID: u32 = 2015;
pub const CALAMARI_PARACHAIN_ID: u32 = 2084;

trait IdentifyChain {
fn is_manta(&self) -> bool;
Expand Down Expand Up @@ -71,19 +71,24 @@ fn load_spec(
// manta chainspec
"manta-dev" => Ok(Box::new(chain_specs::manta_development_config(para_id))),
"manta-local" => Ok(Box::new(chain_specs::manta_local_config(para_id))),
"manta-testnet" => Ok(Box::new(chain_specs::manta_testnet_config(para_id))),
"manta-testnet" => Ok(Box::new(chain_specs::manta_testnet_config(para_id)?)),
"manta" => Ok(Box::new(chain_specs::manta_config()?)),
// calamari chainspec
"calamari-dev" => Ok(Box::new(chain_specs::calamari_development_config(para_id))),
"calamari-local" => Ok(Box::new(chain_specs::calamari_local_config(para_id))),
"calamari-testnet" => Ok(Box::new(chain_specs::calamari_testnet_config(para_id)?)),
"calamari-testnet-ci" => Ok(Box::new(chain_specs::calamari_testnet_ci_config()?)),
"calamari" | "" => Ok(Box::new(chain_specs::calamari_config()?)),
"calamari" => Ok(Box::new(chain_specs::calamari_config()?)),
path => {
let chain_spec = chain_specs::ChainSpec::from_json_file(path.into())?;
if chain_spec.is_manta() {
Ok(Box::new(chain_specs::MantaChainSpec::from_json_file(path.into())?))
Ok(Box::new(chain_specs::MantaChainSpec::from_json_file(
path.into(),
)?))
} else if chain_spec.is_calamari() {
Ok(Box::new(chain_specs::CalamariChainSpec::from_json_file(path.into())?))
Ok(Box::new(chain_specs::CalamariChainSpec::from_json_file(
path.into(),
)?))
} else {
Err("Please input a file name starting with manta or calamari.".into())
}
Expand Down Expand Up @@ -123,7 +128,20 @@ impl SubstrateCli for Cli {
}

fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
load_spec(id, self.run.parachain_id.unwrap_or(PARACHAIN_ID).into())
if id.starts_with("manta") {
load_spec(
id,
self.run.parachain_id.unwrap_or(MANTA_PARACHAIN_ID).into(),
)
} else {
load_spec(
id,
self.run
.parachain_id
.unwrap_or(CALAMARI_PARACHAIN_ID)
.into(),
)
}
}

fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
Expand Down Expand Up @@ -273,7 +291,7 @@ pub fn run() -> Result<()> {

let block: Block = generate_genesis_block(&load_spec(
&params.chain.clone().unwrap_or_default(),
params.parachain_id.unwrap_or(PARACHAIN_ID).into(),
params.parachain_id.unwrap_or(MANTA_PARACHAIN_ID).into(),
)?)?;
let raw_header = block.header().encode();
let output_buf = if params.raw {
Expand Down Expand Up @@ -340,7 +358,12 @@ pub fn run() -> Result<()> {
.chain(cli.relaychain_args.iter()),
);

let id = ParaId::from(cli.run.parachain_id.or(para_id).unwrap_or(PARACHAIN_ID));
let id = ParaId::from(
cli.run
.parachain_id
.or(para_id)
.unwrap_or(MANTA_PARACHAIN_ID),
);

let parachain_account =
AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(&id);
Expand Down
Loading