Skip to content

Commit

Permalink
chore: use go 1.20 (#840)
Browse files Browse the repository at this point in the history
* rm GenPubKey

* use go 1.19 since go 1.18 is no longer supported

* update go version in Dockerfiles and github actions

* remove ioutil because it's deprecated

* gofumpt

* pass linter

* use go 1.20

* change the version of go mentioned in other files

* quote the version of go in in the linter action

* ignore deprecation of rand.Seed for testing

* protocgen.sh

* Update README.md

---------

Co-authored-by: Shawn <[email protected]>
Co-authored-by: Marius Poke <[email protected]>
  • Loading branch information
3 people authored Apr 19, 2023
1 parent 9fef736 commit 7bfb7b5
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/automated-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.18.0" # The Go version to download (if necessary) and use.
go-version: "1.20" # The Go version to download (if necessary) and use.

- name: Unit, integration and difference tests
run: go test ./...
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.18.0" # The Go version to download (if necessary) and use.
go-version: "1.20" # The Go version to download (if necessary) and use.
- name: Test with coverage
run: go test -coverpkg=./x/... -coverprofile=coverage.out ./...
- name: SonarCloud Scan
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: "1.20"
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
Expand All @@ -43,4 +43,4 @@ jobs:
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
# skip-build-cache: true
4 changes: 2 additions & 2 deletions .github/workflows/manual-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.18'
go-version: "1.20"
- uses: actions/checkout@v3

- name: Checkout LFS objects
Expand All @@ -20,7 +20,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.18" # The Go version to download (if necessary) and use.
go-version: "1.20" # The Go version to download (if necessary) and use.

- name: E2E tests
run: make test-e2e
5 changes: 2 additions & 3 deletions .github/workflows/nightly-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
- cron: '0 3 * * *'
- cron: "0 3 * * *"

jobs:
nightly-test:
Expand All @@ -24,14 +24,13 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.18'
go-version: "1.20"

- uses: actions/checkout@v3

- name: E2E tests
run: make test-e2e


nightly-test-fail:
needs: nightly-test
if: ${{ failure() }}
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1

FROM golang:1.18-alpine AS is-builder
FROM golang:1.20-alpine AS is-builder

ENV PACKAGES curl make git libc-dev bash gcc linux-headers
RUN apk add --no-cache $PACKAGES
Expand Down
12 changes: 6 additions & 6 deletions Dockerfile.gaia
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1

# build latest tagged gaia
FROM golang:1.18-alpine AS gaia-builder
FROM golang:1.20-alpine AS gaia-builder
# WORKDIR is set to /go by default
ARG USE_GAIA_TAG
ENV GAIA_TAG=${USE_GAIA_TAG}
Expand All @@ -25,25 +25,25 @@ RUN git clone https://github.com/cosmos/gaia.git
WORKDIR /go/gaia

# fetch gaia from tag and build it
RUN if [ -n "${GAIA_TAG}" ]; \
then git checkout "${GAIA_TAG}"; \
RUN if [ -n "${GAIA_TAG}" ]; \
then git checkout "${GAIA_TAG}"; \
# if GAIA_TAG is not set, build the latest tagged version
else \
git checkout $(git tag | tail -1); \
git checkout $(git tag | tail -1); \
fi

# Also replace sdk version in the go.mod if specified
RUN if [ -d "/interchain-security/cosmos-sdk" ]; then \
go mod edit -replace github.com/cosmos/cosmos-sdk=/interchain-security/cosmos-sdk && \
echo "local sdk version used in gaia build"; \
fi
fi

RUN go mod tidy
# Print the version of the sdk used in the build
RUN go list -m github.com/cosmos/cosmos-sdk
RUN make build

FROM golang:1.18-alpine AS is-builder
FROM golang:1.20-alpine AS is-builder

ENV PACKAGES curl make git libc-dev bash gcc linux-headers
RUN apk add --no-cache $PACKAGES
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The code for CCV is housed under [x/ccv](./x/ccv). The `types` folder contains t
## For OSX or Linux

# go 1.18 (https://formulae.brew.sh/formula/go)
brew install go@1.18
brew install go@1.20
# jq (optional, for testnet) (https://formulae.brew.sh/formula/jq)
brew install jq
# docker (optional, for integration tests, testnet) (https://docs.docker.com/get-docker/)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/cosmos/interchain-security

go 1.18
go 1.20

require (
github.com/confio/ics23/go v0.9.0
Expand Down
2 changes: 1 addition & 1 deletion scripts/protocgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ cd ..
cp -r github.com/cosmos/interchain-security/* ./
rm -rf github.com

go mod tidy -compat=1.18
go mod tidy -compat=1.20
8 changes: 4 additions & 4 deletions x/ccv/provider/client/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package client
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
"path/filepath"
"time"

Expand Down Expand Up @@ -252,7 +252,7 @@ type ConsumerAdditionProposalReq struct {
func ParseConsumerAdditionProposalJSON(proposalFile string) (ConsumerAdditionProposalJSON, error) {
proposal := ConsumerAdditionProposalJSON{}

contents, err := ioutil.ReadFile(filepath.Clean(proposalFile))
contents, err := os.ReadFile(filepath.Clean(proposalFile))
if err != nil {
return proposal, err
}
Expand Down Expand Up @@ -304,7 +304,7 @@ type EquivocationProposalReq struct {
func ParseEquivocationProposalJSON(proposalFile string) (EquivocationProposalJSON, error) {
proposal := EquivocationProposalJSON{}

contents, err := ioutil.ReadFile(filepath.Clean(proposalFile))
contents, err := os.ReadFile(filepath.Clean(proposalFile))
if err != nil {
return proposal, err
}
Expand All @@ -327,7 +327,7 @@ func EquivocationProposalRESTHandler(clientCtx client.Context) govrest.ProposalR
func ParseConsumerRemovalProposalJSON(proposalFile string) (ConsumerRemovalProposalJSON, error) {
proposal := ConsumerRemovalProposalJSON{}

contents, err := ioutil.ReadFile(filepath.Clean(proposalFile))
contents, err := os.ReadFile(filepath.Clean(proposalFile))
if err != nil {
return proposal, err
}
Expand Down
8 changes: 4 additions & 4 deletions x/ccv/provider/keeper/key_assignment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestGetAllValidatorConsumerPubKey(t *testing.T) {
pk, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t))
defer ctrl.Finish()

rand.Seed(time.Now().Unix())
rand.Seed(time.Now().Unix()) // nolint:staticcheck // ignore SA1019 for tests
chainIDs := []string{"consumer-1", "consumer-2", "consumer-3"}
numAssignments := 10
testAssignments := []types.ValidatorConsumerPubKey{}
Expand Down Expand Up @@ -124,7 +124,7 @@ func TestGetAllValidatorsByConsumerAddr(t *testing.T) {
pk, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t))
defer ctrl.Finish()

rand.Seed(time.Now().Unix())
rand.Seed(time.Now().Unix()) // nolint:staticcheck // ignore SA1019 for tests
chainIDs := []string{"consumer-1", "consumer-2", "consumer-3"}
numAssignments := 10
testAssignments := []types.ValidatorByConsumerAddr{}
Expand Down Expand Up @@ -202,7 +202,7 @@ func TestGetAllKeyAssignmentReplacements(t *testing.T) {

chainID := "consumer-1"

rand.Seed(time.Now().Unix())
rand.Seed(time.Now().Unix()) // nolint:staticcheck // ignore SA1019 for tests
numAssignments := 10
testAssignments := []types.KeyAssignmentReplacement{}
for i := 0; i < numAssignments; i++ {
Expand Down Expand Up @@ -259,7 +259,7 @@ func TestGetAllConsumerAddrsToPrune(t *testing.T) {
pk, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t))
defer ctrl.Finish()

rand.Seed(time.Now().Unix())
rand.Seed(time.Now().Unix()) // nolint:staticcheck // ignore SA1019 for tests
chainIDs := []string{"consumer-1", "consumer-2", "consumer-3"}
numAssignments := 10
testAssignments := []types.ConsumerAddrsToPrune{}
Expand Down
4 changes: 2 additions & 2 deletions x/ccv/provider/keeper/throttle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ func TestGlobalSlashEntryDeletion(t *testing.T) {

// Instantiate shuffled copy of above slice
shuffledEntries := append([]providertypes.GlobalSlashEntry{}, entries...)
rand.Seed(now.UnixNano())
rand.Seed(now.UnixNano()) // nolint:staticcheck // ignore SA1019 for tests
rand.Shuffle(len(shuffledEntries), func(i, j int) {
shuffledEntries[i], shuffledEntries[j] = shuffledEntries[j], shuffledEntries[i]
})
Expand Down Expand Up @@ -1189,7 +1189,7 @@ func TestPanicIfTooMuchThrottledPacketData(t *testing.T) {
defaultParams.MaxThrottledPackets = tc.max
providerKeeper.SetParams(ctx, defaultParams)

rand.Seed(time.Now().UnixNano())
rand.Seed(time.Now().UnixNano()) // nolint:staticcheck // ignore SA1019 for tests

// Queuing up a couple data instances for another chain shouldn't matter
err := providerKeeper.QueueThrottledPacketData(ctx, "chain-17", 0, testkeeper.GetNewSlashPacketData())
Expand Down

0 comments on commit 7bfb7b5

Please sign in to comment.