mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-08 15:58:02 +00:00
Reduce provisioner work (#6328)
* Store values needed to create inherent data when needed instead of creating them early on * Point deps to substrate branch * Arc the client * Cargo update * Fix main cargo files * Undo cargo file changes * Add overseer dep to inherents * Update deps * Simplify code * Update benchmark * Update node/client/src/benchmarking.rs Co-authored-by: Bastian Köcher <info@kchr.de> * Update node/core/parachains-inherent/src/lib.rs Co-authored-by: Bastian Köcher <info@kchr.de> * Update node/core/parachains-inherent/src/lib.rs Co-authored-by: Bastian Köcher <info@kchr.de> * Revert "Update node/core/parachains-inherent/src/lib.rs" This reverts commit 8b9555dc2451acfabab173d259e00da2728b7aa2. * Revert "Update node/core/parachains-inherent/src/lib.rs" This reverts commit 816c92d0e001e71f677d0acbcf22bdc3f511bc56. * cargo update -p sp-io * fmt Co-authored-by: Bastian Köcher <info@kchr.de>
This commit is contained in:
Generated
+184
-181
File diff suppressed because it is too large
Load Diff
@@ -5,6 +5,8 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
async-trait = "0.1.57"
|
||||
futures = "0.3.21"
|
||||
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
@@ -359,7 +359,7 @@ pub fn benchmark_inherent_data(
|
||||
// Assume that all runtimes have the `timestamp` pallet.
|
||||
let d = std::time::Duration::from_millis(0);
|
||||
let timestamp = sp_timestamp::InherentDataProvider::new(d.into());
|
||||
timestamp.provide_inherent_data(&mut inherent_data)?;
|
||||
futures::executor::block_on(timestamp.provide_inherent_data(&mut inherent_data))?;
|
||||
|
||||
let para_data = polkadot_primitives::v2::InherentData {
|
||||
bitfields: Vec::new(),
|
||||
@@ -368,8 +368,7 @@ pub fn benchmark_inherent_data(
|
||||
parent_header: header,
|
||||
};
|
||||
|
||||
polkadot_node_core_parachains_inherent::ParachainsInherentDataProvider::from_data(para_data)
|
||||
.provide_inherent_data(&mut inherent_data)?;
|
||||
inherent_data.put_data(polkadot_primitives::v2::PARACHAINS_INHERENT_IDENTIFIER, ¶_data)?;
|
||||
|
||||
Ok(inherent_data)
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ gum = { package = "tracing-gum", path = "../../gum" }
|
||||
thiserror = "1.0.31"
|
||||
async-trait = "0.1.57"
|
||||
polkadot-node-subsystem = { path = "../../subsystem" }
|
||||
polkadot-overseer = { path = "../../overseer" }
|
||||
polkadot-primitives = { path = "../../../primitives" }
|
||||
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
@@ -29,9 +29,8 @@ use polkadot_node_subsystem::{
|
||||
errors::SubsystemError, messages::ProvisionerMessage, overseer::Handle,
|
||||
};
|
||||
use polkadot_primitives::v2::{Block, Hash, InherentData as ParachainsInherentData};
|
||||
use sp_blockchain::HeaderBackend;
|
||||
use sp_runtime::generic::BlockId;
|
||||
use std::time;
|
||||
use std::{sync::Arc, time};
|
||||
|
||||
pub(crate) const LOG_TARGET: &str = "parachain::parachains-inherent";
|
||||
|
||||
@@ -39,22 +38,24 @@ pub(crate) const LOG_TARGET: &str = "parachain::parachains-inherent";
|
||||
const PROVISIONER_TIMEOUT: time::Duration = core::time::Duration::from_millis(2500);
|
||||
|
||||
/// Provides the parachains inherent data.
|
||||
pub struct ParachainsInherentDataProvider {
|
||||
inherent_data: ParachainsInherentData,
|
||||
pub struct ParachainsInherentDataProvider<C: sp_blockchain::HeaderBackend<Block>> {
|
||||
pub client: Arc<C>,
|
||||
pub overseer: polkadot_overseer::Handle,
|
||||
pub parent: Hash,
|
||||
}
|
||||
|
||||
impl ParachainsInherentDataProvider {
|
||||
/// Create a [`Self`] directly from some [`ParachainsInherentData`].
|
||||
pub fn from_data(inherent_data: ParachainsInherentData) -> Self {
|
||||
Self { inherent_data }
|
||||
impl<C: sp_blockchain::HeaderBackend<Block>> ParachainsInherentDataProvider<C> {
|
||||
/// Create a new [`Self`].
|
||||
pub fn new(client: Arc<C>, overseer: polkadot_overseer::Handle, parent: Hash) -> Self {
|
||||
ParachainsInherentDataProvider { client, overseer, parent }
|
||||
}
|
||||
|
||||
/// Create a new instance of the [`ParachainsInherentDataProvider`].
|
||||
pub async fn create<C: HeaderBackend<Block>>(
|
||||
client: &C,
|
||||
pub async fn create(
|
||||
client: Arc<C>,
|
||||
mut overseer: Handle,
|
||||
parent: Hash,
|
||||
) -> Result<Self, Error> {
|
||||
) -> Result<ParachainsInherentData, Error> {
|
||||
let pid = async {
|
||||
let (sender, receiver) = futures::channel::oneshot::channel();
|
||||
gum::trace!(
|
||||
@@ -119,18 +120,28 @@ impl ParachainsInherentDataProvider {
|
||||
},
|
||||
};
|
||||
|
||||
Ok(Self { inherent_data })
|
||||
Ok(inherent_data)
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl sp_inherents::InherentDataProvider for ParachainsInherentDataProvider {
|
||||
fn provide_inherent_data(
|
||||
impl<C: sp_blockchain::HeaderBackend<Block>> sp_inherents::InherentDataProvider
|
||||
for ParachainsInherentDataProvider<C>
|
||||
{
|
||||
async fn provide_inherent_data(
|
||||
&self,
|
||||
dst_inherent_data: &mut sp_inherents::InherentData,
|
||||
) -> Result<(), sp_inherents::Error> {
|
||||
let inherent_data = ParachainsInherentDataProvider::create(
|
||||
self.client.clone(),
|
||||
self.overseer.clone(),
|
||||
self.parent,
|
||||
)
|
||||
.await
|
||||
.map_err(|e| sp_inherents::Error::Application(Box::new(e)))?;
|
||||
|
||||
dst_inherent_data
|
||||
.put_data(polkadot_primitives::v2::PARACHAINS_INHERENT_IDENTIFIER, &self.inherent_data)
|
||||
.put_data(polkadot_primitives::v2::PARACHAINS_INHERENT_IDENTIFIER, &inherent_data)
|
||||
}
|
||||
|
||||
async fn try_handle_error(
|
||||
|
||||
@@ -1154,11 +1154,12 @@ where
|
||||
let overseer_handle = overseer_handle.clone();
|
||||
|
||||
async move {
|
||||
let parachain = polkadot_node_core_parachains_inherent::ParachainsInherentDataProvider::create(
|
||||
&*client_clone,
|
||||
overseer_handle,
|
||||
parent,
|
||||
).await.map_err(|e| Box::new(e))?;
|
||||
let parachain =
|
||||
polkadot_node_core_parachains_inherent::ParachainsInherentDataProvider::new(
|
||||
client_clone,
|
||||
overseer_handle,
|
||||
parent,
|
||||
);
|
||||
|
||||
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user