difftreelog
Merge pull request #325 from UniqueNetwork/fix/use-default-runtime-in-testnet
in: master
Use default runtime in the local testnet
4 files changed
node/cli/src/chain_spec.rsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617use cumulus_primitives_core::ParaId;18use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};17use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};19use sc_service::ChainType;18use sc_service::ChainType;20use sp_core::{sr25519, Pair, Public};19use sp_core::{sr25519, Pair, Public};262527use unique_runtime_common::types::*;26use unique_runtime_common::types::*;2728#[cfg(feature = "unique-runtime")]29use unique_runtime as default_runtime;3031#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]32use quartz_runtime as default_runtime;3334#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]35use opal_runtime as default_runtime;283629/// The `ChainSpec` parameterized for the unique runtime.37/// The `ChainSpec` parameterized for the unique runtime.30#[cfg(feature = "unique-runtime")]38#[cfg(feature = "unique-runtime")]37/// The `ChainSpec` parameterized for the opal runtime.45/// The `ChainSpec` parameterized for the opal runtime.38pub type OpalChainSpec = sc_service::GenericChainSpec<opal_runtime::GenesisConfig, Extensions>;46pub type OpalChainSpec = sc_service::GenericChainSpec<opal_runtime::GenesisConfig, Extensions>;4748#[cfg(feature = "unique-runtime")]49pub type DefaultChainSpec = UniqueChainSpec;5051#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]52pub type DefaultChainSpec = QuartzChainSpec;5354#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]55pub type DefaultChainSpec = OpalChainSpec;395640pub enum RuntimeId {57pub enum RuntimeId {41 #[cfg(feature = "unique-runtime")]58 #[cfg(feature = "unique-runtime")]125 AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()142 AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()126}143}144145macro_rules! testnet_genesis {146 (147 $runtime:path,148 $root_key:expr,149 $initial_authorities:expr,150 $endowed_accounts:expr,151 $id:expr152 ) => {{153 use $runtime::*;154155 GenesisConfig {156 system: SystemConfig {157 code: WASM_BINARY158 .expect("WASM binary was not build, please build it!")159 .to_vec(),160 },161 balances: BalancesConfig {162 balances: $endowed_accounts163 .iter()164 .cloned()165 // 1e13 UNQ166 .map(|k| (k, 1 << 100))167 .collect(),168 },169 treasury: Default::default(),170 sudo: SudoConfig {171 key: Some($root_key),172 },173 vesting: VestingConfig { vesting: vec![] },174 parachain_info: ParachainInfoConfig {175 parachain_id: $id.into(),176 },177 parachain_system: Default::default(),178 aura: AuraConfig {179 authorities: $initial_authorities,180 },181 aura_ext: Default::default(),182 evm: EVMConfig {183 accounts: BTreeMap::new(),184 },185 ethereum: EthereumConfig {},186 }187 }};188}127189128pub fn development_config() -> OpalChainSpec {190pub fn development_config() -> OpalChainSpec {129 let mut properties = Map::new();191 let mut properties = Map::new();130 properties.insert("tokenSymbol".into(), "OPL".into());192 properties.insert("tokenSymbol".into(), opal_runtime::TOKEN_SYMBOL.into());131 properties.insert("tokenDecimals".into(), 18.into());193 properties.insert("tokenDecimals".into(), 18.into());132 properties.insert("ss58Format".into(), 42.into());194 properties.insert("ss58Format".into(), opal_runtime::SS58Prefix::get().into());133195134 OpalChainSpec::from_genesis(196 OpalChainSpec::from_genesis(135 // Name197 // Name138 "opal_dev",200 "opal_dev",139 ChainType::Local,201 ChainType::Local,140 move || {202 move || {141 testnet_genesis(203 testnet_genesis!(204 opal_runtime,142 // Sudo account205 // Sudo account143 get_account_id_from_seed::<sr25519::Public>("Alice"),206 get_account_id_from_seed::<sr25519::Public>("Alice"),144 vec![207 vec![145 get_from_seed::<AuraId>("Alice"),208 get_from_seed::<AuraId>("Alice"),146 get_from_seed::<AuraId>("Bob"),209 get_from_seed::<AuraId>("Bob"),150 get_account_id_from_seed::<sr25519::Public>("Alice"),213 get_account_id_from_seed::<sr25519::Public>("Alice"),151 get_account_id_from_seed::<sr25519::Public>("Bob"),214 get_account_id_from_seed::<sr25519::Public>("Bob"),152 ],215 ],153 1000.into(),216 1000154 )217 )155 },218 },156 // Bootnodes219 // Bootnodes170 )233 )171}234}172235173pub fn local_testnet_rococo_config() -> OpalChainSpec {236pub fn local_testnet_rococo_config() -> DefaultChainSpec {174 let mut properties = Map::new();237 let mut properties = Map::new();175 properties.insert("tokenSymbol".into(), "OPL".into());238 properties.insert("tokenSymbol".into(), default_runtime::TOKEN_SYMBOL.into());176 properties.insert("tokenDecimals".into(), 18.into());239 properties.insert("tokenDecimals".into(), 18.into());177 properties.insert("ss58Format".into(), 42.into());240 properties.insert(241 "ss58Format".into(),242 default_runtime::SS58Prefix::get().into(),243 );178244179 OpalChainSpec::from_genesis(245 DefaultChainSpec::from_genesis(180 // Name246 // Name247 format!(248 "{}{}",249 default_runtime::RUNTIME_NAME.to_uppercase(),250 if cfg!(feature = "unique-runtime") {251 ""252 } else {181 "OPAL by UNIQUE",253 " by UNIQUE"254 }255 )256 .as_str(),182 // ID257 // ID183 "opal_local",258 format!("{}_local", default_runtime::RUNTIME_NAME).as_str(),184 ChainType::Local,259 ChainType::Local,185 move || {260 move || {186 testnet_genesis(261 testnet_genesis!(262 default_runtime,187 // Sudo account263 // Sudo account188 get_account_id_from_seed::<sr25519::Public>("Alice"),264 get_account_id_from_seed::<sr25519::Public>("Alice"),189 vec![265 vec![190 get_from_seed::<AuraId>("Alice"),266 get_from_seed::<AuraId>("Alice"),191 get_from_seed::<AuraId>("Bob"),267 get_from_seed::<AuraId>("Bob"),205 get_account_id_from_seed::<sr25519::Public>("Eve//stash"),281 get_account_id_from_seed::<sr25519::Public>("Eve//stash"),206 get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),282 get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),207 ],283 ],208 1000.into(),284 1000209 )285 )210 },286 },211 // Bootnodes287 // Bootnodes225 )301 )226}302}227228fn testnet_genesis(229 root_key: AccountId,230 initial_authorities: Vec<AuraId>,231 endowed_accounts: Vec<AccountId>,232 id: ParaId,233) -> opal_runtime::GenesisConfig {234 use opal_runtime::*;235236 GenesisConfig {237 system: SystemConfig {238 code: WASM_BINARY239 .expect("WASM binary was not build, please build it!")240 .to_vec(),241 },242 balances: BalancesConfig {243 balances: endowed_accounts244 .iter()245 .cloned()246 // 1e13 UNQ247 .map(|k| (k, 1 << 100))248 .collect(),249 },250 treasury: Default::default(),251 sudo: SudoConfig {252 key: Some(root_key),253 },254 vesting: VestingConfig { vesting: vec![] },255 parachain_info: ParachainInfoConfig { parachain_id: id },256 parachain_system: Default::default(),257 aura: AuraConfig {258 authorities: initial_authorities,259 },260 aura_ext: Default::default(),261 evm: EVMConfig {262 accounts: BTreeMap::new(),263 },264 ethereum: EthereumConfig {},265 }266}267303runtime/opal/src/lib.rsdiffbeforeafterboth115use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};115use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};116116117pub const RUNTIME_NAME: &str = "opal";117pub const RUNTIME_NAME: &str = "opal";118pub const TOKEN_SYMBOL: &str = "OPL";118119119type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;120type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;120121runtime/quartz/src/lib.rsdiffbeforeafterboth115use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};115use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};116116117pub const RUNTIME_NAME: &str = "quartz";117pub const RUNTIME_NAME: &str = "quartz";118pub const TOKEN_SYMBOL: &str = "QTZ";118119119type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;120type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;120121runtime/unique/src/lib.rsdiffbeforeafterboth114use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};114use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};115115116pub const RUNTIME_NAME: &str = "unique";116pub const RUNTIME_NAME: &str = "unique";117pub const TOKEN_SYMBOL: &str = "UNQ";117118118type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;119type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;119120