Skip to content

MX-17468 Update sync speed for supernova#7670

Merged
sstanculeanu merged 2 commits into
feat/supernova-async-execfrom
last-executed-nonce-metrics
Feb 5, 2026
Merged

MX-17468 Update sync speed for supernova#7670
sstanculeanu merged 2 commits into
feat/supernova-async-execfrom
last-executed-nonce-metrics

Conversation

@mradian1

@mradian1 mradian1 commented Feb 5, 2026

Copy link
Copy Markdown

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?

@mradian1 mradian1 self-assigned this Feb 5, 2026

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 refactors the synchronization speed calculation logic for the supernova release. The implementation changes from storing speed deltas to storing absolute round numbers in the history, simplifying the calculation algorithm.

Changes:

  • Refactored CalculateSynchronizationSpeed to store absolute round numbers instead of speed deltas
  • Extracted speed calculation logic into a new helper method calculateSpeedFromSpeedHistory
  • Updated CalculateTimeToSynchronize to return "Estimating..." instead of empty string when speed is unknown
  • Updated test to reflect the new data structure (storing round numbers instead of deltas)

Reviewed changes

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

File Description
cmd/termui/presenter/chainInfoGetters.go Refactored synchronization speed calculation to use absolute round numbers and simplified the algorithm by extracting calculation logic into a new helper method
cmd/termui/presenter/chainInfoGetters_test.go Updated test setup to populate history with absolute round numbers instead of speed deltas

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

}
if cumulatedTime == 0 || numSyncedBlocks == 0 {

numSyncedBlocks := psh.synchronizationSpeedHistory[lastIndex] - psh.synchronizationSpeedHistory[firstIndex]

Copilot AI Feb 5, 2026

Copy link

Choose a reason for hiding this comment

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

Potential integer underflow issue: If the synchronized round goes backwards (e.g., during a blockchain rollback), this subtraction of uint64 values will underflow and wrap around to a very large positive number, causing incorrect speed calculations. The old implementation explicitly handled this case by checking if the difference was negative and setting it to 0. Consider adding a similar check here to handle the case where synchronizationSpeedHistory[lastIndex] < synchronizationSpeedHistory[firstIndex].

Suggested change
numSyncedBlocks := psh.synchronizationSpeedHistory[lastIndex] - psh.synchronizationSpeedHistory[firstIndex]
firstRound := psh.synchronizationSpeedHistory[firstIndex]
lastRound := psh.synchronizationSpeedHistory[lastIndex]
if lastRound < firstRound {
return 0
}
numSyncedBlocks := lastRound - firstRound

Copilot uses AI. Check for mistakes.
speed := (float64(numSyncedBlocks) / float64(cumulatedTimeMs)) * numMillisecondsInASecond

return uint64(speed)

Copilot AI Feb 5, 2026

Copy link

Choose a reason for hiding this comment

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

There is an extra blank line before the closing brace that is inconsistent with the rest of the functions in this file. Remove the blank line at line 132 for consistency.

Suggested change

Copilot uses AI. Check for mistakes.
@sstanculeanu sstanculeanu merged commit d3fde09 into feat/supernova-async-exec Feb 5, 2026
14 of 15 checks passed
@sstanculeanu sstanculeanu deleted the last-executed-nonce-metrics branch February 5, 2026 12:32
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