Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit c5169a3
Author: David Boehm <91908103+dboehm-avalabs@users.noreply.github.com>
Date:   Wed Nov 29 15:34:57 2023 -0500

    MerkleDB Remove ID from Node to reduce size and removal channel creation. (#2324)

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

commit 56c2ad9
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Wed Nov 29 14:35:33 2023 -0500

    Replace periodic push accepted gossip with pull preference gossip for block discovery (#2367)

commit 1dddf30
Author: Dhruba Basu <7675102+dhrubabasu@users.noreply.github.com>
Date:   Wed Nov 29 07:16:27 2023 -0800

    Rename `D` to `Durango` (#2389)

commit 6ed238c
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Wed Nov 29 01:05:16 2023 -0500

    Add block source metrics to monitor gossip (#2386)

commit 21c14b1
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Tue Nov 28 23:59:51 2023 -0500

    Add metric to track the stake weight of block providers (#2376)

commit 02ae8d9
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Tue Nov 28 15:10:25 2023 -0500

    Unexport RequestID from snowman engine (#2384)

commit be422a0
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Tue Nov 28 13:58:45 2023 -0500

    Implement generic bimap (#2383)

commit d7e7ff5
Author: Dhruba Basu <7675102+dhrubabasu@users.noreply.github.com>
Date:   Tue Nov 28 10:10:49 2023 -0800

    `vms/avm`: Rename `states` pkg to `state` (#2381)

commit 6e52922
Author: Dhruba Basu <7675102+dhrubabasu@users.noreply.github.com>
Date:   Tue Nov 28 07:55:27 2023 -0800

    `vms/platformvm`: Move `toEngine` channel to mempool (#2333)

commit 590ad12
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Mon Nov 27 16:57:15 2023 -0500

    Remove common bootstrapper (#2297)

commit 9ad213c
Author: Dhruba Basu <7675102+dhrubabasu@users.noreply.github.com>
Date:   Mon Nov 27 11:45:03 2023 -0800

    `vms/platformvm`: Consolidate `state` pkg mocks (#2370)

commit 3a424d0
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Mon Nov 27 13:36:03 2023 -0500

    Remove `engine.GetVM` (#2374)

commit b9ab41a
Author: felipemadero <felipe.madero@avalabs.org>
Date:   Mon Nov 27 14:44:54 2023 -0300

    Add option to provide BLS keys to validators in the genesis (#2371)

commit 42161aa
Author: Dhruba Basu <7675102+dhrubabasu@users.noreply.github.com>
Date:   Mon Nov 27 09:07:48 2023 -0800

    `vms/platformvm`: Adjust `Diff.Apply` signature (#2368)

commit 79e572d
Author: felipemadero <felipe.madero@avalabs.org>
Date:   Mon Nov 27 13:43:32 2023 -0300

    Avoid closing stdout and stderr during log close (#2372)

commit e04dad8
Author: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>
Date:   Sun Nov 26 13:13:56 2023 -0500

    Move peerTracker from x/sync to network/p2p (#2356)

commit b1b051a
Author: Dhruba Basu <7675102+dhrubabasu@users.noreply.github.com>
Date:   Sat Nov 25 16:32:05 2023 -0800

    `vms/platformvm`: Remove unused `withMetrics` txheap (#2373)

commit 8d9b93c
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Fri Nov 24 12:45:51 2023 -0500

    Add metric for duration between block timestamp and block acceptance time (#2366)

commit 9353569
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Fri Nov 24 11:23:36 2023 -0500

    Document storage growth in readme (#2364)

commit 6ad31d6
Author: Dhruba Basu <7675102+dhrubabasu@users.noreply.github.com>
Date:   Wed Nov 22 17:40:43 2023 -0800

    Remove Banff check from mempool verifier (#2360)

commit 62df19c
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Wed Nov 22 19:47:37 2023 -0500

    Update versions for v1.10.16 (#2353)

commit 48c541c
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Wed Nov 22 17:46:14 2023 -0500

    Fix P-chain mempool tx count metric (#2361)

commit 4ce0d67
Author: Gyuho Lee <6799218+gyuho@users.noreply.github.com>
Date:   Thu Nov 23 01:39:53 2023 +0800

    Use linkedhashmap for P-Chain mempool (#1536)

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

commit f2f6d0a
Author: Patrick O'Grady <prohb125@gmail.com>
Date:   Tue Nov 21 22:07:24 2023 -0600

    [vms/proposervm] Update Build Heuristic (#2348)

    Co-authored-by: Alberto Benegiamo <alberto.benegiamo@gmail.com>

commit 459f8ba
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Tue Nov 21 19:24:02 2023 -0500

    Reduce the size of the OracleBlock interface (#2355)

commit f7cc69b
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Tue Nov 21 17:13:17 2023 -0500

    Expand consensus health check (#2354)

commit 2b737d5
Author: Stephen Buttolph <stephen@avalabs.org>
Date:   Tue Nov 21 13:26:55 2023 -0500

    Cleanup snowman consensus metrics (#2349)

Signed-off-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>
  • Loading branch information
joshua-kim committed Nov 29, 2023
1 parent 4ecbb8c commit 738bd2e
Show file tree
Hide file tree
Showing 134 changed files with 4,029 additions and 3,683 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The minimum recommended hardware specification for nodes connected to Mainnet is
- CPU: Equivalent of 8 AWS vCPU
- RAM: 16 GiB
- Storage: 1 TiB
- Nodes running for very long periods of time or nodes with custom configurations may observe higher storage requirements.
- OS: Ubuntu 20.04/22.04 or macOS >= 12
- Network: Reliable IPv4 or IPv6 network connection, with an open public port.

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

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

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 `30` and compatible with version `v1.10.15`.

### APIs

- Added log level information to the result of `admin.setLoggerLevel`
- Updated `info.peers` to return chain aliases for `benched` chains
- Added support to sample validators of non-tracked subnets with `platform.sampleValidators`
- Added `avalanche_{chainID}_max_verified_height` metric to track the highest verified block

### Configs

- Added `--db-read-only` to run the node without writing to disk.
- This flag is only expected to be used during testing as it will cause memory use to increase over time
- Removed `--bootstrap-retry-enabled`
- Removed `--bootstrap-retry-warn-frequency`

### Fixes

- Fixed packing of large block requests during C-chain state sync
- Fixed order of updating acceptor tip and sending chain events to C-chain event subscribers

### What's Changed

- Return log levels from admin.SetLoggerLevel by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2250
- feat(api) : Peers function to return the PrimaryAlias of the chainID by @DoTheBestToGetTheBest in https://github.com/ava-labs/avalanchego/pull/2251
- Switch to using require.TestingT interface in SenderTest struct by @marun in https://github.com/ava-labs/avalanchego/pull/2258
- Cleanup `ipcs` `Socket` test by @danlaine in https://github.com/ava-labs/avalanchego/pull/2257
- Require poll metrics to be registered by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2260
- Track all subnet validator sets in the validator manager by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2253
- e2e: Make NewWallet and NewEthclient regular functions by @marun in https://github.com/ava-labs/avalanchego/pull/2262
- Fix typos in docs by @vuittont60 in https://github.com/ava-labs/avalanchego/pull/2261
- Remove Token constants information from keys by @dboehm-avalabs in https://github.com/ava-labs/avalanchego/pull/2197
- Remove unused `UnsortedEquals` function by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2264
- Document p2p package by @joshua-kim in https://github.com/ava-labs/avalanchego/pull/2254
- Use extended public key to derive ledger addresses by @felipemadero in https://github.com/ava-labs/avalanchego/pull/2246
- `merkledb` -- rename nit by @danlaine in https://github.com/ava-labs/avalanchego/pull/2267
- `merkledb` -- fix nil check in test by @danlaine in https://github.com/ava-labs/avalanchego/pull/2268
- Add read-only database flag (`--db-read-only`) by @danlaine in https://github.com/ava-labs/avalanchego/pull/2266
- `merkledb` -- remove unneeded var declarations by @danlaine in https://github.com/ava-labs/avalanchego/pull/2269
- Add fuzz test for `NewIteratorWithStartAndPrefix` by @danlaine in https://github.com/ava-labs/avalanchego/pull/1992
- Return if element was deleted from `Hashmap` by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2271
- `mempool.NewMempool` -> `mempool.New` by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2276
- e2e: Refactor suite setup and helpers to tests/fixture/e2e for reuse by coreth by @marun in https://github.com/ava-labs/avalanchego/pull/2265
- Cleanup platformvm mempool errs by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2278
- MerkleDB:Naming and comments cleanup by @dboehm-avalabs in https://github.com/ava-labs/avalanchego/pull/2274
- Move `DropExpiredStakerTxs` to platformvm mempool by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2279
- Cleanup `ids.NodeID` usage by @abi87 in https://github.com/ava-labs/avalanchego/pull/2280
- Genesis validators cleanup by @abi87 in https://github.com/ava-labs/avalanchego/pull/2282
- Remove Lazy Initialize on Node by @joshua-kim in https://github.com/ava-labs/avalanchego/pull/1384
- Remove sentinel node from MerkleDB proofs by @dboehm-avalabs in https://github.com/ava-labs/avalanchego/pull/2106
- Embed `noop` handler for all unhandled messages by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2288
- `merkledb` -- Add `Clearer` interface by @danlaine in https://github.com/ava-labs/avalanchego/pull/2277
- Simplify get server creation by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2285
- Move management of platformvm preferred block to `executor.Manager` by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2292
- Add `recentTxsLock` to platform `network` struct by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2294
- e2e: More fixture refinement in support of coreth integration testing by @marun in https://github.com/ava-labs/avalanchego/pull/2275
- Add `VerifyTx` to `executor.Manager` by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2293
- Simplify avalanche bootstrapping by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2286
- Replace unique slices with sets in the engine interface by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2317
- Use zap.Stringer rather than zap.Any by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2320
- Move `AddUnverifiedTx` logic to `network.IssueTx` by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2310
- Remove `AddUnverifiedTx` from `Builder` by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2311
- Remove error from SDK AppGossip handler by @joshua-kim in https://github.com/ava-labs/avalanchego/pull/2252
- Rename AppRequestFailed to AppError by @joshua-kim in https://github.com/ava-labs/avalanchego/pull/2321
- Remove `Network` interface from `Builder` by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2312
- Update `error_code` to be sint32 instead of uint32. by @joshua-kim in https://github.com/ava-labs/avalanchego/pull/2322
- Refactor bootstrapper implementation into consensus by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2300
- Pchain - Cleanup NodeID generation in UTs by @abi87 in https://github.com/ava-labs/avalanchego/pull/2291
- nit: loop --> variadic by @danlaine in https://github.com/ava-labs/avalanchego/pull/2316
- Update zap dependency to v1.26.0 by @danlaine in https://github.com/ava-labs/avalanchego/pull/2325
- Remove useless anon functions by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2326
- Move `network` implementation to separate package by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2296
- Unexport avalanche constant from common package by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2327
- Remove `common.Config` functions by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2328
- Move engine startup into helper function by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2329
- Remove bootstrapping retry config by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2301
- Export snowman bootstrapper by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2331
- Remove common.Config from syncer.Config by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2330
- `platformvm.VM` -- replace `Config` field with `validators.Manager` by @danlaine in https://github.com/ava-labs/avalanchego/pull/2319
- Improve height monitoring by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2347
- Cleanup snowman consensus metrics by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2349
- Expand consensus health check by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2354
- Reduce the size of the OracleBlock interface by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2355
- [vms/proposervm] Update Build Heuristic by @patrick-ogrady in https://github.com/ava-labs/avalanchego/pull/2348
- Use linkedhashmap for P-Chain mempool by @gyuho in https://github.com/ava-labs/avalanchego/pull/1536
- Increase txs in pool metric when adding tx by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2361

### New Contributors

- @DoTheBestToGetTheBest made their first contribution in https://github.com/ava-labs/avalanchego/pull/2251
- @vuittont60 made their first contribution in https://github.com/ava-labs/avalanchego/pull/2261

**Full Changelog**: https://github.com/ava-labs/avalanchego/compare/v1.10.15...v1.10.16

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

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
65 changes: 28 additions & 37 deletions chains/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ type ManagerConfig struct {
MeterVMEnabled bool // Should each VM be wrapped with a MeterVM
Metrics metrics.MultiGatherer

AcceptedFrontierGossipFrequency time.Duration
ConsensusAppConcurrency int
FrontierPollFrequency time.Duration
ConsensusAppConcurrency int

// Max Time to spend fetching a container and its
// ancestors when responding to a GetAncestors
Expand Down Expand Up @@ -824,7 +824,7 @@ func (m *manager) createAvalancheChain(
ctx,
vdrs,
msgChan,
m.AcceptedFrontierGossipFrequency,
m.FrontierPollFrequency,
m.ConsensusAppConcurrency,
m.ResourceTracker,
validators.UnhandledSubnetConnector, // avalanche chains don't use subnet connector
Expand Down Expand Up @@ -878,21 +878,17 @@ func (m *manager) createAvalancheChain(

// create bootstrap gear
bootstrapCfg := smbootstrap.Config{
Config: common.Config{
Ctx: ctx,
Beacons: vdrs,
SampleK: sampleK,
Alpha: bootstrapWeight/2 + 1, // must be > 50%
StartupTracker: startupTracker,
Sender: snowmanMessageSender,
BootstrapTracker: sb,
Timer: h,
AncestorsMaxContainersReceived: m.BootstrapAncestorsMaxContainersReceived,
SharedCfg: &common.SharedConfig{},
},
AllGetsServer: snowGetHandler,
Blocked: blockBlocker,
VM: vmWrappingProposerVM,
AllGetsServer: snowGetHandler,
Ctx: ctx,
Beacons: vdrs,
SampleK: sampleK,
StartupTracker: startupTracker,
Sender: snowmanMessageSender,
BootstrapTracker: sb,
Timer: h,
AncestorsMaxContainersReceived: m.BootstrapAncestorsMaxContainersReceived,
Blocked: blockBlocker,
VM: vmWrappingProposerVM,
}
var snowmanBootstrapper common.BootstrapableEngine
snowmanBootstrapper, err = smbootstrap.New(
Expand Down Expand Up @@ -1170,7 +1166,7 @@ func (m *manager) createSnowmanChain(
ctx,
vdrs,
msgChan,
m.AcceptedFrontierGossipFrequency,
m.FrontierPollFrequency,
m.ConsensusAppConcurrency,
m.ResourceTracker,
subnetConnector,
Expand Down Expand Up @@ -1224,24 +1220,19 @@ func (m *manager) createSnowmanChain(
}

// create bootstrap gear
alpha := bootstrapWeight/2 + 1 // must be > 50%
bootstrapCfg := smbootstrap.Config{
Config: common.Config{
Ctx: ctx,
Beacons: beacons,
SampleK: sampleK,
StartupTracker: startupTracker,
Alpha: alpha,
Sender: messageSender,
BootstrapTracker: sb,
Timer: h,
AncestorsMaxContainersReceived: m.BootstrapAncestorsMaxContainersReceived,
SharedCfg: &common.SharedConfig{},
},
AllGetsServer: snowGetHandler,
Blocked: blocked,
VM: vm,
Bootstrapped: bootstrapFunc,
AllGetsServer: snowGetHandler,
Ctx: ctx,
Beacons: beacons,
SampleK: sampleK,
StartupTracker: startupTracker,
Sender: messageSender,
BootstrapTracker: sb,
Timer: h,
AncestorsMaxContainersReceived: m.BootstrapAncestorsMaxContainersReceived,
Blocked: blocked,
VM: vm,
Bootstrapped: bootstrapFunc,
}
var bootstrapper common.BootstrapableEngine
bootstrapper, err = smbootstrap.New(
Expand All @@ -1264,7 +1255,7 @@ func (m *manager) createSnowmanChain(
messageSender,
beacons,
sampleK,
alpha,
bootstrapWeight/2+1, // must be > 50%
m.StateSyncBeacons,
vm,
)
Expand Down
26 changes: 12 additions & 14 deletions codec/hierarchycodec/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/ava-labs/avalanchego/codec"
"github.com/ava-labs/avalanchego/codec/reflectcodec"
"github.com/ava-labs/avalanchego/utils/bimap"
"github.com/ava-labs/avalanchego/utils/wrappers"
)

Expand Down Expand Up @@ -42,20 +43,18 @@ type typeID struct {
type hierarchyCodec struct {
codec.Codec

lock sync.RWMutex
currentGroupID uint16
nextTypeID uint16
typeIDToType map[typeID]reflect.Type
typeToTypeID map[reflect.Type]typeID
lock sync.RWMutex
currentGroupID uint16
nextTypeID uint16
registeredTypes *bimap.BiMap[typeID, reflect.Type]
}

// New returns a new, concurrency-safe codec
func New(tagNames []string, maxSliceLen uint32) Codec {
hCodec := &hierarchyCodec{
currentGroupID: 0,
nextTypeID: 0,
typeIDToType: map[typeID]reflect.Type{},
typeToTypeID: map[reflect.Type]typeID{},
currentGroupID: 0,
nextTypeID: 0,
registeredTypes: bimap.New[typeID, reflect.Type](),
}
hCodec.Codec = reflectcodec.New(hCodec, tagNames, maxSliceLen)
return hCodec
Expand Down Expand Up @@ -88,7 +87,7 @@ func (c *hierarchyCodec) RegisterType(val interface{}) error {
defer c.lock.Unlock()

valType := reflect.TypeOf(val)
if _, exists := c.typeToTypeID[valType]; exists {
if c.registeredTypes.HasValue(valType) {
return fmt.Errorf("%w: %v", codec.ErrDuplicateType, valType)
}

Expand All @@ -98,8 +97,7 @@ func (c *hierarchyCodec) RegisterType(val interface{}) error {
}
c.nextTypeID++

c.typeIDToType[valTypeID] = valType
c.typeToTypeID[valType] = valTypeID
c.registeredTypes.Put(valTypeID, valType)
return nil
}

Expand All @@ -112,7 +110,7 @@ func (c *hierarchyCodec) PackPrefix(p *wrappers.Packer, valueType reflect.Type)
c.lock.RLock()
defer c.lock.RUnlock()

typeID, ok := c.typeToTypeID[valueType] // Get the type ID of the value being marshaled
typeID, ok := c.registeredTypes.GetKey(valueType) // Get the type ID of the value being marshaled
if !ok {
return fmt.Errorf("can't marshal unregistered type %q", valueType)
}
Expand All @@ -136,7 +134,7 @@ func (c *hierarchyCodec) UnpackPrefix(p *wrappers.Packer, valueType reflect.Type
typeID: typeIDShort,
}
// Get a type that implements the interface
implementingType, ok := c.typeIDToType[t]
implementingType, ok := c.registeredTypes.GetValue(t)
if !ok {
return reflect.Value{}, fmt.Errorf("couldn't unmarshal interface: unknown type ID %+v", t)
}
Expand Down
22 changes: 10 additions & 12 deletions codec/linearcodec/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/ava-labs/avalanchego/codec"
"github.com/ava-labs/avalanchego/codec/reflectcodec"
"github.com/ava-labs/avalanchego/utils/bimap"
"github.com/ava-labs/avalanchego/utils/wrappers"
)

Expand All @@ -36,19 +37,17 @@ type Codec interface {
type linearCodec struct {
codec.Codec

lock sync.RWMutex
nextTypeID uint32
typeIDToType map[uint32]reflect.Type
typeToTypeID map[reflect.Type]uint32
lock sync.RWMutex
nextTypeID uint32
registeredTypes *bimap.BiMap[uint32, reflect.Type]
}

// New returns a new, concurrency-safe codec; it allow to specify
// both tagNames and maxSlicelenght
func New(tagNames []string, maxSliceLen uint32) Codec {
hCodec := &linearCodec{
nextTypeID: 0,
typeIDToType: map[uint32]reflect.Type{},
typeToTypeID: map[reflect.Type]uint32{},
nextTypeID: 0,
registeredTypes: bimap.New[uint32, reflect.Type](),
}
hCodec.Codec = reflectcodec.New(hCodec, tagNames, maxSliceLen)
return hCodec
Expand Down Expand Up @@ -78,12 +77,11 @@ func (c *linearCodec) RegisterType(val interface{}) error {
defer c.lock.Unlock()

valType := reflect.TypeOf(val)
if _, exists := c.typeToTypeID[valType]; exists {
if c.registeredTypes.HasValue(valType) {
return fmt.Errorf("%w: %v", codec.ErrDuplicateType, valType)
}

c.typeIDToType[c.nextTypeID] = valType
c.typeToTypeID[valType] = c.nextTypeID
c.registeredTypes.Put(c.nextTypeID, valType)
c.nextTypeID++
return nil
}
Expand All @@ -97,7 +95,7 @@ func (c *linearCodec) PackPrefix(p *wrappers.Packer, valueType reflect.Type) err
c.lock.RLock()
defer c.lock.RUnlock()

typeID, ok := c.typeToTypeID[valueType] // Get the type ID of the value being marshaled
typeID, ok := c.registeredTypes.GetKey(valueType) // Get the type ID of the value being marshaled
if !ok {
return fmt.Errorf("can't marshal unregistered type %q", valueType)
}
Expand All @@ -114,7 +112,7 @@ func (c *linearCodec) UnpackPrefix(p *wrappers.Packer, valueType reflect.Type) (
return reflect.Value{}, fmt.Errorf("couldn't unmarshal interface: %w", p.Err)
}
// Get a type that implements the interface
implementingType, ok := c.typeIDToType[typeID]
implementingType, ok := c.registeredTypes.GetValue(typeID)
if !ok {
return reflect.Value{}, fmt.Errorf("couldn't unmarshal interface: unknown type ID %d", typeID)
}
Expand Down
17 changes: 12 additions & 5 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ const (
subnetConfigFileExt = ".json"
ipResolutionTimeout = 30 * time.Second

ipcDeprecationMsg = "IPC API is deprecated"
keystoreDeprecationMsg = "keystore API is deprecated"
ipcDeprecationMsg = "IPC API is deprecated"
keystoreDeprecationMsg = "keystore API is deprecated"
acceptedFrontierGossipDeprecationMsg = "push-based accepted frontier gossip is deprecated"
)

var (
Expand All @@ -72,6 +73,12 @@ var (
IpcsChainIDsKey: ipcDeprecationMsg,
IpcsPathKey: ipcDeprecationMsg,
KeystoreAPIEnabledKey: keystoreDeprecationMsg,
ConsensusGossipAcceptedFrontierValidatorSizeKey: acceptedFrontierGossipDeprecationMsg,
ConsensusGossipAcceptedFrontierNonValidatorSizeKey: acceptedFrontierGossipDeprecationMsg,
ConsensusGossipAcceptedFrontierPeerSizeKey: acceptedFrontierGossipDeprecationMsg,
ConsensusGossipOnAcceptValidatorSizeKey: acceptedFrontierGossipDeprecationMsg,
ConsensusGossipOnAcceptNonValidatorSizeKey: acceptedFrontierGossipDeprecationMsg,
ConsensusGossipOnAcceptPeerSizeKey: acceptedFrontierGossipDeprecationMsg,
}

errSybilProtectionDisabledStakerWeights = errors.New("sybil protection disabled weights must be positive")
Expand Down Expand Up @@ -1320,9 +1327,9 @@ func GetNodeConfig(v *viper.Viper) (node.Config, error) {
}

// Gossiping
nodeConfig.AcceptedFrontierGossipFrequency = v.GetDuration(ConsensusAcceptedFrontierGossipFrequencyKey)
if nodeConfig.AcceptedFrontierGossipFrequency < 0 {
return node.Config{}, fmt.Errorf("%s must be >= 0", ConsensusAcceptedFrontierGossipFrequencyKey)
nodeConfig.FrontierPollFrequency = v.GetDuration(ConsensusFrontierPollFrequencyKey)
if nodeConfig.FrontierPollFrequency < 0 {
return node.Config{}, fmt.Errorf("%s must be >= 0", ConsensusFrontierPollFrequencyKey)
}

// App handling
Expand Down

0 comments on commit 738bd2e

Please sign in to comment.