Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 19 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ members = [
"frame/lottery",
"frame/membership",
"frame/merkle-mountain-range",
"frame/merkle-mountain-range/primitives",
"frame/merkle-mountain-range/rpc",
"frame/multisig",
"frame/nicks",
Expand Down Expand Up @@ -172,6 +171,7 @@ members = [
"primitives/keyring",
"primitives/keystore",
"primitives/maybe-compressed-blob",
"primitives/merkle-mountain-range",
"primitives/npos-elections",
"primitives/npos-elections/fuzzer",
"primitives/offchain",
Expand Down
6 changes: 5 additions & 1 deletion bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ impl pallet_mmr::Config for Runtime {
const INDEXING_PREFIX: &'static [u8] = b"mmr";
type Hashing = <Runtime as frame_system::Config>::Hashing;
type Hash = <Runtime as frame_system::Config>::Hash;
type LeafData = frame_system::Pallet<Self>;
type LeafData = pallet_mmr::ParentNumberAndHash<Self>;
type OnNewRoot = ();
type WeightInfo = ();
}
Expand Down Expand Up @@ -1804,6 +1804,10 @@ impl_runtime_apis! {
let node = mmr::DataOrHash::Data(leaf.into_opaque_leaf());
pallet_mmr::verify_leaf_proof::<mmr::Hashing, _>(root, node, proof)
}

fn mmr_root() -> Result<mmr::Hash, mmr::Error> {
Ok(Mmr::mmr_root())
}
}

impl sp_session::SessionKeys<Block> for Runtime {
Expand Down
1 change: 1 addition & 0 deletions client/beefy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ sp-blockchain = { version = "4.0.0-dev", path = "../../primitives/blockchain" }
sp-consensus = { version = "0.10.0-dev", path = "../../primitives/consensus/common" }
sp-core = { version = "6.0.0", path = "../../primitives/core" }
sp-keystore = { version = "0.12.0", path = "../../primitives/keystore" }
sp-mmr-primitives = { version = "4.0.0-dev", path = "../../primitives/merkle-mountain-range" }
sp-runtime = { version = "6.0.0", path = "../../primitives/runtime" }

sc-chain-spec = { version = "4.0.0-dev", path = "../../client/chain-spec" }
Expand Down
22 changes: 14 additions & 8 deletions client/beefy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_consensus::SyncOracle;
use sp_keystore::SyncCryptoStorePtr;
use sp_mmr_primitives::MmrApi;
use sp_runtime::traits::Block;

use beefy_primitives::BeefyApi;
use beefy_primitives::{BeefyApi, MmrRootHash};

use crate::notification::{BeefyBestBlockSender, BeefySignedCommitmentSender};

Expand Down Expand Up @@ -87,7 +88,7 @@ pub fn beefy_peers_set_config(
/// of today, Rust does not allow a type alias to be used as a trait bound. Tracking
/// issue is <https://github.com/rust-lang/rust/issues/41517>.
pub trait Client<B, BE>:
BlockchainEvents<B> + HeaderBackend<B> + Finalizer<B, BE> + ProvideRuntimeApi<B> + Send + Sync
BlockchainEvents<B> + HeaderBackend<B> + Finalizer<B, BE> + Send + Sync
where
B: Block,
BE: Backend<B>,
Expand All @@ -110,18 +111,21 @@ where
}

/// BEEFY gadget initialization parameters.
pub struct BeefyParams<B, BE, C, N>
pub struct BeefyParams<B, BE, C, N, R>
where
B: Block,
BE: Backend<B>,
C: Client<B, BE>,
C::Api: BeefyApi<B>,
R: ProvideRuntimeApi<B>,
R::Api: BeefyApi<B> + MmrApi<B, MmrRootHash>,
N: GossipNetwork<B> + Clone + SyncOracle + Send + Sync + 'static,
{
/// BEEFY client
pub client: Arc<C>,
/// Client Backend
pub backend: Arc<BE>,
/// Runtime Api Provider
pub runtime: Arc<R>,
/// Local key store
pub key_store: Option<SyncCryptoStorePtr>,
/// Gossip network
Expand All @@ -138,21 +142,22 @@ where
pub protocol_name: std::borrow::Cow<'static, str>,
}

#[cfg(not(test))]
/// Start the BEEFY gadget.
///
/// This is a thin shim around running and awaiting a BEEFY worker.
pub async fn start_beefy_gadget<B, BE, C, N>(beefy_params: BeefyParams<B, BE, C, N>)
pub async fn start_beefy_gadget<B, BE, C, N, R>(beefy_params: BeefyParams<B, BE, C, N, R>)
where
B: Block,
BE: Backend<B>,
C: Client<B, BE>,
C::Api: BeefyApi<B>,
R: ProvideRuntimeApi<B>,
R::Api: BeefyApi<B> + MmrApi<B, MmrRootHash>,
N: GossipNetwork<B> + Clone + SyncOracle + Send + Sync + 'static,
{
let BeefyParams {
client,
backend,
runtime,
key_store,
network,
signed_commitment_sender,
Expand Down Expand Up @@ -188,6 +193,7 @@ where
let worker_params = worker::WorkerParams {
client,
backend,
runtime,
key_store: key_store.into(),
signed_commitment_sender,
beefy_best_block_sender,
Expand All @@ -198,7 +204,7 @@ where
sync_oracle,
};

let worker = worker::BeefyWorker::<_, _, _, _>::new(worker_params);
let worker = worker::BeefyWorker::<_, _, _, _, _>::new(worker_params);

worker.run().await
}
5 changes: 1 addition & 4 deletions client/beefy/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

//! BEEFY Prometheus metrics definition

#[cfg(not(test))]
use prometheus::{register, PrometheusError, Registry};
use prometheus::{Counter, Gauge, U64};
use prometheus::{register, Counter, Gauge, PrometheusError, Registry, U64};

/// BEEFY metrics exposed through Prometheus
pub(crate) struct Metrics {
Expand All @@ -39,7 +37,6 @@ pub(crate) struct Metrics {
}

impl Metrics {
#[cfg(not(test))]
pub(crate) fn register(registry: &Registry) -> Result<Self, PrometheusError> {
Ok(Self {
beefy_validator_set_id: register(
Expand Down
Loading