Skip to content

Import db check in round handler#7701

Merged
sstanculeanu merged 2 commits into
feat/supernova-async-execfrom
fix-supernova-activation-import-db
Feb 12, 2026
Merged

Import db check in round handler#7701
sstanculeanu merged 2 commits into
feat/supernova-async-execfrom
fix-supernova-activation-import-db

Conversation

@ssd04

@ssd04 ssd04 commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

Reasoning behind the pull request

  • When starting the node we have to determine if we start with supernova parameters in round handler or with initial params
  • This is done based on supernova activation time

Proposed changes

  • Added additional check to not consider supernova force activation at start if in import db mode

Testing procedure

  • ImportDB test

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 11, 2026
Comment on lines +499 to +500
log.Error("computeInflationBeforeSupernova: sub second round time before supernova activation")
roundDurationInSec = 1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

  • added special treatment to avoid divide by zero at any cost
  • this case should not happen, in case it happens it should be treated as an error and fixed

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.

for before Supernova, if we anyway set a default value, we might as well set it with 6s

@codecov

codecov Bot commented Feb 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 62.50000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.50%. Comparing base (7aaa1c9) to head (eb6d651).
⚠️ Report is 4 commits behind head on feat/supernova-async-exec.

Files with missing lines Patch % Lines
epochStart/metachain/economics.go 40.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@                      Coverage Diff                      @@
##           feat/supernova-async-exec    #7701      +/-   ##
=============================================================
- Coverage                      77.51%   77.50%   -0.02%     
=============================================================
  Files                            882      882              
  Lines                         122754   122760       +6     
=============================================================
- Hits                           95157    95139      -18     
- Misses                         21257    21279      +22     
- Partials                        6340     6342       +2     

☔ 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.

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 pull request addresses a critical issue in the round handler initialization where supernova parameters could be incorrectly activated when starting a node in ImportDB mode. The PR ensures that supernova activation based on time is skipped during database import, relying instead on explicit flag-based activation.

Changes:

  • Added ImportDBMode flag to round handler to prevent time-based supernova activation during database import
  • Added division-by-zero protection in economics calculation for sub-second round durations
  • Added comprehensive test coverage for ImportDB mode behavior with supernova activation

Reviewed changes

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

File Description
factory/core/coreComponents.go Passes ImportDBMode flag from core components to round handler initialization
epochStart/metachain/economics.go Adds safety check to prevent division by zero when round duration is sub-second
consensus/round/round_test.go Adds test case verifying supernova doesn't auto-activate in ImportDB mode
consensus/round/round.go Adds ImportDBMode field and logic to prevent time-based supernova force activation during DB import

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

roundDuration := 10 * time.Millisecond

supernovaRoundDuration := 5 * time.Millisecond
supernovaStartRond := int64(5)

Copilot AI Feb 12, 2026

Copy link

Choose a reason for hiding this comment

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

Variable name has a typo: "supernovaStartRond" should be "supernovaStartRound" (missing 'u' in 'Round'). This inconsistency appears throughout this test case and other test cases in this file.

Copilot uses AI. Check for mistakes.
Comment on lines +495 to +501
roundDurationInSec := e.roundTime.TimeDuration().Seconds()
if roundDurationInSec <= 0 {
// this means that round duration is sub-seconds
// set it to 1 second
log.Error("computeInflationBeforeSupernova: sub second round time before supernova activation")
roundDurationInSec = 1
}

Copilot AI Feb 12, 2026

Copy link

Choose a reason for hiding this comment

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

The division by zero protection added here lacks test coverage. While the fix is important for edge cases where round duration might be sub-second, there should be a test case that verifies this behavior, especially since the mock RoundTimeDurationHandler can return custom durations. Consider adding a test that sets roundTime.TimeDuration() to return a sub-second value (e.g., 500 microseconds) to ensure the error is logged and the fallback to 1 second works correctly.

Copilot uses AI. Check for mistakes.
@sstanculeanu sstanculeanu merged commit 862985f into feat/supernova-async-exec Feb 12, 2026
15 of 17 checks passed
@sstanculeanu sstanculeanu deleted the fix-supernova-activation-import-db branch February 12, 2026 08:48
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