From 92b1860f5adc897aa8934d9bfe800130d290f1fa Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Mon, 3 May 2021 14:26:56 -0400 Subject: [PATCH] Bump Substrate to `ec180313` (#955) * Bump Substrate to commit `0856e0729c5f9cd5d398b93680ab154fe486e588` * Update service to use new inherent data client Relevant Substrate PR: https://github.com/paritytech/substrate/pull/8526 * Appease Clippy --- bridges/bin/millau/node/Cargo.toml | 1 + bridges/bin/millau/node/src/service.rs | 57 +++++++++++++++++++------- bridges/bin/rialto/node/Cargo.toml | 1 + bridges/bin/rialto/node/src/service.rs | 55 ++++++++++++++++++------- 4 files changed, 85 insertions(+), 29 deletions(-) diff --git a/bridges/bin/millau/node/Cargo.toml b/bridges/bin/millau/node/Cargo.toml index cbcb2e710c..4c5f081e15 100644 --- a/bridges/bin/millau/node/Cargo.toml +++ b/bridges/bin/millau/node/Cargo.toml @@ -47,6 +47,7 @@ sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "master" } substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate", branch = "master" } [build-dependencies] diff --git a/bridges/bin/millau/node/src/service.rs b/bridges/bin/millau/node/src/service.rs index 8677ec2e70..a3cb4fa245 100644 --- a/bridges/bin/millau/node/src/service.rs +++ b/bridges/bin/millau/node/src/service.rs @@ -37,8 +37,8 @@ use sc_finality_grandpa::SharedVoterState; use sc_keystore::LocalKeystore; use sc_service::{error::Error as ServiceError, Configuration, TaskManager}; use sc_telemetry::{Telemetry, TelemetryWorker}; +use sp_consensus::SlotData; use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; -use sp_inherents::InherentDataProviders; use std::sync::Arc; use std::time::Duration; @@ -80,8 +80,6 @@ pub fn new_partial( if config.keystore_remote.is_some() { return Err(ServiceError::Other("Remote Keystores are not supported.".to_string())); } - let inherent_data_providers = InherentDataProviders::new(); - let telemetry = config .telemetry_endpoints .clone() @@ -124,14 +122,24 @@ pub fn new_partial( let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(grandpa_block_import.clone(), client.clone()); - let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { + let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration(); + + let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { block_import: aura_block_import.clone(), justification_import: Some(Box::new(grandpa_block_import)), client: client.clone(), - inherent_data_providers: inherent_data_providers.clone(), + create_inherent_data_providers: move |_, ()| async move { + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + + let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration( + *timestamp, + slot_duration, + ); + + Ok((timestamp, slot)) + }, spawner: &task_manager.spawn_essential_handle(), can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()), - slot_duration: sc_consensus_aura::slot_duration(&*client)?, registry: config.prometheus_registry(), check_for_equivocation: Default::default(), telemetry: telemetry.as_ref().map(|x| x.handle()), @@ -145,7 +153,6 @@ pub fn new_partial( keystore_container, select_chain, transaction_pool, - inherent_data_providers, other: (aura_block_import, grandpa_link, telemetry), }) } @@ -167,7 +174,6 @@ pub fn new_full(mut config: Configuration) -> Result mut keystore_container, select_chain, transaction_pool, - inherent_data_providers, other: (block_import, grandpa_link, mut telemetry), } = new_partial(&config)?; @@ -277,13 +283,25 @@ pub fn new_full(mut config: Configuration) -> Result let can_author_with = sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()); - let aura = sc_consensus_aura::start_aura::(StartAuraParams { - slot_duration: sc_consensus_aura::slot_duration(&*client)?, - client: client.clone(), + let slot_duration = sc_consensus_aura::slot_duration(&*client)?; + let raw_slot_duration = slot_duration.slot_duration(); + + let aura = sc_consensus_aura::start_aura::(StartAuraParams { + slot_duration, + client, select_chain, block_import, proposer_factory, - inherent_data_providers, + create_inherent_data_providers: move |_, ()| async move { + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + + let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration( + *timestamp, + raw_slot_duration, + ); + + Ok((timestamp, slot)) + }, force_authoring, backoff_authoring_blocks, keystore: keystore_container.sync_keystore(), @@ -394,14 +412,23 @@ pub fn new_light(mut config: Configuration) -> Result let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(grandpa_block_import.clone(), client.clone()); - let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { + let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration(); + let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { block_import: aura_block_import, justification_import: Some(Box::new(grandpa_block_import)), client: client.clone(), - inherent_data_providers: InherentDataProviders::new(), + create_inherent_data_providers: move |_, ()| async move { + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + + let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration( + *timestamp, + slot_duration, + ); + + Ok((timestamp, slot)) + }, spawner: &task_manager.spawn_essential_handle(), can_author_with: sp_consensus::NeverCanAuthor, - slot_duration: sc_consensus_aura::slot_duration(&*client)?, registry: config.prometheus_registry(), check_for_equivocation: Default::default(), telemetry: telemetry.as_ref().map(|x| x.handle()), diff --git a/bridges/bin/rialto/node/Cargo.toml b/bridges/bin/rialto/node/Cargo.toml index 370985d8ae..38272cd8c7 100644 --- a/bridges/bin/rialto/node/Cargo.toml +++ b/bridges/bin/rialto/node/Cargo.toml @@ -48,6 +48,7 @@ sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "master" } substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate", branch = "master" } [build-dependencies] diff --git a/bridges/bin/rialto/node/src/service.rs b/bridges/bin/rialto/node/src/service.rs index 841202ac7b..a0d3d311a0 100644 --- a/bridges/bin/rialto/node/src/service.rs +++ b/bridges/bin/rialto/node/src/service.rs @@ -37,8 +37,8 @@ use sc_finality_grandpa::SharedVoterState; use sc_keystore::LocalKeystore; use sc_service::{error::Error as ServiceError, Configuration, TaskManager}; use sc_telemetry::{Telemetry, TelemetryWorker}; +use sp_consensus::SlotData; use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; -use sp_inherents::InherentDataProviders; use std::sync::Arc; use std::time::Duration; @@ -80,7 +80,6 @@ pub fn new_partial( if config.keystore_remote.is_some() { return Err(ServiceError::Other("Remote Keystores are not supported.".to_string())); } - let inherent_data_providers = InherentDataProviders::new(); let telemetry = config .telemetry_endpoints @@ -124,14 +123,24 @@ pub fn new_partial( let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(grandpa_block_import.clone(), client.clone()); - let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { + let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration(); + + let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { block_import: aura_block_import.clone(), justification_import: Some(Box::new(grandpa_block_import)), client: client.clone(), - inherent_data_providers: inherent_data_providers.clone(), + create_inherent_data_providers: move |_, ()| async move { + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + + let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration( + *timestamp, + slot_duration, + ); + + Ok((timestamp, slot)) + }, spawner: &task_manager.spawn_essential_handle(), can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()), - slot_duration: sc_consensus_aura::slot_duration(&*client)?, registry: config.prometheus_registry(), check_for_equivocation: Default::default(), telemetry: telemetry.as_ref().map(|x| x.handle()), @@ -145,7 +154,6 @@ pub fn new_partial( keystore_container, select_chain, transaction_pool, - inherent_data_providers, other: (aura_block_import, grandpa_link, telemetry), }) } @@ -167,7 +175,6 @@ pub fn new_full(mut config: Configuration) -> Result mut keystore_container, select_chain, transaction_pool, - inherent_data_providers, other: (block_import, grandpa_link, mut telemetry), } = new_partial(&config)?; @@ -278,13 +285,24 @@ pub fn new_full(mut config: Configuration) -> Result let can_author_with = sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()); - let aura = sc_consensus_aura::start_aura::(StartAuraParams { - slot_duration: sc_consensus_aura::slot_duration(&*client)?, - client: client.clone(), + let slot_duration = sc_consensus_aura::slot_duration(&*client)?; + let raw_slot_duration = slot_duration.slot_duration(); + let aura = sc_consensus_aura::start_aura::(StartAuraParams { + slot_duration, + client, select_chain, block_import, proposer_factory, - inherent_data_providers, + create_inherent_data_providers: move |_, ()| async move { + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + + let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration( + *timestamp, + raw_slot_duration, + ); + + Ok((timestamp, slot)) + }, force_authoring, backoff_authoring_blocks, keystore: keystore_container.sync_keystore(), @@ -395,14 +413,23 @@ pub fn new_light(mut config: Configuration) -> Result let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(grandpa_block_import.clone(), client.clone()); - let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { + let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration(); + let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { block_import: aura_block_import, justification_import: Some(Box::new(grandpa_block_import)), client: client.clone(), - inherent_data_providers: InherentDataProviders::new(), + create_inherent_data_providers: move |_, ()| async move { + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + + let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration( + *timestamp, + slot_duration, + ); + + Ok((timestamp, slot)) + }, spawner: &task_manager.spawn_essential_handle(), can_author_with: sp_consensus::NeverCanAuthor, - slot_duration: sc_consensus_aura::slot_duration(&*client)?, registry: config.prometheus_registry(), check_for_equivocation: Default::default(), telemetry: telemetry.as_ref().map(|x| x.handle()),