Skip to content

Commit 98cc33d

Browse files
author
Ayush
committed
Fixed compilation error in runtime and modified to make it compatible for Kusama
1 parent c080905 commit 98cc33d

File tree

2 files changed

+94
-47
lines changed

2 files changed

+94
-47
lines changed

runtime/Cargo.toml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ git = 'https://github.com/paritytech/substrate.git'
150150
branch = "polkadot-v0.9.8"
151151
version = '3.0.0'
152152

153+
[dependencies.sp-consensus-aura]
154+
default-features = false
155+
git = 'https://github.com/paritytech/substrate.git'
156+
branch = "polkadot-v0.9.8"
157+
153158
[dependencies.sp-inherents]
154159
default-features = false
155160
git = 'https://github.com/paritytech/substrate.git'
@@ -220,6 +225,11 @@ git = 'https://github.com/paritytech/cumulus.git'
220225
branch = "polkadot-v0.9.8"
221226
default-features = false
222227

228+
[dependencies.cumulus-pallet-dmp-queue]
229+
git = 'https://github.com/paritytech/cumulus.git'
230+
branch = "polkadot-v0.9.8"
231+
default-features = false
232+
223233
[dependencies.cumulus-primitives-utility]
224234
git = 'https://github.com/paritytech/cumulus.git'
225235
branch = "polkadot-v0.9.8"
@@ -266,13 +276,12 @@ git = "https://github.com/paritytech/polkadot"
266276
branch = "release-v0.9.8"
267277
default-features = false
268278

269-
[dependencies.pallet-balances]
270-
default-features = false
271-
git = 'https://github.com/paritytech/substrate.git'
279+
[dependencies.pallet-aura]
280+
git = "https://github.com/paritytech/substrate"
272281
branch = "polkadot-v0.9.8"
273-
version = '3.0.0'
282+
default-features = false
274283

275-
[dependencies.pallet-babe]
284+
[dependencies.pallet-balances]
276285
default-features = false
277286
git = 'https://github.com/paritytech/substrate.git'
278287
branch = "polkadot-v0.9.8"
@@ -327,12 +336,6 @@ git = 'https://github.com/paritytech/substrate.git'
327336
branch = "polkadot-v0.9.8"
328337
version = '3.0.0'
329338

330-
[dependencies.sp-consensus-babe]
331-
default-features = false
332-
git = 'https://github.com/paritytech/substrate.git'
333-
branch = "polkadot-v0.9.8"
334-
version = '0.9.0'
335-
336339
[dependencies.sp-staking]
337340
default-features = false
338341
git = 'https://github.com/paritytech/substrate.git'
@@ -375,7 +378,6 @@ std = [
375378
"pallet-timestamp/std",
376379
"pallet-sudo/std",
377380
"pallet-transaction-payment/std",
378-
'pallet-babe/std',
379381
'pallet-grandpa/std',
380382
'pallet-indices/std',
381383
'pallet-collective/std',
@@ -392,6 +394,7 @@ std = [
392394
"xcm-executor/std",
393395
"cumulus-pallet-xcm/std",
394396
"cumulus-pallet-xcmp-queue/std",
395-
'sp-consensus-babe/std',
396397
"cumulus-pallet-aura-ext/std",
398+
"pallet-aura/std",
399+
"sp-consensus-aura/std",
397400
]

runtime/src/lib.rs

Lines changed: 78 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,7 @@ use sp_version::NativeVersion;
4343
use sp_version::RuntimeVersion;
4444
use pallet_xcm::XcmPassthrough;
4545
use polkadot_parachain::primitives::Sibling;
46-
use xcm::v0::{
47-
BodyId,
48-
Junction,
49-
Junction::*,
50-
MultiLocation,
51-
MultiLocation::*,
52-
NetworkId,
53-
};
46+
use xcm::v0::{BodyId, Junction::*, MultiAsset, MultiLocation, MultiLocation::*, NetworkId, Xcm};
5447
use xcm_builder::{
5548
IsConcrete,
5649
AccountId32Aliases,
@@ -69,6 +62,8 @@ use xcm_builder::{
6962
AllowUnpaidExecutionFrom,
7063
FixedWeightBounds,
7164
UsingComponents,
65+
SignedToAccountId32,
66+
EnsureXcmOrigin,
7267
};
7368
use xcm_executor::{
7469
Config,
@@ -105,6 +100,7 @@ pub use frame_support::{
105100
pub use pallet_balances::Call as BalancesCall;
106101
// pub use pallet_staking::StakerStatus;
107102
pub use pallet_timestamp::Call as TimestampCall;
103+
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
108104
#[cfg(any(feature = "std", test))]
109105
pub use sp_runtime::BuildStorage;
110106
pub use sp_runtime::{
@@ -314,6 +310,7 @@ impl pallet_timestamp::Config for Runtime {
314310
parameter_types! {
315311
pub const ExistentialDeposit: u128 = 500;
316312
pub const MaxLocks: u32 = 50;
313+
pub const MaxReserves: u32 = 50;
317314
}
318315

319316
impl pallet_balances::Config for Runtime {
@@ -325,7 +322,9 @@ impl pallet_balances::Config for Runtime {
325322
type Event = Event;
326323
type ExistentialDeposit = ExistentialDeposit;
327324
type MaxLocks = MaxLocks;
325+
type MaxReserves = MaxReserves;
328326
type WeightInfo = ();
327+
type ReserveIdentifier = [u8; 8];
329328
}
330329

331330
parameter_types! {
@@ -408,6 +407,8 @@ parameter_types! {
408407
pub const BountyUpdatePeriod: u32 = 20;
409408
pub const DataDepositPerByte: u64 = 1;
410409
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
410+
pub const MaxApprovals: u32 = 100;
411+
411412
}
412413

413414
impl pallet_treasury::Config for Runtime {
@@ -436,6 +437,7 @@ impl pallet_treasury::Config for Runtime {
436437
// type Tippers = GeneralCouncilProvider;
437438
// Just gets burned.
438439
type WeightInfo = ();
440+
type MaxApprovals = MaxApprovals;
439441
}
440442

441443
parameter_types! {
@@ -726,12 +728,10 @@ impl membership_supernodes::Config for Runtime {
726728
}
727729

728730
parameter_types! {
729-
pub const RococoLocation: MultiLocation = MultiLocation::X1(Junction::Parent);
731+
pub const RococoLocation: MultiLocation = MultiLocation::X1(Parent);
730732
pub const RococoNetwork: NetworkId = NetworkId::Polkadot;
731733
pub RelayChainOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();
732-
pub Ancestry: MultiLocation = Junction::Parachain {
733-
id: ParachainInfo::parachain_id().into()
734-
}.into();
734+
pub Ancestry: MultiLocation = X1(Parachain(ParachainInfo::parachain_id().into()));
735735
}
736736

737737
/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
@@ -820,7 +820,34 @@ impl Config for XcmConfig {
820820
type ResponseHandler = (); // Don't handle responses for now.
821821
}
822822

823-
impl cumulus_pallet_xcm::Config for Runtime {}
823+
/// No local origins on this chain are allowed to dispatch XCM sends/executions.
824+
pub type LocalOriginToLocation = SignedToAccountId32<Origin, AccountId, RococoNetwork>;
825+
826+
/// The means for routing XCM messages which are not for local execution into the right message
827+
/// queues.
828+
pub type XcmRouter = (
829+
// Two routers - use UMP to communicate with the relay chain:
830+
cumulus_primitives_utility::ParentAsUmp<ParachainSystem>,
831+
// ..and XCMP to communicate with the sibling chains.
832+
XcmpQueue,
833+
);
834+
835+
impl pallet_xcm::Config for Runtime {
836+
type Event = Event;
837+
type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
838+
type XcmRouter = XcmRouter;
839+
type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
840+
type XcmExecuteFilter = All<(MultiLocation, Xcm<Call>)>;
841+
type XcmExecutor = XcmExecutor<XcmConfig>;
842+
type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>;
843+
type XcmReserveTransferFilter = ();
844+
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
845+
}
846+
847+
impl cumulus_pallet_xcm::Config for Runtime {
848+
type Event = Event;
849+
type XcmExecutor = XcmExecutor<XcmConfig>;
850+
}
824851

825852
impl cumulus_pallet_xcmp_queue::Config for Runtime {
826853
type Event = Event;
@@ -832,36 +859,39 @@ parameter_types! {
832859
pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;
833860
}
834861

835-
/// No local origins on this chain are allowed to dispatch XCM sends/executions.
836-
pub type LocalOriginToLocation = ();
837-
838-
/// The means for routing XCM messages which are not for local execution into the right message
839-
/// queues.
840-
pub type XcmRouter = (
841-
// Two routers - use UMP to communicate with the relay chain:
842-
cumulus_primitives_utility::ParentAsUmp<ParachainSystem>,
843-
// ..and XCMP to communicate with the sibling chains.
844-
XcmpQueue,
845-
);
846-
847862
parameter_types! {
848863
pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;
864+
pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;
849865
}
850866

851867
impl cumulus_pallet_parachain_system::Config for Runtime {
852-
type Event = Event;
853-
type OnValidationData = ();
854-
type SelfParaId = parachain_info::Module<Runtime>;
855-
type OutboundXcmpMessageSource = XcmpQueue;
856-
type XcmpMessageHandler = XcmpQueue;
857-
type ReservedXcmpWeight = ReservedXcmpWeight;
858-
868+
type Event = Event;
869+
type OnValidationData = ();
870+
type SelfParaId = parachain_info::Pallet<Runtime>;
871+
type OutboundXcmpMessageSource = XcmpQueue;
872+
type DmpMessageHandler = DmpQueue;
873+
type ReservedDmpWeight = ReservedDmpWeight;
874+
type XcmpMessageHandler = XcmpQueue;
875+
type ReservedXcmpWeight = ReservedXcmpWeight;
859876
}
860877

878+
861879
impl parachain_info::Config for Runtime {}
862880

863881
impl cumulus_pallet_aura_ext::Config for Runtime {}
864882

883+
impl pallet_randomness_collective_flip::Config for Runtime {}
884+
885+
impl cumulus_pallet_dmp_queue::Config for Runtime {
886+
type Event = Event;
887+
type XcmExecutor = XcmExecutor<XcmConfig>;
888+
type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;
889+
}
890+
891+
impl pallet_aura::Config for Runtime {
892+
type AuthorityId = AuraId;
893+
}
894+
865895
// Create the runtime by composing the FRAME pallets that were previously configured.
866896
construct_runtime!(
867897
pub enum Runtime where
@@ -874,6 +904,7 @@ construct_runtime!(
874904
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
875905
//Indices: pallet_indices::{Pallet, Call, Storage, Event<T>, Config<T>},
876906
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
907+
Aura: pallet_aura::{Pallet, Config<T>},
877908
AuraExt: cumulus_pallet_aura_ext::{Pallet, Config},
878909
TransactionPayment: pallet_transaction_payment::{Pallet, Storage},
879910
Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>},
@@ -913,8 +944,10 @@ construct_runtime!(
913944
// PARACHAIN
914945
ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>},
915946
ParachainInfo: parachain_info::{Pallet, Storage, Config},
916-
XcmHandler: cumulus_pallet_xcm::{Pallet, Origin},
947+
PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin},
948+
XcmHandler: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin},
917949
XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>},
950+
DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>},
918951
}
919952
);
920953

@@ -993,8 +1026,9 @@ impl_runtime_apis! {
9931026
fn validate_transaction(
9941027
source: TransactionSource,
9951028
tx: <Block as BlockT>::Extrinsic,
1029+
block_hash: <Block as BlockT>::Hash,
9961030
) -> TransactionValidity {
997-
Executive::validate_transaction(source, tx)
1031+
Executive::validate_transaction(source, tx, block_hash)
9981032
}
9991033
}
10001034

@@ -1016,6 +1050,16 @@ impl_runtime_apis! {
10161050
}
10171051
}
10181052

1053+
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
1054+
fn slot_duration() -> sp_consensus_aura::SlotDuration {
1055+
sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
1056+
}
1057+
1058+
fn authorities() -> Vec<AuraId> {
1059+
Aura::authorities()
1060+
}
1061+
}
1062+
10191063
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
10201064
fn account_nonce(account: AccountId) -> Index {
10211065
System::account_nonce(account)

0 commit comments

Comments
 (0)