Skip to content

Commit

Permalink
Merge branch 'main' into salman/store-rolekey
Browse files Browse the repository at this point in the history
  • Loading branch information
salman01zp authored Jan 8, 2024
2 parents 8306b5d + 4c87b0e commit 4c85e04
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 110 deletions.
28 changes: 14 additions & 14 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace.package]
version = "0.5.0"
version = "0.6.0"
authors = ["Webb Technologies Inc."]
edition = "2021"
license = "Unlicense"
Expand Down
101 changes: 46 additions & 55 deletions node/src/chainspec/testnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@

#![allow(clippy::type_complexity)]

use crate::{
distributions::{combine_distributions, develop, testnet},
testnet_fixtures::{get_bootnodes, get_initial_authorities, get_testnet_root_key},
};
use crate::testnet_fixtures::{get_bootnodes, get_initial_authorities, get_testnet_root_key};
use core::marker::PhantomData;
use hex_literal::hex;
use pallet_airdrop_claims::{MultiAddress, StatementKind};
Expand All @@ -45,6 +42,9 @@ use webb_consensus_types::network_config::{Network, NetworkConfig};
/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
pub type ChainSpec = sc_service::GenericChainSpec<RuntimeGenesisConfig>;

pub const ENDOWMENT: Balance = 10_000_000 * UNIT;
pub const STASH: Balance = ENDOWMENT / 10;

/// Generate a crypto pair from seed.
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
TPublic::Pair::from_string(&format!("//{seed}"), None)
Expand Down Expand Up @@ -117,19 +117,16 @@ pub fn local_testnet_config(chain_id: u64) -> Result<ChainSpec, String> {
get_account_id_from_seed::<sr25519::Public>("Alice"),
// Pre-funded accounts
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>("Alice"), ENDOWMENT),
(get_account_id_from_seed::<sr25519::Public>("Bob"), ENDOWMENT),
(get_account_id_from_seed::<sr25519::Public>("Charlie"), ENDOWMENT),
(get_account_id_from_seed::<sr25519::Public>("Dave"), ENDOWMENT),
(get_account_id_from_seed::<sr25519::Public>("Eve"), ENDOWMENT),
],
chain_id,
combine_distributions(vec![
develop::get_evm_balance_distribution(),
testnet::get_evm_balance_distribution(),
]),
testnet::get_substrate_balance_distribution(),
develop::get_local_claims(),
Default::default(),
Default::default(),
Default::default(),
true,
)
},
Expand Down Expand Up @@ -171,39 +168,37 @@ pub fn tangle_testnet_config(chain_id: u64) -> Result<ChainSpec, String> {
get_testnet_root_key(),
// Pre-funded accounts
vec![
get_testnet_root_key(),
hex!["4e85271af1330e5e9384bd3ac5bdc04c0f8ef5a8cc29c1a8ae483d674164745c"].into(),
hex!["804808fb75d16340dc250871138a1a6f1dfa3cab9cc1fbd6f42960f1c39a950d"].into(),
hex!["587c2ef00ec0a1b98af4c655763acd76ece690fccbb255f01663660bc274960d"].into(),
hex!["cc195602a63bbdcf2ef4773c86fdbfefe042cb9aa8e3059d02e59a062d9c3138"].into(),
hex!["a24f729f085de51eebaeaeca97d6d499761b8f6daeca9b99d754a06ef8bcec3f"].into(),
hex!["368ea402dbd9c9888ae999d6a799cf36e08673ee53c001dfb4529c149fc2c13b"].into(),
hex!["2c7f3cc085da9175414d1a9d40aa3aa161c8584a9ca62a938684dfbe90ae9d74"].into(),
hex!["0a55e5245382700f35d16a5ea6d60a56c36c435bef7204353b8c36871f347857"].into(),
hex!["e0948453e7acbc6ac937e124eb01580191e99f4262d588d4524994deb6134349"].into(),
hex!["6c73e5ee9f8614e7c9f23fd8f7257d12e061e75fcbeb3b50ed70eb87ba91f500"].into(),
hex!["541dc9dd9cd9b47ff19c77c3b14fab50ab0774e19abe438719cd09e4f4861166"].into(),
hex!["607e948bad733780eda6c0bd9b084243276332823ca8481fc20cd01e1a2ef36f"].into(),
hex!["b2c09cb1b78c3afd2b1ea4316dfb1be9065e070db948477248e4f3e0f1a2d850"].into(),
hex!["fc156f082d789f94149f8b52b191672fbf202ef1b92b487c3cec9bca2d1fbe72"].into(),
hex!["0e87759b6eeb6891743900cba17b8b5f31b2fa9c28536d9bcf76468d6e455b23"].into(),
hex!["48cea44ac6dd245572272dc6d4d33908586fb80886bf3207344388eac279cc25"].into(),
hex!["fa2c711c82661a761cf200421b9a5ef3257aa977a3a33acad0722d7d6993f03b"].into(),
hex!["daf7985bfa22b5060a4eb212fbeddb7c47f7c29db5a356ed9500b34d2944eb3d"].into(),
hex!["4ec0389ae623884a68234fd84d85af833633668aa382007e6515020e8cc29532"].into(),
hex!["48bb70f924e7362ee55817a6628a79e522a08a31735b0129e47ac435215d6c4e"].into(),
hex!["d6a033ee1790ef28fffe1b1ffec19b8921690632d073d955b9057e701eced352"].into(),
hex!["14ecdcc058ee431166402eefb682c276cc16a5d1083409b28076fda4c4d5352f"].into(),
hex!["400d597fe03f1031a9b4e1983b7c42eeed29ef3f9da6715667d06b367bdb897f"].into(),
hex!["668cf048845804f31759decbec11cb41bf316b1901d2142a35ad3a8eb7420326"].into(),
(get_testnet_root_key(), ENDOWMENT * 5), // 50 Million
(
hex!["6c99e8e4ae3fe7e3328d7e9d85eb98e86bdc6410695797349fa536ebb9bb0a4a"]
.into(),
ENDOWMENT,
),
(
hex!["444dbfd0220eb1a993a7a2b9e1530aee1d17388ba3db34a0ee2b8ff971bfd073"]
.into(),
ENDOWMENT,
),
(
hex!["2c4e648b0fbbb88ff6b92b208273eb144383b2b19edc992e91448a4371d4d97d"]
.into(),
ENDOWMENT,
),
(
hex!["c884c8eb280327221a3ae6a45fe6c8805f09bcfc11b409c8e2daa621c0d99608"]
.into(),
ENDOWMENT,
),
(
hex!["483e0b8d6801c51115fd4b124c91e2d5dcd642b30335f6c5a1738ea18f66c251"]
.into(),
ENDOWMENT,
),
],
chain_id,
combine_distributions(vec![
develop::get_evm_balance_distribution(),
testnet::get_evm_balance_distribution(),
]),
testnet::get_substrate_balance_distribution(),
vec![],
Default::default(),
Default::default(),
Default::default(),
true,
)
},
Expand All @@ -229,29 +224,26 @@ fn testnet_genesis(
initial_authorities: Vec<(AccountId, BabeId, GrandpaId, ImOnlineId, RoleKeyId)>,
_initial_nominators: Vec<AccountId>,
root_key: AccountId,
endowed_accounts: Vec<AccountId>,
endowed_accounts: Vec<(AccountId, Balance)>,
chain_id: u64,
genesis_evm_distribution: Vec<(H160, fp_evm::GenesisAccount)>,
genesis_substrate_distribution: Vec<(AccountId, Balance)>,
claims: Vec<(MultiAddress, Balance)>,
_enable_println: bool,
) -> RuntimeGenesisConfig {
const ENDOWMENT: Balance = 10_000_000 * UNIT;
const STASH: Balance = ENDOWMENT / 100;

// stakers: all validators and nominators.
let _rng = rand::thread_rng();
// stakers: all validators and nominators.
let stakers = initial_authorities
.iter()
.map(|x| (x.0.clone(), x.0.clone(), UNIT, StakerStatus::Validator))
.map(|x| (x.0.clone(), x.0.clone(), STASH, StakerStatus::Validator))
.collect();

let num_endowed_accounts = endowed_accounts.len();

let claims_list: Vec<(MultiAddress, Balance, Option<StatementKind>)> = endowed_accounts
.iter()
.map(|x| (MultiAddress::Native(x.clone()), ENDOWMENT, Some(StatementKind::Regular)))
.map(|x| (MultiAddress::Native(x.0.clone()), ENDOWMENT, Some(StatementKind::Regular)))
.chain(claims.clone().into_iter().map(|(a, b)| (a, b, Some(StatementKind::Regular))))
.collect();

Expand All @@ -263,7 +255,7 @@ fn testnet_genesis(
.map(|x| {
let mut bounded_vec = BoundedVec::new();
bounded_vec.try_push((ENDOWMENT, ENDOWMENT, 0)).unwrap();
(MultiAddress::Native(x.clone()), bounded_vec)
(MultiAddress::Native(x.0.clone()), bounded_vec)
})
.chain(claims.into_iter().map(|(a, b)| {
let mut bounded_vec = BoundedVec::new();
Expand All @@ -284,7 +276,6 @@ fn testnet_genesis(
balances: endowed_accounts
.iter()
.cloned()
.map(|k| (k, ENDOWMENT))
.chain(genesis_substrate_distribution.iter().cloned().map(|(k, v)| (k, v)))
.collect(),
},
Expand Down Expand Up @@ -317,7 +308,7 @@ fn testnet_genesis(
.iter()
.take((num_endowed_accounts + 1) / 2)
.cloned()
.map(|member| (member, STASH))
.map(|member| (member.0, STASH))
.collect(),
},
treasury: Default::default(),
Expand Down
2 changes: 1 addition & 1 deletion node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl<T: sc_service::ChainSpec + 'static> IdentifyChain for T {

impl SubstrateCli for Cli {
fn impl_name() -> String {
"Tangle Substrate Node".into()
"Tangle Node".into()
}

fn impl_version() -> String {
Expand Down
1 change: 1 addition & 0 deletions node/src/distributions/develop.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(dead_code)]
// This file is part of Tangle.
// Copyright (C) 2022-2024 Webb Technologies Inc.
//
Expand Down
1 change: 1 addition & 0 deletions node/src/distributions/testnet.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(dead_code)]
// This file is part of Tangle.
// Copyright (C) 2022-2024 Webb Technologies Inc.
//
Expand Down
Loading

0 comments on commit 4c85e04

Please sign in to comment.