git.delta.rocks / unique-network / refs/commits / 157619d37683

difftreelog

wip parachains

Greg Zaitsev2021-06-03parent: #c803bd5.patch.diff
in: master

2 files changed

modifiedruntime/Cargo.tomldiffbeforeafterboth
--- a/runtime/Cargo.toml
+++ b/runtime/Cargo.toml
@@ -1,66 +1,19 @@
+################################################################################
+# Package 
+
 [package]
-authors = ['UseTech Professional <https://usetech.com/blockchain>']
+authors = ['Unique Network <support@uniquenetwork.io>']
+build = 'build.rs'
+description = 'Substrate node nft'
 edition = '2018'
-homepage = 'https://substrate.io'
+homepage = 'https://unique.network'
 license = 'All Rights Reserved'
 name = 'nft-runtime'
-repository = 'https://github.com/usetech-llc/nft_parachain/'
+repository = 'https://github.com/usetech-llc/nft_private/'
 version = '3.0.0'
 
 [package.metadata.docs.rs]
 targets = ['x86_64-unknown-linux-gnu']
-
-[build-dependencies]
-substrate-wasm-builder = '4.0.0'
-
-# alias "parity-scale-code" to "codec"
-[dependencies.codec]
-default-features = false
-features = ['derive']
-package = 'parity-scale-codec'
-version = '2.0.0'
-
-[dependencies]
-hex-literal = { optional = true, version = '0.3.1' }
-serde = { features = ['derive'], optional = true, version = '1.0.119' }
-
-# local dependencies
-pallet-nft = { path = '../pallets/nft', default-features = false, version = '3.0.0' }
-pallet-inflation = { path = '../pallets/inflation', default-features = false, version = '3.0.0' }
-
-# Substrate dependencies
-frame-benchmarking = { default-features = false, optional = true, version = '3.0.0' }
-frame-executive = { default-features = false, version = '3.0.0' }
-frame-support = { default-features = false, version = '3.0.0' }
-frame-system = { default-features = false, version = '3.0.0' }
-frame-system-benchmarking = { default-features = false, optional = true, version = '3.0.0' }
-frame-system-rpc-runtime-api = { default-features = false, version = '3.0.0' }
-pallet-aura = { default-features = false, version = '3.0.0' }
-pallet-balances = { default-features = false, version = '3.0.0' }
-pallet-contracts = { default-features = false, version = '3.0.0' }
-pallet-contracts-primitives = { default-features = false, version = '3.0.0' }
-pallet-contracts-rpc-runtime-api = { default-features = false, version = '3.0.0' }
-pallet-grandpa = { default-features = false, version = '3.0.0' }
-pallet-randomness-collective-flip = { default-features = false, version = '3.0.0' }
-pallet-sudo = { default-features = false, version = '3.0.0' }
-pallet-timestamp = { default-features = false, version = '3.0.0' }
-pallet-transaction-payment = { default-features = false, version = '3.0.0' }
-pallet-transaction-payment-rpc-runtime-api = { default-features = false, version = '3.0.0' }
-pallet-treasury = { default-features = false, version = "3.0.0" }
-pallet-vesting = {  default-features = false, version = "3.0.0" }
-sp-arithmetic = { default-features = false, version = '3.0.0' }
-sp-api = { default-features = false, version = '3.0.0' }
-sp-block-builder = { default-features = false, version = '3.0.0' }
-sp-consensus-aura = { default-features = false, version = '0.9.0' }
-sp-core = { default-features = false, version = '3.0.0' }
-sp-inherents = { default-features = false, version = '3.0.0' }
-sp-offchain = { default-features = false, version = '3.0.0' }
-sp-runtime = { default-features = false, version = '3.0.0' }
-sp-session = { default-features = false, version = '3.0.0' }
-sp-std = { default-features = false, version = '3.0.0' }
-sp-transaction-pool = { default-features = false, version = '3.0.0' }
-sp-version = { default-features = false, version = '3.0.0' }
-smallvec = "1.4.1"
 
 [features]
 default = ['std']
@@ -78,17 +31,19 @@
 ]
 std = [
     'codec/std',
-    'serde',
+	'cumulus-pallet-parachain-system/std',
+	'cumulus-pallet-xcm/std',
+	'cumulus-pallet-xcmp-queue/std',
+	'cumulus-primitives-core/std',
+	'cumulus-primitives-utility/std',
     'frame-executive/std',
     'frame-support/std',
     'frame-system/std',
     'frame-system-rpc-runtime-api/std',
-    'pallet-aura/std',
     'pallet-balances/std',
     'pallet-contracts/std',
     'pallet-contracts-primitives/std',
     'pallet-contracts-rpc-runtime-api/std',
-    'pallet-grandpa/std',
     'pallet-randomness-collective-flip/std',
     'pallet-sudo/std',
     'pallet-timestamp/std',
@@ -96,19 +51,297 @@
     'pallet-transaction-payment-rpc-runtime-api/std',
     'pallet-treasury/std',
     'pallet-vesting/std',
-
-    'pallet-inflation/std',
-    'pallet-nft/std',
+    'serde',
     'sp-api/std',
     'sp-block-builder/std',
-    'sp-consensus-aura/std',
     'sp-core/std',
     'sp-inherents/std',
+	'sp-io/std',
     'sp-offchain/std',
     'sp-runtime/std',
     'sp-session/std',
     'sp-std/std',
     'sp-transaction-pool/std',
     'sp-version/std',
+	'xcm/std',
+	'xcm-builder/std',
+	'xcm-executor/std',
 
+    'pallet-inflation/std',
+    'pallet-nft/std',
 ]
+
+################################################################################
+# Substrate Dependencies
+
+[dependencies.codec]
+default-features = false
+features = ['derive']
+package = 'parity-scale-codec'
+version = '2.0.0'
+
+[dependencies.frame-benchmarking]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+optional = true
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.frame-executive]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.frame-support]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.frame-system]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.frame-system-benchmarking]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+optional = true
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.frame-system-rpc-runtime-api]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.hex-literal]
+optional = true
+version = '0.3.1'
+
+[dependencies.serde]
+features = ['derive']
+optional = true
+version = '1.0.119'
+
+[dependencies.pallet-balances]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+# Contracts specific packages
+[dependencies.pallet-contracts]
+git = 'https://github.com/paritytech/substrate.git'
+default-features = false
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.pallet-contracts-primitives]
+git = 'https://github.com/paritytech/substrate.git'
+default-features = false
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.pallet-contracts-rpc-runtime-api]
+git = 'https://github.com/paritytech/substrate.git'
+default-features = false
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.pallet-randomness-collective-flip]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.pallet-sudo]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.pallet-timestamp]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.pallet-transaction-payment]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.pallet-transaction-payment-rpc-runtime-api]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.pallet-treasury]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.pallet-vesting]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.sp-arithmetic]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.sp-api]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.sp-block-builder]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.sp-core]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.sp-inherents]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.sp-io]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.sp-offchain]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.sp-runtime]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.sp-session]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.sp-std]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.sp-transaction-pool]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.sp-version]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.smallvec]
+version = '1.4.1'
+
+################################################################################
+# Cumulus dependencies
+
+[dependencies.parachain-info]
+default-features = false
+git = 'https://github.com/paritytech/cumulus.git'
+branch = 'rococo-v1'
+version = '0.1.0'
+
+[dependencies.cumulus-pallet-parachain-system]
+git = 'https://github.com/paritytech/cumulus.git'
+branch = 'rococo-v1'
+default-features = false
+
+[dependencies.cumulus-primitives-core]
+git = 'https://github.com/paritytech/cumulus.git'
+branch = 'rococo-v1'
+default-features = false
+
+[dependencies.cumulus-pallet-xcm]
+git = 'https://github.com/paritytech/cumulus.git'
+branch = 'rococo-v1'
+default-features = false
+
+[dependencies.cumulus-pallet-xcmp-queue]
+git = 'https://github.com/paritytech/cumulus.git'
+branch = 'rococo-v1'
+default-features = false
+
+[dependencies.cumulus-primitives-utility]
+git = 'https://github.com/paritytech/cumulus.git'
+branch = 'rococo-v1'
+default-features = false
+
+################################################################################
+# Polkadot dependencies
+
+[dependencies.polkadot-parachain]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'rococo-v1'
+default-features = false
+
+[dependencies.xcm]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'rococo-v1'
+default-features = false
+
+[dependencies.xcm-builder]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'rococo-v1'
+default-features = false
+
+[dependencies.xcm-executor]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'rococo-v1'
+default-features = false
+
+[dependencies.pallet-xcm]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'rococo-v1'
+default-features = false
+
+
+################################################################################
+# Build Dependencies
+
+[build-dependencies]
+substrate-wasm-builder = '4.0.0'
+
+
+################################################################################
+# local dependencies
+
+pallet-nft = { path = '../pallets/nft', default-features = false, version = '3.0.0' }
+pallet-inflation = { path = '../pallets/inflation', default-features = false, version = '3.0.0' }
+
modifiedruntime/src/lib.rsdiffbeforeafterboth
13#[cfg(feature = "std")]13#[cfg(feature = "std")]
14include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));14include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
1515
16use pallet_grandpa::fg_primitives;
17use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
18use sp_api::impl_runtime_apis;16use sp_api::impl_runtime_apis;
19use sp_consensus_aura::sr25519::AuthorityId as AuraId;
20use sp_core::{ crypto::KeyTypeId, crypto::Public, OpaqueMetadata };17use sp_core::{ crypto::KeyTypeId, crypto::Public, OpaqueMetadata };
21use sp_runtime::{18use sp_runtime::{
19 BuildStorage,
22 Permill, Perbill, Percent,20 Permill, Perbill, Percent,
23 ModuleId,21 ModuleId,
24 create_runtime_str, generic, impl_opaque_keys,22 create_runtime_str, generic, impl_opaque_keys,
25 traits::{23 traits::{
26 Convert, ConvertInto, BlakeTwo256, Block as BlockT, IdentifyAccount, 24 AccountIdLookup, BlakeTwo256, Block as BlockT, Convert, ConvertInto, IdentifyAccount,
27 IdentityLookup, NumberFor, Verify, AccountIdConversion,25 IdentityLookup, NumberFor, Verify, AccountIdConversion,
28 },26 },
29 transaction_validity::{TransactionSource, TransactionValidity},27 transaction_validity::{TransactionSource, TransactionValidity},
30 ApplyExtrinsicResult, MultiSignature,28 ApplyExtrinsicResult, MultiSignature,
31};29};
30
31use sp_std::prelude::*;
32
32#[cfg(feature = "std")]33#[cfg(feature = "std")]
33use sp_version::NativeVersion;34use sp_version::NativeVersion;
42 parameter_types,43 parameter_types,
43 StorageValue,44 StorageValue,
44 traits::{45 traits::{
45 Currency, ExistenceRequirement, Get, KeyOwnerProofSystem, OnUnbalanced, Randomness,46 All, Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier, OnUnbalanced, Randomness
46 LockIdentifier,
47 },47 },
48 weights::{48 weights::{
49 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},49 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
50 DispatchClass, DispatchInfo, GetDispatchInfo, Pays, PostDispatchInfo, Weight,50 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,
51 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients51 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients
52 },52 },
53};53};
6464
65pub use pallet_timestamp::Call as TimestampCall;65pub use pallet_timestamp::Call as TimestampCall;
66
67// Polkadot imports
68use polkadot_parachain::primitives::Sibling;
69use xcm::v0::{Junction, MultiLocation, NetworkId};
70use xcm_builder::{
71 AccountId32Aliases, CurrencyAdapter, LocationInverter, ParentIsDefault, RelayChainAsNative,
72 SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
73 SovereignSignedViaLocation, FixedRateOfConcreteFungible, EnsureXcmOrigin,
74 AllowTopLevelPaidExecutionFrom, TakeWeightCredit, FixedWeightBounds, IsConcrete, NativeAsset,
75 AllowUnpaidExecutionFrom, ParentAsSuperuser,
76};
77use xcm_executor::{Config, XcmExecutor};
78
6679
67mod chain_extension;80mod chain_extension;
140153
141 impl_opaque_keys! {154 impl_opaque_keys! {
142 pub struct SessionKeys {155 pub struct SessionKeys {}
143 pub aura: Aura,
144 pub grandpa: Grandpa,
145 }
146 }156 }
147}157}
166pub const HOURS: BlockNumber = MINUTES * 60;176pub const HOURS: BlockNumber = MINUTES * 60;
167pub const DAYS: BlockNumber = HOURS * 24;177pub const DAYS: BlockNumber = HOURS * 24;
178
179#[derive(codec::Encode, codec::Decode)]
180pub enum XCMPMessage<XAccountId, XBalance> {
181 /// Transfer tokens to the given account from the Parachain account.
182 TransferToken(XAccountId, XBalance),
183}
168184
169/// The version information used to identify this runtime when compiled natively.185/// The version information used to identify this runtime when compiled natively.
170#[cfg(feature = "std")]186#[cfg(feature = "std")]
175 }191 }
176}192}
177
178/// Provides a membership set with only the configured aura users
179pub struct ValiudatorsOnly<Runtime: pallet_aura::Config>(PhantomData<Runtime>);
180impl frame_support::traits::Contains<AccountId> for ValiudatorsOnly<Runtime> {
181 fn contains(t: &AccountId) -> bool {
182 let arr: [u8; 32] = *t.as_ref();
183 let raw_key: Vec<u8> = Vec::from(arr);
184
185 match pallet_aura::Module::<Runtime>::authorities().iter().find(|auth| auth.to_raw_vec() == raw_key) {
186 Some(_) => true,
187 None => false,
188 }
189 }
190 fn sorted_members() -> Vec<AccountId> {
191 let mut members: Vec<AccountId> = Vec::new();
192 for auth in pallet_aura::Module::<Runtime>::authorities() {
193 let mut arr: [u8; 32] = Default::default();
194 let bor_arr = auth.clone().to_raw_vec();
195 let slice = bor_arr.as_slice();
196 arr.copy_from_slice(slice);
197 members.push(AccountId::from(arr));
198 }
199 members
200 }
201 fn count() -> usize {
202 pallet_aura::Module::<Runtime>::authorities().len()
203 }
204}
205
206impl frame_support::traits::ContainsLengthBound for ValiudatorsOnly<Runtime> {
207 fn min_len() -> usize {
208 1
209 }
210 fn max_len() -> usize {
211 100
212 }
213}
214193
215type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;194type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;
216195
283}262}
284263
285impl system::Config for Runtime {264impl system::Config for Runtime {
286 /// The basic call filter to use in dispatchable.265 /// The data to be stored in an account.
287 type BaseCallFilter = ();266 type AccountData = pallet_balances::AccountData<Balance>;
288 /// The identifier used to distinguish between accounts.267 /// The identifier used to distinguish between accounts.
289 type AccountId = AccountId;268 type AccountId = AccountId;
290 /// The aggregated dispatch type that is available for extrinsics.269 /// The basic call filter to use in dispatchable.
291 type Call = Call;270 type BaseCallFilter = ();
292 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.271 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).
293 type Lookup = IdentityLookup<AccountId>;272 type BlockHashCount = BlockHashCount;
294 /// The index type for storing how many extrinsics an account has signed.273 /// The maximum length of a block (in bytes).
295 type Index = Index;274 type BlockLength = RuntimeBlockLength;
296 /// The index type for blocks.275 /// The index type for blocks.
297 type BlockNumber = BlockNumber;276 type BlockNumber = BlockNumber;
277 /// The weight of the overhead invoked on the block import process, independent of the
278 /// extrinsics included in that block.
279 type BlockWeights = RuntimeBlockWeights;
280 /// The aggregated dispatch type that is available for extrinsics.
281 type Call = Call;
282 /// The weight of database operations that the runtime can invoke.
283 type DbWeight = RocksDbWeight;
284 /// The ubiquitous event type.
285 type Event = Event;
298 /// The type for hashing blocks and tries.286 /// The type for hashing blocks and tries.
299 type Hash = Hash;287 type Hash = Hash;
300 /// The hashing algorithm used.288 /// The hashing algorithm used.
301 type Hashing = BlakeTwo256;289 type Hashing = BlakeTwo256;
302 /// The header type.290 /// The header type.
303 type Header = generic::Header<BlockNumber, BlakeTwo256>;291 type Header = generic::Header<BlockNumber, BlakeTwo256>;
304 /// The ubiquitous event type.292 /// The index type for storing how many extrinsics an account has signed.
305 type Event = Event;293 type Index = Index;
306 /// The ubiquitous origin type.294 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.
307 type Origin = Origin;295 type Lookup = IdentityLookup<AccountId>;
308 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).296 /// What to do if an account is fully reaped from the system.
309 type BlockHashCount = BlockHashCount;297 type OnKilledAccount = ();
310 /// The weight of database operations that the runtime can invoke.298 /// What to do if a new account is created.
311 type DbWeight = RocksDbWeight;299 type OnNewAccount = ();
312 /// The weight of the overhead invoked on the block import process, independent of the
313 /// extrinsics included in that block.
314 type BlockWeights = RuntimeBlockWeights;300 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
315 /// Version of the runtime.301 /// The ubiquitous origin type.
316 type Version = Version;302 type Origin = Origin;
317 /// This type is being generated by `construct_runtime!`.303 /// This type is being generated by `construct_runtime!`.
318 type PalletInfo = PalletInfo;304 type PalletInfo = PalletInfo;
319 /// What to do if a new account is created.305 /// This is used as an identifier of the chain. 42 is the generic substrate prefix.
320 type OnNewAccount = ();
321 /// What to do if an account is fully reaped from the system.
322 type OnKilledAccount = ();306 type SS58Prefix = SS58Prefix;
323 /// The data to be stored in an account.
324 type AccountData = pallet_balances::AccountData<Balance>;
325 /// Weight information for the extrinsics of this pallet.307 /// Weight information for the extrinsics of this pallet.
326 type SystemWeightInfo = system::weights::SubstrateWeight<Runtime>;308 type SystemWeightInfo = system::weights::SubstrateWeight<Runtime>;
327 309 /// Version of the runtime.
328 type BlockLength = RuntimeBlockLength;310 type Version = Version;
329 type SS58Prefix = SS58Prefix;
330}311}
331
332impl pallet_aura::Config for Runtime {
333 type AuthorityId = AuraId;
334}
335
336impl pallet_grandpa::Config for Runtime {
337 type Event = Event;
338 type Call = Call;
339
340 type KeyOwnerProofSystem = ();
341
342 type KeyOwnerProof =
343 <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;
344
345 type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
346 KeyTypeId,
347 GrandpaId,
348 )>>::IdentificationTuple;
349
350 type HandleEquivocation = ();
351
352 type WeightInfo = ();
353}
354312
355parameter_types! {313parameter_types! {
356 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;314 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
379 type DustRemoval = Treasury;337 type DustRemoval = Treasury;
380 type ExistentialDeposit = ExistentialDeposit;338 type ExistentialDeposit = ExistentialDeposit;
381 type AccountStore = System;339 type AccountStore = System;
382 type WeightInfo = ();340 type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
383}341}
384342
385pub const MICROUNIQUE: Balance = 1_000_000_000;343pub const MICROUNIQUE: Balance = 1_000_000_000;
440 type MaxCodeSize = MaxCodeSize;398 type MaxCodeSize = MaxCodeSize;
441}399}
442400
443parameter_types! {401parame ter_types! {
444 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; // Targeting 0.1 Unique per NFT transfer 402 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; // Targeting 0.1 Unique per NFT transfer
445}403}
446404
520 type WeightInfo = ();478 type WeightInfo = ();
521}479}
480
481parameter_types! {
482 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;
483}
484
485impl cumulus_pallet_parachain_system::Config for Runtime {
486 type Event = Event;
487 type OnValidationData = ();
488 type SelfParaId = parachain_info::Module<Runtime>;
489 type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<
490 MaxDownwardMessageWeight,
491 XcmExecutor<XcmConfig>,
492 Call,
493 >;
494 type OutboundXcmpMessageSource = XcmpQueue;
495 type XcmpMessageHandler = XcmpQueue;
496 type ReservedXcmpWeight = ReservedXcmpWeight;
497}
498
499impl parachain_info::Config for Runtime {}
500
501parameter_types! {
502 pub const RococoLocation: MultiLocation = MultiLocation::X1(Junction::Parent);
503 pub const RococoNetwork: NetworkId = NetworkId::Polkadot;
504 pub RelayChainOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();
505 pub Ancestry: MultiLocation = Junction::Parachain {
506 id: ParachainInfo::parachain_id().into()
507 }.into();
508}
509
510/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
511/// when determining ownership of accounts for asset transacting and when attempting to use XCM
512/// `Transact` in order to determine the dispatch Origin.
513pub type LocationToAccountId = (
514 // The parent (Relay-chain) origin converts to the default `AccountId`.
515 ParentIsDefault<AccountId>,
516 // Sibling parachain origins convert to AccountId via the `ParaId::into`.
517 SiblingParachainConvertsVia<Sibling, AccountId>,
518 // Straight up local `AccountId32` origins just alias directly to `AccountId`.
519 AccountId32Aliases<RococoNetwork, AccountId>,
520);
521
522/// Means for transacting assets on this chain.
523pub type LocalAssetTransactor = CurrencyAdapter<
524 // Use this currency:
525 Balances,
526 // Use this currency when it is a fungible asset matching the given location or name:
527 IsConcrete<RococoLocation>,
528 // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:
529 LocationToAccountId,
530 // Our chain's account ID type (we can't get away without mentioning it explicitly):
531 AccountId,
532>;
533
534/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,
535/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can
536/// biases the kind of local `Origin` it will become.
537pub type XcmOriginToTransactDispatchOrigin = (
538 // Sovereign account converter; this attempts to derive an `AccountId` from the origin location
539 // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for
540 // foreign chains who want to have a local sovereign account on this chain which they control.
541 SovereignSignedViaLocation<LocationToAccountId, Origin>,
542 // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when
543 // recognised.
544 RelayChainAsNative<RelayChainOrigin, Origin>,
545 // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when
546 // recognised.
547 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,
548 // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a
549 // transaction from the Root origin.
550 ParentAsSuperuser<Origin>,
551 // Native signed account converter; this just converts an `AccountId32` origin into a normal
552 // `Origin::Signed` origin of the same 32-byte value.
553 SignedAccountId32AsNative<RococoNetwork, Origin>,
554);
555
556parameter_types! {
557 pub UnitWeightCost: Weight = 1_000;
558}
559
560parameter_types! {
561 // 1_000_000_000_000 => 1 unit of asset for 1 unit of Weight.
562 // TODO: Should take the actual weight price. This is just 1_000 ROC per second of weight.
563 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::X1(Junction::Parent), 1_000);
564 pub AllowUnpaidFrom: Vec<MultiLocation> = vec![ MultiLocation::X1(Junction::Parent) ];
565}
566
567pub type Barrier = (
568 TakeWeightCredit,
569 AllowTopLevelPaidExecutionFrom<All<MultiLocation>>,
570 AllowUnpaidExecutionFrom<IsInVec<AllowUnpaidFrom>>, // <- Parent gets free execution
571);
572
573
574pub struct XcmConfig;
575impl Config for XcmConfig {
576 type Call = Call;
577 type XcmSender = XcmRouter;
578 // How to withdraw and deposit an asset.
579 type AssetTransactor = LocalAssetTransactor;
580 type OriginConverter = XcmOriginToTransactDispatchOrigin;
581 type IsReserve = NativeAsset;
582 type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of ROC
583 type LocationInverter = LocationInverter<Ancestry>;
584 type Barrier = Barrier;
585 type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
586 type Trader = FixedRateOfConcreteFungible<WeightPrice>;
587 type ResponseHandler = (); // Don't handle responses for now.
588}
589
590parameter_types! {
591 pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;
592}
593
594/// No local origins on this chain are allowed to dispatch XCM sends/executions.
595pub type LocalOriginToLocation = ();
596
597/// The means for routing XCM messages which are not for local execution into the right message
598/// queues.
599pub type XcmRouter = (
600 // Two routers - use UMP to communicate with the relay chain:
601 cumulus_primitives_utility::ParentAsUmp<ParachainSystem>,
602 // ..and XCMP to communicate with the sibling chains.
603 XcmpQueue,
604);
605
606impl pallet_xcm::Config for Runtime {
607 type Event = Event;
608 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
609 type XcmRouter = XcmRouter;
610 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
611 type XcmExecutor = XcmExecutor<XcmConfig>;
612}
613
614impl cumulus_pallet_xcm::Config for Runtime {}
615
616impl cumulus_pallet_xcmp_queue::Config for Runtime {
617 type Event = Event;
618 type XcmExecutor = XcmExecutor<XcmConfig>;
619 type ChannelInfo = ParachainSystem;
620}
522621
523parameter_types! {622parameter_types! {
524 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();623 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();
555 NodeBlock = opaque::Block,654 NodeBlock = opaque::Block,
556 UncheckedExtrinsic = UncheckedExtrinsic655 UncheckedExtrinsic = UncheckedExtrinsic
557 {656 {
558 System: system::{Module, Call, Config, Storage, Event<T>},657 Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
559 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
560 Contracts: pallet_contracts::{Module, Call, Config<T>, Storage, Event<T>},658 Contracts: pallet_contracts::{Module, Call, Config<T>, Storage, Event<T>},
561 Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},659 CumulusXcm: cumulus_pallet_xcm::{Pallet, Origin},
562 Aura: pallet_aura::{Module, Config<T> },660 ParachainInfo: parachain_info::{Pallet, Storage, Config},
563 Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event},661 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>},
564 Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},662 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin},
565 TransactionPayment: pallet_transaction_payment::{Module, Storage},663 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
566 Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},664 Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
567 Inflation: pallet_inflation::{Module, Call, Storage},665 System: system::{Module, Call, Config, Storage, Event<T>},
568 Nft: pallet_nft::{Module, Call, Config<T>, Storage, Event<T>},666 Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
667 TransactionPayment: pallet_transaction_payment::{Module, Storage},
668 Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},
669 Vesting: pallet_vesting::{Module, Call, Config<T>, Storage, Event<T>},
569 Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},670 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>},
671
570 Vesting: pallet_vesting::{Module, Call, Config<T>, Storage, Event<T>},672 Inflation: pallet_inflation::{Module, Call, Storage},
673 Nft: pallet_nft::{Module, Call, Config<T>, Storage, Event<T>},
571 }674 }
572);675);
573676
601704
602impl_runtime_apis! {705impl_runtime_apis! {
603
604 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>
605 for Runtime
606 {
607 fn call(
608 origin: AccountId,
609 dest: AccountId,
610 value: Balance,
611 gas_limit: u64,
612 input_data: Vec<u8>,
613 ) -> pallet_contracts_primitives::ContractExecResult {
614 Contracts::bare_call(origin, dest, value, gas_limit, input_data)
615 }
616
617 fn get_storage(
618 address: AccountId,
619 key: [u8; 32],
620 ) -> pallet_contracts_primitives::GetStorageResult {
621 Contracts::get_storage(address, key)
622 }
623
624 fn rent_projection(
625 address: AccountId,
626 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {
627 Contracts::rent_projection(address)
628 }
629 }
630
631 impl sp_api::Core<Block> for Runtime {706 impl sp_api::Core<Block> for Runtime {
632 fn version() -> RuntimeVersion {707 fn version() -> RuntimeVersion {
688 }763 }
689 }764 }
690
691 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
692 fn slot_duration() -> u64 {
693 Aura::slot_duration()
694 }
695
696 fn authorities() -> Vec<AuraId> {
697 Aura::authorities()
698 }
699 }
700765
701 impl sp_session::SessionKeys<Block> for Runtime {766 impl sp_session::SessionKeys<Block> for Runtime {
702 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {767 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
710 }775 }
711 }776 }
712777
713 impl fg_primitives::GrandpaApi<Block> for Runtime {
714 fn grandpa_authorities() -> GrandpaAuthorityList {
715 Grandpa::grandpa_authorities()
716 }
717
718 fn submit_report_equivocation_unsigned_extrinsic(
719 _equivocation_proof: fg_primitives::EquivocationProof<
720 <Block as BlockT>::Hash,
721 NumberFor<Block>,
722 >,
723 _key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,
724 ) -> Option<()> {
725 None
726 }
727
728 fn generate_key_ownership_proof(
729 _set_id: fg_primitives::SetId,
730 _authority_id: GrandpaId,
731 ) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {
732 // NOTE: this is the only implementation possible since we've
733 // defined our key owner proof type as a bottom type (i.e. a type
734 // with no values).
735 None
736 }
737 }
738
739 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {778 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
740 fn account_nonce(account: AccountId) -> Index {779 fn account_nonce(account: AccountId) -> Index {
751 }790 }
752 }791 }
792
793 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>
794 for Runtime
795 {
796 fn call(
797 origin: AccountId,
798 dest: AccountId,
799 value: Balance,
800 gas_limit: u64,
801 input_data: Vec<u8>,
802 ) -> pallet_contracts_primitives::ContractExecResult {
803 Contracts::bare_call(origin, dest, value, gas_limit, input_data)
804 }
805
806 fn get_storage(
807 address: AccountId,
808 key: [u8; 32],
809 ) -> pallet_contracts_primitives::GetStorageResult {
810 Contracts::get_storage(address, key)
811 }
812
813 fn rent_projection(
814 address: AccountId,
815 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {
816 Contracts::rent_projection(address)
817 }
818 }
753819
754 #[cfg(feature = "runtime-benchmarks")]820 #[cfg(feature = "runtime-benchmarks")]
755 impl frame_benchmarking::Benchmark<Block> for Runtime {821 impl frame_benchmarking::Benchmark<Block> for Runtime {