Skip to content

Commit

Permalink
merged
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph committed Nov 8, 2024
2 parents 8c56d05 + a411226 commit 3867b1b
Show file tree
Hide file tree
Showing 123 changed files with 8,401 additions and 3,838 deletions.
2 changes: 2 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
## How this works

## How this was tested

## Need to be documented in RELEASES.md?
9 changes: 9 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Release Notes

## Pending Release

### Configs

- Added P-chain configs
- `"l1-weights-cache-size"`
- `"l1-inactive-validators-cache-size"`
- `"l1-subnet-id-node-id-cache-size"`

## [v1.11.11](https://github.com/ava-labs/avalanchego/releases/tag/v1.11.11)

This version is backwards compatible to [v1.11.0](https://github.com/ava-labs/avalanchego/releases/tag/v1.11.0). It is optional, but encouraged.
Expand Down
8 changes: 5 additions & 3 deletions api/info/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Client interface {
GetNetworkID(context.Context, ...rpc.Option) (uint32, error)
GetNetworkName(context.Context, ...rpc.Option) (string, error)
GetBlockchainID(context.Context, string, ...rpc.Option) (ids.ID, error)
Peers(context.Context, ...rpc.Option) ([]Peer, error)
Peers(context.Context, []ids.NodeID, ...rpc.Option) ([]Peer, error)
IsBootstrapped(context.Context, string, ...rpc.Option) (bool, error)
GetTxFee(context.Context, ...rpc.Option) (*GetTxFeeResponse, error)
Upgrades(context.Context, ...rpc.Option) (*upgrade.Config, error)
Expand Down Expand Up @@ -83,9 +83,11 @@ func (c *client) GetBlockchainID(ctx context.Context, alias string, options ...r
return res.BlockchainID, err
}

func (c *client) Peers(ctx context.Context, options ...rpc.Option) ([]Peer, error) {
func (c *client) Peers(ctx context.Context, nodeIDs []ids.NodeID, options ...rpc.Option) ([]Peer, error) {
res := &PeersReply{}
err := c.requester.SendRequest(ctx, "info.peers", struct{}{}, res, options...)
err := c.requester.SendRequest(ctx, "info.peers", &PeersArgs{
NodeIDs: nodeIDs,
}, res, options...)
return res.Peers, err
}

Expand Down
14 changes: 8 additions & 6 deletions api/metrics/label_gatherer.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ func (g *labelGatherer) Register(labelValue string, gatherer prometheus.Gatherer
)
}

g.names = append(g.names, labelValue)
g.gatherers = append(g.gatherers, &labeledGatherer{
labelName: g.labelName,
labelValue: labelValue,
gatherer: gatherer,
})
g.register(
labelValue,
&labeledGatherer{
labelName: g.labelName,
labelValue: labelValue,
gatherer: gatherer,
},
)
return nil
}

Expand Down
100 changes: 88 additions & 12 deletions api/metrics/label_gatherer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,13 @@ func TestLabelGatherer_Gather(t *testing.T) {
}
}

func TestLabelGatherer_Register(t *testing.T) {
func TestLabelGatherer_Registration(t *testing.T) {
const (
firstName = "first"
secondName = "second"
)
firstLabeledGatherer := &labeledGatherer{
labelValue: "first",
labelValue: firstName,
gatherer: &testGatherer{},
}
firstLabelGatherer := func() *labelGatherer {
Expand All @@ -154,25 +158,37 @@ func TestLabelGatherer_Register(t *testing.T) {
}
}
secondLabeledGatherer := &labeledGatherer{
labelValue: "second",
labelValue: secondName,
gatherer: &testGatherer{
mfs: []*dto.MetricFamily{{}},
},
}
secondLabelGatherer := &labelGatherer{
secondLabelGatherer := func() *labelGatherer {
return &labelGatherer{
multiGatherer: multiGatherer{
names: []string{
firstLabeledGatherer.labelValue,
secondLabeledGatherer.labelValue,
},
gatherers: prometheus.Gatherers{
firstLabeledGatherer,
secondLabeledGatherer,
},
},
}
}
onlySecondLabeledGatherer := &labelGatherer{
multiGatherer: multiGatherer{
names: []string{
firstLabeledGatherer.labelValue,
secondLabeledGatherer.labelValue,
},
gatherers: prometheus.Gatherers{
firstLabeledGatherer,
secondLabeledGatherer,
},
},
}

tests := []struct {
registerTests := []struct {
name string
labelGatherer *labelGatherer
labelValue string
Expand All @@ -183,29 +199,29 @@ func TestLabelGatherer_Register(t *testing.T) {
{
name: "first registration",
labelGatherer: &labelGatherer{},
labelValue: "first",
labelValue: firstName,
gatherer: firstLabeledGatherer.gatherer,
expectedErr: nil,
expectedLabelGatherer: firstLabelGatherer(),
},
{
name: "second registration",
labelGatherer: firstLabelGatherer(),
labelValue: "second",
labelValue: secondName,
gatherer: secondLabeledGatherer.gatherer,
expectedErr: nil,
expectedLabelGatherer: secondLabelGatherer,
expectedLabelGatherer: secondLabelGatherer(),
},
{
name: "conflicts with previous registration",
labelGatherer: firstLabelGatherer(),
labelValue: "first",
labelValue: firstName,
gatherer: secondLabeledGatherer.gatherer,
expectedErr: errDuplicateGatherer,
expectedLabelGatherer: firstLabelGatherer(),
},
}
for _, test := range tests {
for _, test := range registerTests {
t.Run(test.name, func(t *testing.T) {
require := require.New(t)

Expand All @@ -214,4 +230,64 @@ func TestLabelGatherer_Register(t *testing.T) {
require.Equal(test.expectedLabelGatherer, test.labelGatherer)
})
}

deregisterTests := []struct {
name string
labelGatherer *labelGatherer
labelValue string
expectedRemoved bool
expectedLabelGatherer *labelGatherer
}{
{
name: "remove from nothing",
labelGatherer: &labelGatherer{},
labelValue: firstName,
expectedRemoved: false,
expectedLabelGatherer: &labelGatherer{},
},
{
name: "remove unknown name",
labelGatherer: firstLabelGatherer(),
labelValue: secondName,
expectedRemoved: false,
expectedLabelGatherer: firstLabelGatherer(),
},
{
name: "remove first name",
labelGatherer: firstLabelGatherer(),
labelValue: firstName,
expectedRemoved: true,
expectedLabelGatherer: &labelGatherer{
multiGatherer: multiGatherer{
// We must populate with empty slices rather than nil slices
// to pass the equality check.
names: []string{},
gatherers: prometheus.Gatherers{},
},
},
},
{
name: "remove second name",
labelGatherer: secondLabelGatherer(),
labelValue: secondName,
expectedRemoved: true,
expectedLabelGatherer: firstLabelGatherer(),
},
{
name: "remove only first name",
labelGatherer: secondLabelGatherer(),
labelValue: firstName,
expectedRemoved: true,
expectedLabelGatherer: onlySecondLabeledGatherer,
},
}
for _, test := range deregisterTests {
t.Run(test.name, func(t *testing.T) {
require := require.New(t)

removed := test.labelGatherer.Deregister(test.labelValue)
require.Equal(test.expectedRemoved, removed)
require.Equal(test.expectedLabelGatherer, test.labelGatherer)
})
}
}
32 changes: 26 additions & 6 deletions api/metrics/multi_gatherer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ package metrics

import (
"fmt"
"slices"
"sync"

"github.com/prometheus/client_golang/prometheus"

"github.com/ava-labs/avalanchego/utils"

dto "github.com/prometheus/client_model/go"
)

Expand All @@ -20,13 +23,11 @@ type MultiGatherer interface {
// Register adds the outputs of [gatherer] to the results of future calls to
// Gather with the provided [name] added to the metrics.
Register(name string, gatherer prometheus.Gatherer) error
}

// Deprecated: Use NewPrefixGatherer instead.
//
// TODO: Remove once coreth is updated.
func NewMultiGatherer() MultiGatherer {
return NewPrefixGatherer()
// Deregister removes the outputs of a gatherer with [name] from the results
// of future calls to Gather. Returns true if a gatherer with [name] was
// found.
Deregister(name string) bool
}

type multiGatherer struct {
Expand All @@ -42,6 +43,25 @@ func (g *multiGatherer) Gather() ([]*dto.MetricFamily, error) {
return g.gatherers.Gather()
}

func (g *multiGatherer) register(name string, gatherer prometheus.Gatherer) {
g.names = append(g.names, name)
g.gatherers = append(g.gatherers, gatherer)
}

func (g *multiGatherer) Deregister(name string) bool {
g.lock.Lock()
defer g.lock.Unlock()

index := slices.Index(g.names, name)
if index == -1 {
return false
}

g.names = utils.DeleteIndex(g.names, index)
g.gatherers = utils.DeleteIndex(g.gatherers, index)
return true
}

func MakeAndRegister(gatherer MultiGatherer, name string) (*prometheus.Registry, error) {
reg := prometheus.NewRegistry()
if err := gatherer.Register(name, reg); err != nil {
Expand Down
12 changes: 7 additions & 5 deletions api/metrics/prefix_gatherer.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ func (g *prefixGatherer) Register(prefix string, gatherer prometheus.Gatherer) e
}
}

g.names = append(g.names, prefix)
g.gatherers = append(g.gatherers, &prefixedGatherer{
prefix: prefix,
gatherer: gatherer,
})
g.register(
prefix,
&prefixedGatherer{
prefix: prefix,
gatherer: gatherer,
},
)
return nil
}

Expand Down
4 changes: 3 additions & 1 deletion config/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ must be the same with the number of given `--state-sync-ids`.

#### `--partial-sync-primary-network` (string)

Partial sync enables non-validators to optionally sync only the P-chain on the primary network.
Partial sync enables nodes that are not primary network validators to optionally sync
only the P-chain on the primary network. Nodes that use this option can still track
Subnets. After the Etna upgrade, nodes that use this option can also validate L1s.

## Chain Configs

Expand Down
2 changes: 1 addition & 1 deletion genesis/genesis_fuji.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var (
MaxPerSecond: 250_000,
TargetPerSecond: 125_000, // Target block size ~125KB
MinPrice: 1,
// ExcessConversionConstant = (Capacity - Target) * NumberOfSecondsPerDoubling / ln(2)
// ExcessConversionConstant = (MaxPerSecond - TargetPerSecond) * NumberOfSecondsPerDoubling / ln(2)
//
// ln(2) is a float and the result is consensus critical, so we
// hardcode the result.
Expand Down
2 changes: 1 addition & 1 deletion genesis/genesis_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var (
MaxPerSecond: 250_000,
TargetPerSecond: 125_000, // Target block size ~125KB
MinPrice: 1,
// ExcessConversionConstant = (Capacity - Target) * NumberOfSecondsPerDoubling / ln(2)
// ExcessConversionConstant = (MaxPerSecond - TargetPerSecond) * NumberOfSecondsPerDoubling / ln(2)
//
// ln(2) is a float and the result is consensus critical, so we
// hardcode the result.
Expand Down
2 changes: 1 addition & 1 deletion genesis/genesis_mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var (
MaxPerSecond: 250_000,
TargetPerSecond: 125_000, // Target block size ~125KB
MinPrice: 1,
// ExcessConversionConstant = (Capacity - Target) * NumberOfSecondsPerDoubling / ln(2)
// ExcessConversionConstant = (MaxPerSecond - TargetPerSecond) * NumberOfSecondsPerDoubling / ln(2)
//
// ln(2) is a float and the result is consensus critical, so we
// hardcode the result.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ require (
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.12.0
github.com/stretchr/testify v1.9.0
github.com/supranational/blst v0.3.11
github.com/supranational/blst v0.3.13
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a
github.com/thepudds/fzgen v0.4.2
github.com/tyler-smith/go-bip32 v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.3.0 h1:mjC+YW8QpAdXibNi+vNWgzmgBH4+5l5dCXv8cNysBLI=
github.com/subosito/gotenv v1.3.0/go.mod h1:YzJjq/33h7nrwdY+iHMhEOEEbW0ovIz0tB6t6PwAXzs=
github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4=
github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
github.com/supranational/blst v0.3.13 h1:AYeSxdOMacwu7FBmpfloBz5pbFXDmJL33RuwnKtmTjk=
github.com/supranational/blst v0.3.13/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a h1:1ur3QoCqvE5fl+nylMaIr9PVV1w343YRDtsy+Rwu7XI=
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48=
Expand Down
7 changes: 5 additions & 2 deletions ids/id.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,12 @@ func (id ID) Prefix(prefixes ...uint64) ID {
return hashing.ComputeHash256Array(packer.Bytes)
}

// Append this id to create a more selective id.
// Append this id with the provided suffixes and re-hash the result. This
// returns a new ID and does not modify the original ID.
//
// This is used to generate the ACP-77 validationIDs.
// This is used to generate ACP-77 validationIDs.
//
// Ref: https://github.com/avalanche-foundation/ACPs/tree/e333b335c34c8692d84259d21bd07b2bb849dc2c/ACPs/77-reinventing-subnets#convertsubnettol1tx
func (id ID) Append(suffixes ...uint32) ID {
packer := wrappers.Packer{
Bytes: make([]byte, IDLen+len(suffixes)*wrappers.IntLen),
Expand Down
Loading

0 comments on commit 3867b1b

Please sign in to comment.