Skip to content

Commit 306b369

Browse files
committed
chore: rename active_duration and status_change_delay parameter to status_timeout
1 parent 21ad688 commit 306b369

File tree

16 files changed

+180
-181
lines changed

16 files changed

+180
-181
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ proto-gen:
7676

7777
.PHONY: proto-lint
7878
proto-lint:
79-
find proto -name *.proto -exec buf format -w {} \;
79+
@find proto -name *.proto -exec buf format -w {} \;
8080

8181
.PHONY: build-image
8282
build-image:

proto/sentinel/node/v3/params.proto

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ option (gogoproto.equal_all) = false;
1111
option (gogoproto.goproto_getters_all) = false;
1212

1313
message Params {
14-
google.protobuf.Duration active_duration = 1 [
14+
cosmos.base.v1beta1.Coin deposit = 1 [(gogoproto.nullable) = false];
15+
repeated sentinel.types.v1.Price min_gigabyte_prices = 2 [(gogoproto.nullable) = false];
16+
repeated sentinel.types.v1.Price min_hourly_prices = 3 [(gogoproto.nullable) = false];
17+
google.protobuf.Duration status_timeout = 4 [
1518
(gogoproto.nullable) = false,
1619
(gogoproto.stdduration) = true
1720
];
18-
cosmos.base.v1beta1.Coin deposit = 2 [(gogoproto.nullable) = false];
19-
repeated sentinel.types.v1.Price min_gigabyte_prices = 3 [(gogoproto.nullable) = false];
20-
repeated sentinel.types.v1.Price min_hourly_prices = 4 [(gogoproto.nullable) = false];
2121
}

proto/sentinel/session/v3/params.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ message Params {
1818
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
1919
(gogoproto.nullable) = false
2020
];
21-
google.protobuf.Duration status_change_delay = 7 [
21+
google.protobuf.Duration status_timeout = 7 [
2222
(gogoproto.nullable) = false,
2323
(gogoproto.stdduration) = true
2424
];

proto/sentinel/subscription/v3/params.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ message Params {
1313
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
1414
(gogoproto.nullable) = false
1515
];
16-
google.protobuf.Duration status_change_delay = 2 [
16+
google.protobuf.Duration status_timeout = 2 [
1717
(gogoproto.nullable) = false,
1818
(gogoproto.stdduration) = true
1919
];

x/node/keeper/params.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ func (k *Keeper) GetParams(ctx sdk.Context) (v v3.Params) {
3131
return v
3232
}
3333

34-
// ActiveDuration retrieves the active duration parameter from the module's parameters.
35-
func (k *Keeper) ActiveDuration(ctx sdk.Context) time.Duration {
36-
return k.GetParams(ctx).ActiveDuration
37-
}
38-
3934
// Deposit retrieves the deposit parameter from the module's parameters.
4035
func (k *Keeper) Deposit(ctx sdk.Context) sdk.Coin {
4136
return k.GetParams(ctx).Deposit
@@ -51,6 +46,11 @@ func (k *Keeper) MinHourlyPrices(ctx sdk.Context) v1base.Prices {
5146
return k.GetParams(ctx).MinHourlyPrices
5247
}
5348

49+
// StatusTimeout retrieves the status timeout parameter from the module's parameters.
50+
func (k *Keeper) StatusTimeout(ctx sdk.Context) time.Duration {
51+
return k.GetParams(ctx).StatusTimeout
52+
}
53+
5454
// ValidateGigabytePrices validates prices against the minimum gigabyte prices.
5555
func (k *Keeper) ValidateGigabytePrices(ctx sdk.Context, prices v1base.Prices) error {
5656
minPrices := k.MinGigabytePrices(ctx)
@@ -65,9 +65,9 @@ func (k *Keeper) ValidateHourlyPrices(ctx sdk.Context, prices v1base.Prices) err
6565
return validatePrices(prices, minPrices)
6666
}
6767

68-
// GetInactiveAt returns the inactive time by adding ActiveDuration to the current block time.
68+
// GetInactiveAt returns the inactive time by adding StatusTimeout to the current block time.
6969
func (k *Keeper) GetInactiveAt(ctx sdk.Context) time.Time {
70-
d := k.ActiveDuration(ctx)
70+
d := k.StatusTimeout(ctx)
7171

7272
return ctx.BlockTime().Add(d)
7373
}

x/node/migrations/migrator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ func (k *Migrator) deleteKeys(ctx sdk.Context, keyPrefix []byte) (keys [][]byte)
5555

5656
func (k *Migrator) setParams(ctx sdk.Context) {
5757
params := v3.Params{
58-
ActiveDuration: 1 * time.Hour,
5958
Deposit: sdk.NewInt64Coin("udvpn", 0),
6059
MinGigabytePrices: []v1.Price{}, // TODO: set min gigabyte prices
6160
MinHourlyPrices: []v1.Price{}, // TODO: set min hourly prices
61+
StatusTimeout: 1 * time.Hour,
6262
}
6363

6464
k.node.SetParams(ctx, params)

x/node/types/v3/params.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ import (
1212
)
1313

1414
var (
15-
// DefaultActiveDuration defines the default duration a node remains active after registration.
16-
DefaultActiveDuration = 30 * time.Second
17-
1815
// DefaultDeposit defines the default amount of deposit required for a node.
1916
DefaultDeposit = sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(10))
2017

@@ -35,6 +32,9 @@ var (
3532
QuoteValue: sdkmath.NewInt(10),
3633
},
3734
}
35+
36+
// DefaultStatusTimeout defines the default duration before a status is considered outdated.
37+
DefaultStatusTimeout = 30 * time.Second
3838
)
3939

4040
// GetMinGigabytePrices returns the minimum gigabyte prices configured in the parameters.
@@ -49,10 +49,6 @@ func (m *Params) GetMinHourlyPrices() v1base.Prices {
4949

5050
// Validate validates all parameters to ensure they conform to expected rules.
5151
func (m *Params) Validate() error {
52-
if err := validateActiveDuration(m.ActiveDuration); err != nil {
53-
return fmt.Errorf("invalid active_duration: %w", err)
54-
}
55-
5652
if err := validateDeposit(m.Deposit); err != nil {
5753
return fmt.Errorf("invalid deposit: %w", err)
5854
}
@@ -65,44 +61,35 @@ func (m *Params) Validate() error {
6561
return fmt.Errorf("invalid min_hourly_prices: %w", err)
6662
}
6763

64+
if err := validateStatusTimeout(m.StatusTimeout); err != nil {
65+
return fmt.Errorf("invalid status_timeout: %w", err)
66+
}
67+
6868
return nil
6969
}
7070

7171
// NewParams creates a new Params instance with the provided values.
7272
func NewParams(
73-
activeDuration time.Duration, deposit sdk.Coin, minGigabytePrices, minHourlyPrices v1base.Prices,
73+
deposit sdk.Coin, minGigabytePrices, minHourlyPrices v1base.Prices, statusTimeout time.Duration,
7474
) Params {
7575
return Params{
76-
ActiveDuration: activeDuration,
7776
Deposit: deposit,
7877
MinGigabytePrices: minGigabytePrices,
7978
MinHourlyPrices: minHourlyPrices,
79+
StatusTimeout: statusTimeout,
8080
}
8181
}
8282

8383
// DefaultParams returns the default parameters for the module.
8484
func DefaultParams() Params {
8585
return NewParams(
86-
DefaultActiveDuration,
8786
DefaultDeposit,
8887
DefaultMinGigabytePrices,
8988
DefaultMinHourlyPrices,
89+
DefaultStatusTimeout,
9090
)
9191
}
9292

93-
// validateActiveDuration checks that the active duration is greater than zero.
94-
func validateActiveDuration(v time.Duration) error {
95-
if v == 0 {
96-
return errors.New("value cannot be zero")
97-
}
98-
99-
if v < 0 {
100-
return errors.New("value cannot be negative")
101-
}
102-
103-
return nil
104-
}
105-
10693
// validateDeposit checks that the deposit is not nil, not negative, and valid.
10794
func validateDeposit(v sdk.Coin) error {
10895
if v.IsNil() {
@@ -145,3 +132,16 @@ func validateMinHourlyPrices(v []v1base.Price) error {
145132

146133
return nil
147134
}
135+
136+
// validateStatusTimeout checks that the status duration is greater than zero.
137+
func validateStatusTimeout(v time.Duration) error {
138+
if v == 0 {
139+
return errors.New("value cannot be zero")
140+
}
141+
142+
if v < 0 {
143+
return errors.New("value cannot be negative")
144+
}
145+
146+
return nil
147+
}

0 commit comments

Comments
 (0)