Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions common/configs/processConfigs.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ func checkRoundConfigValues(cfg config.ProcessConfigByRound) error {
return fmt.Errorf("%w for MaxBlockProcessingTimeMs, received %d, min expected %d",
process.ErrInvalidValue, cfg.MaxBlockProcessingTimeMs, minBlockProcessingTimeMs)
}
if cfg.RoundModulusTriggerWhenSyncIsStuck == 0 {
return fmt.Errorf("%w for RoundModulusTriggerWhenSyncIsStuck", process.ErrInvalidValue)
}

return nil
}
Expand Down
19 changes: 19 additions & 0 deletions common/configs/processConfigs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func getConfigsByRound() []config.ProcessConfigByRound {
NumFloodingRoundsOutOfSpecs: 4,
MaxConsecutiveRoundsOfRatingDecrease: 600,
MaxBlockProcessingTimeMs: 1000,
RoundModulusTriggerWhenSyncIsStuck: 10,
},
{
EnableRound: 1,
Expand All @@ -35,6 +36,7 @@ func getConfigsByRound() []config.ProcessConfigByRound {
NumFloodingRoundsOutOfSpecs: 40,
MaxConsecutiveRoundsOfRatingDecrease: 6000,
MaxBlockProcessingTimeMs: 1000,
RoundModulusTriggerWhenSyncIsStuck: 10,
},
}
}
Expand Down Expand Up @@ -112,6 +114,21 @@ func TestNewProcessConfigsByEpoch(t *testing.T) {
require.True(t, strings.Contains(err.Error(), "MaxRoundsToKeepUnprocessedMiniBlocks"))
})

t.Run("should return error for zero RoundModulusTriggerWhenSyncIsStuck value", func(t *testing.T) {
t.Parallel()

confByEpoch := []config.ProcessConfigByEpoch{
{EnableEpoch: 0, MaxMetaNoncesBehind: 15},
}
confByRound := getConfigsByRound()
confByRound[0].RoundModulusTriggerWhenSyncIsStuck = 0

pce, err := configs.NewProcessConfigsHandler(confByEpoch, confByRound, &epochNotifier.RoundNotifierStub{})
require.Nil(t, pce)
require.ErrorIs(t, err, process.ErrInvalidValue)
require.True(t, strings.Contains(err.Error(), "RoundModulusTriggerWhenSyncIsStuck"))
})

t.Run("should return error for invalid max consecutive rounds of rating decrease value", func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -175,6 +192,7 @@ func TestProcessConfigsByEpoch_Getters(t *testing.T) {
NumFloodingRoundsOutOfSpecs: 4,
MaxConsecutiveRoundsOfRatingDecrease: 600,
MaxBlockProcessingTimeMs: 1000,
RoundModulusTriggerWhenSyncIsStuck: 10,
},
{EnableRound: 1,
MaxRoundsWithoutNewBlockReceived: 11,
Expand All @@ -187,6 +205,7 @@ func TestProcessConfigsByEpoch_Getters(t *testing.T) {
NumFloodingRoundsOutOfSpecs: 40,
MaxConsecutiveRoundsOfRatingDecrease: 6000,
MaxBlockProcessingTimeMs: 2000,
RoundModulusTriggerWhenSyncIsStuck: 10,
},
}

Expand Down
3 changes: 3 additions & 0 deletions consensus/spos/bls/ntpsync/roundSyncController.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/multiversx/mx-chain-go/consensus/spos"
"github.com/multiversx/mx-chain-go/ntp"
logger "github.com/multiversx/mx-chain-logger-go"
"golang.org/x/exp/slices"
)

var log = logger.GetOrCreate("nonceSyncController")
Expand Down Expand Up @@ -95,6 +96,8 @@ func areNoncesInAscendingOrder(nonces []uint64) bool {
return false
}

slices.Sort(nonces)

for i := 1; i < len(nonces); i++ {
if nonces[i] != nonces[i-1]+1 {
return false
Expand Down
5 changes: 5 additions & 0 deletions consensus/spos/bls/v2/subroundEndRound.go
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,11 @@ func (sr *subroundEndRound) receivedSignature(_ context.Context, cnsDta *consens
return false
}

if sr.HasProofForCompetingBlock() {
log.Debug("receivedSignature: competing block proof detected, dropping signature")
return false
}

index, err := sr.ConsensusGroupIndex(node)
if err != nil {
log.Debug("receivedSignature.ConsensusGroupIndex",
Expand Down
Loading