@@ -32,22 +32,18 @@ use primitives::v1::{
32
32
SessionInfo as SessionInfoData ,
33
33
} ;
34
34
use runtime_common:: {
35
- SlowAdjustingFeeUpdate ,
36
- impls:: ToAuthor ,
37
- BlockHashCount , BlockWeights , BlockLength , RocksDbWeight , OffchainSolutionWeightLimit ,
35
+ SlowAdjustingFeeUpdate , impls:: ToAuthor , BlockHashCount , BlockWeights , BlockLength , RocksDbWeight ,
38
36
} ;
39
37
use runtime_parachains:: {
40
38
self ,
41
39
runtime_api_impl:: v1 as runtime_api_impl,
42
40
} ;
43
41
use frame_support:: {
44
- parameter_types, construct_runtime, debug,
45
- traits:: { KeyOwnerProofSystem , Filter } ,
46
- weights:: Weight ,
42
+ parameter_types, construct_runtime, debug, traits:: { KeyOwnerProofSystem , Filter , EnsureOrigin } , weights:: Weight ,
47
43
} ;
48
44
use sp_runtime:: {
49
45
create_runtime_str, generic, impl_opaque_keys,
50
- ApplyExtrinsicResult , KeyTypeId , Perbill , curve :: PiecewiseLinear ,
46
+ ApplyExtrinsicResult , KeyTypeId , Perbill ,
51
47
transaction_validity:: { TransactionValidity , TransactionSource , TransactionPriority } ,
52
48
traits:: {
53
49
BlakeTwo256 , Block as BlockT , OpaqueKeys , IdentityLookup ,
@@ -64,7 +60,7 @@ use pallet_grandpa::{AuthorityId as GrandpaId, fg_primitives};
64
60
use sp_core:: OpaqueMetadata ;
65
61
use sp_staking:: SessionIndex ;
66
62
use pallet_session:: historical as session_historical;
67
- use frame_system:: EnsureRoot ;
63
+ use frame_system:: { EnsureRoot , EnsureOneOf , EnsureSigned } ;
68
64
use runtime_common:: { paras_sudo_wrapper, paras_registrar} ;
69
65
70
66
use runtime_parachains:: origin as parachains_origin;
@@ -78,10 +74,8 @@ use runtime_parachains::dmp as parachains_dmp;
78
74
use runtime_parachains:: ump as parachains_ump;
79
75
use runtime_parachains:: hrmp as parachains_hrmp;
80
76
use runtime_parachains:: scheduler as parachains_scheduler;
81
- use runtime_parachains:: reward_points:: RewardValidatorsWithEraPoints ;
82
77
83
78
pub use pallet_balances:: Call as BalancesCall ;
84
- pub use pallet_staking:: StakerStatus ;
85
79
86
80
use polkadot_parachain:: primitives:: Id as ParaId ;
87
81
use xcm:: v0:: { MultiLocation , NetworkId } ;
@@ -91,10 +85,11 @@ use xcm_builder::{
91
85
CurrencyAdapter as XcmCurrencyAdapter , ChildParachainAsNative ,
92
86
SignedAccountId32AsNative , ChildSystemParachainAsSuperuser , LocationInverter ,
93
87
} ;
88
+ use constants:: { time:: * , currency:: * , fee:: * } ;
94
89
95
90
/// Constant values used within the runtime.
96
91
pub mod constants;
97
- use constants :: { time :: * , currency :: * , fee :: * } ;
92
+ mod propose_parachain ;
98
93
99
94
// Make the WASM binary available.
100
95
#[ cfg( feature = "std" ) ]
@@ -105,7 +100,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
105
100
spec_name : create_runtime_str ! ( "rococo" ) ,
106
101
impl_name : create_runtime_str ! ( "parity-rococo-v1" ) ,
107
102
authoring_version : 0 ,
108
- spec_version : 14 ,
103
+ spec_version : 15 ,
109
104
impl_version : 0 ,
110
105
#[ cfg( not( feature = "disable-runtime-api" ) ) ]
111
106
apis : RUNTIME_API_VERSIONS ,
@@ -182,7 +177,6 @@ construct_runtime! {
182
177
183
178
// Consensus support.
184
179
Authorship : pallet_authorship:: { Module , Call , Storage } ,
185
- Staking : pallet_staking:: { Module , Call , Storage , Config <T >, Event <T >, ValidateUnsigned } ,
186
180
Offences : pallet_offences:: { Module , Call , Storage , Event } ,
187
181
Historical : session_historical:: { Module } ,
188
182
Session : pallet_session:: { Module , Call , Storage , Event , Config <T >} ,
@@ -208,6 +202,9 @@ construct_runtime! {
208
202
209
203
// Sudo
210
204
Sudo : pallet_sudo:: { Module , Call , Storage , Event <T >, Config <T >} ,
205
+
206
+ // Propose parachain pallet.
207
+ ProposeParachain : propose_parachain:: { Module , Call , Storage , Event } ,
211
208
}
212
209
}
213
210
@@ -304,35 +301,15 @@ impl frame_system::offchain::SigningTypes for Runtime {
304
301
type Signature = Signature ;
305
302
}
306
303
307
- impl pallet_session:: historical:: Config for Runtime {
308
- type FullIdentification = pallet_staking:: Exposure < AccountId , Balance > ;
309
- type FullIdentificationOf = pallet_staking:: ExposureOf < Runtime > ;
304
+ /// Special `FullIdentificationOf` implementation that is returning for every input `Some(Default::default())`.
305
+ pub struct FullIdentificationOf ;
306
+ impl sp_runtime:: traits:: Convert < AccountId , Option < ( ) > > for FullIdentificationOf {
307
+ fn convert ( _: AccountId ) -> Option < ( ) > { Some ( Default :: default ( ) ) }
310
308
}
311
309
312
- pallet_staking_reward_curve:: build! {
313
- const REWARD_CURVE : PiecewiseLinear <' static > = curve!(
314
- min_inflation: 0_025_000 ,
315
- max_inflation: 0_100_000 ,
316
- ideal_stake: 0_500_000 ,
317
- falloff: 0_050_000 ,
318
- max_piece_count: 40 ,
319
- test_precision: 0_005_000 ,
320
- ) ;
321
- }
322
-
323
- parameter_types ! {
324
- // Six sessions in an era (6 hours).
325
- pub const SessionsPerEra : SessionIndex = 6 ;
326
- // 28 eras for unbonding (7 days).
327
- pub const BondingDuration : pallet_staking:: EraIndex = 28 ;
328
- // 27 eras in which slashes can be cancelled (~7 days).
329
- pub const SlashDeferDuration : pallet_staking:: EraIndex = 27 ;
330
- pub const RewardCurve : & ' static PiecewiseLinear <' static > = & REWARD_CURVE ;
331
- pub const MaxNominatorRewardedPerValidator : u32 = 64 ;
332
- // quarter of the last session will be for election.
333
- pub ElectionLookahead : BlockNumber = EpochDurationInBlocks :: get( ) / 4 ;
334
- pub const MaxIterations : u32 = 10 ;
335
- pub MinSolutionScoreBump : Perbill = Perbill :: from_rational_approximation( 5u32 , 10_000 ) ;
310
+ impl pallet_session:: historical:: Config for Runtime {
311
+ type FullIdentification = ( ) ;
312
+ type FullIdentificationOf = FullIdentificationOf ;
336
313
}
337
314
338
315
parameter_types ! {
@@ -353,32 +330,6 @@ impl pallet_im_online::Config for Runtime {
353
330
type WeightInfo = ( ) ;
354
331
}
355
332
356
- impl pallet_staking:: Config for Runtime {
357
- type Currency = Balances ;
358
- type UnixTime = Timestamp ;
359
- type CurrencyToVote = frame_support:: traits:: U128CurrencyToVote ;
360
- type RewardRemainder = ( ) ;
361
- type Event = Event ;
362
- type Slash = ( ) ;
363
- type Reward = ( ) ;
364
- type SessionsPerEra = SessionsPerEra ;
365
- type BondingDuration = BondingDuration ;
366
- type SlashDeferDuration = SlashDeferDuration ;
367
- // A majority of the council can cancel the slash.
368
- type SlashCancelOrigin = EnsureRoot < AccountId > ;
369
- type SessionInterface = Self ;
370
- type RewardCurve = RewardCurve ;
371
- type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator ;
372
- type NextNewSession = Session ;
373
- type ElectionLookahead = ElectionLookahead ;
374
- type Call = Call ;
375
- type UnsignedPriority = StakingUnsignedPriority ;
376
- type MaxIterations = MaxIterations ;
377
- type OffchainSolutionWeightLimit = OffchainSolutionWeightLimit ;
378
- type MinSolutionScoreBump = MinSolutionScoreBump ;
379
- type WeightInfo = ( ) ;
380
- }
381
-
382
333
parameter_types ! {
383
334
pub const ExistentialDeposit : Balance = 1 * CENTS ;
384
335
pub const MaxLocks : u32 = 50 ;
@@ -414,7 +365,7 @@ parameter_types! {
414
365
impl pallet_offences:: Config for Runtime {
415
366
type Event = Event ;
416
367
type IdentificationTuple = pallet_session:: historical:: IdentificationTuple < Self > ;
417
- type OnOffenceHandler = Staking ;
368
+ type OnOffenceHandler = ( ) ;
418
369
type WeightSoftLimit = OffencesWeightSoftLimit ;
419
370
}
420
371
@@ -445,13 +396,19 @@ parameter_types! {
445
396
pub const DisabledValidatorsThreshold : Perbill = Perbill :: from_percent( 17 ) ;
446
397
}
447
398
399
+ /// Special `ValidatorIdOf` implementation that is just returning the input as result.
400
+ pub struct ValidatorIdOf ;
401
+ impl sp_runtime:: traits:: Convert < AccountId , Option < AccountId > > for ValidatorIdOf {
402
+ fn convert ( a : AccountId ) -> Option < AccountId > { Some ( a) }
403
+ }
404
+
448
405
impl pallet_session:: Config for Runtime {
449
406
type Event = Event ;
450
407
type ValidatorId = AccountId ;
451
- type ValidatorIdOf = pallet_staking :: StashOf < Self > ;
408
+ type ValidatorIdOf = ValidatorIdOf ;
452
409
type ShouldEndSession = Babe ;
453
410
type NextSessionRotation = Babe ;
454
- type SessionManager = pallet_session:: historical:: NoteHistoricalRoot < Self , Staking > ;
411
+ type SessionManager = pallet_session:: historical:: NoteHistoricalRoot < Self , ProposeParachain > ;
455
412
type SessionHandler = <SessionKeys as OpaqueKeys >:: KeyTypeIdProviders ;
456
413
type Keys = SessionKeys ;
457
414
type DisabledValidatorsThreshold = DisabledValidatorsThreshold ;
@@ -531,16 +488,23 @@ impl pallet_authorship::Config for Runtime {
531
488
type FindAuthor = pallet_session:: FindAccountFromAuthorIndex < Self , Babe > ;
532
489
type UncleGenerations = UncleGenerations ;
533
490
type FilterUncle = ( ) ;
534
- type EventHandler = ( Staking , ImOnline ) ;
491
+ type EventHandler = ImOnline ;
535
492
}
536
493
537
494
impl parachains_origin:: Config for Runtime { }
538
495
539
496
impl parachains_configuration:: Config for Runtime { }
540
497
498
+ /// Special `RewardValidators` that does nothing ;)
499
+ pub struct RewardValidators ;
500
+ impl runtime_parachains:: inclusion:: RewardValidators for RewardValidators {
501
+ fn reward_backing ( _: impl IntoIterator < Item =ValidatorIndex > ) { }
502
+ fn reward_bitfields ( _: impl IntoIterator < Item =ValidatorIndex > ) { }
503
+ }
504
+
541
505
impl parachains_inclusion:: Config for Runtime {
542
506
type Event = Event ;
543
- type RewardValidators = RewardValidatorsWithEraPoints < Runtime > ;
507
+ type RewardValidators = RewardValidators ;
544
508
}
545
509
546
510
impl parachains_paras:: Config for Runtime {
@@ -621,6 +585,41 @@ impl pallet_sudo::Config for Runtime {
621
585
type Call = Call ;
622
586
}
623
587
588
+ /// Priviledged origin used by propose parachain.
589
+ pub struct PriviledgedOrigin ;
590
+
591
+ impl EnsureOrigin < Origin > for PriviledgedOrigin {
592
+ type Success = ( ) ;
593
+
594
+ fn try_origin ( o : Origin ) -> Result < Self :: Success , Origin > {
595
+ let allowed = [
596
+ hex_literal:: hex!( "b44c58e50328768ac06ed44b842bfa69d86ea10f60bc36156c9ffc5e00867220" ) ,
597
+ hex_literal:: hex!( "762a6a38ba72b139cba285a39a6766e02046fb023f695f5ecf7f48b037c0dd6b" )
598
+ ] ;
599
+
600
+ let origin = o. clone ( ) ;
601
+ match EnsureSigned :: try_origin ( o) {
602
+ Ok ( who) if allowed. iter ( ) . any ( |a| a == & who. as_ref ( ) ) => Ok ( ( ) ) ,
603
+ _ => Err ( origin) ,
604
+ }
605
+ }
606
+
607
+ #[ cfg( feature = "runtime-benchmarks" ) ]
608
+ fn successful_origin ( ) -> Origin { Origin :: root ( ) }
609
+ }
610
+
611
+ parameter_types ! {
612
+ pub const ProposeDeposit : Balance = 1000 * DOLLARS ;
613
+ pub const MaxNameLength : u32 = 20 ;
614
+ }
615
+
616
+ impl propose_parachain:: Config for Runtime {
617
+ type Event = Event ;
618
+ type MaxNameLength = MaxNameLength ;
619
+ type ProposeDeposit = ProposeDeposit ;
620
+ type PriviledgedOrigin = EnsureOneOf < AccountId , EnsureRoot < AccountId > , PriviledgedOrigin > ;
621
+ }
622
+
624
623
#[ cfg( not( feature = "disable-runtime-api" ) ) ]
625
624
sp_api:: impl_runtime_apis! {
626
625
impl sp_api:: Core <Block > for Runtime {
0 commit comments