Merge rc into feat/supernova async exec 2026.04.02#7818
Conversation
add extra validation
…to rc/supernova # Conflicts: # process/block/baseProcess.go # process/errors.go
…va-2026.04.02 Merge master into rc/supernova 2026.04.02
There was a problem hiding this comment.
Pull request overview
This PR adds validation for duplicated mini-block (and shard-data) hashes to prevent blocks/headers containing repeated hashes where uniqueness is expected, and introduces a dedicated error for this condition.
Changes:
- Added
process.ErrDuplicatedHashInBlockerror. - Added duplicate-hash detection in intercepted meta-header integrity checks and in header/body correlation checks.
- Added/updated unit tests for duplicated hashes across shard processors and intercepted meta headers.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
process/errors.go |
Introduces ErrDuplicatedHashInBlock used by new validation paths. |
process/block/baseProcess.go |
Adds duplicate-hash detection to header/body correlation logic. |
process/block/shardblock_test.go |
Adds tests asserting correlation fails on duplicated hashes. |
process/block/interceptedBlocks/common.go |
Adds shared helper + enforces uniqueness for shard-info and miniblock header hashes. |
process/block/interceptedBlocks/common_test.go |
Adds unit tests for duplicate-hash checks in intercepted-block utilities. |
process/block/interceptedBlocks/interceptedMetaBlockHeader.go |
Minor formatting change in integrity flow (no logic change). |
process/block/interceptedBlocks/interceptedMetaBlockHeader_test.go |
Adds tests ensuring duplicated miniblock header hashes are rejected. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // check if header has the same mini blocks as presented in body | ||
| func (bp *baseProcessor) checkHeaderBodyCorrelationProposal(miniBlockHeaders []data.MiniBlockHeaderHandler, body *block.Body) error { | ||
| mbHashesFromHdr := make(map[string]data.MiniBlockHeaderHandler, len(miniBlockHeaders)) | ||
| for i := 0; i < len(miniBlockHeaders); i++ { |
There was a problem hiding this comment.
checkHeaderBodyCorrelationProposal builds mbHashesFromHdr by calling miniBlockHeaders[i].GetHash() before validating that the header handler is non-nil. If miniBlockHeaders contains a nil entry (there is already a unit test for this case), this will panic with a nil pointer dereference instead of returning ErrNilMiniBlockHeader. Consider validating miniBlockHeaders entries before building the map, or building the map inside the main loop after the nil check.
| for i := 0; i < len(miniBlockHeaders); i++ { | |
| for i := 0; i < len(miniBlockHeaders); i++ { | |
| if miniBlockHeaders[i] == nil { | |
| return process.ErrNilMiniBlockHeader | |
| } |
process/block/baseProcess.go
Outdated
| mbHashesFromHdr := make(map[string]data.MiniBlockHeaderHandler, len(miniBlockHeaders)) | ||
| for i := 0; i < len(miniBlockHeaders); i++ { | ||
| mbHashesFromHdr[string(miniBlockHeaders[i].GetHash())] = miniBlockHeaders[i] |
There was a problem hiding this comment.
mbHashesFromHdr is only used for presence checks and deletions; the stored MiniBlockHeaderHandler value is never read. Using map[string]struct{} (or a boolean) would clarify intent and avoid keeping unused pointers in the map.
| mbHashesFromHdr := make(map[string]data.MiniBlockHeaderHandler, len(miniBlockHeaders)) | |
| for i := 0; i < len(miniBlockHeaders); i++ { | |
| mbHashesFromHdr[string(miniBlockHeaders[i].GetHash())] = miniBlockHeaders[i] | |
| mbHashesFromHdr := make(map[string]struct{}, len(miniBlockHeaders)) | |
| for i := 0; i < len(miniBlockHeaders); i++ { | |
| mbHashesFromHdr[string(miniBlockHeaders[i].GetHash())] = struct{}{} |
process/block/baseProcess.go
Outdated
| mbHashesFromHdr := make(map[string]data.MiniBlockHeaderHandler, len(miniBlockHeaders)) | ||
| for i := 0; i < len(miniBlockHeaders); i++ { | ||
| mbHashesFromHdr[string(miniBlockHeaders[i].GetHash())] = miniBlockHeaders[i] |
There was a problem hiding this comment.
mbHashesFromHdr is only used as a set (membership + delete); the map value is never read. Consider changing this to map[string]struct{} to make the code’s intent clearer and reduce memory overhead.
| mbHashesFromHdr := make(map[string]data.MiniBlockHeaderHandler, len(miniBlockHeaders)) | |
| for i := 0; i < len(miniBlockHeaders); i++ { | |
| mbHashesFromHdr[string(miniBlockHeaders[i].GetHash())] = miniBlockHeaders[i] | |
| mbHashesFromHdr := make(map[string]struct{}, len(miniBlockHeaders)) | |
| for i := 0; i < len(miniBlockHeaders); i++ { | |
| mbHashesFromHdr[string(miniBlockHeaders[i].GetHash())] = struct{}{} |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feat/supernova-async-exec #7818 +/- ##
==========================================================
Coverage 77.58% 77.58%
==========================================================
Files 882 882
Lines 123941 123987 +46
==========================================================
+ Hits 96155 96193 +38
- Misses 21416 21420 +4
- Partials 6370 6374 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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?