feat: add configurable maximum flashblocks per block cap (default 10) #280
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
Adds a configurable maximum limit for the number of flashblocks that can be produced per block, ensures the maximum cannot exceed configured value.
💡 Motivation and Context
The flashblock count was previously determined purely by timing calculations (
block_time / flashblock_interval
), which doesn't prevent the count go over 10 when using flashblock_interval < 200 for a 2s block time chain.By capping the flashblocks it adds another layer of insurance that it won't lead to accidental unwanted behaviors in terms of the number of flashblocks
Changes
--flashblocks.max-per-block
with default value of 10FLASHBLOCKS_MAX_PER_BLOCK
supportmax_flashblocks_per_block
field toFlashblocksConfig
flashblocks_per_block()
methodImplementation Details
The cap is applied in two places:
FlashBlocksConfigExt::flashblocks_per_block()
- handles fixed timing modecalculate_flashblocks()
- handles dynamic timing mode calculationsThis approach ensures consistent behavior across both modes without restructuring the existing timing logic.
Testing