@@ -101,6 +101,7 @@ use sp_version::RuntimeVersion;
101
101
102
102
use nimbus_primitives:: CanAuthor ;
103
103
104
+ mod migrations;
104
105
mod precompiles;
105
106
pub use precompiles:: {
106
107
MoonbeamPrecompiles , PrecompileName , FOREIGN_ASSET_PRECOMPILE_ADDRESS_PREFIX ,
@@ -146,7 +147,7 @@ pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(WEIGHT_REF_TIME_PER_
146
147
. saturating_div ( 2 )
147
148
. set_proof_size ( relay_chain:: MAX_POV_SIZE as u64 ) ;
148
149
149
- pub const MILLISECS_PER_BLOCK : u64 = 12000 ;
150
+ pub const MILLISECS_PER_BLOCK : u64 = 6_000 ;
150
151
pub const MINUTES : BlockNumber = 60_000 / ( MILLISECS_PER_BLOCK as BlockNumber ) ;
151
152
pub const HOURS : BlockNumber = MINUTES * 60 ;
152
153
pub const DAYS : BlockNumber = HOURS * 24 ;
@@ -668,6 +669,19 @@ impl pallet_ethereum::Config for Runtime {
668
669
type ExtraDataLength = ConstU32 < 30 > ;
669
670
}
670
671
672
+ /// Maximum number of blocks simultaneously accepted by the Runtime, not yet included
673
+ /// into the relay chain.
674
+ const UNINCLUDED_SEGMENT_CAPACITY : u32 = 3 ;
675
+ /// How many parachain blocks are processed by the relay chain per parent. Limits the
676
+ /// number of blocks authored per slot.
677
+ const BLOCK_PROCESSING_VELOCITY : u32 = 1 ;
678
+
679
+ type ConsensusHook = pallet_async_backing:: consensus_hook:: FixedVelocityConsensusHook <
680
+ Runtime ,
681
+ BLOCK_PROCESSING_VELOCITY ,
682
+ UNINCLUDED_SEGMENT_CAPACITY ,
683
+ > ;
684
+
671
685
impl cumulus_pallet_parachain_system:: Config for Runtime {
672
686
type RuntimeEvent = RuntimeEvent ;
673
687
type OnSystemEvent = ( ) ;
@@ -676,8 +690,10 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
676
690
type OutboundXcmpMessageSource = XcmpQueue ;
677
691
type XcmpMessageHandler = XcmpQueue ;
678
692
type ReservedXcmpWeight = ReservedXcmpWeight ;
679
- type CheckAssociatedRelayNumber = cumulus_pallet_parachain_system:: RelayNumberStrictlyIncreases ;
680
- type ConsensusHook = cumulus_pallet_parachain_system:: ExpectParentIncluded ;
693
+ type CheckAssociatedRelayNumber =
694
+ cumulus_pallet_parachain_system:: RelayNumberMonotonicallyIncreases ;
695
+ //TODO: replace by ConsensusHookWrapperForRelayTimestamp
696
+ type ConsensusHook = ConsensusHook ;
681
697
type DmpQueue = frame_support:: traits:: EnqueueWithOrigin < MessageQueue , RelayOrigin > ;
682
698
type WeightInfo = cumulus_pallet_parachain_system:: weights:: SubstrateWeight < Runtime > ;
683
699
}
@@ -768,13 +784,11 @@ impl pallet_parachain_staking::OnInactiveCollator<Runtime> for OnInactiveCollato
768
784
type MonetaryGovernanceOrigin =
769
785
EitherOfDiverse < EnsureRoot < AccountId > , governance:: custom_origins:: GeneralAdmin > ;
770
786
771
- /// TODO:
772
- /// Temporary type that we should replace by RelayChainSlotProvider once async backing is enabled.
773
- pub struct StakingRoundSlotProvider ;
774
- impl Get < Slot > for StakingRoundSlotProvider {
787
+ pub struct RelayChainSlotProvider ;
788
+ impl Get < Slot > for RelayChainSlotProvider {
775
789
fn get ( ) -> Slot {
776
- let block_number : u64 = frame_system :: pallet:: Pallet :: < Runtime > :: block_number ( ) . into ( ) ;
777
- Slot :: from ( block_number )
790
+ let slot_info = pallet_async_backing :: pallet:: Pallet :: < Runtime > :: slot_info ( ) ;
791
+ slot_info . unwrap_or_default ( ) . 0
778
792
}
779
793
}
780
794
@@ -815,7 +829,7 @@ impl pallet_parachain_staking::Config for Runtime {
815
829
type PayoutCollatorReward = PayoutCollatorOrOrbiterReward ;
816
830
type OnInactiveCollator = OnInactiveCollator ;
817
831
type OnNewRound = OnNewRound ;
818
- type SlotProvider = StakingRoundSlotProvider ;
832
+ type SlotProvider = RelayChainSlotProvider ;
819
833
type WeightInfo = moonbeam_weights:: pallet_parachain_staking:: WeightInfo < Runtime > ;
820
834
type MaxCandidates = ConstU32 < 200 > ;
821
835
type SlotDuration = ConstU64 < 12_000 > ;
@@ -837,6 +851,12 @@ impl pallet_author_slot_filter::Config for Runtime {
837
851
type WeightInfo = moonbeam_weights:: pallet_author_slot_filter:: WeightInfo < Runtime > ;
838
852
}
839
853
854
+ impl pallet_async_backing:: Config for Runtime {
855
+ type AllowMultipleBlocksPerSlot = ConstBool < true > ;
856
+ type GetAndVerifySlot = pallet_async_backing:: RelaySlot ;
857
+ type ExpectedBlockTime = ConstU64 < 6000 > ;
858
+ }
859
+
840
860
parameter_types ! {
841
861
pub const InitializationPayment : Perbill = Perbill :: from_percent( 30 ) ;
842
862
pub const RelaySignaturesThreshold : Perbill = Perbill :: from_percent( 100 ) ;
@@ -1103,7 +1123,10 @@ impl pallet_proxy::Config for Runtime {
1103
1123
1104
1124
impl pallet_migrations:: Config for Runtime {
1105
1125
type RuntimeEvent = RuntimeEvent ;
1106
- type MigrationsList = ( moonbeam_runtime_common:: migrations:: CommonMigrations < Runtime > , ) ;
1126
+ type MigrationsList = (
1127
+ moonbeam_runtime_common:: migrations:: CommonMigrations < Runtime > ,
1128
+ migrations:: MoonbeamMigrations ,
1129
+ ) ;
1107
1130
type XcmExecutionManager = XcmExecutionManager ;
1108
1131
}
1109
1132
@@ -1347,6 +1370,7 @@ construct_runtime! {
1347
1370
AuthorFilter : pallet_author_slot_filter:: { Pallet , Call , Storage , Event , Config <T >} = 22 ,
1348
1371
AuthorMapping : pallet_author_mapping:: { Pallet , Call , Config <T >, Storage , Event <T >} = 23 ,
1349
1372
MoonbeamOrbiters : pallet_moonbeam_orbiters:: { Pallet , Call , Storage , Event <T >} = 24 ,
1373
+ AsyncBacking : pallet_async_backing:: { Pallet , Storage } = 25 ,
1350
1374
1351
1375
// Handy utilities.
1352
1376
Utility : pallet_utility:: { Pallet , Call , Event } = 30 ,
@@ -1572,12 +1596,10 @@ moonbeam_runtime_common::impl_runtime_apis_plus_common! {
1572
1596
1573
1597
impl async_backing_primitives:: UnincludedSegmentApi <Block > for Runtime {
1574
1598
fn can_build_upon(
1575
- _included_hash : <Block as BlockT >:: Hash ,
1576
- _slot : async_backing_primitives:: Slot ,
1599
+ included_hash : <Block as BlockT >:: Hash ,
1600
+ slot : async_backing_primitives:: Slot ,
1577
1601
) -> bool {
1578
- // This runtime API can be called only when asynchronous backing is enabled client-side
1579
- // We return false here to force the client to not use async backing in moonbeam.
1580
- false
1602
+ ConsensusHook :: can_build_upon( included_hash, slot)
1581
1603
}
1582
1604
}
1583
1605
}
0 commit comments