From eb7ddd75e0bf13b4671b385a9bb7a364b2e8b553 Mon Sep 17 00:00:00 2001 From: cocoyeal <150209682+cocoyeal@users.noreply.github.com> Date: Mon, 20 May 2024 22:42:41 +0800 Subject: [PATCH 1/4] Fix broken docs link (#3028) --- api/admin/service.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/admin/service.md b/api/admin/service.md index 94afbf370451..4a2a97c29e13 100644 --- a/api/admin/service.md +++ b/api/admin/service.md @@ -75,7 +75,7 @@ Now, calls to the X-Chain can be made to either `/ext/bc/X` or, equivalently, to Give a blockchain an alias, a different name that can be used any place the blockchain’s ID is used. -:::note Aliasing a chain can also be done via the [Node API](https://docs.avax.network/nodes/configure/avalanchego-config-flags.md#--chain-aliases-file-string). +:::note Aliasing a chain can also be done via the [Node API](/nodes/configure/avalanchego-config-flags.md#--chain-aliases-file-string). Note that the alias is set for each chain on each node individually. In a multi-node Subnet, the same alias should be configured on each node to use an alias across a Subnet successfully. Setting an alias for a chain on one node does not register that alias with other nodes automatically. From 46bc6f5e86dd7ef0ecd8bddec7c6c2b84564019c Mon Sep 17 00:00:00 2001 From: Dhruba Basu <7675102+dhrubabasu@users.noreply.github.com> Date: Mon, 20 May 2024 18:40:21 -0400 Subject: [PATCH 2/4] `gossipping` -> `gossiping` (#3033) --- RELEASES.md | 4 ++-- node/node.go | 2 +- snow/README.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 5fd5372d5e86..051b1801aac5 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -3018,7 +3018,7 @@ This version is backwards compatible to [v1.7.0](https://github.com/ava-labs/ava ### Networking -- Reduced default peerlist and accepted frontier gossipping +- Reduced default peerlist and accepted frontier gossiping - Increased the default at-large outbound buffer size to 32 MiB ### Metrics @@ -3100,7 +3100,7 @@ This version is backwards compatible to [v1.7.0](https://github.com/ava-labs/ava - Added `--snow-mixed-query-num-push-vdr` and `--snow-mixed-query-num-push-non-vdr` to allow parameterization of sending push queries - By default, non-validators now send only pull queries, not push queries. - By default, validators now send both pull queries and push queries upon inserting a container into consensus. Previously, nodes sent only push queries. -- Added metrics to track the amount of over gossipping of `peerlist` messages +- Added metrics to track the amount of over gossiping of `peerlist` messages - Added custom message queueing support to outbound `Peer` messages - Reused `Ping` messages to avoid needless memory allocations diff --git a/node/node.go b/node/node.go index d225667ccf13..9144541f8a3a 100644 --- a/node/node.go +++ b/node/node.go @@ -504,7 +504,7 @@ func (n *Node) initNetworking() error { } } if unknownACPs.Len() > 0 { - n.Log.Warn("gossipping unknown ACPs", + n.Log.Warn("gossiping unknown ACPs", zap.Reflect("acps", unknownACPs), ) } diff --git a/snow/README.md b/snow/README.md index b5b16bc938ba..86a90919b2ac 100644 --- a/snow/README.md +++ b/snow/README.md @@ -47,7 +47,7 @@ Currently, Avalanchego implements its own message serialization to communicate. ### [Network](https://github.com/ava-labs/avalanchego/blob/master/network/network.go) -The networking interface is shared across all chains. It implements functions from the `ExternalSender` interface. The two functions it implements are `Send` and `Gossip`. `Send` sends a message of type `OutboundMessage` to a specific set of nodes (specified by an array of `NodeIDs`). `Gossip` sends a message of type `OutboundMessage` to a random group of nodes in a subnet (can be a validator or a non-validator). Gossipping is used to push transactions across the network. The networking protocol uses TLS to pass messages between peers. +The networking interface is shared across all chains. It implements functions from the `ExternalSender` interface. The two functions it implements are `Send` and `Gossip`. `Send` sends a message of type `OutboundMessage` to a specific set of nodes (specified by an array of `NodeIDs`). `Gossip` sends a message of type `OutboundMessage` to a random group of nodes in a subnet (can be a validator or a non-validator). gossiping is used to push transactions across the network. The networking protocol uses TLS to pass messages between peers. Along with sending and gossiping, the networking library is also responsible for making connections and maintaining connections. Any node whether they are a validator or non-validator will attempt to connect to the primary network. From 7106666fd2e1bbe714c7e894da35a2a2cedd15e0 Mon Sep 17 00:00:00 2001 From: marun Date: Mon, 20 May 2024 16:38:13 -0700 Subject: [PATCH 3/4] [tmpnet] Ensure tmpnet compatibility with windows (#3002) Signed-off-by: marun Co-authored-by: Stephen Buttolph --- scripts/build_test.sh | 6 ------ .../fixture/tmpnet/detached_process_default.go | 17 +++++++++++++++++ .../fixture/tmpnet/detached_process_windows.go | 12 ++++++++++++ tests/fixture/tmpnet/node_process.go | 5 +---- 4 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 tests/fixture/tmpnet/detached_process_default.go create mode 100644 tests/fixture/tmpnet/detached_process_windows.go diff --git a/scripts/build_test.sh b/scripts/build_test.sh index 747cb8882449..cfff1a2fc9fd 100755 --- a/scripts/build_test.sh +++ b/scripts/build_test.sh @@ -9,12 +9,6 @@ source "$AVALANCHE_PATH"/scripts/constants.sh EXCLUDED_TARGETS="| grep -v /mocks | grep -v proto | grep -v tests/e2e | grep -v tests/upgrade" -GOOS=$(go env GOOS) -if [[ "$GOOS" == "windows" ]]; then - # tmpnet and antithesis tests (which depend on tmpnet) are not compatible with windows - EXCLUDED_TARGETS="${EXCLUDED_TARGETS} | grep -v tests/fixture | grep -v tests/antithesis" -fi - TEST_TARGETS="$(eval "go list ./... ${EXCLUDED_TARGETS}")" # shellcheck disable=SC2086 diff --git a/tests/fixture/tmpnet/detached_process_default.go b/tests/fixture/tmpnet/detached_process_default.go new file mode 100644 index 000000000000..0e4b20ddd8e3 --- /dev/null +++ b/tests/fixture/tmpnet/detached_process_default.go @@ -0,0 +1,17 @@ +// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +//go:build linux || darwin + +package tmpnet + +import ( + "os/exec" + "syscall" +) + +func configureDetachedProcess(cmd *exec.Cmd) { + cmd.SysProcAttr = &syscall.SysProcAttr{ + Setsid: true, + } +} diff --git a/tests/fixture/tmpnet/detached_process_windows.go b/tests/fixture/tmpnet/detached_process_windows.go new file mode 100644 index 000000000000..bf7ff9a726b4 --- /dev/null +++ b/tests/fixture/tmpnet/detached_process_windows.go @@ -0,0 +1,12 @@ +// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +//go:build windows + +package tmpnet + +import "os/exec" + +func configureDetachedProcess(*exec.Cmd) { + panic("tmpnet deployment to windows is not supported") +} diff --git a/tests/fixture/tmpnet/node_process.go b/tests/fixture/tmpnet/node_process.go index 4ce0997eb60f..f2a9c7ff628d 100644 --- a/tests/fixture/tmpnet/node_process.go +++ b/tests/fixture/tmpnet/node_process.go @@ -114,11 +114,8 @@ func (p *NodeProcess) Start(w io.Writer) error { // All arguments are provided in the flags file cmd := exec.Command(p.node.RuntimeConfig.AvalancheGoPath, "--config-file", p.node.getFlagsPath()) // #nosec G204 - // Ensure process is detached from the parent process so that an error in the parent will not affect the child - cmd.SysProcAttr = &syscall.SysProcAttr{ - Setsid: true, - } + configureDetachedProcess(cmd) if err := cmd.Start(); err != nil { return err From 551f8d33cbed58a0159f29e200be76c3283b0347 Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Mon, 20 May 2024 22:03:28 -0400 Subject: [PATCH 4/4] Fix negative ETA caused by rollback in vm.SetState (#3036) --- snow/engine/snowman/bootstrap/bootstrapper.go | 16 +++++----- .../snowman/bootstrap/bootstrapper_test.go | 31 +++++++++++++++++++ 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/snow/engine/snowman/bootstrap/bootstrapper.go b/snow/engine/snowman/bootstrap/bootstrapper.go index 2988ece9ba0e..095ba4e63b17 100644 --- a/snow/engine/snowman/bootstrap/bootstrapper.go +++ b/snow/engine/snowman/bootstrap/bootstrapper.go @@ -150,6 +150,14 @@ func (b *Bootstrapper) Clear(context.Context) error { } func (b *Bootstrapper) Start(ctx context.Context, startReqID uint32) error { + b.Ctx.State.Set(snow.EngineState{ + Type: p2p.EngineType_ENGINE_TYPE_SNOWMAN, + State: snow.Bootstrapping, + }) + if err := b.VM.SetState(ctx, snow.Bootstrapping); err != nil { + return fmt.Errorf("failed to notify VM that bootstrapping has started: %w", err) + } + lastAccepted, err := b.getLastAccepted(ctx) if err != nil { return err @@ -161,14 +169,6 @@ func (b *Bootstrapper) Start(ctx context.Context, startReqID uint32) error { zap.Uint64("lastAcceptedHeight", lastAcceptedHeight), ) - b.Ctx.State.Set(snow.EngineState{ - Type: p2p.EngineType_ENGINE_TYPE_SNOWMAN, - State: snow.Bootstrapping, - }) - if err := b.VM.SetState(ctx, snow.Bootstrapping); err != nil { - return fmt.Errorf("failed to notify VM that bootstrapping has started: %w", err) - } - // Set the starting height b.startingHeight = lastAcceptedHeight b.requestID = startReqID diff --git a/snow/engine/snowman/bootstrap/bootstrapper_test.go b/snow/engine/snowman/bootstrap/bootstrapper_test.go index 159fc98fb581..5577f62fa81d 100644 --- a/snow/engine/snowman/bootstrap/bootstrapper_test.go +++ b/snow/engine/snowman/bootstrap/bootstrapper_test.go @@ -742,6 +742,37 @@ func TestBootstrapperReceiveStaleAncestorsMessage(t *testing.T) { require.Equal(snow.Bootstrapping, config.Ctx.State.Get().State) } +func TestBootstrapperRollbackOnSetState(t *testing.T) { + require := require.New(t) + + config, _, _, vm := newConfig(t) + + blks := snowmantest.BuildChain(2) + initializeVMWithBlockchain(vm, blks) + + blks[1].StatusV = choices.Accepted + + bs, err := New( + config, + func(context.Context, uint32) error { + config.Ctx.State.Set(snow.EngineState{ + Type: p2ppb.EngineType_ENGINE_TYPE_SNOWMAN, + State: snow.NormalOp, + }) + return nil + }, + ) + require.NoError(err) + + vm.SetStateF = func(context.Context, snow.State) error { + blks[1].StatusV = choices.Processing + return nil + } + + require.NoError(bs.Start(context.Background(), 0)) + require.Equal(blks[0].HeightV, bs.startingHeight) +} + func initializeVMWithBlockchain(vm *block.TestVM, blocks []*snowmantest.Block) { vm.CantSetState = false vm.LastAcceptedF = func(context.Context) (ids.ID, error) {