Skip to content

Commit eb0e473

Browse files
authored
Merge pull request #7899 from multiversx/merge-master-into-rc/supernova-2026.07.03
Merge master into rc/supernova 2026.07.03
2 parents d1e285d + f60f013 commit eb0e473

5 files changed

Lines changed: 114 additions & 35 deletions

File tree

process/block/headerForBlock/export_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,23 @@ func (hfb *headersForBlock) ComputeExistingAndRequestMissingShardHeaders(metaBlo
4848
func (hfb *headersForBlock) UpdateLastNotarizedBlockForShard(hdr data.ShardHeaderHandler, headerHash []byte) {
4949
hfb.updateLastNotarizedBlockForShard(hdr, headerHash)
5050
}
51+
52+
// SetLastNotarizedHeaderForShard -
53+
func (hfb *headersForBlock) SetLastNotarizedHeaderForShard(shardID uint32, info LastNotarizedHeaderInfoHandler) {
54+
hfb.lastNotarizedShardHeaders[shardID] = info
55+
}
56+
57+
// SetHighestHdrNonceForCurrentBlock -
58+
func (hfb *headersForBlock) SetHighestHdrNonceForCurrentBlock(shardID uint32, nonce uint64) {
59+
hfb.highestHdrNonce[shardID] = nonce
60+
}
61+
62+
// SetShardBlockFinality -
63+
func (hfb *headersForBlock) SetShardBlockFinality(finality uint32) {
64+
hfb.blockFinality = finality
65+
}
66+
67+
// RequestMissingFinalityAttestingShardHeaders -
68+
func (hfb *headersForBlock) RequestMissingFinalityAttestingShardHeaders() uint32 {
69+
return hfb.requestMissingFinalityAttestingShardHeaders()
70+
}

process/block/headerForBlock/headersForBlock.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,8 @@ func (hfb *headersForBlock) requestMissingFinalityAttestingHeaders(
580580
false,
581581
false,
582582
)
583+
584+
hfb.requestProofIfNeeded(headersHashes[index], headers[index])
583585
}
584586
}
585587

process/block/headerForBlock/headersForBlock_test.go

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,98 @@ func TestHeadersForBlock_ComputeHeadersForCurrentBlock(t *testing.T) {
914914
})
915915
}
916916

917+
func TestHeadersForBlock_RequestMissingFinalityAttestingShardHeaders(t *testing.T) {
918+
t.Parallel()
919+
920+
t.Run("attestation header present but proof missing should request proof", func(t *testing.T) {
921+
t.Parallel()
922+
923+
referencedHeaderHash := []byte("sh0TestHash1")
924+
referencedHeader := &block.HeaderV2{
925+
Header: &block.Header{
926+
ShardID: 0,
927+
Round: 100,
928+
Nonce: 100,
929+
},
930+
}
931+
attestationHeaderHash := []byte("sh0TestHash2")
932+
attestationHeader := &block.HeaderV2{
933+
Header: &block.Header{
934+
ShardID: 0,
935+
Round: 101,
936+
Nonce: 101,
937+
PrevHash: referencedHeaderHash,
938+
},
939+
}
940+
941+
counter := 0
942+
var requestedShardID uint32
943+
var requestedHash []byte
944+
var mutRequestEquivalentProof sync.Mutex
945+
wg := &sync.WaitGroup{}
946+
wg.Add(1)
947+
948+
args := createMockArgs()
949+
args.ShardCoordinator = &testscommon.ShardsCoordinatorMock{
950+
NoShards: 2,
951+
}
952+
args.EnableEpochsHandler = &enableEpochsHandlerMock.EnableEpochsHandlerStub{
953+
IsFlagEnabledInEpochCalled: func(flag core.EnableEpochFlag, epoch uint32) bool {
954+
return flag == common.AndromedaFlag
955+
},
956+
}
957+
args.RequestHandler = &testscommon.RequestHandlerStub{
958+
RequestEquivalentProofByHashCalled: func(headerShard uint32, headerHash []byte) {
959+
mutRequestEquivalentProof.Lock()
960+
counter++
961+
requestedShardID = headerShard
962+
requestedHash = append([]byte(nil), headerHash...)
963+
mutRequestEquivalentProof.Unlock()
964+
965+
wg.Done()
966+
},
967+
}
968+
969+
poolsHolder, ok := args.DataPool.(*dataRetriever.PoolsHolderMock)
970+
require.True(t, ok)
971+
poolsHolder.SetHeadersPool(createPoolsHolderForHeaderRequests())
972+
poolsHolder.SetProofsPool(&dataRetriever.ProofsPoolMock{
973+
HasProofCalled: func(shardID uint32, headerHash []byte) bool {
974+
return false // no proof available for the attestation header
975+
},
976+
})
977+
978+
args.BlockTracker = &mock.BlockTrackerStub{
979+
GetLastCrossNotarizedHeaderCalled: func(shardID uint32) (data.HeaderHandler, []byte, error) {
980+
return referencedHeader, referencedHeaderHash, nil
981+
},
982+
}
983+
984+
hfb, err := headerForBlock.NewHeadersForBlock(args)
985+
require.NoError(t, err)
986+
987+
hfb.SetShardBlockFinality(1)
988+
hfb.SetHighestHdrNonceForCurrentBlock(referencedHeader.GetShardID(), referencedHeader.GetNonce())
989+
hfb.SetLastNotarizedHeaderForShard(
990+
referencedHeader.GetShardID(),
991+
headerForBlock.NewLastNotarizedHeaderInfo(referencedHeader, referencedHeaderHash, false, false),
992+
)
993+
994+
poolsHolder.Headers().AddHeader(attestationHeaderHash, attestationHeader)
995+
996+
missingFinalityHeaders := hfb.RequestMissingFinalityAttestingShardHeaders()
997+
require.Equal(t, uint32(0), missingFinalityHeaders)
998+
999+
wg.Wait()
1000+
1001+
mutRequestEquivalentProof.Lock()
1002+
require.Equal(t, 1, counter)
1003+
require.Equal(t, attestationHeader.GetShardID(), requestedShardID)
1004+
require.Equal(t, attestationHeaderHash, requestedHash)
1005+
mutRequestEquivalentProof.Unlock()
1006+
})
1007+
}
1008+
9171009
type headerData struct {
9181010
header data.HeaderHandler
9191011
headerHash []byte

process/block/interceptedBlocks/common.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/multiversx/mx-chain-go/sharding"
1111
)
1212

13-
const maxLenMiniBlockReservedField = 10
1413
const maxLenMiniBlockHeaderReservedField = 32
1514

1615
func checkForDuplicateHashes(hashes [][]byte) error {

process/coordinator/process.go

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -484,40 +484,6 @@ func (tc *transactionCoordinator) processMiniBlocksFromMe(
484484
return nil
485485
}
486486

487-
// TODO consider calling this from VerifyBlockProposal instead of ProcessBlockProposal
488-
func (tc *transactionCoordinator) checkMiniBlock(
489-
miniBlock *block.MiniBlock,
490-
) error {
491-
// there are checks for non existing shard id at interceptors level
492-
493-
if miniBlock.SenderShardID != tc.shardCoordinator.SelfId() && miniBlock.GetReceiverShardID() != tc.shardCoordinator.SelfId() && miniBlock.GetReceiverShardID() != core.AllShardId {
494-
return fmt.Errorf("%w - not valid shard ids: block type: %s, sender shard id: %d, receiver shard id: %d",
495-
process.ErrInvalidShardId,
496-
miniBlock.Type,
497-
miniBlock.SenderShardID,
498-
miniBlock.ReceiverShardID)
499-
}
500-
501-
if miniBlock.GetType() == block.PeerBlock &&
502-
(miniBlock.GetSenderShardID() != core.MetachainShardId || miniBlock.GetReceiverShardID() != core.AllShardId) {
503-
return fmt.Errorf("%w - peer blocks: block type: %s, sender shard id: %d, receiver shard id: %d",
504-
process.ErrInvalidShardId,
505-
miniBlock.Type,
506-
miniBlock.SenderShardID,
507-
miniBlock.ReceiverShardID)
508-
}
509-
510-
if miniBlock.GetType() != block.PeerBlock && miniBlock.GetReceiverShardID() == core.AllShardId {
511-
return fmt.Errorf("%w - invalid all shard ids: block type: %s, sender shard id: %d, receiver shard id: %d",
512-
process.ErrInvalidShardId,
513-
miniBlock.Type,
514-
miniBlock.SenderShardID,
515-
miniBlock.ReceiverShardID)
516-
}
517-
518-
return nil
519-
}
520-
521487
func (tc *transactionCoordinator) processMiniBlocksToMe(
522488
header data.HeaderHandler,
523489
body *block.Body,

0 commit comments

Comments
 (0)