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

frame-executive: Reject invalid inherents in the executive #12365

Merged
merged 6 commits into from
Dec 4, 2022

Conversation

bkchr
Copy link
Member

@bkchr bkchr commented Sep 27, 2022

We already had support for making a block fail if an inherent returned, but it was part of the signed extension CheckWeight. Rejecting blocks with invalid inherents should happen on the frame-executive level without requiring any special signed extension. This is crucial to prevent any kind of spamming of the network that could may happen with blocks that include failing inherents.

We already had support for making a block fail if an inherent returned, but it was part of the
signed extension `CheckWeight`. Rejecting blocks with invalid inherents should happen on the
`frame-executive` level without requiring any special signed extension. This is crucial to prevent
any kind of spamming of the network that could may happen with blocks that include failing inherents.
@bkchr bkchr 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. D9-needsaudit 👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited labels Sep 27, 2022
@muharem
Copy link
Contributor

muharem commented Nov 7, 2022

Just verifying my understanding,

  • every signed or unsigned transactions added to the pool has to be valid for TaggedTransactionQueue::validate_transaction (no inherents expected)
  • inherents added by an author to the block when its being build, using BlockBuilder, and checking them with BlockBuilder::check_inherents.

trying to find where this all orchestrated in the codebase, somewhere on the node level

@bkchr
Copy link
Member Author

bkchr commented Nov 16, 2022

  • every signed or unsigned transactions added to the pool has to be valid for TaggedTransactionQueue::validate_transaction (no inherents expected)

Exactly! Inherents will normally be rejected by validate_transaction.

  • inherents added by an author to the block when its being build, using BlockBuilder, and checking them with BlockBuilder::check_inherents.

check_inherents is only called by nodes on importing a block, not while producing a block.

@bkchr
Copy link
Member Author

bkchr commented Nov 25, 2022

bot rebase

@paritytech-processbot
Copy link

Rebased

bkchr and others added 2 commits November 26, 2022 10:22
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
//
// The entire block should be discarded if an inherent fails to apply. Otherwise
// it may open an attack vector.
if r.is_err() && dispatch_info.class == DispatchClass::Mandatory {
Copy link
Contributor

Choose a reason for hiding this comment

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

I hope there's some doc on top of DispatchClass::Mandatory saying this can only be applied to inherents.

Perhaps also a doc in the frame macros saying you cannot annotate any transaction with DispatchClass::Mandatory.

Or, we should just call this DispatchClass::Inherent 🤷

Kinda confusing now.

Copy link
Member Author

Choose a reason for hiding this comment

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

/// A mandatory dispatch. These kinds of dispatch are always included regardless of their
/// weight, therefore it is critical that they are separately validated to ensure that a
/// malicious validator cannot craft a valid but impossibly heavy block. Usually this just
/// means ensuring that the extrinsic can only be included once and that it is always very
/// light.
///
/// Do *NOT* use it for extrinsics that can be heavy.
///
/// The only real use case for this is inherent extrinsics that are required to execute in a
/// block for the block to be valid, and it solves the issue in the case that the block
/// initialization is sufficiently heavy to mean that those inherents do not fit into the
/// block. Essentially, we assume that in these exceptional circumstances, it is better to
/// allow an overweight block to be created than to not allow any block at all to be created.
Mandatory,
looks good or? :D

@louismerlin louismerlin added D1-audited 👍 PR contains changes to fund-managing logic that has been properly reviewed and externally audited and removed D9-needsaudit 👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited labels Dec 1, 2022
@bkchr
Copy link
Member Author

bkchr commented Dec 4, 2022

bot rebase

@paritytech-processbot
Copy link

Rebased

@bkchr
Copy link
Member Author

bkchr commented Dec 4, 2022

bot merge

@paritytech-processbot
Copy link

Waiting for commit status.

@paritytech-processbot paritytech-processbot bot merged commit cb3eaf2 into master Dec 4, 2022
@paritytech-processbot paritytech-processbot bot deleted the bkchr-mandatory-checks-move branch December 4, 2022 19:40
ltfschoen pushed a commit to ltfschoen/substrate that referenced this pull request Feb 22, 2023
…h#12365)

* frame-executive: Reject invalid inherents in the executive

We already had support for making a block fail if an inherent returned, but it was part of the
signed extension `CheckWeight`. Rejecting blocks with invalid inherents should happen on the
`frame-executive` level without requiring any special signed extension. This is crucial to prevent
any kind of spamming of the network that could may happen with blocks that include failing inherents.

* FMT

* Update frame/executive/src/lib.rs

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>

* Update primitives/runtime/src/transaction_validity.rs

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>

Co-authored-by: parity-processbot <>
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
…h#12365)

* frame-executive: Reject invalid inherents in the executive

We already had support for making a block fail if an inherent returned, but it was part of the
signed extension `CheckWeight`. Rejecting blocks with invalid inherents should happen on the
`frame-executive` level without requiring any special signed extension. This is crucial to prevent
any kind of spamming of the network that could may happen with blocks that include failing inherents.

* FMT

* Update frame/executive/src/lib.rs

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>

* Update primitives/runtime/src/transaction_validity.rs

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>

Co-authored-by: parity-processbot <>
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
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. D1-audited 👍 PR contains changes to fund-managing logic that has been properly reviewed and externally audited
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants