Skip to content

Conversation

@AdoAdoAdo
Copy link
Contributor

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?

Copy link
Contributor

Copilot AI left a comment

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 fixes issues with the execution queue's Add and Pop operations, addressing concurrency problems and improving error handling in the async execution system.

Key Changes

  • Fixed the Pop() method condition from > 1 to >= 1 to correctly handle single-item queues
  • Updated AddOrReplace notification logic to only notify when the first item is added to an empty queue
  • Added ValidateQueueIntegrity() method for periodic queue health checks
  • Improved error handling with proper error propagation and retry logic with exponential backoff
  • Enhanced error handling in baseSync.go using errors.Is() instead of direct comparison

Reviewed changes

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

Show a summary per file
File Description
process/asyncExecution/queue/blocksQueue.go Fixed Pop() condition bug, restructured notification logic, added ValidateQueueIntegrity() method, and enhanced logging
process/asyncExecution/headersExecutor.go Added retry mechanism with max attempts and exponential backoff, periodic validation ticker, nil checks for headers/bodies, and fixed error propagation
process/sync/baseSync.go Updated error comparison to use errors.Is() and ensured deferred error handling works correctly
process/asyncExecution/queue/errors.go Removed unused ErrMissingHeaderNonce and added ErrQueueIntegrityViolation
process/asyncExecution/errors.go Added new error types for nil handlers and execution results
process/interface.go Added ValidateQueueIntegrity() to BlocksQueue interface
process/asyncExecution/interface.go Added ValidateQueueIntegrity() to BlocksQueue interface
testscommon/processMocks/blocksQueueMock.go Added ValidateQueueIntegrityCalled field and method to mock
process/asyncExecution/queue/blocksQueue_test.go Added comprehensive test coverage for ValidateQueueIntegrity() and concurrent operations
process/asyncExecution/headersExecutor_test.go Fixed test expectations to properly validate error propagation
Comments suppressed due to low confidence (1)

process/asyncExecution/headersExecutor.go:143

  • This select statement with a default case creates a busy-wait loop when the validation ticker doesn't fire. The default case will be executed continuously, causing high CPU usage even when the queue is empty and Pop() is blocking. Consider removing the default case or adding a small sleep in the default branch to avoid busy-waiting. The ticker and Pop() blocking should provide sufficient responsiveness without the default case.
		select {
		case <-ctx.Done():
			return
		case <-validationTicker.C:
			// Periodic queue validation
			err := he.blocksQueue.ValidateQueueIntegrity()
			if err != nil {
				log.Error("headersExecutor.start: queue integrity validation failed", "err", err)
			}
		default:
			he.mutPaused.RLock()
			isPaused := he.isPaused
			he.mutPaused.RUnlock()

			if isPaused {
				time.Sleep(timeToSleep)
				continue
			}

			// blocking operation
			headerBodyPair, ok := he.blocksQueue.Pop()
			if !ok {
				log.Debug("headersExecutor.start: not ok fetching from queue")
				// close event
				return
			}

			if check.IfNil(headerBodyPair.Header) || check.IfNil(headerBodyPair.Body) {
				log.Debug("headersExecutor.start: popped nil header or body, continuing...")
				continue
			}

			err := he.process(headerBodyPair)
			if err != nil {
				he.handleProcessError(ctx, headerBodyPair)
			}
		}

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

if err != nil {
log.Warn("headersExecutor.process process block failed",
"nonce", pair.Header.GetNonce(),
"hash", pair.Header.GetPrevHash(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"hash", pair.Header.GetPrevHash(),
"prevHash", pair.Header.GetPrevHash(),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 192 to 193
// Validate input parameters
if check.IfNil(pair.Header) {
Copy link
Contributor

@ssd04 ssd04 Jan 5, 2026

Choose a reason for hiding this comment

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

don't think its really needed, there are already some nil checks before process call

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

ssd04
ssd04 previously approved these changes Jan 8, 2026
Copy link
Contributor

Copilot AI left a comment

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


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

sstanculeanu
sstanculeanu previously approved these changes Jan 8, 2026
Base automatically changed from fix-tx-pool-restore-on-bootstrap to feat/supernova-async-exec January 8, 2026 10:14
@sstanculeanu sstanculeanu dismissed stale reviews from ssd04 and themself January 8, 2026 10:14

The base branch was changed.

An error occurred while trying to automatically change base from fix-tx-pool-restore-on-bootstrap to feat/supernova-async-exec January 8, 2026 10:14
sstanculeanu
sstanculeanu previously approved these changes Jan 8, 2026
@codecov
Copy link

codecov bot commented Jan 8, 2026

Codecov Report

❌ Patch coverage is 74.57627% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.68%. Comparing base (09a3fcc) to head (0b6f2f8).
⚠️ Report is 22 commits behind head on feat/supernova-async-exec.

Files with missing lines Patch % Lines
process/asyncExecution/headersExecutor.go 60.60% 11 Missing and 2 partials ⚠️
epochStart/metachain/epochStartData.go 58.33% 5 Missing ⚠️
update/common.go 0.00% 4 Missing ⚠️
process/block/preprocess/transactions.go 50.00% 2 Missing and 1 partial ⚠️
consensus/spos/worker.go 66.66% 1 Missing and 1 partial ⚠️
epochStart/metachain/trigger.go 80.00% 1 Missing ⚠️
process/asyncExecution/queue/blocksQueue.go 97.50% 1 Missing ⚠️
storage/pruning/pruningStorer.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@                    Coverage Diff                     @@
##           feat/supernova-async-exec    #7591   +/-   ##
==========================================================
  Coverage                      77.68%   77.68%           
==========================================================
  Files                            876      876           
  Lines                         121033   121120   +87     
==========================================================
+ Hits                           94029    94097   +68     
- Misses                         20796    20816   +20     
+ Partials                        6208     6207    -1     

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

sstanculeanu
sstanculeanu previously approved these changes Jan 12, 2026
sstanculeanu
sstanculeanu previously approved these changes Jan 12, 2026
@AdoAdoAdo AdoAdoAdo merged commit aebd60e into feat/supernova-async-exec Jan 13, 2026
10 of 11 checks passed
@AdoAdoAdo AdoAdoAdo deleted the fix-race-execution branch January 13, 2026 09:19
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