mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-22 05:35:42 +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"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
async-trait = "0.1.57"
|
||||||
|
futures = "0.3.21"
|
||||||
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
frame-benchmarking-cli = { 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" }
|
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.
|
// Assume that all runtimes have the `timestamp` pallet.
|
||||||
let d = std::time::Duration::from_millis(0);
|
let d = std::time::Duration::from_millis(0);
|
||||||
let timestamp = sp_timestamp::InherentDataProvider::new(d.into());
|
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 {
|
let para_data = polkadot_primitives::v2::InherentData {
|
||||||
bitfields: Vec::new(),
|
bitfields: Vec::new(),
|
||||||
@@ -368,8 +368,7 @@ pub fn benchmark_inherent_data(
|
|||||||
parent_header: header,
|
parent_header: header,
|
||||||
};
|
};
|
||||||
|
|
||||||
polkadot_node_core_parachains_inherent::ParachainsInherentDataProvider::from_data(para_data)
|
inherent_data.put_data(polkadot_primitives::v2::PARACHAINS_INHERENT_IDENTIFIER, ¶_data)?;
|
||||||
.provide_inherent_data(&mut inherent_data)?;
|
|
||||||
|
|
||||||
Ok(inherent_data)
|
Ok(inherent_data)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ gum = { package = "tracing-gum", path = "../../gum" }
|
|||||||
thiserror = "1.0.31"
|
thiserror = "1.0.31"
|
||||||
async-trait = "0.1.57"
|
async-trait = "0.1.57"
|
||||||
polkadot-node-subsystem = { path = "../../subsystem" }
|
polkadot-node-subsystem = { path = "../../subsystem" }
|
||||||
|
polkadot-overseer = { path = "../../overseer" }
|
||||||
polkadot-primitives = { path = "../../../primitives" }
|
polkadot-primitives = { path = "../../../primitives" }
|
||||||
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sp-inherents = { 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,
|
errors::SubsystemError, messages::ProvisionerMessage, overseer::Handle,
|
||||||
};
|
};
|
||||||
use polkadot_primitives::v2::{Block, Hash, InherentData as ParachainsInherentData};
|
use polkadot_primitives::v2::{Block, Hash, InherentData as ParachainsInherentData};
|
||||||
use sp_blockchain::HeaderBackend;
|
|
||||||
use sp_runtime::generic::BlockId;
|
use sp_runtime::generic::BlockId;
|
||||||
use std::time;
|
use std::{sync::Arc, time};
|
||||||
|
|
||||||
pub(crate) const LOG_TARGET: &str = "parachain::parachains-inherent";
|
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);
|
const PROVISIONER_TIMEOUT: time::Duration = core::time::Duration::from_millis(2500);
|
||||||
|
|
||||||
/// Provides the parachains inherent data.
|
/// Provides the parachains inherent data.
|
||||||
pub struct ParachainsInherentDataProvider {
|
pub struct ParachainsInherentDataProvider<C: sp_blockchain::HeaderBackend<Block>> {
|
||||||
inherent_data: ParachainsInherentData,
|
pub client: Arc<C>,
|
||||||
|
pub overseer: polkadot_overseer::Handle,
|
||||||
|
pub parent: Hash,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ParachainsInherentDataProvider {
|
impl<C: sp_blockchain::HeaderBackend<Block>> ParachainsInherentDataProvider<C> {
|
||||||
/// Create a [`Self`] directly from some [`ParachainsInherentData`].
|
/// Create a new [`Self`].
|
||||||
pub fn from_data(inherent_data: ParachainsInherentData) -> Self {
|
pub fn new(client: Arc<C>, overseer: polkadot_overseer::Handle, parent: Hash) -> Self {
|
||||||
Self { inherent_data }
|
ParachainsInherentDataProvider { client, overseer, parent }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new instance of the [`ParachainsInherentDataProvider`].
|
/// Create a new instance of the [`ParachainsInherentDataProvider`].
|
||||||
pub async fn create<C: HeaderBackend<Block>>(
|
pub async fn create(
|
||||||
client: &C,
|
client: Arc<C>,
|
||||||
mut overseer: Handle,
|
mut overseer: Handle,
|
||||||
parent: Hash,
|
parent: Hash,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<ParachainsInherentData, Error> {
|
||||||
let pid = async {
|
let pid = async {
|
||||||
let (sender, receiver) = futures::channel::oneshot::channel();
|
let (sender, receiver) = futures::channel::oneshot::channel();
|
||||||
gum::trace!(
|
gum::trace!(
|
||||||
@@ -119,18 +120,28 @@ impl ParachainsInherentDataProvider {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Self { inherent_data })
|
Ok(inherent_data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl sp_inherents::InherentDataProvider for ParachainsInherentDataProvider {
|
impl<C: sp_blockchain::HeaderBackend<Block>> sp_inherents::InherentDataProvider
|
||||||
fn provide_inherent_data(
|
for ParachainsInherentDataProvider<C>
|
||||||
|
{
|
||||||
|
async fn provide_inherent_data(
|
||||||
&self,
|
&self,
|
||||||
dst_inherent_data: &mut sp_inherents::InherentData,
|
dst_inherent_data: &mut sp_inherents::InherentData,
|
||||||
) -> Result<(), sp_inherents::Error> {
|
) -> 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
|
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(
|
async fn try_handle_error(
|
||||||
|
|||||||
@@ -1154,11 +1154,12 @@ where
|
|||||||
let overseer_handle = overseer_handle.clone();
|
let overseer_handle = overseer_handle.clone();
|
||||||
|
|
||||||
async move {
|
async move {
|
||||||
let parachain = polkadot_node_core_parachains_inherent::ParachainsInherentDataProvider::create(
|
let parachain =
|
||||||
&*client_clone,
|
polkadot_node_core_parachains_inherent::ParachainsInherentDataProvider::new(
|
||||||
overseer_handle,
|
client_clone,
|
||||||
parent,
|
overseer_handle,
|
||||||
).await.map_err(|e| Box::new(e))?;
|
parent,
|
||||||
|
);
|
||||||
|
|
||||||
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
|
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user