Skip to content

MX-17245 · Improve shard processor coverage#7350

Merged
sstanculeanu merged 19 commits into
feat/supernova-async-execfrom
shardblockproposal-testing
Oct 27, 2025
Merged

MX-17245 · Improve shard processor coverage#7350
sstanculeanu merged 19 commits into
feat/supernova-async-execfrom
shardblockproposal-testing

Conversation

@mradian1

@mradian1 mradian1 commented Oct 16, 2025

Copy link
Copy Markdown

Reasoning behind the pull request

Increase cover of shardProcessor and txCoordinator

Proposed changes

  • Create a method that constructs a shardProcessor with given components, then use this method to initialize correspondingly a shardProcessor and test collectExecutionResults

Testing procedure

  • Export a method (in export_test.go) to partially create a shardProcessor, through reflection: given a map[string]interface{} try to construct a shardProcessor{}, and initialize the corresponding fields (for the given keys in the map) with the given values.

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?

@mradian1 mradian1 self-assigned this Oct 16, 2025
@mradian1 mradian1 marked this pull request as draft October 16, 2025 18:22
@codecov

codecov Bot commented Oct 16, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.69%. Comparing base (b7d2356) to head (2e37fa8).

Additional details and impacted files
@@                      Coverage Diff                      @@
##           feat/supernova-async-exec    #7350      +/-   ##
=============================================================
+ Coverage                      75.68%   75.69%   +0.01%     
=============================================================
  Files                            860      860              
  Lines                         141702   141698       -4     
=============================================================
+ Hits                          107248   107264      +16     
+ Misses                         28514    28500      -14     
+ Partials                        5940     5934       -6     

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

@mradian1 mradian1 marked this pull request as ready for review October 24, 2025 07:11
return sp.collectExecutionResults(headerHash, header, body)
}

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

Comment thread process/block/export_test.go Outdated
for name, component := range subcomponents {
if err := setField(sp, name, component); err != nil {
if err2 := setField(sp.baseProcessor, name, component); err2 != nil {
return nil, err

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.

is it intended here err or should it be err2? (perhaps rename err2 to errSetBaseProcessor)

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.

removed it altogether, it was not really necessary

Comment thread process/block/metablock.go Outdated
Comment on lines +479 to +480
return nil, fmt.Errorf("%w : getAllMiniBlockDstMeFromShards shardInfo.HeaderHash = %s",
process.ErrMissingHeader, hex.EncodeToString(shardInfo.HeaderHash))

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.

not sure we should add the name of the func inside the error.. maybe this could become somthing like

Suggested change
return nil, fmt.Errorf("%w : getAllMiniBlockDstMeFromShards shardInfo.HeaderHash = %s",
process.ErrMissingHeader, hex.EncodeToString(shardInfo.HeaderHash))
return nil, fmt.Errorf("%w for shard info with hash = %s",
process.ErrMissingHeader, hex.EncodeToString(shardInfo.HeaderHash))

similar for all

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

Comment thread process/block/shardblock.go Outdated
Comment on lines +1855 to +1856
return nil, fmt.Errorf("%w : getAllMiniBlockDstMeFromMeta metaBlockHash = %s",
process.ErrMissingHeader, hex.EncodeToString(metaBlockHash))

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.

same here:

Suggested change
return nil, fmt.Errorf("%w : getAllMiniBlockDstMeFromMeta metaBlockHash = %s",
process.ErrMissingHeader, hex.EncodeToString(metaBlockHash))
return nil, fmt.Errorf("%w for metaBlockHash %s",
process.ErrMissingHeader, hex.EncodeToString(metaBlockHash))

Comment thread process/coordinator/processProposal.go Outdated
// but add them into pendingMiniBlocksAndHashes
if lastMBIndex != len(mbsSlice) {
pendingMiniBlocksAndHashes = miniBlocksAndHashes[lastMBIndex:]
if lastMBIndex+1 < len(mbsSlice) {

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.

Suggested change
if lastMBIndex+1 < len(mbsSlice) {
if lastMBIndex < len(mbsSlice) - 1 {

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

Comment thread process/block/shardblock_test.go Outdated
},
}
}
//body := &block.Body{}

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.

remove this line

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.

removed

Comment thread process/block/shardblock_test.go Outdated
Comment on lines +4852 to +4858
type gracePeriodErrStub struct{}

func (gracePeriodErrStub) GetGracePeriodForEpoch(_ uint32) (uint32, error) {
return 0, errors.New("epochChangeGracePeriodHandler forced error")
}

func (gracePeriodErrStub) IsInterfaceNil() bool { return false }

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.

extract it into a new file as a regular mock + comments on exported

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

Comment thread process/block/shardblock_test.go Outdated
func TestShardProcessor_CheckEpochCorrectnessShouldErrorWhenIsHeaderOfInvalidEpoch(t *testing.T) {
t.Parallel()

// isHeaderOfInvalidEpoch := header.GetEpoch() > sp.epochStartTrigger.MetaEpoch()

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.

remove this line

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.

removed

Comment thread process/block/shardblock_test.go Outdated
},
}

//make epochChangeConfirmed true (sp.epochStartTrigger.EpochStartRound() <= sp.epochStartTrigger.EpochFinalityAttestingRound())

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.

remove this line

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.

removed

Comment thread process/block/shardblock_test.go Outdated
func TestShardProcessor_CheckEpochCorrectnessShouldErrorWhenIsNotEpochStartButShouldBe(t *testing.T) {
t.Parallel()

//isNotEpochStartButShouldBe := header.GetEpoch() != currentBlockHeader.GetEpoch() && !header.IsStartOfEpochBlock()

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.

same here

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.

removed

@sstanculeanu sstanculeanu merged commit f19f4f5 into feat/supernova-async-exec Oct 27, 2025
8 of 9 checks passed
@sstanculeanu sstanculeanu deleted the shardblockproposal-testing branch October 27, 2025 15:06
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.

3 participants