Skip to content

Get fees from the previous header of epoch change proposed for metrics#7654

Merged
sstanculeanu merged 25 commits into
feat/supernova-async-execfrom
get-metrics-from-prev-of-epoch-change-proposed
Feb 4, 2026
Merged

Get fees from the previous header of epoch change proposed for metrics#7654
sstanculeanu merged 25 commits into
feat/supernova-async-execfrom
get-metrics-from-prev-of-epoch-change-proposed

Conversation

@sstanculeanu

Copy link
Copy Markdown
Collaborator

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?

@sstanculeanu sstanculeanu self-assigned this Jan 30, 2026
@sstanculeanu sstanculeanu added the type:bug Something isn't working label Jan 30, 2026
Comment thread process/block/baseProcess.go
Comment thread process/block/metablockProposal.go Outdated
Comment thread process/block/shardblockProposal.go
@AdoAdoAdo AdoAdoAdo mentioned this pull request Feb 2, 2026
@AdoAdoAdo AdoAdoAdo changed the base branch from MX-17438-fix-end-of-epoch-rewards-metric to feat/supernova-async-exec February 2, 2026 13:19
@codecov

codecov Bot commented Feb 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 36.58537% with 52 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.56%. Comparing base (c635e8b) to head (f9e5790).

Files with missing lines Patch % Lines
epochStart/bootstrap/process.go 35.71% 25 Missing and 2 partials ⚠️
process/block/baseProcess.go 45.45% 10 Missing and 2 partials ⚠️
process/block/shardblockProposal.go 15.38% 10 Missing and 1 partial ⚠️
process/block/metablock.go 66.66% 1 Missing ⚠️
process/block/shardblock.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                      Coverage Diff                      @@
##           feat/supernova-async-exec    #7654      +/-   ##
=============================================================
- Coverage                      77.59%   77.56%   -0.04%     
=============================================================
  Files                            877      877              
  Lines                         121752   121784      +32     
=============================================================
- Hits                           94476    94458      -18     
- Misses                         21008    21051      +43     
- Partials                        6268     6275       +7     

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

Comment thread epochStart/bootstrap/process.go
Comment thread process/block/metablockProposal.go Outdated
Comment thread process/block/shardblockProposal.go
Comment thread process/block/shardblockProposal.go
Comment thread epochStart/bootstrap/process.go Outdated
Comment thread epochStart/bootstrap/process.go Outdated
prevHashOfEpochChangeProposed []byte,
executionResults []data.BaseExecutionResultHandler,
) {
) bool {

@AdoAdoAdo AdoAdoAdo Feb 3, 2026

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 accumulated fees we need the execution result that has GetHeaderHash equal to the prevHash of epoch change propose block.

Comment thread epochStart/bootstrap/process.go

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 refactors how economics metrics (accumulated fees and dev rewards) are retrieved for epoch changes in v3 headers (Supernova activation). Instead of getting fees from the last execution result of an epoch start block, the code now gets fees from the execution result of the previous header of the epoch change proposed block.

Changes:

  • Refactored metrics collection logic to fetch fees from the previous header of epoch change proposed blocks for v3 headers
  • Moved and split the saveEpochStartEconomicsMetrics function from common package to baseProcessor, with specialized handling for v3 headers
  • Removed obsolete helper functions GetAccumulatedFeesInEpoch and GetDeveloperFeesInEpoch from the common package along with their tests

Reviewed changes

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

Show a summary per file
File Description
process/block/shardblockProposal.go Added saveEpochStartEconomicsIfNeeded and setEpochStartMetricsV3FromExecutionResults methods to handle fee metrics for shard processors
process/block/shardblock.go Updated call to use instance method instead of package-level function
process/block/metrics.go Removed obsolete saveEpochStartEconomicsMetrics function
process/block/metablockProposal.go Added saveEpochStartEconomicsMetricsV3IfNeeded to set fee metrics when processing epoch change proposed blocks
process/block/metablock.go Updated calls to use instance method instead of package-level function
process/block/baseProcess.go Added saveEpochStartEconomicsMetrics method with v3-aware logic
node/chainSimulator/chainSimulator_test.go Added integration test to verify economics metrics are properly set across epochs
epochStart/bootstrap/process.go Refactored metrics setting logic for bootstrap with v3-specific handling, improved syncing logic for intermediate blocks
common/common_test.go Removed tests for deleted helper functions
common/common.go Removed obsolete helper functions that were replaced by new implementation

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

Comment thread process/block/shardblockProposal.go
Comment thread process/block/shardblockProposal.go Outdated
Comment thread process/block/metablockProposal.go Outdated
Comment thread node/chainSimulator/chainSimulator_test.go Outdated
Comment thread process/block/shardblockProposal.go Outdated
AdoAdoAdo
AdoAdoAdo previously approved these changes Feb 3, 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

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


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

Comment on lines +979 to +993
for currentNonce > metaEpochChangeProposedHeader.GetNonce() {
intermHeader, err := sp.getHeaderFromHash(true, currentHash, core.MetachainShardId)
if err != nil {
// if a header is not found, return here to close the loop. should no be blocking
return
}
currentNonce = intermHeader.GetNonce()

updatedMetrics := sp.saveEconomicsMetricFromExecutionResults(intermHeader.GetExecutionResultsHandlers(), metaEpochChangeProposedHeader.GetPrevHash())
if updatedMetrics {
return
}

currentHash = intermHeader.GetPrevHash()
}

Copilot AI Feb 3, 2026

Copy link

Choose a reason for hiding this comment

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

Potential infinite loop detected in the loop logic. The loop condition checks if currentNonce > metaEpochChangeProposedHeader.GetNonce(), and inside the loop, currentNonce is updated with intermHeader.GetNonce(). However, if the intermHeader has the same or higher nonce as the current value (which could happen if getHeaderFromHash retrieves an unexpected header or if there's a chain inconsistency), the loop will never terminate. Consider adding a safeguard to ensure forward progress, such as checking that the new nonce is strictly less than the current nonce before updating, or adding a maximum iteration counter.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

this should not happen

Comment thread process/block/shardblockProposal.go Outdated
axenteoctavian
axenteoctavian previously approved these changes Feb 3, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@sstanculeanu sstanculeanu dismissed stale reviews from axenteoctavian and AdoAdoAdo via 41133ca February 3, 2026 14:47
@sstanculeanu sstanculeanu merged commit 77f5559 into feat/supernova-async-exec Feb 4, 2026
8 of 9 checks passed
@sstanculeanu sstanculeanu deleted the get-metrics-from-prev-of-epoch-change-proposed branch February 4, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants