RevertCurrentBlock#7355
Conversation
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
| } | ||
|
|
||
| // RemoveFromHash will remove the execution result with the provided hash and all execution results with higher nonces | ||
| func (ert *executionResultsTracker) RemoveFromHash(hash []byte) error { |
There was a problem hiding this comment.
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.
| } | ||
| _, shouldIgnoreExecutionResultNonce := ert.noncesToRemoveOnAdd[executionResult.GetHeaderNonce()] | ||
| if shouldIgnoreExecutionResultNonce { | ||
| delete(ert.noncesToRemoveOnAdd, executionResult.GetHeaderNonce()) |
There was a problem hiding this comment.
can we make sure we are considering all registered nonces to remove ?
There was a problem hiding this comment.
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
RevertCurrentBlockinterface to accept aHeaderHandlerparameter - Added
RemoveFromNoncemethod to the execution results tracker - Added
RemoveAtNonceAndHighermethod 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 |
There was a problem hiding this comment.
Corrected spelling of 'thorough' to 'through'.
| // first search thorough pending execution results and remove it if already processed | |
| // first search through pending execution results and remove it if already processed |
| log.Error("revertCurrentBlockV3 RemoveFromNonce", "err", err) | ||
| return | ||
| } | ||
|
|
||
| err = bp.blocksQueue.RemoveAtNonceAndHigher(headerHandler.GetNonce()) | ||
| if err != nil { | ||
| log.Error("revertCurrentBlockV3 RemoveAtNonceAndHigher", "err", err) |
There was a problem hiding this comment.
Error logging should include the header nonce being reverted to aid debugging. Add 'nonce' field to both log.Error calls.
| 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()) |
| 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
good catch, updated
| return | ||
| } | ||
|
|
||
| err = bp.blocksQueue.RemoveAtNonceAndHigher(headerNonce) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
| return nil | ||
| } | ||
|
|
||
| bq.updateLastAddedNonceBasedOnRemovingNonce(nonce) |
There was a problem hiding this comment.
I don't think this should update, as you are also returning error.
| ert.hashToRemoveOnAdd = hash | ||
| return nil | ||
| } | ||
| return ert.removePendingFromNonceUnprotected(nonce) |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
might need to get the prevHash as well.
|
The TODO will be taken on a different PR, which will add also a manager component, to handle the three subcomponents consistently. |
There was a problem hiding this comment.
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
AddExecutionResultfails, the error is logged butnilis 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 inhandleProcessError, 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.
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:
featbranch created?featbranch merging, do all satellite projects have a proper tag insidego.mod?