feat(flashtypes): Add validation utilities, Metadata helpers, and Fla… #302
+181
−0
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.
Summary
This PR enhances the
base-flashtypescrate with validation utilities, helper methods, and comprehensive unit tests to improve developer experience and code reusability.Changes
New
validationmoduleAdded common validation functions for flashblock data:
is_non_zero_address()- validate non-zero addressesis_valid_state_root()/is_valid_block_hash()- validate non-zero hashesis_valid_blob_gas()- validate optional blob gas valuesis_valid_gas_usage()- validate gas used vs limitis_valid_timestamp()- validate non-zero timestampsis_valid_transaction_bytes()- validate non-empty transaction dataMetadatahelper methodsis_empty()- check if metadata has no receipts or balance updatesreceipts_len()/balance_updates_len()- count tracked itemsbalance_for()- lookup balance by addresshas_balance_update()- check if address has pending updateFlashblockconvenience methodshas_base_payload()- check if base payload is presentis_first_chunk()- check if this is index 0transaction_count()- get number of transactionshas_withdrawals()- check for withdrawal presenceTests
Motivation
These utilities reduce boilerplate when working with flashblock types and provide a consistent API for common validation patterns used throughout the codebase.