Skip to content

RevertCurrentBlock#7355

Merged
AdoAdoAdo merged 30 commits into
feat/supernova-async-execfrom
revert-current-block
Nov 1, 2025
Merged

RevertCurrentBlock#7355
AdoAdoAdo merged 30 commits into
feat/supernova-async-execfrom
revert-current-block

Conversation

@sstanculeanu

Copy link
Copy Markdown
Collaborator

Reasoning behind the pull request

  • RevertCurrentBlock should update also the execution tracker
  • as for the blocks queue, AddOrReplace method should be able to replace all headers on top of a specific nonce

Proposed changes

  • updated blocksQeueu.AddOrReplace
  • added a new method executionResultsTracker.RemoveFromHash

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?

@codecov

codecov Bot commented Oct 20, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.48819% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.31%. Comparing base (129c05f) to head (857919f).
⚠️ Report is 32 commits behind head on feat/supernova-async-exec.

Files with missing lines Patch % Lines
...xecution/executionTrack/executionResultsTracker.go 80.95% 2 Missing and 2 partials ⚠️
process/asyncExecution/queue/blocksQueue.go 95.23% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@                      Coverage Diff                      @@
##           feat/supernova-async-exec    #7355      +/-   ##
=============================================================
+ Coverage                      77.28%   77.31%   +0.02%     
=============================================================
  Files                            867      867              
  Lines                         116704   116789      +85     
=============================================================
+ Hits                           90193    90292      +99     
+ Misses                         20559    20548      -11     
+ Partials                        5952     5949       -3     

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

ssd04
ssd04 previously approved these changes Oct 21, 2025
Comment thread process/block/baseProcess.go Outdated
Comment thread process/block/baseProcess.go Outdated
Comment thread process/block/baseProcess.go Outdated
Comment thread process/asyncExecution/executionTrack/executionResultsTracker.go Outdated
Comment thread process/asyncExecution/queue/blocksQueue.go Outdated
}

// RemoveFromHash will remove the execution result with the provided hash and all execution results with higher nonces
func (ert *executionResultsTracker) RemoveFromHash(hash []byte) error {

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.

can you check if it is possible to give also the Nonce?
at line 331 if we cannot find the hash, any on-top results would not be cleaned.

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.

updated

}
_, shouldIgnoreExecutionResultNonce := ert.noncesToRemoveOnAdd[executionResult.GetHeaderNonce()]
if shouldIgnoreExecutionResultNonce {
delete(ert.noncesToRemoveOnAdd, executionResult.GetHeaderNonce())

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.

can we make sure we are considering all registered nonces to remove ?

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.

updated

@AdoAdoAdo AdoAdoAdo requested a review from Copilot October 28, 2025 13:22

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 enhances the RevertCurrentBlock functionality to properly clean up the execution tracker and blocks queue when reverting blocks. The key changes ensure that when a block processing fails and needs to be reverted, both the execution results tracker and the blocks queue are updated to maintain consistency.

Key Changes:

  • Modified RevertCurrentBlock interface to accept a HeaderHandler parameter
  • Added RemoveFromNonce method to the execution results tracker
  • Added RemoveAtNonceAndHigher method and eviction subscriber support to the blocks queue
  • Integrated blocks queue eviction notifications with the execution results tracker

Reviewed Changes

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

Show a summary per file
File Description
process/interface.go Updated BlockProcessor and related interfaces with new method signatures
process/block/baseProcess.go Implemented revertCurrentBlockV3 logic to clean up tracker and queue
process/asyncExecution/queue/blocksQueue.go Added removal methods and eviction subscriber support
process/asyncExecution/executionTrack/executionResultsTracker.go Added RemoveFromNonce and OnHeaderEvicted methods
factory/processing/*.go Updated factory code to wire up eviction subscriptions
testscommon/* Updated mocks to match new interfaces
integrationTests/* Updated test initialization to register eviction subscribers

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

ert.mutex.Lock()
defer ert.mutex.Unlock()

// first search thorough pending execution results and remove it if already processed

Copilot AI Oct 28, 2025

Copy link

Choose a reason for hiding this comment

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

Corrected spelling of 'thorough' to 'through'.

Suggested change
// first search thorough pending execution results and remove it if already processed
// first search through pending execution results and remove it if already processed

Copilot uses AI. Check for mistakes.
Comment thread process/block/baseProcess.go Outdated
Comment on lines +1740 to +1746
log.Error("revertCurrentBlockV3 RemoveFromNonce", "err", err)
return
}

err = bp.blocksQueue.RemoveAtNonceAndHigher(headerHandler.GetNonce())
if err != nil {
log.Error("revertCurrentBlockV3 RemoveAtNonceAndHigher", "err", err)

Copilot AI Oct 28, 2025

Copy link

Choose a reason for hiding this comment

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

Error logging should include the header nonce being reverted to aid debugging. Add 'nonce' field to both log.Error calls.

Suggested change
log.Error("revertCurrentBlockV3 RemoveFromNonce", "err", err)
return
}
err = bp.blocksQueue.RemoveAtNonceAndHigher(headerHandler.GetNonce())
if err != nil {
log.Error("revertCurrentBlockV3 RemoveAtNonceAndHigher", "err", err)
log.Error("revertCurrentBlockV3 RemoveFromNonce", "err", err, "nonce", headerHandler.GetNonce())
return
}
err = bp.blocksQueue.RemoveAtNonceAndHigher(headerHandler.GetNonce())
if err != nil {
log.Error("revertCurrentBlockV3 RemoveAtNonceAndHigher", "err", err, "nonce", headerHandler.GetNonce())

Copilot uses AI. Check for mistakes.
Comment on lines +195 to +204
if indexToRemove == 0 {
// removing from the beginning, clear the entire queue
bq.headerBodyPairs = make([]HeaderBodyPair, 0)
if nonce > 0 {
bq.lastAddedNonce = nonce - 1
return nil
}

bq.lastAddedNonce = 0
return nil

Copilot AI Oct 28, 2025

Copy link

Choose a reason for hiding this comment

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

When removing from the beginning (indexToRemove == 0), eviction notifications are not sent for the removed pairs. This is inconsistent with the behavior at line 211 where notifyEvictedPairs is called. Consider notifying subscribers before clearing the queue to maintain consistent behavior.

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.

good catch, updated

miiu96
miiu96 previously approved these changes Oct 28, 2025
Comment thread process/interface.go
Comment thread process/block/baseProcess.go Outdated
return
}

err = bp.blocksQueue.RemoveAtNonceAndHigher(headerNonce)

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.

is it still needed then to have the execution results tracker subscribed to the evictions from the blocks queue if we call remove on both here?

I think it should not be needed, or am I missing something?

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.

as blocksQueue.AddOrReaplace is now able to replace an intermediat nonce and remove all the above ones, I think the subscriber mechanism can be kept

removed the call to executionResultsTracker from the above though, as it will be done internally through notification

}

// RegisterEvictionSubscriber registers a new eviction subscriber
func (bq *blocksQueue) RegisterEvictionSubscriber(subscriber BlocksQueueEvictionSubscriber) {

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.

is this still needed?

ssd04
ssd04 previously approved these changes Oct 29, 2025
Comment thread process/asyncExecution/queue/blocksQueue.go Outdated
@AdoAdoAdo AdoAdoAdo requested a review from Copilot October 31, 2025 08:59

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 37 out of 37 changed files in this pull request and generated 4 comments.


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

Comment thread process/asyncExecution/queue/blocksQueue.go Outdated
Comment thread process/asyncExecution/queue/blocksQueue.go Outdated
Comment thread process/asyncExecution/queue/blocksQueue.go Outdated
Comment thread process/asyncExecution/executionTrack/executionResultsTracker.go Outdated
Comment thread process/asyncExecution/queue/blocksQueue.go Outdated
return nil
}

bq.updateLastAddedNonceBasedOnRemovingNonce(nonce)

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.

I don't think this should update, as you are also returning error.

ert.hashToRemoveOnAdd = hash
return nil
}
return ert.removePendingFromNonceUnprotected(nonce)

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.

I think this does not finish the cleanup, as the lastExecutedResultHash is not set correctly.
Maybe give on RemoveFromNonce the previousHash if this blockNonce, so that it is set on lastExecutedResultHash?

}

// OnHeaderEvicted is a callback called when a header is removed from the execution queue
func (ert *executionResultsTracker) OnHeaderEvicted(headerNonce uint64) {

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.

I think this also needs to give the hash of the previous block (previous to the header with the nonce to be removed) so that it is set as the last

return pairsToBeRemoved, firstIndex
}

func (bq *blocksQueue) removeFromNonce(nonce uint64) {

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.

this might need to receive the hash of the previous block, to notify the subscribers


// RemoveAtNonceAndHigher removes the header-body pair at the specified nonce
// and all pairs with higher nonces from the queue
func (bq *blocksQueue) RemoveAtNonceAndHigher(nonce uint64) {

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.

might need to get the prevHash as well.

@AdoAdoAdo

Copy link
Copy Markdown
Contributor

The TODO will be taken on a different PR, which will add also a manager component, to handle the three subcomponents consistently.
Then the left comments should be solved as well.

@AdoAdoAdo AdoAdoAdo requested a review from Copilot October 31, 2025 13:34

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 38 out of 38 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

process/asyncExecution/headersExecutor.go:126

  • When AddExecutionResult fails, the error is logged but nil is returned. This means the processing is marked as successful even though the execution result was not saved. This should return the error to trigger retry logic in handleProcessError, otherwise the result will be lost permanently.
	err = he.executionTracker.AddExecutionResult(executionResult)
	if err != nil {
		log.Warn("headersExecutor.process add execution result failed", "err", err)
		return nil

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

Comment thread process/asyncExecution/queue/blocksQueue.go
Comment thread process/block/shardblockProposal.go
@AdoAdoAdo AdoAdoAdo merged commit b47470c into feat/supernova-async-exec Nov 1, 2025
11 checks passed
@AdoAdoAdo AdoAdoAdo deleted the revert-current-block branch November 1, 2025 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants