Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Reduce provisioner work #12718

Closed
wants to merge 7 commits into from
Closed

Reduce provisioner work #12718

wants to merge 7 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Nov 16, 2022

βœ„ -----------------------------------------------------------------------------

Thank you for your Pull Request! πŸ™

Before you submit, please check that:

  • Description: You added a brief description of the PR, e.g.:
    • What does it do?
    • What important points should reviewers know?
    • Is there something left for follow-up PRs?
  • Labels: You labeled the PR appropriately if you have permissions to do so:
    • A* for PR status (one required)
    • B* for changelog (one required)
    • C* for release notes (exactly one required)
    • D* for various implications/requirements
    • Github project assignment
  • Related Issues: You mentioned a related issue if this PR is related to it, e.g. Fixes #228 or Related #1337.
  • 2 Reviewers: You asked at least two reviewers to review. If you aren't sure, start with GH suggestions.
  • Style Guide: Your PR adheres to the style guide
    • In particular, mind the maximal line length of 100 (120 in exceptional circumstances).
    • There is no commented code checked in unless necessary.
    • Any panickers in the runtime have a proof or were removed.
  • Runtime Version: You bumped the runtime version if there are breaking changes in the runtime.
  • Docs: You updated any rustdocs which may need to change.
  • Polkadot Companion: Has the PR altered the external API or interfaces used by Polkadot?
    • If so, do you have the corresponding Polkadot PR ready?
    • Optionally: Do you have a corresponding Cumulus PR?

Refer to the contributing guide for details.

After you've read this notice feel free to remove it.
Thank you!

βœ„ -----------------------------------------------------------------------------

@github-actions github-actions bot added the A3-in_progress Pull request is in progress. No review needed at this stage. label Nov 16, 2022
@@ -22,6 +22,7 @@ log = "0.4.17"
thiserror = "1.0.30"
sc-client-api = { version = "4.0.0-dev", path = "../../api" }
sc-consensus = { version = "0.10.0-dev", path = "../../../client/consensus/common" }
sp-consensus-babe = { version = "0.10.0-dev", path = "../../../primitives/consensus/babe" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not depend on babe.

Comment on lines +171 to +182
fn get_slot(&mut self) -> Option<InherentType> {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
let slot_duration = SlotDuration::from_duration(self.slot_duration)?;
let slot =
sp_consensus_babe::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
*timestamp,
slot_duration,
)
.slot();

Some(slot)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also wrong. There are reasons why it is generic.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes of course!

Comment on lines +129 to +132
pub fn from_duration(duration: sp_std::time::Duration) -> Option<Self> {
let millis: u64 = duration.as_millis().try_into().ok()?;
Some(Self::from_millis(millis))
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be From<Duration>.

And as_millis() as u64 is fine here. Until this overflows, there still seems to be a lot of time :P

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Someone likes to live dangerously :P I agree though!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoever reads this in the future with Substrate still running. Sorry :P

Comment on lines -55 to -56
/// The inherent data.
pub inherent_data: InherentData,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be replaced by Box<InherentdataProvider>

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why? So far, it looks like it's not needed at all. In case I can fix the changes to make them generic without this field, of course.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should still create the inherent data providers inside here and just pass this around to create the inherent data. The function create_inherent_data should be made async. Then you can wait there for the provisioner result.

Copy link
Author

@ghost ghost Nov 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if we keep creating the inherent data providers here, does that not mean that we still do call the provisioner to do all the work for non block building validators? At least in polkadot as polkadot_node_core_parachains_inherent::ParachainsInherentDataProvider::createis called in create_inherent_data_providers https://github.com/paritytech/polkadot/blob/master/node/service/src/lib.rs#L1155-L1159. Which seems to be gathering the inherent data https://github.com/paritytech/polkadot/blob/master/node/core/parachains-inherent/src/lib.rs#L53.

I was thinking of factoring out the slotand timestampcalculation in to a different async in order to get these here and later on call create_inherent_data_providers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you will then just move the call to the provisioner to create_inherent_data. I don't see the problem.

@ghost
Copy link
Author

ghost commented Nov 20, 2022

@bkchr I think I finally understood what you meant. New attempt is at #12749. Still working on the polkadot part

@ghost
Copy link
Author

ghost commented Nov 20, 2022

Closed in favor of #12749

@ghost ghost closed this Nov 20, 2022
@ghost ghost deleted the alexg/reduce_provisioner_work branch November 21, 2022 10:43
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A3-in_progress Pull request is in progress. No review needed at this stage.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant