From 822af50fb942d65aa95ee90eeaf576f1e729c1d8 Mon Sep 17 00:00:00 2001 From: 1xstj <106580853+1xstj@users.noreply.github.com> Date: Wed, 27 Dec 2023 10:21:33 +0000 Subject: [PATCH] fix: Mainnet halts at block 100 --- primitives/src/lib.rs | 19 ------------------- runtime/mainnet/src/lib.rs | 21 +++++++++------------ runtime/testnet/src/lib.rs | 20 ++++++++------------ 3 files changed, 17 insertions(+), 43 deletions(-) diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 6d5fbb930..71e3695fc 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -43,13 +43,8 @@ pub mod time { /// slot_duration()`. /// /// Change this to adjust the block time. - #[cfg(not(feature = "integration-tests"))] pub const SECONDS_PER_BLOCK: Moment = 6; - #[allow(clippy::identity_op)] - #[cfg(feature = "integration-tests")] - pub const SECONDS_PER_BLOCK: Moment = 3; - pub const MILLISECS_PER_BLOCK: Moment = SECONDS_PER_BLOCK * 1000; pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK; @@ -142,20 +137,6 @@ pub mod fee { } } -/// The number of blocks in one session -#[allow(clippy::identity_op)] -#[cfg(feature = "integration-tests")] -pub const SESSION_PERIOD_BLOCKS: BlockNumber = 20 * crate::time::MINUTES; - -#[cfg(not(feature = "integration-tests"))] -pub const SESSION_PERIOD_BLOCKS: BlockNumber = 6 * crate::time::HOURS; - -#[cfg(not(feature = "integration-tests"))] -pub const UNSIGNED_PROPOSAL_EXPIRY: BlockNumber = SESSION_PERIOD_BLOCKS / 4; - -#[cfg(feature = "integration-tests")] -pub const UNSIGNED_PROPOSAL_EXPIRY: BlockNumber = SESSION_PERIOD_BLOCKS; - /// We assume that ~10% of the block weight is consumed by `on_initialize` handlers. This is /// used to limit the maximal weight of a single extrinsic. pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10); diff --git a/runtime/mainnet/src/lib.rs b/runtime/mainnet/src/lib.rs index c72d5f8b6..883ba0f93 100644 --- a/runtime/mainnet/src/lib.rs +++ b/runtime/mainnet/src/lib.rs @@ -99,7 +99,7 @@ pub use sp_runtime::{MultiAddress, Perbill, Percent, Permill}; pub use tangle_primitives::{ currency::*, fee::*, time::*, AccountId, AccountIndex, Address, Balance, BlockNumber, Hash, Header, Index, Moment, Signature, AVERAGE_ON_INITIALIZE_RATIO, MAXIMUM_BLOCK_WEIGHT, - NORMAL_DISPATCH_RATIO, SESSION_PERIOD_BLOCKS, UNSIGNED_PROPOSAL_EXPIRY, + NORMAL_DISPATCH_RATIO, }; use pallet_airdrop_claims::TestWeightInfo; @@ -368,21 +368,18 @@ impl pallet_authorship::Config for Runtime { type FindAuthor = pallet_session::FindAccountFromAuthorIndex; } -parameter_types! { - pub const Period: BlockNumber = SESSION_PERIOD_BLOCKS; - pub const Offset: BlockNumber = 0; -} +use crate::opaque::SessionKeys; impl pallet_session::Config for Runtime { type RuntimeEvent = RuntimeEvent; type ValidatorId = ::AccountId; type ValidatorIdOf = pallet_staking::StashOf; - type ShouldEndSession = pallet_session::PeriodicSessions; - type NextSessionRotation = pallet_session::PeriodicSessions; - type SessionManager = Staking; - type SessionHandler = ::KeyTypeIdProviders; - type Keys = opaque::SessionKeys; - type WeightInfo = pallet_session::weights::SubstrateWeight; + type ShouldEndSession = Babe; + type NextSessionRotation = Babe; + type SessionManager = pallet_session::historical::NoteHistoricalRoot; + type SessionHandler = ::KeyTypeIdProviders; + type Keys = SessionKeys; + type WeightInfo = (); } impl pallet_session::historical::Config for Runtime { @@ -949,7 +946,7 @@ parameter_types! { impl pallet_im_online::Config for Runtime { type AuthorityId = ImOnlineId; type RuntimeEvent = RuntimeEvent; - type NextSessionRotation = pallet_session::PeriodicSessions; + type NextSessionRotation = Babe; type ValidatorSet = Historical; type ReportUnresponsiveness = (); type UnsignedPriority = ImOnlineUnsignedPriority; diff --git a/runtime/testnet/src/lib.rs b/runtime/testnet/src/lib.rs index 0092d94e8..05852eb87 100644 --- a/runtime/testnet/src/lib.rs +++ b/runtime/testnet/src/lib.rs @@ -110,7 +110,6 @@ pub use tangle_primitives::{ verifier::{arkworks::ArkworksVerifierGroth16Bn254, circom::CircomVerifierGroth16Bn254}, AccountId, AccountIndex, Address, BabeId, Balance, BlockNumber, Hash, Header, Index, Moment, Signature, AVERAGE_ON_INITIALIZE_RATIO, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, - SESSION_PERIOD_BLOCKS, UNSIGNED_PROPOSAL_EXPIRY, }; use pallet_airdrop_claims::TestWeightInfo; @@ -379,21 +378,18 @@ impl pallet_authorship::Config for Runtime { type FindAuthor = pallet_session::FindAccountFromAuthorIndex; } -parameter_types! { - pub const Period: BlockNumber = SESSION_PERIOD_BLOCKS; - pub const Offset: BlockNumber = 0; -} +use crate::opaque::SessionKeys; impl pallet_session::Config for Runtime { type RuntimeEvent = RuntimeEvent; type ValidatorId = ::AccountId; type ValidatorIdOf = pallet_staking::StashOf; - type ShouldEndSession = pallet_session::PeriodicSessions; - type NextSessionRotation = pallet_session::PeriodicSessions; - type SessionManager = Staking; - type SessionHandler = ::KeyTypeIdProviders; - type Keys = opaque::SessionKeys; - type WeightInfo = pallet_session::weights::SubstrateWeight; + type ShouldEndSession = Babe; + type NextSessionRotation = Babe; + type SessionManager = pallet_session::historical::NoteHistoricalRoot; + type SessionHandler = ::KeyTypeIdProviders; + type Keys = SessionKeys; + type WeightInfo = (); } impl pallet_session::historical::Config for Runtime { @@ -960,7 +956,7 @@ parameter_types! { impl pallet_im_online::Config for Runtime { type AuthorityId = ImOnlineId; type RuntimeEvent = RuntimeEvent; - type NextSessionRotation = pallet_session::PeriodicSessions; + type NextSessionRotation = Babe; type ValidatorSet = Historical; type ReportUnresponsiveness = (); type UnsignedPriority = ImOnlineUnsignedPriority;