From 9b81f5145e6a9e64cda034730212ae3ece6e2793 Mon Sep 17 00:00:00 2001 From: Ori Newman Date: Thu, 11 Nov 2021 09:27:07 +0200 Subject: [PATCH] Increase p2p msg size and reset utxo after ibd (#1847) * Don't build unnecessary binaries * Reset UTXO index after IBD * Enlarge max msg size to 1gb * Fix UTXO chunks logic * Revert UTXO set override change * Fix sendPruningPointUTXOSet * Increase tests timeout to 20 minutes Co-authored-by: Kaspa Profiler <> --- .github/workflows/deploy.yaml | 8 ++++---- .../handle_request_pruning_point_utxo_set.go | 14 ++++++++++++-- build_and_test.sh | 4 ++-- .../netadapter/server/grpcserver/p2pserver.go | 2 +- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 4e584fa1c..ac00972bf 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -1,7 +1,7 @@ name: Build and upload assets on: release: - types: [published] + types: [ published ] jobs: build: @@ -36,7 +36,7 @@ jobs: # `-tags netgo,osusergo` means use pure go replacements for "os/user" and "net" # `-s -w` strips the binary to produce smaller size binaries run: | - go build -v -ldflags="-s -w -extldflags=-static" -tags netgo,osusergo -o ./bin/ ./... + go build -v -ldflags="-s -w -extldflags=-static" -tags netgo,osusergo -o ./bin/ . ./cmd/... archive="bin/kaspad-${{ github.event.release.tag_name }}-linux.zip" asset_name="kaspad-${{ github.event.release.tag_name }}-linux.zip" zip -r "${archive}" ./bin/* @@ -47,7 +47,7 @@ jobs: if: runner.os == 'Windows' shell: bash run: | - go build -v -ldflags="-s -w" -o bin/ ./... + go build -v -ldflags="-s -w" -o bin/ . ./cmd/... archive="bin/kaspad-${{ github.event.release.tag_name }}-win64.zip" asset_name="kaspad-${{ github.event.release.tag_name }}-win64.zip" powershell "Compress-Archive bin/* \"${archive}\"" @@ -57,7 +57,7 @@ jobs: - name: Build on MacOS if: runner.os == 'macOS' run: | - go build -v -ldflags="-s -w" -o ./bin/ ./... + go build -v -ldflags="-s -w" -o ./bin/ . ./cmd/... archive="bin/kaspad-${{ github.event.release.tag_name }}-osx.zip" asset_name="kaspad-${{ github.event.release.tag_name }}-osx.zip" zip -r "${archive}" ./bin/* diff --git a/app/protocol/flows/blockrelay/handle_request_pruning_point_utxo_set.go b/app/protocol/flows/blockrelay/handle_request_pruning_point_utxo_set.go index 3f310959a..8bfca3895 100644 --- a/app/protocol/flows/blockrelay/handle_request_pruning_point_utxo_set.go +++ b/app/protocol/flows/blockrelay/handle_request_pruning_point_utxo_set.go @@ -102,14 +102,17 @@ func (flow *handleRequestPruningPointUTXOSetFlow) sendPruningPointUTXOSet( return err } - if len(pruningPointUTXOs) < step && chunksSent%ibdBatchSize == 0 { + finished := len(pruningPointUTXOs) < step + if finished && chunksSent%ibdBatchSize != 0 { log.Debugf("Finished sending UTXOs for pruning block %s", msgRequestPruningPointUTXOSet.PruningPointHash) return flow.outgoingRoute.Enqueue(appmessage.NewMsgDonePruningPointUTXOSetChunks()) } - fromOutpoint = pruningPointUTXOs[len(pruningPointUTXOs)-1].Outpoint + if len(pruningPointUTXOs) > 0 { + fromOutpoint = pruningPointUTXOs[len(pruningPointUTXOs)-1].Outpoint + } chunksSent++ // Wait for the peer to request more chunks every `ibdBatchSize` chunks @@ -123,6 +126,13 @@ func (flow *handleRequestPruningPointUTXOSetFlow) sendPruningPointUTXOSet( return protocolerrors.Errorf(true, "received unexpected message type. "+ "expected: %s, got: %s", appmessage.CmdRequestNextPruningPointUTXOSetChunk, message.Command()) } + + if finished { + log.Debugf("Finished sending UTXOs for pruning block %s", + msgRequestPruningPointUTXOSet.PruningPointHash) + + return flow.outgoingRoute.Enqueue(appmessage.NewMsgDonePruningPointUTXOSetChunks()) + } } } } diff --git a/build_and_test.sh b/build_and_test.sh index 5153fd6eb..30f70b0b7 100755 --- a/build_and_test.sh +++ b/build_and_test.sh @@ -21,7 +21,7 @@ go build $FLAGS -o kaspad . if [ -n "${NO_PARALLEL}" ] then - go test -parallel=1 $FLAGS ./... + go test -timeout 20m -parallel=1 $FLAGS ./... else - go test $FLAGS ./... + go test -timeout 20m $FLAGS ./... fi \ No newline at end of file diff --git a/infrastructure/network/netadapter/server/grpcserver/p2pserver.go b/infrastructure/network/netadapter/server/grpcserver/p2pserver.go index c180bd116..d57863745 100644 --- a/infrastructure/network/netadapter/server/grpcserver/p2pserver.go +++ b/infrastructure/network/netadapter/server/grpcserver/p2pserver.go @@ -18,7 +18,7 @@ type p2pServer struct { gRPCServer } -const p2pMaxMessageSize = 100 * 1024 * 1024 // 100MB +const p2pMaxMessageSize = 1024 * 1024 * 1024 // 1GB // p2pMaxInboundConnections is the max amount of inbound connections for the P2P server. // Note that inbound connections are not limited by the gRPC server. (A value of 0 means