Skip to content

Conversation

@sstanculeanu
Copy link
Collaborator

Reasoning behind the pull request

  • a huge nonce gap porposed can lead to a higher number of requests

Proposed changes

  • added validation on both proposal and verification to not allow a higher nonce gap than a configured value

Testing procedure

  • with feat branch

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?

@sstanculeanu sstanculeanu self-assigned this Feb 10, 2026
@codecov
Copy link

codecov bot commented Feb 10, 2026

Codecov Report

❌ Patch coverage is 94.73684% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.53%. Comparing base (3ce7096) to head (7347a19).
⚠️ Report is 2 commits behind head on ai-audit-findings.

Files with missing lines Patch % Lines
process/block/metablock.go 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@                  Coverage Diff                  @@
##           ai-audit-findings    #7693      +/-   ##
=====================================================
- Coverage              77.53%   77.53%   -0.01%     
=====================================================
  Files                    878      878              
  Lines                 122173   122211      +38     
=====================================================
+ Hits                   94728    94753      +25     
- Misses                 21135    21143       +8     
- Partials                6310     6315       +5     

☔ 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 changed the base branch from feat/supernova-async-exec to ai-audit-findings February 10, 2026 13:15
@AdoAdoAdo AdoAdoAdo requested a review from Copilot February 10, 2026 13:25
return execResult, nil
}

func (mp *metaProcessor) checkShardInfoProposalNonceGap(metaHeader data.MetaHeaderHandler) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

the check needs to be enforced not only on shardInfo by metachain, but also for metablock and its last executed result notarization, or on shard chain between the block header and its last executed result notarization.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

pushed

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

Adds a configurable upper bound for the shard-info proposal nonce gap to prevent unbounded “nonce-gap” missing-data requests before a metablock proposal is fully validated (HIGH-003).

Changes:

  • Introduces MaxShardInfoProposalNonceGap config/plumbing (config struct, TOML, factory wiring, test configs).
  • Adds nonce-gap validation for metablock proposal creation and verification, plus a new ErrNonceGapTooLarge.
  • Extends unit tests and stubs to cover the new behavior.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
testscommon/headerHandlerStub.go Implements GetShardInfoHandlers() for tests via a callback + safe default.
testscommon/generalConfig.go Sets a default MaxShardInfoProposalNonceGap in the shared test config.
testscommon/components/configs.go Sets MaxShardInfoProposalNonceGap in component test config.
process/errors.go Adds ErrNonceGapTooLarge error sentinel.
process/block/metablock_test.go Updates meta processor test args with MaxShardInfoProposalNonceGap.
process/block/metablockProposal_test.go Adds coverage for nonce-gap validation on propose/verify paths.
process/block/metablockProposal.go Adds nonce-gap validation calls and implements checkShardInfoProposalNonceGap.
process/block/metablock.go Stores max-gap in metaProcessor and applies a default when unset.
process/block/argProcessor.go Adds MaxShardInfoProposalNonceGap to ArgMetaProcessor.
factory/processing/blockProcessorCreator.go Wires config value into ArgMetaProcessor.
config/config.go Adds MaxShardInfoProposalNonceGap to GeneralSettingsConfig.
cmd/node/config/config.toml Documents/exposes MaxShardInfoProposalNonceGap in node config.

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

Comment on lines 61 to 65
err = mp.checkShardInfoProposalNonceGap(metaHeader)
if err != nil {
return nil, err
}

Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

The nonce-gap validation is invoked in CreateNewHeaderProposal(), but at this stage the metablock’s ShardInfo/ShardInfoProposal handlers are typically not populated yet (they get set later during CreateBlockProposal). This means the "proposal"-side validation may be ineffective and large nonce gaps could still be produced locally. Consider moving (or additionally adding) this check after shard info/proposals are set on the header in the proposal-building flow, keeping VerifyBlockProposal as the inbound guard.

Suggested change
err = mp.checkShardInfoProposalNonceGap(metaHeader)
if err != nil {
return nil, err
}

Copilot uses AI. Check for mistakes.
// No finalized data for this shard, skip validation
continue
}

Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

checkShardInfoProposalNonceGap() computes nonceGap := maxProposedNonce - lastFinalizedNonce using uint64. If a block contains a proposed nonce lower than the finalized nonce for the same shard, this will underflow and produce a huge gap value, leading to a confusing error and potentially rejecting cases that should be treated as "no gap" or as a distinct validation error. Add an explicit comparison (e.g., handle maxProposedNonce <= lastFinalizedNonce) before subtracting.

Suggested change
// Handle cases where proposed nonce is not ahead of the finalized nonce
if maxProposedNonce <= lastFinalizedNonce {
if maxProposedNonce < lastFinalizedNonce {
return fmt.Errorf("%w: shard %d has proposed nonce %d lower than finalized nonce %d",
process.ErrNonceGapTooLarge,
shardID,
maxProposedNonce,
lastFinalizedNonce)
}
// maxProposedNonce == lastFinalizedNonce: no gap to check
continue
}

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

Choose a reason for hiding this comment

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

fixed

# Make sure that this is greater than the unbonding period!
SetGuardianEpochsDelay = 2 # TODO: for mainnet should be 20, 2 is just for testing

# MaxShardInfoProposalNonceGap defines the maximum gap allowed between highest finalized shard nonce and lowest proposed shard nonce
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

The TOML comment says the gap is measured between the "highest finalized" and the "lowest proposed" shard nonce, but the implementation validates against the highest proposed nonce per shard. Please update this comment to match the actual behavior to avoid operator/config confusion.

Suggested change
# MaxShardInfoProposalNonceGap defines the maximum gap allowed between highest finalized shard nonce and lowest proposed shard nonce
# MaxShardInfoProposalNonceGap defines the maximum gap allowed between the highest finalized shard nonce
# and the highest proposed shard nonce per shard

Copilot uses AI. Check for mistakes.
…chain-go into ai-findings-high-003

# Conflicts:
#	factory/processing/blockProcessorCreator.go
#	process/block/argProcessor.go
#	process/block/baseProcess.go
#	process/block/baseProcess_test.go
#	process/block/metablock_test.go
#	process/errors.go
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.

2 participants