From b0282663c66831c4db5561669f40956a83524f4b Mon Sep 17 00:00:00 2001 From: Ermal Kaleci Date: Mon, 22 Jul 2024 15:03:14 +0200 Subject: [PATCH] Use equivocation import queue (#1304) * use equivocation import queue * shiden check for equivocation --- Cargo.lock | 10 ++--- bin/collator/Cargo.toml | 2 +- bin/collator/src/parachain/service.rs | 61 ++++++++++++--------------- runtime/astar/Cargo.toml | 2 +- runtime/local/Cargo.toml | 2 +- runtime/shibuya/Cargo.toml | 2 +- runtime/shiden/Cargo.toml | 2 +- 7 files changed, 37 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 51dda062d9..b5ef7d5618 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -609,7 +609,7 @@ dependencies = [ [[package]] name = "astar-collator" -version = "5.42.0" +version = "5.42.1" dependencies = [ "astar-primitives", "astar-runtime", @@ -751,7 +751,7 @@ dependencies = [ [[package]] name = "astar-runtime" -version = "5.42.0" +version = "5.42.1" dependencies = [ "array-bytes 6.2.3", "astar-primitives", @@ -6483,7 +6483,7 @@ dependencies = [ [[package]] name = "local-runtime" -version = "5.42.0" +version = "5.42.1" dependencies = [ "array-bytes 6.2.3", "astar-primitives", @@ -14214,7 +14214,7 @@ dependencies = [ [[package]] name = "shibuya-runtime" -version = "5.42.0" +version = "5.42.1" dependencies = [ "array-bytes 6.2.3", "astar-primitives", @@ -14335,7 +14335,7 @@ dependencies = [ [[package]] name = "shiden-runtime" -version = "5.42.0" +version = "5.42.1" dependencies = [ "array-bytes 6.2.3", "astar-primitives", diff --git a/bin/collator/Cargo.toml b/bin/collator/Cargo.toml index f9838a2871..8bbf7c1323 100644 --- a/bin/collator/Cargo.toml +++ b/bin/collator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "astar-collator" -version = "5.42.0" +version = "5.42.1" description = "Astar collator implementation in Rust." build = "build.rs" default-run = "astar-collator" diff --git a/bin/collator/src/parachain/service.rs b/bin/collator/src/parachain/service.rs index fecd80e122..27dd0c680e 100644 --- a/bin/collator/src/parachain/service.rs +++ b/bin/collator/src/parachain/service.rs @@ -198,7 +198,7 @@ where &Configuration, Option, &TaskManager, - ) -> Result, sc_service::Error>, + ) -> sc_consensus::DefaultImportQueue, { let telemetry = config .telemetry_endpoints @@ -251,7 +251,7 @@ where config, telemetry.as_ref().map(|telemetry| telemetry.handle()), &task_manager, - )?; + ); let params = PartialComponents { backend, @@ -348,7 +348,7 @@ where &Configuration, Option, &TaskManager, - ) -> Result, sc_service::Error>, + ) -> sc_consensus::DefaultImportQueue, SC: FnOnce( Arc>>, ParachainBlockImport< @@ -651,7 +651,7 @@ where &Configuration, Option, &TaskManager, - ) -> Result, sc_service::Error>, + ) -> sc_consensus::DefaultImportQueue, SC: FnOnce( Arc>>, ParachainBlockImport< @@ -932,7 +932,7 @@ pub fn build_import_queue_fallback( config: &Configuration, telemetry_handle: Option, task_manager: &TaskManager, -) -> Result, sc_service::Error> +) -> sc_consensus::DefaultImportQueue where RuntimeApi: ConstructRuntimeApi>> + Send @@ -950,19 +950,15 @@ where sc_client_api::StateBackend, Executor: sc_executor::NativeExecutionDispatch + 'static, { - let client2 = client.clone(); + let client_for_aura = client.clone(); let aura_verifier = move || { - let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client2).unwrap(); - - Box::new(cumulus_client_consensus_aura::build_verifier::< - AuraPair, - _, - _, - _, - >( - cumulus_client_consensus_aura::BuildVerifierParams { - client: client2.clone(), + let slot_duration = + cumulus_client_consensus_aura::slot_duration(&*client_for_aura).unwrap(); + + Box::new(sc_consensus_aura::build_verifier::( + sc_consensus_aura::BuildVerifierParams { + client: client_for_aura.clone(), create_inherent_data_providers: move |_, _| async move { let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); @@ -975,6 +971,8 @@ where Ok((slot, timestamp)) }, telemetry: telemetry_handle, + check_for_equivocation: sc_consensus_aura::CheckForEquivocation::Yes, + compatibility_mode: sc_consensus_aura::CompatibilityMode::None, }, )) as Box<_> }; @@ -992,13 +990,7 @@ where let registry = config.prometheus_registry(); let spawner = task_manager.spawn_essential_handle(); - Ok(BasicQueue::new( - verifier, - Box::new(block_import), - None, - &spawner, - registry, - )) + BasicQueue::new(verifier, Box::new(block_import), None, &spawner, registry) } /// Build aura only import queue. @@ -1016,7 +1008,7 @@ pub fn build_import_queue( config: &Configuration, telemetry_handle: Option, task_manager: &TaskManager, -) -> Result, sc_service::Error> +) -> sc_consensus::DefaultImportQueue where RuntimeApi: ConstructRuntimeApi>> + Send @@ -1034,19 +1026,19 @@ where sc_client_api::StateBackend, Executor: sc_executor::NativeExecutionDispatch + 'static, { - let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?; + let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client) + .expect("AuraApi slot_duration failed!"); - cumulus_client_consensus_aura::import_queue::< + cumulus_client_consensus_aura::equivocation_import_queue::fully_verifying_import_queue::< AuraPair, _, _, _, _, - _, - >(cumulus_client_consensus_aura::ImportQueueParams { - block_import, + >( client, - create_inherent_data_providers: move |_, _| async move { + block_import, + move |_, _| async move { let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); let slot = @@ -1057,10 +1049,11 @@ where Ok((slot, timestamp)) }, - registry: config.prometheus_registry(), - spawner: &task_manager.spawn_essential_handle(), - telemetry: telemetry_handle, - }).map_err(Into::into) + slot_duration, + &task_manager.spawn_essential_handle(), + config.prometheus_registry(), + telemetry_handle, + ) } /// Start collating with the `shell` runtime while waiting for an upgrade to an Aura compatible runtime. diff --git a/runtime/astar/Cargo.toml b/runtime/astar/Cargo.toml index 4b823f9646..8f25abd0f1 100644 --- a/runtime/astar/Cargo.toml +++ b/runtime/astar/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "astar-runtime" -version = "5.42.0" +version = "5.42.1" build = "build.rs" authors.workspace = true edition.workspace = true diff --git a/runtime/local/Cargo.toml b/runtime/local/Cargo.toml index 41fad4bb88..13a4ebe06e 100644 --- a/runtime/local/Cargo.toml +++ b/runtime/local/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "local-runtime" -version = "5.42.0" +version = "5.42.1" build = "build.rs" authors.workspace = true edition.workspace = true diff --git a/runtime/shibuya/Cargo.toml b/runtime/shibuya/Cargo.toml index 0b89a19b23..ddbecbea8e 100644 --- a/runtime/shibuya/Cargo.toml +++ b/runtime/shibuya/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "shibuya-runtime" -version = "5.42.0" +version = "5.42.1" build = "build.rs" authors.workspace = true edition.workspace = true diff --git a/runtime/shiden/Cargo.toml b/runtime/shiden/Cargo.toml index 058640c8ee..b5dd064176 100644 --- a/runtime/shiden/Cargo.toml +++ b/runtime/shiden/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "shiden-runtime" -version = "5.42.0" +version = "5.42.1" build = "build.rs" authors.workspace = true edition.workspace = true