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
--- a/runtime/common/config/parachain.rs
+++ b/runtime/common/config/parachain.rs
@@ -43,6 +43,8 @@
 	#[cfg(feature = "lookahead")]
 	type CheckAssociatedRelayNumber =
 		cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
+	#[cfg(feature = "lookahead")]
+	type ConsensusHook = ConsensusHook;
 }
 
 impl parachain_info::Config for Runtime {}
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
44use up_common::types::{AccountId, BlockNumber};44use up_common::types::{AccountId, BlockNumber};
4545
46use crate::{46use crate::{
47 AllPalletsWithSystem, Aura, Balances, InherentDataExt, Runtime, RuntimeCall, Signature,47 AllPalletsWithSystem, Aura, Balances, Runtime, RuntimeCall, Signature,
48 Treasury,48 Treasury,
49};49};
5050
146 }146 }
147}147}
148148
149#[cfg(not(feature = "lookahead"))]
149pub(crate) struct CheckInherents;150pub(crate) struct CheckInherents;
150151
152#[cfg(not(feature = "lookahead"))]
151impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {153impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
152 fn check_inherents(154 fn check_inherents(
153 block: &Block,155 block: &Block,
154 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,156 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,
155 ) -> sp_inherents::CheckInherentsResult {157 ) -> sp_inherents::CheckInherentsResult {
158 use crate::InherentDataExt;
159
156 let relay_chain_slot = relay_state_proof160 let relay_chain_slot = relay_state_proof
157 .read_slot()161 .read_slot()
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>,
+);