From 1b0f49324ff9a3c094a7e4c50c2636962eecea46 Mon Sep 17 00:00:00 2001 From: Dan Laine Date: Fri, 19 Mar 2021 14:35:23 -0400 Subject: [PATCH 01/13] better bootstrapping logs --- snow/engine/common/bootstrapper.go | 4 +-- snow/engine/snowman/bootstrap/bootstrapper.go | 30 +++++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/snow/engine/common/bootstrapper.go b/snow/engine/common/bootstrapper.go index dd714d10a381..6307ebcb3b40 100644 --- a/snow/engine/common/bootstrapper.go +++ b/snow/engine/common/bootstrapper.go @@ -21,11 +21,11 @@ const ( // StatusUpdateFrequency is how many containers should be processed between // logs - StatusUpdateFrequency = 2500 + StatusUpdateFrequency = 5000 // MaxOutstandingRequests is the maximum number of GetAncestors sent but not // responded to/failed - MaxOutstandingRequests = 8 + MaxOutstandingRequests = 10 // MaxTimeFetchingAncestors is the maximum amount of time to spend fetching // vertices during a call to GetAncestors diff --git a/snow/engine/snowman/bootstrap/bootstrapper.go b/snow/engine/snowman/bootstrap/bootstrapper.go index ce4efe611414..0f707e97c08e 100644 --- a/snow/engine/snowman/bootstrap/bootstrapper.go +++ b/snow/engine/snowman/bootstrap/bootstrapper.go @@ -18,6 +18,7 @@ import ( "github.com/ava-labs/avalanchego/snow/engine/snowman/block" "github.com/ava-labs/avalanchego/snow/validators" "github.com/ava-labs/avalanchego/utils/formatting" + safemath "github.com/ava-labs/avalanchego/utils/math" ) const ( @@ -44,6 +45,13 @@ type Bootstrapper struct { common.Fetcher metrics + // Greatest height of the blocks passed in ForceAccepted + tipHeight uint64 + // Height of the last accepted block when bootstrapping starts + startingHeight uint64 + // Blocks passed into ForceAccepted + startingAcceptedFrontier ids.Set + // Blocked tracks operations that are blocked on blocks Blocked *queue.Jobs @@ -72,6 +80,16 @@ func (b *Bootstrapper) Initialize( b.OnFinished = onFinished b.executedStateTransitions = math.MaxInt32 b.delayAmount = initialBootstrappingDelay + b.startingAcceptedFrontier = ids.Set{} + lastAcceptedID, err := b.VM.LastAccepted() + if err != nil { + return fmt.Errorf("couldn't get last accepted ID: %s", err) + } + lastAccepted, err := b.VM.GetBlock(lastAcceptedID) + if err != nil { + return fmt.Errorf("couldn't get last accepted block: %s", err) + } + b.startingHeight = lastAccepted.Height() if err := b.metrics.Initialize(namespace, registerer); err != nil { return err @@ -114,7 +132,11 @@ func (b *Bootstrapper) ForceAccepted(acceptedContainerIDs []ids.ID) error { b.NumFetched = 0 for _, blkID := range acceptedContainerIDs { + b.startingAcceptedFrontier.Add(blkID) if blk, err := b.VM.GetBlock(blkID); err == nil { + if height := blk.Height(); height > b.tipHeight { + b.tipHeight = height + } if err := b.process(blk); err != nil { return err } @@ -213,6 +235,10 @@ func (b *Bootstrapper) GetAncestorsFailed(vdr ids.ShortID, requestID uint32) err func (b *Bootstrapper) process(blk snowman.Block) error { status := blk.Status() blkID := blk.ID() + blkHeight := blk.Height() + if blkHeight > b.tipHeight && b.startingAcceptedFrontier.Contains(blkID) { + b.tipHeight = blkHeight + } for status == choices.Processing { if err := b.Blocked.Push(&blockJob{ numAccepted: b.numAccepted, @@ -222,7 +248,7 @@ func (b *Bootstrapper) process(blk snowman.Block) error { b.numFetched.Inc() b.NumFetched++ // Progress tracker if b.NumFetched%common.StatusUpdateFrequency == 0 { // Periodically print progress - b.Ctx.Log.Info("fetched %d blocks", b.NumFetched) + b.Ctx.Log.Info("fetched %d of %d blocks", b.NumFetched, safemath.Max64(0, b.tipHeight-b.startingHeight)) } } @@ -333,7 +359,7 @@ func (b *Bootstrapper) executeAll(jobs *queue.Jobs) (int, error) { } numExecuted++ if numExecuted%common.StatusUpdateFrequency == 0 { // Periodically print progress - b.Ctx.Log.Info("executed %d blocks", numExecuted) + b.Ctx.Log.Info("executed %d of %d blocks", numExecuted, safemath.Max64(0, b.tipHeight-b.startingHeight)) } b.Ctx.ConsensusDispatcher.Accept(b.Ctx, job.ID(), job.Bytes()) From e6ece85f578c3d1ce3b8099df59e59ca8b31d67b Mon Sep 17 00:00:00 2001 From: Dan Laine Date: Fri, 19 Mar 2021 15:52:02 -0400 Subject: [PATCH 02/13] reduce number of repeated bootstrap logs --- .../avalanche/bootstrap/bootstrapper.go | 41 ++++++++++++++----- snow/engine/common/bootstrapper.go | 12 +++++- snow/engine/snowman/bootstrap/bootstrapper.go | 37 ++++++++++++----- 3 files changed, 67 insertions(+), 23 deletions(-) diff --git a/snow/engine/avalanche/bootstrap/bootstrapper.go b/snow/engine/avalanche/bootstrap/bootstrapper.go index ea7f4c11b945..08c8884079cb 100644 --- a/snow/engine/avalanche/bootstrap/bootstrapper.go +++ b/snow/engine/avalanche/bootstrap/bootstrapper.go @@ -195,7 +195,11 @@ func (b *Bootstrapper) process(vtxs ...avalanche.Vertex) error { b.numFetchedVts.Inc() b.NumFetched++ // Progress tracker if b.NumFetched%common.StatusUpdateFrequency == 0 { - b.Ctx.Log.Info("fetched %d vertices", b.NumFetched) + if !b.Restarted { + b.Ctx.Log.Info("fetched %d vertices", b.NumFetched) + } else { + b.Ctx.Log.Debug("fetched %d vertices", b.NumFetched) + } } } else { b.Ctx.Log.Verbo("couldn't push to vtxBlocked: %s", err) @@ -373,15 +377,22 @@ func (b *Bootstrapper) checkFinish() error { return nil } - b.Ctx.Log.Info("bootstrapping fetched %d vertices. executing transaction state transitions...", - b.NumFetched) + if !b.Restarted { + b.Ctx.Log.Info("bootstrapping fetched %d vertices. Executing transaction state transitions...", b.NumFetched) + } else { + b.Ctx.Log.Debug("bootstrapping fetched %d vertices. Executing transaction state transitions...", b.NumFetched) + } _, err := b.executeAll(b.TxBlocked, b.Ctx.DecisionDispatcher) if err != nil { return err } - b.Ctx.Log.Info("executing vertex state transitions...") + if b.Restarted { + b.Ctx.Log.Info("executing vertex state transitions...") + } else { + b.Ctx.Log.Debug("executing vertex state transitions...") + } executedVts, err := b.executeAll(b.VtxBlocked, b.Ctx.ConsensusDispatcher) if err != nil { return err @@ -394,19 +405,21 @@ func (b *Bootstrapper) checkFinish() error { // bootstrapping process will terminate even as new vertices are being // issued. if executedVts > 0 && executedVts < previouslyExecuted/2 && b.RetryBootstrap { - b.Ctx.Log.Info("bootstrapping is checking for more vertices before finishing the bootstrap process...") + b.Ctx.Log.Debug("checking for more vertices before finishing bootstrapping") return b.RestartBootstrap(true) } - b.Ctx.Log.Info("bootstrapping fetched enough vertices to finish the bootstrap process...") - // Notify the subnet that this chain is synced b.Subnet.Bootstrapped(b.Ctx.ChainID) // If the subnet hasn't finished bootstrapping, this chain should remain // syncing. if !b.Subnet.IsBootstrapped() { - b.Ctx.Log.Info("bootstrapping is waiting for the remaining chains in this subnet to finish syncing...") + if !b.Restarted { + b.Ctx.Log.Info("bootstrapping is waiting for the remaining chains in this subnet to finish syncing...") + } else { + b.Ctx.Log.Debug("bootstrapping is waiting for the remaining chains in this subnet to finish syncing...") + } // Delay new incoming messages to avoid consuming unnecessary resources // while keeping up to date on the latest tip. b.Config.Delay.Delay(b.delayAmount) @@ -450,12 +463,20 @@ func (b *Bootstrapper) executeAll(jobs *queue.Jobs, events snow.EventDispatcher) } numExecuted++ if numExecuted%common.StatusUpdateFrequency == 0 { // Periodically print progress - b.Ctx.Log.Info("executed %d operations", numExecuted) + if !b.Restarted { + b.Ctx.Log.Info("executed %d operations", numExecuted) + } else { + b.Ctx.Log.Debug("executed %d operations", numExecuted) + } } events.Accept(b.Ctx, job.ID(), job.Bytes()) } - b.Ctx.Log.Info("executed %d operations", numExecuted) + if !b.Restarted { + b.Ctx.Log.Info("executed %d operations", numExecuted) + } else { + b.Ctx.Log.Debug("executed %d operations", numExecuted) + } return numExecuted, nil } diff --git a/snow/engine/common/bootstrapper.go b/snow/engine/common/bootstrapper.go index 6307ebcb3b40..48e9a7eef645 100644 --- a/snow/engine/common/bootstrapper.go +++ b/snow/engine/common/bootstrapper.go @@ -42,6 +42,8 @@ type Bootstrapper struct { // received a reply from pendingAcceptedFrontier ids.ShortSet acceptedFrontier ids.Set + // True if RestartBootstrap has been called at least once + Restarted bool // holds the beacons that were sampled for the accepted frontier sampledBeacons validators.Set @@ -293,7 +295,11 @@ func (b *Bootstrapper) Accepted(validatorID ids.ShortID, requestID uint32, conta } } - b.Ctx.Log.Info("Bootstrapping started syncing with %d vertices in the accepted frontier", size) + if !b.Restarted { + b.Ctx.Log.Info("Bootstrapping started syncing with %d vertices in the accepted frontier", size) + } else { + b.Ctx.Log.Debug("Bootstrapping started syncing with %d vertices in the accepted frontier", size) + } return b.Bootstrapable.ForceAccepted(accepted) } @@ -333,10 +339,12 @@ func (b *Bootstrapper) Disconnected(validatorID ids.ShortID) error { } func (b *Bootstrapper) RestartBootstrap(reset bool) error { + b.Restarted = true + // resets the attempts when we're pulling blocks/vertices // we don't want to fail the bootstrap at that stage if reset { - b.Ctx.Log.Info("Checking for new frontiers...") + b.Ctx.Log.Debug("Checking for new frontiers") b.bootstrapAttempts = 0 } diff --git a/snow/engine/snowman/bootstrap/bootstrapper.go b/snow/engine/snowman/bootstrap/bootstrapper.go index 0f707e97c08e..5b7391b92ed0 100644 --- a/snow/engine/snowman/bootstrap/bootstrapper.go +++ b/snow/engine/snowman/bootstrap/bootstrapper.go @@ -23,7 +23,7 @@ import ( const ( // Parameters for delaying bootstrapping to avoid potential CPU burns - initialBootstrappingDelay = 500 * time.Millisecond + initialBootstrappingDelay = 2 * time.Second maxBootstrappingDelay = time.Minute ) @@ -248,7 +248,11 @@ func (b *Bootstrapper) process(blk snowman.Block) error { b.numFetched.Inc() b.NumFetched++ // Progress tracker if b.NumFetched%common.StatusUpdateFrequency == 0 { // Periodically print progress - b.Ctx.Log.Info("fetched %d of %d blocks", b.NumFetched, safemath.Max64(0, b.tipHeight-b.startingHeight)) + if !b.Restarted { + b.Ctx.Log.Info("fetched %d of %d blocks", b.NumFetched, safemath.Max64(0, b.tipHeight-b.startingHeight)) + } else { + b.Ctx.Log.Debug("fetched %d of %d blocks", b.NumFetched, safemath.Max64(0, b.tipHeight-b.startingHeight)) + } } } @@ -284,8 +288,11 @@ func (b *Bootstrapper) checkFinish() error { return nil } - b.Ctx.Log.Info("bootstrapping fetched %d blocks. executing state transitions...", - b.NumFetched) + if !b.Restarted { + b.Ctx.Log.Info("bootstrapping fetched %d blocks. Executing state transitions...", b.NumFetched) + } else { + b.Ctx.Log.Debug("bootstrapping fetched %d blocks. Executing state transitions...", b.NumFetched) + } executedBlocks, err := b.executeAll(b.Blocked) if err != nil { @@ -298,14 +305,10 @@ func (b *Bootstrapper) checkFinish() error { // Note that executedVts < c*previouslyExecuted is enforced so that the // bootstrapping process will terminate even as new blocks are being issued. if executedBlocks > 0 && executedBlocks < previouslyExecuted/2 && b.RetryBootstrap { - b.Ctx.Log.Info("bootstrapping is checking for more blocks before finishing the bootstrap process...") - b.processedStartingAcceptedFrontier = false return b.RestartBootstrap(true) } - b.Ctx.Log.Info("bootstrapping fetched enough blocks to finish the bootstrap process...") - // Notify the subnet that this chain is synced b.Subnet.Bootstrapped(b.Ctx.ChainID) @@ -318,7 +321,11 @@ func (b *Bootstrapper) checkFinish() error { // If the subnet hasn't finished bootstrapping, this chain should remain // syncing. if !b.Subnet.IsBootstrapped() { - b.Ctx.Log.Info("bootstrapping is waiting for the remaining chains in this subnet to finish syncing...") + if !b.Restarted { + b.Ctx.Log.Info("waiting for the remaining chains in this subnet to finish syncing") + } else { + b.Ctx.Log.Debug("waiting for the remaining chains in this subnet to finish syncing") + } // Delay new incoming messages to avoid consuming unnecessary resources // while keeping up to date on the latest tip. b.Config.Delay.Delay(b.delayAmount) @@ -359,13 +366,21 @@ func (b *Bootstrapper) executeAll(jobs *queue.Jobs) (int, error) { } numExecuted++ if numExecuted%common.StatusUpdateFrequency == 0 { // Periodically print progress - b.Ctx.Log.Info("executed %d of %d blocks", numExecuted, safemath.Max64(0, b.tipHeight-b.startingHeight)) + if !b.Restarted { + b.Ctx.Log.Info("executed %d of %d blocks", numExecuted, safemath.Max64(0, b.tipHeight-b.startingHeight)) + } else { + b.Ctx.Log.Debug("executed %d of %d blocks", numExecuted, safemath.Max64(0, b.tipHeight-b.startingHeight)) + } } b.Ctx.ConsensusDispatcher.Accept(b.Ctx, job.ID(), job.Bytes()) b.Ctx.DecisionDispatcher.Accept(b.Ctx, job.ID(), job.Bytes()) } - b.Ctx.Log.Info("executed %d blocks", numExecuted) + if !b.Restarted { + b.Ctx.Log.Info("executed %d blocks", numExecuted) + } else { + b.Ctx.Log.Debug("executed %d blocks", numExecuted) + } return numExecuted, nil } From ece7a2633f98dd75701f6bada7f911bdb884441b Mon Sep 17 00:00:00 2001 From: Dan Laine Date: Fri, 19 Mar 2021 16:23:52 -0400 Subject: [PATCH 03/13] typo; nits --- snow/engine/avalanche/bootstrap/bootstrapper.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snow/engine/avalanche/bootstrap/bootstrapper.go b/snow/engine/avalanche/bootstrap/bootstrapper.go index 08c8884079cb..54beba134b9d 100644 --- a/snow/engine/avalanche/bootstrap/bootstrapper.go +++ b/snow/engine/avalanche/bootstrap/bootstrapper.go @@ -388,7 +388,7 @@ func (b *Bootstrapper) checkFinish() error { return err } - if b.Restarted { + if !b.Restarted { b.Ctx.Log.Info("executing vertex state transitions...") } else { b.Ctx.Log.Debug("executing vertex state transitions...") @@ -416,9 +416,9 @@ func (b *Bootstrapper) checkFinish() error { // syncing. if !b.Subnet.IsBootstrapped() { if !b.Restarted { - b.Ctx.Log.Info("bootstrapping is waiting for the remaining chains in this subnet to finish syncing...") + b.Ctx.Log.Info("waiting for the remaining chains in this subnet to finish syncing") } else { - b.Ctx.Log.Debug("bootstrapping is waiting for the remaining chains in this subnet to finish syncing...") + b.Ctx.Log.Debug("waiting for the remaining chains in this subnet to finish syncing") } // Delay new incoming messages to avoid consuming unnecessary resources // while keeping up to date on the latest tip. From e636e7c68cc69f049861410a2a9d2622ef2e3f25 Mon Sep 17 00:00:00 2001 From: StephenButtolph Date: Thu, 25 Mar 2021 12:18:51 -0400 Subject: [PATCH 04/13] made vertex.Codec a package private var --- snow/engine/avalanche/vertex/builder.go | 2 +- snow/engine/avalanche/vertex/codec.go | 8 ++++---- snow/engine/avalanche/vertex/parser.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/snow/engine/avalanche/vertex/builder.go b/snow/engine/avalanche/vertex/builder.go index dd99d9b23e3f..a5ef9180ecda 100644 --- a/snow/engine/avalanche/vertex/builder.go +++ b/snow/engine/avalanche/vertex/builder.go @@ -47,7 +47,7 @@ func Build( return nil, err } - vtxBytes, err := Codec.Marshal(innerVtx.Version, innerVtx) + vtxBytes, err := c.Marshal(innerVtx.Version, innerVtx) vtx := statelessVertex{ innerStatelessVertex: innerVtx, id: hashing.ComputeHash256Array(vtxBytes), diff --git a/snow/engine/avalanche/vertex/codec.go b/snow/engine/avalanche/vertex/codec.go index 977b16459e36..0d5a6623d1dc 100644 --- a/snow/engine/avalanche/vertex/codec.go +++ b/snow/engine/avalanche/vertex/codec.go @@ -23,18 +23,18 @@ const ( ) var ( - Codec codec.Manager + c codec.Manager ) func init() { codecV0 := linearcodec.New("serializeV0", maxSize) codecV1 := linearcodec.New("serializeV1", maxSize) - Codec = codec.NewManager(maxSize) + c = codec.NewManager(maxSize) errs := wrappers.Errs{} errs.Add( - Codec.RegisterCodec(noEpochTransitionsCodecVersion, codecV0), - Codec.RegisterCodec(apricotCodecVersion, codecV1), + c.RegisterCodec(noEpochTransitionsCodecVersion, codecV0), + c.RegisterCodec(apricotCodecVersion, codecV1), ) if errs.Errored() { panic(errs.Err) diff --git a/snow/engine/avalanche/vertex/parser.go b/snow/engine/avalanche/vertex/parser.go index 6218570b55c6..dcb57c9c709f 100644 --- a/snow/engine/avalanche/vertex/parser.go +++ b/snow/engine/avalanche/vertex/parser.go @@ -17,7 +17,7 @@ type Parser interface { // Parse the provided vertex bytes into a stateless vertex func Parse(vertex []byte) (StatelessVertex, error) { vtx := innerStatelessVertex{} - version, err := Codec.Unmarshal(vertex, &vtx) + version, err := c.Unmarshal(vertex, &vtx) vtx.Version = version return statelessVertex{ innerStatelessVertex: vtx, From bcbdb33938ccd1291fa3e851d607eec0b8acae6d Mon Sep 17 00:00:00 2001 From: Aaron Buchwald Date: Thu, 25 Mar 2021 14:26:32 -0400 Subject: [PATCH 05/13] Add docker ignore file --- .dockerignore | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000000..3e23d7e4be83 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +.ci +.git +.github +.gitignore +.golangci.yml +.idea +.vscode + +LICENSE +*.md From 9b11f4ac85101639eddda993c63f6cd24e9cd846 Mon Sep 17 00:00:00 2001 From: Aaron Buchwald Date: Thu, 25 Mar 2021 14:35:22 -0400 Subject: [PATCH 06/13] Fix up so docker images built by script keep last commit hash --- Dockerfile | 4 ++++ scripts/build_avalanche.sh | 2 +- scripts/build_local_image.sh | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2caa08a205bb..43f361f2fbb8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,17 @@ # syntax=docker/dockerfile:experimental +ARG AVALANCHEGO_COMMIT FROM golang:1.15.5-buster +ARG AVALANCHEGO_COMMIT + RUN mkdir -p /go/src/github.com/ava-labs WORKDIR $GOPATH/src/github.com/ava-labs/ COPY . avalanchego WORKDIR $GOPATH/src/github.com/ava-labs/avalanchego +RUN export AVALANCHEGO_COMMIT=$AVALANCHEGO_COMMIT RUN ./scripts/build.sh RUN ln -sv $GOPATH/src/github.com/ava-labs/avalanchego/ /avalanchego diff --git a/scripts/build_avalanche.sh b/scripts/build_avalanche.sh index 3a2dad5b76cc..78c14c63ac67 100755 --- a/scripts/build_avalanche.sh +++ b/scripts/build_avalanche.sh @@ -10,7 +10,7 @@ GOPATH="$(go env GOPATH)" AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) # Directory above this script BUILD_DIR=$AVALANCHE_PATH/build # Where binaries go -GIT_COMMIT=$( git rev-list -1 HEAD ) +GIT_COMMIT=${AVALANCHEGO_COMMIT:-$( git rev-list -1 HEAD )} # Build aVALANCHE echo "Building Avalanche..." diff --git a/scripts/build_local_image.sh b/scripts/build_local_image.sh index b808e5be6f1a..5189e7e64583 100755 --- a/scripts/build_local_image.sh +++ b/scripts/build_local_image.sh @@ -14,4 +14,4 @@ FULL_COMMIT_HASH="$(git --git-dir="$AVALANCHE_PATH/.git" rev-parse HEAD)" COMMIT_HASH="${FULL_COMMIT_HASH::8}" echo "Building Docker Image: $DOCKERHUB_REPO:$COMMIT_HASH" -docker build -t "$DOCKERHUB_REPO:$COMMIT_HASH" "$AVALANCHE_PATH" -f "$AVALANCHE_PATH/Dockerfile" +docker build -t "$DOCKERHUB_REPO:$COMMIT_HASH" "$AVALANCHE_PATH" -f "$AVALANCHE_PATH/Dockerfile" --build-arg AVALANCHEGO_COMMIT="$FULL_COMMIT_HASH" From 32e5f59720cae591c8798abb2d09cf5b65dfbdd7 Mon Sep 17 00:00:00 2001 From: Aaron Buchwald Date: Thu, 25 Mar 2021 19:06:16 -0400 Subject: [PATCH 07/13] Bump e2e test image to v0.11.0-rc.2 --- .ci/run_e2e_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/run_e2e_tests.sh b/.ci/run_e2e_tests.sh index cc4042d77b5b..c0b2106abe36 100755 --- a/.ci/run_e2e_tests.sh +++ b/.ci/run_e2e_tests.sh @@ -18,7 +18,7 @@ echo "Using Avalanche Image: $AVALANCHE_IMAGE" DOCKER_REPO="avaplatform" BYZANTINE_IMAGE="$DOCKER_REPO/avalanche-byzantine:v0.2.0-rc.1" -TEST_SUITE_IMAGE="$DOCKER_REPO/avalanche-testing:v0.11.0-rc.1" +TEST_SUITE_IMAGE="$DOCKER_REPO/avalanche-testing:v0.11.0-rc.2" # Kurtosis Environment Parameters KURTOSIS_CORE_CHANNEL="1.0.3" From 104fa20a6e88650585f1999f77475c12901608cf Mon Sep 17 00:00:00 2001 From: Dan Laine Date: Thu, 25 Mar 2021 22:13:50 -0400 Subject: [PATCH 08/13] fix tests --- .../snowman/bootstrap/bootstrapper_test.go | 59 +++++++++++++++++-- 1 file changed, 55 insertions(+), 4 deletions(-) diff --git a/snow/engine/snowman/bootstrap/bootstrapper_test.go b/snow/engine/snowman/bootstrap/bootstrapper_test.go index fb8692e44945..3686c8e251bc 100644 --- a/snow/engine/snowman/bootstrap/bootstrapper_test.go +++ b/snow/engine/snowman/bootstrap/bootstrapper_test.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/prometheus/client_golang/prometheus" + "gotest.tools/assert" "github.com/ava-labs/avalanchego/database/memdb" "github.com/ava-labs/avalanchego/ids" @@ -102,6 +103,13 @@ func TestBootstrapperSingleFrontier(t *testing.T) { BytesV: blkBytes1, } + vm.CantLastAccepted = false + vm.LastAcceptedF = func() (ids.ID, error) { return blk0.ID(), nil } + vm.GetBlockF = func(blkID ids.ID) (snowman.Block, error) { + assert.Equal(t, blk0.ID(), blkID) + return blk0, nil + } + finished := new(bool) bs := Bootstrapper{} err := bs.Initialize( @@ -194,6 +202,13 @@ func TestBootstrapperUnknownByzantineResponse(t *testing.T) { BytesV: blkBytes2, } + vm.CantLastAccepted = false + vm.LastAcceptedF = func() (ids.ID, error) { return blk0.ID(), nil } + vm.GetBlockF = func(blkID ids.ID) (snowman.Block, error) { + assert.Equal(t, blk0.ID(), blkID) + return blk0, nil + } + finished := new(bool) bs := Bootstrapper{} err := bs.Initialize( @@ -344,6 +359,13 @@ func TestBootstrapperPartialFetch(t *testing.T) { BytesV: blkBytes3, } + vm.CantLastAccepted = false + vm.LastAcceptedF = func() (ids.ID, error) { return blk0.ID(), nil } + vm.GetBlockF = func(blkID ids.ID) (snowman.Block, error) { + assert.Equal(t, blk0.ID(), blkID) + return blk0, nil + } + finished := new(bool) bs := Bootstrapper{} err := bs.Initialize( @@ -498,7 +520,12 @@ func TestBootstrapperMultiPut(t *testing.T) { } vm.CantBootstrapping = false - + vm.CantLastAccepted = false + vm.LastAcceptedF = func() (ids.ID, error) { return blk0.ID(), nil } + vm.GetBlockF = func(blkID ids.ID) (snowman.Block, error) { + assert.Equal(t, blk0.ID(), blkID) + return blk0, nil + } finished := new(bool) bs := Bootstrapper{} err := bs.Initialize( @@ -599,6 +626,20 @@ func TestBootstrapperAcceptedFrontier(t *testing.T) { blkID := ids.GenerateTestID() + dummyBlk := &snowman.TestBlock{ + TestDecidable: choices.TestDecidable{ + IDV: blkID, + StatusV: choices.Accepted, + }, + HeightV: 0, + BytesV: []byte{1, 2, 3}, + } + vm.CantLastAccepted = false + vm.LastAcceptedF = func() (ids.ID, error) { return blkID, nil } + vm.GetBlockF = func(bID ids.ID) (snowman.Block, error) { + assert.Equal(t, blkID, bID) + return dummyBlk, nil + } bs := Bootstrapper{} err := bs.Initialize( config, @@ -610,8 +651,6 @@ func TestBootstrapperAcceptedFrontier(t *testing.T) { t.Fatal(err) } - vm.LastAcceptedF = func() (ids.ID, error) { return blkID, nil } - accepted, err := bs.CurrentAcceptedFrontier() if err != nil { t.Fatal(err) @@ -641,6 +680,13 @@ func TestBootstrapperFilterAccepted(t *testing.T) { StatusV: choices.Accepted, }} + vm.CantLastAccepted = false + vm.LastAcceptedF = func() (ids.ID, error) { return blk1.ID(), nil } + vm.GetBlockF = func(blkID ids.ID) (snowman.Block, error) { + assert.Equal(t, blk1.ID(), blkID) + return blk1, nil + } + bs := Bootstrapper{} err := bs.Initialize( config, @@ -653,7 +699,6 @@ func TestBootstrapperFilterAccepted(t *testing.T) { } blkIDs := []ids.ID{blkID0, blkID1, blkID2} - vm.GetBlockF = func(blkID ids.ID) (snowman.Block, error) { switch blkID { case blkID0: @@ -726,6 +771,12 @@ func TestBootstrapperFinalized(t *testing.T) { finished := new(bool) bs := Bootstrapper{} + vm.CantLastAccepted = false + vm.LastAcceptedF = func() (ids.ID, error) { return blk0.ID(), nil } + vm.GetBlockF = func(blkID ids.ID) (snowman.Block, error) { + assert.Equal(t, blk0.ID(), blkID) + return blk0, nil + } err := bs.Initialize( config, func() error { *finished = true; return nil }, From 96685f46f67b7db2069f5fbc83f317bc1428f114 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Tue, 30 Mar 2021 21:01:34 +0100 Subject: [PATCH 09/13] Key funded in the P chain --- genesis/genesis_local.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/genesis/genesis_local.go b/genesis/genesis_local.go index 0e56da46698c..ce029197a5ee 100644 --- a/genesis/genesis_local.go +++ b/genesis/genesis_local.go @@ -9,7 +9,7 @@ import ( "github.com/ava-labs/avalanchego/utils/units" ) -// PrivateKey-vmRQiZeXEXYMyJhEiqdC2z5JhuDbxL8ix9UVvjgMu2Er1NepE => X-local1g65uqn6t77p656w64023nh8nd9updzmxyymev2 +// PrivateKey-vmRQiZeXEXYMyJhEiqdC2z5JhuDbxL8ix9UVvjgMu2Er1NepE => P-local1g65uqn6t77p656w64023nh8nd9updzmxyymev2 // PrivateKey-ewoqjP7PxY4yr3iLTpLisriqt94hdyDFNgchSxGGztUrTXtNN => X-local18jma8ppw3nhx5r4ap8clazz0dps7rv5u00z96u var ( From 189aa846918dca08aab860ebc6370db7857b88b1 Mon Sep 17 00:00:00 2001 From: Dan Laine Date: Tue, 6 Apr 2021 17:56:38 -0400 Subject: [PATCH 10/13] address PR 367 comments --- snow/engine/snowman/bootstrap/bootstrapper.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/snow/engine/snowman/bootstrap/bootstrapper.go b/snow/engine/snowman/bootstrap/bootstrapper.go index 5b7391b92ed0..958112a34a05 100644 --- a/snow/engine/snowman/bootstrap/bootstrapper.go +++ b/snow/engine/snowman/bootstrap/bootstrapper.go @@ -18,12 +18,11 @@ import ( "github.com/ava-labs/avalanchego/snow/engine/snowman/block" "github.com/ava-labs/avalanchego/snow/validators" "github.com/ava-labs/avalanchego/utils/formatting" - safemath "github.com/ava-labs/avalanchego/utils/math" ) const ( // Parameters for delaying bootstrapping to avoid potential CPU burns - initialBootstrappingDelay = 2 * time.Second + initialBootstrappingDelay = 500 * time.Millisecond maxBootstrappingDelay = time.Minute ) @@ -249,9 +248,9 @@ func (b *Bootstrapper) process(blk snowman.Block) error { b.NumFetched++ // Progress tracker if b.NumFetched%common.StatusUpdateFrequency == 0 { // Periodically print progress if !b.Restarted { - b.Ctx.Log.Info("fetched %d of %d blocks", b.NumFetched, safemath.Max64(0, b.tipHeight-b.startingHeight)) + b.Ctx.Log.Info("fetched %d of %d blocks", b.NumFetched, b.tipHeight-b.startingHeight) } else { - b.Ctx.Log.Debug("fetched %d of %d blocks", b.NumFetched, safemath.Max64(0, b.tipHeight-b.startingHeight)) + b.Ctx.Log.Debug("fetched %d of %d blocks", b.NumFetched, b.tipHeight-b.startingHeight) } } } @@ -367,9 +366,9 @@ func (b *Bootstrapper) executeAll(jobs *queue.Jobs) (int, error) { numExecuted++ if numExecuted%common.StatusUpdateFrequency == 0 { // Periodically print progress if !b.Restarted { - b.Ctx.Log.Info("executed %d of %d blocks", numExecuted, safemath.Max64(0, b.tipHeight-b.startingHeight)) + b.Ctx.Log.Info("executed %d of %d blocks", numExecuted, b.tipHeight-b.startingHeight) } else { - b.Ctx.Log.Debug("executed %d of %d blocks", numExecuted, safemath.Max64(0, b.tipHeight-b.startingHeight)) + b.Ctx.Log.Debug("executed %d of %d blocks", numExecuted, b.tipHeight-b.startingHeight) } } From bdcb21ebfd4c8ed8ff0528b8e819832c34ac091e Mon Sep 17 00:00:00 2001 From: StephenButtolph Date: Tue, 6 Apr 2021 21:02:31 -0400 Subject: [PATCH 11/13] Added proper error reporting after iterator releasing in the rpcdb --- database/rpcdb/db_client.go | 8 ++- database/rpcdb/db_server.go | 11 ++-- database/rpcdb/rpcdbproto/rpcdb.pb.go | 94 +++++++++++++++------------ database/rpcdb/rpcdbproto/rpcdb.proto | 4 +- database/test_database.go | 71 ++++++++++++++++++++ 5 files changed, 138 insertions(+), 50 deletions(-) diff --git a/database/rpcdb/db_client.go b/database/rpcdb/db_client.go index f2a38e0f852a..b33c8cd1755b 100644 --- a/database/rpcdb/db_client.go +++ b/database/rpcdb/db_client.go @@ -261,8 +261,12 @@ func (it *iterator) Value() []byte { return it.value } // Release frees any resources held by the iterator func (it *iterator) Release() { - _, err := it.db.client.IteratorRelease(context.Background(), &rpcdbproto.IteratorReleaseRequest{ + resp, err := it.db.client.IteratorRelease(context.Background(), &rpcdbproto.IteratorReleaseRequest{ Id: it.id, }) - it.errs.Add(err) + if err != nil { + it.errs.Add(err) + } else { + it.errs.Add(errCodeToError[resp.Err]) + } } diff --git a/database/rpcdb/db_server.go b/database/rpcdb/db_server.go index 4a30eea5a7d6..2cbea8bd5670 100644 --- a/database/rpcdb/db_server.go +++ b/database/rpcdb/db_server.go @@ -162,9 +162,12 @@ func (db *DatabaseServer) IteratorRelease(_ context.Context, req *rpcdbproto.Ite defer db.lock.Unlock() it, exists := db.iterators[req.Id] - if exists { - delete(db.iterators, req.Id) - it.Release() + if !exists { + return &rpcdbproto.IteratorReleaseResponse{Err: 0}, nil } - return &rpcdbproto.IteratorReleaseResponse{}, nil + + delete(db.iterators, req.Id) + err := it.Error() + it.Release() + return &rpcdbproto.IteratorReleaseResponse{Err: errorToErrCode[err]}, errorToRPCError(err) } diff --git a/database/rpcdb/rpcdbproto/rpcdb.pb.go b/database/rpcdb/rpcdbproto/rpcdb.pb.go index 785765bd7694..73ff7b7f05a7 100644 --- a/database/rpcdb/rpcdbproto/rpcdb.pb.go +++ b/database/rpcdb/rpcdbproto/rpcdb.pb.go @@ -1017,6 +1017,7 @@ func (m *IteratorReleaseRequest) GetId() uint64 { } type IteratorReleaseResponse struct { + Err uint32 `protobuf:"varint,1,opt,name=err,proto3" json:"err,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -1047,6 +1048,13 @@ func (m *IteratorReleaseResponse) XXX_DiscardUnknown() { var xxx_messageInfo_IteratorReleaseResponse proto.InternalMessageInfo +func (m *IteratorReleaseResponse) GetErr() uint32 { + if m != nil { + return m.Err + } + return 0 +} + func init() { proto.RegisterType((*HasRequest)(nil), "rpcdbproto.HasRequest") proto.RegisterType((*HasResponse)(nil), "rpcdbproto.HasResponse") @@ -1079,49 +1087,49 @@ func init() { proto.RegisterFile("rpcdb.proto", fileDescriptor_af52f4b90339c3f4) var fileDescriptor_af52f4b90339c3f4 = []byte{ // 677 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xdd, 0x4f, 0x13, 0x4f, - 0x14, 0x4d, 0x3f, 0xf8, 0x3a, 0x2d, 0xe5, 0xf7, 0x1b, 0x2b, 0x94, 0x55, 0xbe, 0x16, 0x21, 0xc5, - 0x07, 0x22, 0x1f, 0x62, 0x4c, 0x48, 0x8c, 0x80, 0x01, 0x63, 0x42, 0x70, 0x21, 0x21, 0x31, 0xbe, - 0x0c, 0x74, 0x08, 0x1b, 0x0b, 0xbb, 0xce, 0x4e, 0x15, 0xdf, 0x7d, 0xf1, 0xbf, 0x36, 0x33, 0x9d, - 0xdd, 0x99, 0x69, 0x77, 0xab, 0xbe, 0xcd, 0x9d, 0x7b, 0xce, 0x99, 0xbb, 0x77, 0xef, 0xb9, 0xa8, - 0xf1, 0xf8, 0xba, 0x73, 0xb5, 0x19, 0xf3, 0x48, 0x44, 0x04, 0x2a, 0x50, 0x67, 0x7f, 0x11, 0x38, - 0xa1, 0x49, 0xc0, 0xbe, 0xf6, 0x58, 0x22, 0xc8, 0x7f, 0xa8, 0x7c, 0x61, 0x3f, 0x5a, 0xa5, 0xe5, - 0x52, 0xbb, 0x1e, 0xc8, 0xa3, 0xbf, 0x85, 0x9a, 0xca, 0x27, 0x71, 0x74, 0x9f, 0x30, 0x09, 0xb8, - 0xa5, 0x89, 0x02, 0x4c, 0x06, 0xf2, 0x28, 0x6f, 0x18, 0x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02, 0xff, 0x94, 0x94, 0xed, 0x4f, 0xd4, 0x40, + 0x10, 0xc6, 0x73, 0x2f, 0xbc, 0x3d, 0x77, 0x1c, 0xba, 0x9e, 0x70, 0x54, 0x79, 0x2b, 0x42, 0x0e, + 0x4d, 0x88, 0xbc, 0x88, 0x31, 0x21, 0x31, 0x02, 0x06, 0x8c, 0x09, 0xc1, 0x42, 0x42, 0x62, 0xfc, + 0xb2, 0x70, 0x4b, 0x68, 0x3c, 0xae, 0x75, 0xbb, 0xa7, 0xf8, 0xdd, 0x2f, 0xfe, 0xd7, 0x66, 0xf7, + 0xb6, 0xed, 0xf6, 0xda, 0x3d, 0xf5, 0xdb, 0xce, 0xce, 0x33, 0xbf, 0x9d, 0x4e, 0x67, 0x06, 0x35, + 0x1e, 0x5e, 0x77, 0xae, 0x36, 0x43, 0x1e, 0x88, 0x80, 0x40, 0x19, 0xea, 0xec, 0x2e, 0x02, 0x27, + 0x34, 0xf2, 0xd8, 0xb7, 0x3e, 0x8b, 0x04, 0x79, 0x80, 0xca, 0x57, 0xf6, 0xb3, 0x55, 0x5a, 0x2e, + 0xb5, 0xeb, 0x9e, 0x3c, 0xba, 0x5b, 0xa8, 0x29, 0x7f, 0x14, 0x06, 0xbd, 0x88, 0x49, 0xc1, 0x2d, + 0x8d, 0x94, 0x60, 0xd2, 0x93, 0x47, 0x79, 0xc3, 0x38, 0x6f, 0x95, 0x97, 0x4b, 0xed, 0x69, 0x4f, + 0x1e, 0x25, 0xf2, 0x98, 0x09, 0x3b, 0xf2, 0x15, 0x6a, 0xca, 0xaf, 0x91, 0x4d, 0x8c, 0x7d, 0xa7, + 0xdd, 0x3e, 0xd3, 0x92, 0x81, 0x51, 0x80, 0xdd, 0x05, 0xce, 0xfa, 0x76, 0x6c, 0xca, 0x29, 0x1b, + 0x1c, 0x77, 0x09, 0x35, 0x15, 0x95, 0xe6, 0x2f, 0xb1, 0xa5, 0x14, 0xbb, 0x82, 0xe9, 0x23, 0xd6, + 0x65, 0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xf3, + 0xa4, 0xd0, 0xa7, 0x19, 0xfb, 0x18, 0x53, 0x9b, 0x80, 0x64, 0x9e, 0x31, 0x97, 0x85, 0x33, 0x5f, + 0xe0, 0xd1, 0xd1, 0x1f, 0x81, 0x74, 0x5c, 0xc9, 0x82, 0x29, 0xcc, 0x2d, 0x0f, 0x67, 0xd1, 0xe6, + 0xd6, 0xb0, 0x5f, 0x25, 0x2c, 0x8c, 0x1c, 0x34, 0xf2, 0xd2, 0x24, 0xfc, 0xcb, 0xa4, 0x3b, 0x5b, + 0xff, 0x11, 0xa1, 0xd3, 0xf8, 0x84, 0xba, 0x39, 0x8e, 0x64, 0xc9, 0x44, 0x14, 0xcc, 0xb3, 0xb3, + 0x6c, 0x17, 0x68, 0xe4, 0x05, 0xa6, 0x33, 0xb3, 0x45, 0x0a, 0x43, 0xcc, 0xf1, 0x74, 0x56, 0x46, + 0x28, 0x34, 0xf5, 0x33, 0x66, 0x86, 0x86, 0x8b, 0xb8, 0x45, 0x51, 0xd9, 0x19, 0x75, 0x56, 0x47, + 0x6a, 0x06, 0xec, 0xab, 0x71, 0xe5, 0xde, 0xf9, 0x13, 0x00, 0x00, 0xff, 0xff, 0xc1, 0x4c, 0xf4, + 0x67, 0x5e, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/database/rpcdb/rpcdbproto/rpcdb.proto b/database/rpcdb/rpcdbproto/rpcdb.proto index 656b0abdaa29..0a4fd499f852 100644 --- a/database/rpcdb/rpcdbproto/rpcdb.proto +++ b/database/rpcdb/rpcdbproto/rpcdb.proto @@ -102,7 +102,9 @@ message IteratorReleaseRequest { uint64 id = 1; } -message IteratorReleaseResponse {} +message IteratorReleaseResponse { + uint32 err = 1; +} service Database { rpc Has(HasRequest) returns (HasResponse); diff --git a/database/test_database.go b/database/test_database.go index ba953481b634..daf00e44f162 100644 --- a/database/test_database.go +++ b/database/test_database.go @@ -26,6 +26,8 @@ var ( TestIteratorStartPrefix, TestIteratorMemorySafety, TestIteratorClosed, + TestIteratorError, + TestIteratorErrorAfterRelease, TestStatNoPanic, TestCompactNoPanic, TestMemorySafetyDatabase, @@ -805,6 +807,75 @@ func TestIteratorClosed(t *testing.T, db Database) { } } +// TestIteratorError tests to make sure that an iterator still works after the +// database is closed. +func TestIteratorError(t *testing.T, db Database) { + key := []byte("hello1") + value := []byte("world1") + + if err := db.Put(key, value); err != nil { + t.Fatalf("Unexpected error on batch.Put: %s", err) + } + + iterator := db.NewIterator() + if iterator == nil { + t.Fatalf("db.NewIterator returned nil") + } + defer iterator.Release() + + if err := db.Close(); err != nil { + t.Fatalf("Unexpected error on db.Close: %s", err) + } + + if !iterator.Next() { + t.Fatalf("iterator.Next Returned: %v ; Expected: %v", false, true) + } + if itKey := iterator.Key(); !bytes.Equal(itKey, key) { + t.Fatalf("iterator.Key Returned: 0x%x ; Expected: 0x%x", itKey, key) + } + if itValue := iterator.Value(); !bytes.Equal(itValue, value) { + t.Fatalf("iterator.Value Returned: 0x%x ; Expected: 0x%x", itValue, value) + } + if err := iterator.Error(); err != nil { + t.Fatalf("Expected no error on iterator.Error but got %s", err) + } +} + +// TestIteratorErrorAfterRelease tests to make sure that an iterator that was +// released still reports the error correctly. +func TestIteratorErrorAfterRelease(t *testing.T, db Database) { + key := []byte("hello1") + value := []byte("world1") + + if err := db.Put(key, value); err != nil { + t.Fatalf("Unexpected error on batch.Put: %s", err) + } + + if err := db.Close(); err != nil { + t.Fatalf("Unexpected error on db.Close: %s", err) + } + + iterator := db.NewIterator() + if iterator == nil { + t.Fatalf("db.NewIterator returned nil") + } + + iterator.Release() + + if iterator.Next() { + t.Fatalf("iterator.Next Returned: %v ; Expected: %v", false, true) + } + if key := iterator.Key(); key != nil { + t.Fatalf("iterator.Key Returned: 0x%x ; Expected: nil", key) + } + if value := iterator.Value(); value != nil { + t.Fatalf("iterator.Value Returned: 0x%x ; Expected: nil", value) + } + if err := iterator.Error(); err != ErrClosed { + t.Fatalf("Expected %s on iterator.Error", ErrClosed) + } +} + // TestStatNoPanic tests to make sure that Stat never panics. func TestStatNoPanic(t *testing.T, db Database) { key1 := []byte("hello1") From f97a8fc5172e3b4c0756689ecfba638a6a0e6ccb Mon Sep 17 00:00:00 2001 From: StephenButtolph Date: Tue, 6 Apr 2021 21:15:04 -0400 Subject: [PATCH 12/13] allow credentials --- api/server.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/server.go b/api/server.go index 7dccf9c2730c..7c1192157381 100644 --- a/api/server.go +++ b/api/server.go @@ -76,7 +76,8 @@ func (s *Server) Initialize( s.log.Info("API created with allowed origins: %v", allowedOrigins) corsWrapper := cors.New(cors.Options{ - AllowedOrigins: allowedOrigins, + AllowedOrigins: allowedOrigins, + AllowCredentials: true, }) corsHandler := corsWrapper.Handler(s.router) s.handler = s.auth.WrapHandler(corsHandler) From c956269f1f5aeac58fd4024e02750a3873013fef Mon Sep 17 00:00:00 2001 From: StephenButtolph Date: Wed, 7 Apr 2021 14:29:31 -0400 Subject: [PATCH 13/13] bump coreth version --- scripts/build_coreth.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build_coreth.sh b/scripts/build_coreth.sh index ff87139b3d09..d9fd6b2d4ed5 100755 --- a/scripts/build_coreth.sh +++ b/scripts/build_coreth.sh @@ -13,7 +13,7 @@ BUILD_DIR="$AVALANCHE_PATH/build" # Where binaries go PLUGIN_DIR="$BUILD_DIR/plugins" # Where plugin binaries (namely coreth) go BINARY_PATH="$PLUGIN_DIR/evm" -CORETH_VER="v0.4.1-rc.1" +CORETH_VER="v0.4.2-rc.3" CORETH_PATH="$GOPATH/pkg/mod/github.com/ava-labs/coreth@$CORETH_VER"