From aed8a77e0306334b86c4e23119c9ac51db1bf70d Mon Sep 17 00:00:00 2001 From: Gregory Hill Date: Thu, 10 Aug 2023 15:43:27 +0100 Subject: [PATCH 1/4] fix: only adjust kintsugi mainnet slot duration Signed-off-by: Gregory Hill --- parachain/src/service.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/parachain/src/service.rs b/parachain/src/service.rs index 2d38956b75..6a2a30c2b2 100644 --- a/parachain/src/service.rs +++ b/parachain/src/service.rs @@ -189,6 +189,12 @@ type MaybeFullSelectChain = Option>; type ParachainBlockImport = TParachainBlockImport>, FullBackend>; +// 0x9af9a64e6e4da8e3073901c3ff0cc4c3aad9563786d89daf6ad820b6e14a0b8b +const KINTSUGI_GENESIS_HASH: H256 = H256([ + 154, 249, 166, 78, 110, 77, 168, 227, 7, 57, 1, 195, 255, 12, 196, 195, 170, 217, 86, 55, 134, 216, 157, 175, 106, + 216, 32, 182, 225, 74, 11, 139, +]); + fn import_slot_duration(client: &C) -> SlotDuration where C: sc_client_api::backend::AuxStore @@ -198,7 +204,11 @@ where C::Api: sp_consensus_aura::AuraApi, { match client.runtime_version_at(client.usage_info().chain.best_hash) { - Ok(x) if x.spec_name.starts_with("kintsugi") && client.usage_info().chain.best_number < 1983993 => { + Ok(x) + if x.spec_name.starts_with("kintsugi") + && client.usage_info().chain.genesis_hash == KINTSUGI_GENESIS_HASH + && client.usage_info().chain.best_number < 1983993 => + { // the kintsugi runtime was misconfigured at genesis to use a slot duration of 6s // which stalled collators when we upgraded to polkadot-v0.9.16 and subsequently // broke mainnet when we introduced the aura timestamp hook, collators should only From 65a5a5cbb3bbb23e87bea545f6599549f973c5ea Mon Sep 17 00:00:00 2001 From: Gregory Hill Date: Thu, 10 Aug 2023 15:44:52 +0100 Subject: [PATCH 2/4] chore: bump spec_version to 1.25.1 Signed-off-by: Gregory Hill --- parachain/runtime/interlay/src/lib.rs | 2 +- parachain/runtime/kintsugi/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/parachain/runtime/interlay/src/lib.rs b/parachain/runtime/interlay/src/lib.rs index 07f1bd6358..ef53390eca 100644 --- a/parachain/runtime/interlay/src/lib.rs +++ b/parachain/runtime/interlay/src/lib.rs @@ -112,7 +112,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("interlay-parachain"), impl_name: create_runtime_str!("interlay-parachain"), authoring_version: 1, - spec_version: 1025000, + spec_version: 1025001, impl_version: 1, transaction_version: 4, apis: RUNTIME_API_VERSIONS, diff --git a/parachain/runtime/kintsugi/src/lib.rs b/parachain/runtime/kintsugi/src/lib.rs index 8bbc49cd9a..e283de4d0c 100644 --- a/parachain/runtime/kintsugi/src/lib.rs +++ b/parachain/runtime/kintsugi/src/lib.rs @@ -113,7 +113,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("kintsugi-parachain"), impl_name: create_runtime_str!("kintsugi-parachain"), authoring_version: 1, - spec_version: 1025000, + spec_version: 1025001, impl_version: 1, transaction_version: 4, apis: RUNTIME_API_VERSIONS, From fe6865425817f3a55640fbde6c5b55977712b8a6 Mon Sep 17 00:00:00 2001 From: Gregory Hill Date: Thu, 10 Aug 2023 15:48:21 +0100 Subject: [PATCH 3/4] refactor: simplify slot duration check Signed-off-by: Gregory Hill --- parachain/src/service.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/parachain/src/service.rs b/parachain/src/service.rs index 6a2a30c2b2..8616ee5556 100644 --- a/parachain/src/service.rs +++ b/parachain/src/service.rs @@ -203,22 +203,19 @@ where + sp_api::CallApiAt, C::Api: sp_consensus_aura::AuraApi, { - match client.runtime_version_at(client.usage_info().chain.best_hash) { - Ok(x) - if x.spec_name.starts_with("kintsugi") - && client.usage_info().chain.genesis_hash == KINTSUGI_GENESIS_HASH - && client.usage_info().chain.best_number < 1983993 => - { - // the kintsugi runtime was misconfigured at genesis to use a slot duration of 6s - // which stalled collators when we upgraded to polkadot-v0.9.16 and subsequently - // broke mainnet when we introduced the aura timestamp hook, collators should only - // switch when syncing after the (failed) 1.20.0 upgrade - SlotDuration::from_millis(6000) - } + if client.usage_info().chain.genesis_hash == KINTSUGI_GENESIS_HASH + && client.usage_info().chain.best_number < 1983993 + { + // the kintsugi runtime was misconfigured at genesis to use a slot duration of 6s + // which stalled collators when we upgraded to polkadot-v0.9.16 and subsequently + // broke mainnet when we introduced the aura timestamp hook, collators should only + // switch when syncing after the (failed) 1.20.0 upgrade + SlotDuration::from_millis(6000) + } else { // this is pallet_timestamp::MinimumPeriod * 2 at the current height // on kintsugi we increased MinimumPeriod from 3_000 to 6_000 at 16_593 // but the interlay runtime has always used 6_000 - _ => sc_consensus_aura::slot_duration(&*client).unwrap(), + sc_consensus_aura::slot_duration(&*client).unwrap() } } From 20e24948f26566774f717332c102431a264b5eec Mon Sep 17 00:00:00 2001 From: Gregory Hill Date: Thu, 10 Aug 2023 16:27:58 +0100 Subject: [PATCH 4/4] fix: remove frontier block import Signed-off-by: Gregory Hill --- parachain/src/eth.rs | 48 +--------------------------------------- parachain/src/service.rs | 20 ++++++----------- 2 files changed, 8 insertions(+), 60 deletions(-) diff --git a/parachain/src/eth.rs b/parachain/src/eth.rs index 6bf4ab9d4e..e80159bd39 100644 --- a/parachain/src/eth.rs +++ b/parachain/src/eth.rs @@ -1,5 +1,4 @@ use crate::service::{FullBackend, FullClient}; -use cumulus_client_consensus_common::ParachainBlockImportMarker; pub use fc_consensus::FrontierBlockImport; use fc_rpc::{EthTask, OverrideHandle}; pub use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool}; @@ -7,14 +6,11 @@ use fp_rpc::EthereumRuntimeRPCApi; use futures::{future, prelude::*}; use primitives::Block; use sc_client_api::{BlockchainEvents, StateBackendFor}; -use sc_consensus::{BlockCheckParams, BlockImport as BlockImportT, BlockImportParams, ImportResult}; use sc_executor::NativeExecutionDispatch; use sc_network_sync::SyncingService; use sc_service::{error::Error as ServiceError, BasePath, Configuration, TaskManager}; use sc_transaction_pool::{ChainApi, Pool}; use sp_api::{ConstructRuntimeApi, ProvideRuntimeApi}; -use sp_block_builder::BlockBuilder as BlockBuilderApi; -use sp_consensus::Error as ConsensusError; use sp_runtime::traits::{BlakeTwo256, Block as BlockT}; use std::{ collections::BTreeMap, @@ -200,7 +196,7 @@ pub async fn spawn_frontier_tasks( overrides.clone(), Arc::new(b), 3, - 0, + 0, // TODO: update when deployed fc_mapping_sync::SyncStrategy::Normal, sync, pubsub_notification_sinks, @@ -248,48 +244,6 @@ pub async fn spawn_frontier_tasks( ); } -#[derive(Clone)] -pub struct BlockImport, C>(FrontierBlockImport); - -impl BlockImport -where - B: BlockT, - I: BlockImportT>, - I::Error: Into, - C: ProvideRuntimeApi, - C::Api: BlockBuilderApi + EthereumRuntimeRPCApi, -{ - pub fn new(inner: I, client: Arc) -> Self { - Self(FrontierBlockImport::new(inner, client)) - } -} - -#[async_trait::async_trait] -impl BlockImportT for BlockImport -where - B: BlockT, - I: BlockImportT> + Send + Sync, - I::Error: Into, - C: ProvideRuntimeApi + Send + Sync, - C::Api: BlockBuilderApi + EthereumRuntimeRPCApi, -{ - type Error = ConsensusError; - type Transaction = sp_api::TransactionFor; - - async fn check_block(&mut self, block: BlockCheckParams) -> Result { - self.0.check_block(block).await - } - - async fn import_block( - &mut self, - block: BlockImportParams, - ) -> Result { - self.0.import_block(block).await - } -} - -impl, C> ParachainBlockImportMarker for BlockImport {} - pub fn new_eth_deps( client: Arc, transaction_pool: Arc

, diff --git a/parachain/src/service.rs b/parachain/src/service.rs index 8616ee5556..1b02e504f9 100644 --- a/parachain/src/service.rs +++ b/parachain/src/service.rs @@ -33,8 +33,8 @@ use substrate_prometheus_endpoint::Registry; // Frontier imports use crate::eth::{ - new_eth_deps, new_frontier_partial, open_frontier_backend, spawn_frontier_tasks, BlockImport as EthBlockImport, - EthCompatRuntimeApiCollection, EthConfiguration, FrontierBackend, FrontierPartialComponents, + new_eth_deps, new_frontier_partial, open_frontier_backend, spawn_frontier_tasks, EthCompatRuntimeApiCollection, + EthConfiguration, FrontierBackend, FrontierPartialComponents, }; macro_rules! new_runtime_executor { @@ -313,7 +313,7 @@ where let import_queue = if instant_seal { // instant sealing sc_consensus_manual_seal::import_queue( - Box::new(EthBlockImport::new(client.clone(), client.clone())), + Box::new(client.clone()), &task_manager.spawn_essential_handle(), registry, ) @@ -322,10 +322,7 @@ where cumulus_client_consensus_aura::import_queue::( cumulus_client_consensus_aura::ImportQueueParams { - block_import: EthBlockImport::new( - ParachainBlockImport::new(client.clone(), backend.clone()), - client.clone(), - ), + block_import: ParachainBlockImport::new(client.clone(), backend.clone()), client: client.clone(), create_inherent_data_providers: move |_parent: sp_core::H256, _| async move { let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); @@ -398,7 +395,7 @@ where CT: fp_rpc::ConvertTransaction<::Extrinsic> + Clone + Default + Send + Sync + 'static, BIC: FnOnce( Arc>, - EthBlockImport, FullClient>, + ParachainBlockImport, Option<&Registry>, Option, &TaskManager, @@ -544,10 +541,7 @@ where if validator { let parachain_consensus = build_consensus( client.clone(), - EthBlockImport::new( - ParachainBlockImport::new(client.clone(), backend.clone()), - client.clone(), - ), + ParachainBlockImport::new(client.clone(), backend.clone()), prometheus_registry.as_ref(), telemetry.as_ref().map(|t| t.handle()), &task_manager, @@ -760,7 +754,7 @@ where let client_for_cidp = client.clone(); let authorship_future = sc_consensus_manual_seal::run_manual_seal(sc_consensus_manual_seal::ManualSealParams { - block_import: EthBlockImport::new(client.clone(), client.clone()), + block_import: client.clone(), env: proposer_factory, client: client.clone(), pool: transaction_pool.clone(),