Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Commit

Permalink
Substrate Updates (#604)
Browse files Browse the repository at this point in the history
* anchor `s2s` & `cargo update`

* companion for #substrate-8125

* companion for #substrate-8087 part.2

* companion for #substrate-8435, 8454

* `cargo update`

* companion for #substrate-8496

* companion for #substrate-8170

* companion for #substrate-8458

* companion for #substrate-8447

* companion for #substrate-8463

* companion for #substrate-8456

* remove migration

* companion for #substrate-8502

* companion for #substrate-8491

* anchor `darwinia-v0.11.0`

* companion for #substrate-8555 part.1

* companion for #substrate-8541

* companion for #substrate-8477

* companion for #substrate-8571

* companion for #substrate-8589

* companion for #substrate-8587

* companion for #substrate-8317

* companion for #substrate-8556

* some fixes

* companion for #substrate-8596

* companion for #substrate-8173 part.2 cc @AsceticBear

* companion for #substrate-8596

* some fixes

* companion for #substrate-8628

* companion for #substrate-8643

* companion for #substrate-8676

* some fixes

* companion for #substrate-8628 part.2

* remove unused dependencies

* update to v2.3.0

* companion for #substrate-8044

* companion for #substrate-8653

* companion for #substrate-8665

* add migration

* update try-runtime

* correct `pre_migration`

* companion for #polkadot-2765

* correct prefix

* remove unused migration

* cherry pick from `f92b521`

* reset Pangolin

Co-authored-by: bear <[email protected]>
  • Loading branch information
aurexav and bear authored May 12, 2021
1 parent f92b521 commit 4e2a5df
Show file tree
Hide file tree
Showing 126 changed files with 3,489 additions and 2,530 deletions.
1,094 changes: 546 additions & 548 deletions Cargo.lock

Large diffs are not rendered by default.

93 changes: 47 additions & 46 deletions bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "GPL-3.0"
name = "drml"
readme = "README.md"
repository = "https://github.com/darwinia-network/darwinia-common/"
version = "2.2.0"
version = "2.3.0"

# TODO: Consider rename this repo to darwinia-runtime-module-library
[[bin]]
Expand All @@ -22,6 +22,7 @@ futures = { version = "0.3.13" }
jsonrpc-core = { version = "15.1.0" }
jsonrpc-pubsub = { version = "15.1.0" }
log = { version = "0.4.14" }
rand = { version = "0.8.3" }
structopt = { version = "0.3.21" }
tokio = { version = "0.3.6", optional = true, features = ["rt-multi-thread"] }
# darwinia
Expand All @@ -46,54 +47,54 @@ dvm-ethereum = { path = "../../../frame/dvm" }
dvm-rpc-runtime-api = { path = "../../../frame/dvm/rpc/runtime-api" }
pangolin-runtime = { path = "../runtime/pangolin" }
# substrate
frame-system-rpc-runtime-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
pallet-im-online = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
pallet-transaction-payment-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sc-authority-discovery = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sc-basic-authorship = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sc-chain-spec = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sc-cli = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sc-client-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sc-consensus = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sc-consensus-babe = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sc-consensus-babe-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sc-consensus-epochs = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sc-consensus-slots = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sc-executor = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sc-finality-grandpa = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sc-finality-grandpa-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sc-finality-grandpa-warp-sync = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sc-keystore = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sc-network = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sc-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sc-service = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sc-sync-state-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sc-telemetry = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sc-transaction-pool = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sp-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sp-authority-discovery = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sp-block-builder = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sp-blockchain = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sp-consensus = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sp-consensus-babe = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sp-finality-grandpa = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sp-inherents = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sp-keystore = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sp-offchain = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sp-runtime = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sp-session = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sp-transaction-pool = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
sp-trie = { features = ["memory-tracker"], git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
substrate-frame-rpc-system = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
substrate-prometheus-endpoint = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
try-runtime-cli = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
frame-system-rpc-runtime-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
pallet-im-online = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
pallet-transaction-payment-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sc-authority-discovery = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sc-basic-authorship = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sc-chain-spec = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sc-cli = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sc-client-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sc-consensus = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sc-consensus-babe = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sc-consensus-babe-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sc-consensus-epochs = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sc-consensus-slots = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sc-executor = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sc-finality-grandpa = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sc-finality-grandpa-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sc-finality-grandpa-warp-sync = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sc-keystore = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sc-network = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sc-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sc-service = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sc-sync-state-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sc-telemetry = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sc-transaction-pool = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sp-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sp-authority-discovery = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sp-block-builder = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sp-blockchain = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sp-consensus = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sp-consensus-babe = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sp-finality-grandpa = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sp-inherents = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sp-keystore = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sp-offchain = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sp-runtime = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sp-session = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sp-transaction-pool = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
sp-trie = { features = ["memory-tracker"], git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
substrate-frame-rpc-system = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
substrate-prometheus-endpoint = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
try-runtime-cli = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }

[build-dependencies]
# substrate
substrate-build-script-utils = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
try-runtime-cli = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.10.0" }
substrate-build-script-utils = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }
try-runtime-cli = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.0" }

[features]
default = [
Expand Down
50 changes: 38 additions & 12 deletions bin/node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

// --- std ---
use std::{collections::BTreeMap, marker::PhantomData};
// --- crates ---
use rand::{seq::SliceRandom, Rng};
// --- substrate ---
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use sc_service::{ChainType, Properties};
Expand Down Expand Up @@ -224,6 +226,7 @@ fn pangolin_build_spec_genesis() -> pangolin_runtime::GenesisConfig {
"0x1ed7de3855ffcce134d718b570febb49bbbbeb32ebbc8c319f44fb9f5690643a",
),
];
let initial_nominators = <Vec<AccountId>>::new();
let collective_members = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];
let evm_accounts = {
let mut map = BTreeMap::new();
Expand Down Expand Up @@ -252,7 +255,7 @@ fn pangolin_build_spec_genesis() -> pangolin_runtime::GenesisConfig {
authorities: vec![],
epoch_config: Some(pangolin_runtime::BABE_GENESIS_EPOCH_CONFIG)
},
darwinia_balances_Instance0: pangolin_runtime::BalancesConfig {
darwinia_balances_Instance1: pangolin_runtime::BalancesConfig {
balances: vec![
(root.clone(), BUNCH_OF_COINS),
(get_account_id_from_seed::<sr25519::Public>("Alice"), A_FEW_COINS),
Expand All @@ -263,21 +266,31 @@ fn pangolin_build_spec_genesis() -> pangolin_runtime::GenesisConfig {
.iter()
.map(|Keys { stash, .. }| (stash.to_owned(), A_FEW_COINS)),
)
.chain(
initial_nominators
.iter()
.map(|n| (n.to_owned(), A_FEW_COINS))
)
.chain(
TEAM_MEMBERS
.iter()
.map(|m| (array_bytes::hex2array_unchecked!(m, 32).into(), MANY_COINS)),
)
.collect()
},
darwinia_balances_Instance1: pangolin_runtime::KtonConfig {
darwinia_balances_Instance2: pangolin_runtime::KtonConfig {
balances: vec![(root.clone(), BUNCH_OF_COINS)]
.into_iter()
.chain(
initial_authorities
.iter()
.map(|Keys { stash, .. }| (stash.to_owned(), A_FEW_COINS)),
)
.chain(
initial_nominators
.iter()
.map(|n| (n.to_owned(), A_FEW_COINS))
)
.chain(
TEAM_MEMBERS
.iter()
Expand All @@ -296,6 +309,19 @@ fn pangolin_build_spec_genesis() -> pangolin_runtime::GenesisConfig {
A_FEW_COINS,
pangolin_runtime::StakerStatus::Validator
))
.chain(initial_nominators.iter().map(|n| {
let mut rng = rand::thread_rng();
let limit = (pangolin_runtime::MAX_NOMINATIONS as usize).min(initial_authorities.len());
let count = rng.gen::<usize>() % limit;
let nominations = initial_authorities
.as_slice()
.choose_multiple(&mut rng, count)
.into_iter()
.map(|c| c.stash.clone())
.collect::<Vec<_>>();

(n.clone(), n.clone(), A_FEW_COINS, pangolin_runtime::StakerStatus::Nominator(nominations))
}))
.collect(),
slash_reward_fraction: Perbill::from_percent(10),
payout_fraction: Perbill::from_percent(50),
Expand All @@ -315,16 +341,16 @@ fn pangolin_build_spec_genesis() -> pangolin_runtime::GenesisConfig {
pallet_im_online: Default::default(),
pallet_authority_discovery: Default::default(),
darwinia_democracy: Default::default(),
pallet_collective_Instance0: pangolin_runtime::CouncilConfig {
pallet_collective_Instance1: pangolin_runtime::CouncilConfig {
phantom: PhantomData::<pangolin_runtime::CouncilCollective>,
members: collective_members.clone(),
},
pallet_collective_Instance1: pangolin_runtime::TechnicalCommitteeConfig {
pallet_collective_Instance2: pangolin_runtime::TechnicalCommitteeConfig {
phantom: PhantomData::<pangolin_runtime::TechnicalCollective>,
members: collective_members
},
darwinia_elections_phragmen: Default::default(),
pallet_membership_Instance0: Default::default(),
pallet_membership_Instance1: Default::default(),
darwinia_claims: Default::default(),
darwinia_vesting: Default::default(),
pallet_sudo: pangolin_runtime::SudoConfig { key: root.clone() },
Expand Down Expand Up @@ -354,7 +380,7 @@ fn pangolin_build_spec_genesis() -> pangolin_runtime::GenesisConfig {
mapping_factory_address: array_bytes::hex2array_unchecked!(MAPPING_FACTORY_ADDRESS, 20).into(),
ethereum_backing_address: array_bytes::hex2array_unchecked!(ETHEREUM_BACKING_ADDRESS, 20).into(),
},
darwinia_relay_authorities_Instance0: pangolin_runtime::EthereumRelayAuthoritiesConfig {
darwinia_relay_authorities_Instance1: pangolin_runtime::EthereumRelayAuthoritiesConfig {
authorities: vec![(
get_account_id_from_seed::<sr25519::Public>("Alice"),
array_bytes::hex2array_unchecked!(ETHEREUM_RELAY_AUTHORITY_SIGNER, 20).into(),
Expand Down Expand Up @@ -428,14 +454,14 @@ fn pangolin_development_genesis() -> pangolin_runtime::GenesisConfig {
authorities: vec![],
epoch_config: Some(pangolin_runtime::BABE_GENESIS_EPOCH_CONFIG)
},
darwinia_balances_Instance0: pangolin_runtime::BalancesConfig {
darwinia_balances_Instance1: pangolin_runtime::BalancesConfig {
balances: endowed_accounts
.clone()
.into_iter()
.map(|a| (a, MANY_COINS))
.collect()
},
darwinia_balances_Instance1: pangolin_runtime::KtonConfig {
darwinia_balances_Instance2: pangolin_runtime::KtonConfig {
balances: endowed_accounts
.clone()
.into_iter()
Expand Down Expand Up @@ -467,16 +493,16 @@ fn pangolin_development_genesis() -> pangolin_runtime::GenesisConfig {
pallet_im_online: Default::default(),
pallet_authority_discovery: Default::default(),
darwinia_democracy: Default::default(),
pallet_collective_Instance0: pangolin_runtime::CouncilConfig {
pallet_collective_Instance1: pangolin_runtime::CouncilConfig {
phantom: PhantomData::<pangolin_runtime::CouncilCollective>,
members: collective_members.clone(),
},
pallet_collective_Instance1: pangolin_runtime::TechnicalCommitteeConfig {
pallet_collective_Instance2: pangolin_runtime::TechnicalCommitteeConfig {
phantom: PhantomData::<pangolin_runtime::TechnicalCollective>,
members: collective_members
},
darwinia_elections_phragmen: Default::default(),
pallet_membership_Instance0: Default::default(),
pallet_membership_Instance1: Default::default(),
darwinia_claims: pangolin_runtime::ClaimsConfig {
claims_list: ClaimsList::from_file(
"bin/res/claims-list.json",
Expand Down Expand Up @@ -511,7 +537,7 @@ fn pangolin_development_genesis() -> pangolin_runtime::GenesisConfig {
mapping_factory_address: array_bytes::hex2array_unchecked!(MAPPING_FACTORY_ADDRESS, 20).into(),
ethereum_backing_address: array_bytes::hex2array_unchecked!(ETHEREUM_BACKING_ADDRESS, 20).into(),
},
darwinia_relay_authorities_Instance0: pangolin_runtime::EthereumRelayAuthoritiesConfig {
darwinia_relay_authorities_Instance1: pangolin_runtime::EthereumRelayAuthoritiesConfig {
authorities: vec![(
get_account_id_from_seed::<sr25519::Public>("Alice"),
array_bytes::hex2array_unchecked!(ETHEREUM_RELAY_AUTHORITY_SIGNER, 20).into(),
Expand Down
Loading

0 comments on commit 4e2a5df

Please sign in to comment.