Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions process/block/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,11 @@ func (sp *shardProcessor) CollectExecutionResults(headerHash []byte, header data
return sp.collectExecutionResults(headerHash, header, body)
}

// AddExecutionResultsOnHeader -
func (sp *shardProcessor) AddExecutionResultsOnHeader(shardHeader data.HeaderHandler) error {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

missing comments on exported methods

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

done

return sp.addExecutionResultsOnHeader(shardHeader)
}

// GetCrossShardIncomingMiniBlocksFromBody -
func (sp *shardProcessor) GetCrossShardIncomingMiniBlocksFromBody(body *block.Body) []*block.MiniBlock {
return sp.getCrossShardIncomingMiniBlocksFromBody(body)
Expand All @@ -822,3 +827,13 @@ func GetLastExecutionResultsRootHash(
func GetHaveTimeForProposal(startTime time.Time, maxDuration time.Duration) func() time.Duration {
return getHaveTimeForProposal(startTime, maxDuration)
}

// ConstructPartialShardBlockProcessorForTest -
func ConstructPartialShardBlockProcessorForTest(subcomponents map[string]interface{}) (*shardProcessor, error) {
sp := &shardProcessor{}
err := factory.ConstructPartialComponentForTest(sp, subcomponents)
if err != nil {
return nil, err
}
return sp, err
}
15 changes: 10 additions & 5 deletions process/block/metablock.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,13 @@ func (mp *metaProcessor) getAllMiniBlockDstMeFromShards(metaHdr *block.MetaBlock
for _, shardInfo := range metaHdr.ShardInfo {
headerInfo, ok := mp.hdrsForCurrBlock.GetHeaderInfo(string(shardInfo.HeaderHash))
if !ok {
continue
return nil, fmt.Errorf("%w for shard info with hash = %s",
process.ErrMissingHeader, hex.EncodeToString(shardInfo.HeaderHash))
}
shardHeader, ok := headerInfo.GetHeader().(data.ShardHeaderHandler)
if !ok {
continue
return nil, fmt.Errorf("%w : for shardInfo.HeaderHash = %s",
process.ErrWrongTypeAssertion, hex.EncodeToString(shardInfo.HeaderHash))
}

lastCrossNotarizedHeader, _, err := mp.blockTracker.GetLastCrossNotarizedHeader(shardInfo.ShardID)
Expand All @@ -489,13 +491,16 @@ func (mp *metaProcessor) getAllMiniBlockDstMeFromShards(metaHdr *block.MetaBlock
}

if shardHeader.GetRound() > metaHdr.Round {
continue
return nil, fmt.Errorf("%w : for shard info with hash = %s",
process.ErrHigherRoundInBlock, hex.EncodeToString(shardInfo.HeaderHash))
}
if shardHeader.GetRound() <= lastCrossNotarizedHeader.GetRound() {
continue
return nil, fmt.Errorf("%w : for shard info with hash = %s",
process.ErrLowerRoundInBlock, hex.EncodeToString(shardInfo.HeaderHash))
}
if shardHeader.GetNonce() <= lastCrossNotarizedHeader.GetNonce() {
continue
return nil, fmt.Errorf("%w : for shard info with hash = %s",
process.ErrLowerNonceInBlock, hex.EncodeToString(shardInfo.HeaderHash))
}

finalCrossMiniBlockHashes := mp.getFinalCrossMiniBlockHashes(shardHeader)
Expand Down
3 changes: 2 additions & 1 deletion process/block/metablock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2795,7 +2795,8 @@ func TestMetaProcessor_VerifyCrossShardMiniBlocksDstMe(t *testing.T) {
assert.Nil(t, err)

err = mp.VerifyCrossShardMiniBlockDstMe(hdr)
assert.Nil(t, err)
assert.Error(t, err)
assert.ErrorIs(t, err, process.ErrMissingHeader)
}

func TestMetaProcess_CreateNewBlockHeaderProcessHeaderExpectCheckRoundCalled(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion process/block/shardblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -1853,7 +1853,8 @@ func (sp *shardProcessor) getAllMiniBlockDstMeFromMeta(header data.ShardHeaderHa
for _, metaBlockHash := range header.GetMetaBlockHashes() {
headerInfo, ok := sp.hdrsForCurrBlock.GetHeaderInfo(string(metaBlockHash))
if !ok {
return nil, err
return nil, fmt.Errorf("%w for metaBlockHash %s",
process.ErrMissingHeader, hex.EncodeToString(metaBlockHash))
}

err = sp.addCrossShardMiniBlocksDstMeToMap(header, metaBlockHash, headerInfo.GetHeader(), lastCrossNotarizedHeader, miniBlockMetaHashes)
Expand Down
Loading
Loading