From c92b1fab4ea61232841710f7ac275cdb963a51c2 Mon Sep 17 00:00:00 2001 From: remz <> Date: Sun, 4 Sep 2022 18:24:09 +0200 Subject: [PATCH] Fixed the wrong signature on authority set change for aura. --- Cargo.toml | 48 ++++++++++++++++++++++----------------------- src/import_queue.rs | 12 +++++++++--- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ac90d35..9fd1c37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,36 +13,36 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -sp-application-crypto = { version = "6.0.0", path = "../../../primitives/application-crypto" } -sp-consensus-aura = { version = "0.10.0-dev", path = "../../../primitives/consensus/aura" } -sp-block-builder = { version = "4.0.0-dev", path = "../../../primitives/block-builder" } -sc-block-builder = { version = "0.10.0-dev", path = "../../block-builder" } -sc-client-api = { version = "4.0.0-dev", path = "../../api" } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" } +sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" } +sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" } +sc-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" } +sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" } codec = { package = "parity-scale-codec", version = "3.0.0" } -sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" } -sc-consensus = { version = "0.10.0-dev", path = "../../../client/consensus/common" } -sp-consensus-slots = { version = "0.10.0-dev", path = "../../../primitives/consensus/slots" } +sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" } +sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" } +sp-consensus-slots = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" } thiserror = "1.0" futures = "0.3.21" -sp-inherents = { version = "4.0.0-dev", path = "../../../primitives/inherents" } +sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" } log = "0.4.8" -sp-core = { version = "6.0.0", path = "../../../primitives/core" } -sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" } -sc-consensus-slots = { version = "0.10.0-dev", path = "../slots" } -sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" } -sp-runtime = { version = "6.0.0", path = "../../../primitives/runtime" } -sp-keystore = { version = "0.12.0", path = "../../../primitives/keystore" } -sc-telemetry = { version = "4.0.0-dev", path = "../../telemetry" } -prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../utils/prometheus", version = "0.10.0-dev" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" } +sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" } +sc-consensus-slots = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" } +sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" } +prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" } async-trait = "0.1.50" [dev-dependencies] -sp-timestamp = { version = "4.0.0-dev", path = "../../../primitives/timestamp" } -sp-keyring = { version = "6.0.0", path = "../../../primitives/keyring" } -sp-tracing = { version = "5.0.0", path = "../../../primitives/tracing" } -sc-keystore = { version = "4.0.0-dev", path = "../../keystore" } -sc-network = { version = "0.10.0-dev", path = "../../network" } -sc-network-test = { version = "0.8.0", path = "../../network/test" } -substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" } +sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" } +sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" } +sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" } +sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" } +sc-network-test = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" } +substrate-test-runtime-client = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" } tempfile = "3.1.0" parking_lot = "0.12.0" diff --git a/src/import_queue.rs b/src/import_queue.rs index 56eb45c..5003d9a 100644 --- a/src/import_queue.rs +++ b/src/import_queue.rs @@ -29,7 +29,7 @@ use sc_consensus::{ }; use sc_consensus_slots::{check_equivocation, CheckedHeader, InherentDataProviderExt}; use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_DEBUG, CONSENSUS_TRACE}; -use sp_api::{ApiExt, ProvideRuntimeApi}; +use sp_api::{ApiExt, Core, ProvideRuntimeApi}; use sp_block_builder::BlockBuilder as BlockBuilderApi; use sp_blockchain::{ well_known_cache_keys::{self, Id as CacheKeyId}, @@ -204,8 +204,14 @@ where ) -> Result<(BlockImportParams, Option)>>), String> { let hash = block.header.hash(); let parent_hash = *block.header.parent_hash(); - let authorities = authorities(self.client.as_ref(), &BlockId::Hash(parent_hash)) - .map_err(|e| format!("Could not fetch authorities at {:?}: {}", parent_hash, e))?; + let runtime_api = self.client.runtime_api(); + let at = &BlockId::Hash(parent_hash); + runtime_api.initialize_block(at, &block.header) + .map_err(|e| format!("Error initializing block {:?}: {:?}", parent_hash, e))?; + + let authorities=runtime_api + .authorities(at) + .map_err(|e| format!("Could not fetch authorities at {:?}: {:?}", parent_hash, e))?; let create_inherent_data_providers = self .create_inherent_data_providers