Skip to content

Commit

Permalink
Merge pull request #23 from OAK-Foundation/irsal-parachain-refactor
Browse files Browse the repository at this point in the history
Update to polkadot-v0.9.10 & some directory changes
  • Loading branch information
irsal authored Nov 3, 2021
2 parents 5295256 + 7f34cdb commit bdf71f2
Show file tree
Hide file tree
Showing 43 changed files with 3,509 additions and 2,519 deletions.
425 changes: 425 additions & 0 deletions .vscode/launch.json

Large diffs are not rendered by default.

2,202 changes: 1,271 additions & 931 deletions Cargo.lock

Large diffs are not rendered by default.

66 changes: 64 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,71 @@
panic = "unwind"

[workspace]
resolver = "2"

members = [
"node/cli",
"node/executor",
"node/runtime",
"runtime",
"pallets/*",
]

# The list of dependencies below (which can be both direct and indirect dependencies) are crates
# that are suspected to be CPU-intensive, and that are unlikely to require debugging (as some of
# their debug info might be missing) or to require to be frequently recompiled. We compile these
# dependencies with `opt-level=3` even in "dev" mode in order to make "dev" mode more usable.
# The majority of these crates are cryptographic libraries.
#
# Note that this does **not** affect crates that depend on Substrate. In other words, if you add
# a dependency on Substrate, you have to copy-paste this list in your own `Cargo.toml` (assuming
# that you want the same list). This list is only relevant when running `cargo build` from within
# the Substrate workspace.
#
# If you see an error mentioning "profile package spec ... did not match any packages", it
# probably concerns this list.
#
# This list is ordered alphabetically.
[profile.dev.package]
blake2 = { opt-level = 3 }
blake2-rfc = { opt-level = 3 }
blake2b_simd = { opt-level = 3 }
chacha20poly1305 = { opt-level = 3 }
cranelift-codegen = { opt-level = 3 }
cranelift-wasm = { opt-level = 3 }
crc32fast = { opt-level = 3 }
crossbeam-deque = { opt-level = 3 }
crossbeam-queue = { opt-level = 3 }
crypto-mac = { opt-level = 3 }
curve25519-dalek = { opt-level = 3 }
ed25519-dalek = { opt-level = 3 }
flate2 = { opt-level = 3 }
futures-channel = { opt-level = 3 }
hashbrown = { opt-level = 3 }
h2 = { opt-level = 3 }
hash-db = { opt-level = 3 }
hmac = { opt-level = 3 }
httparse = { opt-level = 3 }
integer-sqrt = { opt-level = 3 }
keccak = { opt-level = 3 }
libm = { opt-level = 3 }
librocksdb-sys = { opt-level = 3 }
libsecp256k1 = { opt-level = 3 }
libz-sys = { opt-level = 3 }
mio = { opt-level = 3 }
nalgebra = { opt-level = 3 }
num-bigint = { opt-level = 3 }
parking_lot = { opt-level = 3 }
parking_lot_core = { opt-level = 3 }
percent-encoding = { opt-level = 3 }
primitive-types = { opt-level = 3 }
ring = { opt-level = 3 }
rustls = { opt-level = 3 }
sha2 = { opt-level = 3 }
sha3 = { opt-level = 3 }
smallvec = { opt-level = 3 }
snow = { opt-level = 3 }
twox-hash = { opt-level = 3 }
uint = { opt-level = 3 }
wasmi = { opt-level = 3 }
x25519-dalek = { opt-level = 3 }
yamux = { opt-level = 3 }
zeroize = { opt-level = 3 }
153 changes: 82 additions & 71 deletions node/cli/Cargo.toml

Large diffs are not rendered by default.

139 changes: 0 additions & 139 deletions node/cli/res/flaming-fir.json

This file was deleted.

20 changes: 20 additions & 0 deletions node/cli/src/chain_spec/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// This file is part of OAK.

// Copyright (C) 2018-2021 OAK Network
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

pub mod oak_testnet;
pub mod turing;
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ use sc_chain_spec::ChainSpecExtension;
use sp_core::{Pair, Public, crypto::UncheckedInto, sr25519};
use serde::{Serialize, Deserialize};
use node_runtime::{
AuthorityDiscoveryConfig, BabeConfig, BalancesConfig, ContractsConfig, CouncilConfig,
DemocracyConfig, GrandpaConfig, ImOnlineConfig, SessionConfig, SessionKeys, StakerStatus,
AccountId, AuthorityDiscoveryConfig, BabeConfig, BalancesConfig, /*ContractsConfig, */CouncilConfig,
DemocracyConfig, GenesisConfig, GrandpaConfig, ImOnlineConfig, SessionConfig, SessionKeys, StakerStatus,
StakingConfig, ElectionsConfig, IndicesConfig, SocietyConfig, SudoConfig, SystemConfig,
TechnicalCommitteeConfig, QuadraticFundingConfig, wasm_binary_unwrap, MAX_NOMINATIONS,
};
Expand All @@ -37,12 +37,10 @@ use sp_consensus_babe::{AuthorityId as BabeId};
use pallet_im_online::sr25519::{AuthorityId as ImOnlineId};
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_runtime::{Perbill, traits::{Verify, IdentifyAccount}};
pub use node_primitives::{Balance, Signature};
use serde_json::json;

pub use node_primitives::{AccountId, Balance, Signature};
pub use node_runtime::GenesisConfig;

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

const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";

Expand All @@ -57,21 +55,19 @@ pub struct Extensions {
pub fork_blocks: sc_client_api::ForkBlocks<Block>,
/// Known bad block hashes.
pub bad_blocks: sc_client_api::BadBlocks<Block>,
/// The light sync state extension used by the sync-state rpc.
pub light_sync_state: sc_sync_state_rpc::LightSyncStateExtension,
}

/// Specialized `ChainSpec`.
pub type ChainSpec = sc_service::GenericChainSpec<
GenesisConfig,
Extensions,
>;
/// Flaming Fir testnet generator
pub fn flaming_fir_config() -> Result<ChainSpec, String> {
ChainSpec::from_json_bytes(&include_bytes!("../res/flaming-fir.json")[..])
}

/// Generate a json file as configuration template, which is called staging in Polkadot
pub fn oak_testnet_config() -> Result<ChainSpec, String> {
ChainSpec::from_json_bytes(&include_bytes!("../res/oak-testnet.json")[..])
ChainSpec::from_json_bytes(&include_bytes!("../../res/oak-testnet.json")[..])
}

fn session_keys(
Expand Down Expand Up @@ -207,7 +203,7 @@ pub fn testnet_genesis(
initial_nominators: Vec<AccountId>,
root_key: AccountId,
endowed_accounts: Option<Vec<AccountId>>,
enable_println: bool,
_enable_println: bool,
) -> GenesisConfig {
let mut endowed_accounts: Vec<AccountId> = endowed_accounts.unwrap_or_else(|| {
vec![
Expand Down Expand Up @@ -257,19 +253,19 @@ pub fn testnet_genesis(
const STASH: Balance = ENDOWMENT / 1000;

GenesisConfig {
frame_system: SystemConfig {
system: SystemConfig {
code: wasm_binary_unwrap().to_vec(),
changes_trie_config: Default::default(),
},
pallet_balances: BalancesConfig {
balances: BalancesConfig {
balances: endowed_accounts.iter().cloned()
.map(|x| (x, ENDOWMENT))
.collect()
},
pallet_indices: IndicesConfig {
indices: IndicesConfig {
indices: vec![],
},
pallet_session: SessionConfig {
session: SessionConfig {
keys: initial_authorities.iter().map(|x| {
(x.0.clone(), x.0.clone(), session_keys(
x.2.clone(),
Expand All @@ -279,68 +275,69 @@ pub fn testnet_genesis(
))
}).collect::<Vec<_>>(),
},
pallet_staking: StakingConfig {
staking: StakingConfig {
validator_count: 12,
minimum_validator_count: initial_authorities.len() as u32,
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
slash_reward_fraction: Perbill::from_percent(10),
stakers,
.. Default::default()
},
pallet_democracy: DemocracyConfig::default(),
pallet_elections_phragmen: ElectionsConfig {
democracy: DemocracyConfig::default(),
elections: ElectionsConfig {
members: endowed_accounts.iter()
.take((num_endowed_accounts + 1) / 2)
.cloned()
.map(|member| (member, STASH))
.collect(),
},
pallet_collective_Instance1: CouncilConfig::default(),
pallet_collective_Instance2: TechnicalCommitteeConfig {
council: CouncilConfig::default(),
technical_committee: TechnicalCommitteeConfig {
members: endowed_accounts.iter()
.take((num_endowed_accounts + 1) / 2)
.cloned()
.collect(),
phantom: Default::default(),
},
pallet_contracts: ContractsConfig {
/*pallet_contracts: ContractsConfig {
// println should only be enabled on development chains
current_schedule: pallet_contracts::Schedule::default()
.enable_println(enable_println),
},
pallet_sudo: SudoConfig {
},*/
sudo: SudoConfig {
key: root_key,
},
pallet_babe: BabeConfig {
babe: BabeConfig {
authorities: vec![],
epoch_config: Some(node_runtime::BABE_GENESIS_EPOCH_CONFIG),
},
pallet_im_online: ImOnlineConfig {
im_online: ImOnlineConfig {
keys: vec![],
},
pallet_authority_discovery: AuthorityDiscoveryConfig {
authority_discovery: AuthorityDiscoveryConfig {
keys: vec![],
},
pallet_grandpa: GrandpaConfig {
grandpa: GrandpaConfig {
authorities: vec![],
},
pallet_membership_Instance1: Default::default(),
pallet_treasury: Default::default(),
pallet_society: SocietyConfig {
technical_membership: Default::default(),
treasury: Default::default(),
society: SocietyConfig {
members: endowed_accounts.iter()
.take((num_endowed_accounts + 1) / 2)
.cloned()
.collect(),
pot: 0,
max_members: 999,
},
pallet_vesting: Default::default(),
pallet_gilt: Default::default(),
pallet_quadratic_funding: QuadraticFundingConfig {
vesting: Default::default(),
gilt: Default::default(),
quadratic_funding: QuadraticFundingConfig {
init_max_grant_count_per_round: 60,
init_withdrawal_expiration: 1000,
init_is_identity_required: false,
},
transaction_storage: Default::default(),
}
}

Expand Down Expand Up @@ -474,9 +471,4 @@ pub(crate) mod tests {
fn test_create_local_testnet_chain_spec() {
local_testnet_config().build_storage().unwrap();
}

#[test]
fn test_staging_test_net_chain_spec() {
testnet_config().build_storage().unwrap();
}
}
Loading

0 comments on commit bdf71f2

Please sign in to comment.