-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Reduce provisioner work #6328
Reduce provisioner work #6328
Changes from 11 commits
0b8ca58
2133341
d3a7a7f
b57bdcc
c6bd3f0
a7200dc
bfda13f
6715c56
c49f64b
3c5675c
a1e9ddf
dc9c98c
816c92d
8b9555d
1137a65
0d9b9b5
d242d8b
58c1e8c
a990e04
8fca5f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,8 @@ authors = ["Parity Technologies <[email protected]>"] | |
| 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" } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -29,32 +29,33 @@ 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"; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /// How long to wait for the provisioner, before giving up. | ||||||||||||||||||||||
| 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>, | ||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Most of the logic in this function should be moved into the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why so? I like how this is actually a separate function handing all the data gathering.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can still put it into a separate function. I just don't like the duplication of the InherentDataProvider. This doesn't make any sense to me. |
||||||||||||||||||||||
| mut overseer: Handle, | ||||||||||||||||||||||
| parent: Hash, | ||||||||||||||||||||||
|
Comment on lines
+54
to
57
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Revert as this would need |
||||||||||||||||||||||
| ) -> 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)))?; | ||||||||||||||||||||||
|
Comment on lines
+135
to
+141
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Revert as this would need |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| 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( | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.