git.delta.rocks / unique-network / refs/commits / cf53619f112d

difftreelog

Use default runtime in the local testnet

Daniel Shiposha2022-03-30parent: #6d40a57.patch.diff
in: master

4 files changed

modifiednode/cli/src/chain_spec.rsdiffbeforeafterboth
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// 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/>.
1616
17use 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};
2625
27use unique_runtime_common::types::*;26use unique_runtime_common::types::*;
27
28#[cfg(feature = "unique-runtime")]
29use unique_runtime as default_runtime;
30
31#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]
32use quartz_runtime as default_runtime;
33
34#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]
35use opal_runtime as default_runtime;
2836
29/// 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>;
47
48#[cfg(feature = "unique-runtime")]
49pub type DefaultChainSpec = UniqueChainSpec;
50
51#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]
52pub type DefaultChainSpec = QuartzChainSpec;
53
54#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]
55pub type DefaultChainSpec = OpalChainSpec;
3956
40pub 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}
144
145macro_rules! testnet_genesis {
146 (
147 $runtime:path,
148 $root_key:expr,
149 $initial_authorities:expr,
150 $endowed_accounts:expr,
151 $id:expr
152 ) => {{
153 use $runtime::*;
154
155 GenesisConfig {
156 system: SystemConfig {
157 code: WASM_BINARY
158 .expect("WASM binary was not build, please build it!")
159 .to_vec(),
160 },
161 balances: BalancesConfig {
162 balances: $endowed_accounts
163 .iter()
164 .cloned()
165 // 1e13 UNQ
166 .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 { parachain_id: $id.into() },
175 parachain_system: Default::default(),
176 aura: AuraConfig {
177 authorities: $initial_authorities,
178 },
179 aura_ext: Default::default(),
180 evm: EVMConfig {
181 accounts: BTreeMap::new(),
182 },
183 ethereum: EthereumConfig {},
184 }
185 }};
186}
127187
128pub fn development_config() -> OpalChainSpec {188pub fn development_config() -> OpalChainSpec {
129 let mut properties = Map::new();189 let mut properties = Map::new();
130 properties.insert("tokenSymbol".into(), "OPL".into());190 properties.insert("tokenSymbol".into(), opal_runtime::TOKEN_SYMBOL.into());
131 properties.insert("tokenDecimals".into(), 18.into());191 properties.insert("tokenDecimals".into(), 18.into());
132 properties.insert("ss58Format".into(), 42.into());192 properties.insert("ss58Format".into(), opal_runtime::SS58Prefix::get().into());
133193
134 OpalChainSpec::from_genesis(194 OpalChainSpec::from_genesis(
135 // Name195 // Name
138 "opal_dev",198 "opal_dev",
139 ChainType::Local,199 ChainType::Local,
140 move || {200 move || {
141 testnet_genesis(201 testnet_genesis!(
202 opal_runtime,
203
142 // Sudo account204 // Sudo account
143 get_account_id_from_seed::<sr25519::Public>("Alice"),205 get_account_id_from_seed::<sr25519::Public>("Alice"),
144 vec![206 vec![
145 get_from_seed::<AuraId>("Alice"),207 get_from_seed::<AuraId>("Alice"),
146 get_from_seed::<AuraId>("Bob"),208 get_from_seed::<AuraId>("Bob"),
150 get_account_id_from_seed::<sr25519::Public>("Alice"),212 get_account_id_from_seed::<sr25519::Public>("Alice"),
151 get_account_id_from_seed::<sr25519::Public>("Bob"),213 get_account_id_from_seed::<sr25519::Public>("Bob"),
152 ],214 ],
153 1000.into(),215 1000
154 )216 )
155 },217 },
156 // Bootnodes218 // Bootnodes
170 )232 )
171}233}
172234
173pub fn local_testnet_rococo_config() -> OpalChainSpec {235pub fn local_testnet_rococo_config() -> DefaultChainSpec {
174 let mut properties = Map::new();236 let mut properties = Map::new();
175 properties.insert("tokenSymbol".into(), "OPL".into());237 properties.insert("tokenSymbol".into(), default_runtime::TOKEN_SYMBOL.into());
176 properties.insert("tokenDecimals".into(), 18.into());238 properties.insert("tokenDecimals".into(), 18.into());
177 properties.insert("ss58Format".into(), 42.into());239 properties.insert("ss58Format".into(), default_runtime::SS58Prefix::get().into());
178240
179 OpalChainSpec::from_genesis(241 DefaultChainSpec::from_genesis(
180 // Name242 // Name
243 format!(
244 "{}{}",
245 default_runtime::RUNTIME_NAME.to_uppercase(),
181 "OPAL by UNIQUE",246 if cfg!(feature = "unique-runtime") { "" } else { " by UNIQUE" }
247 ).as_str(),
182 // ID248 // ID
183 "opal_local",249 format!("{}_local", default_runtime::RUNTIME_NAME).as_str(),
184 ChainType::Local,250 ChainType::Local,
185 move || {251 move || {
186 testnet_genesis(252 testnet_genesis!(
253 default_runtime,
254
187 // Sudo account255 // Sudo account
188 get_account_id_from_seed::<sr25519::Public>("Alice"),256 get_account_id_from_seed::<sr25519::Public>("Alice"),
189 vec![257 vec![
190 get_from_seed::<AuraId>("Alice"),258 get_from_seed::<AuraId>("Alice"),
191 get_from_seed::<AuraId>("Bob"),259 get_from_seed::<AuraId>("Bob"),
205 get_account_id_from_seed::<sr25519::Public>("Eve//stash"),273 get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
206 get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),274 get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
207 ],275 ],
208 1000.into(),276 1000
209 )277 )
210 },278 },
211 // Bootnodes279 // Bootnodes
225 )293 )
226}294}
227
228fn 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::*;
235
236 GenesisConfig {
237 system: SystemConfig {
238 code: WASM_BINARY
239 .expect("WASM binary was not build, please build it!")
240 .to_vec(),
241 },
242 balances: BalancesConfig {
243 balances: endowed_accounts
244 .iter()
245 .cloned()
246 // 1e13 UNQ
247 .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}
267295
modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
115use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};115use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};
116116
117pub const RUNTIME_NAME: &str = "opal";117pub const RUNTIME_NAME: &str = "opal";
118pub const TOKEN_SYMBOL: &str = "OPL";
118119
119type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;120type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;
120121
modifiedruntime/quartz/src/lib.rsdiffbeforeafterboth
115use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};115use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};
116116
117pub const RUNTIME_NAME: &str = "quartz";117pub const RUNTIME_NAME: &str = "quartz";
118pub const TOKEN_SYMBOL: &str = "QTZ";
118119
119type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;120type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;
120121
modifiedruntime/unique/src/lib.rsdiffbeforeafterboth
114use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};114use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};
115115
116pub const RUNTIME_NAME: &str = "unique";116pub const RUNTIME_NAME: &str = "unique";
117pub const TOKEN_SYMBOL: &str = "UNQ";
117118
118type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;119type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;
119120