Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix writing on channel when a block is requested in order to attest the current one #6794

Merged
merged 10 commits into from
Feb 12, 2025

Conversation

sstanculeanu
Copy link
Collaborator

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:

  • 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?

@sstanculeanu sstanculeanu added the ignore-for-release-notes Do not include item in release notes label Feb 11, 2025
@sstanculeanu sstanculeanu self-assigned this Feb 11, 2025
@@ -2073,6 +2073,12 @@ func (mp *metaProcessor) receivedShardHeader(headerHandler data.HeaderHandler, s
"hash", shardHeaderHash,
)

if mp.isWaitingForNextHeader.IsSet() {
Copy link
Contributor

Choose a reason for hiding this comment

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

there is no guarantee that the received header is the one we requested or it is in fact another one, so in the second case we would falsely exit the wait.

@@ -1751,6 +1751,12 @@ func (sp *shardProcessor) receivedMetaBlock(headerHandler data.HeaderHandler, me
"hash", metaBlockHash,
)

if sp.isWaitingForNextHeader.IsSet() {
Copy link
Contributor

Choose a reason for hiding this comment

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

there is no guarantee that the received header is the one that was requested.

@@ -11,6 +11,7 @@ import (
"time"

Copy link
Contributor

Choose a reason for hiding this comment

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

please optimize as well func (mp *metaProcessor) checkProofsForShardData(header *block.MetaBlock) to request needed blocks and verify the shard data in parallel


bp.mutRequestedAttestingNoncesMap.RLock()
isWaitingForProofs := len(bp.requestedAttestingNoncesMap) > 0
defer bp.mutRequestedAttestingNoncesMap.RUnlock()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
defer bp.mutRequestedAttestingNoncesMap.RUnlock()
bp.mutRequestedAttestingNoncesMap.RUnlock()

?

select {
case <-bp.chanNextHeader:
bp.isWaitingForNextHeader.Reset()
case <-bp.allProofsReceived:
return nil
case <-time.After(bp.extraDelayRequestBlockInfo):
Copy link
Contributor

Choose a reason for hiding this comment

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

check what happens in case of synced node processing in consensus
if this timeout is set properly for that

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe use the passed haveTime callback instead

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated

return
}

bp.mutRequestedAttestingNoncesMap.Lock()
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe extract the locked section into a method, then you can do a defer and cover future exit cases

@@ -423,6 +423,11 @@ func (mp *metaProcessor) checkProofsForShardData(header *block.MetaBlock) error
return nil
}

mp.mutRequestedAttestingNoncesMap.Lock()
mp.requestedAttestingNoncesMap = make(map[string]uint64)
_ = core.EmptyChannel(mp.allProofsReceived)
Copy link
Contributor

Choose a reason for hiding this comment

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

outside of the locked section

@sstanculeanu sstanculeanu merged commit 802cba6 into trigger-fixes Feb 12, 2025
1 of 2 checks passed
@sstanculeanu sstanculeanu deleted the fix_time_out_error_on_sync branch February 12, 2025 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ignore-for-release-notes Do not include item in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants