Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build: Golang 1.20 upgrade. #5462

Merged
merged 14 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version: 2.1

orbs:
win: circleci/windows@2.3.0
go: circleci/go@1.7.0
go: circleci/go@1.7.3
slack: circleci/slack@4.10.1

parameters:
Expand Down Expand Up @@ -461,7 +461,7 @@ commands:
shell: bash.exe
command: |
choco install -y msys2 pacman make wget --force
choco install -y golang --version=1.17.13 --force
choco install -y golang --version=1.20.5 --force
choco install -y python3 --version=3.7.3 --force
export msys2='cmd //C RefreshEnv.cmd '
export msys2+='& set MSYS=winsymlinks:nativestrict '
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
name: Performance regression check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/checkout@v3.5.3
- uses: actions/setup-go@v4.0.1
with:
go-version-file: 'go.mod'
- run: go version
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ jobs:
update: true
path-type: inherit
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v3.5.3
with:
fetch-depth: 0
- name: Determine Go version
id: go_version
run: echo "GO_VERSION=$(./scripts/get_golang_version.sh)" >> $GITHUB_ENV
- name: Install golang
uses: actions/setup-go@v3
uses: actions/setup-go@v4.0.1
with:
go-version: ${{ env.GO_VERSION }}
- name: Restore libsodium from cache
id: cache-libsodium
uses: actions/cache@v3
uses: actions/cache@v3.3.1
with:
path: crypto/libs
key: libsodium-fork-v2-${{ runner.os }}-${{ hashFiles('crypto/libsodium-fork/**') }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codegen_verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v3.5.3
with:
fetch-depth: 0
path: go-algorand
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v3.5.3

- name: Generate Container Metadata
id: meta
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
# if: github.ref == format('refs/heads/{0}', 'master')
# steps:
# - name: Checkout Code
# uses: actions/checkout@v3
# uses: actions/checkout@v3.5.3

# - name: Update DockerHub Repository Description
# uses: peter-evans/dockerhub-description@v3
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
uses: actions/checkout@v3.5.3
with:
fetch-depth: 0 # required for new-from-rev option in .golangci.yml
# move go out of the way temporarily to avoid "go list ./..." from installing modules
- name: Make libsodium.a
run: sudo mv /usr/bin/go /usr/bin/go.bak && make crypto/libs/linux/amd64/lib/libsodium.a && sudo mv /usr/bin/go.bak /usr/bin/go
- name: reviewdog-golangci-lint
uses: reviewdog/action-golangci-lint@v2
uses: reviewdog/action-golangci-lint@v2.3.1
with:
go_version_file: go.mod
golangci_lint_version: "v1.47.3"
golangci_lint_version: "v1.53.2"
golangci_lint_flags: "-c .golangci.yml --allow-parallel-runners"
reporter: "github-pr-check"
tool_name: "Lint Errors"
Expand All @@ -32,7 +32,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
uses: actions/checkout@v3.5.3
with:
fetch-depth: 0 # required for new-from-rev option in .golangci.yml
# move go out of the way temporarily to avoid "go list ./..." from installing modules
Expand All @@ -46,24 +46,24 @@ jobs:
id: go_version
run: echo "GO_VERSION=$(./scripts/get_golang_version.sh)" >> $GITHUB_ENV
- name: Install specific golang
uses: actions/setup-go@v3
uses: actions/setup-go@v4.0.1
with:
go-version: ${{ env.GO_VERSION }}
- name: Create folders for golangci-lint
run: mkdir -p cicdtmp/golangci-lint
- name: Check if custom golangci-lint is already built
id: cache-golangci-lint
uses: actions/cache@v3
uses: actions/cache@v3.3.1
with:
path: cicdtmp/golangci-lint/golangci-lint-cgo
key: cicd-golangci-lint-cgo-v0.0.1
key: cicd-golangci-lint-cgo-v0.0.2

- name: Build custom golangci-lint with CGO_ENABLED
if: steps.cache-golangci-lint.outputs.cache-hit != 'true'
run: |
cd cicdtmp/golangci-lint
git clone https://github.com/golangci/golangci-lint.git .
git checkout tags/v1.47.3
git checkout tags/v1.53.2
CGO_ENABLED=true go build -trimpath -o golangci-lint-cgo ./cmd/golangci-lint
./golangci-lint-cgo --version
cd ../../
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
uses: actions/checkout@v3.5.3
# move go out of the way temporarily to avoid "go list ./..." from installing modules
- name: Make libsodium.a
run: sudo mv /usr/bin/go /usr/bin/go.bak && make crypto/libs/linux/amd64/lib/libsodium.a && sudo mv /usr/bin/go.bak /usr/bin/go
Expand All @@ -31,7 +31,7 @@ jobs:
id: go_version
run: echo "GO_VERSION=$(./scripts/get_golang_version.sh)" >> $GITHUB_ENV
- name: Install go version
uses: actions/setup-go@v3
uses: actions/setup-go@v4.0.1
with:
go-version: ${{ env.GO_VERSION }}
- name: Test tools/block-generator
Expand Down
3 changes: 0 additions & 3 deletions .golangci-warnings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ run:
linters:
disable-all: true
enable:
- deadcode
- gosec
- partitiontest
- structcheck
- varcheck
cce marked this conversation as resolved.
Show resolved Hide resolved
- unused

linters-settings:
Expand Down
13 changes: 12 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,15 @@ issues:
# "EXC0005 staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore"
- ineffective break statement. Did you mean to break out of the outer loop
# revive: irrelevant error about naming
- "var-naming: don't use leading k in Go names"
- "^var-naming: don't use leading k in Go names"
# revive: ignore unused-paramter, package-comments, unexported-return, redefines-builtin-id, var-declaration, empty-block, superfluous-else
- "^unused-parameter: parameter"
- "^package-comments: should have a package comment"
- "^unexported-return: "
- "^redefines-builtin-id: redefinition of"
- "^var-declaration: should"
- "^empty-block: this block is empty, you can remove it"
- "^superfluous-else: if block ends with"

exclude-rules:
- path: _test\.go
Expand All @@ -121,6 +129,9 @@ issues:
linters:
- staticcheck
text: "SA4006: this value" # of X is never used
- linters:
- staticcheck
text: "SA1019: rand*"
# allow shadowing in test code
- path: _test\.go
linters:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:18.04 as builder

ARG GO_VERSION="1.17.13"
ARG GO_VERSION="1.20.5"

ARG CHANNEL
ARG URL
Expand Down
1 change: 0 additions & 1 deletion agreement/actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ type actorContract interface {
}

// A checkedActor wraps an actor, checking its contract on each call.
//
type checkedActor struct {
actor
actorContract
Expand Down
6 changes: 3 additions & 3 deletions agreement/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func makeBundlePanicWrapper(t *testing.T, message string, proposal proposalValue
return uab
}

//Test Bundle Creation with Validation for duplicate votes from same sender
// Test Bundle Creation with Validation for duplicate votes from same sender
func TestBundleCreationWithVotesFromSameAddress(t *testing.T) {
partitiontest.PartitionTest(t)

Expand Down Expand Up @@ -173,7 +173,7 @@ func TestBundleCreationWithVotesFromSameAddress(t *testing.T) {

}

//Test Bundle Creation with Validation
// Test Bundle Creation with Validation
func TestBundleCreationWithEquivocationVotes(t *testing.T) {
partitiontest.PartitionTest(t)

Expand Down Expand Up @@ -283,7 +283,7 @@ func TestBundleCreationWithEquivocationVotes(t *testing.T) {

}

//Test Bundle Creation with Validation
// Test Bundle Creation with Validation
func TestBundleCertificationWithEquivocationVotes(t *testing.T) {
partitiontest.PartitionTest(t)

Expand Down
1 change: 1 addition & 0 deletions agreement/cryptoRequestContext.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type roundRequestsContext struct {
}

// pendingRequests keeps the context for all pending requests
//
//msgp:ignore pendingRequestsContext
type pendingRequestsContext map[round]roundRequestsContext

Expand Down
35 changes: 21 additions & 14 deletions agreement/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,27 @@
//
// Clients instantiate an Service by providing it several
// parameters:
// - Ledger represents a data store which supports the reading and
// writing of data stored within Blocks.
// - BlockFactory produces Blocks for a given round.
// - BlockValidator validates Blocks for a given round.
// - KeyManager holds the participation keys necessary to participate
// in the protocol.
// - Network provides an abstraction over the underlying network.
// - timers.Clock provides timekeeping services for timeouts.
// - db.Accessor provides persistent storage for internal state.
//
// Blocks for which consensus is completed are written using
// Ledger.EnsureBlock alongside Certificate objects, which are
// cryptographic proofs that a Block was confirmed for a given
// round.
//
// - Ledger represents a data store which supports the reading and
// writing of data stored within Blocks.
//
// - BlockFactory produces Blocks for a given round.
//
// - BlockValidator validates Blocks for a given round.
//
// - KeyManager holds the participation keys necessary to participate
// in the protocol.
//
// - Network provides an abstraction over the underlying network.
//
// - timers.Clock provides timekeeping services for timeouts.
//
// - db.Accessor provides persistent storage for internal state.
//
// Blocks for which consensus is completed are written using
// Ledger.EnsureBlock alongside Certificate objects, which are
// cryptographic proofs that a Block was confirmed for a given
// round.
//
// If Ledger and db.Accessor provide crash-safe storage, agreement
// will also recover safely after crashes.
Expand Down
12 changes: 6 additions & 6 deletions agreement/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -669,12 +669,12 @@ func (e thresholdEvent) ComparableStr() string {
//
// The ordering is given as follows:
//
// - certThreshold events are fresher than all other non-certThreshold events.
// - Events from a later period are fresher than events from an older period.
// - nextThreshold events are fresher than softThreshold events from the same
// period.
// - nextThreshold events for the bottom proposal-value are fresher than
// nextThreshold events for some other value.
// - certThreshold events are fresher than all other non-certThreshold events.
// - Events from a later period are fresher than events from an older period.
// - nextThreshold events are fresher than softThreshold events from the same
// period.
// - nextThreshold events for the bottom proposal-value are fresher than
// nextThreshold events for some other value.
//
// Precondition: e.Round == o.Round if e.T != none and o.T != none
func (e thresholdEvent) fresherThan(o thresholdEvent) bool {
Expand Down
54 changes: 27 additions & 27 deletions agreement/proposalManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ func (m *proposalManager) underlying() listener {

// A proposalManager handles eight types of events:
//
// - It applies message relay rules to votePresent, voteVerified,
// payloadPresent, and payloadVerified events.
// - It applies message relay rules to votePresent, voteVerified,
// payloadPresent, and payloadVerified events.
//
// - It enters a new round given a roundInterruption.
//
// - It enters a new period given a nextThreshold event. It also enters a new
// period given a softThreshold/certThreshold event, if necessary.
// - On entering a new period due to a softThreshold/certThreshold, it
// dispatches this event to the proposalMachineRound.
// - It enters a new period given a nextThreshold event. It also enters a new
// period given a softThreshold/certThreshold event, if necessary.
// - On entering a new period due to a softThreshold/certThreshold, it
// dispatches this event to the proposalMachineRound.
//
// For more details, see each method's respective documentation below.
func (m *proposalManager) handle(r routerHandle, p player, e event) event {
Expand Down Expand Up @@ -99,30 +99,30 @@ func (m *proposalManager) handleNewPeriod(r routerHandle, p player, e thresholdE

// handleMessageEvent is called for {vote,payload}{Present,Verified} events.
//
// - A votePresent event is delivered when the state machine receives a new
// proposal-vote. A voteFiltered event is returned if the proposal-vote is
// not fresh or is a duplicate. Otherwise, an empty event is returned.
// - A votePresent event is delivered when the state machine receives a new
// proposal-vote. A voteFiltered event is returned if the proposal-vote is
// not fresh or is a duplicate. Otherwise, an empty event is returned.
//
// - A voteVerified event is delievered after verification was attempted on a
// proposal-vote. A voteMalformed event is returned if the proposal-vote is
// ill-formed and resulted from a corrupt process. A voteFiltered event is
// emitted if the vote is not fresh or is a duplicate. Otherwise the
// proposal-vote is dispatched to the proposalMachineRound, and a voteFiltered
// or a proposalAccepted event is returned.
// - A voteVerified event is delievered after verification was attempted on a
// proposal-vote. A voteMalformed event is returned if the proposal-vote is
// ill-formed and resulted from a corrupt process. A voteFiltered event is
// emitted if the vote is not fresh or is a duplicate. Otherwise the
// proposal-vote is dispatched to the proposalMachineRound, and a voteFiltered
// or a proposalAccepted event is returned.
//
// - A payloadPresent event is delivered when the state machine receives a new
// proposal payload. The payload is dispatched to both the
// proposalMachineRound for the current round and the proposalMachineRound for
// the next round. If both state machines return payloadRejected,
// proposalManager also returns payloadRejected. Otherwise, one state machine
// returned payloadPipelined, and the proposalManager propagates this event to
// the parent, setting the event's round properly.
// - A payloadPresent event is delivered when the state machine receives a new
// proposal payload. The payload is dispatched to both the
// proposalMachineRound for the current round and the proposalMachineRound for
// the next round. If both state machines return payloadRejected,
// proposalManager also returns payloadRejected. Otherwise, one state machine
// returned payloadPipelined, and the proposalManager propagates this event to
// the parent, setting the event's round properly.
//
// - A payloadVerified event is delivered after validation was attempted on a
// proposal payload. If the proposal payload was invalid, a payloadMalformed
// event is returned. Otherwise, the event is dispatched to the
// proposalMachineRound, and then the resulting payload{Rejected,Accepted} or
// proposalCommittable event is returned.
// - A payloadVerified event is delivered after validation was attempted on a
// proposal payload. If the proposal payload was invalid, a payloadMalformed
// event is returned. Otherwise, the event is dispatched to the
// proposalMachineRound, and then the resulting payload{Rejected,Accepted} or
// proposalCommittable event is returned.
func (m *proposalManager) handleMessageEvent(r routerHandle, p player, e filterableMessageEvent) (res event) {
var pipelinedRound round
var pipelinedPeriod period
Expand Down