Skip to content

Commit

Permalink
Merge branch 'master' into signers-config
Browse files Browse the repository at this point in the history
  • Loading branch information
richardpringle authored Feb 17, 2025
2 parents ee687b3 + d76684b commit 843aabc
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

To start developing on AvalancheGo, you'll need a few things installed.

- Golang version >= 1.22.8
- Golang version >= 1.23.6
- gcc
- g++

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The minimum recommended hardware specification for nodes connected to Mainnet is

If you plan to build AvalancheGo from source, you will also need the following software:

- [Go](https://golang.org/doc/install) version >= 1.22.8
- [Go](https://golang.org/doc/install) version >= 1.23.6
- [gcc](https://gcc.gnu.org/)
- g++

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ module github.com/ava-labs/avalanchego
// - README.md
// - go.mod (here)
//
// - If updating between minor versions (e.g. 1.22.x -> 1.23.x):
// - If updating between minor versions (e.g. 1.23.x -> 1.24.x):
// - Consider updating the version of golangci-lint (in scripts/lint.sh).
go 1.22.8
go 1.23.6

require (
github.com/DataDog/zstd v1.5.2
Expand Down
4 changes: 2 additions & 2 deletions utils/hashing/consistent/ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ func (h *hashRing) get(key Hashable) (Hashable, error) {
// If found nothing ascending the tree, we need to wrap around the ring to
// the left-most (min) node.
if result == nil {
min, _ := h.ring.Min()
result = min.value
minNode, _ := h.ring.Min()
result = minNode.value
}
return result, nil
}
Expand Down
4 changes: 2 additions & 2 deletions utils/sampler/rand.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ func (r *rng) Uint64Inclusive(n uint64) uint64 {
//
// ref: https://github.com/golang/go/blob/ce10e9d84574112b224eae88dc4e0f43710808de/src/math/rand/rand.go#L127-L132
default:
max := (1 << 63) - 1 - (1<<63)%(n+1)
maximum := (1 << 63) - 1 - (1<<63)%(n+1)
v := r.uint63()
for v > max {
for v > maximum {
v = r.uint63()
}
return v % (n + 1)
Expand Down
42 changes: 21 additions & 21 deletions utils/sampler/rand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,91 +56,91 @@ func (s *testSTDSource) Uint64() uint64 {

func TestRNG(t *testing.T) {
tests := []struct {
max uint64
maximum uint64
nums []uint64
expected uint64
}{
{
max: math.MaxUint64,
maximum: math.MaxUint64,
nums: []uint64{
0x01,
},
expected: 0x01,
},
{
max: math.MaxUint64,
maximum: math.MaxUint64,
nums: []uint64{
0x0102030405060708,
},
expected: 0x0102030405060708,
},
{
max: math.MaxUint64,
maximum: math.MaxUint64,
nums: []uint64{
0xF102030405060708,
},
expected: 0xF102030405060708,
},
{
max: math.MaxInt64,
maximum: math.MaxInt64,
nums: []uint64{
0x01,
},
expected: 0x01,
},
{
max: math.MaxInt64,
maximum: math.MaxInt64,
nums: []uint64{
0x0102030405060708,
},
expected: 0x0102030405060708,
},
{
max: math.MaxInt64,
maximum: math.MaxInt64,
nums: []uint64{
0x8102030405060708,
},
expected: 0x0102030405060708,
},
{
max: 15,
maximum: 15,
nums: []uint64{
0x810203040506071a,
},
expected: 0x0a,
},
{
max: math.MaxInt64 + 1,
maximum: math.MaxInt64 + 1,
nums: []uint64{
math.MaxInt64 + 1,
},
expected: math.MaxInt64 + 1,
},
{
max: math.MaxInt64 + 1,
maximum: math.MaxInt64 + 1,
nums: []uint64{
math.MaxInt64 + 2,
0,
},
expected: 0,
},
{
max: math.MaxInt64 + 1,
maximum: math.MaxInt64 + 1,
nums: []uint64{
math.MaxInt64 + 2,
0x0102030405060708,
},
expected: 0x0102030405060708,
},
{
max: 2,
maximum: 2,
nums: []uint64{
math.MaxInt64 - 2,
},
expected: 0x02,
},
{
max: 2,
maximum: 2,
nums: []uint64{
math.MaxInt64 - 1,
0x01,
Expand All @@ -157,11 +157,11 @@ func TestRNG(t *testing.T) {
nums: test.nums,
}
r := &rng{rng: source}
val := r.Uint64Inclusive(test.max)
val := r.Uint64Inclusive(test.maximum)
require.Equal(test.expected, val)
require.Empty(source.nums)

if test.max >= math.MaxInt64 {
if test.maximum >= math.MaxInt64 {
return
}

Expand All @@ -170,7 +170,7 @@ func TestRNG(t *testing.T) {
nums: test.nums,
}
mathRNG := rand.New(stdSource) //#nosec G404
stdVal := mathRNG.Int63n(int64(test.max + 1))
stdVal := mathRNG.Int63n(int64(test.maximum + 1))
require.Equal(test.expected, uint64(stdVal))
require.Empty(source.nums)
})
Expand All @@ -182,12 +182,12 @@ func FuzzRNG(f *testing.F) {
require := require.New(t)

var (
max uint64
maximum uint64
sourceNums []uint64
)
fz := fuzzer.NewFuzzer(data)
fz.Fill(&max, &sourceNums)
if max >= math.MaxInt64 {
fz.Fill(&maximum, &sourceNums)
if maximum >= math.MaxInt64 {
t.SkipNow()
}

Expand All @@ -196,14 +196,14 @@ func FuzzRNG(f *testing.F) {
nums: sourceNums,
}
r := &rng{rng: source}
val := r.Uint64Inclusive(max)
val := r.Uint64Inclusive(maximum)

stdSource := &testSTDSource{
onInvalid: t.SkipNow,
nums: sourceNums,
}
mathRNG := rand.New(stdSource) //#nosec G404
stdVal := mathRNG.Int63n(int64(max + 1))
stdVal := mathRNG.Int63n(int64(maximum + 1))
require.Equal(val, uint64(stdVal))
require.Len(stdSource.nums, len(source.nums))
})
Expand Down
4 changes: 2 additions & 2 deletions utils/ulimit/ulimit_bsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ const DefaultFDLimit = 32 * 1024
// privileges. Bumping the Max limit further would require superuser privileges.
// If the value is below the recommendation warn on start.
// see: http://0pointer.net/blog/file-descriptor-limits.html
func Set(max uint64, log logging.Logger) error {
func Set(limit uint64, log logging.Logger) error {
// Note: BSD Rlimit is type int64
// ref: https://cs.opensource.google/go/x/sys/+/b874c991:unix/ztypes_freebsd_amd64.go
bsdMax := int64(max)
bsdMax := int64(limit)
var rLimit syscall.Rlimit
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions utils/ulimit/ulimit_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const DefaultFDLimit = 10 * 1024
// privileges. Bumping the Max limit further would require superuser privileges.
// If the value is below the recommendation warn on start.
// see: http://0pointer.net/blog/file-descriptor-limits.html
func Set(max uint64, log logging.Logger) error {
func Set(limit uint64, log logging.Logger) error {
var rLimit syscall.Rlimit
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
Expand All @@ -34,11 +34,11 @@ func Set(max uint64, log logging.Logger) error {
// The max file limit is 10240, even though the max returned by
// Getrlimit is 1<<63-1. This is OPEN_MAX in sys/syslimits.h.
// See https://github.com/golang/go/issues/30401
if max > DefaultFDLimit {
return fmt.Errorf("error fd-limit: (%d) greater than max: (%d)", max, DefaultFDLimit)
if limit > DefaultFDLimit {
return fmt.Errorf("error fd-limit: (%d) greater than max: (%d)", limit, DefaultFDLimit)
}

rLimit.Cur = max
rLimit.Cur = limit

// set new limit
if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit); err != nil {
Expand Down
8 changes: 4 additions & 4 deletions utils/ulimit/ulimit_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ const DefaultFDLimit = 32 * 1024
// privileges. Bumping the Max limit further would require superuser privileges.
// If the current Max is below our recommendation we will warn on start.
// see: http://0pointer.net/blog/file-descriptor-limits.html
func Set(max uint64, log logging.Logger) error {
func Set(limit uint64, log logging.Logger) error {
var rLimit syscall.Rlimit
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
return fmt.Errorf("error getting rlimit: %w", err)
}

if max > rLimit.Max {
return fmt.Errorf("error fd-limit: (%d) greater than max: (%d)", max, rLimit.Max)
if limit > rLimit.Max {
return fmt.Errorf("error fd-limit: (%d) greater than max: (%d)", limit, rLimit.Max)
}

rLimit.Cur = max
rLimit.Cur = limit

// set new limit
if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions utils/ulimit/ulimit_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import "github.com/ava-labs/avalanchego/utils/logging"
const DefaultFDLimit = 16384

// Set is a no-op for windows and will warn if the default is not used.
func Set(max uint64, log logging.Logger) error {
if max != DefaultFDLimit {
func Set(limit uint64, log logging.Logger) error {
if limit != DefaultFDLimit {
log.Warn("fd-limit is not supported for windows")
}
return nil
Expand Down
4 changes: 2 additions & 2 deletions x/merkledb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Structure

A _Merkle radix trie_ is a data structure that is both a [Merkle tree](https://en.wikipedia.org/wiki/Merkle_tree) and a [radix trie](https://en.wikipedia.org/wiki/Radix_tree). MerkleDB is an implementation of a persisted key-value store (sometimes just called "a store") using a Merkle radix trie. We sometimes use "Merkle radix trie" and "MerkleDB instance" interchangeably below, but the two are not the same. MerkleDB maintains data in a Merkle radix trie, but not all Merkle radix tries implement a key-value store.
A _Merkle radix trie_ is a data structure that is both a [Merkle tree](https://en.wikipedia.org/wiki/Merkle_tree) and a [radix trie](https://en.wikipedia.org/wiki/Radix_tree). MerkleDB is an implementation of a persisted key-value store (sometimes just called "a store") using a Merkle radix trie. We sometimes use "Merkle radix trie" and "MerkleDB instance" interchangeably below, but the two are not the same. MerkleDB maintains data in a Merkle radix trie, but not all Merkle radix tries to implement a key-value store.

Like all tries, a MerkleDB instance is composed of nodes. Conceptually, a node has:
* A unique _key_ which identifies its position in the trie. A node's key is a prefix of its childrens' keys.
Expand Down Expand Up @@ -61,7 +61,7 @@ When a view is created, we don't apply changes to the trie's structure or calcul

When a view is committed, its siblings and all of their descendants are _invalidated_. An invalid view can't be read or committed. Method calls on it will return `ErrInvalid`.

In the diagram above, if `view1` were committed, `view2` would be invalidated. It `view2` were committed, `view1` and `view3` would be invalidated.
In the diagram above, if `view1` were committed, `view2` would be invalidated. If `view2` were committed, `view1` and `view3` would be invalidated.

## Proofs

Expand Down
2 changes: 1 addition & 1 deletion x/merkledb/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func (proof *RangeProof) Verify(
largestProvenKey = maybe.Some(ToKey(proof.KeyValues[len(proof.KeyValues)-1].Key))
}

// The key-value pairs (allegedly) proven by [proof].
// The key-value pairs (allegedly) are proven by [proof].
keyValues := make(map[Key][]byte, len(proof.KeyValues))
for _, keyValue := range proof.KeyValues {
keyValues[ToKey(keyValue.Key)] = keyValue.Value
Expand Down

0 comments on commit 843aabc

Please sign in to comment.