[author-inherent] Use ensure!() to avoid storage transactions are left open by the runtime#91
Closed
arturgontijo wants to merge 1 commit intomainfrom
Closed
[author-inherent] Use ensure!() to avoid storage transactions are left open by the runtime#91arturgontijo wants to merge 1 commit intomainfrom
ensure!() to avoid storage transactions are left open by the runtime#91arturgontijo wants to merge 1 commit intomainfrom
Conversation
RomarQ
reviewed
Jan 28, 2026
|
|
||
| // Now check that the author is valid in this slot | ||
| assert!( | ||
| ensure!( |
Contributor
There was a problem hiding this comment.
We want to panic here. The fix for the pending block inherents needs to be on the client side, when we provide the pending_consenus_data_provider.
Contributor
There was a problem hiding this comment.
Great catch Rodri, shall we comment something like this here then:
Why assert! is critical here
1. This is a mandatory inherent (DispatchClass::Mandatory at line 138). Mandatory inherents must be included in every block AND must succeed. If validation fails, the block itself is invalid.
2. Block-level validity, not transaction-level - The comment explicitly says "Block invalid". If an ineligible author produced a block, we don't want that block to exist at all. Using ensure! would merely fail
the inherent call while potentially allowing the block to be finalized.
3. Security invariant - Author eligibility is a consensus-critical check. If this fails, something is fundamentally wrong (either a bug or an attack). The block must be rejected entirely, not just have a failed
transaction in it.
4. No recovery path - There's no sensible way to "handle" an invalid author gracefully. The block simply shouldn't exist.
and possibly add proper testing for this path?
Contributor
Author
|
Close this as we need it to panic here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR replaces
assert!()byensure!()to avoid a panic duringEthereumRuntimeRPCApi::initialize_pending_block().In order to check this we need to run a moonbeam's zombienet with multiple collators (heads up for
"-leth-pending=trace"too):moonbeam/zombienet/configs/moonbeam-polkadot.tomlOnce parachain blocks are being produced send any
eth_call(txn, "pending")to Alith's node, eg:So eventually we will get these warnings:
Investigating what could cause those warnings I came up with the following panic stack:
After replacing the
assert!()byensure!()there were no more storage transactions being left open.