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
+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.