Skip to content

Commit

Permalink
Merge pull request #5810 from multiversx/proper-fix-for-redundancy
Browse files Browse the repository at this point in the history
Proper fix for redundancy
  • Loading branch information
iulianpascalau authored Jan 8, 2024
2 parents 3e59eae + b4e3198 commit e95550a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
3 changes: 2 additions & 1 deletion consensus/spos/bls/subroundBlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ func checkNewSubroundBlockParams(

// doBlockJob method does the job of the subround Block
func (sr *subroundBlock) doBlockJob(ctx context.Context) bool {
if !sr.IsSelfLeaderInCurrentRound() && !sr.IsMultiKeyLeaderInCurrentRound() { // is NOT self leader in this round?
isSelfLeader := sr.IsSelfLeaderInCurrentRound() && sr.ShouldConsiderSelfKeyInConsensus()
if !isSelfLeader && !sr.IsMultiKeyLeaderInCurrentRound() { // is NOT self leader in this round?
return false
}

Expand Down
6 changes: 2 additions & 4 deletions consensus/spos/bls/subroundStartRound.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,8 @@ func (sr *subroundStartRound) initCurrentRound() bool {
sr.ConsensusGroup(),
sr.RoundHandler().Index(),
)
// TODO refactor the usage of the single key & multikey redundancy system
if sr.NodeRedundancyHandler().IsMainMachineActive() {
return false
}
// we should not return here, the multikey redundancy system relies on it
// the NodeRedundancyHandler "thinks" it is in redundancy mode even if we use the multikey redundancy system
}

leader, err := sr.GetLeader()
Expand Down
4 changes: 2 additions & 2 deletions consensus/spos/bls/subroundStartRound_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ func TestSubroundStartRound_InitCurrentRoundShouldReturnFalseWhenGenerateNextCon
assert.False(t, r)
}

func TestSubroundStartRound_InitCurrentRoundShouldReturnFalseWhenMainMachineIsActive(t *testing.T) {
func TestSubroundStartRound_InitCurrentRoundShouldReturnTrueWhenMainMachineIsActive(t *testing.T) {
t.Parallel()

nodeRedundancyMock := &mock.NodeRedundancyHandlerStub{
Expand All @@ -442,7 +442,7 @@ func TestSubroundStartRound_InitCurrentRoundShouldReturnFalseWhenMainMachineIsAc
srStartRound := *initSubroundStartRoundWithContainer(container)

r := srStartRound.InitCurrentRound()
assert.False(t, r)
assert.True(t, r)
}

func TestSubroundStartRound_InitCurrentRoundShouldReturnFalseWhenGetLeaderErr(t *testing.T) {
Expand Down

0 comments on commit e95550a

Please sign in to comment.