Skip to content

Conversation

@JoshOrndorff
Copy link
Contributor

What does it do?

Modifies the author inherent in two ways.

  1. The inherent is now required. This should allow blocks that don't ahve it to be rejected during the quick prechecks rather than waiting until after they are executed.
  2. The inherent is now Mandatory dispatch class https://crates.parity.io/frame_support/weights/enum.DispatchClass.html#variant.Mandatory This is consistent with how the timestamp inherent is handled.

What important points reviewers should know?

We discovered the need for this change when we tried to install the democracy pallet. Democracy intentionally fills the entire block weight every LaunchPeriod blocks. This was leaving no room for the inherent which was dropped. That made our blocks invalid.

What alternative implementations were considered?

As always, we may ditch the author inherent for a PReRuntime digest when cumulus supports slots (or we may not). But regardless of whether we use this inherent long-term, this is the correct design for it.

What value does it bring to the blockchain users?

The chain doesn't stall after the first launch period.

Checklist

  • Does it require a purge of the network?
  • You bumped the runtime version if there are breaking changes in the runtime ?
  • Does it require changes in documentation/tutorials ?

Comment on lines +189 to +196
fn is_inherent_required(_: &InherentData) -> Result<Option<Self::Error>, Self::Error> {
// Return Ok(Some(_)) unconditionally because this inherent is required in every block
// If it is not found, throw an AuthorInherentRequired error.
Ok(Some(InherentError::Other(
sp_runtime::RuntimeString::Borrowed("AuthorInherentRequired"),
)))
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@4meta5 This is why I was wondering whether we still need the check in on_finalize.

See paritytech/substrate#7941 for my best understanding of how this trait works.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. This should work, but still need to clear the storage item in on_finalize so it can be set in the next block. So can remove the assert!(<Author>::take) and replace it with <Author>::kill()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@4meta5 Could you please investigate whether this cleanup is valid in another PR?

@JoshOrndorff JoshOrndorff merged commit c39f32b into master Jan 28, 2021
@JoshOrndorff JoshOrndorff deleted the joshy-mandatory-author-inherent branch January 28, 2021 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants