Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit a4cee60
Author: Dan Laine <daniel.laine@avalabs.org>
Date:   Fri Oct 27 11:37:05 2023 -0400

    `merkledb` -- don't pass `BranchFactor` to `encodeDBNode` (#2217)

    Signed-off-by: Dan Laine <daniel.laine@avalabs.org>

commit cacbb9b
Author: Dhruba Basu <7675102+dhrubabasu@users.noreply.github.com>
Date:   Thu Oct 26 16:57:56 2023 -0400

    Move all blst function usage to `bls` pkg (#2222)

    Signed-off-by: Dan Laine <daniel.laine@avalabs.org>
    Co-authored-by: Dan Laine <daniel.laine@avalabs.org>

commit 3b213fc
Author: Dhruba Basu <7675102+dhrubabasu@users.noreply.github.com>
Date:   Thu Oct 26 16:53:26 2023 -0400

    Add json marshal tests to existing serialization tests in `platformvm/txs` pkg (#2227)

commit a6448ac
Author: Dhruba Basu <7675102+dhrubabasu@users.noreply.github.com>
Date:   Thu Oct 26 16:48:00 2023 -0400

    Update `golangci-lint` to `v1.55.1` (#2228)

commit fe74ed1
Author: Dan Laine <daniel.laine@avalabs.org>
Date:   Thu Oct 26 12:54:34 2023 -0400

    `merkledb` -- shift nit (#2218)

    Signed-off-by: Dan Laine <daniel.laine@avalabs.org>

commit e933587
Author: David Boehm <91908103+dboehm-avalabs@users.noreply.github.com>
Date:   Thu Oct 26 11:40:57 2023 -0400

    Reduce allocations on insert and remove (#2201)

    Signed-off-by: David Boehm <91908103+dboehm-avalabs@users.noreply.github.com>
    Signed-off-by: Dan Laine <daniel.laine@avalabs.org>
    Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>
    Co-authored-by: Dan Laine <daniel.laine@avalabs.org>

commit 638000c
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Thu Oct 26 02:08:05 2023 -0400

    Update versions for v1.10.14 (#2225)

commit 8463690
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Thu Oct 26 00:12:05 2023 -0400

    Improve logging for block verification failure (#2224)

commit 787f0b6
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Wed Oct 25 17:35:17 2023 -0400

    Fix unexpected unlock (#2221)

commit 1f779af
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Wed Oct 25 17:13:25 2023 -0400

    Revert networking AllowConnection change (#2219)

commit f020a05
Author: Dhruba Basu <7675102+dhrubabasu@users.noreply.github.com>
Date:   Wed Oct 25 16:51:24 2023 -0400

    Add `TransferSubnetOwnershipTx` (#2178)

    Signed-off-by: Dhruba Basu <7675102+dhrubabasu@users.noreply.github.com>

commit 150ffae
Author: Dan Laine <daniel.laine@avalabs.org>
Date:   Wed Oct 25 16:39:10 2023 -0400

    Add pebble database implementation (#1999)

    Co-authored-by: Dhruba Basu <7675102+dhrubabasu@users.noreply.github.com>
    Co-authored-by: Stephen Buttolph <stephen@avalabs.org>

commit de168b1
Author: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>
Date:   Wed Oct 25 15:47:48 2023 -0400

    Add log for ungraceful shutdown on startup (#2215)

    Signed-off-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>

commit cd77a1e
Author: Dhruba Basu <7675102+dhrubabasu@users.noreply.github.com>
Date:   Wed Oct 25 13:27:43 2023 -0400

    Remove `aggregate` struct (#2213)

commit 128757d
Author: Ceyhun Onur <ceyhun.onur@avalabs.org>
Date:   Wed Oct 25 02:03:45 2023 +0300

    Move the overridden manager into the node (#2199)

    Signed-off-by: Ceyhun Onur <ceyhunonur54@gmail.com>
    Co-authored-by: Alberto Benegiamo <alberto.benegiamo@gmail.com>
    Co-authored-by: Stephen Buttolph <stephen@avalabs.org>

commit 7903676
Author: Ceyhun Onur <ceyhun.onur@avalabs.org>
Date:   Tue Oct 24 20:44:01 2023 +0300

    Remove contains from validator manager interface (#2198)

    Signed-off-by: Ceyhun Onur <ceyhunonur54@gmail.com>
    Signed-off-by: Stephen Buttolph <stephen@avalabs.org>
    Co-authored-by: Alberto Benegiamo <alberto.benegiamo@gmail.com>
    Co-authored-by: Stephen Buttolph <stephen@avalabs.org>

commit 963aeb0
Author: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>
Date:   Tue Oct 24 12:54:31 2023 -0400

    Update TestDialContext to use ManuallyTrack (#2209)

    Signed-off-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>

commit e337dda
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Tue Oct 24 12:42:05 2023 -0400

    Remove duplicate networking check (#2204)

    Signed-off-by: Dan Laine <daniel.laine@avalabs.org>
    Co-authored-by: Dan Laine <daniel.laine@avalabs.org>

commit 020e802
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Mon Oct 23 17:37:14 2023 -0400

    Add RSA max key length test (#2205)

commit d3287dd
Author: Alberto Benegiamo <alberto.benegiamo@gmail.com>
Date:   Mon Oct 23 12:09:10 2023 -0700

    Use custom codec for validator metadata (#1510)

commit 3a1dcca
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Mon Oct 23 13:47:37 2023 -0400

    Update local network readme (#2203)

commit 7b7931b
Author: Ceyhun Onur <ceyhun.onur@avalabs.org>
Date:   Mon Oct 23 20:36:47 2023 +0300

    Redesign validator set management to enable tracking all subnets (#1857)

    Signed-off-by: Ceyhun Onur <ceyhunonur54@gmail.com>
    Co-authored-by: Alberto Benegiamo <alberto.benegiamo@gmail.com>
    Co-authored-by: Stephen Buttolph <stephen@avalabs.org>

commit 4cd7051
Author: Alberto Benegiamo <alberto.benegiamo@gmail.com>
Date:   Mon Oct 23 08:48:56 2023 -0700

    Shutdown TimeoutManager during node Shutdown (#1707)

    Signed-off-by: Alberto Benegiamo <alberto.benegiamo@gmail.com>
    Co-authored-by: Dan Laine <daniel.laine@avalabs.org>
    Co-authored-by: Stephen Buttolph <stephen@avalabs.org>
    Co-authored-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>

commit 6624270
Author: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>
Date:   Mon Oct 23 11:37:03 2023 -0400

    Add Heap Set (#2136)

    Signed-off-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>
    Signed-off-by: Stephen Buttolph <stephen@avalabs.org>
    Co-authored-by: Stephen Buttolph <stephen@avalabs.org>
    Co-authored-by: Dhruba Basu <7675102+dhrubabasu@users.noreply.github.com>
    Co-authored-by: dboehm-avalabs <david.boehm@avalabs.org>
    Co-authored-by: David Boehm <91908103+dboehm-avalabs@users.noreply.github.com>
    Co-authored-by: Alberto Benegiamo <alberto.benegiamo@gmail.com>

commit 804f45b
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Fri Oct 20 14:16:44 2023 -0400

    Move selectStartGear lock from Handler into Engines (#2182)

commit 7ed450b
Author: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>
Date:   Fri Oct 20 09:55:40 2023 -0400

    Implement Heap Map (#2137)

    Signed-off-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>
    Co-authored-by: Alberto Benegiamo <alberto.benegiamo@gmail.com>
    Co-authored-by: Stephen Buttolph <stephen@avalabs.org>

commit a21d0cf
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Thu Oct 19 18:13:46 2023 -0400

    Move HealthCheck lock from Handler into Engines (#2173)

commit 26b1505
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Thu Oct 19 17:48:22 2023 -0400

    Move Shutdown lock from Handler into Engines (#2179)

commit 8c6b9d3
Author: Dhruba Basu <7675102+dhrubabasu@users.noreply.github.com>
Date:   Thu Oct 19 15:36:31 2023 -0400

    Add tests for BanffBlock serialization (#2194)

commit d9460de
Author: Dan Laine <daniel.laine@avalabs.org>
Date:   Thu Oct 19 15:26:16 2023 -0400

    Deprecate keystore config (#2195)

commit a9c260b
Author: David Boehm <91908103+dboehm-avalabs@users.noreply.github.com>
Date:   Thu Oct 19 14:44:51 2023 -0400

    Merkle db Make Paths only refer to lists of nodes (#2143)

    Signed-off-by: David Boehm <91908103+dboehm-avalabs@users.noreply.github.com>
    Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>

commit 0faab95
Author: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>
Date:   Thu Oct 19 14:43:29 2023 -0400

    Update P2P proto docs (#2181)

    Signed-off-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>
    Co-authored-by: Stephen Buttolph <stephen@avalabs.org>

commit 927c23d
Author: Dan Laine <daniel.laine@avalabs.org>
Date:   Thu Oct 19 13:07:46 2023 -0400

    Deprecate IPC configs (#2168)

    Co-authored-by: Stephen Buttolph <stephen@avalabs.org>

commit 3b843a3
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Thu Oct 19 12:14:58 2023 -0400

    Update cgo usage (#2184)

Signed-off-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>
  • Loading branch information
joshua-kim committed Oct 27, 2023
1 parent ca57dbd commit a4e9c00
Show file tree
Hide file tree
Showing 208 changed files with 7,045 additions and 3,818 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ linters:
- revive
- staticcheck
- stylecheck
- typecheck
- tagalign
- typecheck
- unconvert
- unparam
- unused
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ To connect to the Fuji Testnet, run:

### Creating a Local Testnet

See [this tutorial.](https://docs.avax.network/build/tutorials/platform/create-a-local-test-network/)
The [avalanche-cli](https://github.com/ava-labs/avalanche-cli) is the easiest way to start a local network.

```sh
avalanche network start
avalanche network status
```

## Bootstrapping

Expand Down
51 changes: 51 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,56 @@
# Release Notes

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

This version is backwards compatible to [v1.10.0](https://github.com/ava-labs/avalanchego/releases/tag/v1.10.0). It is optional, but encouraged.

The plugin version is unchanged at `29` and compatible with version `v1.10.13`.

### Configs

- Deprecated `--api-ipcs-enabled`
- Deprecated `--ipcs-chain-ids`
- Deprecated `--ipcs-path`
- Deprecated `--api-keystore-enabled`

### Fixes

- Fixed shutdown of timeout manager
- Fixed racy access of the shutdown time

### What's Changed

- Remove build check from unit tests by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2189
- Update cgo usage by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2184
- Deprecate IPC configs by @danlaine in https://github.com/ava-labs/avalanchego/pull/2168
- Update P2P proto docs by @joshua-kim in https://github.com/ava-labs/avalanchego/pull/2181
- Merkle db Make Paths only refer to lists of nodes by @dboehm-avalabs in https://github.com/ava-labs/avalanchego/pull/2143
- Deprecate keystore config by @danlaine in https://github.com/ava-labs/avalanchego/pull/2195
- Add tests for BanffBlock serialization by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2194
- Move Shutdown lock from Handler into Engines by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2179
- Move HealthCheck lock from Handler into Engines by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2173
- Implement Heap Map by @joshua-kim in https://github.com/ava-labs/avalanchego/pull/2137
- Move selectStartGear lock from Handler into Engines by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2182
- Add Heap Set by @joshua-kim in https://github.com/ava-labs/avalanchego/pull/2136
- Shutdown TimeoutManager during node Shutdown by @abi87 in https://github.com/ava-labs/avalanchego/pull/1707
- Redesign validator set management to enable tracking all subnets by @ceyonur in https://github.com/ava-labs/avalanchego/pull/1857
- Update local network readme by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2203
- Use custom codec for validator metadata by @abi87 in https://github.com/ava-labs/avalanchego/pull/1510
- Add RSA max key length test by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2205
- Remove duplicate networking check by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2204
- Update TestDialContext to use ManuallyTrack by @joshua-kim in https://github.com/ava-labs/avalanchego/pull/2209
- Remove contains from validator manager interface by @ceyonur in https://github.com/ava-labs/avalanchego/pull/2198
- Move the overridden manager into the node by @ceyonur in https://github.com/ava-labs/avalanchego/pull/2199
- Remove `aggregate` struct by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2213
- Add log for ungraceful shutdown on startup by @joshua-kim in https://github.com/ava-labs/avalanchego/pull/2215
- Add pebble database implementation by @danlaine in https://github.com/ava-labs/avalanchego/pull/1999
- Add `TransferSubnetOwnershipTx` by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2178
- Revert networking AllowConnection change by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2219
- Fix unexpected unlock by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2221
- Improve logging for block verification failure by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2224

**Full Changelog**: https://github.com/ava-labs/avalanchego/compare/v1.10.13...v1.10.14

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

This version is backwards compatible to [v1.10.0](https://github.com/ava-labs/avalanchego/releases/tag/v1.10.0). It is optional, but encouraged.
Expand Down
29 changes: 15 additions & 14 deletions api/auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var (
hashedPassword = password.Hash{}
unAuthorizedResponseRegex = `^{"jsonrpc":"2.0","error":{"code":-32600,"message":"(.*)"},"id":1}`
errTest = errors.New("non-nil error")
hostName = "http://127.0.0.1:9650"
)

func init() {
Expand Down Expand Up @@ -161,8 +162,8 @@ func TestWrapHandlerHappyPath(t *testing.T) {
wrappedHandler := auth.WrapHandler(dummyHandler)

for _, endpoint := range endpoints {
req := httptest.NewRequest(http.MethodPost, "http://127.0.0.1:9650"+endpoint, strings.NewReader(""))
req.Header.Add("Authorization", "Bearer "+tokenStr)
req := httptest.NewRequest(http.MethodPost, hostName+endpoint, strings.NewReader(""))
req.Header.Add("Authorization", headerValStart+tokenStr)
rr := httptest.NewRecorder()
wrappedHandler.ServeHTTP(rr, req)
require.Equal(http.StatusOK, rr.Code)
Expand All @@ -184,8 +185,8 @@ func TestWrapHandlerRevokedToken(t *testing.T) {
wrappedHandler := auth.WrapHandler(dummyHandler)

for _, endpoint := range endpoints {
req := httptest.NewRequest(http.MethodPost, "http://127.0.0.1:9650"+endpoint, strings.NewReader(""))
req.Header.Add("Authorization", "Bearer "+tokenStr)
req := httptest.NewRequest(http.MethodPost, hostName+endpoint, strings.NewReader(""))
req.Header.Add("Authorization", headerValStart+tokenStr)
rr := httptest.NewRecorder()
wrappedHandler.ServeHTTP(rr, req)
require.Equal(http.StatusUnauthorized, rr.Code)
Expand All @@ -209,8 +210,8 @@ func TestWrapHandlerExpiredToken(t *testing.T) {
wrappedHandler := auth.WrapHandler(dummyHandler)

for _, endpoint := range endpoints {
req := httptest.NewRequest(http.MethodPost, "http://127.0.0.1:9650"+endpoint, strings.NewReader(""))
req.Header.Add("Authorization", "Bearer "+tokenStr)
req := httptest.NewRequest(http.MethodPost, hostName+endpoint, strings.NewReader(""))
req.Header.Add("Authorization", headerValStart+tokenStr)
rr := httptest.NewRecorder()
wrappedHandler.ServeHTTP(rr, req)
require.Equal(http.StatusUnauthorized, rr.Code)
Expand Down Expand Up @@ -250,8 +251,8 @@ func TestWrapHandlerUnauthorizedEndpoint(t *testing.T) {

wrappedHandler := auth.WrapHandler(dummyHandler)
for _, endpoint := range unauthorizedEndpoints {
req := httptest.NewRequest(http.MethodPost, "http://127.0.0.1:9650"+endpoint, strings.NewReader(""))
req.Header.Add("Authorization", "Bearer "+tokenStr)
req := httptest.NewRequest(http.MethodPost, hostName+endpoint, strings.NewReader(""))
req.Header.Add("Authorization", headerValStart+tokenStr)
rr := httptest.NewRecorder()
wrappedHandler.ServeHTTP(rr, req)
require.Equal(http.StatusUnauthorized, rr.Code)
Expand All @@ -272,7 +273,7 @@ func TestWrapHandlerAuthEndpoint(t *testing.T) {

wrappedHandler := auth.WrapHandler(dummyHandler)
req := httptest.NewRequest(http.MethodPost, "http://127.0.0.1:9650/ext/auth", strings.NewReader(""))
req.Header.Add("Authorization", "Bearer "+tokenStr)
req.Header.Add("Authorization", headerValStart+tokenStr)
rr := httptest.NewRecorder()
wrappedHandler.ServeHTTP(rr, req)
require.Equal(http.StatusOK, rr.Code)
Expand All @@ -290,8 +291,8 @@ func TestWrapHandlerAccessAll(t *testing.T) {

wrappedHandler := auth.WrapHandler(dummyHandler)
for _, endpoint := range endpoints {
req := httptest.NewRequest(http.MethodPost, "http://127.0.0.1:9650"+endpoint, strings.NewReader(""))
req.Header.Add("Authorization", "Bearer "+tokenStr)
req := httptest.NewRequest(http.MethodPost, hostName+endpoint, strings.NewReader(""))
req.Header.Add("Authorization", headerValStart+tokenStr)
rr := httptest.NewRecorder()
wrappedHandler.ServeHTTP(rr, req)
require.Equal(http.StatusOK, rr.Code)
Expand Down Expand Up @@ -322,7 +323,7 @@ func TestWrapHandlerMutatedRevokedToken(t *testing.T) {
wrappedHandler := auth.WrapHandler(dummyHandler)

for _, endpoint := range endpoints {
req := httptest.NewRequest(http.MethodPost, "http://127.0.0.1:9650"+endpoint, strings.NewReader(""))
req := httptest.NewRequest(http.MethodPost, hostName+endpoint, strings.NewReader(""))
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s=", tokenStr)) // The appended = at the end looks like padding
rr := httptest.NewRecorder()
wrappedHandler.ServeHTTP(rr, req)
Expand Down Expand Up @@ -356,8 +357,8 @@ func TestWrapHandlerInvalidSigningMethod(t *testing.T) {
wrappedHandler := auth.WrapHandler(dummyHandler)

for _, endpoint := range endpoints {
req := httptest.NewRequest(http.MethodPost, "http://127.0.0.1:9650"+endpoint, strings.NewReader(""))
req.Header.Add("Authorization", "Bearer "+tokenStr)
req := httptest.NewRequest(http.MethodPost, hostName+endpoint, strings.NewReader(""))
req.Header.Add("Authorization", headerValStart+tokenStr)
rr := httptest.NewRecorder()
wrappedHandler.ServeHTTP(rr, req)
require.Equal(http.StatusUnauthorized, rr.Code)
Expand Down
4 changes: 0 additions & 4 deletions api/info/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/ava-labs/avalanchego/network"
"github.com/ava-labs/avalanchego/network/peer"
"github.com/ava-labs/avalanchego/snow/networking/benchlist"
"github.com/ava-labs/avalanchego/snow/validators"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/ips"
"github.com/ava-labs/avalanchego/utils/json"
Expand All @@ -37,7 +36,6 @@ type Info struct {
networking network.Network
chainManager chains.Manager
vmManager vms.Manager
validators validators.Set
benchlist benchlist.Manager
}

Expand Down Expand Up @@ -65,7 +63,6 @@ func NewService(
vmManager vms.Manager,
myIP ips.DynamicIPPort,
network network.Network,
validators validators.Set,
benchlist benchlist.Manager,
) (http.Handler, error) {
server := rpc.NewServer()
Expand All @@ -80,7 +77,6 @@ func NewService(
vmManager: vmManager,
myIP: myIP,
networking: network,
validators: validators,
benchlist: benchlist,
},
"info",
Expand Down
2 changes: 1 addition & 1 deletion api/keystore/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

const (
maxPackerSize = 1 * units.GiB // max size, in bytes, of something being marshalled by Marshal()
maxSliceLength = 256 * 1024
maxSliceLength = linearcodec.DefaultMaxSliceLength

codecVersion = 0
)
Expand Down
47 changes: 21 additions & 26 deletions chains/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@ type ChainParameters struct {
// The IDs of the feature extensions this chain is running.
FxIDs []ids.ID
// Invariant: Only used when [ID] is the P-chain ID.
CustomBeacons validators.Set
CustomBeacons validators.Manager
}

type chain struct {
Name string
Context *snow.ConsensusContext
VM common.VM
Handler handler.Handler
Beacons validators.Set
Beacons validators.Manager
}

// ChainConfig is configuration settings for the current execution.
Expand Down Expand Up @@ -531,24 +531,13 @@ func (m *manager) buildChain(chainParams ChainParameters, sb subnets.Subnet) (*c
}
}

var vdrs validators.Set // Validators validating this blockchain
var hasValidators bool
if m.SybilProtectionEnabled {
vdrs, hasValidators = m.Validators.Get(chainParams.SubnetID)
} else { // Sybil protection is disabled. Every peer validates every subnet.
vdrs, hasValidators = m.Validators.Get(constants.PrimaryNetworkID)
}
if !hasValidators {
return nil, fmt.Errorf("couldn't get validator set of subnet with ID %s. The subnet may not exist", chainParams.SubnetID)
}

var chain *chain
switch vm := vm.(type) {
case vertex.LinearizableVMWithEngine:
chain, err = m.createAvalancheChain(
ctx,
chainParams.GenesisData,
vdrs,
m.Validators,
vm,
fxs,
sb,
Expand All @@ -557,15 +546,15 @@ func (m *manager) buildChain(chainParams ChainParameters, sb subnets.Subnet) (*c
return nil, fmt.Errorf("error while creating new avalanche vm %w", err)
}
case block.ChainVM:
beacons := vdrs
beacons := m.Validators
if chainParams.ID == constants.PlatformChainID {
beacons = chainParams.CustomBeacons
}

chain, err = m.createSnowmanChain(
ctx,
chainParams.GenesisData,
vdrs,
m.Validators,
beacons,
vm,
fxs,
Expand Down Expand Up @@ -594,7 +583,7 @@ func (m *manager) AddRegistrant(r Registrant) {
func (m *manager) createAvalancheChain(
ctx *snow.ConsensusContext,
genesisData []byte,
vdrs validators.Set,
vdrs validators.Manager,
vm vertex.LinearizableVMWithEngine,
fxs []*common.Fx,
sb subnets.Subnet,
Expand Down Expand Up @@ -816,7 +805,10 @@ func (m *manager) createAvalancheChain(
appSender: snowmanMessageSender,
}

bootstrapWeight := vdrs.Weight()
bootstrapWeight, err := vdrs.TotalWeight(ctx.SubnetID)
if err != nil {
return nil, fmt.Errorf("error while fetching weight for subnet %s: %w", ctx.SubnetID, err)
}

consensusParams := sb.Config().ConsensusParameters
sampleK := consensusParams.K
Expand All @@ -828,7 +820,7 @@ func (m *manager) createAvalancheChain(
if err != nil {
return nil, fmt.Errorf("error creating peer tracker: %w", err)
}
vdrs.RegisterCallbackListener(connectedValidators)
vdrs.RegisterCallbackListener(ctx.SubnetID, connectedValidators)

// Asynchronously passes messages from the network to the consensus engine
h, err := handler.New(
Expand All @@ -848,7 +840,7 @@ func (m *manager) createAvalancheChain(

connectedBeacons := tracker.NewPeers()
startupTracker := tracker.NewStartup(connectedBeacons, (3*bootstrapWeight+3)/4)
vdrs.RegisterCallbackListener(startupTracker)
vdrs.RegisterCallbackListener(ctx.SubnetID, startupTracker)

snowmanCommonCfg := common.Config{
Ctx: ctx,
Expand Down Expand Up @@ -998,8 +990,8 @@ func (m *manager) createAvalancheChain(
func (m *manager) createSnowmanChain(
ctx *snow.ConsensusContext,
genesisData []byte,
vdrs validators.Set,
beacons validators.Set,
vdrs validators.Manager,
beacons validators.Manager,
vm block.ChainVM,
fxs []*common.Fx,
sb subnets.Subnet,
Expand Down Expand Up @@ -1164,7 +1156,10 @@ func (m *manager) createSnowmanChain(
return nil, err
}

bootstrapWeight := beacons.Weight()
bootstrapWeight, err := beacons.TotalWeight(ctx.SubnetID)
if err != nil {
return nil, fmt.Errorf("error while fetching weight for subnet %s: %w", ctx.SubnetID, err)
}

consensusParams := sb.Config().ConsensusParameters
sampleK := consensusParams.K
Expand All @@ -1176,7 +1171,7 @@ func (m *manager) createSnowmanChain(
if err != nil {
return nil, fmt.Errorf("error creating peer tracker: %w", err)
}
vdrs.RegisterCallbackListener(connectedValidators)
vdrs.RegisterCallbackListener(ctx.SubnetID, connectedValidators)

// Asynchronously passes messages from the network to the consensus engine
h, err := handler.New(
Expand All @@ -1196,7 +1191,7 @@ func (m *manager) createSnowmanChain(

connectedBeacons := tracker.NewPeers()
startupTracker := tracker.NewStartup(connectedBeacons, (3*bootstrapWeight+3)/4)
beacons.RegisterCallbackListener(startupTracker)
beacons.RegisterCallbackListener(ctx.SubnetID, startupTracker)

commonCfg := common.Config{
Ctx: ctx,
Expand Down Expand Up @@ -1358,7 +1353,7 @@ func (m *manager) registerBootstrappedHealthChecks() error {
if !m.IsBootstrapped(constants.PlatformChainID) {
return "node is currently bootstrapping", nil
}
if !validators.Contains(m.Validators, constants.PrimaryNetworkID, m.NodeID) {
if _, ok := m.Validators.GetValidator(constants.PrimaryNetworkID, m.NodeID); !ok {
return "node is not a primary network validator", nil
}

Expand Down
4 changes: 2 additions & 2 deletions codec/linearcodec/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

const (
// default max length of a slice being marshalled by Marshal(). Should be <= math.MaxUint32.
defaultMaxSliceLength = 256 * 1024
DefaultMaxSliceLength = 256 * 1024
)

var (
Expand Down Expand Up @@ -56,7 +56,7 @@ func New(tagNames []string, maxSliceLen uint32) Codec {

// NewDefault is a convenience constructor; it returns a new codec with reasonable default values
func NewDefault() Codec {
return New([]string{reflectcodec.DefaultTagName}, defaultMaxSliceLength)
return New([]string{reflectcodec.DefaultTagName}, DefaultMaxSliceLength)
}

// NewCustomMaxLength is a convenience constructor; it returns a new codec with custom max length and default tags
Expand Down
2 changes: 1 addition & 1 deletion codec/linearcodec/codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestVectors(t *testing.T) {

func TestMultipleTags(t *testing.T) {
for _, test := range codec.MultipleTagsTests {
c := New([]string{"tag1", "tag2"}, defaultMaxSliceLength)
c := New([]string{"tag1", "tag2"}, DefaultMaxSliceLength)
test(c, t)
}
}
Expand Down

0 comments on commit a4e9c00

Please sign in to comment.