Skip to content

Commit 15acfa7

Browse files
Merge branch 'dev' into version-bump-1.3.1
2 parents bf189df + 6eea372 commit 15acfa7

File tree

18 files changed

+59
-136
lines changed

18 files changed

+59
-136
lines changed

chains/atomic/shared_memory.go

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -317,29 +317,37 @@ func (s *state) getKeys(traits [][]byte, startTrait, startKey []byte, limit int)
317317
}
318318

319319
lastTrait = trait
320-
lastKey = startKey
320+
var err error
321+
lastKey, err = s.appendTraitKeys(&keys, &tracked, &limit, trait, startKey)
322+
if err != nil {
323+
return nil, nil, nil, err
324+
}
321325

322-
traitDB := prefixdb.New(trait, s.indexDB)
323-
iter := traitDB.NewIteratorWithStart(startKey)
324-
for iter.Next() {
325-
if limit == 0 {
326-
iter.Release()
327-
return keys, lastTrait, lastKey, nil
328-
}
329-
330-
key := iter.Key()
331-
lastKey = key
332-
333-
id := hashing.ComputeHash256Array(key)
334-
if tracked.Contains(id) {
335-
continue
336-
}
337-
338-
tracked.Add(id)
339-
keys = append(keys, key)
340-
limit--
326+
if limit == 0 {
327+
break
341328
}
342-
iter.Release()
343329
}
344330
return keys, lastTrait, lastKey, nil
345331
}
332+
333+
func (s *state) appendTraitKeys(keys *[][]byte, tracked *ids.Set, limit *int, trait, startKey []byte) ([]byte, error) {
334+
lastKey := startKey
335+
336+
traitDB := prefixdb.New(trait, s.indexDB)
337+
iter := traitDB.NewIteratorWithStart(startKey)
338+
defer iter.Release()
339+
for iter.Next() && *limit > 0 {
340+
key := iter.Key()
341+
lastKey = key
342+
343+
id := hashing.ComputeHash256Array(key)
344+
if tracked.Contains(id) {
345+
continue
346+
}
347+
348+
tracked.Add(id)
349+
*keys = append(*keys, key)
350+
*limit--
351+
}
352+
return lastKey, iter.Error()
353+
}

main/keys.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const (
5858
networkHealthMaxTimeSinceMsgSentKey = "network-health-max-time-since-msg-sent"
5959
networkHealthMaxPortionSendQueueFillKey = "network-health-max-portion-send-queue-full"
6060
networkHealthMaxSendFailRateKey = "network-health-max-send-fail-rate"
61-
networkHealthMaxTimeSinceNoReqsKey = "network-health-max-time-since-no-requests"
61+
networkHealthMaxOutstandingDurationKey = "network-health-max-outstanding-request-duration"
6262
sendQueueSizeKey = "send-queue-size"
6363
benchlistFailThresholdKey = "benchlist-fail-threshold"
6464
benchlistPeerSummaryEnabledKey = "benchlist-peer-summary-enabled"

main/params.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func avalancheFlagSet() *flag.FlagSet {
164164
fs.String(httpsCertFileKey, "", "TLS certificate file for the HTTPs server")
165165
fs.String(httpAllowedOrigins, "*", "Origins to allow on the HTTP port. Defaults to * which allows all origins. Example: https://*.avax.network https://*.avax-test.network")
166166
fs.Bool(apiAuthRequiredKey, false, "Require authorization token to call HTTP APIs")
167-
fs.String(apiAuthPasswordFileKey, "", "Password file used to initially create/validate API authorization tokens. Can be changed via API call.")
167+
fs.String(apiAuthPasswordFileKey, "", "Password file used to initially create/validate API authorization tokens. Leading and trailing whitespace is removed from the password. Can be changed via API call.")
168168
// Enable/Disable APIs
169169
fs.Bool(adminAPIEnabledKey, false, "If true, this node exposes the Admin API")
170170
fs.Bool(infoAPIEnabledKey, true, "If true, this node exposes the Info API")
@@ -187,7 +187,7 @@ func avalancheFlagSet() *flag.FlagSet {
187187
// Router Health
188188
fs.Float64(routerHealthMaxDropRateKey, 1, "Node reports unhealthy if the router drops more than this portion of messages.")
189189
fs.Uint(routerHealthMaxOutstandingRequestsKey, 1024, "Node reports unhealthy if there are more than this many outstanding consensus requests (Get, PullQuery, etc.) over all chains")
190-
fs.Duration(networkHealthMaxTimeSinceNoReqsKey, 5*time.Minute, "Node reports unhealthy if there is at least 1 outstanding request continuously for this duration")
190+
fs.Duration(networkHealthMaxOutstandingDurationKey, 5*time.Minute, "Node reports unhealthy if there has been a request outstanding for this duration")
191191

192192
// Staking
193193
fs.Uint(stakingPortKey, 9651, "Port of the consensus server")
@@ -513,7 +513,7 @@ func setNodeConfig(v *viper.Viper) error {
513513
if err != nil {
514514
return fmt.Errorf("api-auth-password-file %q failed to be read with: %w", passwordFile, err)
515515
}
516-
Config.APIAuthPassword = string(pwBytes)
516+
Config.APIAuthPassword = strings.TrimSpace(string(pwBytes))
517517
if !password.SufficientlyStrong(Config.APIAuthPassword, password.OK) {
518518
return errors.New("api-auth-password is not strong enough")
519519
}
@@ -541,14 +541,14 @@ func setNodeConfig(v *viper.Viper) error {
541541
Config.ConsensusRouter = &router.ChainRouter{}
542542
Config.RouterHealthConfig.MaxDropRate = v.GetFloat64(routerHealthMaxDropRateKey)
543543
Config.RouterHealthConfig.MaxOutstandingRequests = int(v.GetUint(routerHealthMaxOutstandingRequestsKey))
544-
Config.RouterHealthConfig.MaxTimeSinceNoOutstandingRequests = v.GetDuration(networkHealthMaxTimeSinceNoReqsKey)
544+
Config.RouterHealthConfig.MaxOutstandingDuration = v.GetDuration(networkHealthMaxOutstandingDurationKey)
545545
Config.RouterHealthConfig.MaxRunTimeRequests = v.GetDuration(networkMaximumTimeoutKey)
546546
Config.RouterHealthConfig.MaxDropRateHalflife = healthCheckAveragerHalflife
547547
switch {
548548
case Config.RouterHealthConfig.MaxDropRate < 0 || Config.RouterHealthConfig.MaxDropRate > 1:
549549
return fmt.Errorf("%s must be in [0,1]", routerHealthMaxDropRateKey)
550-
case Config.RouterHealthConfig.MaxTimeSinceNoOutstandingRequests <= 0:
551-
return fmt.Errorf("%s must be positive", networkHealthMaxTimeSinceNoReqsKey)
550+
case Config.RouterHealthConfig.MaxOutstandingDuration <= 0:
551+
return fmt.Errorf("%s must be positive", networkHealthMaxOutstandingDurationKey)
552552
}
553553

554554
// IPCs

node/node.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,8 @@ func (n *Node) initIPCs() error {
476476
}
477477

478478
// Initializes the Platform chain.
479-
// Its genesis data specifies the other chains that should
480-
// be created.
481-
func (n *Node) initChains(genesisBytes []byte, avaxAssetID ids.ID) error {
479+
// Its genesis data specifies the other chains that should be created.
480+
func (n *Node) initChains(genesisBytes []byte) {
482481
n.Log.Info("initializing chains")
483482

484483
// Create the Platform Chain
@@ -489,8 +488,6 @@ func (n *Node) initChains(genesisBytes []byte, avaxAssetID ids.ID) error {
489488
VMAlias: platformvm.ID.String(),
490489
CustomBeacons: n.beacons,
491490
})
492-
493-
return nil
494491
}
495492

496493
// initAPIServer initializes the server that handles HTTP calls
@@ -908,9 +905,8 @@ func (n *Node) Initialize(
908905
if err := n.initAliases(n.Config.GenesisBytes); err != nil { // Set up aliases
909906
return fmt.Errorf("couldn't initialize aliases: %w", err)
910907
}
911-
if err := n.initChains(n.Config.GenesisBytes, n.Config.AvaxAssetID); err != nil { // Start the Platform chain
912-
return fmt.Errorf("couldn't initialize chains: %w", err)
913-
}
908+
// Start the Platform chain
909+
n.initChains(n.Config.GenesisBytes)
914910
return nil
915911
}
916912

snow/engine/avalanche/issuer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func (i *issuer) Update() {
110110
}
111111

112112
// Issue a repoll
113-
i.t.errs.Add(i.t.repoll())
113+
i.t.repoll()
114114
}
115115

116116
type vtxIssuer struct{ i *issuer }

snow/engine/avalanche/transitive.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -365,15 +365,10 @@ func (t *Transitive) attemptToIssueTxs() error {
365365
// If there are pending transactions from the VM, issue them.
366366
// If we're not already at the limit for number of concurrent polls, issue a new
367367
// query.
368-
func (t *Transitive) repoll() error {
369-
if t.polls.Len() >= t.Params.ConcurrentRepolls || t.errs.Errored() {
370-
return nil
371-
}
372-
373-
for i := t.polls.Len(); i < t.Params.ConcurrentRepolls; i++ {
368+
func (t *Transitive) repoll() {
369+
for i := t.polls.Len(); i < t.Params.ConcurrentRepolls && !t.errs.Errored(); i++ {
374370
t.issueRepoll()
375371
}
376-
return nil
377372
}
378373

379374
// issueFromByID issues the branch ending with vertex [vtxID] to consensus.

snow/engine/avalanche/transitive_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,8 @@ func TestEngineIssueRepoll(t *testing.T) {
11091109
}
11101110
}
11111111

1112-
if err := te.repoll(); err != nil {
1112+
te.repoll()
1113+
if err := te.errs.Err; err != nil {
11131114
t.Fatal(err)
11141115
}
11151116
}

snow/engine/avalanche/voter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (v *voter) Update() {
7373
}
7474

7575
v.t.Ctx.Log.Debug("Avalanche engine can't quiesce")
76-
v.t.errs.Add(v.t.repoll())
76+
v.t.repoll()
7777
}
7878

7979
func (v *voter) bubbleVotes(votes ids.UniqueBag) (ids.UniqueBag, error) {

snow/networking/router/chain_router.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func (cr *ChainRouter) Initialize(
101101
cr.healthConfig = healthConfig
102102

103103
// Register metrics
104-
rMetrics, err := newRouterMetrics(cr.log, metricsNamespace, metricsRegisterer)
104+
rMetrics, err := newRouterMetrics(metricsNamespace, metricsRegisterer)
105105
if err != nil {
106106
return err
107107
}
@@ -787,22 +787,14 @@ func (cr *ChainRouter) HealthCheck() (interface{}, error) {
787787
healthy = healthy && numOutstandingReqs <= cr.healthConfig.MaxOutstandingRequests
788788
details["outstandingRequests"] = numOutstandingReqs
789789

790-
now := cr.clock.Time()
791-
if numOutstandingReqs == 0 {
792-
cr.lastTimeNoOutstanding = now
793-
}
794-
timeSinceNoOutstandingRequests := now.Sub(cr.lastTimeNoOutstanding)
795-
healthy = healthy && timeSinceNoOutstandingRequests <= cr.healthConfig.MaxTimeSinceNoOutstandingRequests
796-
details["timeSinceNoOutstandingRequests"] = timeSinceNoOutstandingRequests.String()
797-
cr.metrics.timeSinceNoOutstandingRequests.Set(float64(timeSinceNoOutstandingRequests.Milliseconds()))
798-
799790
// check for long running requests
791+
now := cr.clock.Time()
800792
processingRequest := now
801793
if longestRunning, exists := cr.timedRequests.Oldest(); exists {
802794
processingRequest = longestRunning.(requestEntry).time
803795
}
804796
timeReqRunning := now.Sub(processingRequest)
805-
healthy = healthy && timeReqRunning <= cr.healthConfig.MaxTimeSinceNoOutstandingRequests
797+
healthy = healthy && timeReqRunning <= cr.healthConfig.MaxOutstandingDuration
806798
details["longestRunningRequest"] = timeReqRunning.String()
807799
cr.metrics.longestRunningRequest.Set(float64(timeReqRunning.Milliseconds()))
808800

snow/networking/router/chain_router_metrics.go

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,18 @@
44
package router
55

66
import (
7-
"github.com/ava-labs/avalanchego/utils/logging"
87
"github.com/ava-labs/avalanchego/utils/wrappers"
98
"github.com/prometheus/client_golang/prometheus"
109
)
1110

1211
// routerMetrics about router messages
1312
type routerMetrics struct {
14-
outstandingRequests prometheus.Gauge
15-
msgDropRate prometheus.Gauge
16-
timeSinceNoOutstandingRequests prometheus.Gauge
17-
longestRunningRequest prometheus.Gauge
13+
outstandingRequests prometheus.Gauge
14+
msgDropRate prometheus.Gauge
15+
longestRunningRequest prometheus.Gauge
1816
}
1917

20-
func newRouterMetrics(log logging.Logger, namespace string, registerer prometheus.Registerer) (*routerMetrics, error) {
18+
func newRouterMetrics(namespace string, registerer prometheus.Registerer) (*routerMetrics, error) {
2119
rMetrics := &routerMetrics{}
2220
rMetrics.outstandingRequests = prometheus.NewGauge(
2321
prometheus.GaugeOpts{
@@ -33,13 +31,6 @@ func newRouterMetrics(log logging.Logger, namespace string, registerer prometheu
3331
Help: "Rate of messages dropped",
3432
},
3533
)
36-
rMetrics.timeSinceNoOutstandingRequests = prometheus.NewGauge(
37-
prometheus.GaugeOpts{
38-
Namespace: namespace,
39-
Name: "time_since_no_outstanding_requests",
40-
Help: "Time with no requests being processed in milliseconds",
41-
},
42-
)
4334
rMetrics.longestRunningRequest = prometheus.NewGauge(
4435
prometheus.GaugeOpts{
4536
Namespace: namespace,
@@ -52,7 +43,6 @@ func newRouterMetrics(log logging.Logger, namespace string, registerer prometheu
5243
errs.Add(
5344
registerer.Register(rMetrics.outstandingRequests),
5445
registerer.Register(rMetrics.msgDropRate),
55-
registerer.Register(rMetrics.timeSinceNoOutstandingRequests),
5646
registerer.Register(rMetrics.longestRunningRequest),
5747
)
5848
return rMetrics, errs.Err

0 commit comments

Comments
 (0)