Skip to content

Commit a18a92e

Browse files
authored
release: v8.2.0 (#253)
2 parents 254b0df + 5015046 commit a18a92e

File tree

6 files changed

+59
-22
lines changed

6 files changed

+59
-22
lines changed

core/context.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package core
33
import (
44
"context"
55
"errors"
6+
"fmt"
67
"io"
78
"path/filepath"
89
"sync"
@@ -252,23 +253,33 @@ func (c *Context) TLSKeyFile() string {
252253
}
253254

254255
// SanitizedGigabytePrices returns gigabyte prices filtered to include only valid denominations.
255-
func (c *Context) SanitizedGigabytePrices(ctx context.Context) v1.Prices {
256+
func (c *Context) SanitizedGigabytePrices(ctx context.Context) (v1.Prices, error) {
256257
params, err := c.Client().NodeParams(ctx)
257258
if err != nil {
258-
panic(err)
259+
return nil, fmt.Errorf("getting node params: %w", err)
259260
}
260261

261-
return c.sanitizePrices(c.GigabytePrices(), params.GetMinGigabytePrices())
262+
prices := c.sanitizePrices(
263+
c.GigabytePrices(),
264+
params.GetMinGigabytePrices(),
265+
)
266+
267+
return prices, nil
262268
}
263269

264270
// SanitizedHourlyPrices returns hourly prices filtered to include only valid denominations.
265-
func (c *Context) SanitizedHourlyPrices(ctx context.Context) v1.Prices {
271+
func (c *Context) SanitizedHourlyPrices(ctx context.Context) (v1.Prices, error) {
266272
params, err := c.Client().NodeParams(ctx)
267273
if err != nil {
268-
panic(err)
274+
return nil, fmt.Errorf("getting node params: %w", err)
269275
}
270276

271-
return c.sanitizePrices(c.HourlyPrices(), params.GetMinHourlyPrices())
277+
prices := c.sanitizePrices(
278+
c.HourlyPrices(),
279+
params.GetMinHourlyPrices(),
280+
)
281+
282+
return prices, nil
272283
}
273284

274285
// SetLocation sets the geolocation data in the context.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/cosmos/cosmos-sdk v0.47.17
99
github.com/gin-contrib/cors v1.7.6
1010
github.com/gin-gonic/gin v1.11.0
11-
github.com/sentinel-official/sentinel-go-sdk v1.0.0
11+
github.com/sentinel-official/sentinel-go-sdk v1.0.1-0.20251028202929-21beb4dcafa5
1212
github.com/sentinel-official/sentinelhub/v12 v12.0.0
1313
github.com/spf13/cobra v1.10.1
1414
github.com/spf13/pflag v1.0.10

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,8 @@ github.com/secure-io/siv-go v0.0.0-20180922214919-5ff40651e2c4 h1:zOjq+1/uLzn/Xo
576576
github.com/secure-io/siv-go v0.0.0-20180922214919-5ff40651e2c4/go.mod h1:aI+8yClBW+1uovkHw6HM01YXnYB8vohtB9C83wzx34E=
577577
github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb h1:XfLJSPIOUX+osiMraVgIrMR27uMXnRJWGm1+GL8/63U=
578578
github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb/go.mod h1:bR6DqgcAl1zTcOX8/pE2Qkj9XO00eCNqmKb7lXP8EAg=
579-
github.com/sentinel-official/sentinel-go-sdk v1.0.0 h1:7g/VibZlTWLZssRPJ9+9BWHuRBWvgBpBitP2nJ9lBQM=
580-
github.com/sentinel-official/sentinel-go-sdk v1.0.0/go.mod h1:N6mOoaBbrhiphJE8hk42lJZn0J1qZA+uVeOW6/tJfeY=
579+
github.com/sentinel-official/sentinel-go-sdk v1.0.1-0.20251028202929-21beb4dcafa5 h1:IYO60H1U9jQfpUYHieXmAL647FIPfgdrrS24wSy6b1M=
580+
github.com/sentinel-official/sentinel-go-sdk v1.0.1-0.20251028202929-21beb4dcafa5/go.mod h1:N6mOoaBbrhiphJE8hk42lJZn0J1qZA+uVeOW6/tJfeY=
581581
github.com/sentinel-official/sentinelhub/v12 v12.0.0 h1:Iw/6DnJllgSHR4beWdY95VpVNy0ZGESa3TcNrGAtBS8=
582582
github.com/sentinel-official/sentinelhub/v12 v12.0.0/go.mod h1:IuD4dlUOKvJVMTcNcbtQ+AlhTFkiRNXg2DuNlXGjYC8=
583583
github.com/shirou/gopsutil/v4 v4.25.9 h1:JImNpf6gCVhKgZhtaAHJ0serfFGtlfIlSC08eaKdTrU=

node/node.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,15 @@ func (n *Node) Register(ctx context.Context) error {
8080
return nil
8181
}
8282

83-
gigabytePrices := n.Context().SanitizedGigabytePrices(ctx)
84-
hourlyPrices := n.Context().SanitizedHourlyPrices(ctx)
83+
gigabytePrices, err := n.Context().SanitizedGigabytePrices(ctx)
84+
if err != nil {
85+
return fmt.Errorf("sanitizing gigabyte prices: %w", err)
86+
}
87+
88+
hourlyPrices, err := n.Context().SanitizedHourlyPrices(ctx)
89+
if err != nil {
90+
return fmt.Errorf("sanitizing hourly prices: %w", err)
91+
}
8592

8693
log.Info("Registering node",
8794
"gigabyte_prices", gigabytePrices,
@@ -109,8 +116,15 @@ func (n *Node) Register(ctx context.Context) error {
109116

110117
// UpdateDetails updates the node's pricing and address details on the network.
111118
func (n *Node) UpdateDetails(ctx context.Context) error {
112-
gigabytePrices := n.Context().SanitizedGigabytePrices(ctx)
113-
hourlyPrices := n.Context().SanitizedHourlyPrices(ctx)
119+
gigabytePrices, err := n.Context().SanitizedGigabytePrices(ctx)
120+
if err != nil {
121+
return fmt.Errorf("sanitizing gigabyte prices: %w", err)
122+
}
123+
124+
hourlyPrices, err := n.Context().SanitizedHourlyPrices(ctx)
125+
if err != nil {
126+
return fmt.Errorf("sanitizing hourly prices: %w", err)
127+
}
114128

115129
log.Info("Updating node details",
116130
"gigabyte_prices", gigabytePrices,

workers/node.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,24 @@ func NewNodeStatusUpdateWorker(c *core.Context, interval time.Duration) cron.Wor
4646
// NewNodePricesUpdateWorker creates a worker that periodically updates the node's prices on the blockchain.
4747
// The worker computes the current quote prices using the OracleClient and broadcasts a MsgUpdateNodeDetailsRequest.
4848
func NewNodePricesUpdateWorker(c *core.Context, interval time.Duration) cron.Worker {
49-
handlerFunc := func(ctx context.Context) error {
49+
handlerFunc := func(ctx context.Context) (err error) {
5050
client := c.OracleClient()
5151
if client == nil {
5252
return nil
5353
}
5454

55-
var gigabytePrices v1.Prices
55+
var (
56+
prices v1.Prices
57+
gigabytePrices v1.Prices
58+
hourlyPrices v1.Prices
59+
)
5660

57-
for _, price := range c.SanitizedGigabytePrices(ctx) {
61+
prices, err = c.SanitizedGigabytePrices(ctx)
62+
if err != nil {
63+
return fmt.Errorf("sanitizing gigabyte prices: %w", err)
64+
}
65+
66+
for _, price := range prices {
5867
price, err := price.UpdateQuoteValue(ctx, client.GetQuotePrice)
5968
if err != nil {
6069
return fmt.Errorf("updating quote price for denom %q: %w", price.Denom, err)
@@ -63,9 +72,12 @@ func NewNodePricesUpdateWorker(c *core.Context, interval time.Duration) cron.Wor
6372
gigabytePrices = gigabytePrices.Add(price)
6473
}
6574

66-
var hourlyPrices v1.Prices
75+
prices, err = c.SanitizedHourlyPrices(ctx)
76+
if err != nil {
77+
return fmt.Errorf("sanitizing hourly prices: %w", err)
78+
}
6779

68-
for _, price := range c.SanitizedHourlyPrices(ctx) {
80+
for _, price := range prices {
6981
price, err := price.UpdateQuoteValue(ctx, client.GetQuotePrice)
7082
if err != nil {
7183
return fmt.Errorf("updating quote price for denom %q: %w", price.Denom, err)

workers/session.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func NewSessionUsageSyncWithBlockchainWorker(c *core.Context, interval time.Dura
4848
)
4949

5050
jobGroup, jobCtx := errgroup.WithContext(ctx)
51-
jobGroup.SetLimit(8)
51+
jobGroup.SetLimit(2)
5252

5353
// Iterate over sessions and prepare messages for updates.
5454
for _, val := range items {
@@ -133,7 +133,7 @@ func NewSessionUsageSyncWithDatabaseWorker(c *core.Context, interval time.Durati
133133
}
134134

135135
jobGroup, jobCtx := errgroup.WithContext(ctx)
136-
jobGroup.SetLimit(8)
136+
jobGroup.SetLimit(2)
137137

138138
// Update the database with the fetched statistics.
139139
for key, val := range items {
@@ -214,7 +214,7 @@ func NewSessionUsageValidateWorker(c *core.Context, interval time.Duration) cron
214214
}
215215

216216
jobGroup, jobCtx := errgroup.WithContext(ctx)
217-
jobGroup.SetLimit(8)
217+
jobGroup.SetLimit(2)
218218

219219
// Validate session limits and remove peers if needed.
220220
for _, val := range items {
@@ -295,7 +295,7 @@ func NewSessionValidateWorker(c *core.Context, interval time.Duration) cron.Work
295295
}
296296

297297
jobGroup, jobCtx := errgroup.WithContext(ctx)
298-
jobGroup.SetLimit(8)
298+
jobGroup.SetLimit(2)
299299

300300
// Validate session status and consistency.
301301
for _, val := range items {

0 commit comments

Comments
 (0)