Skip to content

Block size proposal limit checks#7661

Merged
ssd04 merged 30 commits intofeat/supernova-async-execfrom
size-limit-block-proposal
Feb 10, 2026
Merged

Block size proposal limit checks#7661
ssd04 merged 30 commits intofeat/supernova-async-execfrom
size-limit-block-proposal

Conversation

@ssd04
Copy link
Contributor

@ssd04 ssd04 commented Feb 2, 2026

Reasoning behind the pull request

  • Update block size computation component to handle also execution results size
  • Added limit config field for execution results
  • Added block size limit checks in gasComputation component

Testing procedure

  • System test with txs over limit

Pre-requisites

Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:

  • was the PR targeted to the correct branch?
  • if this is a larger feature that probably needs more than one PR, is there a feat branch created?
  • if this is a feat branch merging, do all satellite projects have a proper tag inside go.mod?

@ssd04 ssd04 self-assigned this Feb 2, 2026
@ssd04 ssd04 marked this pull request as ready for review February 3, 2026 11:11
return lastMiniBlockIndex, 0, err
}

gc.blockSizeComputation.AddNumMiniBlocks(1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be added also inside the if from L137, for rewards and peer changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was thinking initially that these miniblocks has to be included anyway, added increase limits though

return lastMiniBlockIndex, 0, nil
}

func (gc *gasConsumption) increaseBlockSizeLimits(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated to use it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe rename it to something like addMiniBlockToBlockSizeComputation or similar?

doubleTransactionsDetector process.DoubleTransactionDetector
processedMiniBlocksTracker process.ProcessedMiniBlocksTracker
enableEpochsHandler common.EnableEpochsHandler
enableRoundsHandler common.EnableRoundsHandler
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it was part of the old code, removed

break
}

gc.blockSizeComputation.AddNumMiniBlocks(1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move this inside if !mbsLimitReached, at L296. This way blockSizeComputation gets updated when miniblocks are added via direct call on AddIncomingMiniBlocks, but also when appending pending ones.

and remove it from L157 this way

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, pushed

@ssd04 ssd04 changed the title block proposal size limit - init checks Block size proposal limit checks Feb 3, 2026
sstanculeanu
sstanculeanu previously approved these changes Feb 5, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds block size limit checks for execution results to complement existing gas-based limits. It updates the block size computation component to track execution result sizes and enforces these limits during block proposal creation.

Changes:

  • Moved LastExecutionResultForInclusion from process/estimator to common package for better code organization
  • Extended BlockSizeComputationHandler interface with execution result tracking methods (AddNumExecRes, DecNumExecRes, IsMaxExecResSizeReached)
  • Added MaxExecResSizeInBytes configuration field to BlockSizeThrottleConfig with default value of 10% of 1MB
  • Integrated execution result size checks in ExecutionResultInclusionEstimator and gasConsumption components
  • Updated all test files and integration tests to use the new constructor signatures

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
config/config.go Added MaxExecResSizeInBytes field to BlockSizeThrottleConfig
cmd/node/config/config.toml Added configuration value for execution result size limit
common/dtos.go Moved LastExecutionResultForInclusion struct from estimator package
process/interface.go Updated InclusionEstimator interface signature to use common.LastExecutionResultForInclusion
process/block/preprocess/interfaces.go Extended BlockSizeComputationHandler interface with execution result methods
process/block/preprocess/blockSizeComputation.go Implemented execution result size tracking and limit checking
process/block/preprocess/blockSizeComputation_test.go Added tests for execution result size computation methods
process/estimator/executionResultInclusionEstimator.go Integrated blockSizeComputation for execution result size checks
process/estimator/executionResultInclusionEstimator_test.go Updated tests to pass blockSizeComputation parameter
process/block/gasConsumption.go Added block size limit checks alongside gas limit checks
process/block/gasConsumption_test.go Updated test arguments with blockSizeComputation
testscommon/blockSizeComputationStub.go Extended stub with execution result methods
testscommon/generalConfig.go Added test configuration for new limits
genesis/process/disabled/blockSizeComputationHandler.go Added no-op implementations for new methods
factory/processing/blockProcessorCreator.go Updated block processor creation to pass MaxExecResSizeInBytes
Multiple test files Updated to use new constructor signatures and pass blockSizeComputation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 172 to 177
if erie.blockSizeComputation.IsMaxExecResSizeReached(1) {
log.Debug("ExecutionResultInclusionEstimator: estimated max size reached",
"currentIndex", pendingExecutionIndex)
return pendingExecutionIndex
}
erie.blockSizeComputation.AddNumExecRes(1)
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new execution result size limit functionality (IsMaxExecResSizeReached check at line 172) is not covered by any tests. All tests in this file use BlockSizeComputationStub which returns false by default. Consider adding test cases that verify the behavior when the execution result size limit is reached, similar to how MaxResultsPerBlock is tested.

Copilot uses AI. Check for mistakes.
Comment on lines 172 to 177
if erie.blockSizeComputation.IsMaxExecResSizeReached(1) {
log.Debug("ExecutionResultInclusionEstimator: estimated max size reached",
"currentIndex", pendingExecutionIndex)
return pendingExecutionIndex
}
erie.blockSizeComputation.AddNumExecRes(1)
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ExecutionResultInclusionEstimator's Decide method mutates the blockSizeComputation state by calling AddNumExecRes. This is problematic because Decide is called both during block proposal creation (in addExecutionResultsOnHeader) and during block verification (in checkInclusionEstimationForExecutionResults). During verification, we should not mutate shared state as multiple verifications might be happening concurrently, or a verification might interfere with proposal creation. Consider either: 1) making the size check read-only in the estimator and moving the mutation to the caller, or 2) using a separate blockSizeComputation instance for verification vs proposal.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will add a separate check flow for this case, will trigger calculation encapsulated in this call

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated to trigger calculation separately on each call

roundHandler RoundHandler
// TODO add also max estimated block gas capacity - used gas must be lower than this
blockSizeComputation blockSizeComputationHandler
// blockSizeComputation blockSizeComputationHandler
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

}

var err error
ers.execResSize, err = ers.generateDummyExecutionResultSize(marshalizer, 10)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 10?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i kept the same estimation as for block, as in blockSizeComputation - currently i think on shard we have up to 5 miniblocks and on meta up to 9

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be discussed, there is also the TODO with the option to have a size estimation calculated dynamically based on real time data, in case we'll have more shards in the future

[BlockSizeThrottleConfig]
MinSizeInBytes = 104857 # 104857 is 10% from 1MB
MaxSizeInBytes = 943718 # 943718 is 90% from 1MB
MaxExecResSizeInBytes = 104857 # 104857 is 10% from 1MB
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the average size of an execution result? I am curious what would this limitation mean in concrete number of execution results

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this limit will allow up to 200 execution results

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is based on the dummy created execution results with 10 miniblocks

dummyHash := make([]byte, 32)
_, _ = rand.Reader.Read(dummyHash)

executionResult := &block.ExecutionResult{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use a meta excution result instead? I think that one has more fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to use meta

return ers, nil
}

func (ers *execResSizeComputation) generateDummyExecutionResultSize(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you generate the size estimation based on the larger result? (I think the metachain result is larger).

@codecov
Copy link

codecov bot commented Feb 9, 2026

Codecov Report

❌ Patch coverage is 79.57447% with 48 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.51%. Comparing base (0a9b44a) to head (13a1de8).
⚠️ Report is 31 commits behind head on feat/supernova-async-exec.

Files with missing lines Patch % Lines
factory/processing/blockProcessorCreator.go 66.66% 6 Missing and 6 partials ⚠️
...ess/estimator/executionResultInclusionEstimator.go 61.90% 5 Missing and 3 partials ⚠️
...rocess/estimator/executionResultSizeComputation.go 87.50% 4 Missing and 2 partials ⚠️
process/block/gasConsumption.go 84.61% 2 Missing and 2 partials ⚠️
process/block/preprocess/basePreProcess.go 75.00% 4 Missing ⚠️
process/block/preprocess/miniBlockBuilder.go 78.94% 2 Missing and 2 partials ⚠️
process/block/preprocess/transactions.go 66.66% 2 Missing and 1 partial ⚠️
process/block/preprocess/blockSizeComputation.go 91.30% 1 Missing and 1 partial ⚠️
process/estimator/executionResultSizeChecker.go 83.33% 2 Missing ⚠️
process/block/preprocess/rewardTxPreProcessor.go 66.66% 0 Missing and 1 partial ⚠️
... and 2 more
Additional details and impacted files
@@                      Coverage Diff                      @@
##           feat/supernova-async-exec    #7661      +/-   ##
=============================================================
- Coverage                      77.51%   77.51%   -0.01%     
=============================================================
  Files                            880      882       +2     
  Lines                         122576   122753     +177     
=============================================================
+ Hits                           95016    95146     +130     
- Misses                         21233    21263      +30     
- Partials                        6327     6344      +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

sstanculeanu
sstanculeanu previously approved these changes Feb 9, 2026
AdoAdoAdo
AdoAdoAdo previously approved these changes Feb 9, 2026

// DecNumMiniBlocks decrements the provided value to numMiniBlocks in a concurrent safe manner
func (bsc *blockSizeComputation) DecNumMiniBlocks(numMiniBlocks int) {
atomic.AddInt32(&bsc.numMiniBlocks, -int32(numMiniBlocks))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prevent going below 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added check


// DecNumTxs decrements the provided value to numTxs in a concurrent safe manner
func (bsc *blockSizeComputation) DecNumTxs(numTxs int) {
atomic.AddInt32(&bsc.numTxs, -int32(numTxs))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prevent going below 0 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added check

GasUsed: 1234,
},
ValidatorStatsRootHash: dummyHash,
AccumulatedFeesInEpoch: big.NewInt(0),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe have larger values for the bigints, fully denominated egld values

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated to use bigger values

mbType := miniBlocks[i].GetTypeInt32()
if mbType == int32(block.RewardsBlock) || mbType == int32(block.PeerBlock) {
// rewards and validator info have 0 gas limit, thus they should be included anyway without checking their transactions
gc.addMiniBlockToBlockSizeComputation(miniBlocks[i])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like there is no check for the peer + rewards mbs, if we have reached the size limit before adding more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no check on gas consumption, so did not add for size limit; they are counted for size but with no check

@ssd04 ssd04 dismissed stale reviews from AdoAdoAdo and sstanculeanu via 9b34e42 February 10, 2026 11:24
@ssd04 ssd04 merged commit 0d8b216 into feat/supernova-async-exec Feb 10, 2026
9 checks passed
@ssd04 ssd04 deleted the size-limit-block-proposal branch February 10, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants