-
Notifications
You must be signed in to change notification settings - Fork 215
Fix shard stuck #6739
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
Merged
Merged
Fix shard stuck #6739
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d011e9a
update fork detector for proofs
AdoAdoAdo 1a7f79a
update fork detector for proofs and proof saving in consensus
AdoAdoAdo d35a311
update consensus end round proof handling
AdoAdoAdo 214c1df
fix unit test
AdoAdoAdo 2d594a5
simplify
AdoAdoAdo 943c287
fix unit tests
AdoAdoAdo 5ca3486
fix unit tests
AdoAdoAdo b6f7617
fixes after review
AdoAdoAdo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,6 @@ import ( | |
|
|
||
| "github.com/multiversx/mx-chain-core-go/core" | ||
| "github.com/multiversx/mx-chain-core-go/core/check" | ||
| "github.com/multiversx/mx-chain-core-go/data" | ||
| "github.com/multiversx/mx-chain-core-go/data/block" | ||
| "github.com/multiversx/mx-chain-core-go/display" | ||
|
|
||
|
|
@@ -247,10 +246,36 @@ func (sr *subroundEndRound) doEndRoundJobByNode() bool { | |
| if !sr.waitForSignalSync() { | ||
| return false | ||
| } | ||
| sr.sendProof() | ||
| } | ||
|
|
||
| proof, ok := sr.sendProof() | ||
| if !ok { | ||
| return sr.finalizeConfirmedBlock() | ||
| } | ||
|
|
||
| func (sr *subroundEndRound) waitForProof() bool { | ||
| shardID := sr.ShardCoordinator().SelfId() | ||
| headerHash := sr.GetData() | ||
| if sr.EquivalentProofsPool().HasProof(sr.ShardCoordinator().SelfId(), sr.GetData()) { | ||
| return true | ||
| } | ||
|
|
||
| ctx, cancel := context.WithTimeout(context.Background(), sr.RoundHandler().TimeDuration()) | ||
| defer cancel() | ||
|
|
||
| for { | ||
| select { | ||
| case <-time.After(time.Millisecond): | ||
| if sr.EquivalentProofsPool().HasProof(shardID, headerHash) { | ||
| return true | ||
| } | ||
| case <-ctx.Done(): | ||
| return false | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func (sr *subroundEndRound) finalizeConfirmedBlock() bool { | ||
| if !sr.waitForProof() { | ||
| return false | ||
| } | ||
|
|
||
|
|
@@ -259,14 +284,6 @@ func (sr *subroundEndRound) doEndRoundJobByNode() bool { | |
| return false | ||
| } | ||
|
|
||
| // if proof not nil, it was created and broadcasted so it has to be added to the pool | ||
| if proof != nil { | ||
| ok := sr.EquivalentProofsPool().AddProof(proof) | ||
| if !ok { | ||
| log.Trace("doEndRoundJobByNode.AddProof", "added", ok) | ||
| } | ||
| } | ||
|
|
||
| sr.SetStatus(sr.Current(), spos.SsFinished) | ||
|
|
||
| sr.worker.DisplayStatistics() | ||
|
|
@@ -281,42 +298,44 @@ func (sr *subroundEndRound) doEndRoundJobByNode() bool { | |
| return true | ||
| } | ||
|
|
||
| func (sr *subroundEndRound) sendProof() (data.HeaderProofHandler, bool) { | ||
| func (sr *subroundEndRound) sendProof() { | ||
| if !sr.shouldSendProof() { | ||
| return nil, true | ||
| return | ||
| } | ||
|
|
||
| bitmap := sr.GenerateBitmap(bls.SrSignature) | ||
| err := sr.checkSignaturesValidity(bitmap) | ||
| if err != nil { | ||
| log.Debug("sendProof.checkSignaturesValidity", "error", err.Error()) | ||
| return nil, false | ||
| return | ||
| } | ||
|
|
||
| // Aggregate signatures, handle invalid signers and send final info if needed | ||
| bitmap, sig, err := sr.aggregateSigsAndHandleInvalidSigners(bitmap) | ||
| if err != nil { | ||
| log.Debug("sendProof.aggregateSigsAndHandleInvalidSigners", "error", err.Error()) | ||
| return nil, false | ||
| return | ||
| } | ||
|
|
||
| ok := sr.ScheduledProcessor().IsProcessedOKWithTimeout() | ||
| // placeholder for subroundEndRound.doEndRoundJobByLeader script | ||
| if !ok { | ||
| return nil, false | ||
| return | ||
| } | ||
|
|
||
| roundHandler := sr.RoundHandler() | ||
| if roundHandler.RemainingTime(roundHandler.TimeStamp(), roundHandler.TimeDuration()) < 0 { | ||
| log.Debug("sendProof: time is out -> cancel broadcasting final info and header", | ||
| "round time stamp", roundHandler.TimeStamp(), | ||
| "current time", time.Now()) | ||
| return nil, false | ||
| return | ||
| } | ||
|
|
||
| // broadcast header proof | ||
| proof, err := sr.createAndBroadcastProof(sig, bitmap) | ||
| return proof, err == nil | ||
| _, err = sr.createAndBroadcastProof(sig, bitmap) | ||
|
||
| if err != nil { | ||
| log.Warn("sendProof.createAndBroadcastProof", "error", err.Error()) | ||
| } | ||
| } | ||
|
|
||
| func (sr *subroundEndRound) shouldSendProof() bool { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, forgot it.