Skip to content

Commit 4612530

Browse files
committed
change max supported feeds to uint64, supported feeds update interval to int64
1 parent a523095 commit 4612530

File tree

8 files changed

+42
-45
lines changed

8 files changed

+42
-45
lines changed

benchmark/feeds_bench_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func setupFeeds(ba *BenchmarkApp) error {
140140
ba.CallBeginBlock()
141141

142142
feeds := []types.Feed{}
143-
for i := int64(0); i < numFeeds; i++ {
143+
for i := uint64(0); i < numFeeds; i++ {
144144
feeds = append(feeds, types.Feed{
145145
SignalID: fmt.Sprintf("signal.%d", i),
146146
Interval: 60,

proto/feeds/v1beta1/params.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ message Params {
3333
int64 power_step_threshold = 6;
3434

3535
// MaxSupportedFeeds is the maximum number of feeds supported at a time.
36-
int64 max_supported_feeds = 7;
36+
uint64 max_supported_feeds = 7;
3737

3838
// CooldownTime represents the duration (in seconds) during which validators are prohibited from sending new prices.
3939
int64 cooldown_time = 8;
@@ -45,5 +45,5 @@ message Params {
4545
int64 max_deviation_basis_point = 10;
4646

4747
// SupportedFeedsUpdateInterval is the number of blocks after which the supported feeds will be re-calculated.
48-
uint64 supported_feeds_update_interval = 11;
48+
int64 supported_feeds_update_interval = 11;
4949
}

x/feeds/abci.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
// HandleEndBlock is a handler function for the EndBlock ABCI request.
1010
func HandleEndBlock(ctx sdk.Context, k keeper.Keeper) {
1111
k.CalculatePrices(ctx)
12-
if ctx.BlockHeight()%int64(k.GetParams(ctx).SupportedFeedsUpdateInterval) == 0 {
12+
if ctx.BlockHeight()%k.GetParams(ctx).SupportedFeedsUpdateInterval == 0 {
1313
feeds := k.CalculateNewSupportedFeeds(ctx)
1414
k.SetSupportedFeeds(ctx, feeds)
1515
}

x/feeds/keeper/keeper_signal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func (k Keeper) deleteSignalTotalPowerByPowerIndex(ctx sdk.Context, signalTotalP
118118
}
119119

120120
// GetSignalTotalPowersByPower gets the current signal-total-power sorted by power-rank.
121-
func (k Keeper) GetSignalTotalPowersByPower(ctx sdk.Context, limit int64) []types.Signal {
121+
func (k Keeper) GetSignalTotalPowersByPower(ctx sdk.Context, limit uint64) []types.Signal {
122122
signalTotalPowers := make([]types.Signal, limit)
123123

124124
iterator := k.SignalTotalPowersByPowerStoreIterator(ctx)

x/feeds/types/params.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ const (
1111
DefaultMinInterval = int64(60)
1212
DefaultMaxInterval = int64(3600)
1313
DefaultPowerStepThreshold = int64(1_000_000_000)
14-
DefaultMaxSupportedFeeds = int64(300)
14+
DefaultMaxSupportedFeeds = uint64(300)
1515
DefaultCooldownTime = int64(30)
1616
DefaultMinDeviationBasisPoint = int64(50)
1717
DefaultMaxDeviationBasisPoint = int64(3000)
1818
// estimated from block time of 3 seconds, aims for 1 day update
19-
DefaultSupportedFeedsUpdateInterval = uint64(28800)
19+
DefaultSupportedFeedsUpdateInterval = int64(28800)
2020
)
2121

2222
// NewParams creates a new Params instance
@@ -27,11 +27,11 @@ func NewParams(
2727
minInterval int64,
2828
maxInterval int64,
2929
powerStepThreshold int64,
30-
maxSupportedFeeds int64,
30+
maxSupportedFeeds uint64,
3131
cooldownTime int64,
3232
minDeviationBasisPoint int64,
3333
maxDeviationBasisPoint int64,
34-
supportedFeedsUpdateInterval uint64,
34+
supportedFeedsUpdateInterval int64,
3535
) Params {
3636
return Params{
3737
Admin: admin,
@@ -85,7 +85,7 @@ func (p Params) Validate() error {
8585
if err := validateInt64("power threshold", true, p.PowerStepThreshold); err != nil {
8686
return err
8787
}
88-
if err := validateInt64("max supported feeds", true, p.MaxSupportedFeeds); err != nil {
88+
if err := validateUint64("max supported feeds", false, p.MaxSupportedFeeds); err != nil {
8989
return err
9090
}
9191
if err := validateInt64("cooldown time", true, p.CooldownTime); err != nil {
@@ -97,7 +97,7 @@ func (p Params) Validate() error {
9797
if err := validateInt64("max deviation basis point", true, p.MaxDeviationBasisPoint); err != nil {
9898
return err
9999
}
100-
if err := validateUint64("supported feeds update interval", true, p.SupportedFeedsUpdateInterval); err != nil {
100+
if err := validateInt64("supported feeds update interval", true, p.SupportedFeedsUpdateInterval); err != nil {
101101
return err
102102
}
103103

x/feeds/types/params.pb.go

Lines changed: 29 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x/feeds/types/params_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ func TestParams_Validate(t *testing.T) {
5555
params.PowerStepThreshold = -10 // Invalid value
5656
return params
5757
}(), fmt.Errorf("power threshold must be positive: -10")},
58-
{"invalid MaxSupportedFeeds", func() types.Params {
59-
params := types.DefaultParams()
60-
params.MaxSupportedFeeds = 0 // Invalid value
61-
return params
62-
}(), fmt.Errorf("max supported feeds must be positive: 0")},
6358
{"invalid CooldownTime", func() types.Params {
6459
params := types.DefaultParams()
6560
params.CooldownTime = -5 // Invalid value
@@ -90,6 +85,7 @@ func TestParams_Validate(t *testing.T) {
9085
require.NoError(t, got)
9186
return
9287
}
88+
require.Error(t, got)
9389
require.Equal(t, tt.wantErr.Error(), got.Error())
9490
})
9591
}

x/feeds/types/query.pb.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)