Skip to content

Commit

Permalink
add kerria config
Browse files Browse the repository at this point in the history
  • Loading branch information
mclyk committed Sep 18, 2023
1 parent 8b65fde commit b6f6bba
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 132 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches:
- master
- paraid-3350
pull_request:
branches: [master]

Expand Down
249 changes: 118 additions & 131 deletions node/parallel/src/chain_spec/kerria.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,55 +35,58 @@ use crate::chain_spec::{
/// Specialized `ChainSpec` for the normal parachain runtime.
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig, Extensions>;

fn evm_accounts() -> Vec<AccountId> {
vec![
// the mapping SS58 of Alice
// Secret seed: 0xe5be9a5092b81bca64be81d212e7f2f9eba183bb7a90954f7b76361f6edb5c0a
// H160: 0x8097c3C354652CB1EEed3E5B65fBa2576470678A
"hJGTRJgAGeMy9515iQ56VtfGKiGmejMkXmjKDRrxA46b7Z2So"
.parse()
.unwrap(),
// others are all from ganache with MNEMONIC:
//'into treat head shock search rule sheriff sword problem carpet exercise useful'
"hJGGzG3onkMCMZbPMpLWe3jo3NQeDLtdHRedes6FtPjwEBjnk"
.parse()
.unwrap(),
"hJJAtKQkAFTJKTgPQoMjAqafQeFWuNQujNUjC7xmtjguQLY8z"
.parse()
.unwrap(),
"hJHkTHBNs2UbaLTYyNdRtGqKJfEt1g6qJTsoFSmnSwCMB1GiH"
.parse()
.unwrap(),
"hJGRnsnw7JMJkbc4Jsa2AJyrEkdtBNLFFSpYgNiwpvsgsGS3s"
.parse()
.unwrap(),
"hJJYGraYTku7dcvPY5eeGoXYDZC6ujRboQosFwMuNSMD9bEok"
.parse()
.unwrap(),
]
}
// fn evm_accounts() -> Vec<AccountId> {
// vec![
// // the mapping SS58 of Alice
// // Secret seed: 0xe5be9a5092b81bca64be81d212e7f2f9eba183bb7a90954f7b76361f6edb5c0a
// // H160: 0x8097c3C354652CB1EEed3E5B65fBa2576470678A
// "hJGTRJgAGeMy9515iQ56VtfGKiGmejMkXmjKDRrxA46b7Z2So"
// .parse()
// .unwrap(),
// // others are all from ganache with MNEMONIC:
// //'into treat head shock search rule sheriff sword problem carpet exercise useful'
// "hJGGzG3onkMCMZbPMpLWe3jo3NQeDLtdHRedes6FtPjwEBjnk"
// .parse()
// .unwrap(),
// "hJJAtKQkAFTJKTgPQoMjAqafQeFWuNQujNUjC7xmtjguQLY8z"
// .parse()
// .unwrap(),
// "hJHkTHBNs2UbaLTYyNdRtGqKJfEt1g6qJTsoFSmnSwCMB1GiH"
// .parse()
// .unwrap(),
// "hJGRnsnw7JMJkbc4Jsa2AJyrEkdtBNLFFSpYgNiwpvsgsGS3s"
// .parse()
// .unwrap(),
// "hJJYGraYTku7dcvPY5eeGoXYDZC6ujRboQosFwMuNSMD9bEok"
// .parse()
// .unwrap(),
// ]
// }

fn substrate_accounts() -> Vec<AccountId> {
vec![
// Faucet accounts
"5HHMY7e8UAqR5ZaHGaQnRW5EDR8dP7QpAyjeBu6V7vdXxxbf"
.parse()
.unwrap(),
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>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
]
}
// fn substrate_accounts() -> Vec<AccountId> {
// vec![
// // Faucet accounts
// "5HHMY7e8UAqR5ZaHGaQnRW5EDR8dP7QpAyjeBu6V7vdXxxbf"
// .parse()
// .unwrap(),
// 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>("Ferdie"),
// get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
// get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
// get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
// get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
// get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
// get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
// ]
// }

const initial_account: AccountId = "5DyUFZag8FHYT2bSSMX9DK2hCzeinL5xbdaQnyibsGAMqsDC"
.parse()
.unwrap();
pub fn kerria_dev_config(id: ParaId) -> ChainSpec {
ChainSpec::from_genesis(
// Name
Expand All @@ -92,48 +95,27 @@ pub fn kerria_dev_config(id: ParaId) -> ChainSpec {
"kerria-dev",
ChainType::Development,
move || {
let root_key = get_account_id_from_seed::<sr25519::Public>("Dave");
let root_key = initial_account;
let invulnerables = vec![get_authority_keys_from_seed("Alice")];
let oracle_accounts = vec![get_account_id_from_seed::<sr25519::Public>("Ferdie")];
let bridge_accounts = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];
let liquid_staking_agents = vec![get_account_id_from_seed::<sr25519::Public>("Eve")];
let crowdloans_automators = vec![get_account_id_from_seed::<sr25519::Public>("Bob")];
let initial_allocation: Vec<(AccountId, Balance)> = accumulate(
[substrate_accounts(), evm_accounts()]
.concat()
.iter()
.flat_map(|x| {
if x == &"5HHMY7e8UAqR5ZaHGaQnRW5EDR8dP7QpAyjeBu6V7vdXxxbf"
.parse()
.unwrap()
{
vec![(x.clone(), 10_u128.pow(20))]
} else {
vec![(x.clone(), 10_u128.pow(16))]
}
}),
);
let vesting_list = vec![];
let council = 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"),
];
let technical_committee = vec![
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
];
// let oracle_accounts = vec![get_account_id_from_seed::<sr25519::Public>("Ferdie")];
// let bridge_accounts = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];
// let liquid_staking_agents = vec![get_account_id_from_seed::<sr25519::Public>("Eve")];
// let crowdloans_automators = vec![get_account_id_from_seed::<sr25519::Public>("Bob")];
let initial_allocation: Vec<(AccountId, Balance)> =
vec![(initial_account, 10_u128.pow(20))];
// let vesting_list = vec![];
let council = vec![initial_account];
let technical_committee = vec![initial_account];

kerria_genesis(
root_key,
invulnerables,
initial_allocation,
vesting_list,
oracle_accounts,
bridge_accounts,
liquid_staking_agents,
crowdloans_automators,
// vesting_list,
// oracle_accounts,
// bridge_accounts,
// liquid_staking_agents,
// crowdloans_automators,
council,
technical_committee,
id,
Expand All @@ -151,20 +133,25 @@ pub fn kerria_dev_config(id: ParaId) -> ChainSpec {
)
}

pub fn kerria_config(_id: ParaId) -> Result<ChainSpec, String> {
// ChainSpec::from_json_bytes(&include_bytes!("../../../../resources/specs/kerria_3350.json")[..])
Err("error")
}

fn kerria_genesis(
root_key: AccountId,
invulnerables: Vec<(AccountId, AuraId)>,
initial_allocation: Vec<(AccountId, Balance)>,
vesting_list: Vec<(AccountId, BlockNumber, BlockNumber, u32, Balance)>,
oracle_accounts: Vec<AccountId>,
bridge_accounts: Vec<AccountId>,
liquid_staking_agents: Vec<AccountId>,
crowdloans_automators: Vec<AccountId>,
// vesting_list: Vec<(AccountId, BlockNumber, BlockNumber, u32, Balance)>,
// oracle_accounts: Vec<AccountId>,
// bridge_accounts: Vec<AccountId>,
// liquid_staking_agents: Vec<AccountId>,
// crowdloans_automators: Vec<AccountId>,
council: Vec<AccountId>,
technical_committee: Vec<AccountId>,
id: ParaId,
) -> GenesisConfig {
let revert_bytecode = vec![0x60, 0x00, 0x60, 0x00, 0xFD];
// let revert_bytecode = vec![0x60, 0x00, 0x60, 0x00, 0xFD];
GenesisConfig {
system: SystemConfig {
code: WASM_BINARY
Expand Down Expand Up @@ -199,10 +186,10 @@ fn kerria_genesis(
key: Some(root_key),
},
parachain_info: ParachainInfoConfig { parachain_id: id },
liquid_staking: LiquidStakingConfig {
exchange_rate: Rate::saturating_from_rational(100u32, 100u32), // 1
reserve_factor: Ratio::from_rational(5u32, 10_000u32), // 0.05%
},
// liquid_staking: LiquidStakingConfig {
// exchange_rate: Rate::saturating_from_rational(100u32, 100u32), // 1
// reserve_factor: Ratio::from_rational(5u32, 10_000u32), // 0.05%
// },
democracy: DemocracyConfig::default(),
general_council: GeneralCouncilConfig::default(),
general_council_membership: GeneralCouncilMembershipConfig {
Expand All @@ -215,46 +202,46 @@ fn kerria_genesis(
phantom: Default::default(),
},
treasury: Default::default(),
oracle_membership: OracleMembershipConfig {
members: oracle_accounts.try_into().unwrap(),
phantom: Default::default(),
},
bridge_membership: BridgeMembershipConfig {
members: bridge_accounts.try_into().unwrap(),
phantom: Default::default(),
},
liquid_staking_agents_membership: LiquidStakingAgentsMembershipConfig {
members: liquid_staking_agents.try_into().unwrap(),
phantom: Default::default(),
},
crowdloans_automators_membership: CrowdloansAutomatorsMembershipConfig {
members: crowdloans_automators.try_into().unwrap(),
phantom: Default::default(),
},
vesting: VestingConfig {
vesting: vesting_list.try_into().unwrap(),
},
// oracle_membership: OracleMembershipConfig {
// members: oracle_accounts.try_into().unwrap(),
// phantom: Default::default(),
// },
// bridge_membership: BridgeMembershipConfig {
// members: bridge_accounts.try_into().unwrap(),
// phantom: Default::default(),
// },
// liquid_staking_agents_membership: LiquidStakingAgentsMembershipConfig {
// members: liquid_staking_agents.try_into().unwrap(),
// phantom: Default::default(),
// },
// crowdloans_automators_membership: CrowdloansAutomatorsMembershipConfig {
// members: crowdloans_automators.try_into().unwrap(),
// phantom: Default::default(),
// },
// vesting: VestingConfig {
// vesting: vesting_list.try_into().unwrap(),
// },
polkadot_xcm: PolkadotXcmConfig {
safe_xcm_version: Some(2),
},
evm: EVMConfig {
// We need _some_ code inserted at the precompile address so that
// the evm will actually call the address.
accounts: ParallelPrecompilesType::used_addresses()
.map(|addr| {
(
addr,
fp_evm::GenesisAccount {
nonce: Default::default(),
balance: Default::default(),
storage: Default::default(),
code: revert_bytecode.clone(),
},
)
})
.collect(),
},
base_fee: BaseFeeConfig::new(sp_core::U256::from(10_000_000), sp_runtime::Permill::zero()),
ethereum: Default::default(),
// evm: EVMConfig {
// // We need _some_ code inserted at the precompile address so that
// // the evm will actually call the address.
// accounts: ParallelPrecompilesType::used_addresses()
// .map(|addr| {
// (
// addr,
// fp_evm::GenesisAccount {
// nonce: Default::default(),
// balance: Default::default(),
// storage: Default::default(),
// code: revert_bytecode.clone(),
// },
// )
// })
// .collect(),
// },
// base_fee: BaseFeeConfig::new(sp_core::U256::from(10_000_000), sp_runtime::Permill::zero()),
// ethereum: Default::default(),
}
}
4 changes: 4 additions & 0 deletions node/parallel/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ use std::net::SocketAddr;
const CHAIN_NAME: &str = "Parallel";
const PARALLEL_PARA_ID: u32 = 2012;
const HEIKO_PARA_ID: u32 = 2085;
const KERRIA_PARA_ID: u32 = 3350;

fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
Ok(match id {
Expand All @@ -61,6 +62,9 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, St
"kerria-dev" => Box::new(chain_spec::kerria::kerria_dev_config(ParaId::from(
PARALLEL_PARA_ID,
))),
"kerria" => Box::new(chain_spec::kerria::kerria_config(ParaId::from(
KERRIA_PARA_ID,
))?),
path => {
let path = std::path::PathBuf::from(path);
let starts_with = |prefix: &str| {
Expand Down

0 comments on commit b6f6bba

Please sign in to comment.