diff --git a/process/block/metablock.go b/process/block/metablock.go index 716516d3e4..9ce2be5f25 100644 --- a/process/block/metablock.go +++ b/process/block/metablock.go @@ -427,6 +427,16 @@ func (mp *metaProcessor) checkProofsForShardData(header *block.MetaBlock) error // TODO: consider the validation of the proof: // compare the one from proofsPool with what shardData.CurrentSignature and shardData.CurrentPubKeysBitmap hold // if they are different, verify the proof received on header + + shardHeader, ok := mp.hdrsForCurrBlock.hdrHashAndInfo[string(shardData.HeaderHash)] + if !ok { + return fmt.Errorf("%w for header hash %s", process.ErrMissingHeader, hex.EncodeToString(shardData.HeaderHash)) + } + + if !mp.enableEpochsHandler.IsFlagEnabledInEpoch(common.EquivalentMessagesFlag, shardHeader.hdr.GetEpoch()) { + continue + } + if !mp.proofsPool.HasProof(shardData.ShardID, shardData.HeaderHash) { return fmt.Errorf("%w for header hash %s", process.ErrMissingHeaderProof, hex.EncodeToString(shardData.HeaderHash)) } @@ -2186,11 +2196,11 @@ func (mp *metaProcessor) createShardInfo() ([]data.ShardDataHandler, error) { continue } - isBlockAfterEquivalentMessagesFlag := check.IfNil(headerInfo.hdr) && + isBlockAfterEquivalentMessagesFlag := !check.IfNil(headerInfo.hdr) && mp.enableEpochsHandler.IsFlagEnabledInEpoch(common.EquivalentMessagesFlag, headerInfo.hdr.GetEpoch()) hasMissingShardHdrProof := isBlockAfterEquivalentMessagesFlag && !mp.proofsPool.HasProof(headerInfo.hdr.GetShardID(), []byte(hdrHash)) if hasMissingShardHdrProof { - return nil, fmt.Errorf("%w for shard header with hash %s", process.ErrMissingHeaderProof, hdrHash) + return nil, fmt.Errorf("%w for shard header with hash %s", process.ErrMissingHeaderProof, hex.EncodeToString([]byte(hdrHash))) } shardHdr, ok := headerInfo.hdr.(data.ShardHeaderHandler) diff --git a/process/block/shardblock.go b/process/block/shardblock.go index 4713a9437d..8541f24f06 100644 --- a/process/block/shardblock.go +++ b/process/block/shardblock.go @@ -296,6 +296,15 @@ func (sp *shardProcessor) ProcessBlock( if sp.enableEpochsHandler.IsFlagEnabledInEpoch(common.EquivalentMessagesFlag, header.GetEpoch()) { // check proofs for cross notarized metablocks for _, metaBlockHash := range header.GetMetaBlockHashes() { + hInfo, ok := sp.hdrsForCurrBlock.hdrHashAndInfo[string(metaBlockHash)] + if !ok { + return fmt.Errorf("%w for header hash %s", process.ErrMissingHeader, hex.EncodeToString(metaBlockHash)) + } + + if !sp.enableEpochsHandler.IsFlagEnabledInEpoch(common.EquivalentMessagesFlag, hInfo.hdr.GetEpoch()) { + continue + } + if !sp.proofsPool.HasProof(core.MetachainShardId, metaBlockHash) { return fmt.Errorf("%w for header hash %s", process.ErrMissingHeaderProof, hex.EncodeToString(metaBlockHash)) } @@ -1441,6 +1450,7 @@ func (sp *shardProcessor) CreateNewHeader(round uint64, nonce uint64) (data.Head } sp.roundNotifier.CheckRound(header) + sp.epochNotifier.CheckEpoch(header) err = shardHeader.SetNonce(nonce) if err != nil {