linera-chain: fold execute_block inputs into a BlockExecution enum#6580
Draft
ndr-ds wants to merge 1 commit into
Draft
linera-chain: fold execute_block inputs into a BlockExecution enum#6580ndr-ds wants to merge 1 commit into
ndr-ds wants to merge 1 commit into
Conversation
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.
Motivation
Follow-up to #6471, addressing the review comment from afck: after #6471,
ChainStateView::execute_blocktookreplaying_oracle_responses,policy, andphaseas three separate arguments, but their legal combinations are fully determined by the phase. The type therefore permitted illegal inputs, and one coupling was guarded at runtime by anassert!:Nonewhen staging or validating a proposal,Somewhen executing a confirmed certificate;AutoRetryis only legal when staging a proposal (the block is still being built); validating or confirming mustAbort.Proposal
Merge the three arguments into one
BlockExecutionenum whose variants carry exactly the legal data:StageProposal { policy }— caller-chosen policy (may beAutoRetry); never replays.HandleProposal— alwaysAbort; never replays.HandleConfirmed { oracle_responses }— alwaysAbort; replays the recorded responses.execute_blocknow takes a singleBlockExecutionand derives the oracle-responses/policy internally. Payoff:(AutoRetry, Some(oracle_responses))combination is now unconstructable, so theassert!(replaying_oracle_responses.is_none())inexecute_block_inneris deleted;execute_blockdrops its#[expect(clippy::too_many_arguments)](down to 5 args);committed()explicitly.roundis deliberately left a positional parameter: itsNone-for-confirmed invariant is exclusion-only (both proposal phases carry a round), so folding it in would duplicate the field across variants and delete no guard.Pure refactor, no behavior change. The
CopyBlockExecutionPhasemetric label is kept and derived viaBlockExecution::phase().Test Plan
cargo clippy -p linera-core -p linera-chain --features "metrics test" --all-targets— 0 warnings.cargo build -p linera-chain -p linera-core(default features, metrics off) — clean.cargo doc -p linera-chainwithRUSTDOCFLAGS=-D warnings— clean (intra-doc links on the new enum).cargo test -p linera-chain --features "metrics test" --lib— 57 passed.cargo test -p linera-core --features "metrics test" --lib -- test_handle_block_proposal test_handle_certificate— 20 passed.Release Plan
Links