-
Notifications
You must be signed in to change notification settings - Fork 222
finish consensus if header is received earlier #7583
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ import ( | |
| "github.com/multiversx/mx-chain-core-go/core/check" | ||
| "github.com/multiversx/mx-chain-core-go/data" | ||
| outportcore "github.com/multiversx/mx-chain-core-go/data/outport" | ||
| "github.com/multiversx/mx-chain-go/consensus/spos/bls" | ||
|
|
||
| "github.com/multiversx/mx-chain-go/common" | ||
| "github.com/multiversx/mx-chain-go/consensus/spos" | ||
|
|
@@ -131,6 +132,18 @@ func (sr *subroundStartRound) initCurrentRound() bool { | |
| return false | ||
| } | ||
|
|
||
| currentHeader := sr.Blockchain().GetCurrentBlockHeader() | ||
| if !check.IfNil(currentHeader) && int64(currentHeader.GetRound()) == sr.RoundHandler().Index() { | ||
| log.Debug("initCurrentRound: header for current consensus already committed, setting all subrounds as finished") | ||
|
|
||
| sr.SetStatus(sr.Current(), spos.SsFinished) | ||
| sr.SetStatus(bls.SrBlock, spos.SsFinished) | ||
| sr.SetStatus(bls.SrSignature, spos.SsFinished) | ||
| sr.SetStatus(bls.SrEndRound, spos.SsFinished) | ||
|
|
||
| return true | ||
| } | ||
|
Comment on lines
+135
to
+145
|
||
|
|
||
| sr.AppStatusHandler().SetStringValue(common.MetricConsensusRoundState, "") | ||
|
|
||
| err := sr.generateNextConsensusGroup(sr.RoundHandler().Index()) | ||
|
|
||
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.
The comparison between currentHeader.GetRound() (which returns uint64) and sr.RoundHandler().Index() (which returns int64) involves casting uint64 to int64. This can cause issues if the round number exceeds the maximum value of int64, leading to incorrect comparisons due to overflow. Consider comparing both values as uint64 to avoid potential overflow issues.