Move grandpa crates to consensus folder (#13458)

* Move grandpa under consensus dir
* Rename grandpa folder
* Finish grandpa renaming
* Minor tweaks
* Cargo fmt
* Adjust path to chain spec
This commit is contained in:
Davide Galassi
2023-02-27 17:15:08 +01:00
committed by GitHub
parent 91c595bc78
commit 40c36c0c8a
62 changed files with 356 additions and 356 deletions
+101 -99
View File
@@ -520,8 +520,8 @@ dependencies = [
"sp-beefy",
"sp-blockchain",
"sp-consensus",
"sp-consensus-grandpa",
"sp-core",
"sp-finality-grandpa",
"sp-keyring",
"sp-keystore",
"sp-mmr-primitives",
@@ -3601,6 +3601,7 @@ dependencies = [
"sp-authority-discovery",
"sp-block-builder",
"sp-consensus-babe",
"sp-consensus-grandpa",
"sp-core",
"sp-inherents",
"sp-io",
@@ -4806,9 +4807,9 @@ dependencies = [
"sc-consensus",
"sc-consensus-babe",
"sc-consensus-epochs",
"sc-consensus-grandpa",
"sc-consensus-slots",
"sc-executor",
"sc-finality-grandpa",
"sc-keystore",
"sc-network",
"sc-network-common",
@@ -4829,8 +4830,8 @@ dependencies = [
"sp-blockchain",
"sp-consensus",
"sp-consensus-babe",
"sp-consensus-grandpa",
"sp-core",
"sp-finality-grandpa",
"sp-inherents",
"sp-io",
"sp-keyring",
@@ -4928,8 +4929,8 @@ dependencies = [
"sc-consensus-babe",
"sc-consensus-babe-rpc",
"sc-consensus-epochs",
"sc-finality-grandpa",
"sc-finality-grandpa-rpc",
"sc-consensus-grandpa",
"sc-consensus-grandpa-rpc",
"sc-rpc",
"sc-rpc-api",
"sc-rpc-spec-v2",
@@ -4973,8 +4974,8 @@ dependencies = [
"sc-client-api",
"sc-consensus",
"sc-consensus-aura",
"sc-consensus-grandpa",
"sc-executor",
"sc-finality-grandpa",
"sc-keystore",
"sc-rpc",
"sc-rpc-api",
@@ -4987,8 +4988,8 @@ dependencies = [
"sp-blockchain",
"sp-consensus",
"sp-consensus-aura",
"sp-consensus-grandpa",
"sp-core",
"sp-finality-grandpa",
"sp-inherents",
"sp-io",
"sp-keyring",
@@ -5024,6 +5025,7 @@ dependencies = [
"sp-api",
"sp-block-builder",
"sp-consensus-aura",
"sp-consensus-grandpa",
"sp-core",
"sp-inherents",
"sp-offchain",
@@ -5866,8 +5868,8 @@ dependencies = [
"parity-scale-codec",
"scale-info",
"sp-application-crypto",
"sp-consensus-grandpa",
"sp-core",
"sp-finality-grandpa",
"sp-io",
"sp-keyring",
"sp-runtime",
@@ -8304,6 +8306,76 @@ dependencies = [
"sp-runtime",
]
[[package]]
name = "sc-consensus-grandpa"
version = "0.10.0-dev"
dependencies = [
"ahash 0.8.3",
"array-bytes",
"assert_matches",
"async-trait",
"dyn-clone",
"finality-grandpa",
"fork-tree",
"futures",
"futures-timer",
"log",
"parity-scale-codec",
"parking_lot 0.12.1",
"rand 0.8.5",
"sc-block-builder",
"sc-chain-spec",
"sc-client-api",
"sc-consensus",
"sc-network",
"sc-network-common",
"sc-network-gossip",
"sc-network-test",
"sc-telemetry",
"sc-utils",
"serde",
"serde_json",
"sp-api",
"sp-application-crypto",
"sp-arithmetic",
"sp-blockchain",
"sp-consensus",
"sp-consensus-grandpa",
"sp-core",
"sp-keyring",
"sp-keystore",
"sp-runtime",
"sp-tracing",
"substrate-prometheus-endpoint",
"substrate-test-runtime-client",
"thiserror",
"tokio",
]
[[package]]
name = "sc-consensus-grandpa-rpc"
version = "0.10.0-dev"
dependencies = [
"finality-grandpa",
"futures",
"jsonrpsee",
"log",
"parity-scale-codec",
"sc-block-builder",
"sc-client-api",
"sc-consensus-grandpa",
"sc-rpc",
"serde",
"sp-blockchain",
"sp-consensus-grandpa",
"sp-core",
"sp-keyring",
"sp-runtime",
"substrate-test-runtime-client",
"thiserror",
"tokio",
]
[[package]]
name = "sc-consensus-manual-seal"
version = "0.10.0-dev"
@@ -8476,76 +8548,6 @@ dependencies = [
"wat",
]
[[package]]
name = "sc-finality-grandpa"
version = "0.10.0-dev"
dependencies = [
"ahash 0.8.3",
"array-bytes",
"assert_matches",
"async-trait",
"dyn-clone",
"finality-grandpa",
"fork-tree",
"futures",
"futures-timer",
"log",
"parity-scale-codec",
"parking_lot 0.12.1",
"rand 0.8.5",
"sc-block-builder",
"sc-chain-spec",
"sc-client-api",
"sc-consensus",
"sc-network",
"sc-network-common",
"sc-network-gossip",
"sc-network-test",
"sc-telemetry",
"sc-utils",
"serde",
"serde_json",
"sp-api",
"sp-application-crypto",
"sp-arithmetic",
"sp-blockchain",
"sp-consensus",
"sp-core",
"sp-finality-grandpa",
"sp-keyring",
"sp-keystore",
"sp-runtime",
"sp-tracing",
"substrate-prometheus-endpoint",
"substrate-test-runtime-client",
"thiserror",
"tokio",
]
[[package]]
name = "sc-finality-grandpa-rpc"
version = "0.10.0-dev"
dependencies = [
"finality-grandpa",
"futures",
"jsonrpsee",
"log",
"parity-scale-codec",
"sc-block-builder",
"sc-client-api",
"sc-finality-grandpa",
"sc-rpc",
"serde",
"sp-blockchain",
"sp-core",
"sp-finality-grandpa",
"sp-keyring",
"sp-runtime",
"substrate-test-runtime-client",
"thiserror",
"tokio",
]
[[package]]
name = "sc-informant"
version = "0.10.0-dev"
@@ -8673,7 +8675,7 @@ dependencies = [
"smallvec",
"sp-blockchain",
"sp-consensus",
"sp-finality-grandpa",
"sp-consensus-grandpa",
"sp-runtime",
"substrate-prometheus-endpoint",
"thiserror",
@@ -8745,8 +8747,8 @@ dependencies = [
"sp-arithmetic",
"sp-blockchain",
"sp-consensus",
"sp-consensus-grandpa",
"sp-core",
"sp-finality-grandpa",
"sp-runtime",
"sp-test-primitives",
"sp-tracing",
@@ -9114,7 +9116,7 @@ dependencies = [
"sc-client-api",
"sc-consensus-babe",
"sc-consensus-epochs",
"sc-finality-grandpa",
"sc-consensus-grandpa",
"serde",
"serde_json",
"sp-blockchain",
@@ -9893,6 +9895,23 @@ dependencies = [
"sp-timestamp",
]
[[package]]
name = "sp-consensus-grandpa"
version = "4.0.0-dev"
dependencies = [
"finality-grandpa",
"log",
"parity-scale-codec",
"scale-info",
"serde",
"sp-api",
"sp-application-crypto",
"sp-core",
"sp-keystore",
"sp-runtime",
"sp-std",
]
[[package]]
name = "sp-consensus-pow"
version = "0.10.0-dev"
@@ -10023,23 +10042,6 @@ dependencies = [
"sp-storage",
]
[[package]]
name = "sp-finality-grandpa"
version = "4.0.0-dev"
dependencies = [
"finality-grandpa",
"log",
"parity-scale-codec",
"scale-info",
"serde",
"sp-api",
"sp-application-crypto",
"sp-core",
"sp-keystore",
"sp-runtime",
"sp-std",
]
[[package]]
name = "sp-inherents"
version = "4.0.0-dev"
@@ -10801,9 +10803,9 @@ dependencies = [
"sp-consensus",
"sp-consensus-aura",
"sp-consensus-babe",
"sp-consensus-grandpa",
"sp-core",
"sp-externalities",
"sp-finality-grandpa",
"sp-inherents",
"sp-io",
"sp-keyring",
+3 -3
View File
@@ -29,6 +29,8 @@ members = [
"client/consensus/babe/rpc",
"client/consensus/common",
"client/consensus/epochs",
"client/consensus/grandpa",
"client/consensus/grandpa/rpc",
"client/consensus/manual-seal",
"client/consensus/pow",
"client/consensus/slots",
@@ -38,8 +40,6 @@ members = [
"client/executor/runtime-test",
"client/executor/wasmi",
"client/executor/wasmtime",
"client/finality-grandpa",
"client/finality-grandpa/rpc",
"client/informant",
"client/keystore",
"client/merkle-mountain-range",
@@ -184,6 +184,7 @@ members = [
"primitives/consensus/aura",
"primitives/consensus/babe",
"primitives/consensus/common",
"primitives/consensus/grandpa",
"primitives/consensus/pow",
"primitives/consensus/slots",
"primitives/consensus/vrf",
@@ -193,7 +194,6 @@ members = [
"primitives/database",
"primitives/debug-derive",
"primitives/externalities",
"primitives/finality-grandpa",
"primitives/inherents",
"primitives/io",
"primitives/keyring",
+2 -2
View File
@@ -32,8 +32,8 @@ sc-consensus-aura = { version = "0.10.0-dev", path = "../../../client/consensus/
sp-consensus-aura = { version = "0.10.0-dev", path = "../../../primitives/consensus/aura" }
sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
sc-consensus = { version = "0.10.0-dev", path = "../../../client/consensus/common" }
sc-finality-grandpa = { version = "0.10.0-dev", path = "../../../client/finality-grandpa" }
sp-finality-grandpa = { version = "4.0.0-dev", path = "../../../primitives/finality-grandpa" }
sc-consensus-grandpa = { version = "0.10.0-dev", path = "../../../client/consensus/grandpa" }
sp-consensus-grandpa = { version = "4.0.0-dev", path = "../../../primitives/consensus/grandpa" }
sc-client-api = { version = "4.0.0-dev", path = "../../../client/api" }
sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" }
sp-io = { version = "7.0.0", path = "../../../primitives/io" }
@@ -4,8 +4,8 @@ use node_template_runtime::{
};
use sc_service::ChainType;
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_consensus_grandpa::AuthorityId as GrandpaId;
use sp_core::{sr25519, Pair, Public};
use sp_finality_grandpa::AuthorityId as GrandpaId;
use sp_runtime::traits::{IdentifyAccount, Verify};
// The URL for the telemetry server.
@@ -102,7 +102,7 @@ pub fn run() -> sc_cli::Result<()> {
let PartialComponents { client, task_manager, backend, .. } =
service::new_partial(&config)?;
let aux_revert = Box::new(|client, _, blocks| {
sc_finality_grandpa::revert(client, blocks)?;
sc_consensus_grandpa::revert(client, blocks)?;
Ok(())
});
Ok((cmd.run(client, backend, Some(aux_revert)), task_manager))
+11 -11
View File
@@ -3,8 +3,8 @@
use node_template_runtime::{self, opaque::Block, RuntimeApi};
use sc_client_api::BlockBackend;
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
use sc_consensus_grandpa::SharedVoterState;
pub use sc_executor::NativeElseWasmExecutor;
use sc_finality_grandpa::SharedVoterState;
use sc_keystore::LocalKeystore;
use sc_service::{error::Error as ServiceError, Configuration, TaskManager, WarpSyncParams};
use sc_telemetry::{Telemetry, TelemetryWorker};
@@ -46,13 +46,13 @@ pub fn new_partial(
sc_consensus::DefaultImportQueue<Block, FullClient>,
sc_transaction_pool::FullPool<Block, FullClient>,
(
sc_finality_grandpa::GrandpaBlockImport<
sc_consensus_grandpa::GrandpaBlockImport<
FullBackend,
Block,
FullClient,
FullSelectChain,
>,
sc_finality_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
sc_consensus_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
Option<Telemetry>,
),
>,
@@ -103,7 +103,7 @@ pub fn new_partial(
client.clone(),
);
let (grandpa_block_import, grandpa_link) = sc_finality_grandpa::block_import(
let (grandpa_block_import, grandpa_link) = sc_consensus_grandpa::block_import(
client.clone(),
&(client.clone() as Arc<_>),
select_chain.clone(),
@@ -177,7 +177,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
))),
};
}
let grandpa_protocol_name = sc_finality_grandpa::protocol_standard_name(
let grandpa_protocol_name = sc_consensus_grandpa::protocol_standard_name(
&client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"),
&config.chain_spec,
);
@@ -185,8 +185,8 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
config
.network
.extra_sets
.push(sc_finality_grandpa::grandpa_peers_set_config(grandpa_protocol_name.clone()));
let warp_sync = Arc::new(sc_finality_grandpa::warp_proof::NetworkProvider::new(
.push(sc_consensus_grandpa::grandpa_peers_set_config(grandpa_protocol_name.clone()));
let warp_sync = Arc::new(sc_consensus_grandpa::warp_proof::NetworkProvider::new(
backend.clone(),
grandpa_link.shared_authority_set().clone(),
Vec::default(),
@@ -298,7 +298,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
let keystore =
if role.is_authority() { Some(keystore_container.sync_keystore()) } else { None };
let grandpa_config = sc_finality_grandpa::Config {
let grandpa_config = sc_consensus_grandpa::Config {
// FIXME #1578 make this available through chainspec
gossip_duration: Duration::from_millis(333),
justification_period: 512,
@@ -316,11 +316,11 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
// and vote data availability than the observer. The observer has not
// been tested extensively yet and having most nodes in a network run it
// could lead to finality stalls.
let grandpa_config = sc_finality_grandpa::GrandpaParams {
let grandpa_config = sc_consensus_grandpa::GrandpaParams {
config: grandpa_config,
link: grandpa_link,
network,
voting_rule: sc_finality_grandpa::VotingRulesBuilder::default().build(),
voting_rule: sc_consensus_grandpa::VotingRulesBuilder::default().build(),
prometheus_registry,
shared_voter_state: SharedVoterState::empty(),
telemetry: telemetry.as_ref().map(|x| x.handle()),
@@ -331,7 +331,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
task_manager.spawn_essential_handle().spawn_blocking(
"grandpa-voter",
None,
sc_finality_grandpa::run_grandpa_voter(grandpa_config)?,
sc_consensus_grandpa::run_grandpa_voter(grandpa_config)?,
);
}
@@ -30,6 +30,7 @@ frame-executive = { version = "4.0.0-dev", default-features = false, path = "../
sp-api = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/api" }
sp-block-builder = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/block-builder"}
sp-consensus-aura = { version = "0.10.0-dev", default-features = false, path = "../../../primitives/consensus/aura" }
sp-consensus-grandpa = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/consensus/grandpa" }
sp-core = { version = "7.0.0", default-features = false, path = "../../../primitives/core" }
sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/inherents"}
sp-offchain = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/offchain" }
@@ -78,6 +79,7 @@ std = [
"sp-api/std",
"sp-block-builder/std",
"sp-consensus-aura/std",
"sp-consensus-grandpa/std",
"sp-core/std",
"sp-inherents/std",
"sp-offchain/std",
+8 -10
View File
@@ -6,9 +6,7 @@
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
use pallet_grandpa::{
fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList,
};
use pallet_grandpa::AuthorityId as GrandpaId;
use sp_api::impl_runtime_apis;
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
@@ -429,29 +427,29 @@ impl_runtime_apis! {
}
}
impl fg_primitives::GrandpaApi<Block> for Runtime {
fn grandpa_authorities() -> GrandpaAuthorityList {
impl sp_consensus_grandpa::GrandpaApi<Block> for Runtime {
fn grandpa_authorities() -> sp_consensus_grandpa::AuthorityList {
Grandpa::grandpa_authorities()
}
fn current_set_id() -> fg_primitives::SetId {
fn current_set_id() -> sp_consensus_grandpa::SetId {
Grandpa::current_set_id()
}
fn submit_report_equivocation_unsigned_extrinsic(
_equivocation_proof: fg_primitives::EquivocationProof<
_equivocation_proof: sp_consensus_grandpa::EquivocationProof<
<Block as BlockT>::Hash,
NumberFor<Block>,
>,
_key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,
_key_owner_proof: sp_consensus_grandpa::OpaqueKeyOwnershipProof,
) -> Option<()> {
None
}
fn generate_key_ownership_proof(
_set_id: fg_primitives::SetId,
_set_id: sp_consensus_grandpa::SetId,
_authority_id: GrandpaId,
) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {
) -> Option<sp_consensus_grandpa::OpaqueKeyOwnershipProof> {
// NOTE: this is the only implementation possible since we've
// defined our key owner proof type as a bottom type (i.e. a type
// with no values).
+2 -2
View File
@@ -47,7 +47,7 @@ rand = "0.8"
# primitives
sp-authority-discovery = { version = "4.0.0-dev", path = "../../../primitives/authority-discovery" }
sp-consensus-babe = { version = "0.10.0-dev", path = "../../../primitives/consensus/babe" }
grandpa-primitives = { version = "4.0.0-dev", package = "sp-finality-grandpa", path = "../../../primitives/finality-grandpa" }
grandpa-primitives = { version = "4.0.0-dev", package = "sp-consensus-grandpa", path = "../../../primitives/consensus/grandpa" }
sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" }
sp-core = { version = "7.0.0", path = "../../../primitives/core" }
sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" }
@@ -70,7 +70,7 @@ sc-network = { version = "0.10.0-dev", path = "../../../client/network" }
sc-network-common = { version = "0.10.0-dev", path = "../../../client/network/common" }
sc-consensus-slots = { version = "0.10.0-dev", path = "../../../client/consensus/slots" }
sc-consensus-babe = { version = "0.10.0-dev", path = "../../../client/consensus/babe" }
grandpa = { version = "0.10.0-dev", package = "sc-finality-grandpa", path = "../../../client/finality-grandpa" }
grandpa = { version = "0.10.0-dev", package = "sc-consensus-grandpa", path = "../../../client/consensus/grandpa" }
sc-rpc = { version = "4.0.0-dev", path = "../../../client/rpc" }
sc-basic-authorship = { version = "0.10.0-dev", path = "../../../client/basic-authorship" }
sc-service = { version = "0.10.0-dev", default-features = false, path = "../../../client/service" }
+2 -2
View File
@@ -22,8 +22,8 @@ sc-client-api = { version = "4.0.0-dev", path = "../../../client/api" }
sc-consensus-babe = { version = "0.10.0-dev", path = "../../../client/consensus/babe" }
sc-consensus-babe-rpc = { version = "0.10.0-dev", path = "../../../client/consensus/babe/rpc" }
sc-consensus-epochs = { version = "0.10.0-dev", path = "../../../client/consensus/epochs" }
sc-finality-grandpa = { version = "0.10.0-dev", path = "../../../client/finality-grandpa" }
sc-finality-grandpa-rpc = { version = "0.10.0-dev", path = "../../../client/finality-grandpa/rpc" }
sc-consensus-grandpa = { version = "0.10.0-dev", path = "../../../client/consensus/grandpa" }
sc-consensus-grandpa-rpc = { version = "0.10.0-dev", path = "../../../client/consensus/grandpa/rpc" }
sc-rpc = { version = "4.0.0-dev", path = "../../../client/rpc" }
sc-rpc-api = { version = "0.10.0-dev", path = "../../../client/rpc-api" }
sc-rpc-spec-v2 = { version = "0.10.0-dev", path = "../../../client/rpc-spec-v2" }
+2 -2
View File
@@ -38,7 +38,7 @@ use node_primitives::{AccountId, Balance, Block, BlockNumber, Hash, Index};
use sc_client_api::AuxStore;
use sc_consensus_babe::{BabeConfiguration, Epoch};
use sc_consensus_epochs::SharedEpochChanges;
use sc_finality_grandpa::{
use sc_consensus_grandpa::{
FinalityProofProvider, GrandpaJustificationStream, SharedAuthoritySet, SharedVoterState,
};
use sc_rpc::SubscriptionTaskExecutor;
@@ -120,7 +120,7 @@ where
use mmr_rpc::{Mmr, MmrApiServer};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
use sc_consensus_babe_rpc::{Babe, BabeApiServer};
use sc_finality_grandpa_rpc::{Grandpa, GrandpaApiServer};
use sc_consensus_grandpa_rpc::{Grandpa, GrandpaApiServer};
use sc_rpc::dev::{Dev, DevApiServer};
use sc_rpc_spec_v2::chain_spec::{ChainSpec, ChainSpecApiServer};
use sc_sync_state_rpc::{SyncState, SyncStateApiServer};
+2
View File
@@ -27,6 +27,7 @@ log = { version = "0.4.17", default-features = false }
# primitives
sp-authority-discovery = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/authority-discovery" }
sp-consensus-babe = { version = "0.10.0-dev", default-features = false, path = "../../../primitives/consensus/babe" }
sp-consensus-grandpa = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/consensus/grandpa" }
sp-block-builder = { path = "../../../primitives/block-builder", default-features = false, version = "4.0.0-dev" }
sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/inherents" }
node-primitives = { version = "2.0.0", default-features = false, path = "../primitives" }
@@ -134,6 +135,7 @@ std = [
"pallet-authority-discovery/std",
"pallet-authorship/std",
"sp-consensus-babe/std",
"sp-consensus-grandpa/std",
"pallet-babe/std",
"pallet-bags-list/std",
"pallet-balances/std",
+10 -12
View File
@@ -52,9 +52,6 @@ use frame_system::{
pub use node_primitives::{AccountId, Signature};
use node_primitives::{AccountIndex, Balance, BlockNumber, Hash, Index, Moment};
use pallet_election_provider_multi_phase::SolutionAccuracyOf;
use pallet_grandpa::{
fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList,
};
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use pallet_nfts::PalletFeatures;
use pallet_nis::WithMaximumOf;
@@ -63,6 +60,7 @@ pub use pallet_transaction_payment::{CurrencyAdapter, Multiplier, TargetedFeeAdj
use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
use sp_api::impl_runtime_apis;
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_consensus_grandpa::AuthorityId as GrandpaId;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_inherents::{CheckInherentsResult, InherentData};
use sp_runtime::{
@@ -1957,21 +1955,21 @@ impl_runtime_apis! {
}
}
impl fg_primitives::GrandpaApi<Block> for Runtime {
fn grandpa_authorities() -> GrandpaAuthorityList {
impl sp_consensus_grandpa::GrandpaApi<Block> for Runtime {
fn grandpa_authorities() -> sp_consensus_grandpa::AuthorityList {
Grandpa::grandpa_authorities()
}
fn current_set_id() -> fg_primitives::SetId {
fn current_set_id() -> sp_consensus_grandpa::SetId {
Grandpa::current_set_id()
}
fn submit_report_equivocation_unsigned_extrinsic(
equivocation_proof: fg_primitives::EquivocationProof<
equivocation_proof: sp_consensus_grandpa::EquivocationProof<
<Block as BlockT>::Hash,
NumberFor<Block>,
>,
key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,
key_owner_proof: sp_consensus_grandpa::OpaqueKeyOwnershipProof,
) -> Option<()> {
let key_owner_proof = key_owner_proof.decode()?;
@@ -1982,14 +1980,14 @@ impl_runtime_apis! {
}
fn generate_key_ownership_proof(
_set_id: fg_primitives::SetId,
_set_id: sp_consensus_grandpa::SetId,
authority_id: GrandpaId,
) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {
) -> Option<sp_consensus_grandpa::OpaqueKeyOwnershipProof> {
use codec::Encode;
Historical::prove((fg_primitives::KEY_TYPE, authority_id))
Historical::prove((sp_consensus_grandpa::KEY_TYPE, authority_id))
.map(|p| p.encode())
.map(fg_primitives::OpaqueKeyOwnershipProof::new)
.map(sp_consensus_grandpa::OpaqueKeyOwnershipProof::new)
}
}
+1 -1
View File
@@ -43,7 +43,7 @@ tempfile = "3.1.0"
tokio = "1.22.0"
sc-block-builder = { version = "0.10.0-dev", path = "../block-builder" }
sc-network-test = { version = "0.8.0", path = "../network/test" }
sp-finality-grandpa = { version = "4.0.0-dev", path = "../../primitives/finality-grandpa" }
sp-consensus-grandpa = { version = "4.0.0-dev", path = "../../primitives/consensus/grandpa" }
sp-keyring = { version = "7.0.0", path = "../../primitives/keyring" }
sp-tracing = { version = "6.0.0", path = "../../primitives/tracing" }
substrate-test-runtime-client = { version = "2.0.0", path = "../../test-utils/runtime/client" }
@@ -0,0 +1,60 @@
[package]
name = "sc-consensus-grandpa"
version = "0.10.0-dev"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
homepage = "https://substrate.io"
repository = "https://github.com/paritytech/substrate/"
description = "Integration of the GRANDPA finality gadget into substrate."
documentation = "https://docs.rs/sc-consensus-grandpa"
readme = "README.md"
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
ahash = "0.8.2"
array-bytes = "4.1"
async-trait = "0.1.57"
dyn-clone = "1.0"
finality-grandpa = { version = "0.16.1", features = ["derive-codec"] }
futures = "0.3.21"
futures-timer = "3.0.1"
log = "0.4.17"
parity-scale-codec = { version = "3.2.2", features = ["derive"] }
parking_lot = "0.12.1"
rand = "0.8.5"
serde_json = "1.0.85"
thiserror = "1.0"
fork-tree = { version = "3.0.0", path = "../../../utils/fork-tree" }
prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../../utils/prometheus" }
sc-block-builder = { version = "0.10.0-dev", path = "../../block-builder" }
sc-chain-spec = { version = "4.0.0-dev", path = "../../../client/chain-spec" }
sc-client-api = { version = "4.0.0-dev", path = "../../api" }
sc-consensus = { version = "0.10.0-dev", path = "../common" }
sc-network = { version = "0.10.0-dev", path = "../../network" }
sc-network-gossip = { version = "0.10.0-dev", path = "../../network-gossip" }
sc-network-common = { version = "0.10.0-dev", path = "../../network/common" }
sc-telemetry = { version = "4.0.0-dev", path = "../../telemetry" }
sc-utils = { version = "4.0.0-dev", path = "../../utils" }
sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" }
sp-application-crypto = { version = "7.0.0", path = "../../../primitives/application-crypto" }
sp-arithmetic = { version = "6.0.0", path = "../../../primitives/arithmetic" }
sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" }
sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
sp-core = { version = "7.0.0", path = "../../../primitives/core" }
sp-consensus-grandpa = { version = "4.0.0-dev", path = "../../../primitives/consensus/grandpa" }
sp-keystore = { version = "0.13.0", path = "../../../primitives/keystore" }
sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" }
[dev-dependencies]
assert_matches = "1.3.0"
finality-grandpa = { version = "0.16.1", features = ["derive-codec", "test-helpers"] }
serde = "1.0.136"
tokio = "1.22.0"
sc-network = { version = "0.10.0-dev", path = "../../network" }
sc-network-test = { version = "0.8.0", path = "../../network/test" }
sp-keyring = { version = "7.0.0", path = "../../../primitives/keyring" }
sp-tracing = { version = "6.0.0", path = "../../../primitives/tracing" }
substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" }
@@ -0,0 +1,34 @@
[package]
name = "sc-consensus-grandpa-rpc"
version = "0.10.0-dev"
authors = ["Parity Technologies <admin@parity.io>"]
description = "RPC extensions for the GRANDPA finality gadget"
repository = "https://github.com/paritytech/substrate/"
edition = "2021"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
readme = "README.md"
homepage = "https://substrate.io"
[dependencies]
finality-grandpa = { version = "0.16.1", features = ["derive-codec"] }
futures = "0.3.16"
jsonrpsee = { version = "0.16.2", features = ["client-core", "server", "macros"] }
log = "0.4.8"
parity-scale-codec = { version = "3.2.2", features = ["derive"] }
serde = { version = "1.0.105", features = ["derive"] }
thiserror = "1.0"
sc-client-api = { version = "4.0.0-dev", path = "../../../api" }
sc-consensus-grandpa = { version = "0.10.0-dev", path = "../" }
sc-rpc = { version = "4.0.0-dev", path = "../../../rpc" }
sp-blockchain = { version = "4.0.0-dev", path = "../../../../primitives/blockchain" }
sp-core = { version = "7.0.0", path = "../../../../primitives/core" }
sp-runtime = { version = "7.0.0", path = "../../../../primitives/runtime" }
[dev-dependencies]
sc-block-builder = { version = "0.10.0-dev", path = "../../../block-builder" }
sc-rpc = { version = "4.0.0-dev", features = ["test-helpers"], path = "../../../rpc" }
sp-core = { version = "7.0.0", path = "../../../../primitives/core" }
sp-consensus-grandpa = { version = "4.0.0-dev", path = "../../../../primitives/consensus/grandpa" }
sp-keyring = { version = "7.0.0", path = "../../../../primitives/keyring" }
substrate-test-runtime-client = { version = "2.0.0", path = "../../../../test-utils/runtime/client" }
tokio = { version = "1.22.0", features = ["macros"] }
@@ -35,7 +35,7 @@ pub enum Error {
VoterStateReportsUnreasonablyLargeNumbers,
/// GRANDPA prove finality failed.
#[error("GRANDPA prove finality rpc failed: {0}")]
ProveFinalityFailed(#[from] sc_finality_grandpa::FinalityProofError),
ProveFinalityFailed(#[from] sc_consensus_grandpa::FinalityProofError),
}
/// The error codes returned by jsonrpc.
@@ -18,7 +18,7 @@
use serde::{Deserialize, Serialize};
use sc_finality_grandpa::FinalityProofProvider;
use sc_consensus_grandpa::FinalityProofProvider;
use sp_runtime::traits::{Block as BlockT, NumberFor};
#[derive(Serialize, Deserialize)]
@@ -31,7 +31,7 @@ pub trait RpcFinalityProofProvider<Block: BlockT> {
fn rpc_prove_finality(
&self,
block: NumberFor<Block>,
) -> Result<Option<EncodedFinalityProof>, sc_finality_grandpa::FinalityProofError>;
) -> Result<Option<EncodedFinalityProof>, sc_consensus_grandpa::FinalityProofError>;
}
impl<B, Block> RpcFinalityProofProvider<Block> for FinalityProofProvider<B, Block>
@@ -43,7 +43,7 @@ where
fn rpc_prove_finality(
&self,
block: NumberFor<Block>,
) -> Result<Option<EncodedFinalityProof>, sc_finality_grandpa::FinalityProofError> {
) -> Result<Option<EncodedFinalityProof>, sc_consensus_grandpa::FinalityProofError> {
self.prove_finality(block).map(|x| x.map(|y| EncodedFinalityProof(y.into())))
}
}
@@ -35,7 +35,7 @@ mod finality;
mod notification;
mod report;
use sc_finality_grandpa::GrandpaJustificationStream;
use sc_consensus_grandpa::GrandpaJustificationStream;
use sc_rpc::SubscriptionTaskExecutor;
use sp_runtime::traits::{Block as BlockT, NumberFor};
@@ -105,7 +105,7 @@ where
fn subscribe_justifications(&self, mut sink: SubscriptionSink) -> SubscriptionResult {
let stream = self.justification_stream.subscribe(100_000).map(
|x: sc_finality_grandpa::GrandpaJustification<Block>| {
|x: sc_consensus_grandpa::GrandpaJustification<Block>| {
JustificationNotification::from(x)
},
);
@@ -143,7 +143,7 @@ mod tests {
};
use parity_scale_codec::{Decode, Encode};
use sc_block_builder::{BlockBuilder, RecordProof};
use sc_finality_grandpa::{
use sc_consensus_grandpa::{
report, AuthorityId, FinalityProof, GrandpaJustification, GrandpaJustificationSender,
};
use sp_blockchain::HeaderBackend;
@@ -200,7 +200,7 @@ mod tests {
fn rpc_prove_finality(
&self,
_block: NumberFor<Block>,
) -> Result<Option<EncodedFinalityProof>, sc_finality_grandpa::FinalityProofError> {
) -> Result<Option<EncodedFinalityProof>, sc_consensus_grandpa::FinalityProofError> {
Ok(Some(EncodedFinalityProof(
self.finality_proof
.as_ref()
@@ -216,7 +216,7 @@ mod tests {
let voter_id_1 = AuthorityId::from_slice(&[1; 32]).unwrap();
let voters_best: HashSet<_> = vec![voter_id_1].into_iter().collect();
let best_round_state = sc_finality_grandpa::report::RoundState {
let best_round_state = sc_consensus_grandpa::report::RoundState {
total_weight: 100_u64.try_into().unwrap(),
threshold_weight: 67_u64.try_into().unwrap(),
prevote_current_weight: 50.into(),
@@ -225,7 +225,7 @@ mod tests {
precommit_ids: HashSet::new(),
};
let past_round_state = sc_finality_grandpa::report::RoundState {
let past_round_state = sc_consensus_grandpa::report::RoundState {
total_weight: 100_u64.try_into().unwrap(),
threshold_weight: 67_u64.try_into().unwrap(),
prevote_current_weight: 100.into(),
@@ -364,7 +364,7 @@ mod tests {
};
let msg = finality_grandpa::Message::Precommit(precommit.clone());
let encoded = sp_finality_grandpa::localized_payload(round, set_id, &msg);
let encoded = sp_consensus_grandpa::localized_payload(round, set_id, &msg);
let signature = peers[0].sign(&encoded[..]).into();
let precommit = finality_grandpa::SignedPrecommit {
@@ -17,7 +17,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use parity_scale_codec::Encode;
use sc_finality_grandpa::GrandpaJustification;
use sc_consensus_grandpa::GrandpaJustification;
use serde::{Deserialize, Serialize};
use sp_runtime::traits::Block as BlockT;
@@ -24,7 +24,7 @@ use std::{
use serde::{Deserialize, Serialize};
use sc_finality_grandpa::{report, AuthorityId, SharedAuthoritySet, SharedVoterState};
use sc_consensus_grandpa::{report, AuthorityId, SharedAuthoritySet, SharedVoterState};
use crate::error::Error;
@@ -27,7 +27,7 @@ use parity_scale_codec::{Decode, Encode};
use parking_lot::MappedMutexGuard;
use sc_consensus::shared_data::{SharedData, SharedDataLocked};
use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_INFO};
use sp_finality_grandpa::{AuthorityId, AuthorityList};
use sp_consensus_grandpa::{AuthorityId, AuthorityList};
use crate::{SetId, LOG_TARGET};
@@ -27,7 +27,7 @@ use parity_scale_codec::{Decode, Encode};
use fork_tree::ForkTree;
use sc_client_api::backend::AuxStore;
use sp_blockchain::{Error as ClientError, Result as ClientResult};
use sp_finality_grandpa::{AuthorityList, RoundNumber, SetId};
use sp_consensus_grandpa::{AuthorityList, RoundNumber, SetId};
use sp_runtime::traits::{Block as BlockT, NumberFor};
use crate::{
@@ -501,8 +501,8 @@ pub(crate) fn load_authorities<B: AuxStore, H: Decode, N: Decode + Clone + Ord>(
#[cfg(test)]
mod test {
use super::*;
use sp_consensus_grandpa::AuthorityId;
use sp_core::{crypto::UncheckedFrom, H256};
use sp_finality_grandpa::AuthorityId;
use substrate_test_runtime_client::{self, runtime::Block};
fn dummy_id() -> AuthorityId {
@@ -95,7 +95,7 @@ use sc_network_common::protocol::role::ObservedRole;
use sc_network_gossip::{MessageIntent, ValidatorContext};
use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_DEBUG};
use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver, TracingUnboundedSender};
use sp_finality_grandpa::AuthorityId;
use sp_consensus_grandpa::AuthorityId;
use sp_runtime::traits::{Block as BlockT, NumberFor, Zero};
use super::{benefit, cost, Round, SetId, NEIGHBOR_REBROADCAST_PERIOD};
@@ -931,7 +931,7 @@ impl<Block: BlockT> Inner<Block> {
return Action::Discard(cost::UNKNOWN_VOTER)
}
if !sp_finality_grandpa::check_message_signature(
if !sp_consensus_grandpa::check_message_signature(
&full.message.message,
&full.message.id,
&full.message.signature,
@@ -61,7 +61,7 @@ use gossip::{
};
use sc_network_common::service::{NetworkBlock, NetworkSyncForkRequest};
use sc_utils::mpsc::TracingUnboundedReceiver;
use sp_finality_grandpa::{AuthorityId, AuthoritySignature, RoundNumber, SetId as SetIdNumber};
use sp_consensus_grandpa::{AuthorityId, AuthoritySignature, RoundNumber, SetId as SetIdNumber};
pub mod gossip;
mod periodic;
@@ -739,7 +739,7 @@ impl<Block: BlockT> Sink<Message<Block::Header>> for OutgoingMessages<Block> {
// when locals exist, sign messages on import
if let Some(ref keystore) = self.keystore {
let target_hash = *(msg.target().0);
let signed = sp_finality_grandpa::sign_message(
let signed = sp_consensus_grandpa::sign_message(
keystore.keystore(),
msg,
keystore.local_id().clone(),
@@ -842,7 +842,7 @@ fn check_compact_commit<Block: BlockT>(
use crate::communication::gossip::Misbehavior;
use finality_grandpa::Message as GrandpaMessage;
if !sp_finality_grandpa::check_message_signature_with_buffer(
if !sp_consensus_grandpa::check_message_signature_with_buffer(
&GrandpaMessage::Precommit(precommit.clone()),
id,
sig,
@@ -934,7 +934,7 @@ fn check_catch_up<Block: BlockT>(
for (msg, id, sig) in messages {
signatures_checked += 1;
if !sp_finality_grandpa::check_message_signature_with_buffer(
if !sp_consensus_grandpa::check_message_signature_with_buffer(
&msg, id, sig, round, set_id, buf,
) {
debug!(target: LOG_TARGET, "Bad catch up message signature {}", id);
@@ -37,7 +37,7 @@ use sc_network_common::{
use sc_network_gossip::Validator;
use sc_network_test::{Block, Hash};
use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver, TracingUnboundedSender};
use sp_finality_grandpa::AuthorityList;
use sp_consensus_grandpa::AuthorityList;
use sp_keyring::Ed25519Keyring;
use sp_runtime::traits::NumberFor;
use std::{
@@ -237,8 +237,8 @@ fn config() -> crate::Config {
fn voter_set_state() -> SharedVoterSetState<Block> {
use crate::{authorities::AuthoritySet, environment::VoterSetState};
use finality_grandpa::round::State as RoundState;
use sp_consensus_grandpa::AuthorityId;
use sp_core::{crypto::ByteArray, H256};
use sp_finality_grandpa::AuthorityId;
let state = RoundState::genesis((H256::zero(), 0));
let base = state.prevote_ghost.unwrap();
@@ -306,7 +306,7 @@ fn good_commit_leads_to_relay() {
let target_number = 500;
let precommit = finality_grandpa::Precommit { target_hash, target_number };
let payload = sp_finality_grandpa::localized_payload(
let payload = sp_consensus_grandpa::localized_payload(
round,
set_id,
&finality_grandpa::Message::Precommit(precommit.clone()),
@@ -318,7 +318,7 @@ fn good_commit_leads_to_relay() {
for (i, key) in private.iter().enumerate() {
precommits.push(precommit.clone());
let signature = sp_finality_grandpa::AuthoritySignature::from(key.sign(&payload[..]));
let signature = sp_consensus_grandpa::AuthoritySignature::from(key.sign(&payload[..]));
auth_data.push((signature, public[i].0.clone()))
}
@@ -456,7 +456,7 @@ fn bad_commit_leads_to_report() {
let target_number = 500;
let precommit = finality_grandpa::Precommit { target_hash, target_number };
let payload = sp_finality_grandpa::localized_payload(
let payload = sp_consensus_grandpa::localized_payload(
round,
set_id,
&finality_grandpa::Message::Precommit(precommit.clone()),
@@ -468,7 +468,7 @@ fn bad_commit_leads_to_report() {
for (i, key) in private.iter().enumerate() {
precommits.push(precommit.clone());
let signature = sp_finality_grandpa::AuthoritySignature::from(key.sign(&payload[..]));
let signature = sp_consensus_grandpa::AuthoritySignature::from(key.sign(&payload[..]));
auth_data.push((signature, public[i].0.clone()))
}
@@ -631,7 +631,7 @@ fn local_chain_spec() -> Box<dyn sc_chain_spec::ChainSpec> {
}
}
let chain_spec = GenericChainSpec::<Genesis>::from_json_bytes(
&include_bytes!("../../../chain-spec/res/chain_spec.json")[..],
&include_bytes!("../../../../chain-spec/res/chain_spec.json")[..],
)
.unwrap();
chain_spec.cloned_box()
@@ -42,7 +42,7 @@ use sc_client_api::{
use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_DEBUG, CONSENSUS_INFO};
use sp_blockchain::HeaderMetadata;
use sp_consensus::SelectChain as SelectChainT;
use sp_finality_grandpa::{
use sp_consensus_grandpa::{
AuthorityId, AuthoritySignature, Equivocation, EquivocationProof, GrandpaApi, RoundNumber,
SetId, GRANDPA_ENGINE_ID,
};
@@ -42,7 +42,7 @@ use std::sync::Arc;
use parity_scale_codec::{Decode, Encode};
use sc_client_api::backend::Backend;
use sp_blockchain::{Backend as BlockchainBackend, HeaderBackend};
use sp_finality_grandpa::GRANDPA_ENGINE_ID;
use sp_consensus_grandpa::GRANDPA_ENGINE_ID;
use sp_runtime::{
generic::BlockId,
traits::{Block as BlockT, Header as HeaderT, NumberFor, One},
@@ -264,8 +264,8 @@ mod tests {
use sc_block_builder::BlockBuilderProvider;
use sc_client_api::{apply_aux, LockImportRun};
use sp_consensus::BlockOrigin;
use sp_consensus_grandpa::GRANDPA_ENGINE_ID as ID;
use sp_core::crypto::UncheckedFrom;
use sp_finality_grandpa::GRANDPA_ENGINE_ID as ID;
use sp_keyring::Ed25519Keyring;
use substrate_test_runtime_client::{
runtime::{Block, Header, H256},
@@ -279,7 +279,7 @@ mod tests {
/// AND if at least one of those headers is invalid, all other MUST be considered invalid.
fn check_finality_proof<Block: BlockT>(
current_set_id: SetId,
current_authorities: sp_finality_grandpa::AuthorityList,
current_authorities: sp_consensus_grandpa::AuthorityList,
remote_proof: Vec<u8>,
) -> sp_blockchain::Result<super::FinalityProof<Block::Header>>
where
@@ -402,7 +402,7 @@ mod tests {
};
let grandpa_just: GrandpaJustification<Block> =
sp_finality_grandpa::GrandpaJustification::<Header> {
sp_consensus_grandpa::GrandpaJustification::<Header> {
round: 8,
votes_ancestries: Vec::new(),
commit,
@@ -442,7 +442,7 @@ mod tests {
};
let msg = finality_grandpa::Message::Precommit(precommit.clone());
let encoded = sp_finality_grandpa::localized_payload(round, set_id, &msg);
let encoded = sp_consensus_grandpa::localized_payload(round, set_id, &msg);
let signature = voter.sign(&encoded[..]).into();
let signed_precommit = finality_grandpa::SignedPrecommit {
@@ -31,8 +31,8 @@ use sc_utils::mpsc::TracingUnboundedSender;
use sp_api::{Core, RuntimeApiInfo, TransactionFor};
use sp_blockchain::{well_known_cache_keys, BlockStatus};
use sp_consensus::{BlockOrigin, Error as ConsensusError, SelectChain};
use sp_consensus_grandpa::{ConsensusLog, GrandpaApi, ScheduledChange, SetId, GRANDPA_ENGINE_ID};
use sp_core::hashing::twox_128;
use sp_finality_grandpa::{ConsensusLog, GrandpaApi, ScheduledChange, SetId, GRANDPA_ENGINE_ID};
use sp_runtime::{
generic::OpaqueDigestItemId,
traits::{Block as BlockT, Header as HeaderT, NumberFor, Zero},
@@ -25,7 +25,7 @@ use std::{
use finality_grandpa::{voter_set::VoterSet, Error as GrandpaError};
use parity_scale_codec::{Decode, Encode};
use sp_blockchain::{Error as ClientError, HeaderBackend};
use sp_finality_grandpa::AuthorityId;
use sp_consensus_grandpa::AuthorityId;
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor};
use crate::{AuthorityList, Commit, Error};
@@ -41,22 +41,22 @@ use crate::{AuthorityList, Commit, Error};
#[derive(Clone, Encode, Decode, PartialEq, Eq, Debug)]
pub struct GrandpaJustification<Block: BlockT> {
/// The GRANDPA justification for block finality.
pub justification: sp_finality_grandpa::GrandpaJustification<Block::Header>,
pub justification: sp_consensus_grandpa::GrandpaJustification<Block::Header>,
_block: PhantomData<Block>,
}
impl<Block: BlockT> From<sp_finality_grandpa::GrandpaJustification<Block::Header>>
impl<Block: BlockT> From<sp_consensus_grandpa::GrandpaJustification<Block::Header>>
for GrandpaJustification<Block>
{
fn from(justification: sp_finality_grandpa::GrandpaJustification<Block::Header>) -> Self {
fn from(justification: sp_consensus_grandpa::GrandpaJustification<Block::Header>) -> Self {
Self { justification, _block: Default::default() }
}
}
impl<Block: BlockT> Into<sp_finality_grandpa::GrandpaJustification<Block::Header>>
impl<Block: BlockT> Into<sp_consensus_grandpa::GrandpaJustification<Block::Header>>
for GrandpaJustification<Block>
{
fn into(self) -> sp_finality_grandpa::GrandpaJustification<Block::Header> {
fn into(self) -> sp_consensus_grandpa::GrandpaJustification<Block::Header> {
self.justification
}
}
@@ -122,7 +122,7 @@ impl<Block: BlockT> GrandpaJustification<Block> {
}
}
Ok(sp_finality_grandpa::GrandpaJustification { round, commit, votes_ancestries }.into())
Ok(sp_consensus_grandpa::GrandpaJustification { round, commit, votes_ancestries }.into())
}
/// Decode a GRANDPA justification and validate the commit and the votes'
@@ -205,7 +205,7 @@ impl<Block: BlockT> GrandpaJustification<Block> {
let mut buf = Vec::new();
let mut visited_hashes = HashSet::new();
for signed in self.justification.commit.precommits.iter() {
if !sp_finality_grandpa::check_message_signature_with_buffer(
if !sp_consensus_grandpa::check_message_signature_with_buffer(
&finality_grandpa::Message::Precommit(signed.precommit.clone()),
&signed.id,
&signed.signature,
@@ -75,10 +75,10 @@ use sp_api::ProvideRuntimeApi;
use sp_application_crypto::AppKey;
use sp_blockchain::{Error as ClientError, HeaderBackend, HeaderMetadata, Result as ClientResult};
use sp_consensus::SelectChain;
use sp_core::{crypto::ByteArray, traits::CallContext};
use sp_finality_grandpa::{
use sp_consensus_grandpa::{
AuthorityList, AuthoritySignature, SetId, CLIENT_LOG_TARGET as LOG_TARGET,
};
use sp_core::{crypto::ByteArray, traits::CallContext};
use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr};
use sp_runtime::{
generic::BlockId,
@@ -146,7 +146,7 @@ use environment::{Environment, VoterSetState};
use until_imported::UntilGlobalMessageBlocksImported;
// Re-export these two because it's just so damn convenient.
pub use sp_finality_grandpa::{
pub use sp_consensus_grandpa::{
AuthorityId, AuthorityPair, CatchUp, Commit, CompactCommit, GrandpaApi, Message, Precommit,
Prevote, PrimaryPropose, ScheduledChange, SignedMessage,
};
@@ -1091,7 +1091,7 @@ where
Poll::Ready(Ok(())) => {
// voters don't conclude naturally
return Poll::Ready(Err(Error::Safety(
"finality-grandpa inner voter has concluded.".into(),
"consensus-grandpa inner voter has concluded.".into(),
)))
},
Poll::Ready(Err(CommandOrError::Error(e))) => {
@@ -32,7 +32,7 @@ use sc_telemetry::TelemetryHandle;
use sc_utils::mpsc::TracingUnboundedReceiver;
use sp_blockchain::HeaderMetadata;
use sp_consensus::SelectChain;
use sp_finality_grandpa::AuthorityId;
use sp_consensus_grandpa::AuthorityId;
use sp_keystore::SyncCryptoStorePtr;
use sp_runtime::traits::{Block as BlockT, NumberFor};
@@ -35,10 +35,10 @@ use sc_network_test::{
};
use sp_api::{ApiRef, ProvideRuntimeApi};
use sp_consensus::{BlockOrigin, Error as ConsensusError, SelectChain};
use sp_core::H256;
use sp_finality_grandpa::{
use sp_consensus_grandpa::{
AuthorityList, EquivocationProof, GrandpaApi, OpaqueKeyOwnershipProof, GRANDPA_ENGINE_ID,
};
use sp_core::H256;
use sp_keyring::Ed25519Keyring;
use sp_keystore::{testing::KeyStore as TestKeyStore, SyncCryptoStore, SyncCryptoStorePtr};
use sp_runtime::{
@@ -398,7 +398,7 @@ async fn run_to_completion(
fn add_scheduled_change(block: &mut Block, change: ScheduledChange<BlockNumber>) {
block.header.digest_mut().push(DigestItem::Consensus(
GRANDPA_ENGINE_ID,
sp_finality_grandpa::ConsensusLog::ScheduledChange(change).encode(),
sp_consensus_grandpa::ConsensusLog::ScheduledChange(change).encode(),
));
}
@@ -409,7 +409,7 @@ fn add_forced_change(
) {
block.header.digest_mut().push(DigestItem::Consensus(
GRANDPA_ENGINE_ID,
sp_finality_grandpa::ConsensusLog::ForcedChange(median_last_finalized, change).encode(),
sp_consensus_grandpa::ConsensusLog::ForcedChange(median_last_finalized, change).encode(),
));
}
@@ -1798,7 +1798,7 @@ async fn justification_with_equivocation() {
let precommit = finality_grandpa::Precommit { target_hash, target_number };
let msg = finality_grandpa::Message::Precommit(precommit.clone());
let encoded = sp_finality_grandpa::localized_payload(round, set_id, &msg);
let encoded = sp_consensus_grandpa::localized_payload(round, set_id, &msg);
let precommit = finality_grandpa::SignedPrecommit {
precommit: precommit.clone(),
@@ -1871,7 +1871,7 @@ async fn imports_justification_for_regular_blocks_on_import() {
};
let msg = finality_grandpa::Message::Precommit(precommit.clone());
let encoded = sp_finality_grandpa::localized_payload(round, set_id, &msg);
let encoded = sp_consensus_grandpa::localized_payload(round, set_id, &msg);
let signature = peers[0].sign(&encoded[..]).into();
let precommit = finality_grandpa::SignedPrecommit {
@@ -1946,13 +1946,13 @@ async fn grandpa_environment_doesnt_send_equivocation_reports_for_itself() {
// reporting the equivocation should fail since the offender is a local
// authority (i.e. we have keys in our keystore for the given id)
let equivocation_proof = sp_finality_grandpa::Equivocation::Prevote(equivocation.clone());
let equivocation_proof = sp_consensus_grandpa::Equivocation::Prevote(equivocation.clone());
assert!(matches!(environment.report_equivocation(equivocation_proof), Err(Error::Safety(_))));
// if we set the equivocation offender to another id for which we don't have
// keys it should work
equivocation.identity = TryFrom::try_from(&[1; 32][..]).unwrap();
let equivocation_proof = sp_finality_grandpa::Equivocation::Prevote(equivocation);
let equivocation_proof = sp_consensus_grandpa::Equivocation::Prevote(equivocation);
assert!(environment.report_equivocation(equivocation_proof).is_ok());
}
@@ -38,7 +38,7 @@ use parking_lot::Mutex;
use prometheus_endpoint::{register, Gauge, PrometheusError, Registry, U64};
use sc_client_api::{BlockImportNotification, ImportNotifications};
use sc_utils::mpsc::TracingUnboundedReceiver;
use sp_finality_grandpa::AuthorityId;
use sp_consensus_grandpa::AuthorityId;
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor};
use std::{
@@ -25,7 +25,7 @@ use crate::{
use sc_client_api::Backend as ClientBackend;
use sc_network_common::sync::warp::{EncodedProof, VerificationResult, WarpSyncProvider};
use sp_blockchain::{Backend as BlockchainBackend, HeaderBackend};
use sp_finality_grandpa::{AuthorityList, SetId, GRANDPA_ENGINE_ID};
use sp_consensus_grandpa::{AuthorityList, SetId, GRANDPA_ENGINE_ID};
use sp_runtime::{
generic::BlockId,
traits::{Block as BlockT, Header as HeaderT, NumberFor, One},
@@ -324,7 +324,7 @@ mod tests {
use sc_block_builder::BlockBuilderProvider;
use sp_blockchain::HeaderBackend;
use sp_consensus::BlockOrigin;
use sp_finality_grandpa::GRANDPA_ENGINE_ID;
use sp_consensus_grandpa::GRANDPA_ENGINE_ID;
use sp_keyring::Ed25519Keyring;
use sp_runtime::traits::Header as _;
use std::sync::Arc;
@@ -369,9 +369,9 @@ mod tests {
.collect::<Vec<_>>();
let digest = sp_runtime::generic::DigestItem::Consensus(
sp_finality_grandpa::GRANDPA_ENGINE_ID,
sp_finality_grandpa::ConsensusLog::ScheduledChange(
sp_finality_grandpa::ScheduledChange { delay: 0u64, next_authorities },
sp_consensus_grandpa::GRANDPA_ENGINE_ID,
sp_consensus_grandpa::ConsensusLog::ScheduledChange(
sp_consensus_grandpa::ScheduledChange { delay: 0u64, next_authorities },
)
.encode(),
);
@@ -394,7 +394,7 @@ mod tests {
let precommit = finality_grandpa::Precommit { target_hash, target_number };
let msg = finality_grandpa::Message::Precommit(precommit.clone());
let encoded = sp_finality_grandpa::localized_payload(42, current_set_id, &msg);
let encoded = sp_consensus_grandpa::localized_payload(42, current_set_id, &msg);
let signature = keyring.sign(&encoded[..]).into();
let precommit = finality_grandpa::SignedPrecommit {
@@ -1,60 +0,0 @@
[package]
name = "sc-finality-grandpa"
version = "0.10.0-dev"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
homepage = "https://substrate.io"
repository = "https://github.com/paritytech/substrate/"
description = "Integration of the GRANDPA finality gadget into substrate."
documentation = "https://docs.rs/sc-finality-grandpa"
readme = "README.md"
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
ahash = "0.8.2"
array-bytes = "4.1"
async-trait = "0.1.57"
dyn-clone = "1.0"
finality-grandpa = { version = "0.16.1", features = ["derive-codec"] }
futures = "0.3.21"
futures-timer = "3.0.1"
log = "0.4.17"
parity-scale-codec = { version = "3.2.2", features = ["derive"] }
parking_lot = "0.12.1"
rand = "0.8.5"
serde_json = "1.0.85"
thiserror = "1.0"
fork-tree = { version = "3.0.0", path = "../../utils/fork-tree" }
prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../utils/prometheus" }
sc-block-builder = { version = "0.10.0-dev", path = "../block-builder" }
sc-chain-spec = { version = "4.0.0-dev", path = "../../client/chain-spec" }
sc-client-api = { version = "4.0.0-dev", path = "../api" }
sc-consensus = { version = "0.10.0-dev", path = "../consensus/common" }
sc-network = { version = "0.10.0-dev", path = "../network" }
sc-network-gossip = { version = "0.10.0-dev", path = "../network-gossip" }
sc-network-common = { version = "0.10.0-dev", path = "../network/common" }
sc-telemetry = { version = "4.0.0-dev", path = "../telemetry" }
sc-utils = { version = "4.0.0-dev", path = "../utils" }
sp-api = { version = "4.0.0-dev", path = "../../primitives/api" }
sp-application-crypto = { version = "7.0.0", path = "../../primitives/application-crypto" }
sp-arithmetic = { version = "6.0.0", path = "../../primitives/arithmetic" }
sp-blockchain = { version = "4.0.0-dev", path = "../../primitives/blockchain" }
sp-consensus = { version = "0.10.0-dev", path = "../../primitives/consensus/common" }
sp-core = { version = "7.0.0", path = "../../primitives/core" }
sp-finality-grandpa = { version = "4.0.0-dev", path = "../../primitives/finality-grandpa" }
sp-keystore = { version = "0.13.0", path = "../../primitives/keystore" }
sp-runtime = { version = "7.0.0", path = "../../primitives/runtime" }
[dev-dependencies]
assert_matches = "1.3.0"
finality-grandpa = { version = "0.16.1", features = ["derive-codec", "test-helpers"] }
serde = "1.0.136"
tokio = "1.22.0"
sc-network = { version = "0.10.0-dev", path = "../network" }
sc-network-test = { version = "0.8.0", path = "../network/test" }
sp-keyring = { version = "7.0.0", path = "../../primitives/keyring" }
sp-tracing = { version = "6.0.0", path = "../../primitives/tracing" }
substrate-test-runtime-client = { version = "2.0.0", path = "../../test-utils/runtime/client" }
@@ -1,36 +0,0 @@
[package]
name = "sc-finality-grandpa-rpc"
version = "0.10.0-dev"
authors = ["Parity Technologies <admin@parity.io>"]
description = "RPC extensions for the GRANDPA finality gadget"
repository = "https://github.com/paritytech/substrate/"
edition = "2021"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
readme = "README.md"
homepage = "https://substrate.io"
[dependencies]
finality-grandpa = { version = "0.16.1", features = ["derive-codec"] }
futures = "0.3.16"
jsonrpsee = { version = "0.16.2", features = ["client-core", "server", "macros"] }
log = "0.4.8"
parity-scale-codec = { version = "3.2.2", features = ["derive"] }
serde = { version = "1.0.105", features = ["derive"] }
thiserror = "1.0"
sc-client-api = { version = "4.0.0-dev", path = "../../api" }
sc-finality-grandpa = { version = "0.10.0-dev", path = "../" }
sc-rpc = { version = "4.0.0-dev", path = "../../rpc" }
sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" }
sp-core = { version = "7.0.0", path = "../../../primitives/core" }
sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" }
[dev-dependencies]
sc-block-builder = { version = "0.10.0-dev", path = "../../block-builder" }
sc-rpc = { version = "4.0.0-dev", features = [
"test-helpers",
], path = "../../rpc" }
sp-core = { version = "7.0.0", path = "../../../primitives/core" }
sp-finality-grandpa = { version = "4.0.0-dev", path = "../../../primitives/finality-grandpa" }
sp-keyring = { version = "7.0.0", path = "../../../primitives/keyring" }
substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" }
tokio = { version = "1.22.0", features = ["macros"] }
+1 -1
View File
@@ -190,7 +190,7 @@ The API of `sc-network` allows one to register user-defined notification protoco
`sc-network` automatically tries to open a substream towards each node for which the legacy
Substream substream is open. The handshake is then performed automatically.
For example, the `sc-finality-grandpa` crate registers the `/paritytech/grandpa/1`
For example, the `sc-consensus-grandpa` crate registers the `/paritytech/grandpa/1`
notifications protocol.
At the moment, for backwards-compatibility, notification protocols are tied to the legacy
+1 -1
View File
@@ -32,7 +32,7 @@ sc-consensus = { version = "0.10.0-dev", path = "../../consensus/common" }
sc-peerset = { version = "4.0.0-dev", path = "../../peerset" }
serde = { version = "1.0.136", features = ["derive"] }
sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
sp-finality-grandpa = { version = "4.0.0-dev", path = "../../../primitives/finality-grandpa" }
sp-consensus-grandpa = { version = "4.0.0-dev", path = "../../../primitives/consensus/grandpa" }
sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" }
sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" }
thiserror = "1.0"
@@ -16,7 +16,7 @@
use codec::{Decode, Encode};
use futures::channel::oneshot;
pub use sp_finality_grandpa::{AuthorityList, SetId};
pub use sp_consensus_grandpa::{AuthorityList, SetId};
use sp_runtime::traits::{Block as BlockT, NumberFor};
use std::{fmt, sync::Arc};
+1 -1
View File
@@ -212,7 +212,7 @@
//! `sc-network` automatically tries to open a substream towards each node for which the legacy
//! Substream substream is open. The handshake is then performed automatically.
//!
//! For example, the `sc-finality-grandpa` crate registers the `/paritytech/grandpa/1`
//! For example, the `sc-consensus-grandpa` crate registers the `/paritytech/grandpa/1`
//! notifications protocol.
//!
//! At the moment, for backwards-compatibility, notification protocols are tied to the legacy
+1 -1
View File
@@ -38,7 +38,7 @@ sp-arithmetic = { version = "6.0.0", path = "../../../primitives/arithmetic" }
sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" }
sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
sp-core = { version = "7.0.0", path = "../../../primitives/core" }
sp-finality-grandpa = { version = "4.0.0-dev", path = "../../../primitives/finality-grandpa" }
sp-consensus-grandpa = { version = "4.0.0-dev", path = "../../../primitives/consensus/grandpa" }
sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" }
[dev-dependencies]
+1 -1
View File
@@ -34,7 +34,7 @@ use sc_network_common::sync::{
},
};
use sp_blockchain::HeaderBackend;
use sp_finality_grandpa::{AuthorityList, SetId};
use sp_consensus_grandpa::{AuthorityList, SetId};
use sp_runtime::traits::{Block as BlockT, Header, NumberFor, Zero};
use std::{sync::Arc, task::Poll};
+1 -1
View File
@@ -21,6 +21,6 @@ sc-chain-spec = { version = "4.0.0-dev", path = "../chain-spec" }
sc-client-api = { version = "4.0.0-dev", path = "../api" }
sc-consensus-babe = { version = "0.10.0-dev", path = "../consensus/babe" }
sc-consensus-epochs = { version = "0.10.0-dev", path = "../consensus/epochs" }
sc-finality-grandpa = { version = "0.10.0-dev", path = "../finality-grandpa" }
sc-consensus-grandpa = { version = "0.10.0-dev", path = "../consensus/grandpa" }
sp-blockchain = { version = "4.0.0-dev", path = "../../primitives/blockchain" }
sp-runtime = { version = "7.0.0", path = "../../primitives/runtime" }
+2 -2
View File
@@ -52,7 +52,7 @@ use sp_runtime::traits::{Block as BlockT, NumberFor};
use std::sync::Arc;
type SharedAuthoritySet<TBl> =
sc_finality_grandpa::SharedAuthoritySet<<TBl as BlockT>::Hash, NumberFor<TBl>>;
sc_consensus_grandpa::SharedAuthoritySet<<TBl as BlockT>::Hash, NumberFor<TBl>>;
type SharedEpochChanges<TBl> =
sc_consensus_epochs::SharedEpochChanges<TBl, sc_consensus_babe::Epoch>;
@@ -117,7 +117,7 @@ pub struct LightSyncState<Block: BlockT> {
/// The authority set for grandpa.
#[serde(serialize_with = "serialize_encoded")]
pub grandpa_authority_set:
sc_finality_grandpa::AuthoritySet<<Block as BlockT>::Hash, NumberFor<Block>>,
sc_consensus_grandpa::AuthoritySet<<Block as BlockT>::Hash, NumberFor<Block>>,
}
/// An api for sync state RPC calls.
+1 -1
View File
@@ -41,7 +41,7 @@
# GRANDPA, BABE, consensus stuff
/frame/babe/ @andresilva
/frame/grandpa/ @andresilva
/client/finality-grandpa/ @andresilva
/client/consensus/grandpa/ @andresilva
/client/consensus/babe/ @andresilva
/client/consensus/slots/ @andresilva
/client/consensus/pow/ @sorpaas
+2 -2
View File
@@ -23,7 +23,7 @@ pallet-authorship = { version = "4.0.0-dev", default-features = false, path = ".
pallet-session = { version = "4.0.0-dev", default-features = false, path = "../session" }
sp-application-crypto = { version = "7.0.0", default-features = false, path = "../../primitives/application-crypto" }
sp-core = { version = "7.0.0", default-features = false, path = "../../primitives/core" }
sp-finality-grandpa = { version = "4.0.0-dev", default-features = false, path = "../../primitives/finality-grandpa" }
sp-consensus-grandpa = { version = "4.0.0-dev", default-features = false, path = "../../primitives/consensus/grandpa" }
sp-io = { version = "7.0.0", default-features = false, path = "../../primitives/io" }
sp-runtime = { version = "7.0.0", default-features = false, path = "../../primitives/runtime" }
sp-session = { version = "4.0.0-dev", default-features = false, path = "../../primitives/session" }
@@ -54,7 +54,7 @@ std = [
"scale-info/std",
"sp-application-crypto/std",
"sp-core/std",
"sp-finality-grandpa/std",
"sp-consensus-grandpa/std",
"sp-io/std",
"sp-runtime/std",
"sp-session/std",
+3 -3
View File
@@ -50,14 +50,14 @@ benchmarks! {
251, 129, 29, 45, 32, 29, 6
];
let equivocation_proof1: sp_finality_grandpa::EquivocationProof<H256, u64> =
let equivocation_proof1: sp_consensus_grandpa::EquivocationProof<H256, u64> =
Decode::decode(&mut &EQUIVOCATION_PROOF_BLOB[..]).unwrap();
let equivocation_proof2 = equivocation_proof1.clone();
}: {
sp_finality_grandpa::check_equivocation_proof(equivocation_proof1);
sp_consensus_grandpa::check_equivocation_proof(equivocation_proof1);
} verify {
assert!(sp_finality_grandpa::check_equivocation_proof(equivocation_proof2));
assert!(sp_consensus_grandpa::check_equivocation_proof(equivocation_proof2));
}
note_stalled {
+2 -2
View File
@@ -39,7 +39,7 @@ use sp_std::prelude::*;
use codec::{self as codec, Decode, Encode};
use frame_support::traits::{Get, KeyOwnerProofSystem};
use sp_finality_grandpa::{EquivocationProof, RoundNumber, SetId};
use sp_consensus_grandpa::{EquivocationProof, RoundNumber, SetId};
use sp_runtime::{
transaction_validity::{
InvalidTransaction, TransactionPriority, TransactionSource, TransactionValidity,
@@ -251,7 +251,7 @@ fn is_known_offence<T: Config>(
key_owner_proof: &T::KeyOwnerProof,
) -> Result<(), TransactionValidityError> {
// check the membership proof to extract the offender's id
let key = (sp_finality_grandpa::KEY_TYPE, equivocation_proof.offender().clone());
let key = (sp_consensus_grandpa::KEY_TYPE, equivocation_proof.offender().clone());
let offender = T::KeyOwnerProofSystem::check_proof(key, key_owner_proof.clone())
.ok_or(InvalidTransaction::BadProof)?;
+2 -2
View File
@@ -29,7 +29,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
// re-export since this is necessary for `impl_apis` in runtime.
pub use sp_finality_grandpa as fg_primitives;
pub use sp_consensus_grandpa as fg_primitives;
use sp_std::prelude::*;
@@ -555,7 +555,7 @@ impl<T: Config> Pallet<T> {
// validate equivocation proof (check votes are different and
// signatures are valid).
if !sp_finality_grandpa::check_equivocation_proof(equivocation_proof) {
if !sp_consensus_grandpa::check_equivocation_proof(equivocation_proof) {
return Err(Error::<T>::InvalidEquivocationProof.into())
}
+5 -5
View File
@@ -30,8 +30,8 @@ use frame_support::{
},
};
use pallet_session::historical as pallet_session_historical;
use sp_consensus_grandpa::{RoundNumber, SetId, GRANDPA_ENGINE_ID};
use sp_core::{crypto::KeyTypeId, H256};
use sp_finality_grandpa::{RoundNumber, SetId, GRANDPA_ENGINE_ID};
use sp_keyring::Ed25519Keyring;
use sp_runtime::{
curve::PiecewiseLinear,
@@ -354,12 +354,12 @@ pub fn generate_equivocation_proof(
set_id: SetId,
vote1: (RoundNumber, H256, u64, &Ed25519Keyring),
vote2: (RoundNumber, H256, u64, &Ed25519Keyring),
) -> sp_finality_grandpa::EquivocationProof<H256, u64> {
) -> sp_consensus_grandpa::EquivocationProof<H256, u64> {
let signed_prevote = |round, hash, number, keyring: &Ed25519Keyring| {
let prevote = finality_grandpa::Prevote { target_hash: hash, target_number: number };
let prevote_msg = finality_grandpa::Message::Prevote(prevote.clone());
let payload = sp_finality_grandpa::localized_payload(round, set_id, &prevote_msg);
let payload = sp_consensus_grandpa::localized_payload(round, set_id, &prevote_msg);
let signed = keyring.sign(&payload).into();
(prevote, signed)
};
@@ -367,9 +367,9 @@ pub fn generate_equivocation_proof(
let (prevote1, signed1) = signed_prevote(vote1.0, vote1.1, vote1.2, vote1.3);
let (prevote2, signed2) = signed_prevote(vote2.0, vote2.1, vote2.2, vote2.3);
sp_finality_grandpa::EquivocationProof::new(
sp_consensus_grandpa::EquivocationProof::new(
set_id,
sp_finality_grandpa::Equivocation::Prevote(finality_grandpa::Equivocation {
sp_consensus_grandpa::Equivocation::Prevote(finality_grandpa::Equivocation {
round_number: vote1.0,
identity: vote1.3.public().into(),
first: (prevote1, signed1),
+8 -8
View File
@@ -355,7 +355,7 @@ fn report_equivocation_current_set_works() {
// create the key ownership proof
let key_owner_proof =
Historical::prove((sp_finality_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
Historical::prove((sp_consensus_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
// report the equivocation and the tx should be dispatched successfully
assert_ok!(Grandpa::report_equivocation_unsigned(
@@ -408,7 +408,7 @@ fn report_equivocation_old_set_works() {
// create the key ownership proof in the "old" set
let key_owner_proof =
Historical::prove((sp_finality_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
Historical::prove((sp_consensus_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
start_era(2);
@@ -486,7 +486,7 @@ fn report_equivocation_invalid_set_id() {
let equivocation_keyring = extract_keyring(equivocation_key);
let key_owner_proof =
Historical::prove((sp_finality_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
Historical::prove((sp_consensus_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
let set_id = Grandpa::current_set_id();
@@ -524,7 +524,7 @@ fn report_equivocation_invalid_session() {
// generate a key ownership proof at set id = 1
let key_owner_proof =
Historical::prove((sp_finality_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
Historical::prove((sp_consensus_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
start_era(2);
@@ -563,7 +563,7 @@ fn report_equivocation_invalid_key_owner_proof() {
// generate a key ownership proof for the authority at index 1
let invalid_key_owner_proof =
Historical::prove((sp_finality_grandpa::KEY_TYPE, &invalid_owner_key)).unwrap();
Historical::prove((sp_consensus_grandpa::KEY_TYPE, &invalid_owner_key)).unwrap();
let equivocation_authority_index = 0;
let equivocation_key = &authorities[equivocation_authority_index].0;
@@ -610,7 +610,7 @@ fn report_equivocation_invalid_equivocation_proof() {
// generate a key ownership proof at set id = 1
let key_owner_proof =
Historical::prove((sp_finality_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
Historical::prove((sp_consensus_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
let set_id = Grandpa::current_set_id();
@@ -685,7 +685,7 @@ fn report_equivocation_validate_unsigned_prevents_duplicates() {
);
let key_owner_proof =
Historical::prove((sp_finality_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
Historical::prove((sp_consensus_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
let call = Call::report_equivocation_unsigned {
equivocation_proof: Box::new(equivocation_proof.clone()),
@@ -873,7 +873,7 @@ fn valid_equivocation_reports_dont_pay_fees() {
// create the key ownership proof.
let key_owner_proof =
Historical::prove((sp_finality_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
Historical::prove((sp_consensus_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
// check the dispatch info for the call.
let info = Call::<Test>::report_equivocation_unsigned {
@@ -1,5 +1,5 @@
[package]
name = "sp-finality-grandpa"
name = "sp-consensus-grandpa"
version = "4.0.0-dev"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
@@ -7,7 +7,7 @@ license = "Apache-2.0"
homepage = "https://substrate.io"
repository = "https://github.com/paritytech/substrate/"
description = "Primitives for GRANDPA integration, suitable for WASM compilation."
documentation = "https://docs.rs/sp-finality-grandpa"
documentation = "https://docs.rs/sp-consensus-grandpa"
readme = "README.md"
[package.metadata.docs.rs]
@@ -19,12 +19,12 @@ grandpa = { package = "finality-grandpa", version = "0.16.1", default-features =
log = { version = "0.4.17", default-features = false }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
serde = { version = "1.0.136", features = ["derive"], optional = true }
sp-api = { version = "4.0.0-dev", default-features = false, path = "../api" }
sp-application-crypto = { version = "7.0.0", default-features = false, path = "../application-crypto" }
sp-core = { version = "7.0.0", default-features = false, path = "../core" }
sp-keystore = { version = "0.13.0", default-features = false, optional = true, path = "../keystore" }
sp-runtime = { version = "7.0.0", default-features = false, path = "../runtime" }
sp-std = { version = "5.0.0", default-features = false, path = "../std" }
sp-api = { version = "4.0.0-dev", default-features = false, path = "../../api" }
sp-application-crypto = { version = "7.0.0", default-features = false, path = "../../application-crypto" }
sp-core = { version = "7.0.0", default-features = false, path = "../../core" }
sp-keystore = { version = "0.13.0", default-features = false, optional = true, path = "../../keystore" }
sp-runtime = { version = "7.0.0", default-features = false, path = "../../runtime" }
sp-std = { version = "5.0.0", default-features = false, path = "../../std" }
[features]
default = ["std"]
+2 -2
View File
@@ -38,7 +38,7 @@ pallet-babe = { version = "4.0.0-dev", default-features = false, path = "../../f
frame-system = { version = "4.0.0-dev", default-features = false, path = "../../frame/system" }
frame-system-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, path = "../../frame/system/rpc/runtime-api" }
pallet-timestamp = { version = "4.0.0-dev", default-features = false, path = "../../frame/timestamp" }
sp-finality-grandpa = { version = "4.0.0-dev", default-features = false, path = "../../primitives/finality-grandpa" }
sp-consensus-grandpa = { version = "4.0.0-dev", default-features = false, path = "../../primitives/consensus/grandpa" }
sp-trie = { version = "7.0.0", default-features = false, path = "../../primitives/trie" }
sp-transaction-pool = { version = "4.0.0-dev", default-features = false, path = "../../primitives/transaction-pool" }
trie-db = { version = "0.25.1", default-features = false }
@@ -97,7 +97,7 @@ std = [
"frame-system/std",
"pallet-timestamp/std",
"sc-service",
"sp-finality-grandpa/std",
"sp-consensus-grandpa/std",
"sp-trie/std",
"sp-transaction-pool/std",
"trie-db/std",
+8 -8
View File
@@ -945,29 +945,29 @@ cfg_if! {
}
}
impl sp_finality_grandpa::GrandpaApi<Block> for Runtime {
fn grandpa_authorities() -> sp_finality_grandpa::AuthorityList {
impl sp_consensus_grandpa::GrandpaApi<Block> for Runtime {
fn grandpa_authorities() -> sp_consensus_grandpa::AuthorityList {
Vec::new()
}
fn current_set_id() -> sp_finality_grandpa::SetId {
fn current_set_id() -> sp_consensus_grandpa::SetId {
0
}
fn submit_report_equivocation_unsigned_extrinsic(
_equivocation_proof: sp_finality_grandpa::EquivocationProof<
_equivocation_proof: sp_consensus_grandpa::EquivocationProof<
<Block as BlockT>::Hash,
NumberFor<Block>,
>,
_key_owner_proof: sp_finality_grandpa::OpaqueKeyOwnershipProof,
_key_owner_proof: sp_consensus_grandpa::OpaqueKeyOwnershipProof,
) -> Option<()> {
None
}
fn generate_key_ownership_proof(
_set_id: sp_finality_grandpa::SetId,
_authority_id: sp_finality_grandpa::AuthorityId,
) -> Option<sp_finality_grandpa::OpaqueKeyOwnershipProof> {
_set_id: sp_consensus_grandpa::SetId,
_authority_id: sp_consensus_grandpa::AuthorityId,
) -> Option<sp_consensus_grandpa::OpaqueKeyOwnershipProof> {
None
}
}