chore: regenerate umbrella crate, fix feature propagation
This commit is contained in:
@@ -241,8 +241,10 @@ pub trait BlockImportOperation<Block: BlockT> {
|
||||
fn mark_head(&mut self, hash: Block::Hash) -> pezsp_blockchain::Result<()>;
|
||||
|
||||
/// Add a transaction index operation.
|
||||
fn update_transaction_index(&mut self, index: Vec<IndexOperation>)
|
||||
-> pezsp_blockchain::Result<()>;
|
||||
fn update_transaction_index(
|
||||
&mut self,
|
||||
index: Vec<IndexOperation>,
|
||||
) -> pezsp_blockchain::Result<()>;
|
||||
|
||||
/// Configure whether to create a block gap if newly imported block is missing parent
|
||||
fn set_create_gap(&mut self, create_gap: bool);
|
||||
|
||||
@@ -137,19 +137,27 @@ pub trait BlockBackend<Block: BlockT> {
|
||||
///
|
||||
/// Note that this will only fetch transactions
|
||||
/// that are indexed by the runtime with `storage_index_transaction`.
|
||||
fn block_indexed_body(&self, hash: Block::Hash) -> pezsp_blockchain::Result<Option<Vec<Vec<u8>>>>;
|
||||
fn block_indexed_body(
|
||||
&self,
|
||||
hash: Block::Hash,
|
||||
) -> pezsp_blockchain::Result<Option<Vec<Vec<u8>>>>;
|
||||
|
||||
/// Get full block by hash.
|
||||
fn block(&self, hash: Block::Hash) -> pezsp_blockchain::Result<Option<SignedBlock<Block>>>;
|
||||
|
||||
/// Get block status by block hash.
|
||||
fn block_status(&self, hash: Block::Hash) -> pezsp_blockchain::Result<pezsp_consensus::BlockStatus>;
|
||||
fn block_status(
|
||||
&self,
|
||||
hash: Block::Hash,
|
||||
) -> pezsp_blockchain::Result<pezsp_consensus::BlockStatus>;
|
||||
|
||||
/// Get block justifications for the block with the given hash.
|
||||
fn justifications(&self, hash: Block::Hash) -> pezsp_blockchain::Result<Option<Justifications>>;
|
||||
fn justifications(&self, hash: Block::Hash)
|
||||
-> pezsp_blockchain::Result<Option<Justifications>>;
|
||||
|
||||
/// Get block hash by number.
|
||||
fn block_hash(&self, number: NumberFor<Block>) -> pezsp_blockchain::Result<Option<Block::Hash>>;
|
||||
fn block_hash(&self, number: NumberFor<Block>)
|
||||
-> pezsp_blockchain::Result<Option<Block::Hash>>;
|
||||
|
||||
/// Get single indexed transaction by content hash.
|
||||
///
|
||||
|
||||
@@ -407,7 +407,10 @@ impl<Block: BlockT> blockchain::Backend<Block> for Blockchain<Block> {
|
||||
.and_then(|b| b.extrinsics().map(|x| x.to_vec())))
|
||||
}
|
||||
|
||||
fn justifications(&self, hash: Block::Hash) -> pezsp_blockchain::Result<Option<Justifications>> {
|
||||
fn justifications(
|
||||
&self,
|
||||
hash: Block::Hash,
|
||||
) -> pezsp_blockchain::Result<Option<Justifications>> {
|
||||
Ok(self.storage.read().blocks.get(&hash).and_then(|b| b.justifications().cloned()))
|
||||
}
|
||||
|
||||
@@ -672,7 +675,10 @@ impl<Block: BlockT> backend::Backend<Block> for Backend<Block> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn commit_operation(&self, operation: Self::BlockImportOperation) -> pezsp_blockchain::Result<()> {
|
||||
fn commit_operation(
|
||||
&self,
|
||||
operation: Self::BlockImportOperation,
|
||||
) -> pezsp_blockchain::Result<()> {
|
||||
if !operation.finalized_blocks.is_empty() {
|
||||
for (block, justification) in operation.finalized_blocks {
|
||||
self.blockchain.finalize_header(block, justification)?;
|
||||
@@ -804,9 +810,9 @@ pub fn check_genesis_storage(storage: &Storage) -> pezsp_blockchain::Result<()>
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{in_mem::Blockchain, NewBlockState};
|
||||
use bizinikiwi_test_runtime::{Block, Header, H256};
|
||||
use pezsp_blockchain::Backend;
|
||||
use pezsp_runtime::{traits::Header as HeaderT, ConsensusEngineId, Justifications};
|
||||
use bizinikiwi_test_runtime::{Block, Header, H256};
|
||||
|
||||
pub const ID1: ConsensusEngineId = *b"TST1";
|
||||
pub const ID2: ConsensusEngineId = *b"TST2";
|
||||
|
||||
@@ -32,9 +32,9 @@ pub use backend::*;
|
||||
pub use call_executor::*;
|
||||
pub use client::*;
|
||||
pub use notifications::*;
|
||||
pub use proof_provider::*;
|
||||
pub use pezsp_blockchain as blockchain;
|
||||
pub use pezsp_blockchain::HeaderBackend;
|
||||
pub use proof_provider::*;
|
||||
|
||||
pub use pezsp_state_machine::{CompactProof, StorageProof};
|
||||
pub use pezsp_storage::{ChildInfo, PrefixedStorageKey, StorageData, StorageKey};
|
||||
|
||||
@@ -48,7 +48,6 @@ use pezsc_network::{
|
||||
Multiaddr, NetworkDHTProvider, NetworkSigner, NetworkStateInfo,
|
||||
};
|
||||
use pezsc_network_types::{multihash::Code, PeerId};
|
||||
use schema::PeerSignature;
|
||||
use pezsp_api::{ApiError, ProvideRuntimeApi};
|
||||
use pezsp_authority_discovery::{
|
||||
AuthorityDiscoveryApi, AuthorityId, AuthorityPair, AuthoritySignature,
|
||||
@@ -60,6 +59,7 @@ use pezsp_core::{
|
||||
};
|
||||
use pezsp_keystore::{Keystore, KeystorePtr};
|
||||
use pezsp_runtime::traits::Block as BlockT;
|
||||
use schema::PeerSignature;
|
||||
|
||||
mod addr_cache;
|
||||
/// Dht payload schemas generated from Protobuf definitions via Prost crate in build.rs.
|
||||
|
||||
@@ -20,9 +20,9 @@ use crate::error::Error;
|
||||
use log::{info, warn};
|
||||
use pezsc_network::{multiaddr::Protocol, Multiaddr};
|
||||
use pezsc_network_types::PeerId;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use pezsp_authority_discovery::AuthorityId;
|
||||
use pezsp_runtime::DeserializeOwned;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
collections::{hash_map::Entry, HashMap, HashSet},
|
||||
fs::File,
|
||||
@@ -300,8 +300,8 @@ mod tests {
|
||||
|
||||
use super::*;
|
||||
|
||||
use quickcheck::{Arbitrary, Gen, QuickCheck, TestResult};
|
||||
use pezsc_network_types::multihash::{Code, Multihash};
|
||||
use quickcheck::{Arbitrary, Gen, QuickCheck, TestResult};
|
||||
|
||||
use pezsp_authority_discovery::{AuthorityId, AuthorityPair};
|
||||
use pezsp_core::crypto::Pair;
|
||||
|
||||
@@ -26,9 +26,9 @@ mod schema_v2 {
|
||||
|
||||
use super::*;
|
||||
use codec::Encode;
|
||||
use prost::Message;
|
||||
use pezsc_network::{Multiaddr, PeerId};
|
||||
use pezsc_network_types::ed25519::Keypair;
|
||||
use prost::Message;
|
||||
|
||||
#[test]
|
||||
fn v2_decodes_v1() {
|
||||
|
||||
@@ -26,6 +26,7 @@ use std::{
|
||||
use crate::tests::{create_spawner, test_config};
|
||||
|
||||
use super::*;
|
||||
use bizinikiwi_test_runtime_client::runtime::Block;
|
||||
use futures::{
|
||||
channel::mpsc::{self, channel},
|
||||
executor::{block_on, LocalPool},
|
||||
@@ -33,7 +34,6 @@ use futures::{
|
||||
sink::SinkExt,
|
||||
task::LocalSpawn,
|
||||
};
|
||||
use prometheus_endpoint::prometheus::default_registry;
|
||||
use pezsc_client_api::HeaderBackend;
|
||||
use pezsc_network::{
|
||||
service::signature::{Keypair, SigningError},
|
||||
@@ -47,7 +47,7 @@ use pezsc_network_types::{
|
||||
use pezsp_api::{ApiRef, ProvideRuntimeApi};
|
||||
use pezsp_keystore::{testing::MemoryKeystore, Keystore};
|
||||
use pezsp_runtime::traits::{Block as BlockT, NumberFor, Zero};
|
||||
use bizinikiwi_test_runtime_client::runtime::Block;
|
||||
use prometheus_endpoint::prometheus::default_registry;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct TestApi {
|
||||
@@ -135,8 +135,9 @@ pub struct TestNetwork {
|
||||
pub put_value_call: Arc<Mutex<Vec<(KademliaKey, Vec<u8>)>>>,
|
||||
pub put_value_to_call: Arc<Mutex<Vec<(Record, HashSet<pezsc_network_types::PeerId>, bool)>>>,
|
||||
pub get_value_call: Arc<Mutex<Vec<KademliaKey>>>,
|
||||
pub store_value_call:
|
||||
Arc<Mutex<Vec<(KademliaKey, Vec<u8>, Option<pezsc_network_types::PeerId>, Option<Instant>)>>>,
|
||||
pub store_value_call: Arc<
|
||||
Mutex<Vec<(KademliaKey, Vec<u8>, Option<pezsc_network_types::PeerId>, Option<Instant>)>>,
|
||||
>,
|
||||
|
||||
event_sender: mpsc::UnboundedSender<TestNetworkEvent>,
|
||||
event_receiver: Option<mpsc::UnboundedReceiver<TestNetworkEvent>>,
|
||||
|
||||
@@ -27,13 +27,14 @@ use futures::{
|
||||
future::{Future, FutureExt},
|
||||
};
|
||||
use log::{debug, error, info, log_enabled, trace, warn, Level};
|
||||
use prometheus_endpoint::Registry as PrometheusRegistry;
|
||||
use pezsc_block_builder::{BlockBuilderApi, BlockBuilderBuilder};
|
||||
use pezsc_proposer_metrics::{EndProposingReason, MetricsLink as PrometheusMetrics};
|
||||
use pezsc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_INFO};
|
||||
use pezsc_transaction_pool_api::{InPoolTransaction, TransactionPool, TxInvalidityReportMap};
|
||||
use pezsp_api::{ApiExt, CallApiAt, ProofRecorder, ProvideRuntimeApi};
|
||||
use pezsp_blockchain::{ApplyExtrinsicFailed::Validity, Error::ApplyExtrinsicFailed, HeaderBackend};
|
||||
use pezsp_blockchain::{
|
||||
ApplyExtrinsicFailed::Validity, Error::ApplyExtrinsicFailed, HeaderBackend,
|
||||
};
|
||||
use pezsp_consensus::{DisableProofRecording, EnableProofRecording, ProofRecording, Proposal};
|
||||
use pezsp_core::traits::SpawnNamed;
|
||||
use pezsp_inherents::InherentData;
|
||||
@@ -42,6 +43,7 @@ use pezsp_runtime::{
|
||||
Digest, ExtrinsicInclusionMode, Percent, SaturatedConversion,
|
||||
};
|
||||
use pezsp_trie::recorder::IgnoredNodes;
|
||||
use prometheus_endpoint::Registry as PrometheusRegistry;
|
||||
use std::{marker::PhantomData, pin::Pin, sync::Arc, time};
|
||||
|
||||
/// Default block size limit in bytes used by [`Proposer`].
|
||||
@@ -68,8 +70,8 @@ pub struct ProposerFactory<A, C, PR> {
|
||||
metrics: PrometheusMetrics,
|
||||
/// The default block size limit.
|
||||
///
|
||||
/// If no `block_size_limit` is passed to [`pezsp_consensus::Proposer::propose`], this block size
|
||||
/// limit will be used.
|
||||
/// If no `block_size_limit` is passed to [`pezsp_consensus::Proposer::propose`], this block
|
||||
/// size limit will be used.
|
||||
default_block_size_limit: usize,
|
||||
/// Soft deadline percentage of hard deadline.
|
||||
///
|
||||
@@ -672,6 +674,11 @@ where
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
prelude::*,
|
||||
runtime::{Block as TestBlock, Extrinsic, ExtrinsicBuilder, Transfer},
|
||||
TestClientBuilder, TestClientBuilderExt,
|
||||
};
|
||||
use futures::executor::block_on;
|
||||
use parking_lot::Mutex;
|
||||
use pezsc_client_api::{Backend, TrieCacheContext};
|
||||
@@ -681,11 +688,6 @@ mod tests {
|
||||
use pezsp_blockchain::HeaderBackend;
|
||||
use pezsp_consensus::{BlockOrigin, Environment};
|
||||
use pezsp_runtime::{generic::BlockId, traits::NumberFor, Perbill};
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
prelude::*,
|
||||
runtime::{Block as TestBlock, Extrinsic, ExtrinsicBuilder, Transfer},
|
||||
TestClientBuilder, TestClientBuilderExt,
|
||||
};
|
||||
|
||||
const SOURCE: TransactionSource = TransactionSource::External;
|
||||
|
||||
|
||||
@@ -378,12 +378,12 @@ where
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use pezsp_blockchain::HeaderBackend;
|
||||
use pezsp_core::Blake2Hasher;
|
||||
use pezsp_state_machine::Backend;
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
runtime::ExtrinsicBuilder, DefaultTestClientBuilderExt, TestClientBuilderExt,
|
||||
};
|
||||
use pezsp_blockchain::HeaderBackend;
|
||||
use pezsp_core::Blake2Hasher;
|
||||
use pezsp_state_machine::Backend;
|
||||
|
||||
#[test]
|
||||
fn block_building_storage_proof_does_not_include_runtime_by_default() {
|
||||
@@ -404,9 +404,11 @@ mod tests {
|
||||
let proof = block.proof.expect("Proof is build on request");
|
||||
let genesis_state_root = client.header(genesis_hash).unwrap().unwrap().state_root;
|
||||
|
||||
let backend =
|
||||
pezsp_state_machine::create_proof_check_backend::<Blake2Hasher>(genesis_state_root, proof)
|
||||
.unwrap();
|
||||
let backend = pezsp_state_machine::create_proof_check_backend::<Blake2Hasher>(
|
||||
genesis_state_root,
|
||||
proof,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert!(backend
|
||||
.storage(&pezsp_core::storage::well_known_keys::CODE)
|
||||
|
||||
@@ -24,13 +24,13 @@ use crate::{
|
||||
};
|
||||
use pezsc_network::config::MultiaddrWithPeerId;
|
||||
use pezsc_telemetry::TelemetryEndpoints;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json as json;
|
||||
use pezsp_core::{
|
||||
storage::{ChildInfo, Storage, StorageChild, StorageData, StorageKey},
|
||||
Bytes,
|
||||
};
|
||||
use pezsp_runtime::BuildStorage;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json as json;
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
collections::{BTreeMap, VecDeque},
|
||||
@@ -166,8 +166,8 @@ where
|
||||
});
|
||||
},
|
||||
// The `StateRootHash` variant exists as a way to keep note that other clients support
|
||||
// it, but Bizinikiwi itself isn't capable of loading chain specs with just a hash at the
|
||||
// moment.
|
||||
// it, but Bizinikiwi itself isn't capable of loading chain specs with just a hash at
|
||||
// the moment.
|
||||
Genesis::StateRootHash(_) =>
|
||||
return Err("Genesis storage in hash format not supported".into()),
|
||||
Genesis::RuntimeGenesis(RuntimeGenesisInner {
|
||||
@@ -795,11 +795,11 @@ pub fn set_code_substitute_in_json_chain_spec(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
use serde_json::{from_str, json, Value};
|
||||
use pezsp_application_crypto::Ss58Codec;
|
||||
use pezsp_core::storage::well_known_keys;
|
||||
use pezsp_keyring::Sr25519Keyring;
|
||||
use pretty_assertions::assert_eq;
|
||||
use serde_json::{from_str, json, Value};
|
||||
|
||||
type TestSpec = ChainSpec;
|
||||
|
||||
@@ -966,9 +966,10 @@ mod tests {
|
||||
.build();
|
||||
|
||||
let actual = output.as_json(false).unwrap();
|
||||
let expected =
|
||||
from_str::<Value>(include_str!("../res/bizinikiwi_test_runtime_from_named_preset.json"))
|
||||
.unwrap();
|
||||
let expected = from_str::<Value>(include_str!(
|
||||
"../res/bizinikiwi_test_runtime_from_named_preset.json"
|
||||
))
|
||||
.unwrap();
|
||||
|
||||
//wasm blob may change overtime so let's zero it. Also ensure it is there:
|
||||
let actual = zeroize_code_key_in_json(false, actual.as_str());
|
||||
|
||||
@@ -106,8 +106,9 @@ impl<Block: BlockT, B: Backend<Block>, E: RuntimeVersionOf> GenesisBlockBuilder<
|
||||
backend: Arc<B>,
|
||||
executor: E,
|
||||
) -> pezsp_blockchain::Result<Self> {
|
||||
let genesis_storage =
|
||||
build_genesis_storage.build_storage().map_err(pezsp_blockchain::Error::Storage)?;
|
||||
let genesis_storage = build_genesis_storage
|
||||
.build_storage()
|
||||
.map_err(pezsp_blockchain::Error::Storage)?;
|
||||
Self::new_with_storage(genesis_storage, commit_genesis_state, backend, executor)
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
use codec::{Decode, Encode};
|
||||
pub use pezsc_executor::pezsp_wasm_interface::HostFunctions;
|
||||
use pezsc_executor::{error::Result, WasmExecutor};
|
||||
use serde_json::{from_slice, Value};
|
||||
use pezsp_core::{
|
||||
storage::Storage,
|
||||
traits::{CallContext, CodeExecutor, Externalities, FetchRuntimeCode, RuntimeCode},
|
||||
@@ -29,6 +28,7 @@ use pezsp_core::{
|
||||
use pezsp_genesis_builder::{PresetId, Result as BuildResult};
|
||||
pub use pezsp_genesis_builder::{DEV_RUNTIME_PRESET, LOCAL_TESTNET_RUNTIME_PRESET};
|
||||
use pezsp_state_machine::BasicExternalities;
|
||||
use serde_json::{from_slice, Value};
|
||||
use std::borrow::Cow;
|
||||
|
||||
/// A utility that facilitates calling the GenesisBuilder API from the runtime wasm code blob.
|
||||
@@ -85,8 +85,8 @@ where
|
||||
/// Returns a json representation of the default `RuntimeGenesisConfig` provided by the
|
||||
/// `runtime`.
|
||||
///
|
||||
/// Calls [`GenesisBuilder::get_preset`](pezsp_genesis_builder::GenesisBuilder::get_preset) in the
|
||||
/// `runtime` with `None` argument.
|
||||
/// Calls [`GenesisBuilder::get_preset`](pezsp_genesis_builder::GenesisBuilder::get_preset) in
|
||||
/// the `runtime` with `None` argument.
|
||||
pub fn get_default_config(&self) -> core::result::Result<Value, String> {
|
||||
self.get_named_preset(None)
|
||||
}
|
||||
@@ -176,9 +176,9 @@ where
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use serde_json::{from_str, json};
|
||||
pub use pezsp_consensus_babe::{AllowedSlots, BabeEpochConfiguration};
|
||||
pub use pezsp_genesis_builder::PresetId;
|
||||
use serde_json::{from_str, json};
|
||||
|
||||
#[test]
|
||||
fn list_presets_works() {
|
||||
|
||||
@@ -192,9 +192,9 @@
|
||||
//!
|
||||
//! This interaction involves passing the runtime genesis config JSON blob to the runtime using the
|
||||
//! [`pezsp_genesis_builder::GenesisBuilder::build_state`] function. During this operation, the
|
||||
//! runtime converts the JSON representation of the genesis config into [`pezsp_io::storage`] items. It
|
||||
//! is a crucial step for computing the storage root hash, which is a key component in determining
|
||||
//! the genesis hash.
|
||||
//! runtime converts the JSON representation of the genesis config into [`pezsp_io::storage`] items.
|
||||
//! It is a crucial step for computing the storage root hash, which is a key component in
|
||||
//! determining the genesis hash.
|
||||
//!
|
||||
//! Consequently, the runtime must support the [`pezsp_genesis_builder::GenesisBuilder`] API to
|
||||
//! utilize either `patch` or `full` formats.
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
//! Implementation of the `insert` subcommand
|
||||
|
||||
use crate::{
|
||||
utils, with_crypto_scheme, CryptoScheme, Error, KeystoreParams, SharedParams, BizinikiwiCli,
|
||||
utils, with_crypto_scheme, BizinikiwiCli, CryptoScheme, Error, KeystoreParams, SharedParams,
|
||||
};
|
||||
use clap::Parser;
|
||||
use pezsc_keystore::LocalKeystore;
|
||||
|
||||
@@ -22,7 +22,7 @@ use super::{
|
||||
generate::GenerateCmd, generate_node_key::GenerateNodeKeyCmd, insert_key::InsertKeyCmd,
|
||||
inspect_key::InspectKeyCmd, inspect_node_key::InspectNodeKeyCmd,
|
||||
};
|
||||
use crate::{Error, BizinikiwiCli};
|
||||
use crate::{BizinikiwiCli, Error};
|
||||
|
||||
/// Key utilities for the cli.
|
||||
#[derive(Debug, clap::Subcommand)]
|
||||
|
||||
@@ -25,7 +25,6 @@ use crate::{
|
||||
CliConfiguration, PrometheusParams, RpcParams, RuntimeParams, TelemetryParams,
|
||||
};
|
||||
use clap::Parser;
|
||||
use regex::Regex;
|
||||
use pezsc_service::{
|
||||
config::{
|
||||
BasePath, IpNetwork, PrometheusConfig, RpcBatchRequestConfig, TransactionPoolOptions,
|
||||
@@ -33,6 +32,7 @@ use pezsc_service::{
|
||||
ChainSpec, Role,
|
||||
};
|
||||
use pezsc_telemetry::TelemetryEndpoints;
|
||||
use regex::Regex;
|
||||
use std::num::NonZeroU32;
|
||||
|
||||
/// The `run` command used to run a node.
|
||||
|
||||
@@ -21,7 +21,6 @@ use crate::{
|
||||
error::{self, Error},
|
||||
OutputType,
|
||||
};
|
||||
use serde_json::json;
|
||||
use pezsp_core::{
|
||||
crypto::{
|
||||
unwrap_or_default_ss58_version, ExposeSecret, SecretString, Ss58AddressFormat, Ss58Codec,
|
||||
@@ -31,6 +30,7 @@ use pezsp_core::{
|
||||
Pair,
|
||||
};
|
||||
use pezsp_runtime::{traits::IdentifyAccount, MultiSigner};
|
||||
use serde_json::json;
|
||||
use std::path::PathBuf;
|
||||
|
||||
/// Public key type for Runtime
|
||||
|
||||
@@ -22,9 +22,9 @@ use crate::{
|
||||
error, utils, with_crypto_scheme, CryptoSchemeFlag, NetworkSchemeFlag, OutputTypeFlag,
|
||||
};
|
||||
use clap::Parser;
|
||||
use rand::{rngs::OsRng, RngCore};
|
||||
use pezsp_core::crypto::{unwrap_or_default_ss58_version, Ss58AddressFormat, Ss58Codec};
|
||||
use pezsp_runtime::traits::IdentifyAccount;
|
||||
use rand::{rngs::OsRng, RngCore};
|
||||
use utils::print_from_uri;
|
||||
|
||||
/// The `vanity` command
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
//! Configuration trait for a CLI based on bizinikiwi
|
||||
|
||||
use crate::{
|
||||
arg_enums::Database, error::Result, DatabaseParams, ImportParams, KeystoreParams,
|
||||
NetworkParams, NodeKeyParams, OffchainWorkerParams, PruningParams, RpcEndpoint, SharedParams,
|
||||
BizinikiwiCli,
|
||||
arg_enums::Database, error::Result, BizinikiwiCli, DatabaseParams, ImportParams,
|
||||
KeystoreParams, NetworkParams, NodeKeyParams, OffchainWorkerParams, PruningParams, RpcEndpoint,
|
||||
SharedParams,
|
||||
};
|
||||
use log::warn;
|
||||
use names::{Generator, Name};
|
||||
|
||||
@@ -42,11 +42,11 @@ pub use commands::*;
|
||||
pub use config::*;
|
||||
pub use error::*;
|
||||
pub use params::*;
|
||||
pub use runner::*;
|
||||
pub use pezsc_service::{ChainSpec, Role};
|
||||
pub use pezsc_tracing::logging::LoggerBuilder;
|
||||
pub use signals::Signals;
|
||||
pub use pezsp_version::RuntimeVersion;
|
||||
pub use runner::*;
|
||||
pub use signals::Signals;
|
||||
|
||||
/// Bizinikiwi client CLI
|
||||
///
|
||||
|
||||
@@ -34,7 +34,8 @@ impl Into<pezsc_transaction_pool::TransactionPoolType> for TransactionPoolType {
|
||||
match self {
|
||||
TransactionPoolType::SingleState =>
|
||||
pezsc_transaction_pool::TransactionPoolType::SingleState,
|
||||
TransactionPoolType::ForkAware => pezsc_transaction_pool::TransactionPoolType::ForkAware,
|
||||
TransactionPoolType::ForkAware =>
|
||||
pezsc_transaction_pool::TransactionPoolType::ForkAware,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{error::Error as CliError, Result, Signals, BizinikiwiCli};
|
||||
use crate::{error::Error as CliError, BizinikiwiCli, Result, Signals};
|
||||
use chrono::prelude::*;
|
||||
use futures::{future::FutureExt, Future};
|
||||
use log::info;
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
use std::{fmt::Debug, sync::Arc};
|
||||
|
||||
use codec::Codec;
|
||||
use pez_fork_tree::ForkTree;
|
||||
use parking_lot::RwLock;
|
||||
use pez_fork_tree::ForkTree;
|
||||
use pezsp_api::ProvideRuntimeApi;
|
||||
use pezsp_blockchain::{HeaderBackend, HeaderMetadata};
|
||||
use pezsp_consensus_aura::{AuraApi, ConsensusLog, AURA_ENGINE_ID};
|
||||
@@ -108,7 +108,8 @@ where
|
||||
compatibility_mode,
|
||||
)
|
||||
.map_err(|e| format!("Could not fetch authorities at {:?}: {}", parent_hash, e))?;
|
||||
let is_descendent_of = pezsc_client_api::utils::is_descendent_of(&*self.client, None);
|
||||
let is_descendent_of =
|
||||
pezsc_client_api::utils::is_descendent_of(&*self.client, None);
|
||||
let mut authorities_cache = self.authorities.write();
|
||||
authorities_cache
|
||||
.import(
|
||||
|
||||
@@ -24,7 +24,6 @@ use crate::{
|
||||
};
|
||||
use codec::Codec;
|
||||
use log::{debug, info, trace};
|
||||
use prometheus_endpoint::Registry;
|
||||
use pezsc_client_api::{backend::AuxStore, BlockOf, UsageProvider};
|
||||
use pezsc_consensus::{
|
||||
block_import::{BlockImport, BlockImportParams, ForkChoiceStrategy},
|
||||
@@ -44,6 +43,7 @@ use pezsp_runtime::{
|
||||
traits::{Block as BlockT, Header, NumberFor},
|
||||
DigestItem,
|
||||
};
|
||||
use prometheus_endpoint::Registry;
|
||||
use std::{fmt::Debug, sync::Arc};
|
||||
|
||||
/// check a header has been signed by the right key. If the slot is too far in the future, an error
|
||||
|
||||
@@ -546,6 +546,10 @@ where
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
runtime::{Header, H256},
|
||||
TestClient,
|
||||
};
|
||||
use parking_lot::Mutex;
|
||||
use pezsc_block_builder::BlockBuilderBuilder;
|
||||
use pezsc_client_api::BlockchainEvents;
|
||||
@@ -568,10 +572,6 @@ mod tests {
|
||||
task::Poll,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
runtime::{Header, H256},
|
||||
TestClient,
|
||||
};
|
||||
|
||||
const SLOT_DURATION_MS: u64 = 1000;
|
||||
|
||||
|
||||
@@ -193,6 +193,10 @@ impl From<Error> for ErrorObjectOwned {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
runtime::Block, Backend, DefaultTestClientBuilderExt, TestClient, TestClientBuilder,
|
||||
TestClientBuilderExt,
|
||||
};
|
||||
use pezsc_consensus_babe::ImportQueueParams;
|
||||
use pezsc_rpc_api::DenyUnsafe;
|
||||
use pezsc_transaction_pool_api::{OffchainTransactionPoolFactory, RejectAllTxPool};
|
||||
@@ -200,10 +204,6 @@ mod tests {
|
||||
use pezsp_core::{crypto::key_types::BABE, testing::TaskExecutor};
|
||||
use pezsp_keyring::Sr25519Keyring;
|
||||
use pezsp_keystore::{testing::MemoryKeystore, Keystore};
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
runtime::Block, Backend, DefaultTestClientBuilderExt, TestClient, TestClientBuilder,
|
||||
TestClientBuilderExt,
|
||||
};
|
||||
|
||||
fn create_keystore(authority: Sr25519Keyring) -> KeystorePtr {
|
||||
let keystore = MemoryKeystore::new();
|
||||
@@ -213,8 +213,8 @@ mod tests {
|
||||
keystore.into()
|
||||
}
|
||||
|
||||
fn test_babe_rpc_module() -> Babe<Block, TestClient, pezsc_consensus::LongestChain<Backend, Block>>
|
||||
{
|
||||
fn test_babe_rpc_module(
|
||||
) -> Babe<Block, TestClient, pezsc_consensus::LongestChain<Backend, Block>> {
|
||||
let builder = TestClientBuilder::new();
|
||||
let (client, longest_chain) = builder.build_with_longest_chain();
|
||||
let client = Arc::new(client);
|
||||
|
||||
@@ -139,6 +139,7 @@ pub fn load_block_weight<H: Encode, B: AuxStore>(
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::migration::EpochV0;
|
||||
use bizinikiwi_test_runtime_client;
|
||||
use pez_fork_tree::ForkTree;
|
||||
use pezsc_consensus_epochs::{EpochHeader, PersistedEpoch, PersistedEpochHeader};
|
||||
use pezsc_network_test::Block as TestBlock;
|
||||
@@ -146,7 +147,6 @@ mod test {
|
||||
use pezsp_consensus_babe::AllowedSlots;
|
||||
use pezsp_core::H256;
|
||||
use pezsp_runtime::traits::NumberFor;
|
||||
use bizinikiwi_test_runtime_client;
|
||||
|
||||
#[test]
|
||||
fn load_decode_from_v0_epoch_changes() {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
use super::*;
|
||||
use authorship::claim_slot;
|
||||
use bizinikiwi_test_runtime_client::DefaultTestClientBuilderExt;
|
||||
use pezsc_block_builder::{BlockBuilder, BlockBuilderBuilder};
|
||||
use pezsc_client_api::{BlockchainEvents, Finalizer};
|
||||
use pezsc_consensus::{BoxBlockImport, BoxJustificationImport};
|
||||
@@ -43,7 +44,6 @@ use pezsp_runtime::{
|
||||
traits::Block as BlockT,
|
||||
};
|
||||
use std::{cell::RefCell, task::Poll, time::Duration};
|
||||
use bizinikiwi_test_runtime_client::DefaultTestClientBuilderExt;
|
||||
|
||||
type Item = DigestItem;
|
||||
|
||||
|
||||
@@ -163,6 +163,7 @@ where
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
use bizinikiwi_test_runtime_client::runtime::Block;
|
||||
use codec::{Decode, Encode};
|
||||
use jsonrpsee::{core::EmptyServerParams as EmptyParams, RpcModule};
|
||||
use pezsc_consensus_beefy::{
|
||||
@@ -171,7 +172,6 @@ mod tests {
|
||||
};
|
||||
use pezsp_consensus_beefy::{ecdsa_crypto, known_payloads, Payload, SignedCommitment};
|
||||
use pezsp_runtime::traits::{BlakeTwo256, Hash};
|
||||
use bizinikiwi_test_runtime_client::runtime::Block;
|
||||
|
||||
fn setup_io_handler() -> (
|
||||
RpcModule<Beefy<Block, ecdsa_crypto::AuthorityId>>,
|
||||
@@ -190,9 +190,12 @@ mod tests {
|
||||
let (finality_proof_sender, finality_proof_stream) =
|
||||
BeefyVersionedFinalityProofStream::<Block, ecdsa_crypto::AuthorityId>::channel();
|
||||
|
||||
let handler =
|
||||
Beefy::new(finality_proof_stream, best_block_stream, pezsc_rpc::testing::test_executor())
|
||||
.expect("Setting up the BEEFY RPC handler works");
|
||||
let handler = Beefy::new(
|
||||
finality_proof_stream,
|
||||
best_block_stream,
|
||||
pezsc_rpc::testing::test_executor(),
|
||||
)
|
||||
.expect("Setting up the BEEFY RPC handler works");
|
||||
|
||||
(handler.into_rpc(), finality_proof_sender)
|
||||
}
|
||||
|
||||
@@ -607,7 +607,12 @@ pub(crate) mod tests {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn send_topic(&mut self, _who: &pezsc_network_types::PeerId, _topic: B::Hash, _force: bool) {
|
||||
fn send_topic(
|
||||
&mut self,
|
||||
_who: &pezsc_network_types::PeerId,
|
||||
_topic: B::Hash,
|
||||
_force: bool,
|
||||
) {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,12 +81,12 @@ pub(crate) fn verify_with_validator_set<'a, Block: BlockT, AuthorityId: Authorit
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests {
|
||||
use bizinikiwi_test_runtime_client::runtime::Block;
|
||||
use codec::Encode;
|
||||
use pezsp_consensus_beefy::{
|
||||
ecdsa_crypto, known_payloads, test_utils::Keyring, Commitment, Payload, SignedCommitment,
|
||||
VersionedFinalityProof,
|
||||
};
|
||||
use bizinikiwi_test_runtime_client::runtime::Block;
|
||||
|
||||
use super::*;
|
||||
use crate::tests::make_beefy_ids;
|
||||
|
||||
@@ -34,7 +34,6 @@ use crate::{
|
||||
use futures::{stream::Fuse, FutureExt, StreamExt};
|
||||
use log::{debug, error, info, trace, warn};
|
||||
use parking_lot::Mutex;
|
||||
use prometheus_endpoint::Registry;
|
||||
use pezsc_client_api::{Backend, BlockBackend, BlockchainEvents, FinalityNotification, Finalizer};
|
||||
use pezsc_consensus::BlockImport;
|
||||
use pezsc_network::{NetworkRequest, NotificationService, ProtocolName};
|
||||
@@ -48,6 +47,7 @@ use pezsp_consensus_beefy::{
|
||||
};
|
||||
use pezsp_keystore::KeystorePtr;
|
||||
use pezsp_runtime::traits::{Block, Header as HeaderT, NumberFor, Zero};
|
||||
use prometheus_endpoint::Registry;
|
||||
use std::{
|
||||
collections::{BTreeMap, VecDeque},
|
||||
future::Future,
|
||||
@@ -557,8 +557,9 @@ pub async fn start_beefy_gadget<B, BE, C, N, P, R, S, AuthorityId>(
|
||||
|
||||
let mut block_import_justif = links.from_block_import_justif_stream.subscribe(100_000).fuse();
|
||||
|
||||
// Subscribe to finality notifications and justifications before waiting for runtime pezpallet and
|
||||
// reuse the streams, so we don't miss notifications while waiting for pezpallet to be available.
|
||||
// Subscribe to finality notifications and justifications before waiting for runtime pezpallet
|
||||
// and reuse the streams, so we don't miss notifications while waiting for pezpallet to be
|
||||
// available.
|
||||
let finality_notifications = client.finality_notification_stream();
|
||||
let (mut transformer, mut finality_notifications) =
|
||||
finality_notification_transformer_future(finality_notifications);
|
||||
|
||||
@@ -36,6 +36,7 @@ use crate::{
|
||||
worker::PersistedState,
|
||||
BeefyRPCLinks, BeefyVoterLinks, BeefyWorkerBuilder, KnownPeers, UnpinnedFinalityNotification,
|
||||
};
|
||||
use bizinikiwi_test_runtime_client::{BlockBuilderExt, ClientExt};
|
||||
use futures::{
|
||||
future,
|
||||
stream::{Fuse, FuturesUnordered},
|
||||
@@ -43,7 +44,9 @@ use futures::{
|
||||
};
|
||||
use parking_lot::Mutex;
|
||||
use pezsc_block_builder::BlockBuilderBuilder;
|
||||
use pezsc_client_api::{Backend as BackendT, BlockchainEvents, FinalityNotifications, HeaderBackend};
|
||||
use pezsc_client_api::{
|
||||
Backend as BackendT, BlockchainEvents, FinalityNotifications, HeaderBackend,
|
||||
};
|
||||
use pezsc_consensus::{
|
||||
BlockImport, BlockImportParams, BoxJustificationImport, ForkChoiceStrategy, ImportResult,
|
||||
ImportedAux,
|
||||
@@ -54,7 +57,6 @@ use pezsc_network_test::{
|
||||
PeersFullClient, TestNetFactory,
|
||||
};
|
||||
use pezsc_utils::{mpsc::TracingUnboundedReceiver, notification::NotificationReceiver};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use pezsp_api::{ApiRef, ProvideRuntimeApi};
|
||||
use pezsp_application_crypto::key_types::BEEFY as BEEFY_KEY_TYPE;
|
||||
use pezsp_consensus::BlockOrigin;
|
||||
@@ -76,8 +78,8 @@ use pezsp_runtime::{
|
||||
traits::{Header as HeaderT, NumberFor},
|
||||
BuildStorage, DigestItem, EncodedJustification, Justifications, Storage,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{marker::PhantomData, sync::Arc, task::Poll};
|
||||
use bizinikiwi_test_runtime_client::{BlockBuilderExt, ClientExt};
|
||||
use tokio::time::Duration;
|
||||
|
||||
const GENESIS_HASH: H256 = H256::zero();
|
||||
@@ -1395,7 +1397,8 @@ async fn beefy_finalizing_after_pallet_genesis() {
|
||||
|
||||
// Minimum BEEFY block delta is 1.
|
||||
|
||||
// GRANDPA finalize blocks leading up to BEEFY pezpallet genesis -> BEEFY should finalize nothing.
|
||||
// GRANDPA finalize blocks leading up to BEEFY pezpallet genesis -> BEEFY should finalize
|
||||
// nothing.
|
||||
finalize_block_and_wait_for_beefy(&net, peers.clone(), &hashes[14], &[]).await;
|
||||
|
||||
// GRANDPA finalize block #16 -> BEEFY should finalize #15 (genesis mandatory) and #16.
|
||||
|
||||
@@ -1035,6 +1035,10 @@ pub(crate) mod tests {
|
||||
},
|
||||
BeefyRPCLinks, KnownPeers,
|
||||
};
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
runtime::{Block, Digest, DigestItem, Header},
|
||||
Backend,
|
||||
};
|
||||
use futures::{future::poll_fn, task::Poll};
|
||||
use parking_lot::Mutex;
|
||||
use pezsc_client_api::{Backend as BackendT, HeaderBackend};
|
||||
@@ -1050,10 +1054,6 @@ pub(crate) mod tests {
|
||||
ConsensusLog, Payload, SignedCommitment,
|
||||
};
|
||||
use pezsp_runtime::traits::{Header as HeaderT, One};
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
runtime::{Block, Digest, DigestItem, Header},
|
||||
Backend,
|
||||
};
|
||||
|
||||
impl<B: super::Block, AuthorityId: AuthorityIdBound> PersistedState<B, AuthorityId> {
|
||||
pub fn active_round(&self) -> Result<&Rounds<B, AuthorityId>, Error> {
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
|
||||
//! Block import helpers.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use pezsp_runtime::{
|
||||
traits::{Block as BlockT, HashingFor, Header as HeaderT, NumberFor},
|
||||
DigestItem, Justification, Justifications,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{any::Any, borrow::Cow, collections::HashMap, sync::Arc};
|
||||
|
||||
use pezsp_consensus::{BlockOrigin, Error};
|
||||
|
||||
@@ -20,13 +20,13 @@ use futures::{
|
||||
task::{Context, Poll},
|
||||
};
|
||||
use log::{debug, trace};
|
||||
use prometheus_endpoint::Registry;
|
||||
use pezsc_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver, TracingUnboundedSender};
|
||||
use pezsp_consensus::BlockOrigin;
|
||||
use pezsp_runtime::{
|
||||
traits::{Block as BlockT, Header as HeaderT, NumberFor},
|
||||
Justification, Justifications,
|
||||
};
|
||||
use prometheus_endpoint::Registry;
|
||||
use std::pin::Pin;
|
||||
|
||||
use crate::{
|
||||
|
||||
@@ -36,13 +36,13 @@ mod report;
|
||||
use error::Error;
|
||||
use finality::{EncodedFinalityProof, RpcFinalityProofProvider};
|
||||
use notification::JustificationNotification;
|
||||
use report::{ReportAuthoritySet, ReportVoterState, ReportedRoundStates};
|
||||
use pezsc_consensus_grandpa::GrandpaJustificationStream;
|
||||
use pezsc_rpc::{
|
||||
utils::{BoundedVecDeque, PendingSubscription},
|
||||
SubscriptionTaskExecutor,
|
||||
};
|
||||
use pezsp_runtime::traits::{Block as BlockT, NumberFor};
|
||||
use report::{ReportAuthoritySet, ReportVoterState, ReportedRoundStates};
|
||||
|
||||
/// Provides RPC methods for interacting with GRANDPA.
|
||||
#[rpc(client, server)]
|
||||
@@ -133,6 +133,10 @@ mod tests {
|
||||
use super::*;
|
||||
use std::{collections::HashSet, sync::Arc};
|
||||
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
runtime::{Block, Header, H256},
|
||||
DefaultTestClientBuilderExt, TestClientBuilder, TestClientBuilderExt,
|
||||
};
|
||||
use codec::{Decode, Encode};
|
||||
use jsonrpsee::{core::EmptyServerParams as EmptyParams, types::SubscriptionId, RpcModule};
|
||||
use pezsc_block_builder::BlockBuilderBuilder;
|
||||
@@ -144,10 +148,6 @@ mod tests {
|
||||
use pezsp_core::crypto::ByteArray;
|
||||
use pezsp_keyring::Ed25519Keyring;
|
||||
use pezsp_runtime::traits::{Block as BlockT, Header as HeaderT};
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
runtime::{Block, Header, H256},
|
||||
DefaultTestClientBuilderExt, TestClientBuilder, TestClientBuilderExt,
|
||||
};
|
||||
|
||||
struct TestAuthoritySet;
|
||||
struct TestVoterState;
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
use codec::Encode;
|
||||
use pezsc_consensus_grandpa::GrandpaJustification;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use pezsp_runtime::traits::Block as BlockT;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// An encoded justification proving that the given header has been finalized
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
|
||||
@@ -22,9 +22,9 @@ use std::{cmp::Ord, fmt::Debug, ops::Add};
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use finality_grandpa::voter_set::VoterSet;
|
||||
use pez_fork_tree::{FilterAction, ForkTree};
|
||||
use log::debug;
|
||||
use parking_lot::MappedMutexGuard;
|
||||
use pez_fork_tree::{FilterAction, ForkTree};
|
||||
use pezsc_consensus::shared_data::{SharedData, SharedDataLocked};
|
||||
use pezsc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_INFO};
|
||||
use pezsp_consensus_grandpa::{AuthorityId, AuthorityList};
|
||||
|
||||
@@ -504,9 +504,9 @@ pub(crate) fn load_authorities<B: AuxStore, H: Decode, N: Decode + Clone + Ord>(
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use bizinikiwi_test_runtime_client::{self, runtime::Block};
|
||||
use pezsp_consensus_grandpa::AuthorityId;
|
||||
use pezsp_core::{crypto::UncheckedFrom, H256};
|
||||
use bizinikiwi_test_runtime_client::{self, runtime::Block};
|
||||
|
||||
fn dummy_id() -> AuthorityId {
|
||||
AuthorityId::unchecked_from([1; 32])
|
||||
|
||||
@@ -88,8 +88,6 @@
|
||||
use ahash::{AHashMap, AHashSet};
|
||||
use codec::{Decode, DecodeAll, Encode};
|
||||
use log::{debug, trace};
|
||||
use prometheus_endpoint::{register, CounterVec, Opts, PrometheusError, Registry, U64};
|
||||
use rand::seq::SliceRandom;
|
||||
use pezsc_network::ReputationChange;
|
||||
use pezsc_network_common::role::ObservedRole;
|
||||
use pezsc_network_gossip::{MessageIntent, ValidatorContext};
|
||||
@@ -98,6 +96,8 @@ use pezsc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_DEBUG};
|
||||
use pezsc_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver, TracingUnboundedSender};
|
||||
use pezsp_consensus_grandpa::AuthorityId;
|
||||
use pezsp_runtime::traits::{Block as BlockT, NumberFor, Zero};
|
||||
use prometheus_endpoint::{register, CounterVec, Opts, PrometheusError, Registry, U64};
|
||||
use rand::seq::SliceRandom;
|
||||
|
||||
use super::{benefit, cost, Round, SetId, NEIGHBOR_REBROADCAST_PERIOD};
|
||||
use crate::{environment, CatchUp, CompactCommit, SignedMessage, LOG_TARGET};
|
||||
@@ -1666,11 +1666,11 @@ pub(super) struct PeerReport {
|
||||
mod tests {
|
||||
use super::{super::NEIGHBOR_REBROADCAST_PERIOD, environment::SharedVoterSetState, *};
|
||||
use crate::communication;
|
||||
use bizinikiwi_test_runtime_client::runtime::{Block, Header};
|
||||
use pezsc_network::config::Role;
|
||||
use pezsc_network_gossip::Validator as GossipValidatorT;
|
||||
use pezsp_core::{crypto::UncheckedFrom, H256};
|
||||
use std::time::Instant;
|
||||
use bizinikiwi_test_runtime_client::runtime::{Block, Header};
|
||||
|
||||
// some random config (not really needed)
|
||||
fn config() -> crate::Config {
|
||||
|
||||
@@ -389,7 +389,8 @@ fn good_commit_leads_to_relay() {
|
||||
for (i, key) in private.iter().enumerate() {
|
||||
precommits.push(precommit.clone());
|
||||
|
||||
let signature = pezsp_consensus_grandpa::AuthoritySignature::from(key.sign(&payload[..]));
|
||||
let signature =
|
||||
pezsp_consensus_grandpa::AuthoritySignature::from(key.sign(&payload[..]));
|
||||
auth_data.push((signature, public[i].0.clone()))
|
||||
}
|
||||
|
||||
@@ -540,7 +541,8 @@ fn bad_commit_leads_to_report() {
|
||||
for (i, key) in private.iter().enumerate() {
|
||||
precommits.push(precommit.clone());
|
||||
|
||||
let signature = pezsp_consensus_grandpa::AuthoritySignature::from(key.sign(&payload[..]));
|
||||
let signature =
|
||||
pezsp_consensus_grandpa::AuthoritySignature::from(key.sign(&payload[..]));
|
||||
auth_data.push((signature, public[i].0.clone()))
|
||||
}
|
||||
|
||||
|
||||
@@ -400,7 +400,10 @@ impl Metrics {
|
||||
) -> Result<Self, PrometheusError> {
|
||||
Ok(Self {
|
||||
finality_grandpa_round: register(
|
||||
Gauge::new("bizinikiwi_finality_grandpa_round", "Highest completed GRANDPA round.")?,
|
||||
Gauge::new(
|
||||
"bizinikiwi_finality_grandpa_round",
|
||||
"Highest completed GRANDPA round.",
|
||||
)?,
|
||||
registry,
|
||||
)?,
|
||||
finality_grandpa_prevotes: register(
|
||||
|
||||
@@ -260,6 +260,11 @@ where
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{authorities::AuthoritySetChanges, BlockNumberOps, ClientError, SetId};
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
runtime::{Block, Header, H256},
|
||||
Backend as TestBackend, ClientBlockImportExt, ClientExt, DefaultTestClientBuilderExt,
|
||||
TestClient, TestClientBuilder, TestClientBuilderExt,
|
||||
};
|
||||
use futures::executor::block_on;
|
||||
use pezsc_block_builder::BlockBuilderBuilder;
|
||||
use pezsc_client_api::{apply_aux, LockImportRun};
|
||||
@@ -267,11 +272,6 @@ mod tests {
|
||||
use pezsp_consensus_grandpa::GRANDPA_ENGINE_ID as ID;
|
||||
use pezsp_core::crypto::UncheckedFrom;
|
||||
use pezsp_keyring::Ed25519Keyring;
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
runtime::{Block, Header, H256},
|
||||
Backend as TestBackend, ClientBlockImportExt, ClientExt, DefaultTestClientBuilderExt,
|
||||
TestClient, TestClientBuilder, TestClientBuilderExt,
|
||||
};
|
||||
|
||||
/// Check GRANDPA proof-of-finality for the given block.
|
||||
///
|
||||
|
||||
@@ -32,7 +32,9 @@ use pezsc_utils::mpsc::TracingUnboundedSender;
|
||||
use pezsp_api::{Core, RuntimeApiInfo};
|
||||
use pezsp_blockchain::BlockStatus;
|
||||
use pezsp_consensus::{BlockOrigin, Error as ConsensusError, SelectChain};
|
||||
use pezsp_consensus_grandpa::{ConsensusLog, GrandpaApi, ScheduledChange, SetId, GRANDPA_ENGINE_ID};
|
||||
use pezsp_consensus_grandpa::{
|
||||
ConsensusLog, GrandpaApi, ScheduledChange, SetId, GRANDPA_ENGINE_ID,
|
||||
};
|
||||
use pezsp_runtime::{
|
||||
generic::OpaqueDigestItemId,
|
||||
traits::{Block as BlockT, Header as HeaderT, NumberFor, Zero},
|
||||
|
||||
@@ -60,7 +60,6 @@ use codec::Decode;
|
||||
use futures::{prelude::*, StreamExt};
|
||||
use log::{debug, error, info};
|
||||
use parking_lot::RwLock;
|
||||
use prometheus_endpoint::{PrometheusError, Registry};
|
||||
use pezsc_client_api::{
|
||||
backend::{AuxStore, Backend},
|
||||
utils::is_descendent_of,
|
||||
@@ -73,7 +72,9 @@ use pezsc_transaction_pool_api::OffchainTransactionPoolFactory;
|
||||
use pezsc_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver};
|
||||
use pezsp_api::ProvideRuntimeApi;
|
||||
use pezsp_application_crypto::AppCrypto;
|
||||
use pezsp_blockchain::{Error as ClientError, HeaderBackend, HeaderMetadata, Result as ClientResult};
|
||||
use pezsp_blockchain::{
|
||||
Error as ClientError, HeaderBackend, HeaderMetadata, Result as ClientResult,
|
||||
};
|
||||
use pezsp_consensus::SelectChain;
|
||||
use pezsp_consensus_grandpa::{
|
||||
AuthorityList, AuthoritySignature, SetId, CLIENT_LOG_TARGET as LOG_TARGET,
|
||||
@@ -84,6 +85,7 @@ use pezsp_runtime::{
|
||||
generic::BlockId,
|
||||
traits::{Block as BlockT, NumberFor, Zero},
|
||||
};
|
||||
use prometheus_endpoint::{PrometheusError, Registry};
|
||||
|
||||
pub use finality_grandpa::BlockNumberOps;
|
||||
use finality_grandpa::{voter, voter_set::VoterSet, Error as GrandpaError};
|
||||
@@ -682,8 +684,8 @@ pub struct GrandpaParams<Block: BlockT, C, N, S, SC, VR> {
|
||||
/// The Network instance.
|
||||
///
|
||||
/// It is assumed that this network will feed us Grandpa notifications. When using the
|
||||
/// `pezsc_network` crate, it is assumed that the Grandpa notifications protocol has been passed
|
||||
/// to the configuration of the networking. See [`grandpa_peers_set_config`].
|
||||
/// `pezsc_network` crate, it is assumed that the Grandpa notifications protocol has been
|
||||
/// passed to the configuration of the networking. See [`grandpa_peers_set_config`].
|
||||
pub network: N,
|
||||
/// Event stream for syncing-related events.
|
||||
pub sync: S,
|
||||
|
||||
@@ -410,10 +410,10 @@ mod tests {
|
||||
communication::tests::{make_test_network, Event},
|
||||
};
|
||||
use assert_matches::assert_matches;
|
||||
use bizinikiwi_test_runtime_client::{TestClientBuilder, TestClientBuilderExt};
|
||||
use pezsc_network_types::PeerId;
|
||||
use pezsc_utils::mpsc::tracing_unbounded;
|
||||
use pezsp_blockchain::HeaderBackend as _;
|
||||
use bizinikiwi_test_runtime_client::{TestClientBuilder, TestClientBuilderExt};
|
||||
|
||||
use futures::executor;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
use super::*;
|
||||
use assert_matches::assert_matches;
|
||||
use async_trait::async_trait;
|
||||
use bizinikiwi_test_runtime_client::{runtime::BlockNumber, BlockBuilderExt};
|
||||
use environment::HasVoted;
|
||||
use futures_timer::Delay;
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
@@ -49,7 +50,6 @@ use pezsp_runtime::{
|
||||
Justifications,
|
||||
};
|
||||
use std::{collections::HashSet, pin::Pin};
|
||||
use bizinikiwi_test_runtime_client::{runtime::BlockNumber, BlockBuilderExt};
|
||||
use tokio::runtime::Handle;
|
||||
|
||||
use authorities::AuthoritySet;
|
||||
|
||||
@@ -35,11 +35,11 @@ use futures::{
|
||||
use futures_timer::Delay;
|
||||
use log::{debug, warn};
|
||||
use parking_lot::Mutex;
|
||||
use prometheus_endpoint::{register, Gauge, PrometheusError, Registry, U64};
|
||||
use pezsc_client_api::{BlockImportNotification, ImportNotifications};
|
||||
use pezsc_utils::mpsc::TracingUnboundedReceiver;
|
||||
use pezsp_consensus_grandpa::AuthorityId;
|
||||
use pezsp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor};
|
||||
use prometheus_endpoint::{register, Gauge, PrometheusError, Registry, U64};
|
||||
|
||||
use std::{
|
||||
collections::{HashMap, VecDeque},
|
||||
@@ -562,6 +562,7 @@ pub(crate) type UntilGlobalMessageBlocksImported<Block, BlockStatus, BlockSyncRe
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{CatchUp, CompactCommit};
|
||||
use bizinikiwi_test_runtime_client::runtime::{Block, Hash, Header};
|
||||
use finality_grandpa::Precommit;
|
||||
use futures::future::Either;
|
||||
use futures_timer::Delay;
|
||||
@@ -569,7 +570,6 @@ mod tests {
|
||||
use pezsc_utils::mpsc::{tracing_unbounded, TracingUnboundedSender};
|
||||
use pezsp_consensus::BlockOrigin;
|
||||
use pezsp_core::crypto::UncheckedFrom;
|
||||
use bizinikiwi_test_runtime_client::runtime::{Block, Hash, Header};
|
||||
|
||||
#[derive(Clone)]
|
||||
struct TestChainState {
|
||||
|
||||
@@ -347,18 +347,18 @@ where
|
||||
mod tests {
|
||||
use super::WarpSyncProof;
|
||||
use crate::{AuthoritySetChanges, GrandpaJustification};
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
BlockBuilderExt, ClientBlockImportExt, ClientExt, DefaultTestClientBuilderExt,
|
||||
TestClientBuilder, TestClientBuilderExt,
|
||||
};
|
||||
use codec::Encode;
|
||||
use rand::prelude::*;
|
||||
use pezsc_block_builder::BlockBuilderBuilder;
|
||||
use pezsp_blockchain::HeaderBackend;
|
||||
use pezsp_consensus::BlockOrigin;
|
||||
use pezsp_consensus_grandpa::GRANDPA_ENGINE_ID;
|
||||
use pezsp_keyring::Ed25519Keyring;
|
||||
use rand::prelude::*;
|
||||
use std::sync::Arc;
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
BlockBuilderExt, ClientBlockImportExt, ClientExt, DefaultTestClientBuilderExt,
|
||||
TestClientBuilder, TestClientBuilderExt,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn warp_sync_proof_generate_verify() {
|
||||
@@ -426,7 +426,8 @@ mod tests {
|
||||
let precommit = finality_grandpa::Precommit { target_hash, target_number };
|
||||
|
||||
let msg = finality_grandpa::Message::Precommit(precommit.clone());
|
||||
let encoded = pezsp_consensus_grandpa::localized_payload(42, current_set_id, &msg);
|
||||
let encoded =
|
||||
pezsp_consensus_grandpa::localized_payload(42, current_set_id, &msg);
|
||||
let signature = keyring.sign(&encoded[..]).into();
|
||||
|
||||
let precommit = finality_grandpa::SignedPrecommit {
|
||||
|
||||
@@ -82,8 +82,9 @@ impl SlotTimestampProvider {
|
||||
let slot_duration = pezsc_consensus_aura::slot_duration(&*client)?;
|
||||
|
||||
let time = Self::with_header(&client, slot_duration, |header| {
|
||||
let slot_number = *pezsc_consensus_aura::find_pre_digest::<B, AuthoritySignature>(&header)
|
||||
.map_err(|err| format!("{}", err))?;
|
||||
let slot_number =
|
||||
*pezsc_consensus_aura::find_pre_digest::<B, AuthoritySignature>(&header)
|
||||
.map_err(|err| format!("{}", err))?;
|
||||
Ok(slot_number)
|
||||
})?;
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
use futures::prelude::*;
|
||||
use futures_timer::Delay;
|
||||
use prometheus_endpoint::Registry;
|
||||
use pezsc_client_api::{
|
||||
backend::{Backend as ClientBackend, Finalizer},
|
||||
client::BlockchainEvents,
|
||||
@@ -35,6 +34,7 @@ use pezsp_consensus::{Environment, Proposer, SelectChain};
|
||||
use pezsp_core::traits::SpawnNamed;
|
||||
use pezsp_inherents::CreateInherentDataProviders;
|
||||
use pezsp_runtime::{traits::Block as BlockT, ConsensusEngineId};
|
||||
use prometheus_endpoint::Registry;
|
||||
use std::{marker::PhantomData, sync::Arc, time::Duration};
|
||||
|
||||
mod error;
|
||||
@@ -346,16 +346,18 @@ pub async fn run_delayed_finalize<B, CB, C, S>(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use pezsc_basic_authorship::ProposerFactory;
|
||||
use pezsc_consensus::ImportedAux;
|
||||
use pezsc_transaction_pool::{BasicPool, FullChainApi, Options, RevalidationType};
|
||||
use pezsc_transaction_pool_api::{MaintainedTransactionPool, TransactionPool, TransactionSource};
|
||||
use pezsp_inherents::InherentData;
|
||||
use pezsp_runtime::generic::{Digest, DigestItem};
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
DefaultTestClientBuilderExt, Sr25519Keyring::*, TestClientBuilder, TestClientBuilderExt,
|
||||
};
|
||||
use bizinikiwi_test_runtime_transaction_pool::{uxt, TestApi};
|
||||
use pezsc_basic_authorship::ProposerFactory;
|
||||
use pezsc_consensus::ImportedAux;
|
||||
use pezsc_transaction_pool::{BasicPool, FullChainApi, Options, RevalidationType};
|
||||
use pezsc_transaction_pool_api::{
|
||||
MaintainedTransactionPool, TransactionPool, TransactionSource,
|
||||
};
|
||||
use pezsp_inherents::InherentData;
|
||||
use pezsp_runtime::generic::{Digest, DigestItem};
|
||||
|
||||
fn api() -> Arc<TestApi> {
|
||||
Arc::new(TestApi::empty())
|
||||
|
||||
@@ -25,8 +25,8 @@ use futures::{
|
||||
};
|
||||
use jsonrpsee::{core::async_trait, proc_macros::rpc};
|
||||
use pezsc_consensus::ImportedAux;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use pezsp_runtime::EncodedJustification;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Sender passed to the authorship task to report errors or successes.
|
||||
pub type Sender<T> = Option<oneshot::Sender<std::result::Result<T, Error>>>;
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
|
||||
use crate::{rpc, ConsensusDataProvider, CreatedBlock, Error};
|
||||
use futures::prelude::*;
|
||||
use pezsc_consensus::{BlockImport, BlockImportParams, ForkChoiceStrategy, ImportResult, StateAction};
|
||||
use pezsc_consensus::{
|
||||
BlockImport, BlockImportParams, ForkChoiceStrategy, ImportResult, StateAction,
|
||||
};
|
||||
use pezsc_transaction_pool_api::TransactionPool;
|
||||
use pezsp_api::ProvideRuntimeApi;
|
||||
use pezsp_blockchain::HeaderBackend;
|
||||
|
||||
@@ -47,7 +47,6 @@ use crate::worker::UntilImportedOrTimeout;
|
||||
use codec::{Decode, Encode};
|
||||
use futures::{Future, StreamExt};
|
||||
use log::*;
|
||||
use prometheus_endpoint::Registry;
|
||||
use pezsc_client_api::{self, backend::AuxStore, BlockOf, BlockchainEvents};
|
||||
use pezsc_consensus::{
|
||||
BasicQueue, BlockCheckParams, BlockImport, BlockImportParams, BoxBlockImport,
|
||||
@@ -63,6 +62,7 @@ use pezsp_runtime::{
|
||||
generic::{BlockId, Digest, DigestItem},
|
||||
traits::{Block as BlockT, Header as HeaderT},
|
||||
};
|
||||
use prometheus_endpoint::Registry;
|
||||
use std::{cmp::Ordering, marker::PhantomData, sync::Arc, time::Duration};
|
||||
|
||||
const LOG_TARGET: &str = "pow";
|
||||
|
||||
@@ -134,9 +134,9 @@ where
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use bizinikiwi_test_runtime_client;
|
||||
use pezsp_core::{hash::H256, sr25519, Pair};
|
||||
use pezsp_runtime::testing::{Digest as DigestTest, Header as HeaderTest};
|
||||
use bizinikiwi_test_runtime_client;
|
||||
|
||||
use super::{check_equivocation, MAX_SLOT_CAPACITY, PRUNING_BOUND};
|
||||
|
||||
|
||||
@@ -36,7 +36,9 @@ use futures::{future::Either, Future, TryFutureExt};
|
||||
use futures_timer::Delay;
|
||||
use log::{debug, info, warn};
|
||||
use pezsc_consensus::{BlockImport, JustificationSyncLink};
|
||||
use pezsc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_DEBUG, CONSENSUS_INFO, CONSENSUS_WARN};
|
||||
use pezsc_telemetry::{
|
||||
telemetry, TelemetryHandle, CONSENSUS_DEBUG, CONSENSUS_INFO, CONSENSUS_WARN,
|
||||
};
|
||||
use pezsp_arithmetic::traits::BaseArithmetic;
|
||||
use pezsp_consensus::{Proposal, Proposer, SelectChain, SyncOracle};
|
||||
use pezsp_consensus_slots::{Slot, SlotDuration};
|
||||
@@ -469,7 +471,8 @@ impl<T: SimpleSlotWorker<B> + Send + Sync, B: BlockT>
|
||||
|
||||
/// Slot specific extension that the inherent data provider needs to implement.
|
||||
pub trait InherentDataProviderExt {
|
||||
/// The current slot that will be found in the [`InherentData`](`pezsp_inherents::InherentData`).
|
||||
/// The current slot that will be found in the
|
||||
/// [`InherentData`](`pezsp_inherents::InherentData`).
|
||||
fn slot(&self) -> Slot;
|
||||
}
|
||||
|
||||
@@ -809,9 +812,9 @@ impl<N> BackoffAuthoringBlocksStrategy<N> for () {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use bizinikiwi_test_runtime_client::runtime::{Block, Header};
|
||||
use pezsp_runtime::traits::NumberFor;
|
||||
use std::time::{Duration, Instant};
|
||||
use bizinikiwi_test_runtime_client::runtime::{Block, Header};
|
||||
|
||||
const SLOT_DURATION: Duration = Duration::from_millis(6000);
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
|
||||
use rand::{distributions::Uniform, rngs::StdRng, Rng, SeedableRng};
|
||||
use pezsc_client_api::{
|
||||
Backend as _, BlockImportOperation, NewBlockState, StateBackend, TrieCacheContext,
|
||||
};
|
||||
@@ -27,6 +26,7 @@ use pezsp_runtime::{
|
||||
testing::{Block as RawBlock, Header, MockCallU64, TestXt},
|
||||
StateVersion, Storage,
|
||||
};
|
||||
use rand::{distributions::Uniform, rngs::StdRng, Rng, SeedableRng};
|
||||
use tempfile::TempDir;
|
||||
|
||||
pub(crate) type Block = RawBlock<TestXt<MockCallU64, ()>>;
|
||||
|
||||
@@ -615,7 +615,9 @@ impl<Block: BlockT> BlockchainDb<Block> {
|
||||
match Decode::decode(&mut &body[..]) {
|
||||
Ok(body) => return Ok(Some(body)),
|
||||
Err(err) =>
|
||||
return Err(pezsp_blockchain::Error::Backend(format!("Error decoding body: {err}"))),
|
||||
return Err(pezsp_blockchain::Error::Backend(format!(
|
||||
"Error decoding body: {err}"
|
||||
))),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1186,7 +1188,9 @@ impl<Block: BlockT> Backend<Block> {
|
||||
///
|
||||
/// Should only be needed for benchmarking.
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
pub fn expose_db(&self) -> (Arc<dyn pezsp_database::Database<DbHash>>, pezsp_database::ColumnId) {
|
||||
pub fn expose_db(
|
||||
&self,
|
||||
) -> (Arc<dyn pezsp_database::Database<DbHash>>, pezsp_database::ColumnId) {
|
||||
(self.storage.db.clone(), columns::STATE)
|
||||
}
|
||||
|
||||
@@ -1323,7 +1327,8 @@ impl<Block: BlockT> Backend<Block> {
|
||||
|
||||
// Cannot find tree route with empty DB or when imported a detached block.
|
||||
if meta.best_hash != Default::default() && parent_exists {
|
||||
let tree_route = pezsp_blockchain::tree_route(&self.blockchain, meta.best_hash, route_to)?;
|
||||
let tree_route =
|
||||
pezsp_blockchain::tree_route(&self.blockchain, meta.best_hash, route_to)?;
|
||||
|
||||
// uncanonicalize: check safety violations and ensure the numbers no longer
|
||||
// point to these block hashes in the key mapping.
|
||||
@@ -1888,7 +1893,9 @@ impl<Block: BlockT> Backend<Block> {
|
||||
LastCanonicalized::NotCanonicalizing => false,
|
||||
};
|
||||
|
||||
if requires_canonicalization && pezsc_client_api::Backend::have_state_at(self, f_hash, f_num) {
|
||||
if requires_canonicalization &&
|
||||
pezsc_client_api::Backend::have_state_at(self, f_hash, f_num)
|
||||
{
|
||||
let commit = self.storage.state_db.canonicalize_block(&f_hash).map_err(
|
||||
pezsp_blockchain::Error::from_state_db::<
|
||||
pezsc_state_db::Error<pezsp_database::error::DatabaseError>,
|
||||
@@ -2460,7 +2467,9 @@ impl<Block: BlockT> pezsc_client_api::backend::Backend<Block> for Backend<Block>
|
||||
let best_hash = self.blockchain.info().best_hash;
|
||||
|
||||
if best_hash == hash {
|
||||
return Err(pezsp_blockchain::Error::Backend(format!("Can't remove best block {hash:?}")));
|
||||
return Err(pezsp_blockchain::Error::Backend(format!(
|
||||
"Can't remove best block {hash:?}"
|
||||
)));
|
||||
}
|
||||
|
||||
let hdr = self.blockchain.header_metadata(hash)?;
|
||||
@@ -2974,7 +2983,10 @@ pub(crate) mod tests {
|
||||
backend
|
||||
.storage
|
||||
.db
|
||||
.get(columns::STATE, &pezsp_trie::prefixed_key::<BlakeTwo256>(&key, EMPTY_PREFIX))
|
||||
.get(
|
||||
columns::STATE,
|
||||
&pezsp_trie::prefixed_key::<BlakeTwo256>(&key, EMPTY_PREFIX)
|
||||
)
|
||||
.unwrap(),
|
||||
&b"hello"[..]
|
||||
);
|
||||
@@ -3011,7 +3023,10 @@ pub(crate) mod tests {
|
||||
backend
|
||||
.storage
|
||||
.db
|
||||
.get(columns::STATE, &pezsp_trie::prefixed_key::<BlakeTwo256>(&key, EMPTY_PREFIX))
|
||||
.get(
|
||||
columns::STATE,
|
||||
&pezsp_trie::prefixed_key::<BlakeTwo256>(&key, EMPTY_PREFIX)
|
||||
)
|
||||
.unwrap(),
|
||||
&b"hello"[..]
|
||||
);
|
||||
@@ -4261,7 +4276,10 @@ pub(crate) mod tests {
|
||||
};
|
||||
let mut op = backend.begin_operation().unwrap();
|
||||
op.set_block_data(header, None, None, None, NewBlockState::Best).unwrap();
|
||||
assert!(matches!(backend.commit_operation(op), Err(pezsp_blockchain::Error::SetHeadTooOld)));
|
||||
assert!(matches!(
|
||||
backend.commit_operation(op),
|
||||
Err(pezsp_blockchain::Error::SetHeadTooOld)
|
||||
));
|
||||
|
||||
// Insert 2 as best again.
|
||||
let header = backend.blockchain().header(block2).unwrap().unwrap();
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use schnellru::{Limiter, LruMap};
|
||||
use pezsp_runtime::{traits::Block as BlockT, Justifications};
|
||||
use schnellru::{Limiter, LruMap};
|
||||
|
||||
const LOG_TARGET: &str = "db::pin";
|
||||
const PINNING_CACHE_SIZE: usize = 2048;
|
||||
|
||||
@@ -478,7 +478,10 @@ pub fn read_header<Block: BlockT>(
|
||||
pub fn read_meta<Block>(
|
||||
db: &dyn Database<DbHash>,
|
||||
col_header: u32,
|
||||
) -> Result<Meta<<<Block as BlockT>::Header as HeaderT>::Number, Block::Hash>, pezsp_blockchain::Error>
|
||||
) -> Result<
|
||||
Meta<<<Block as BlockT>::Header as HeaderT>::Number, Block::Hash>,
|
||||
pezsp_blockchain::Error,
|
||||
>
|
||||
where
|
||||
Block: BlockT,
|
||||
{
|
||||
@@ -569,8 +572,10 @@ pub fn read_genesis_hash<Hash: Decode>(
|
||||
match db.get(COLUMN_META, meta_keys::GENESIS_HASH) {
|
||||
Some(h) => match Decode::decode(&mut &h[..]) {
|
||||
Ok(h) => Ok(Some(h)),
|
||||
Err(err) =>
|
||||
Err(pezsp_blockchain::Error::Backend(format!("Error decoding genesis hash: {}", err))),
|
||||
Err(err) => Err(pezsp_blockchain::Error::Backend(format!(
|
||||
"Error decoding genesis hash: {}",
|
||||
err
|
||||
))),
|
||||
},
|
||||
None => Ok(None),
|
||||
}
|
||||
|
||||
@@ -88,7 +88,9 @@ fn initialize(
|
||||
>(&path, config)
|
||||
}
|
||||
} else {
|
||||
pezsc_executor_wasmtime::create_runtime::<pezsp_io::BizinikiwiHostFunctions>(blob, config)
|
||||
pezsc_executor_wasmtime::create_runtime::<pezsp_io::BizinikiwiHostFunctions>(
|
||||
blob, config,
|
||||
)
|
||||
}
|
||||
.map(|runtime| -> Box<dyn WasmModule> { Box::new(runtime) })
|
||||
},
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use polkavm::{CallError, Caller, Reg};
|
||||
use pezsc_executor_common::{
|
||||
error::{Error, WasmError},
|
||||
wasm_runtime::{AllocationStats, WasmInstance, WasmModule},
|
||||
@@ -24,6 +23,7 @@ use pezsc_executor_common::{
|
||||
use pezsp_wasm_interface::{
|
||||
Function, FunctionContext, HostFunctions, Pointer, Value, ValueType, WordSize,
|
||||
};
|
||||
use polkavm::{CallError, Caller, Reg};
|
||||
|
||||
#[repr(transparent)]
|
||||
pub struct InstancePre(polkavm::InstancePre<(), String>);
|
||||
@@ -140,7 +140,11 @@ impl<'r, 'a> FunctionContext for Context<'r, 'a> {
|
||||
.map(|_| ())
|
||||
}
|
||||
|
||||
fn write_memory(&mut self, address: Pointer<u8>, data: &[u8]) -> pezsp_wasm_interface::Result<()> {
|
||||
fn write_memory(
|
||||
&mut self,
|
||||
address: Pointer<u8>,
|
||||
data: &[u8],
|
||||
) -> pezsp_wasm_interface::Result<()> {
|
||||
self.0
|
||||
.instance
|
||||
.write_memory(u32::from(address), data)
|
||||
|
||||
@@ -573,8 +573,9 @@ pub struct NativeElseWasmExecutor<D: NativeExecutionDispatch> {
|
||||
/// Native runtime version info.
|
||||
native_version: NativeVersion,
|
||||
/// Fallback wasm executor.
|
||||
wasm:
|
||||
WasmExecutor<ExtendedHostFunctions<pezsp_io::BizinikiwiHostFunctions, D::ExtendHostFunctions>>,
|
||||
wasm: WasmExecutor<
|
||||
ExtendedHostFunctions<pezsp_io::BizinikiwiHostFunctions, D::ExtendHostFunctions>,
|
||||
>,
|
||||
|
||||
use_native: bool,
|
||||
}
|
||||
@@ -745,7 +746,9 @@ impl<D: NativeExecutionDispatch> Clone for NativeElseWasmExecutor<D> {
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
impl<D: NativeExecutionDispatch> pezsp_core::traits::ReadRuntimeVersion for NativeElseWasmExecutor<D> {
|
||||
impl<D: NativeExecutionDispatch> pezsp_core::traits::ReadRuntimeVersion
|
||||
for NativeElseWasmExecutor<D>
|
||||
{
|
||||
fn read_runtime_version(
|
||||
&self,
|
||||
wasm_code: &[u8],
|
||||
|
||||
@@ -29,10 +29,10 @@ use pezsc_executor_common::{
|
||||
runtime_blob::RuntimeBlob,
|
||||
wasm_runtime::{HeapAllocStrategy, WasmInstance, WasmModule},
|
||||
};
|
||||
use schnellru::{ByLength, LruMap};
|
||||
use pezsp_core::traits::{Externalities, FetchRuntimeCode, RuntimeCode};
|
||||
use pezsp_version::RuntimeVersion;
|
||||
use pezsp_wasm_interface::HostFunctions;
|
||||
use schnellru::{ByLength, LruMap};
|
||||
|
||||
use std::{
|
||||
panic::AssertUnwindSafe,
|
||||
@@ -53,7 +53,8 @@ pub enum WasmExecutionMethod {
|
||||
impl Default for WasmExecutionMethod {
|
||||
fn default() -> Self {
|
||||
Self::Compiled {
|
||||
instantiation_strategy: pezsc_executor_wasmtime::InstantiationStrategy::PoolingCopyOnWrite,
|
||||
instantiation_strategy:
|
||||
pezsc_executor_wasmtime::InstantiationStrategy::PoolingCopyOnWrite,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -445,11 +446,11 @@ mod tests {
|
||||
|
||||
use super::*;
|
||||
use alloc::borrow::Cow;
|
||||
use bizinikiwi_test_runtime::Block;
|
||||
use codec::Encode;
|
||||
use pezsp_api::{Core, RuntimeApiInfo};
|
||||
use pezsp_version::{create_apis_vec, RuntimeVersion};
|
||||
use pezsp_wasm_interface::HostFunctions;
|
||||
use bizinikiwi_test_runtime::Block;
|
||||
|
||||
#[derive(Encode)]
|
||||
pub struct OldRuntimeVersion {
|
||||
|
||||
@@ -82,7 +82,11 @@ impl<'a> pezsp_wasm_interface::FunctionContext for HostContext<'a> {
|
||||
util::read_memory_into(&self.caller, address, dest).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
fn write_memory(&mut self, address: Pointer<u8>, data: &[u8]) -> pezsp_wasm_interface::Result<()> {
|
||||
fn write_memory(
|
||||
&mut self,
|
||||
address: Pointer<u8>,
|
||||
data: &[u8],
|
||||
) -> pezsp_wasm_interface::Result<()> {
|
||||
util::write_memory_from(&mut self.caller, address, data).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
|
||||
@@ -37,12 +37,12 @@ mod util;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
pub use pezsc_executor_common::{
|
||||
runtime_blob::RuntimeBlob,
|
||||
wasm_runtime::{HeapAllocStrategy, WasmModule},
|
||||
};
|
||||
pub use runtime::{
|
||||
create_runtime, create_runtime_from_artifact, create_runtime_from_artifact_bytes,
|
||||
prepare_runtime_artifact, Config, DeterministicStackLimit, InstantiationStrategy, Semantics,
|
||||
WasmtimeRuntime,
|
||||
};
|
||||
pub use pezsc_executor_common::{
|
||||
runtime_blob::RuntimeBlob,
|
||||
wasm_runtime::{HeapAllocStrategy, WasmModule},
|
||||
};
|
||||
|
||||
@@ -101,11 +101,13 @@ where
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests {
|
||||
use super::*;
|
||||
use crate::test_utils::{run_test_with_pezmmr_gadget_pre_post_using_client, MmrBlock, MockClient};
|
||||
use crate::test_utils::{
|
||||
run_test_with_pezmmr_gadget_pre_post_using_client, MmrBlock, MockClient,
|
||||
};
|
||||
use bizinikiwi_test_runtime_client::{runtime::Block, Backend};
|
||||
use parking_lot::Mutex;
|
||||
use pezsp_runtime::generic::BlockId;
|
||||
use std::{sync::Arc, time::Duration};
|
||||
use bizinikiwi_test_runtime_client::{runtime::Block, Backend};
|
||||
|
||||
#[test]
|
||||
fn should_load_persistent_sanity_checks() {
|
||||
|
||||
@@ -19,6 +19,11 @@
|
||||
//! Test utilities.
|
||||
|
||||
use crate::MmrGadget;
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
runtime::{Block, BlockNumber, Hash, Header},
|
||||
Backend, BlockBuilderExt, Client, ClientBlockImportExt, ClientExt, DefaultTestClientBuilderExt,
|
||||
TestClientBuilder, TestClientBuilderExt,
|
||||
};
|
||||
use parking_lot::Mutex;
|
||||
use pezsc_block_builder::BlockBuilderBuilder;
|
||||
use pezsc_client_api::{
|
||||
@@ -40,11 +45,6 @@ use pezsp_runtime::{
|
||||
traits::{Block as BlockT, Header as HeaderT},
|
||||
};
|
||||
use std::{future::Future, sync::Arc, time::Duration};
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
runtime::{Block, BlockNumber, Hash, Header},
|
||||
Backend, BlockBuilderExt, Client, ClientBlockImportExt, ClientExt, DefaultTestClientBuilderExt,
|
||||
TestClientBuilder, TestClientBuilderExt,
|
||||
};
|
||||
use tokio::runtime::Runtime;
|
||||
|
||||
type MmrHash = H256;
|
||||
|
||||
@@ -36,7 +36,7 @@ mod sync_with_runtime;
|
||||
|
||||
pub use self::{
|
||||
api::{Api, ApiBackend},
|
||||
config::{Config, CoreConfig, BizinikiwiConfig},
|
||||
config::{BizinikiwiConfig, Config, CoreConfig},
|
||||
error::{Error, RemoteErr},
|
||||
protocol::{peers_set_config, protocol_name},
|
||||
run::run,
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
use super::{
|
||||
api::ApiBackend,
|
||||
config::{Config, BizinikiwiConfig},
|
||||
config::{BizinikiwiConfig, Config},
|
||||
error::RemoteErr,
|
||||
extrinsic_queue::ExtrinsicQueue,
|
||||
maybe_inf_delay::MaybeInfDelay,
|
||||
|
||||
@@ -33,9 +33,9 @@ use futures::{
|
||||
prelude::*,
|
||||
};
|
||||
use log::trace;
|
||||
use prometheus_endpoint::Registry;
|
||||
use pezsc_network_types::PeerId;
|
||||
use pezsp_runtime::traits::Block as BlockT;
|
||||
use prometheus_endpoint::Registry;
|
||||
use std::{
|
||||
collections::{HashMap, VecDeque},
|
||||
pin::Pin,
|
||||
@@ -347,13 +347,13 @@ impl<B: BlockT> futures::future::FusedFuture for GossipEngine<B> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{ValidationResult, ValidatorContext};
|
||||
use bizinikiwi_test_runtime_client::runtime::Block;
|
||||
use codec::{DecodeAll, Encode};
|
||||
use futures::{
|
||||
channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender},
|
||||
executor::{block_on, block_on_stream},
|
||||
future::poll_fn,
|
||||
};
|
||||
use quickcheck::{Arbitrary, Gen, QuickCheck};
|
||||
use pezsc_network::{
|
||||
config::MultiaddrWithPeerId,
|
||||
service::traits::{Direction, MessageSink, NotificationEvent},
|
||||
@@ -366,11 +366,11 @@ mod tests {
|
||||
testing::H256,
|
||||
traits::{Block as BlockT, NumberFor},
|
||||
};
|
||||
use quickcheck::{Arbitrary, Gen, QuickCheck};
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
use bizinikiwi_test_runtime_client::runtime::Block;
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
struct TestNetwork {}
|
||||
|
||||
@@ -22,10 +22,10 @@ use ahash::AHashSet;
|
||||
use pezsc_network_types::PeerId;
|
||||
use schnellru::{ByLength, LruMap};
|
||||
|
||||
use prometheus_endpoint::{register, Counter, PrometheusError, Registry, U64};
|
||||
use pezsc_network::{types::ProtocolName, NotificationService};
|
||||
use pezsc_network_common::role::ObservedRole;
|
||||
use pezsp_runtime::traits::{Block as BlockT, Hash, HashingFor};
|
||||
use prometheus_endpoint::{register, Counter, PrometheusError, Registry, U64};
|
||||
use std::{collections::HashMap, iter, sync::Arc, time, time::Instant};
|
||||
|
||||
// FIXME: Add additional spam/DoS attack protection: https://github.com/pezkuwichain/kurdistan-sdk/issues/7
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use bizinikiwi_test_runtime_client::runtime;
|
||||
use criterion::{
|
||||
criterion_group, criterion_main, AxisScale, BenchmarkId, Criterion, PlotConfiguration,
|
||||
Throughput,
|
||||
@@ -33,7 +34,6 @@ use pezsc_network_common::{sync::message::BlockAnnouncesHandshake, ExHashT};
|
||||
use pezsp_core::H256;
|
||||
use pezsp_runtime::traits::{Block as BlockT, Zero};
|
||||
use std::{sync::Arc, time::Duration};
|
||||
use bizinikiwi_test_runtime_client::runtime;
|
||||
use tokio::{sync::Mutex, task::JoinHandle};
|
||||
|
||||
const NUMBER_OF_NOTIFICATIONS: usize = 100;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use bizinikiwi_test_runtime_client::runtime;
|
||||
use criterion::{
|
||||
criterion_group, criterion_main, AxisScale, BenchmarkId, Criterion, PlotConfiguration,
|
||||
Throughput,
|
||||
@@ -33,7 +34,6 @@ use pezsc_network_common::{sync::message::BlockAnnouncesHandshake, ExHashT};
|
||||
use pezsp_core::H256;
|
||||
use pezsp_runtime::traits::{Block as BlockT, Zero};
|
||||
use std::{sync::Arc, time::Duration};
|
||||
use bizinikiwi_test_runtime_client::runtime;
|
||||
use tokio::{sync::Mutex, task::JoinHandle};
|
||||
|
||||
const MAX_SIZE: u64 = 2u64.pow(30);
|
||||
|
||||
@@ -26,7 +26,6 @@ use crate::schema;
|
||||
use codec::{self, Decode, Encode};
|
||||
use futures::prelude::*;
|
||||
use log::{debug, trace};
|
||||
use prost::Message;
|
||||
use pezsc_client_api::{BlockBackend, ProofProvider};
|
||||
use pezsc_network::{
|
||||
config::ProtocolId,
|
||||
@@ -39,6 +38,7 @@ use pezsp_core::{
|
||||
storage::{ChildInfo, ChildType, PrefixedStorageKey},
|
||||
};
|
||||
use pezsp_runtime::traits::Block;
|
||||
use prost::Message;
|
||||
use std::{marker::PhantomData, sync::Arc};
|
||||
|
||||
const LOG_TARGET: &str = "light-client-request-handler";
|
||||
|
||||
@@ -30,14 +30,14 @@ use crate::{
|
||||
use cid::{self, Version};
|
||||
use futures::StreamExt;
|
||||
use log::{debug, error, trace};
|
||||
use prost::Message;
|
||||
use pezsc_client_api::BlockBackend;
|
||||
use pezsc_network_types::PeerId;
|
||||
use pezsp_runtime::traits::Block as BlockT;
|
||||
use prost::Message;
|
||||
use schema::bitswap::{
|
||||
message::{wantlist::WantType, Block as MessageBlock, BlockPresence, BlockPresenceType},
|
||||
Message as BitswapMessage,
|
||||
};
|
||||
use pezsp_runtime::traits::Block as BlockT;
|
||||
use std::{io, sync::Arc, time::Duration};
|
||||
use unsigned_varint::encode as varint_encode;
|
||||
|
||||
@@ -292,16 +292,16 @@ pub enum BitswapError {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use bizinikiwi_test_runtime::ExtrinsicBuilder;
|
||||
use bizinikiwi_test_runtime_client::{self, prelude::*, TestClientBuilder};
|
||||
use futures::channel::oneshot;
|
||||
use pezsc_block_builder::BlockBuilderBuilder;
|
||||
use pezsp_consensus::BlockOrigin;
|
||||
use pezsp_runtime::codec::Encode;
|
||||
use schema::bitswap::{
|
||||
message::{wantlist::Entry, Wantlist},
|
||||
Message as BitswapMessage,
|
||||
};
|
||||
use pezsp_consensus::BlockOrigin;
|
||||
use pezsp_runtime::codec::Encode;
|
||||
use bizinikiwi_test_runtime::ExtrinsicBuilder;
|
||||
use bizinikiwi_test_runtime_client::{self, prelude::*, TestClientBuilder};
|
||||
|
||||
#[tokio::test]
|
||||
async fn undecodable_message() {
|
||||
@@ -503,7 +503,9 @@ mod tests {
|
||||
0x70,
|
||||
cid::multihash::Multihash::wrap(
|
||||
u64::from(cid::multihash::Code::Blake2b256),
|
||||
&pezsp_crypto_hashing::blake2_256(&ext.encode()[pattern_index..]),
|
||||
&pezsp_crypto_hashing::blake2_256(
|
||||
&ext.encode()[pattern_index..],
|
||||
),
|
||||
)
|
||||
.unwrap(),
|
||||
)
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
//! The `DiscoveryBehaviour` struct implements the `NetworkBehaviour` trait of libp2p and is
|
||||
//! responsible for discovering other nodes that are part of the network.
|
||||
//!
|
||||
//! Bizinikiwi uses the following mechanisms in order to discover nodes that are part of the network:
|
||||
//! Bizinikiwi uses the following mechanisms in order to discover nodes that are part of the
|
||||
//! network:
|
||||
//!
|
||||
//! - Bootstrap nodes. These are hard-coded node identities and addresses passed in the constructor
|
||||
//! of the `DiscoveryBehaviour`. You can also call `add_known_address` later to add an entry.
|
||||
|
||||
@@ -265,8 +265,6 @@ pub mod utils;
|
||||
|
||||
pub use crate::litep2p::Litep2pNetworkBackend;
|
||||
pub use event::{DhtEvent, Event};
|
||||
#[doc(inline)]
|
||||
pub use request_responses::{Config, IfDisconnected, RequestFailure};
|
||||
pub use pezsc_network_common::{
|
||||
role::{ObservedRole, Roles},
|
||||
types::ReputationChange,
|
||||
@@ -275,6 +273,8 @@ pub use pezsc_network_types::{
|
||||
multiaddr::{self, Multiaddr},
|
||||
PeerId,
|
||||
};
|
||||
#[doc(inline)]
|
||||
pub use request_responses::{Config, IfDisconnected, RequestFailure};
|
||||
pub use service::{
|
||||
metrics::NotificationMetrics,
|
||||
signature::Signature,
|
||||
|
||||
@@ -71,8 +71,8 @@ use litep2p::{
|
||||
},
|
||||
Litep2p, Litep2pEvent, ProtocolName as Litep2pProtocolName,
|
||||
};
|
||||
use prometheus_endpoint::Registry;
|
||||
use pezsc_network_types::kad::{Key as RecordKey, PeerRecord, Record as P2PRecord};
|
||||
use prometheus_endpoint::Registry;
|
||||
|
||||
use pezsc_client_api::BlockBackend;
|
||||
use pezsc_network_common::{role::Roles, ExHashT};
|
||||
|
||||
@@ -466,11 +466,17 @@ mod tests {
|
||||
// Report 2 peers with a negative reputation.
|
||||
handle.report_peer(
|
||||
peer_a,
|
||||
pezsc_network_common::types::ReputationChange { value: i32::MIN, reason: "test".into() },
|
||||
pezsc_network_common::types::ReputationChange {
|
||||
value: i32::MIN,
|
||||
reason: "test".into(),
|
||||
},
|
||||
);
|
||||
handle.report_peer(
|
||||
peer_b,
|
||||
pezsc_network_common::types::ReputationChange { value: i32::MIN, reason: "test".into() },
|
||||
pezsc_network_common::types::ReputationChange {
|
||||
value: i32::MIN,
|
||||
reason: "test".into(),
|
||||
},
|
||||
);
|
||||
|
||||
// Advance time to propagate peers.
|
||||
|
||||
@@ -25,8 +25,8 @@ use libp2p::PeerId;
|
||||
use log::trace;
|
||||
use parking_lot::Mutex;
|
||||
use partial_sort::PartialSort;
|
||||
use prometheus_endpoint::Registry;
|
||||
use pezsc_network_common::{role::ObservedRole, types::ReputationChange};
|
||||
use prometheus_endpoint::Registry;
|
||||
use std::{
|
||||
cmp::{Ord, Ordering, PartialOrd},
|
||||
collections::{hash_map::Entry, HashMap, HashSet},
|
||||
@@ -558,11 +558,17 @@ mod tests {
|
||||
// Report 2 peers with a negative reputation.
|
||||
handle.report_peer(
|
||||
peer_a,
|
||||
pezsc_network_common::types::ReputationChange { value: i32::MIN, reason: "test".into() },
|
||||
pezsc_network_common::types::ReputationChange {
|
||||
value: i32::MIN,
|
||||
reason: "test".into(),
|
||||
},
|
||||
);
|
||||
handle.report_peer(
|
||||
peer_b,
|
||||
pezsc_network_common::types::ReputationChange { value: i32::MIN, reason: "test".into() },
|
||||
pezsc_network_common::types::ReputationChange {
|
||||
value: i32::MIN,
|
||||
reason: "test".into(),
|
||||
},
|
||||
);
|
||||
|
||||
// Advance time to propagate banned peers.
|
||||
|
||||
@@ -45,8 +45,8 @@ use libp2p::{
|
||||
};
|
||||
use log::{debug, error, trace, warn};
|
||||
use parking_lot::RwLock;
|
||||
use rand::distributions::{Distribution as _, Uniform};
|
||||
use pezsc_utils::mpsc::TracingUnboundedReceiver;
|
||||
use rand::distributions::{Distribution as _, Uniform};
|
||||
use smallvec::SmallVec;
|
||||
use tokio::sync::oneshot::error::RecvError;
|
||||
use tokio_stream::StreamMap;
|
||||
|
||||
@@ -232,7 +232,11 @@ impl NotificationService for NotificationHandle {
|
||||
}
|
||||
|
||||
/// Send synchronous `notification` to `peer`.
|
||||
fn send_sync_notification(&mut self, peer: &pezsc_network_types::PeerId, notification: Vec<u8>) {
|
||||
fn send_sync_notification(
|
||||
&mut self,
|
||||
peer: &pezsc_network_types::PeerId,
|
||||
notification: Vec<u8>,
|
||||
) {
|
||||
if let Some(info) = self.peers.get(&((*peer).into())) {
|
||||
metrics::register_notification_sent(
|
||||
info.sink.metrics(),
|
||||
|
||||
@@ -813,7 +813,11 @@ impl ProtocolController {
|
||||
.map(From::from)
|
||||
.collect::<HashSet<pezsc_network_types::PeerId>>()
|
||||
.union(
|
||||
&self.nodes.keys().map(From::from).collect::<HashSet<pezsc_network_types::PeerId>>(),
|
||||
&self
|
||||
.nodes
|
||||
.keys()
|
||||
.map(From::from)
|
||||
.collect::<HashSet<pezsc_network_types::PeerId>>(),
|
||||
)
|
||||
.cloned()
|
||||
.collect();
|
||||
|
||||
@@ -75,8 +75,8 @@ use libp2p::{
|
||||
use log::{debug, error, info, trace, warn};
|
||||
use metrics::{Histogram, MetricSources, Metrics};
|
||||
use parking_lot::Mutex;
|
||||
use prometheus_endpoint::Registry;
|
||||
use pezsc_network_types::kad::{Key as KademliaKey, Record};
|
||||
use prometheus_endpoint::Registry;
|
||||
|
||||
use pezsc_client_api::BlockBackend;
|
||||
use pezsc_network_common::{
|
||||
|
||||
@@ -30,9 +30,6 @@ use crate::config::*;
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use futures::{channel::oneshot, prelude::*, stream::FuturesUnordered, FutureExt};
|
||||
use prometheus_endpoint::{
|
||||
prometheus, register, Counter, Gauge, Histogram, HistogramOpts, PrometheusError, Registry, U64,
|
||||
};
|
||||
use pezsc_network::{
|
||||
config::{NonReservedPeerMode, SetConfig},
|
||||
error, multiaddr,
|
||||
@@ -52,6 +49,9 @@ use pezsp_runtime::traits::Block as BlockT;
|
||||
use pezsp_statement_store::{
|
||||
Hash, NetworkPriority, Statement, StatementSource, StatementStore, SubmitResult,
|
||||
};
|
||||
use prometheus_endpoint::{
|
||||
prometheus, register, Counter, Gauge, Histogram, HistogramOpts, PrometheusError, Registry, U64,
|
||||
};
|
||||
use std::{
|
||||
collections::{hash_map::Entry, HashMap, HashSet},
|
||||
iter,
|
||||
@@ -797,7 +797,9 @@ mod tests {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
async fn next_event(&mut self) -> Option<pezsc_network::service::traits::NotificationEvent> {
|
||||
async fn next_event(
|
||||
&mut self,
|
||||
) -> Option<pezsc_network::service::traits::NotificationEvent> {
|
||||
None
|
||||
}
|
||||
|
||||
@@ -819,7 +821,8 @@ mod tests {
|
||||
|
||||
#[derive(Clone)]
|
||||
struct TestStatementStore {
|
||||
statements: Arc<Mutex<HashMap<pezsp_statement_store::Hash, pezsp_statement_store::Statement>>>,
|
||||
statements:
|
||||
Arc<Mutex<HashMap<pezsp_statement_store::Hash, pezsp_statement_store::Statement>>>,
|
||||
recent_statements:
|
||||
Arc<Mutex<HashMap<pezsp_statement_store::Hash, pezsp_statement_store::Statement>>>,
|
||||
}
|
||||
|
||||
@@ -309,9 +309,9 @@ impl<B: BlockT> FusedStream for BlockAnnounceValidator<B> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::block_announce_validator::AllocateSlotForBlockAnnounceValidation;
|
||||
use bizinikiwi_test_runtime_client::runtime::Block;
|
||||
use pezsc_network_types::PeerId;
|
||||
use pezsp_consensus::block_validation::DefaultBlockAnnounceValidator;
|
||||
use bizinikiwi_test_runtime_client::runtime::Block;
|
||||
|
||||
#[test]
|
||||
fn allocate_one_validation_slot() {
|
||||
|
||||
@@ -24,14 +24,14 @@ use crate::{
|
||||
strategy::chain_sync::{PeerSync, PeerSyncState},
|
||||
LOG_TARGET,
|
||||
};
|
||||
use pez_fork_tree::ForkTree;
|
||||
use log::{debug, trace, warn};
|
||||
use prometheus_endpoint::{
|
||||
prometheus::core::GenericGauge, register, GaugeVec, Opts, PrometheusError, Registry, U64,
|
||||
};
|
||||
use pez_fork_tree::ForkTree;
|
||||
use pezsc_network_types::PeerId;
|
||||
use pezsp_blockchain::Error as ClientError;
|
||||
use pezsp_runtime::traits::{Block as BlockT, NumberFor, Zero};
|
||||
use prometheus_endpoint::{
|
||||
prometheus::core::GenericGauge, register, GaugeVec, Opts, PrometheusError, Registry, U64,
|
||||
};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet, VecDeque},
|
||||
time::{Duration, Instant},
|
||||
@@ -441,9 +441,9 @@ impl<'a, B: BlockT> Matcher<'a, B> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::strategy::chain_sync::PeerSync;
|
||||
use quickcheck::{Arbitrary, Gen, QuickCheck};
|
||||
use pezsp_blockchain::Error as ClientError;
|
||||
use pezsp_test_primitives::{Block, BlockNumber, Hash};
|
||||
use quickcheck::{Arbitrary, Gen, QuickCheck};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -26,8 +26,8 @@ use crate::{
|
||||
use codec::{Decode, Encode};
|
||||
use futures::{channel::oneshot, stream::StreamExt};
|
||||
use log::{debug, trace};
|
||||
use prost::Message;
|
||||
use pezsc_network_types::PeerId;
|
||||
use prost::Message;
|
||||
use schnellru::{ByLength, LruMap};
|
||||
|
||||
use pezsc_client_api::{BlockBackend, ProofProvider};
|
||||
|
||||
@@ -46,8 +46,6 @@ use crate::{
|
||||
|
||||
use futures::{channel::oneshot, FutureExt};
|
||||
use log::{debug, error, info, trace, warn};
|
||||
use prometheus_endpoint::{register, Gauge, PrometheusError, Registry, U64};
|
||||
use prost::Message;
|
||||
use pezsc_client_api::{blockchain::BlockGap, BlockBackend, ProofProvider};
|
||||
use pezsc_consensus::{BlockImportError, BlockImportStatus, IncomingBlock};
|
||||
use pezsc_network::{IfDisconnected, ProtocolName};
|
||||
@@ -64,6 +62,8 @@ use pezsp_runtime::{
|
||||
},
|
||||
EncodedJustification, Justifications,
|
||||
};
|
||||
use prometheus_endpoint::{register, Gauge, PrometheusError, Registry, U64};
|
||||
use prost::Message;
|
||||
|
||||
use std::{
|
||||
any::Any,
|
||||
@@ -142,8 +142,10 @@ impl Metrics {
|
||||
fn register(r: &Registry) -> Result<Self, PrometheusError> {
|
||||
Ok(Self {
|
||||
queued_blocks: {
|
||||
let g =
|
||||
Gauge::new("bizinikiwi_sync_queued_blocks", "Number of blocks in import queue")?;
|
||||
let g = Gauge::new(
|
||||
"bizinikiwi_sync_queued_blocks",
|
||||
"Number of blocks in import queue",
|
||||
)?;
|
||||
register(g, r)?
|
||||
},
|
||||
fork_targets: {
|
||||
|
||||
@@ -23,17 +23,17 @@ use crate::{
|
||||
block_relay_protocol::BlockResponseError, mock::MockBlockDownloader,
|
||||
service::network::NetworkServiceProvider,
|
||||
};
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
runtime::{Block, Hash, Header},
|
||||
BlockBuilderExt, ClientBlockImportExt, ClientExt, DefaultTestClientBuilderExt, TestClient,
|
||||
TestClientBuilder, TestClientBuilderExt,
|
||||
};
|
||||
use futures::{channel::oneshot::Canceled, executor::block_on};
|
||||
use pezsc_block_builder::BlockBuilderBuilder;
|
||||
use pezsc_network::RequestFailure;
|
||||
use pezsc_network_common::sync::message::{BlockAnnounce, BlockData, BlockState, FromBlock};
|
||||
use pezsp_blockchain::HeaderBackend;
|
||||
use std::sync::Mutex;
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
runtime::{Block, Hash, Header},
|
||||
BlockBuilderExt, ClientBlockImportExt, ClientExt, DefaultTestClientBuilderExt, TestClient,
|
||||
TestClientBuilder, TestClientBuilderExt,
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
struct ProxyBlockDownloader {
|
||||
|
||||
@@ -33,7 +33,6 @@ use crate::{
|
||||
LOG_TARGET,
|
||||
};
|
||||
use log::{debug, error, info, warn};
|
||||
use prometheus_endpoint::Registry;
|
||||
use pezsc_client_api::{BlockBackend, ProofProvider};
|
||||
use pezsc_consensus::{BlockImportError, BlockImportStatus};
|
||||
use pezsc_network::ProtocolName;
|
||||
@@ -41,6 +40,7 @@ use pezsc_network_common::sync::{message::BlockAnnounce, SyncMode};
|
||||
use pezsc_network_types::PeerId;
|
||||
use pezsp_blockchain::{Error as ClientError, HeaderBackend, HeaderMetadata};
|
||||
use pezsp_runtime::traits::{Block as BlockT, Header, NumberFor};
|
||||
use prometheus_endpoint::Registry;
|
||||
use std::{any::Any, collections::HashMap, sync::Arc};
|
||||
|
||||
/// Corresponding `ChainSync` mode.
|
||||
|
||||
@@ -31,7 +31,6 @@ use crate::{
|
||||
};
|
||||
use futures::{channel::oneshot, FutureExt};
|
||||
use log::{debug, error, trace};
|
||||
use prost::Message;
|
||||
use pezsc_client_api::ProofProvider;
|
||||
use pezsc_consensus::{BlockImportError, BlockImportStatus, IncomingBlock};
|
||||
use pezsc_network::{IfDisconnected, ProtocolName};
|
||||
@@ -42,6 +41,7 @@ use pezsp_runtime::{
|
||||
traits::{Block as BlockT, Header, NumberFor},
|
||||
Justifications, SaturatedConversion,
|
||||
};
|
||||
use prost::Message;
|
||||
use std::{any::Any, collections::HashMap, sync::Arc};
|
||||
|
||||
mod rep {
|
||||
@@ -398,16 +398,16 @@ mod test {
|
||||
service::network::NetworkServiceProvider,
|
||||
strategy::state_sync::{ImportResult, StateSyncProgress, StateSyncProvider},
|
||||
};
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
runtime::{Block, Hash},
|
||||
BlockBuilderExt, DefaultTestClientBuilderExt, TestClientBuilder, TestClientBuilderExt,
|
||||
};
|
||||
use codec::Decode;
|
||||
use pezsc_block_builder::BlockBuilderBuilder;
|
||||
use pezsc_client_api::KeyValueStates;
|
||||
use pezsc_consensus::{ImportedAux, ImportedState};
|
||||
use pezsp_core::H256;
|
||||
use pezsp_runtime::traits::Zero;
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
runtime::{Block, Hash},
|
||||
BlockBuilderExt, DefaultTestClientBuilderExt, TestClientBuilder, TestClientBuilderExt,
|
||||
};
|
||||
|
||||
mockall::mock! {
|
||||
pub StateSync<B: BlockT> {}
|
||||
|
||||
@@ -26,12 +26,12 @@ use codec::{Decode, Encode};
|
||||
use log::debug;
|
||||
use pezsc_client_api::{CompactProof, KeyValueStates, ProofProvider};
|
||||
use pezsc_consensus::ImportedState;
|
||||
use smallvec::SmallVec;
|
||||
use pezsp_core::storage::well_known_keys;
|
||||
use pezsp_runtime::{
|
||||
traits::{Block as BlockT, Header, NumberFor},
|
||||
Justifications,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use std::{collections::HashMap, fmt, sync::Arc};
|
||||
|
||||
/// Generic state sync provider. Used for mocking in tests.
|
||||
|
||||
@@ -772,16 +772,16 @@ where
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::{mock::MockBlockDownloader, service::network::NetworkServiceProvider};
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
runtime::{Block, Hash},
|
||||
BlockBuilderExt, DefaultTestClientBuilderExt, TestClientBuilder, TestClientBuilderExt,
|
||||
};
|
||||
use pezsc_block_builder::BlockBuilderBuilder;
|
||||
use pezsp_blockchain::{BlockStatus, Error as BlockchainError, HeaderBackend, Info};
|
||||
use pezsp_consensus_grandpa::{AuthorityList, SetId, GRANDPA_ENGINE_ID};
|
||||
use pezsp_core::H256;
|
||||
use pezsp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor};
|
||||
use std::{io::ErrorKind, sync::Arc};
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
runtime::{Block, Hash},
|
||||
BlockBuilderExt, DefaultTestClientBuilderExt, TestClientBuilder, TestClientBuilderExt,
|
||||
};
|
||||
|
||||
mockall::mock! {
|
||||
pub Client<B: BlockT> {}
|
||||
|
||||
@@ -19,17 +19,17 @@
|
||||
//! Testing block import logic.
|
||||
|
||||
use super::*;
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
self,
|
||||
prelude::*,
|
||||
runtime::{Block, Hash},
|
||||
};
|
||||
use futures::executor::block_on;
|
||||
use pezsc_consensus::{
|
||||
import_single_block, BasicQueue, BlockImportError, BlockImportStatus, ImportedAux,
|
||||
IncomingBlock,
|
||||
};
|
||||
use pezsp_consensus::BlockOrigin;
|
||||
use bizinikiwi_test_runtime_client::{
|
||||
self,
|
||||
prelude::*,
|
||||
runtime::{Block, Hash},
|
||||
};
|
||||
|
||||
fn prepare_good_block() -> (TestClient, Hash, u64, PeerId, IncomingBlock<Block>) {
|
||||
let client = bizinikiwi_test_runtime_client::new();
|
||||
|
||||
@@ -27,10 +27,10 @@ use pezsc_network::{
|
||||
Roles,
|
||||
};
|
||||
|
||||
use bizinikiwi_test_runtime_client::runtime;
|
||||
use pezsc_network_common::sync::message::BlockAnnouncesHandshake;
|
||||
use pezsp_runtime::traits::Zero;
|
||||
use std::{sync::Arc, time::Duration};
|
||||
use bizinikiwi_test_runtime_client::runtime;
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
/// High level network backend (litep2p or libp2p) test client.
|
||||
|
||||
@@ -21,16 +21,16 @@
|
||||
|
||||
use futures::prelude::*;
|
||||
use libp2p::PeerId;
|
||||
use rand::{
|
||||
distributions::{Distribution, Uniform, WeightedIndex},
|
||||
seq::IteratorRandom,
|
||||
};
|
||||
use pezsc_network::{
|
||||
peer_store::{PeerStore, PeerStoreProvider},
|
||||
protocol_controller::{IncomingIndex, Message, ProtoSetConfig, ProtocolController, SetId},
|
||||
ReputationChange,
|
||||
};
|
||||
use pezsc_utils::mpsc::tracing_unbounded;
|
||||
use rand::{
|
||||
distributions::{Distribution, Uniform, WeightedIndex},
|
||||
seq::IteratorRandom,
|
||||
};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
sync::Arc,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user