Refactoring Checkpoint: (WIP)
This commit is contained in:
@@ -19,7 +19,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
[dependencies]
|
||||
async-trait = { workspace = true }
|
||||
codec = { workspace = true, default-features = true }
|
||||
fork-tree = { workspace = true, default-features = true }
|
||||
pez-fork-tree = { workspace = true, default-features = true }
|
||||
futures = { workspace = true }
|
||||
log = { workspace = true, default-features = true }
|
||||
parking_lot = { workspace = true, default-features = true }
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
use std::{fmt::Debug, sync::Arc};
|
||||
|
||||
use codec::Codec;
|
||||
use fork_tree::ForkTree;
|
||||
use pez_fork_tree::ForkTree;
|
||||
use parking_lot::RwLock;
|
||||
use pezsp_api::ProvideRuntimeApi;
|
||||
use pezsp_blockchain::{HeaderBackend, HeaderMetadata};
|
||||
|
||||
@@ -19,7 +19,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
[dependencies]
|
||||
async-trait = { workspace = true }
|
||||
codec = { features = ["derive"], workspace = true, default-features = true }
|
||||
fork-tree = { workspace = true, default-features = true }
|
||||
pez-fork-tree = { workspace = true, default-features = true }
|
||||
futures = { workspace = true }
|
||||
log = { workspace = true, default-features = true }
|
||||
num-bigint = { workspace = true }
|
||||
|
||||
@@ -139,7 +139,7 @@ pub fn load_block_weight<H: Encode, B: AuxStore>(
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::migration::EpochV0;
|
||||
use fork_tree::ForkTree;
|
||||
use pez_fork_tree::ForkTree;
|
||||
use pezsc_consensus_epochs::{EpochHeader, PersistedEpoch, PersistedEpochHeader};
|
||||
use pezsc_network_test::Block as TestBlock;
|
||||
use pezsp_consensus::Error as ConsensusError;
|
||||
|
||||
@@ -354,7 +354,7 @@ pub enum Error<B: BlockT> {
|
||||
RuntimeApi(pezsp_api::ApiError),
|
||||
/// Fork tree error
|
||||
#[error(transparent)]
|
||||
ForkTree(Box<fork_tree::Error<pezsp_blockchain::Error>>),
|
||||
ForkTree(Box<pez_fork_tree::Error<pezsp_blockchain::Error>>),
|
||||
}
|
||||
|
||||
impl<B: BlockT> From<Error<B>> for String {
|
||||
|
||||
@@ -340,11 +340,11 @@ the `PublicKey`, but note that it's not the case for BEEFY. As a consequence of
|
||||
**not** convert the `AccountId` raw bytes into a BEEFY `PublicKey`.
|
||||
|
||||
The easiest way to generate or view hex-encoded or SS58-encoded BEEFY Public Key is by using the
|
||||
[Subkey](https://bizinikiwi.dev/docs/en/knowledgebase/integrate/subkey) tool. Generate a BEEFY key
|
||||
[Subkey](https://bizinikiwi.dev/docs/en/knowledgebase/integrate/pez_subkey) tool. Generate a BEEFY key
|
||||
using the following command
|
||||
|
||||
```sh
|
||||
subkey generate --scheme ecdsa
|
||||
pez_subkey generate --scheme ecdsa
|
||||
```
|
||||
|
||||
The output will look something like
|
||||
|
||||
@@ -18,7 +18,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
codec = { features = ["derive"], workspace = true, default-features = true }
|
||||
fork-tree = { workspace = true, default-features = true }
|
||||
pez-fork-tree = { workspace = true, default-features = true }
|
||||
pezsc-client-api = { workspace = true, default-features = true }
|
||||
pezsc-consensus = { workspace = true, default-features = true }
|
||||
pezsp-blockchain = { workspace = true, default-features = true }
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
pub mod migration;
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use fork_tree::{FilterAction, ForkTree};
|
||||
use pez_fork_tree::{FilterAction, ForkTree};
|
||||
use pezsc_client_api::utils::is_descendent_of;
|
||||
use pezsp_blockchain::{Error as ClientError, HeaderBackend, HeaderMetadata};
|
||||
use pezsp_runtime::traits::{Block as BlockT, NumberFor, One, Zero};
|
||||
@@ -195,7 +195,7 @@ where
|
||||
}
|
||||
|
||||
/// Increment the epoch, yielding an `IncrementedEpoch` to be imported
|
||||
/// into the fork-tree.
|
||||
/// into the pez-fork-tree.
|
||||
pub fn increment(&self, next_descriptor: E::NextEpochDescriptor) -> IncrementedEpoch<E> {
|
||||
let next = self.as_ref().increment(next_descriptor);
|
||||
let to_persist = match *self {
|
||||
@@ -305,7 +305,7 @@ impl<E: Epoch> PersistedEpochHeader<E> {
|
||||
}
|
||||
}
|
||||
|
||||
/// A fresh, incremented epoch to import into the underlying fork-tree.
|
||||
/// A fresh, incremented epoch to import into the underlying pez-fork-tree.
|
||||
///
|
||||
/// Create this with `ViableEpoch::increment`.
|
||||
#[must_use = "Freshly-incremented epoch must be imported with `EpochChanges::import`"]
|
||||
@@ -401,7 +401,7 @@ where
|
||||
hash: &Hash,
|
||||
number: Number,
|
||||
slot: E::Slot,
|
||||
) -> Result<(), fork_tree::Error<D::Error>> {
|
||||
) -> Result<(), pez_fork_tree::Error<D::Error>> {
|
||||
let is_descendent_of = descendent_of_builder.build_is_descendent_of(None);
|
||||
|
||||
let predicate = |epoch: &PersistedEpochHeader<E>| match *epoch {
|
||||
@@ -518,7 +518,7 @@ where
|
||||
parent_number: Number,
|
||||
slot: E::Slot,
|
||||
make_genesis: G,
|
||||
) -> Result<Option<E>, fork_tree::Error<D::Error>>
|
||||
) -> Result<Option<E>, pez_fork_tree::Error<D::Error>>
|
||||
where
|
||||
G: FnOnce(E::Slot) -> E,
|
||||
E: Clone,
|
||||
@@ -543,13 +543,13 @@ where
|
||||
parent_hash: &Hash,
|
||||
parent_number: Number,
|
||||
slot: E::Slot,
|
||||
) -> Result<Option<ViableEpochDescriptor<Hash, Number, E>>, fork_tree::Error<D::Error>> {
|
||||
) -> Result<Option<ViableEpochDescriptor<Hash, Number, E>>, pez_fork_tree::Error<D::Error>> {
|
||||
if parent_number == Zero::zero() {
|
||||
// need to insert the genesis epoch.
|
||||
return Ok(Some(ViableEpochDescriptor::UnimportedGenesis(slot)));
|
||||
}
|
||||
|
||||
// find_node_where will give you the node in the fork-tree which is an ancestor
|
||||
// find_node_where will give you the node in the pez-fork-tree which is an ancestor
|
||||
// of the `parent_hash` by default. if the last epoch was signalled at the parent_hash,
|
||||
// then it won't be returned. we need to create a new fake chain head hash which
|
||||
// "descends" from our parent-hash.
|
||||
@@ -616,7 +616,7 @@ where
|
||||
number: Number,
|
||||
parent_hash: Hash,
|
||||
epoch: IncrementedEpoch<E>,
|
||||
) -> Result<(), fork_tree::Error<D::Error>> {
|
||||
) -> Result<(), pez_fork_tree::Error<D::Error>> {
|
||||
let is_descendent_of =
|
||||
descendent_of_builder.build_is_descendent_of(Some((hash, parent_hash)));
|
||||
let IncrementedEpoch(epoch) = epoch;
|
||||
@@ -625,7 +625,7 @@ where
|
||||
let res = self.inner.import(hash, number, header, &is_descendent_of);
|
||||
|
||||
match res {
|
||||
Ok(_) | Err(fork_tree::Error::Duplicate) => {
|
||||
Ok(_) | Err(pez_fork_tree::Error::Duplicate) => {
|
||||
self.epochs.insert((hash, number), epoch);
|
||||
Ok(())
|
||||
},
|
||||
@@ -641,14 +641,14 @@ where
|
||||
let persisted = PersistedEpoch::Regular(current);
|
||||
let header = PersistedEpochHeader::from(&persisted);
|
||||
let _res = self.inner.import(parent_hash, number - One::one(), header, &|_, _| {
|
||||
Ok(false) as Result<bool, fork_tree::Error<ClientError>>
|
||||
Ok(false) as Result<bool, pez_fork_tree::Error<ClientError>>
|
||||
});
|
||||
self.epochs.insert((parent_hash, number - One::one()), persisted);
|
||||
|
||||
let persisted = PersistedEpoch::Regular(next);
|
||||
let header = PersistedEpochHeader::from(&persisted);
|
||||
let _res = self.inner.import(hash, number, header, &|_, _| {
|
||||
Ok(true) as Result<bool, fork_tree::Error<ClientError>>
|
||||
Ok(true) as Result<bool, pez_fork_tree::Error<ClientError>>
|
||||
});
|
||||
self.epochs.insert((hash, number), persisted);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
use crate::{Epoch, EpochChanges, PersistedEpoch, PersistedEpochHeader};
|
||||
use codec::{Decode, Encode};
|
||||
use fork_tree::ForkTree;
|
||||
use pez_fork_tree::ForkTree;
|
||||
use pezsp_runtime::traits::{Block as BlockT, NumberFor};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ dyn-clone = { workspace = true }
|
||||
finality-grandpa = { features = [
|
||||
"derive-codec",
|
||||
], workspace = true, default-features = true }
|
||||
fork-tree = { workspace = true, default-features = true }
|
||||
pez-fork-tree = { workspace = true, default-features = true }
|
||||
futures = { workspace = true }
|
||||
futures-timer = { workspace = true }
|
||||
log = { workspace = true, default-features = true }
|
||||
|
||||
@@ -22,7 +22,7 @@ use std::{cmp::Ord, fmt::Debug, ops::Add};
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use finality_grandpa::voter_set::VoterSet;
|
||||
use fork_tree::{FilterAction, ForkTree};
|
||||
use pez_fork_tree::{FilterAction, ForkTree};
|
||||
use log::debug;
|
||||
use parking_lot::MappedMutexGuard;
|
||||
use pezsc_consensus::shared_data::{SharedData, SharedDataLocked};
|
||||
@@ -48,14 +48,14 @@ pub enum Error<N, E> {
|
||||
)]
|
||||
ForcedAuthoritySetChangeDependencyUnsatisfied(N),
|
||||
#[error("Invalid operation in the pending changes tree: {0}")]
|
||||
ForkTree(fork_tree::Error<E>),
|
||||
ForkTree(pez_fork_tree::Error<E>),
|
||||
}
|
||||
|
||||
impl<N, E> From<fork_tree::Error<E>> for Error<N, E> {
|
||||
fn from(err: fork_tree::Error<E>) -> Error<N, E> {
|
||||
impl<N, E> From<pez_fork_tree::Error<E>> for Error<N, E> {
|
||||
fn from(err: pez_fork_tree::Error<E>) -> Error<N, E> {
|
||||
match err {
|
||||
fork_tree::Error::Client(err) => Error::Client(err),
|
||||
fork_tree::Error::Duplicate => Error::DuplicateAuthoritySetChange,
|
||||
pez_fork_tree::Error::Client(err) => Error::Client(err),
|
||||
pez_fork_tree::Error::Duplicate => Error::DuplicateAuthoritySetChange,
|
||||
err => Error::ForkTree(err),
|
||||
}
|
||||
}
|
||||
@@ -558,7 +558,7 @@ where
|
||||
is_descendent_of,
|
||||
|change| change.effective_number() <= finalized_number,
|
||||
)? {
|
||||
fork_tree::FinalizationResult::Changed(change) => {
|
||||
pez_fork_tree::FinalizationResult::Changed(change) => {
|
||||
status.changed = true;
|
||||
|
||||
let pending_forced_changes = std::mem::take(&mut self.pending_forced_changes);
|
||||
@@ -595,7 +595,7 @@ where
|
||||
status.new_set_block = Some((finalized_hash, finalized_number));
|
||||
}
|
||||
},
|
||||
fork_tree::FinalizationResult::Unchanged => {},
|
||||
pez_fork_tree::FinalizationResult::Unchanged => {},
|
||||
}
|
||||
|
||||
Ok(status)
|
||||
@@ -1050,7 +1050,7 @@ mod tests {
|
||||
// trying to finalize past `change_c` without finalizing `change_a` first
|
||||
assert!(matches!(
|
||||
authorities.apply_standard_changes("hash_d", 40, &is_descendent_of, false, None),
|
||||
Err(Error::ForkTree(fork_tree::Error::UnfinalizedAncestor))
|
||||
Err(Error::ForkTree(pez_fork_tree::Error::UnfinalizedAncestor))
|
||||
));
|
||||
assert_eq!(authorities.authority_set_changes, AuthoritySetChanges::empty());
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ use codec::{Decode, Encode};
|
||||
use finality_grandpa::round::State as RoundState;
|
||||
use log::{info, warn};
|
||||
|
||||
use fork_tree::ForkTree;
|
||||
use pez_fork_tree::ForkTree;
|
||||
use pezsc_client_api::backend::AuxStore;
|
||||
use pezsp_blockchain::{Error as ClientError, Result as ClientResult};
|
||||
use pezsp_consensus_grandpa::{AuthorityList, RoundNumber, SetId};
|
||||
|
||||
@@ -486,7 +486,7 @@ where
|
||||
let authority_set = AuthoritySet::new(
|
||||
authorities.clone(),
|
||||
set_id,
|
||||
fork_tree::ForkTree::new(),
|
||||
pez_fork_tree::ForkTree::new(),
|
||||
Vec::new(),
|
||||
AuthoritySetChanges::empty(),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user