git.delta.rocks / unique-network / refs/commits / 2df619c5c26c

difftreelog

fix lookahead leftovers

Yaroslav Bolyukin2023-11-17parent: #25775a5.patch.diff
in: master

6 files changed

modifiedprimitives/common/src/constants.rsdiffbeforeafterboth
--- a/primitives/common/src/constants.rs
+++ b/primitives/common/src/constants.rs
@@ -26,7 +26,7 @@
 #[cfg(not(feature = "lookahead"))]
 pub const MILLISECS_PER_BLOCK: u64 = 12000;
 #[cfg(feature = "lookahead")]
-pub const MILLISECS_PER_BLOCK: u64 = 3000;
+pub const MILLISECS_PER_BLOCK: u64 = 6000;
 pub const MILLISECS_PER_RELAY_BLOCK: u64 = 6000;
 
 pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
modifiedruntime/common/config/parachain.rsdiffbeforeafterboth
before · runtime/common/config/parachain.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use frame_support::{parameter_types, weights::Weight};18use up_common::constants::*;1920use crate::{DmpQueue, Runtime, RuntimeEvent, XcmpQueue};2122parameter_types! {23	pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);24	pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);25}2627impl cumulus_pallet_parachain_system::Config for Runtime {28	type RuntimeEvent = RuntimeEvent;29	type SelfParaId = parachain_info::Pallet<Self>;30	type OnSystemEvent = ();31	// type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<32	// 	MaxDownwardMessageWeight,33	// 	XcmExecutor<XcmConfig>,34	// 	Call,35	// >;36	type OutboundXcmpMessageSource = XcmpQueue;37	type DmpMessageHandler = DmpQueue;38	type ReservedDmpWeight = ReservedDmpWeight;39	type ReservedXcmpWeight = ReservedXcmpWeight;40	type XcmpMessageHandler = XcmpQueue;41	#[cfg(not(feature = "lookahead"))]42	type CheckAssociatedRelayNumber = cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;43	#[cfg(feature = "lookahead")]44	type CheckAssociatedRelayNumber =45		cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;46}4748impl parachain_info::Config for Runtime {}4950impl cumulus_pallet_aura_ext::Config for Runtime {}5152/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included53/// into the relay chain.54#[cfg(feature = "lookahead")]55const UNINCLUDED_SEGMENT_CAPACITY: u32 = 3;56/// How many parachain blocks are processed by the relay chain per parent. Limits the57/// number of blocks authored per slot.58#[cfg(feature = "lookahead")]59const BLOCK_PROCESSING_VELOCITY: u32 = 2;60#[cfg(feature = "lookahead")]61pub type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<62	Runtime,63	{ MILLISECS_PER_RELAY_BLOCK as u32 },64	BLOCK_PROCESSING_VELOCITY,65	UNINCLUDED_SEGMENT_CAPACITY,66>;
modifiedruntime/common/config/substrate.rsdiffbeforeafterboth
--- a/runtime/common/config/substrate.rs
+++ b/runtime/common/config/substrate.rs
@@ -17,7 +17,7 @@
 use frame_support::{
 	dispatch::DispatchClass,
 	ord_parameter_types, parameter_types,
-	traits::{ConstBool, ConstU32, Everything, NeverEnsureOrigin},
+	traits::{ConstBool, ConstU32, ConstU64, Everything, NeverEnsureOrigin},
 	weights::{
 		constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},
 		ConstantMultiplier,
@@ -134,15 +134,14 @@
 	type MaxKeyLen = MigrationMaxKeyLen;
 }
 
-parameter_types! {
-	pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
-}
-
 impl pallet_timestamp::Config for Runtime {
 	/// A timestamp: milliseconds since the unix epoch.
 	type Moment = u64;
 	type OnTimestampSet = ();
-	type MinimumPeriod = MinimumPeriod;
+	#[cfg(not(feature = "lookahead"))]
+	type MinimumPeriod = ConstU64<{SLOT_DURATION / 2}>;
+	#[cfg(feature = "lookahead")]
+	type MinimumPeriod = ConstU64<0>;
 	type WeightInfo = ();
 }
 
@@ -247,6 +246,8 @@
 	type DisabledValidators = ();
 	type MaxAuthorities = MaxAuthorities;
 	type AllowMultipleBlocksPerSlot = ConstBool<true>;
+	#[cfg(feature = "lookahead")]
+	type SlotDuration = ConstU64<SLOT_DURATION>;
 }
 
 impl pallet_utility::Config for Runtime {
modifiedruntime/common/mod.rsdiffbeforeafterboth
--- a/runtime/common/mod.rs
+++ b/runtime/common/mod.rs
@@ -44,7 +44,7 @@
 use up_common::types::{AccountId, BlockNumber};
 
 use crate::{
-	AllPalletsWithSystem, Aura, Balances, InherentDataExt, Runtime, RuntimeCall, Signature,
+	AllPalletsWithSystem, Aura, Balances, Runtime, RuntimeCall, Signature,
 	Treasury,
 };
 
@@ -146,13 +146,17 @@
 	}
 }
 
+#[cfg(not(feature = "lookahead"))]
 pub(crate) struct CheckInherents;
 
+#[cfg(not(feature = "lookahead"))]
 impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
 	fn check_inherents(
 		block: &Block,
 		relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,
 	) -> sp_inherents::CheckInherentsResult {
+		use crate::InherentDataExt;
+
 		let relay_chain_slot = relay_state_proof
 			.read_slot()
 			.expect("Could not read the relay chain slot from the proof");
modifiedruntime/common/runtime_apis.rsdiffbeforeafterboth
--- a/runtime/common/runtime_apis.rs
+++ b/runtime/common/runtime_apis.rs
@@ -485,7 +485,14 @@
 
 			impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
 				fn slot_duration() -> sp_consensus_aura::SlotDuration {
-					sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
+					#[cfg(not(feature = "lookahead"))]
+					{
+						sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
+					}
+					#[cfg(feature = "lookahead")]
+					{
+						sp_consensus_aura::SlotDuration::from_millis(up_common::constants::SLOT_DURATION)
+					}
 				}
 
 				fn authorities() -> Vec<AuraId> {
modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
--- a/runtime/opal/src/lib.rs
+++ b/runtime/opal/src/lib.rs
@@ -67,8 +67,15 @@
 
 impl_common_runtime_apis!();
 
+// CheckInherents is included in consensus hook
+#[cfg(not(feature = "lookahead"))]
 cumulus_pallet_parachain_system::register_validate_block!(
 	Runtime = Runtime,
 	BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
 	CheckInherents = CheckInherents,
 );
+#[cfg(feature = "lookahead")]
+cumulus_pallet_parachain_system::register_validate_block!(
+	Runtime = Runtime,
+	BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
+);