Skip to content

add guard to avoid underflow and deleting needed nodesConfig#7908

Merged
AdoAdoAdo merged 2 commits into
feat/testnet-fixesfrom
nodes-coordinator-underflow-fix
Jul 9, 2026
Merged

add guard to avoid underflow and deleting needed nodesConfig#7908
AdoAdoAdo merged 2 commits into
feat/testnet-fixesfrom
nodes-coordinator-underflow-fix

Conversation

@BeniaminDrasovean

Copy link
Copy Markdown
Contributor

Reasoning behind the pull request

Proposed changes

Testing procedure

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?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR prevents an unsigned integer underflow in removeOlderEpochs when epoch < maxDelta, which previously could cause unintended deletion of nodesConfig entries. It also adds focused unit tests to lock in the expected retention behavior for early epochs and normal pruning.

Changes:

  • Added a guard in removeOlderEpochs to avoid epoch - maxDelta underflow and to prevent erroneous deletions.
  • Refactored the deletion threshold into an epochToRemove variable for clarity.
  • Added unit tests covering the “epoch < maxDelta” no-op case and the normal “remove only older epochs” case.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
sharding/nodesCoordinator/indexHashedNodesCoordinatorLite.go Adds an early return to avoid underflow and uses a precomputed epochToRemove for correct pruning.
sharding/nodesCoordinator/indexHashedNodesCoordinatorLite_test.go Adds tests validating no removals for early epochs and correct removal of only the oldest epoch once the delta threshold is reached.

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

@AdoAdoAdo AdoAdoAdo merged commit 88ee526 into feat/testnet-fixes Jul 9, 2026
9 checks passed
@AdoAdoAdo AdoAdoAdo deleted the nodes-coordinator-underflow-fix branch July 9, 2026 09:42
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.70%. Comparing base (a1cc8c6) to head (57bfb43).
⚠️ Report is 3 commits behind head on feat/testnet-fixes.

Additional details and impacted files
@@                 Coverage Diff                 @@
##           feat/testnet-fixes    #7908   +/-   ##
===================================================
  Coverage               77.69%   77.70%           
===================================================
  Files                     885      885           
  Lines                  126020   126023    +3     
===================================================
+ Hits                    97914    97921    +7     
+ Misses                  21626    21624    -2     
+ Partials                 6480     6478    -2     

☔ View full report in Codecov by Harness.
📢 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.

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.

4 participants