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

pallet-aura: add feature-flagged explicit slot duration type #14649

Merged
merged 10 commits into from
Aug 4, 2023

Conversation

rphmeier
Copy link
Contributor

@rphmeier rphmeier commented Jul 26, 2023

This is feature-flagged for backwards compatibility - runtimes which are intending to upgrade to asynchronous backing should make use of this.

The main motivation of this change is that computing the slot duration with the MinimumPeriod doesn't play nicely with asynchronous backing and authoring multiple blocks per slot. MinimumPeriod for Cumulus chains doesn't really make a whole lot of sense, as the only clock that they can be compared to is the relay-chain slot number. We will recommend that parachains run with MinimumPeriod = 0, so this change is necessary to keep Aura working in that situation.

I added this with the experimental feature flag with LTS in mind.

@rphmeier rphmeier added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit T1-runtime This PR/Issue is related to the topic “runtime”. labels Jul 26, 2023
@rphmeier rphmeier requested review from a team July 26, 2023 17:29
@rphmeier rphmeier changed the title aura: add feature-flagged explicit slot duration type pallet-aura: add feature-flagged explicit slot duration type Jul 26, 2023
Copy link

@BradleyOlson64 BradleyOlson64 left a comment

Choose a reason for hiding this comment

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

I'm guessing this should be included in the User Update Guide?

Enable feature explicit-slot-duration on aura dependencies.

@rphmeier
Copy link
Contributor Author

I'm guessing this should be included in the User Update Guide?

Yeah, specifically for the parts where asynchronous backing is actually enabled and more than one block needs to be made per slot.

@rphmeier
Copy link
Contributor Author

Can someone in @paritytech/sdk-node comment on whether it's better to just do the breaking change or to add the feature flag as proposed here?

///
/// This was the default behavior of the Aura pallet and may be used for
/// backwards compatibility.
pub struct MinimumPeriodTimesTwo<T>(sp_std::marker::PhantomData<T>);
Copy link
Contributor

@liamaharon liamaharon Jul 30, 2023

Choose a reason for hiding this comment

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

Should this be #[cfg(not(feature = "explicit-slot-duration"))]?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it's strictly necessary with the explicit-slot-duration feature. I don't see a reason this should be feature flagged as it's strictly additive.

@davxy
Copy link
Member

davxy commented Jul 30, 2023

Can someone in @paritytech/sdk-node comment on whether it's better to just do the breaking change or to add the feature flag as proposed here?

IMO the feature flag is a good way to gently propose a change. However should also be considered that this breaking change is not "silent". Maybe an explicit comment about the backward compatible default type would be useful and a matter of a very small change for the user...

Even better would be to use associated_types_default. But is unstable :-/

@@ -207,6 +207,7 @@ impl pallet_aura::Config for Runtime {
type DisabledValidators = ();
type MaxAuthorities = ConstU32<32>;
type AllowMultipleBlocksPerSlot = ConstBool<false>;
type SlotDuration = pallet_aura::MinimumPeriodTimesTwo<Runtime>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this just to make the doc-CI happy (as it builds with all workspace features)

@rphmeier rphmeier force-pushed the rh-aura-generalize-duration branch from ece178d to 9558faa Compare August 1, 2023 16:35
@rphmeier
Copy link
Contributor Author

rphmeier commented Aug 1, 2023

bot merge

@paritytech-processbot
Copy link

Waiting for commit status.

@paritytech-processbot
Copy link

Merge cancelled due to error. Error: Statuses failed for 9558faa

@@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }

pallet-aura = { version = "4.0.0-dev", default-features = false, path = "../../../frame/aura" }
pallet-aura = { version = "4.0.0-dev", default-features = false, features = ["explicit-slot-duration"], path = "../../../frame/aura" }
Copy link
Contributor

Choose a reason for hiding this comment

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

fwiw if this is more the case of something that is experimental now but you see being useful for everyone, there is also feature = experimental already used in a few frame based crates.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is exactly what I was looking for. Thanks

@rphmeier rphmeier force-pushed the rh-aura-generalize-duration branch from 3908288 to aeef644 Compare August 4, 2023 04:12
@rphmeier
Copy link
Contributor Author

rphmeier commented Aug 4, 2023

bot merge

@paritytech-processbot
Copy link

Waiting for commit status.

@paritytech-processbot paritytech-processbot bot merged commit 2e7932f into master Aug 4, 2023
4 checks passed
@paritytech-processbot paritytech-processbot bot deleted the rh-aura-generalize-duration branch August 4, 2023 04:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit T1-runtime This PR/Issue is related to the topic “runtime”.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants