mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-21 01:41:03 +00:00
Merkle Mountain Range & BEEFY integration (#2101)
* Switch branch. * Implement basic MMR leaf. * Revert "Switch branch." This reverts commit 7f4d41c67f27ca560c53fc63fd3bd06ac182403c. * Bump substrate. * Integrate BEEFY. Bump all. Fix missing imports. * Use beefy pallet to get authorities. * Bump BEEFY repo. * Use next authority set instead of the current one. * Start BEEFY service. * Fix BEEFY start up. * Cache BEEFY authority set. * Add BEEFY ValidatorSetId to MMR * Fix code. * Apply suggestions from code review Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com> * Review grumbles. * Update beefy repo. * Work-around missing protocol. * Revert "Work-around missing protocol." This reverts commit 0a6257a8bccc1c67e966898cdedc408c6469ffd6. * Add beefy peers set config. * Expose storage of BEEFY. * Uncompress BEEFY keys for merkle tree. * Update ordering. * Switch to branch. * Bump deps. * Switch to custom beefy. * Add MMR RuntimeApi and custom rpc. * Add set length details. * Fix compilation. * Expose MmrLeaf storage. * Expose MmrLeaf storage. * Don't use session handler, and rather compute & cache beefy details on call. * Don't use session handler, and rather compute & cache beefy details on call. * Fixes. * Update Cargo.lock. * Switch back to master. * Update lockfile. * Fix xcm print issue. * Cargo.lock. * Use master branch. * Remove extra dep. * Fix tests. * Update Cargo.lock * Add BEEFY & MMR to westend. * Implement session keys migration. * Update testnet script. * start BEEFY for all node types * Update Cargo.lock * fix Cargo.toml * resolve another merge conflict * add Westend BEEFY keys * Apply suggestions from code review Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com> * Update BEEFY. * Add Rococo BEEFY keys * resolve merge issue * fix pallet indices * fix Westend OldSessionKey * remove unused imports in Westend runtime * Fix compilation for Westend. * address review * start BEEFY gadget conditionally * address review again * fix typo * remove duplicate * remove another duplicate * well * add missing stuff * cleanup Cargo.toml files - revert unnecessary changes - add missing /std dependencies - remove unused dependencies * runtime: remove unused structs from rococo runtime * node: cleanup service Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com> Co-authored-by: adoerr <0xad@gmx.net> Co-authored-by: André Silva <andrerfosilva@gmail.com>
This commit is contained in:
@@ -40,6 +40,7 @@ use {
|
||||
sc_keystore::LocalKeystore,
|
||||
babe_primitives::BabeApi,
|
||||
grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider},
|
||||
beefy_primitives::ecdsa::AuthoritySignature as BeefySignature,
|
||||
sp_runtime::traits::Header as HeaderT,
|
||||
};
|
||||
#[cfg(feature = "real-overseer")]
|
||||
@@ -243,7 +244,8 @@ fn new_partial<RuntimeApi, Executor>(
|
||||
Block, FullClient<RuntimeApi, Executor>, FullGrandpaBlockImport<RuntimeApi, Executor>
|
||||
>,
|
||||
grandpa::LinkHalf<Block, FullClient<RuntimeApi, Executor>, FullSelectChain>,
|
||||
babe::BabeLink<Block>
|
||||
babe::BabeLink<Block>,
|
||||
beefy_gadget::notification::BeefySignedCommitmentSender<Block, BeefySignature>,
|
||||
),
|
||||
grandpa::SharedVoterState,
|
||||
std::time::Duration, // slot-duration
|
||||
@@ -342,6 +344,9 @@ fn new_partial<RuntimeApi, Executor>(
|
||||
telemetry.as_ref().map(|x| x.handle()),
|
||||
)?;
|
||||
|
||||
let (beefy_link, beefy_commitment_stream) =
|
||||
beefy_gadget::notification::BeefySignedCommitmentStream::channel();
|
||||
|
||||
let justification_stream = grandpa_link.justification_stream();
|
||||
let shared_authority_set = grandpa_link.shared_authority_set().clone();
|
||||
let shared_voter_state = grandpa::SharedVoterState::empty();
|
||||
@@ -350,7 +355,7 @@ fn new_partial<RuntimeApi, Executor>(
|
||||
Some(shared_authority_set.clone()),
|
||||
);
|
||||
|
||||
let import_setup = (block_import.clone(), grandpa_link, babe_link.clone());
|
||||
let import_setup = (block_import.clone(), grandpa_link, babe_link.clone(), beefy_link);
|
||||
let rpc_setup = shared_voter_state.clone();
|
||||
|
||||
let shared_epoch_changes = babe_link.epoch_changes().clone();
|
||||
@@ -363,7 +368,9 @@ fn new_partial<RuntimeApi, Executor>(
|
||||
let select_chain = select_chain.clone();
|
||||
let chain_spec = config.chain_spec.cloned_box();
|
||||
|
||||
move |deny_unsafe, subscription_executor| -> polkadot_rpc::RpcExtension {
|
||||
move |deny_unsafe, subscription_executor: polkadot_rpc::SubscriptionTaskExecutor|
|
||||
-> polkadot_rpc::RpcExtension
|
||||
{
|
||||
let deps = polkadot_rpc::FullDeps {
|
||||
client: client.clone(),
|
||||
pool: transaction_pool.clone(),
|
||||
@@ -379,9 +386,13 @@ fn new_partial<RuntimeApi, Executor>(
|
||||
shared_voter_state: shared_voter_state.clone(),
|
||||
shared_authority_set: shared_authority_set.clone(),
|
||||
justification_stream: justification_stream.clone(),
|
||||
subscription_executor,
|
||||
subscription_executor: subscription_executor.clone(),
|
||||
finality_provider: finality_proof_provider.clone(),
|
||||
},
|
||||
beefy: polkadot_rpc::BeefyDeps {
|
||||
beefy_commitment_stream: beefy_commitment_stream.clone(),
|
||||
subscription_executor,
|
||||
},
|
||||
};
|
||||
|
||||
polkadot_rpc::create_full(deps)
|
||||
@@ -731,6 +742,11 @@ pub fn new_full<RuntimeApi, Executor>(
|
||||
// anything in terms of behaviour, but makes the logs more consistent with the other
|
||||
// Substrate nodes.
|
||||
config.network.extra_sets.push(grandpa::grandpa_peers_set_config());
|
||||
|
||||
if config.chain_spec.is_westend() || config.chain_spec.is_rococo() {
|
||||
config.network.extra_sets.push(beefy_gadget::beefy_peers_set_config());
|
||||
}
|
||||
|
||||
#[cfg(feature = "real-overseer")]
|
||||
{
|
||||
use polkadot_network_bridge::{peer_sets_info, IsAuthority};
|
||||
@@ -824,6 +840,7 @@ pub fn new_full<RuntimeApi, Executor>(
|
||||
}
|
||||
|
||||
let availability_config = config.database.clone().try_into().map_err(Error::Availability)?;
|
||||
let chain_spec = config.chain_spec.cloned_box();
|
||||
|
||||
let approval_voting_config = ApprovalVotingConfig {
|
||||
path: config.database.path()
|
||||
@@ -849,7 +866,7 @@ pub fn new_full<RuntimeApi, Executor>(
|
||||
telemetry: telemetry.as_mut(),
|
||||
})?;
|
||||
|
||||
let (block_import, link_half, babe_link) = import_setup;
|
||||
let (block_import, link_half, babe_link, beefy_link) = import_setup;
|
||||
|
||||
let overseer_client = client.clone();
|
||||
let spawner = task_manager.spawn_handle();
|
||||
@@ -967,6 +984,29 @@ pub fn new_full<RuntimeApi, Executor>(
|
||||
task_manager.spawn_essential_handle().spawn_blocking("babe", babe);
|
||||
}
|
||||
|
||||
// We currently only run the BEEFY gadget on Rococo and Westend test
|
||||
// networks. On Rococo we start the BEEFY gadget as a normal (non-essential)
|
||||
// task for now, since BEEFY is still experimental and we don't want a
|
||||
// failure to bring down the whole node. Westend test network is less used
|
||||
// than Rococo and therefore a failure there will be less problematic, this
|
||||
// will be the main testing target for BEEFY for now.
|
||||
if chain_spec.is_westend() || chain_spec.is_rococo() {
|
||||
let gadget = beefy_gadget::start_beefy_gadget::<_, beefy_primitives::ecdsa::AuthorityPair, _, _, _, _>(
|
||||
client.clone(),
|
||||
keystore_container.sync_keystore(),
|
||||
network.clone(),
|
||||
beefy_link,
|
||||
network.clone(),
|
||||
prometheus_registry.clone()
|
||||
);
|
||||
|
||||
if chain_spec.is_westend() {
|
||||
task_manager.spawn_essential_handle().spawn_blocking("beefy-gadget", gadget);
|
||||
} else {
|
||||
task_manager.spawn_handle().spawn_blocking("beefy-gadget", gadget);
|
||||
}
|
||||
}
|
||||
|
||||
// if the node isn't actively participating in consensus then it doesn't
|
||||
// need a keystore, regardless of which protocol we use below.
|
||||
let keystore_opt = if role.is_authority() {
|
||||
|
||||
Reference in New Issue
Block a user