mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 17:31:03 +00:00
Companion for Substrate#10568 - Add new BEEFY RPC (#4638)
* support best Beefy RPC through arc<mutex> * beefy RPC through lockless message passing - wip Not working because channel can't be simply opened and receiver passed to `rpc_extensions_builder` because `rpc_extensions_builder` has to be `Fn` and not `FnOnce`... and and Receiver side of mpsc can't be cloned yay!.. * beefy RPC through lockless message passing * beefy: use specialized type definitions * bubble up service errors from BEEFY RPC * update lockfile for substrate Co-authored-by: parity-processbot <>
This commit is contained in:
Generated
+169
-164
File diff suppressed because it is too large
Load Diff
@@ -34,6 +34,7 @@ mod tests;
|
|||||||
|
|
||||||
#[cfg(feature = "full-node")]
|
#[cfg(feature = "full-node")]
|
||||||
use {
|
use {
|
||||||
|
beefy_gadget::notification::{BeefyBestBlockSender, BeefySignedCommitmentSender},
|
||||||
grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider},
|
grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider},
|
||||||
polkadot_node_core_approval_voting::Config as ApprovalVotingConfig,
|
polkadot_node_core_approval_voting::Config as ApprovalVotingConfig,
|
||||||
polkadot_node_core_av_store::Config as AvailabilityConfig,
|
polkadot_node_core_av_store::Config as AvailabilityConfig,
|
||||||
@@ -414,7 +415,7 @@ fn new_partial<RuntimeApi, ExecutorDispatch, ChainSelection>(
|
|||||||
>,
|
>,
|
||||||
grandpa::LinkHalf<Block, FullClient<RuntimeApi, ExecutorDispatch>, ChainSelection>,
|
grandpa::LinkHalf<Block, FullClient<RuntimeApi, ExecutorDispatch>, ChainSelection>,
|
||||||
babe::BabeLink<Block>,
|
babe::BabeLink<Block>,
|
||||||
beefy_gadget::notification::BeefySignedCommitmentSender<Block>,
|
(BeefySignedCommitmentSender<Block>, BeefyBestBlockSender<Block>),
|
||||||
),
|
),
|
||||||
grandpa::SharedVoterState,
|
grandpa::SharedVoterState,
|
||||||
std::time::Duration, // slot-duration
|
std::time::Duration, // slot-duration
|
||||||
@@ -485,8 +486,11 @@ where
|
|||||||
telemetry.as_ref().map(|x| x.handle()),
|
telemetry.as_ref().map(|x| x.handle()),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let (beefy_link, beefy_commitment_stream) =
|
let (beefy_commitment_link, beefy_commitment_stream) =
|
||||||
beefy_gadget::notification::BeefySignedCommitmentStream::channel();
|
beefy_gadget::notification::BeefySignedCommitmentStream::<Block>::channel();
|
||||||
|
let (beefy_best_block_link, beefy_best_block_stream) =
|
||||||
|
beefy_gadget::notification::BeefyBestBlockStream::<Block>::channel();
|
||||||
|
let beefy_links = (beefy_commitment_link, beefy_best_block_link);
|
||||||
|
|
||||||
let justification_stream = grandpa_link.justification_stream();
|
let justification_stream = grandpa_link.justification_stream();
|
||||||
let shared_authority_set = grandpa_link.shared_authority_set().clone();
|
let shared_authority_set = grandpa_link.shared_authority_set().clone();
|
||||||
@@ -496,12 +500,12 @@ where
|
|||||||
Some(shared_authority_set.clone()),
|
Some(shared_authority_set.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();
|
let shared_epoch_changes = babe_link.epoch_changes().clone();
|
||||||
let slot_duration = babe_config.slot_duration();
|
let slot_duration = babe_config.slot_duration();
|
||||||
|
|
||||||
|
let import_setup = (block_import, grandpa_link, babe_link, beefy_links);
|
||||||
|
let rpc_setup = shared_voter_state.clone();
|
||||||
|
|
||||||
let rpc_extensions_builder = {
|
let rpc_extensions_builder = {
|
||||||
let client = client.clone();
|
let client = client.clone();
|
||||||
let keystore = keystore_container.sync_keystore();
|
let keystore = keystore_container.sync_keystore();
|
||||||
@@ -532,6 +536,7 @@ where
|
|||||||
},
|
},
|
||||||
beefy: polkadot_rpc::BeefyDeps {
|
beefy: polkadot_rpc::BeefyDeps {
|
||||||
beefy_commitment_stream: beefy_commitment_stream.clone(),
|
beefy_commitment_stream: beefy_commitment_stream.clone(),
|
||||||
|
beefy_best_block_stream: beefy_best_block_stream.clone(),
|
||||||
subscription_executor,
|
subscription_executor,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -893,7 +898,7 @@ where
|
|||||||
telemetry: telemetry.as_mut(),
|
telemetry: telemetry.as_mut(),
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let (block_import, link_half, babe_link, beefy_link) = import_setup;
|
let (block_import, link_half, babe_link, beefy_links) = import_setup;
|
||||||
|
|
||||||
let overseer_client = client.clone();
|
let overseer_client = client.clone();
|
||||||
let spawner = task_manager.spawn_handle();
|
let spawner = task_manager.spawn_handle();
|
||||||
@@ -1091,7 +1096,8 @@ where
|
|||||||
backend: backend.clone(),
|
backend: backend.clone(),
|
||||||
key_store: keystore_opt.clone(),
|
key_store: keystore_opt.clone(),
|
||||||
network: network.clone(),
|
network: network.clone(),
|
||||||
signed_commitment_sender: beefy_link,
|
signed_commitment_sender: beefy_links.0,
|
||||||
|
beefy_best_block_sender: beefy_links.1,
|
||||||
min_block_delta: if chain_spec.is_wococo() { 4 } else { 8 },
|
min_block_delta: if chain_spec.is_wococo() { 4 } else { 8 },
|
||||||
prometheus_registry: prometheus_registry.clone(),
|
prometheus_registry: prometheus_registry.clone(),
|
||||||
protocol_name: beefy_protocol_name,
|
protocol_name: beefy_protocol_name,
|
||||||
|
|||||||
@@ -61,10 +61,13 @@ pub struct GrandpaDeps<B> {
|
|||||||
pub finality_provider: Arc<FinalityProofProvider<B, Block>>,
|
pub finality_provider: Arc<FinalityProofProvider<B, Block>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use beefy_gadget::notification::{BeefyBestBlockStream, BeefySignedCommitmentStream};
|
||||||
/// Dependencies for BEEFY
|
/// Dependencies for BEEFY
|
||||||
pub struct BeefyDeps {
|
pub struct BeefyDeps {
|
||||||
/// Receives notifications about signed commitment events from BEEFY.
|
/// Receives notifications about signed commitment events from BEEFY.
|
||||||
pub beefy_commitment_stream: beefy_gadget::notification::BeefySignedCommitmentStream<Block>,
|
pub beefy_commitment_stream: BeefySignedCommitmentStream<Block>,
|
||||||
|
/// Receives notifications about best block events from BEEFY.
|
||||||
|
pub beefy_best_block_stream: BeefyBestBlockStream<Block>,
|
||||||
/// Executor to drive the subscription manager in the BEEFY RPC handler.
|
/// Executor to drive the subscription manager in the BEEFY RPC handler.
|
||||||
pub subscription_executor: sc_rpc::SubscriptionTaskExecutor,
|
pub subscription_executor: sc_rpc::SubscriptionTaskExecutor,
|
||||||
}
|
}
|
||||||
@@ -155,12 +158,12 @@ where
|
|||||||
deny_unsafe,
|
deny_unsafe,
|
||||||
)?));
|
)?));
|
||||||
|
|
||||||
io.extend_with(beefy_gadget_rpc::BeefyApi::to_delegate(
|
let handler: beefy_gadget_rpc::BeefyRpcHandler<Block> = beefy_gadget_rpc::BeefyRpcHandler::new(
|
||||||
beefy_gadget_rpc::BeefyRpcHandler::new(
|
|
||||||
beefy.beefy_commitment_stream,
|
beefy.beefy_commitment_stream,
|
||||||
|
beefy.beefy_best_block_stream,
|
||||||
beefy.subscription_executor,
|
beefy.subscription_executor,
|
||||||
),
|
)?;
|
||||||
));
|
io.extend_with(beefy_gadget_rpc::BeefyApi::to_delegate(handler));
|
||||||
|
|
||||||
Ok(io)
|
Ok(io)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user