Make RPC block always available #8411
Draft
+1,046
−809
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.
Issue Addressed
RPCBlock, within the context of range sync, is always available. The availability checks inprocess_chain_segmentare therefore superfluous and make the code difficult to reason about. IfRPCBlockis always available, that enables strong type safety guarantees in downstream chain segment processing.The only place outside of range sync where
RPCBlockis used is in block lookup. During block lookup, theRPCBlockis not guaranteed to be available. Therefore it makes sense to introduce a new type for block lookup e.g.MaybeAvailableRpcBlockso that the construction of anRPCBlockhas type-level availability guarantees.Proposed Changes
Split
process_blockintoprocess_sync_blockand the existingprocess_block. TheRPCBlockcode path will useprocess_sync_blockwhich removes all availability checks, as theRpcBlocktype already guarantees availability.New Types Introduced
AvailableExecutionPendingBlock: Similar toExecutionPendingBlock, but instead of having aMaybeAvailableBlockit contains anAvailableBlockNew traits introduced
BlockWithAvailabilityStatus: Used as a generic acrossAvailableBlockandMaybeAvailableBlockto expose helper functions needed forprocess_blockandprocess_sync_block.GenericExecutionPendingBlock: Used as a generic acrossAvailableExecutionPendingBlockandExecutionPendingBlock. Allows for code reuse forfn from_signature_verified_componentsacross the two types.Type changes
SignatureVerifiedBlock: theblockfield is now a genericBlockWithAvailabilityStatus. This allows for code reuse acrossAvailableBlockandMaybeAvailableBlockTODOs
More info soon