diff --git a/Cargo.lock b/Cargo.lock index a025dd999..48b7a8a57 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -702,6 +702,7 @@ dependencies = [ "sp-consensus", "sp-consensus-aura", "sp-core", + "sp-genesis-builder", "sp-inherents", "sp-io", "sp-keyring", @@ -771,6 +772,7 @@ dependencies = [ "cumulus-primitives-core", "cumulus-primitives-utility", "dapp-staking-runtime-api", + "fp-evm", "fp-rpc", "fp-self-contained", "frame-benchmarking", @@ -839,6 +841,7 @@ dependencies = [ "polkadot-runtime-common", "precompile-utils", "scale-info", + "serde_json", "smallvec", "sp-api", "sp-arithmetic", @@ -6547,6 +6550,7 @@ dependencies = [ "array-bytes 6.2.3", "astar-primitives", "dapp-staking-runtime-api", + "fp-evm", "fp-rpc", "fp-self-contained", "frame-benchmarking", @@ -6608,6 +6612,7 @@ dependencies = [ "parity-scale-codec", "precompile-utils", "scale-info", + "serde_json", "smallvec", "sp-api", "sp-arithmetic", @@ -14373,6 +14378,7 @@ dependencies = [ "cumulus-primitives-core", "cumulus-primitives-utility", "dapp-staking-runtime-api", + "fp-evm", "fp-rpc", "fp-self-contained", "frame-benchmarking", @@ -14453,6 +14459,7 @@ dependencies = [ "polkadot-runtime-common", "precompile-utils", "scale-info", + "serde_json", "smallvec", "sp-api", "sp-arithmetic", @@ -14492,6 +14499,7 @@ dependencies = [ "cumulus-primitives-core", "cumulus-primitives-utility", "dapp-staking-runtime-api", + "fp-evm", "fp-rpc", "fp-self-contained", "frame-benchmarking", @@ -14561,6 +14569,7 @@ dependencies = [ "polkadot-runtime-common", "precompile-utils", "scale-info", + "serde_json", "smallvec", "sp-api", "sp-arithmetic", diff --git a/Cargo.toml b/Cargo.toml index 66c30a964..e413f0d65 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -77,7 +77,7 @@ clap = { version = "4.2.5", features = ["derive"] } env_logger = "0.10.0" futures = { version = "0.3.30" } serde = { version = "1.0.151", default-features = false, features = ["derive", "alloc"] } -serde_json = "1.0.92" +serde_json = { version = "1.0.92", default-features = false } tokio = { version = "1.24.2", features = ["macros", "sync"] } url = "2.2.2" jsonrpsee = { version = "0.22.5", features = ["server"] } diff --git a/bin/collator/Cargo.toml b/bin/collator/Cargo.toml index c843099e6..a784f981b 100644 --- a/bin/collator/Cargo.toml +++ b/bin/collator/Cargo.toml @@ -33,6 +33,7 @@ sp-api = { workspace = true, features = ["std"] } sp-block-builder = { workspace = true, features = ["std"] } sp-consensus-aura = { workspace = true, features = ["std"] } sp-core = { workspace = true, features = ["std"] } +sp-genesis-builder = { workspace = true, features = ["std"] } sp-inherents = { workspace = true, features = ["std"] } sp-io = { workspace = true, features = ["std"] } sp-offchain = { workspace = true, features = ["std"] } diff --git a/bin/collator/src/local/chain_spec.rs b/bin/collator/src/local/chain_spec.rs index e545408bc..af35be4a5 100644 --- a/bin/collator/src/local/chain_spec.rs +++ b/bin/collator/src/local/chain_spec.rs @@ -16,208 +16,27 @@ // You should have received a copy of the GNU General Public License // along with Astar. If not, see . -//! Chain specifications. - -use local_runtime::{ - wasm_binary_unwrap, AccountId, AuraConfig, AuraId, BalancesConfig, - CommunityCouncilMembershipConfig, CommunityTreasuryPalletId, CouncilMembershipConfig, - DappStakingConfig, EVMConfig, GrandpaConfig, GrandpaId, InflationConfig, InflationParameters, - Precompiles, RuntimeGenesisConfig, Signature, SudoConfig, TechnicalCommitteeMembershipConfig, - TierThreshold, TreasuryPalletId, VestingConfig, AST, -}; +use local_runtime::wasm_binary_unwrap; use sc_service::ChainType; -use sp_core::{crypto::Ss58Codec, sr25519, Pair, Public}; -use sp_runtime::{ - traits::{AccountIdConversion, IdentifyAccount, Verify}, - Perbill, Permill, -}; - -type AccountPublic = ::Signer; -/// Specialized `ChainSpec` for Shiden Network. +/// Specialized `ChainSpec` for local network. pub type ChainSpec = sc_service::GenericChainSpec; -/// Helper function to generate a crypto pair from seed -fn get_from_seed(seed: &str) -> ::Public { - TPublic::Pair::from_string(&format!("//{}", seed), None) - .expect("static values are valid; qed") - .public() -} - -/// Helper function to generate an account ID from seed -fn get_account_id_from_seed(seed: &str) -> AccountId -where - AccountPublic: From<::Public>, -{ - AccountPublic::from(get_from_seed::(seed)).into_account() -} - -/// Generate an Aura authority key. -pub fn authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) { - (get_from_seed::(s), get_from_seed::(s)) -} - -/// Development config (single validator Alice) +/// Development config. pub fn development_config() -> ChainSpec { let mut properties = serde_json::map::Map::new(); properties.insert("tokenSymbol".into(), "LOC".into()); properties.insert("tokenDecimals".into(), 18.into()); + ChainSpec::builder(wasm_binary_unwrap(), None) .with_name("Development") .with_id("dev") .with_chain_type(ChainType::Development) .with_properties(properties) - .with_genesis_config(testnet_genesis( - vec![authority_keys_from_seed("Alice")], - get_account_id_from_seed::("Alice"), - vec![ - get_account_id_from_seed::("Alice"), - get_account_id_from_seed::("Bob"), - get_account_id_from_seed::("Dave"), - get_account_id_from_seed::("Charlie"), - get_account_id_from_seed::("Eve"), - get_account_id_from_seed::("Ferdie"), - TreasuryPalletId::get().into_account_truncating(), - CommunityTreasuryPalletId::get().into_account_truncating(), - // Arrakis.TEST account in MetaMask - // Import known test account with private key - // 0x01ab6e801c06e59ca97a14fc0a1978b27fa366fc87450e0b65459dd3515b7391 - // H160 address: 0xaaafB3972B05630fCceE866eC69CdADd9baC2771 - AccountId::from_ss58check("5FQedkNQcF2fJPwkB6Z1ZcMgGti4vcJQNs6x85YPv3VhjBBT") - .unwrap(), - ], - )) + .with_genesis_config(local_runtime::genesis_config::default_config()) .build() } -fn testnet_genesis( - initial_authorities: Vec<(AuraId, GrandpaId)>, - root_key: AccountId, - endowed_accounts: Vec, -) -> serde_json::Value { - let accounts: Vec = vec!["Alice", "Bob", "Charlie", "Dave", "Eve"] - .iter() - .map(|s| get_account_id_from_seed::(s)) - .collect(); - - // This is supposed the be the simplest bytecode to revert without returning any data. - // We will pre-deploy it under all of our precompiles to ensure they can be called from - // within contracts. - // (PUSH1 0x00 PUSH1 0x00 REVERT) - let revert_bytecode = vec![0x60, 0x00, 0x60, 0x00, 0xFD]; - let config = RuntimeGenesisConfig { - system: Default::default(), - balances: BalancesConfig { - balances: endowed_accounts - .iter() - .cloned() - .map(|k| (k, 1_000_000_000 * AST)) - .collect(), - }, - vesting: VestingConfig { vesting: vec![] }, - aura: AuraConfig { - authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(), - }, - grandpa: GrandpaConfig { - authorities: initial_authorities - .iter() - .map(|x| (x.1.clone(), 1)) - .collect(), - ..Default::default() - }, - evm: EVMConfig { - // We need _some_ code inserted at the precompile address so that - // the evm will actually call the address. - accounts: Precompiles::used_addresses_h160() - .map(|addr| { - ( - addr, - fp_evm::GenesisAccount { - nonce: Default::default(), - balance: Default::default(), - storage: Default::default(), - code: revert_bytecode.clone(), - }, - ) - }) - .collect(), - ..Default::default() - }, - ethereum: Default::default(), - sudo: SudoConfig { - key: Some(root_key), - }, - assets: Default::default(), - transaction_payment: Default::default(), - dapp_staking: DappStakingConfig { - reward_portion: vec![ - Permill::from_percent(40), - Permill::from_percent(30), - Permill::from_percent(20), - Permill::from_percent(10), - ], - slot_distribution: vec![ - Permill::from_percent(10), - Permill::from_percent(20), - Permill::from_percent(30), - Permill::from_percent(40), - ], - tier_thresholds: vec![ - TierThreshold::DynamicPercentage { - percentage: Perbill::from_parts(35_700_000), // 3.57% - minimum_required_percentage: Perbill::from_parts(23_800_000), // 2.38% - }, - TierThreshold::DynamicPercentage { - percentage: Perbill::from_parts(8_900_000), // 0.89% - minimum_required_percentage: Perbill::from_parts(6_000_000), // 0.6% - }, - TierThreshold::DynamicPercentage { - percentage: Perbill::from_parts(23_800_000), // 2.38% - minimum_required_percentage: Perbill::from_parts(17_900_000), // 1.79% - }, - TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(600_000), // 0.06% - }, - ], - slots_per_tier: vec![10, 20, 30, 40], - safeguard: Some(false), - ..Default::default() - }, - inflation: InflationConfig { - params: InflationParameters::default(), - ..Default::default() - }, - council_membership: CouncilMembershipConfig { - members: accounts - .clone() - .try_into() - .expect("Should support at least 5 members."), - phantom: Default::default(), - }, - technical_committee_membership: TechnicalCommitteeMembershipConfig { - members: accounts[..3] - .to_vec() - .try_into() - .expect("Should support at least 3 members."), - phantom: Default::default(), - }, - community_council_membership: CommunityCouncilMembershipConfig { - members: accounts - .try_into() - .expect("Should support at least 5 members."), - phantom: Default::default(), - }, - council: Default::default(), - technical_committee: Default::default(), - community_council: Default::default(), - democracy: Default::default(), - treasury: Default::default(), - community_treasury: Default::default(), - }; - - serde_json::to_value(&config).expect("Could not build genesis config.") -} - #[cfg(test)] pub(crate) mod tests { use super::*; diff --git a/bin/collator/src/parachain/chain_spec/astar.rs b/bin/collator/src/parachain/chain_spec/astar.rs index f5e0ec349..47819db0c 100644 --- a/bin/collator/src/parachain/chain_spec/astar.rs +++ b/bin/collator/src/parachain/chain_spec/astar.rs @@ -18,42 +18,17 @@ //! Astar chain specifications. -use super::{get_from_seed, Extensions}; -use astar_primitives::oracle::CurrencyAmount; -use astar_runtime::{ - wasm_binary_unwrap, AccountId, AuraId, Balance, DappStakingConfig, EVMConfig, InflationConfig, - InflationParameters, OracleMembershipConfig, ParachainInfoConfig, Precompiles, - PriceAggregatorConfig, Signature, TierThreshold, ASTR, -}; -use cumulus_primitives_core::ParaId; +use super::Extensions; +use astar_primitives::parachain::ASTAR_ID; +use astar_runtime::wasm_binary_unwrap; use sc_service::ChainType; -use sp_core::{sr25519, Pair, Public}; -use sp_runtime::{ - traits::{IdentifyAccount, Verify}, - Perbill, Permill, -}; - -const PARA_ID: u32 = 2006; /// Specialized `ChainSpec` for Astar Network. pub type AstarChainSpec = sc_service::GenericChainSpec; -/// Gen Astar chain specification for given parachain id. +/// Get Astar chain specification. pub fn get_chain_spec() -> AstarChainSpec { - // Alice as default - let sudo_key = get_account_id_from_seed::("Alice"); - let endowned = vec![ - ( - get_account_id_from_seed::("Alice"), - 1_000_000_000 * ASTR, - ), - ( - get_account_id_from_seed::("Bob"), - 1_000_000_000 * ASTR, - ), - ]; - let mut properties = serde_json::map::Map::new(); properties.insert("tokenSymbol".into(), "ASTR".into()); properties.insert("tokenDecimals".into(), 18.into()); @@ -63,161 +38,13 @@ pub fn get_chain_spec() -> AstarChainSpec { Extensions { bad_blocks: Default::default(), relay_chain: "tokyo".into(), - para_id: PARA_ID, + para_id: ASTAR_ID, }, ) .with_name("Astar Testnet") .with_id("astar") .with_chain_type(ChainType::Development) .with_properties(properties) - .with_genesis_config(make_genesis( - endowned.clone(), - sudo_key.clone(), - PARA_ID.into(), - )) + .with_genesis_config(astar_runtime::genesis_config::default_config(ASTAR_ID)) .build() } - -fn session_keys(aura: AuraId) -> astar_runtime::SessionKeys { - astar_runtime::SessionKeys { aura } -} - -/// Helper function to create RuntimeGenesisConfig. -fn make_genesis( - balances: Vec<(AccountId, Balance)>, - root_key: AccountId, - parachain_id: ParaId, -) -> serde_json::Value { - let authorities = vec![ - ( - get_account_id_from_seed::("Alice"), - get_from_seed::("Alice"), - ), - ( - get_account_id_from_seed::("Bob"), - get_from_seed::("Bob"), - ), - ]; - - // This is supposed the be the simplest bytecode to revert without returning any data. - // We will pre-deploy it under all of our precompiles to ensure they can be called from - // within contracts. - // (PUSH1 0x00 PUSH1 0x00 REVERT) - let revert_bytecode = vec![0x60, 0x00, 0x60, 0x00, 0xFD]; - - let config = astar_runtime::RuntimeGenesisConfig { - system: Default::default(), - sudo: astar_runtime::SudoConfig { - key: Some(root_key), - }, - parachain_info: ParachainInfoConfig { - parachain_id, - ..Default::default() - }, - balances: astar_runtime::BalancesConfig { balances }, - vesting: astar_runtime::VestingConfig { vesting: vec![] }, - session: astar_runtime::SessionConfig { - keys: authorities - .iter() - .map(|x| (x.0.clone(), x.0.clone(), session_keys(x.1.clone()))) - .collect::>(), - }, - aura: astar_runtime::AuraConfig { - authorities: vec![], - }, - aura_ext: Default::default(), - collator_selection: astar_runtime::CollatorSelectionConfig { - desired_candidates: 32, - candidacy_bond: 3_200_000 * ASTR, - invulnerables: authorities.iter().map(|x| x.0.clone()).collect::>(), - }, - evm: EVMConfig { - // We need _some_ code inserted at the precompile address so that - // the evm will actually call the address. - accounts: Precompiles::used_addresses_h160() - .map(|addr| { - ( - addr, - fp_evm::GenesisAccount { - nonce: Default::default(), - balance: Default::default(), - storage: Default::default(), - code: revert_bytecode.clone(), - }, - ) - }) - .collect(), - ..Default::default() - }, - ethereum: Default::default(), - polkadot_xcm: Default::default(), - assets: Default::default(), - parachain_system: Default::default(), - transaction_payment: Default::default(), - dapp_staking: DappStakingConfig { - reward_portion: vec![ - Permill::from_percent(40), - Permill::from_percent(30), - Permill::from_percent(20), - Permill::from_percent(10), - ], - slot_distribution: vec![ - Permill::from_percent(10), - Permill::from_percent(20), - Permill::from_percent(30), - Permill::from_percent(40), - ], - // percentages below are calulated based on total issuance at the time when dApp staking v3 was launched (8.4B) - tier_thresholds: vec![ - TierThreshold::DynamicPercentage { - percentage: Perbill::from_parts(35_700_000), // 3.57% - minimum_required_percentage: Perbill::from_parts(23_800_000), // 2.38% - }, - TierThreshold::DynamicPercentage { - percentage: Perbill::from_parts(8_900_000), // 0.89% - minimum_required_percentage: Perbill::from_parts(6_000_000), // 0.6% - }, - TierThreshold::DynamicPercentage { - percentage: Perbill::from_parts(2_380_000), // 0.238% - minimum_required_percentage: Perbill::from_parts(1_790_000), // 0.179% - }, - TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(200_000), // 0.02% - }, - ], - slots_per_tier: vec![10, 20, 30, 40], - safeguard: Some(false), - ..Default::default() - }, - inflation: InflationConfig { - params: InflationParameters::default(), - ..Default::default() - }, - oracle_membership: OracleMembershipConfig { - members: vec![ - get_account_id_from_seed::("Alice"), - get_account_id_from_seed::("Bob"), - ] - .try_into() - .expect("Assumption is that at least two members will be allowed."), - ..Default::default() - }, - price_aggregator: PriceAggregatorConfig { - circular_buffer: vec![CurrencyAmount::from_rational(5, 10)] - .try_into() - .expect("Must work since buffer should have at least a single value."), - }, - }; - - serde_json::to_value(&config).expect("Could not build genesis config.") -} - -type AccountPublic = ::Signer; - -/// Helper function to generate an account ID from seed -fn get_account_id_from_seed(seed: &str) -> AccountId -where - AccountPublic: From<::Public>, -{ - AccountPublic::from(get_from_seed::(seed)).into_account() -} diff --git a/bin/collator/src/parachain/chain_spec/mod.rs b/bin/collator/src/parachain/chain_spec/mod.rs index 14a390909..3c2a6a89f 100644 --- a/bin/collator/src/parachain/chain_spec/mod.rs +++ b/bin/collator/src/parachain/chain_spec/mod.rs @@ -16,11 +16,9 @@ // You should have received a copy of the GNU General Public License // along with Astar. If not, see . +use astar_primitives::Block; use sc_chain_spec::ChainSpecExtension; use serde::{Deserialize, Serialize}; -use sp_core::{Pair, Public}; - -use astar_primitives::Block; pub mod astar; pub mod shibuya; @@ -51,10 +49,3 @@ impl Extensions { sc_chain_spec::get_extension(chain_spec.extensions()) } } - -/// Helper function to generate a crypto pair from seed -fn get_from_seed(seed: &str) -> ::Public { - TPublic::Pair::from_string(&format!("//{}", seed), None) - .expect("static values are valid; qed") - .public() -} diff --git a/bin/collator/src/parachain/chain_spec/shibuya.rs b/bin/collator/src/parachain/chain_spec/shibuya.rs index cab9754a5..fa38806c3 100644 --- a/bin/collator/src/parachain/chain_spec/shibuya.rs +++ b/bin/collator/src/parachain/chain_spec/shibuya.rs @@ -18,46 +18,16 @@ //! Shibuya chain specifications. -use cumulus_primitives_core::ParaId; +use super::Extensions; +use astar_primitives::parachain::SHIBUYA_ID; use sc_service::ChainType; -use shibuya_runtime::{ - wasm_binary_unwrap, AccountId, AuraConfig, AuraId, Balance, BalancesConfig, - CollatorSelectionConfig, CommunityCouncilMembershipConfig, CouncilMembershipConfig, - DappStakingConfig, EVMChainIdConfig, EVMConfig, InflationConfig, InflationParameters, - OracleMembershipConfig, ParachainInfoConfig, Precompiles, PriceAggregatorConfig, - RuntimeGenesisConfig, SessionConfig, SessionKeys, Signature, SudoConfig, - TechnicalCommitteeMembershipConfig, TierThreshold, VestingConfig, SBY, -}; -use sp_core::{sr25519, Pair, Public}; - -use astar_primitives::oracle::CurrencyAmount; -use sp_runtime::{ - traits::{IdentifyAccount, Verify}, - Perbill, Permill, -}; - -use super::{get_from_seed, Extensions}; - -const PARA_ID: u32 = 1000; +use shibuya_runtime::{wasm_binary_unwrap, RuntimeGenesisConfig}; /// Specialized `ChainSpec` for Shibuya testnet. pub type ShibuyaChainSpec = sc_service::GenericChainSpec; -/// Gen Shibuya chain specification for given parachain id. +/// Gen Shibuya chain specification. pub fn get_chain_spec() -> ShibuyaChainSpec { - // Alice as default - let sudo_key = get_account_id_from_seed::("Alice"); - let endowned = vec![ - ( - get_account_id_from_seed::("Alice"), - 1_000_000_000 * SBY, - ), - ( - get_account_id_from_seed::("Bob"), - 1_000_000_000 * SBY, - ), - ]; - let mut properties = serde_json::map::Map::new(); properties.insert("tokenSymbol".into(), "SBY".into()); properties.insert("tokenDecimals".into(), 18.into()); @@ -67,195 +37,13 @@ pub fn get_chain_spec() -> ShibuyaChainSpec { Extensions { bad_blocks: Default::default(), relay_chain: "tokyo".into(), - para_id: PARA_ID, + para_id: SHIBUYA_ID, }, ) .with_name("Shibuya Testnet") .with_id("shibuya") .with_chain_type(ChainType::Development) .with_properties(properties) - .with_genesis_config(make_genesis( - endowned.clone(), - sudo_key.clone(), - PARA_ID.into(), - )) + .with_genesis_config(shibuya_runtime::genesis_config::default_config(SHIBUYA_ID)) .build() } - -fn session_keys(aura: AuraId) -> SessionKeys { - SessionKeys { aura } -} - -/// Helper function to create Shibuya RuntimeGenesisConfig. -fn make_genesis( - balances: Vec<(AccountId, Balance)>, - root_key: AccountId, - parachain_id: ParaId, -) -> serde_json::Value { - let authorities = vec![ - ( - get_account_id_from_seed::("Alice"), - get_from_seed::("Alice"), - ), - ( - get_account_id_from_seed::("Bob"), - get_from_seed::("Bob"), - ), - ]; - let accounts: Vec = vec!["Alice", "Bob", "Charlie", "Dave", "Eve"] - .iter() - .map(|s| get_account_id_from_seed::(s)) - .collect(); - - // This is supposed the be the simplest bytecode to revert without returning any data. - // We will pre-deploy it under all of our precompiles to ensure they can be called from - // within contracts. - // (PUSH1 0x00 PUSH1 0x00 REVERT) - let revert_bytecode = vec![0x60, 0x00, 0x60, 0x00, 0xFD]; - - let config = RuntimeGenesisConfig { - system: Default::default(), - sudo: SudoConfig { - key: Some(root_key), - }, - parachain_info: ParachainInfoConfig { - parachain_id, - ..Default::default() - }, - balances: BalancesConfig { balances }, - vesting: VestingConfig { vesting: vec![] }, - session: SessionConfig { - keys: authorities - .iter() - .map(|x| (x.0.clone(), x.0.clone(), session_keys(x.1.clone()))) - .collect::>(), - }, - aura: AuraConfig { - authorities: vec![], - }, - aura_ext: Default::default(), - collator_selection: CollatorSelectionConfig { - desired_candidates: 32, - candidacy_bond: 32_000 * SBY, - invulnerables: authorities.iter().map(|x| x.0.clone()).collect::>(), - }, - evm: EVMConfig { - // We need _some_ code inserted at the precompile address so that - // the evm will actually call the address. - accounts: Precompiles::used_addresses_h160() - .map(|addr| { - ( - addr, - fp_evm::GenesisAccount { - nonce: Default::default(), - balance: Default::default(), - storage: Default::default(), - code: revert_bytecode.clone(), - }, - ) - }) - .collect(), - ..Default::default() - }, - evm_chain_id: EVMChainIdConfig { - chain_id: 0x51, - ..Default::default() - }, - ethereum: Default::default(), - polkadot_xcm: Default::default(), - assets: Default::default(), - parachain_system: Default::default(), - transaction_payment: Default::default(), - dapp_staking: DappStakingConfig { - reward_portion: vec![ - Permill::from_percent(40), - Permill::from_percent(30), - Permill::from_percent(20), - Permill::from_percent(10), - ], - slot_distribution: vec![ - Permill::from_percent(10), - Permill::from_percent(20), - Permill::from_percent(30), - Permill::from_percent(40), - ], - // percentages below are calulated based on a total issuance at the time when dApp staking v3 was launched (147M) - tier_thresholds: vec![ - TierThreshold::DynamicPercentage { - percentage: Perbill::from_parts(20_000), // 0.0020% - minimum_required_percentage: Perbill::from_parts(17_000), // 0.0017% - }, - TierThreshold::DynamicPercentage { - percentage: Perbill::from_parts(13_000), // 0.0013% - minimum_required_percentage: Perbill::from_parts(10_000), // 0.0010% - }, - TierThreshold::DynamicPercentage { - percentage: Perbill::from_parts(5_400), // 0.00054% - minimum_required_percentage: Perbill::from_parts(3_400), // 0.00034% - }, - TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(1_400), // 0.00014% - }, - ], - slots_per_tier: vec![10, 20, 30, 40], - safeguard: Some(false), - ..Default::default() - }, - inflation: InflationConfig { - params: InflationParameters::default(), - ..Default::default() - }, - oracle_membership: OracleMembershipConfig { - members: vec![ - get_account_id_from_seed::("Alice"), - get_account_id_from_seed::("Bob"), - ] - .try_into() - .expect("Assumption is that at least two members will be allowed."), - ..Default::default() - }, - price_aggregator: PriceAggregatorConfig { - circular_buffer: vec![CurrencyAmount::from_rational(5, 10)] - .try_into() - .expect("Must work since buffer should have at least a single value."), - }, - council_membership: CouncilMembershipConfig { - members: accounts - .clone() - .try_into() - .expect("Should support at least 5 members."), - phantom: Default::default(), - }, - technical_committee_membership: TechnicalCommitteeMembershipConfig { - members: accounts[..3] - .to_vec() - .try_into() - .expect("Should support at least 3 members."), - phantom: Default::default(), - }, - community_council_membership: CommunityCouncilMembershipConfig { - members: accounts - .try_into() - .expect("Should support at least 5 members."), - phantom: Default::default(), - }, - council: Default::default(), - technical_committee: Default::default(), - community_council: Default::default(), - democracy: Default::default(), - treasury: Default::default(), - community_treasury: Default::default(), - }; - - serde_json::to_value(&config).expect("Could not build genesis config.") -} - -type AccountPublic = ::Signer; - -/// Helper function to generate an account ID from seed -fn get_account_id_from_seed(seed: &str) -> AccountId -where - AccountPublic: From<::Public>, -{ - AccountPublic::from(get_from_seed::(seed)).into_account() -} diff --git a/bin/collator/src/parachain/chain_spec/shiden.rs b/bin/collator/src/parachain/chain_spec/shiden.rs index a0d77b445..4efc239a2 100644 --- a/bin/collator/src/parachain/chain_spec/shiden.rs +++ b/bin/collator/src/parachain/chain_spec/shiden.rs @@ -18,44 +18,17 @@ //! Shiden chain specifications. -use cumulus_primitives_core::ParaId; +use super::Extensions; +use astar_primitives::parachain::SHIDEN_ID; use sc_service::ChainType; -use shiden_runtime::{ - wasm_binary_unwrap, AccountId, AuraId, Balance, DappStakingConfig, EVMConfig, InflationConfig, - InflationParameters, OracleMembershipConfig, ParachainInfoConfig, Precompiles, - PriceAggregatorConfig, RuntimeGenesisConfig, Signature, TierThreshold, SDN, -}; -use sp_core::{sr25519, Pair, Public}; - -use astar_primitives::oracle::CurrencyAmount; -use sp_runtime::{ - traits::{IdentifyAccount, Verify}, - Perbill, Permill, -}; - -use super::{get_from_seed, Extensions}; - -const PARA_ID: u32 = 2007; +use shiden_runtime::wasm_binary_unwrap; /// Specialized `ChainSpec` for Shiden Network. pub type ShidenChainSpec = sc_service::GenericChainSpec; -/// Gen Shiden chain specification for given parachain id. +/// Gen Shiden chain specification. pub fn get_chain_spec() -> ShidenChainSpec { - // Alice as default - let sudo_key = get_account_id_from_seed::("Alice"); - let endowned = vec![ - ( - get_account_id_from_seed::("Alice"), - 1_000_000_000 * SDN, - ), - ( - get_account_id_from_seed::("Bob"), - 1_000_000_000 * SDN, - ), - ]; - let mut properties = serde_json::map::Map::new(); properties.insert("tokenSymbol".into(), "SDN".into()); properties.insert("tokenDecimals".into(), 18.into()); @@ -65,161 +38,13 @@ pub fn get_chain_spec() -> ShidenChainSpec { Extensions { bad_blocks: Default::default(), relay_chain: "tokyo".into(), - para_id: PARA_ID, + para_id: SHIDEN_ID, }, ) .with_name("Shiden Testnet") .with_id("shiden") .with_chain_type(ChainType::Development) .with_properties(properties) - .with_genesis_config(make_genesis( - endowned.clone(), - sudo_key.clone(), - PARA_ID.into(), - )) + .with_genesis_config(shiden_runtime::genesis_config::default_config(SHIDEN_ID)) .build() } - -fn session_keys(aura: AuraId) -> shiden_runtime::SessionKeys { - shiden_runtime::SessionKeys { aura } -} - -/// Helper function to create RuntimeGenesisConfig. -fn make_genesis( - balances: Vec<(AccountId, Balance)>, - root_key: AccountId, - parachain_id: ParaId, -) -> serde_json::Value { - let authorities = vec![ - ( - get_account_id_from_seed::("Alice"), - get_from_seed::("Alice"), - ), - ( - get_account_id_from_seed::("Bob"), - get_from_seed::("Bob"), - ), - ]; - - // This is supposed the be the simplest bytecode to revert without returning any data. - // We will pre-deploy it under all of our precompiles to ensure they can be called from - // within contracts. - // (PUSH1 0x00 PUSH1 0x00 REVERT) - let revert_bytecode = vec![0x60, 0x00, 0x60, 0x00, 0xFD]; - - let config = RuntimeGenesisConfig { - system: Default::default(), - sudo: shiden_runtime::SudoConfig { - key: Some(root_key), - }, - parachain_info: ParachainInfoConfig { - parachain_id, - ..Default::default() - }, - balances: shiden_runtime::BalancesConfig { balances }, - vesting: shiden_runtime::VestingConfig { vesting: vec![] }, - session: shiden_runtime::SessionConfig { - keys: authorities - .iter() - .map(|x| (x.0.clone(), x.0.clone(), session_keys(x.1.clone()))) - .collect::>(), - }, - aura: shiden_runtime::AuraConfig { - authorities: vec![], - }, - aura_ext: Default::default(), - collator_selection: shiden_runtime::CollatorSelectionConfig { - desired_candidates: 32, - candidacy_bond: 32_000 * SDN, - invulnerables: authorities.iter().map(|x| x.0.clone()).collect::>(), - }, - evm: EVMConfig { - // We need _some_ code inserted at the precompile address so that - // the evm will actually call the address. - accounts: Precompiles::used_addresses_h160() - .map(|addr| { - ( - addr, - fp_evm::GenesisAccount { - nonce: Default::default(), - balance: Default::default(), - storage: Default::default(), - code: revert_bytecode.clone(), - }, - ) - }) - .collect(), - ..Default::default() - }, - ethereum: Default::default(), - polkadot_xcm: Default::default(), - assets: Default::default(), - parachain_system: Default::default(), - transaction_payment: Default::default(), - dapp_staking: DappStakingConfig { - reward_portion: vec![ - Permill::from_percent(40), - Permill::from_percent(30), - Permill::from_percent(20), - Permill::from_percent(10), - ], - slot_distribution: vec![ - Permill::from_percent(10), - Permill::from_percent(20), - Permill::from_percent(30), - Permill::from_percent(40), - ], - // percentages below are calulated based on a total issuance at the time when dApp staking v3 was launched (84.3M) - tier_thresholds: vec![ - TierThreshold::DynamicPercentage { - percentage: Perbill::from_parts(35_700_000), // 3.57% - minimum_required_percentage: Perbill::from_parts(23_800_000), // 2.38% - }, - TierThreshold::DynamicPercentage { - percentage: Perbill::from_parts(8_900_000), // 0.89% - minimum_required_percentage: Perbill::from_parts(6_000_000), // 0.6% - }, - TierThreshold::DynamicPercentage { - percentage: Perbill::from_parts(2_380_000), // 0.238% - minimum_required_percentage: Perbill::from_parts(1_790_000), // 0.179% - }, - TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(600_000), // 0.06% - }, - ], - slots_per_tier: vec![10, 20, 30, 40], - safeguard: Some(false), - ..Default::default() - }, - inflation: InflationConfig { - params: InflationParameters::default(), - ..Default::default() - }, - oracle_membership: OracleMembershipConfig { - members: vec![ - get_account_id_from_seed::("Alice"), - get_account_id_from_seed::("Bob"), - ] - .try_into() - .expect("Assumption is that at least two members will be allowed."), - ..Default::default() - }, - price_aggregator: PriceAggregatorConfig { - circular_buffer: vec![CurrencyAmount::from_rational(5, 10)] - .try_into() - .expect("Must work since buffer should have at least a single value."), - }, - }; - - serde_json::to_value(&config).expect("Could not build genesis config.") -} - -type AccountPublic = ::Signer; - -/// Helper function to generate an account ID from seed -fn get_account_id_from_seed(seed: &str) -> AccountId -where - AccountPublic: From<::Public>, -{ - AccountPublic::from(get_from_seed::(seed)).into_account() -} diff --git a/pallets/dapp-staking/src/lib.rs b/pallets/dapp-staking/src/lib.rs index 63f061602..a8dc283af 100644 --- a/pallets/dapp-staking/src/lib.rs +++ b/pallets/dapp-staking/src/lib.rs @@ -509,6 +509,7 @@ pub mod pallet { pub tier_thresholds: Vec, pub slots_per_tier: Vec, pub safeguard: Option, + #[serde(skip)] pub _config: PhantomData, } diff --git a/pallets/inflation/src/lib.rs b/pallets/inflation/src/lib.rs index 72a745c87..25fa4bd50 100644 --- a/pallets/inflation/src/lib.rs +++ b/pallets/inflation/src/lib.rs @@ -201,6 +201,7 @@ pub mod pallet { #[derive(DefaultNoBound)] pub struct GenesisConfig { pub params: InflationParameters, + #[serde(skip)] pub _config: sp_std::marker::PhantomData, } diff --git a/primitives/src/genesis.rs b/primitives/src/genesis.rs new file mode 100644 index 000000000..a4b25a3ae --- /dev/null +++ b/primitives/src/genesis.rs @@ -0,0 +1,75 @@ +// This file is part of Astar. + +// Copyright (C) Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar 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. + +// Astar 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 Astar. If not, see . + +use scale_info::prelude::format; +use sp_core::{Pair, Public}; +use sp_runtime::traits::{IdentifyAccount, Verify}; + +use super::{AccountId, Signature}; + +type AccountPublic = ::Signer; + +/// Helper function to generate a crypto pair from seed +pub fn get_from_seed(seed: &str) -> ::Public { + TPublic::Pair::from_string(&format!("//{}", seed), None) + .expect("static values are valid; qed") + .public() +} + +/// Helper function to generate an account ID from seed +pub fn get_account_id_from_seed(seed: &str) -> AccountId +where + AccountPublic: From<::Public>, +{ + AccountPublic::from(get_from_seed::(seed)).into_account() +} + +/// Helper struct for genesis configuration. +#[derive(Clone, PartialEq, Eq)] +pub struct GenesisAccount { + /// Account ID + pub account_id: AccountId, + /// Public key + pub pub_key: ::Public, +} + +impl GenesisAccount +where + AccountPublic: From<::Public>, +{ + /// Create a new genesis account from a seed. + pub fn from_seed(seed: &str) -> Self { + let pub_key = get_from_seed::(seed); + let account_id = AccountPublic::from(pub_key.clone()).into_account(); + + Self { + account_id, + pub_key, + } + } + + /// Return the `account Id` (address) of the genesis account. + pub fn account_id(&self) -> AccountId { + self.account_id.clone() + } + + /// Return the `public key` of the genesis account. + pub fn pub_key(&self) -> ::Public { + self.pub_key.clone() + } +} diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index c8ce3d460..e67d8059b 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -44,6 +44,12 @@ pub mod oracle; /// Governance primitives. pub mod governance; +/// Genesis generation helpers & primitives. +pub mod genesis; + +/// Parachain related constants. +pub mod parachain; + /// Benchmark primitives #[cfg(feature = "runtime-benchmarks")] pub mod benchmarks; diff --git a/primitives/src/parachain.rs b/primitives/src/parachain.rs new file mode 100644 index 000000000..04dc95676 --- /dev/null +++ b/primitives/src/parachain.rs @@ -0,0 +1,24 @@ +// This file is part of Astar. + +// Copyright (C) Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar 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. + +// Astar 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 Astar. If not, see . + +/// Shibuya parachain Id used in production. +pub const SHIBUYA_ID: u32 = 1000; +/// Astar parachain Id used in production. +pub const ASTAR_ID: u32 = 2006; +/// Shiden parachain Id used in production. +pub const SHIDEN_ID: u32 = 2007; diff --git a/runtime/astar/Cargo.toml b/runtime/astar/Cargo.toml index 1c375c427..c8961aa07 100644 --- a/runtime/astar/Cargo.toml +++ b/runtime/astar/Cargo.toml @@ -14,9 +14,11 @@ log = { workspace = true, optional = true } num_enum = { workspace = true } parity-scale-codec = { workspace = true } scale-info = { workspace = true } +serde_json = { workspace = true } smallvec = { workspace = true } # primitives +fp-evm = { workspace = true } fp-rpc = { workspace = true } fp-self-contained = { workspace = true } sp-api = { workspace = true } @@ -138,8 +140,10 @@ substrate-wasm-builder = { workspace = true, optional = true } default = ["std"] std = [ "parity-scale-codec/std", + "serde_json/std", "sp-genesis-builder/std", "fp-rpc/std", + "fp-evm/std", "fp-self-contained/std", "sp-std/std", "sp-api/std", diff --git a/runtime/astar/src/genesis_config.rs b/runtime/astar/src/genesis_config.rs new file mode 100644 index 000000000..5e45a694e --- /dev/null +++ b/runtime/astar/src/genesis_config.rs @@ -0,0 +1,161 @@ +// This file is part of Astar. + +// Copyright (C) Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar 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. + +// Astar 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 Astar. If not, see . + +use crate::*; +use astar_primitives::{evm::EVM_REVERT_CODE, genesis::GenesisAccount, parachain::ASTAR_ID}; + +/// Provides the JSON representation of predefined genesis config for given `id`. +pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option> { + let genesis = match id.try_into() { + Ok("development") => default_config(ASTAR_ID), + _ => return None, + }; + Some( + serde_json::to_string(&genesis) + .expect("serialization to json is expected to work. qed.") + .into_bytes(), + ) +} + +/// Get the default genesis config for the Astar runtime. +pub fn default_config(para_id: u32) -> serde_json::Value { + let alice = GenesisAccount::::from_seed("Alice"); + let bob = GenesisAccount::::from_seed("Bob"); + + let balances: Vec<(AccountId, Balance)> = vec![ + (alice.account_id(), 1_000_000_000_000 * ASTR), + (bob.account_id(), 1_000_000_000_000 * ASTR), + ( + TreasuryPalletId::get().into_account_truncating(), + 1_000_000_000 * ASTR, + ), + ]; + + let authorities = vec![&alice, &bob]; + + let config = RuntimeGenesisConfig { + system: Default::default(), + sudo: SudoConfig { + key: Some(alice.account_id()), + }, + parachain_info: ParachainInfoConfig { + parachain_id: para_id.into(), + ..Default::default() + }, + balances: BalancesConfig { balances }, + vesting: VestingConfig { vesting: vec![] }, + session: SessionConfig { + keys: authorities + .iter() + .map(|x| { + ( + x.account_id(), + x.account_id(), + SessionKeys { + aura: x.pub_key().into(), + }, + ) + }) + .collect::>(), + }, + aura: AuraConfig { + authorities: vec![], + }, + aura_ext: Default::default(), + collator_selection: CollatorSelectionConfig { + desired_candidates: 32, + candidacy_bond: 3_200_000 * ASTR, + invulnerables: authorities + .iter() + .map(|x| x.account_id()) + .collect::>(), + }, + evm: EVMConfig { + // We need _some_ code inserted at the precompile address so that + // the evm will actually call the address. + accounts: Precompiles::used_addresses_h160() + .map(|addr| { + ( + addr, + fp_evm::GenesisAccount { + nonce: Default::default(), + balance: Default::default(), + storage: Default::default(), + code: EVM_REVERT_CODE.into(), + }, + ) + }) + .collect(), + ..Default::default() + }, + ethereum: Default::default(), + polkadot_xcm: Default::default(), + assets: Default::default(), + parachain_system: Default::default(), + transaction_payment: Default::default(), + dapp_staking: DappStakingConfig { + reward_portion: vec![ + Permill::from_percent(40), + Permill::from_percent(30), + Permill::from_percent(20), + Permill::from_percent(10), + ], + slot_distribution: vec![ + Permill::from_percent(10), + Permill::from_percent(20), + Permill::from_percent(30), + Permill::from_percent(40), + ], + // percentages below are calculated based on a total issuance at the time when dApp staking v3 was launched (84.3M) + tier_thresholds: vec![ + TierThreshold::DynamicPercentage { + percentage: Perbill::from_parts(35_700_000), // 3.57% + minimum_required_percentage: Perbill::from_parts(23_800_000), // 2.38% + }, + TierThreshold::DynamicPercentage { + percentage: Perbill::from_parts(8_900_000), // 0.89% + minimum_required_percentage: Perbill::from_parts(6_000_000), // 0.6% + }, + TierThreshold::DynamicPercentage { + percentage: Perbill::from_parts(2_380_000), // 0.238% + minimum_required_percentage: Perbill::from_parts(1_790_000), // 0.179% + }, + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(600_000), // 0.06% + }, + ], + slots_per_tier: vec![10, 20, 30, 40], + safeguard: Some(false), + ..Default::default() + }, + inflation: Default::default(), + oracle_membership: OracleMembershipConfig { + members: vec![alice.account_id(), bob.account_id()] + .try_into() + .expect("Assumption is that at least two members will be allowed."), + ..Default::default() + }, + price_aggregator: PriceAggregatorConfig { + circular_buffer: vec![CurrencyAmount::from_rational(5, 10)] + .try_into() + .expect("Must work since buffer should have at least a single value."), + }, + }; + + serde_json::to_value(&config).expect("Could not build genesis config.") +} diff --git a/runtime/astar/src/lib.rs b/runtime/astar/src/lib.rs index 07b98fd20..400f12004 100644 --- a/runtime/astar/src/lib.rs +++ b/runtime/astar/src/lib.rs @@ -26,8 +26,7 @@ use cumulus_primitives_core::AggregateMessageOrigin; use frame_support::{ construct_runtime, dispatch::DispatchClass, - genesis_builder_helper::{build_state, get_preset}, - parameter_types, + genesis_builder_helper, parameter_types, traits::{ fungible::{Balanced, Credit}, AsEnsureOriginWithArg, ConstBool, ConstU32, ConstU64, Contains, FindAuthor, Get, Imbalance, @@ -56,7 +55,7 @@ use pallet_transaction_payment::{ use parity_scale_codec::{Compact, Decode, Encode, MaxEncodedLen}; use polkadot_runtime_common::BlockHashCount; use sp_api::impl_runtime_apis; -use sp_core::{OpaqueMetadata, H160, H256, U256}; +use sp_core::{sr25519, OpaqueMetadata, H160, H256, U256}; use sp_inherents::{CheckInherentsResult, InherentData}; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, @@ -80,7 +79,7 @@ use astar_primitives::{ PeriodNumber, RankedTier, SmartContract, StandardTierSlots, }, evm::EvmRevertCodeHandler, - oracle::{CurrencyId, DummyCombineData, Price}, + oracle::{CurrencyAmount, CurrencyId, DummyCombineData, Price}, xcm::AssetLocationIdConverter, Address, AssetId, BlockNumber, Hash, Header, Nonce, UnfreezeChainOnFailedMigration, }; @@ -103,6 +102,7 @@ pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::BuildStorage; mod chain_extensions; +pub mod genesis_config; mod precompiles; mod weights; mod xcm_config; @@ -1980,15 +1980,17 @@ impl_runtime_apis! { impl sp_genesis_builder::GenesisBuilder for Runtime { fn build_state(config: Vec) -> sp_genesis_builder::Result { - build_state::(config) + genesis_builder_helper::build_state::(config) } fn get_preset(id: &Option) -> Option> { - get_preset::(id, |_| None) + genesis_builder_helper::get_preset::(id, &genesis_config::get_preset) } fn preset_names() -> Vec { - vec![] + vec![ + sp_genesis_builder::PresetId::from("development"), + ] } } diff --git a/runtime/local/Cargo.toml b/runtime/local/Cargo.toml index d232ae951..7e00f2eaa 100644 --- a/runtime/local/Cargo.toml +++ b/runtime/local/Cargo.toml @@ -12,8 +12,10 @@ log = { workspace = true, optional = true } num_enum = { workspace = true } parity-scale-codec = { workspace = true } scale-info = { workspace = true } +serde_json = { workspace = true } smallvec = { workspace = true } +fp-evm = { workspace = true } fp-rpc = { workspace = true } fp-self-contained = { workspace = true } frame-executive = { workspace = true } @@ -110,7 +112,9 @@ substrate-wasm-builder = { workspace = true, optional = true } default = ["std"] std = [ "parity-scale-codec/std", + "serde_json/std", "fp-rpc/std", + "fp-evm/std", "fp-self-contained/std", "frame-executive/std", "frame-support/std", diff --git a/runtime/local/src/genesis_config.rs b/runtime/local/src/genesis_config.rs new file mode 100644 index 000000000..621efc7e5 --- /dev/null +++ b/runtime/local/src/genesis_config.rs @@ -0,0 +1,175 @@ +// This file is part of Astar. + +// Copyright (C) Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar 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. + +// Astar 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 Astar. If not, see . + +use crate::*; +use astar_primitives::{ + evm::EVM_REVERT_CODE, + genesis::{get_from_seed, GenesisAccount}, +}; + +/// Provides the JSON representation of predefined genesis config for given `id`. +pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option> { + let genesis = match id.try_into() { + Ok("development") => default_config(), + _ => return None, + }; + Some( + serde_json::to_string(&genesis) + .expect("serialization to json is expected to work. qed.") + .into_bytes(), + ) +} + +/// Get the default genesis config for the local runtime. +pub fn default_config() -> serde_json::Value { + let alice = GenesisAccount::::from_seed("Alice"); + let bob = GenesisAccount::::from_seed("Bob"); + let charlie = GenesisAccount::::from_seed("Charlie"); + let dave = GenesisAccount::::from_seed("Dave"); + let eve = GenesisAccount::::from_seed("Eve"); + + let balances: Vec<(AccountId, Balance)> = vec![ + (alice.account_id(), 1_000_000_000 * AST), + (bob.account_id(), 1_000_000_000 * AST), + ( + TreasuryPalletId::get().into_account_truncating(), + 1_000_000_000 * AST, + ), + ( + CommunityTreasuryPalletId::get().into_account_truncating(), + 1_000_000_000 * AST, + ), + ]; + + let accounts = vec![&alice, &bob, &charlie, &dave, &eve] + .iter() + .map(|x| x.account_id()) + .collect::>(); + + let config = RuntimeGenesisConfig { + system: Default::default(), + sudo: SudoConfig { + key: Some(alice.account_id()), + }, + balances: BalancesConfig { balances }, + vesting: VestingConfig { vesting: vec![] }, + aura: AuraConfig { + authorities: vec![get_from_seed::("Alice")], + }, + grandpa: GrandpaConfig { + authorities: vec![(get_from_seed::("Alice"), 1)], + ..Default::default() + }, + evm: EVMConfig { + // We need _some_ code inserted at the precompile address so that + // the evm will actually call the address. + accounts: Precompiles::used_addresses_h160() + .map(|addr| { + ( + addr, + fp_evm::GenesisAccount { + nonce: Default::default(), + balance: Default::default(), + storage: Default::default(), + code: EVM_REVERT_CODE.into(), + }, + ) + }) + .collect(), + ..Default::default() + }, + ethereum: Default::default(), + assets: Default::default(), + transaction_payment: Default::default(), + dapp_staking: DappStakingConfig { + reward_portion: vec![ + Permill::from_percent(40), + Permill::from_percent(30), + Permill::from_percent(20), + Permill::from_percent(10), + ], + slot_distribution: vec![ + Permill::from_percent(10), + Permill::from_percent(20), + Permill::from_percent(30), + Permill::from_percent(40), + ], + tier_thresholds: vec![ + TierThreshold::DynamicPercentage { + percentage: Perbill::from_parts(35_700_000), // 3.57% + minimum_required_percentage: Perbill::from_parts(23_800_000), // 2.38% + }, + TierThreshold::DynamicPercentage { + percentage: Perbill::from_parts(8_900_000), // 0.89% + minimum_required_percentage: Perbill::from_parts(6_000_000), // 0.6% + }, + TierThreshold::DynamicPercentage { + percentage: Perbill::from_parts(23_800_000), // 2.38% + minimum_required_percentage: Perbill::from_parts(17_900_000), // 1.79% + }, + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(600_000), // 0.06% + }, + ], + slots_per_tier: vec![10, 20, 30, 40], + safeguard: Some(false), + ..Default::default() + }, + inflation: InflationConfig { + params: InflationParameters { + max_inflation_rate: Perquintill::from_percent(7), + treasury_part: Perquintill::from_percent(5), + collators_part: Perquintill::from_percent(3), + dapps_part: Perquintill::from_percent(20), + base_stakers_part: Perquintill::from_percent(25), + adjustable_stakers_part: Perquintill::from_percent(35), + bonus_part: Perquintill::from_percent(12), + ideal_staking_rate: Perquintill::from_percent(50), + }, + ..Default::default() + }, + council_membership: CouncilMembershipConfig { + members: accounts + .clone() + .try_into() + .expect("Should support at least 5 members."), + phantom: Default::default(), + }, + technical_committee_membership: TechnicalCommitteeMembershipConfig { + members: accounts[..3] + .to_vec() + .try_into() + .expect("Should support at least 3 members."), + phantom: Default::default(), + }, + community_council_membership: CommunityCouncilMembershipConfig { + members: accounts + .try_into() + .expect("Should support at least 5 members."), + phantom: Default::default(), + }, + council: Default::default(), + technical_committee: Default::default(), + community_council: Default::default(), + democracy: Default::default(), + treasury: Default::default(), + community_treasury: Default::default(), + }; + + serde_json::to_value(&config).expect("Could not build genesis config.") +} diff --git a/runtime/local/src/lib.rs b/runtime/local/src/lib.rs index b610fe532..3326113f7 100644 --- a/runtime/local/src/lib.rs +++ b/runtime/local/src/lib.rs @@ -25,9 +25,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); use frame_support::{ - construct_runtime, - genesis_builder_helper::{build_state, get_preset}, - parameter_types, + construct_runtime, genesis_builder_helper, parameter_types, traits::{ fungible::{Balanced, Credit, HoldConsideration}, tokens::{PayFromAccount, UnityAssetBalanceConversion}, @@ -52,7 +50,7 @@ use pallet_grandpa::{fg_primitives, AuthorityList as GrandpaAuthorityList}; use pallet_transaction_payment::{FungibleAdapter, Multiplier, TargetedFeeAdjustment}; use parity_scale_codec::{Compact, Decode, Encode, MaxEncodedLen}; use sp_api::impl_runtime_apis; -use sp_core::{crypto::KeyTypeId, ConstBool, OpaqueMetadata, H160, H256, U256}; +use sp_core::{crypto::KeyTypeId, sr25519, ConstBool, OpaqueMetadata, H160, H256, U256}; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{ @@ -134,6 +132,7 @@ pub type Precompiles = LocalPrecompiles; mod chain_extensions; pub use chain_extensions::LocalChainExtensions; +pub mod genesis_config; mod weights; /// Constant values used within the runtime. @@ -357,8 +356,8 @@ impl pallet_assets::Config for Runtime { // These values are based on the Astar 2.0 Tokenomics Modeling report. parameter_types! { - pub const TransactionLengthFeeFactor: Balance = 23_500_000_000_000; // 0.000_023_500_000_000_000 SBY per byte - pub const WeightFeeFactor: Balance = 30_855_000_000_000_000; // Around 0.03 SBY per unit of ref time. + pub const TransactionLengthFeeFactor: Balance = 23_500_000_000_000; // 0.000_023_500_000_000_000 AST per byte + pub const WeightFeeFactor: Balance = 30_855_000_000_000_000; // Around 0.03 AST per unit of ref time. pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25); pub const OperationalFeeMultiplier: u8 = 5; pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(000_015, 1_000_000); // 0.000_015 @@ -1801,15 +1800,17 @@ impl_runtime_apis! { impl sp_genesis_builder::GenesisBuilder for Runtime { fn build_state(config: Vec) -> sp_genesis_builder::Result { - build_state::(config) + genesis_builder_helper::build_state::(config) } fn get_preset(id: &Option) -> Option> { - get_preset::(id, |_| None) + genesis_builder_helper::get_preset::(id, &genesis_config::get_preset) } fn preset_names() -> Vec { - vec![] + vec![ + sp_genesis_builder::PresetId::from("development"), + ] } } diff --git a/runtime/shibuya/Cargo.toml b/runtime/shibuya/Cargo.toml index 5697b8756..967349c82 100644 --- a/runtime/shibuya/Cargo.toml +++ b/runtime/shibuya/Cargo.toml @@ -14,9 +14,11 @@ log = { workspace = true, optional = true } num_enum = { workspace = true } parity-scale-codec = { workspace = true } scale-info = { workspace = true } +serde_json = { workspace = true } smallvec = { workspace = true } # primitives +fp-evm = { workspace = true } fp-rpc = { workspace = true } fp-self-contained = { workspace = true } sp-api = { workspace = true } @@ -151,7 +153,9 @@ substrate-wasm-builder = { workspace = true, optional = true } default = ["std"] std = [ "parity-scale-codec/std", + "serde_json/std", "fp-rpc/std", + "fp-evm/std", "fp-self-contained/std", "sp-std/std", "sp-api/std", diff --git a/runtime/shibuya/src/genesis_config.rs b/runtime/shibuya/src/genesis_config.rs new file mode 100644 index 000000000..1b6ce2db9 --- /dev/null +++ b/runtime/shibuya/src/genesis_config.rs @@ -0,0 +1,202 @@ +// This file is part of Astar. + +// Copyright (C) Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar 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. + +// Astar 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 Astar. If not, see . + +use crate::*; +use astar_primitives::{evm::EVM_REVERT_CODE, genesis::GenesisAccount, parachain::SHIBUYA_ID}; + +/// Provides the JSON representation of predefined genesis config for given `id`. +pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option> { + let genesis = match id.try_into() { + Ok("development") => default_config(SHIBUYA_ID), + _ => return None, + }; + Some( + serde_json::to_string(&genesis) + .expect("serialization to json is expected to work. qed.") + .into_bytes(), + ) +} + +/// Get the default genesis config for the Shibuya runtime. +pub fn default_config(para_id: u32) -> serde_json::Value { + let alice = GenesisAccount::::from_seed("Alice"); + let bob = GenesisAccount::::from_seed("Bob"); + let charlie = GenesisAccount::::from_seed("Charlie"); + let dave = GenesisAccount::::from_seed("Dave"); + let eve = GenesisAccount::::from_seed("Eve"); + + let balances: Vec<(AccountId, Balance)> = vec![ + (alice.account_id(), 1_000_000_000 * SBY), + (bob.account_id(), 1_000_000_000 * SBY), + ( + TreasuryPalletId::get().into_account_truncating(), + 1_000_000_000 * SBY, + ), + ( + CommunityTreasuryPalletId::get().into_account_truncating(), + 1_000_000_000 * SBY, + ), + ]; + + let authorities = vec![&alice, &bob]; + let accounts = vec![&alice, &bob, &charlie, &dave, &eve] + .iter() + .map(|x| x.account_id()) + .collect::>(); + + let config = RuntimeGenesisConfig { + system: Default::default(), + sudo: SudoConfig { + key: Some(alice.account_id()), + }, + parachain_info: ParachainInfoConfig { + parachain_id: para_id.into(), + ..Default::default() + }, + balances: BalancesConfig { balances }, + vesting: VestingConfig { vesting: vec![] }, + session: SessionConfig { + keys: authorities + .iter() + .map(|x| { + ( + x.account_id(), + x.account_id(), + SessionKeys { + aura: x.pub_key().into(), + }, + ) + }) + .collect::>(), + }, + aura: AuraConfig { + authorities: vec![], + }, + aura_ext: Default::default(), + collator_selection: CollatorSelectionConfig { + desired_candidates: 32, + candidacy_bond: 32_000 * SBY, + invulnerables: authorities + .iter() + .map(|x| x.account_id()) + .collect::>(), + }, + evm: EVMConfig { + // We need _some_ code inserted at the precompile address so that + // the evm will actually call the address. + accounts: Precompiles::used_addresses_h160() + .map(|addr| { + ( + addr, + fp_evm::GenesisAccount { + nonce: Default::default(), + balance: Default::default(), + storage: Default::default(), + code: EVM_REVERT_CODE.into(), + }, + ) + }) + .collect(), + ..Default::default() + }, + evm_chain_id: EVMChainIdConfig { + chain_id: 0x51, + ..Default::default() + }, + ethereum: Default::default(), + polkadot_xcm: Default::default(), + assets: Default::default(), + parachain_system: Default::default(), + transaction_payment: Default::default(), + dapp_staking: DappStakingConfig { + reward_portion: vec![ + Permill::from_percent(40), + Permill::from_percent(30), + Permill::from_percent(20), + Permill::from_percent(10), + ], + slot_distribution: vec![ + Permill::from_percent(10), + Permill::from_percent(20), + Permill::from_percent(30), + Permill::from_percent(40), + ], + // percentages below are calulated based on a total issuance at the time when dApp staking v3 was launched (147M) + tier_thresholds: vec![ + TierThreshold::DynamicPercentage { + percentage: Perbill::from_parts(20_000), // 0.0020% + minimum_required_percentage: Perbill::from_parts(17_000), // 0.0017% + }, + TierThreshold::DynamicPercentage { + percentage: Perbill::from_parts(13_000), // 0.0013% + minimum_required_percentage: Perbill::from_parts(10_000), // 0.0010% + }, + TierThreshold::DynamicPercentage { + percentage: Perbill::from_parts(5_400), // 0.00054% + minimum_required_percentage: Perbill::from_parts(3_400), // 0.00034% + }, + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(1_400), // 0.00014% + }, + ], + slots_per_tier: vec![10, 20, 30, 40], + safeguard: Some(false), + ..Default::default() + }, + inflation: Default::default(), + oracle_membership: OracleMembershipConfig { + members: vec![alice.account_id(), bob.account_id()] + .try_into() + .expect("Assumption is that at least two members will be allowed."), + ..Default::default() + }, + price_aggregator: PriceAggregatorConfig { + circular_buffer: vec![CurrencyAmount::from_rational(5, 10)] + .try_into() + .expect("Must work since buffer should have at least a single value."), + }, + council_membership: CouncilMembershipConfig { + members: accounts + .clone() + .try_into() + .expect("Should support at least 5 members."), + phantom: Default::default(), + }, + technical_committee_membership: TechnicalCommitteeMembershipConfig { + members: accounts[..3] + .to_vec() + .try_into() + .expect("Should support at least 3 members."), + phantom: Default::default(), + }, + community_council_membership: CommunityCouncilMembershipConfig { + members: accounts + .try_into() + .expect("Should support at least 5 members."), + phantom: Default::default(), + }, + council: Default::default(), + technical_committee: Default::default(), + community_council: Default::default(), + democracy: Default::default(), + treasury: Default::default(), + community_treasury: Default::default(), + }; + + serde_json::to_value(&config).expect("Could not build genesis config.") +} diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index b9741072f..0c4ff317d 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -26,8 +26,7 @@ use cumulus_primitives_core::AggregateMessageOrigin; use frame_support::{ construct_runtime, dispatch::DispatchClass, - genesis_builder_helper::{build_state, get_preset}, - parameter_types, + genesis_builder_helper, parameter_types, traits::{ fungible::{Balanced, Credit, HoldConsideration}, tokens::{PayFromAccount, UnityAssetBalanceConversion}, @@ -57,7 +56,7 @@ use pallet_transaction_payment::{ use parity_scale_codec::{Compact, Decode, Encode, MaxEncodedLen}; use polkadot_runtime_common::BlockHashCount; use sp_api::impl_runtime_apis; -use sp_core::{OpaqueMetadata, H160, H256, U256}; +use sp_core::{sr25519, OpaqueMetadata, H160, H256, U256}; use sp_inherents::{CheckInherentsResult, InherentData}; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, @@ -90,7 +89,7 @@ use astar_primitives::{ MainCouncilMembershipInst, MainTreasuryInst, OracleMembershipInst, TechnicalCommitteeCollectiveInst, TechnicalCommitteeMembershipInst, }, - oracle::{CurrencyId, DummyCombineData, Price}, + oracle::{CurrencyAmount, CurrencyId, DummyCombineData, Price}, xcm::AssetLocationIdConverter, Address, AssetId, BlockNumber, Hash, Header, Nonce, UnfreezeChainOnFailedMigration, }; @@ -115,6 +114,7 @@ pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::BuildStorage; mod chain_extensions; +pub mod genesis_config; mod precompiles; mod weights; mod xcm_config; @@ -2326,15 +2326,17 @@ impl_runtime_apis! { impl sp_genesis_builder::GenesisBuilder for Runtime { fn build_state(config: Vec) -> sp_genesis_builder::Result { - build_state::(config) + genesis_builder_helper::build_state::(config) } fn get_preset(id: &Option) -> Option> { - get_preset::(id, |_| None) + genesis_builder_helper::get_preset::(id, &genesis_config::get_preset) } fn preset_names() -> Vec { - vec![] + vec![ + sp_genesis_builder::PresetId::from("development"), + ] } } diff --git a/runtime/shiden/Cargo.toml b/runtime/shiden/Cargo.toml index 6bcad447c..cc11dde64 100644 --- a/runtime/shiden/Cargo.toml +++ b/runtime/shiden/Cargo.toml @@ -14,9 +14,11 @@ log = { workspace = true, optional = true } num_enum = { workspace = true } parity-scale-codec = { workspace = true } scale-info = { workspace = true } +serde_json = { workspace = true } smallvec = { workspace = true } # primitives +fp-evm = { workspace = true } fp-rpc = { workspace = true } fp-self-contained = { workspace = true } @@ -141,8 +143,10 @@ substrate-wasm-builder = { workspace = true, optional = true } default = ["std"] std = [ "parity-scale-codec/std", + "serde_json/std", "fp-rpc/std", "fp-self-contained/std", + "fp-evm/std", "sp-std/std", "sp-api/std", "sp-core/std", @@ -241,6 +245,7 @@ std = [ "scale-info/std", ] runtime-benchmarks = [ + "log", "frame-benchmarking", "frame-support/runtime-benchmarks", "frame-system-benchmarking/runtime-benchmarks", diff --git a/runtime/shiden/src/genesis_config.rs b/runtime/shiden/src/genesis_config.rs new file mode 100644 index 000000000..1e72dae59 --- /dev/null +++ b/runtime/shiden/src/genesis_config.rs @@ -0,0 +1,161 @@ +// This file is part of Astar. + +// Copyright (C) Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar 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. + +// Astar 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 Astar. If not, see . + +use crate::*; +use astar_primitives::{evm::EVM_REVERT_CODE, genesis::GenesisAccount, parachain::SHIDEN_ID}; + +/// Provides the JSON representation of predefined genesis config for given `id`. +pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option> { + let genesis = match id.try_into() { + Ok("development") => default_config(SHIDEN_ID), + _ => return None, + }; + Some( + serde_json::to_string(&genesis) + .expect("serialization to json is expected to work. qed.") + .into_bytes(), + ) +} + +/// Get the default genesis config for the Shiden runtime. +pub fn default_config(para_id: u32) -> serde_json::Value { + let alice = GenesisAccount::::from_seed("Alice"); + let bob = GenesisAccount::::from_seed("Bob"); + + let balances: Vec<(AccountId, Balance)> = vec![ + (alice.account_id(), 1_000_000_000_000 * SDN), + (bob.account_id(), 1_000_000_000_000 * SDN), + ( + TreasuryPalletId::get().into_account_truncating(), + 1_000_000_000 * SDN, + ), + ]; + + let authorities = vec![&alice, &bob]; + + let config = RuntimeGenesisConfig { + system: Default::default(), + sudo: SudoConfig { + key: Some(alice.account_id()), + }, + parachain_info: ParachainInfoConfig { + parachain_id: para_id.into(), + ..Default::default() + }, + balances: BalancesConfig { balances }, + vesting: VestingConfig { vesting: vec![] }, + session: SessionConfig { + keys: authorities + .iter() + .map(|x| { + ( + x.account_id(), + x.account_id(), + SessionKeys { + aura: x.pub_key().into(), + }, + ) + }) + .collect::>(), + }, + aura: AuraConfig { + authorities: vec![], + }, + aura_ext: Default::default(), + collator_selection: CollatorSelectionConfig { + desired_candidates: 32, + candidacy_bond: 32_000 * SDN, + invulnerables: authorities + .iter() + .map(|x| x.account_id()) + .collect::>(), + }, + evm: EVMConfig { + // We need _some_ code inserted at the precompile address so that + // the evm will actually call the address. + accounts: Precompiles::used_addresses_h160() + .map(|addr| { + ( + addr, + fp_evm::GenesisAccount { + nonce: Default::default(), + balance: Default::default(), + storage: Default::default(), + code: EVM_REVERT_CODE.into(), + }, + ) + }) + .collect(), + ..Default::default() + }, + ethereum: Default::default(), + polkadot_xcm: Default::default(), + assets: Default::default(), + parachain_system: Default::default(), + transaction_payment: Default::default(), + dapp_staking: DappStakingConfig { + reward_portion: vec![ + Permill::from_percent(40), + Permill::from_percent(30), + Permill::from_percent(20), + Permill::from_percent(10), + ], + slot_distribution: vec![ + Permill::from_percent(10), + Permill::from_percent(20), + Permill::from_percent(30), + Permill::from_percent(40), + ], + // percentages below are calculated based on a total issuance at the time when dApp staking v3 was launched (84.3M) + tier_thresholds: vec![ + TierThreshold::DynamicPercentage { + percentage: Perbill::from_parts(35_700_000), // 3.57% + minimum_required_percentage: Perbill::from_parts(23_800_000), // 2.38% + }, + TierThreshold::DynamicPercentage { + percentage: Perbill::from_parts(8_900_000), // 0.89% + minimum_required_percentage: Perbill::from_parts(6_000_000), // 0.6% + }, + TierThreshold::DynamicPercentage { + percentage: Perbill::from_parts(2_380_000), // 0.238% + minimum_required_percentage: Perbill::from_parts(1_790_000), // 0.179% + }, + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(600_000), // 0.06% + }, + ], + slots_per_tier: vec![10, 20, 30, 40], + safeguard: Some(false), + ..Default::default() + }, + inflation: Default::default(), + oracle_membership: OracleMembershipConfig { + members: vec![alice.account_id(), bob.account_id()] + .try_into() + .expect("Assumption is that at least two members will be allowed."), + ..Default::default() + }, + price_aggregator: PriceAggregatorConfig { + circular_buffer: vec![CurrencyAmount::from_rational(5, 10)] + .try_into() + .expect("Must work since buffer should have at least a single value."), + }, + }; + + serde_json::to_value(&config).expect("Could not build genesis config.") +} diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index f2db7762a..18d6ee401 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -26,8 +26,7 @@ use cumulus_primitives_core::AggregateMessageOrigin; use frame_support::{ construct_runtime, dispatch::DispatchClass, - genesis_builder_helper::{build_state, get_preset}, - parameter_types, + genesis_builder_helper, parameter_types, traits::{ fungible::{Balanced, Credit}, AsEnsureOriginWithArg, ConstBool, ConstU32, ConstU64, Contains, FindAuthor, Get, Imbalance, @@ -55,7 +54,7 @@ use pallet_transaction_payment::{ use parity_scale_codec::{Compact, Decode, Encode, MaxEncodedLen}; use polkadot_runtime_common::BlockHashCount; use sp_api::impl_runtime_apis; -use sp_core::{OpaqueMetadata, H160, H256, U256}; +use sp_core::{sr25519, OpaqueMetadata, H160, H256, U256}; use sp_inherents::{CheckInherentsResult, InherentData}; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, @@ -80,7 +79,7 @@ use astar_primitives::{ }, evm::EvmRevertCodeHandler, governance::OracleMembershipInst, - oracle::{CurrencyId, DummyCombineData, Price}, + oracle::{CurrencyAmount, CurrencyId, DummyCombineData, Price}, xcm::AssetLocationIdConverter, Address, AssetId, BlockNumber, Hash, Header, Nonce, UnfreezeChainOnFailedMigration, }; @@ -104,6 +103,7 @@ pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::BuildStorage; mod chain_extensions; +pub mod genesis_config; mod precompiles; mod weights; mod xcm_config; @@ -1981,15 +1981,17 @@ impl_runtime_apis! { impl sp_genesis_builder::GenesisBuilder for Runtime { fn build_state(config: Vec) -> sp_genesis_builder::Result { - build_state::(config) + genesis_builder_helper::build_state::(config) } fn get_preset(id: &Option) -> Option> { - get_preset::(id, |_| None) + genesis_builder_helper::get_preset::(id, &genesis_config::get_preset) } fn preset_names() -> Vec { - vec![] + vec![ + sp_genesis_builder::PresetId::from("development"), + ] } } diff --git a/third-party/zombienet/multi_parachains.toml b/third-party/zombienet/multi_parachains.toml index 16ffe4551..bdab728b0 100644 --- a/third-party/zombienet/multi_parachains.toml +++ b/third-party/zombienet/multi_parachains.toml @@ -25,8 +25,7 @@ chain = "rococo-local" validator = true [[parachains]] -# Right now this has to be 2000 but soon we might be able to use arbitrary para-id -id = 2000 +id = 1000 # Replace this with whichever chain you need to run, e.g. `astar-dev` if you need Astar chain = "shibuya-dev" cumulus_based = true diff --git a/third-party/zombienet/single_parachain.toml b/third-party/zombienet/single_parachain.toml index 9f4a890b0..1e6114331 100644 --- a/third-party/zombienet/single_parachain.toml +++ b/third-party/zombienet/single_parachain.toml @@ -33,8 +33,7 @@ name = "dave" validator = true [[parachains]] -# Right now this has to be 2000 but soon we might be able to use arbitrary para-id -id = 2000 +id = 1000 # Replace this with whichever chain you need to run, e.g. `astar-dev` if you need Astar chain = "shibuya-dev" cumulus_based = true diff --git a/third-party/zombienet/smoke.toml b/third-party/zombienet/smoke.toml index 40ddb4228..34bdad214 100644 --- a/third-party/zombienet/smoke.toml +++ b/third-party/zombienet/smoke.toml @@ -24,8 +24,7 @@ chain = "rococo-local" validator = true [[parachains]] -# Right now this has to be 2000 but soon we might be able to use arbitrary para-id -id = 2000 +id = 1000 chain = "{{CHAIN}}" cumulus_based = true