Skip to content

Commit

Permalink
Use equivocation import queue (#1304)
Browse files Browse the repository at this point in the history
* use equivocation import queue

* shiden check for equivocation
  • Loading branch information
ermalkaleci authored Jul 22, 2024
1 parent 150b11c commit b028266
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 44 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/collator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
61 changes: 27 additions & 34 deletions bin/collator/src/parachain/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ where
&Configuration,
Option<TelemetryHandle>,
&TaskManager,
) -> Result<sc_consensus::DefaultImportQueue<Block>, sc_service::Error>,
) -> sc_consensus::DefaultImportQueue<Block>,
{
let telemetry = config
.telemetry_endpoints
Expand Down Expand Up @@ -251,7 +251,7 @@ where
config,
telemetry.as_ref().map(|telemetry| telemetry.handle()),
&task_manager,
)?;
);

let params = PartialComponents {
backend,
Expand Down Expand Up @@ -348,7 +348,7 @@ where
&Configuration,
Option<TelemetryHandle>,
&TaskManager,
) -> Result<sc_consensus::DefaultImportQueue<Block>, sc_service::Error>,
) -> sc_consensus::DefaultImportQueue<Block>,
SC: FnOnce(
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>,
ParachainBlockImport<
Expand Down Expand Up @@ -651,7 +651,7 @@ where
&Configuration,
Option<TelemetryHandle>,
&TaskManager,
) -> Result<sc_consensus::DefaultImportQueue<Block>, sc_service::Error>,
) -> sc_consensus::DefaultImportQueue<Block>,
SC: FnOnce(
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>,
ParachainBlockImport<
Expand Down Expand Up @@ -932,7 +932,7 @@ pub fn build_import_queue_fallback<RuntimeApi, Executor>(
config: &Configuration,
telemetry_handle: Option<TelemetryHandle>,
task_manager: &TaskManager,
) -> Result<sc_consensus::DefaultImportQueue<Block>, sc_service::Error>
) -> sc_consensus::DefaultImportQueue<Block>
where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>
+ Send
Expand All @@ -950,19 +950,15 @@ where
sc_client_api::StateBackend<BlakeTwo256>,
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::<AuraPair, _, _, _>(
sc_consensus_aura::BuildVerifierParams {
client: client_for_aura.clone(),
create_inherent_data_providers: move |_, _| async move {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();

Expand All @@ -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<_>
};
Expand All @@ -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.
Expand All @@ -1016,7 +1008,7 @@ pub fn build_import_queue<RuntimeApi, Executor>(
config: &Configuration,
telemetry_handle: Option<TelemetryHandle>,
task_manager: &TaskManager,
) -> Result<sc_consensus::DefaultImportQueue<Block>, sc_service::Error>
) -> sc_consensus::DefaultImportQueue<Block>
where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>
+ Send
Expand All @@ -1034,19 +1026,19 @@ where
sc_client_api::StateBackend<BlakeTwo256>,
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 =
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion runtime/astar/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion runtime/local/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion runtime/shibuya/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion runtime/shiden/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit b028266

Please sign in to comment.