Skip to content

Commit d1f3e4c

Browse files
committed
FEAT: Continue integration for MaxConsecutiveRoundsOfRatingDecrease into configs per round
1 parent 6f55018 commit d1f3e4c

File tree

13 files changed

+37
-6
lines changed

13 files changed

+37
-6
lines changed

common/configs/consts.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ const (
1818
defaultNumFloodingRoundsFastReacting = 20
1919
defaultNumFloodingRoundsSlowReacting = 20
2020
defaultNumFloodingRoundsOutOfSpecs = 20
21+
defaultMaxConsecutiveRoundsOfRatingDecrease = 600
2122
)

common/configs/processConfigs.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func checkConfigsByRound(configsByRound []config.ProcessConfigByRound) error {
106106
}
107107
err := checkRoundConfigValues(cfg)
108108
if err != nil {
109-
return err
109+
return fmt.Errorf("%w in checkConfigsByRound for enable round: %d", err, cfg.EnableRound)
110110
}
111111

112112
seen[cfg.EnableRound] = struct{}{}
@@ -141,6 +141,9 @@ func checkRoundConfigValues(cfg config.ProcessConfigByRound) error {
141141
return fmt.Errorf("%w for NumFloodingRoundsOutOfSpecs, received %d, min expected %d",
142142
process.ErrInvalidValue, cfg.NumFloodingRoundsOutOfSpecs, minFloodingRounds)
143143
}
144+
if cfg.MaxConsecutiveRoundsOfRatingDecrease == 0 {
145+
return process.ErrZeroMaxConsecutiveRoundsOfRatingDecrease
146+
}
144147

145148
return nil
146149
}

common/configs/processConfigs_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ func getConfigsByRound() []config.ProcessConfigByRound {
2121
NumFloodingRoundsSlowReacting: 2,
2222
NumFloodingRoundsFastReacting: 3,
2323
NumFloodingRoundsOutOfSpecs: 4,
24+
MaxConsecutiveRoundsOfRatingDecrease: 600,
2425
},
2526
{
2627
EnableRound: 1,
@@ -30,6 +31,7 @@ func getConfigsByRound() []config.ProcessConfigByRound {
3031
NumFloodingRoundsSlowReacting: 20,
3132
NumFloodingRoundsFastReacting: 30,
3233
NumFloodingRoundsOutOfSpecs: 40,
34+
MaxConsecutiveRoundsOfRatingDecrease: 6000,
3335
},
3436
}
3537
}
@@ -152,6 +154,20 @@ func TestNewProcessConfigsByEpoch(t *testing.T) {
152154
require.True(t, strings.Contains(err.Error(), "NumFloodingRoundsOutOfSpecs"))
153155
})
154156

157+
t.Run("should return error for invalid max consecutive rounds of rating decrease value", func(t *testing.T) {
158+
t.Parallel()
159+
160+
confByEpoch := []config.ProcessConfigByEpoch{
161+
{EnableEpoch: 0, MaxMetaNoncesBehind: 15},
162+
}
163+
confByRound := getConfigsByRound()
164+
confByRound[0].MaxConsecutiveRoundsOfRatingDecrease = 0
165+
166+
pce, err := configs.NewProcessConfigsHandler(confByEpoch, confByRound, &epochNotifier.RoundNotifierStub{})
167+
require.Nil(t, pce)
168+
require.ErrorIs(t, err, process.ErrZeroMaxConsecutiveRoundsOfRatingDecrease)
169+
})
170+
155171
t.Run("should work", func(t *testing.T) {
156172
t.Parallel()
157173

@@ -199,6 +215,7 @@ func TestProcessConfigsByEpoch_Getters(t *testing.T) {
199215
NumFloodingRoundsSlowReacting: 2,
200216
NumFloodingRoundsFastReacting: 3,
201217
NumFloodingRoundsOutOfSpecs: 4,
218+
MaxConsecutiveRoundsOfRatingDecrease: 600,
202219
},
203220
{EnableRound: 1,
204221
MaxRoundsWithoutNewBlockReceived: 11,
@@ -209,6 +226,7 @@ func TestProcessConfigsByEpoch_Getters(t *testing.T) {
209226
NumFloodingRoundsSlowReacting: 20,
210227
NumFloodingRoundsFastReacting: 30,
211228
NumFloodingRoundsOutOfSpecs: 40,
229+
MaxConsecutiveRoundsOfRatingDecrease: 6000,
212230
},
213231
}
214232

common/configs/vars.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,11 @@ func initCfgVarMap() map[dto.ConfigVariable]configVariableHandler {
2525
},
2626
defaultValue: defaultNumFloodingRoundsOutOfSpecs,
2727
},
28+
dto.MaxConsecutiveRoundsOfRatingDecrease: {
29+
valueSelector: func(cfg config.ProcessConfigByRound) uint64 {
30+
return cfg.MaxConsecutiveRoundsOfRatingDecrease
31+
},
32+
defaultValue: defaultMaxConsecutiveRoundsOfRatingDecrease,
33+
},
2834
}
2935
}

config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ type ProcessConfigByRound struct {
396396
NumFloodingRoundsSlowReacting uint32
397397
NumFloodingRoundsOutOfSpecs uint32
398398

399-
MaxConsecutiveRoundsOfRatingDecrease uint32
399+
MaxConsecutiveRoundsOfRatingDecrease uint64
400400
}
401401

402402
// GeneralSettingsConfig will hold the general settings for a node

integrationTests/testProcessorNode.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ var TestProcessConfigsHandler, _ = configs.NewProcessConfigsHandler([]config.Pro
180180
NumFloodingRoundsSlowReacting: 20,
181181
NumFloodingRoundsFastReacting: 30,
182182
NumFloodingRoundsOutOfSpecs: 40,
183+
MaxConsecutiveRoundsOfRatingDecrease: 600,
183184
},
184185
},
185186
forking.NewGenericRoundNotifier(),

node/chainSimulator/components/coreComponents_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ func createArgsCoreComponentsHolder() ArgsCoreComponentsHolder {
7373
NumFloodingRoundsSlowReacting: 20,
7474
NumFloodingRoundsFastReacting: 30,
7575
NumFloodingRoundsOutOfSpecs: 40,
76+
MaxConsecutiveRoundsOfRatingDecrease: 600,
7677
},
7778
},
7879
EpochStartConfigsByEpoch: []config.EpochStartConfigByEpoch{

process/block/export_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ func NewShardProcessorEmptyWith3shards(
163163
NumFloodingRoundsSlowReacting: 20,
164164
NumFloodingRoundsFastReacting: 30,
165165
NumFloodingRoundsOutOfSpecs: 40,
166+
MaxConsecutiveRoundsOfRatingDecrease: 600,
166167
},
167168
},
168169
&epochNotifier.RoundNotifierStub{},

process/peer/process.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,6 @@ func NewValidatorStatisticsProcessor(arguments ArgValidatorStatisticsProcessor)
111111
if arguments.MaxComputableRounds == 0 {
112112
return nil, process.ErrZeroMaxComputableRounds
113113
}
114-
// TODO: Here
115-
//if arguments.MaxConsecutiveRoundsOfRatingDecrease == 0 {
116-
// return nil, process.ErrZeroMaxConsecutiveRoundsOfRatingDecrease
117-
//}
118114
if check.IfNil(arguments.Rater) {
119115
return nil, process.ErrNilRater
120116
}

process/track/baseBlockTrack_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ func CreateShardTrackerMockArguments() track.ArgShardTracker {
151151
NumFloodingRoundsSlowReacting: 20,
152152
NumFloodingRoundsFastReacting: 30,
153153
NumFloodingRoundsOutOfSpecs: 40,
154+
MaxConsecutiveRoundsOfRatingDecrease: 600,
154155
},
155156
},
156157
&epochNotifier.RoundNotifierStub{},

0 commit comments

Comments
 (0)