Skip to content

Commit

Permalink
chore(build): upgrade Go from 1.18 to 1.19 (#2719)
Browse files Browse the repository at this point in the history
- CI uses Go 1.19
- Dockerfiles use Go 1.19
- go.mod uses Go 1.19
- Readme: remove Go 1.19 incompatibility warning
- Readme: update requirement to Go 1.19 or higher
- Re-generate proto files to match Go 1.19 new comments format
- Fix all comments to match Go 1.19 new comments format
- Replace `ioutil` import with `os`
- Fix new lint errors introduced
- Remove old `//gocyclo:ignore` comment
  • Loading branch information
qdm12 authored Jan 17, 2023
1 parent c57ade6 commit 7c01e8f
Show file tree
Hide file tree
Showing 38 changed files with 85 additions and 84 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
stable: true
check-latest: true

Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
stable: true
check-latest: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
stable: true
check-latest: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/copyright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
stable: true
check-latest: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/devnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
stable: true
check-latest: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
stable: true
check-latest: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
stable: true
check-latest: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mocks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
stable: true
check-latest: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
stable: true
check-latest: true

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG DEBIAN_VERSION=bullseye-slim
ARG GO_VERSION=1.18-buster
ARG GO_VERSION=1.19-buster

FROM golang:${GO_VERSION} AS builder

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.staging
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.18
FROM golang:1.19

ARG chain="polkadot"
ARG basepath="~/.gossamer"
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,9 @@ and start a development network.
[Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) is required
to acquire the Gossamer source code, and
[Make](https://tilburgsciencehub.com/building-blocks/configure-your-computer/automation-and-workflows/make/)
is used to build it. Building Gossamer requires version 1.18 of
is used to build it. Building Gossamer requires version 1.19 or higher of
[Golang](https://go.dev/dl/).

> **Warning**
>
> Gossamer will NOT work with version 1.19 of Golang.
### Installation

Clone the [Gossamer](https://github.com/ChainSafe/gossamer) repository and
Expand Down
2 changes: 1 addition & 1 deletion devnet/alice.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2021 ChainSafe Systems (ON)
# SPDX-License-Identifier: LGPL-3.0-only

FROM golang:1.18
FROM golang:1.19

ARG POLKADOT_VERSION=v0.9.10

Expand Down
2 changes: 1 addition & 1 deletion devnet/bob.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2021 ChainSafe Systems (ON)
# SPDX-License-Identifier: LGPL-3.0-only

FROM golang:1.18
FROM golang:1.19

ARG POLKADOT_VERSION=v0.9.10

Expand Down
2 changes: 1 addition & 1 deletion devnet/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/ChainSafe/gossamer/devnet

go 1.18
go 1.19

require (
github.com/aws/aws-sdk-go v1.42.22
Expand Down
2 changes: 1 addition & 1 deletion devnet/substrate_alice.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

ARG POLKADOT_VERSION=v0.9.10

FROM golang:1.18 as openmetrics
FROM golang:1.19 as openmetrics
ARG METRICS_NAMESPACE=substrate.local.devnet

WORKDIR /devnet
Expand Down
2 changes: 1 addition & 1 deletion devnet/substrate_bob.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: LGPL-3.0-only
ARG POLKADOT_VERSION=v0.9.10

FROM golang:1.18 as openmetrics
FROM golang:1.19 as openmetrics

ARG METRICS_NAMESPACE=substrate.local.devnet

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ permalink: /getting-started/installation

## Prerequisites

Install [Go](https://go.dev/doc/install) version [`>=1.18`](https://go.dev/dl/#go1.18)
Install [Go](https://go.dev/doc/install) version [`>=1.19`](https://go.dev/dl/#go1.19)

## Installation

Expand Down
1 change: 1 addition & 0 deletions dot/network/proto/api.v1.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dot/network/proto/proto_generate.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2022 ChainSafe Systems (ON)
// SPDX-License-Identifier: LGPL-3.0-only

// Package proto contains protobuf generated Go structures.
package proto

//go:generate protoc --go_out=. --go_opt=paths=source_relative api.v1.proto
14 changes: 7 additions & 7 deletions dot/rpc/modules/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func NewChainModule(api BlockAPI) *ChainModule {
}

// GetBlock Get header and body of a relay chain block. If no block hash is provided,
// the latest block body will be returned.
// the latest block body will be returned.
func (cm *ChainModule) GetBlock(r *http.Request, req *ChainHashRequest, res *ChainBlockResponse) error {
hash := cm.hashLookup(req)
block, err := cm.blockAPI.GetBlockByHash(hash)
Expand All @@ -97,7 +97,7 @@ func (cm *ChainModule) GetBlock(r *http.Request, req *ChainHashRequest, res *Cha
}

// GetBlockHash Get hash of the 'n-th' block in the canon chain. If no parameters are provided,
// the latest block hash gets returned.
// the latest block hash gets returned.
func (cm *ChainModule) GetBlockHash(r *http.Request, req *ChainBlockNumberRequest, res *ChainHashResponse) error {
// if request is empty, return highest hash
if req.Block == nil {
Expand Down Expand Up @@ -139,7 +139,7 @@ func (cm *ChainModule) GetFinalizedHeadByRound(
return nil
}

//GetHeader Get header of a relay chain block. If no block hash is provided, the latest block header will be returned.
// GetHeader Get header of a relay chain block. If no block hash is provided, the latest block header will be returned.
func (cm *ChainModule) GetHeader(r *http.Request, req *ChainHashRequest, res *ChainBlockHeaderResponse) error {
hash := cm.hashLookup(req)
header, err := cm.blockAPI.GetHeader(hash)
Expand All @@ -152,19 +152,19 @@ func (cm *ChainModule) GetHeader(r *http.Request, req *ChainHashRequest, res *Ch
}

// SubscribeFinalizedHeads handled by websocket handler, but this func should remain
// here so it's added to rpc_methods list
// here so it's added to rpc_methods list
func (cm *ChainModule) SubscribeFinalizedHeads(_ *http.Request, _ *EmptyRequest, _ *ChainBlockHeaderResponse) error {
return ErrSubscriptionTransport
}

// SubscribeNewHead handled by websocket handler, but this func should remain
// here so it's added to rpc_methods list
// here so it's added to rpc_methods list
func (cm *ChainModule) SubscribeNewHead(r *http.Request, req *EmptyRequest, res *ChainBlockHeaderResponse) error {
return ErrSubscriptionTransport
}

// SubscribeNewHeads handled by websocket handler, but this func should remain
// here so it's added to rpc_methods list
// here so it's added to rpc_methods list
func (cm *ChainModule) SubscribeNewHeads(r *http.Request, req *EmptyRequest, res *ChainBlockHeaderResponse) error {
return ErrSubscriptionTransport
}
Expand Down Expand Up @@ -200,7 +200,7 @@ func (cm *ChainModule) unwindRequest(req interface{}) ([]string, error) {
}

// lookupHashByInterface parses given interface to determine block number, then
// finds hash for that block number
// finds hash for that block number
func (cm *ChainModule) lookupHashByInterface(i interface{}) (string, error) {
var num uint
switch x := i.(type) {
Expand Down
6 changes: 3 additions & 3 deletions dot/rpc/modules/grandpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ type ProveFinalityRequest struct {
type ProveFinalityResponse []string

// ProveFinality for the provided block number, the Justification for the last block in the set is written to the
// response. The response is a SCALE encoded proof array. The proof array is empty if the block number is
// not finalized.
// Returns error which are included in the response if they occur.
// response. The response is a SCALE encoded proof array. The proof array is empty if the block number is
// not finalized.
// Returns error which are included in the response if they occur.
func (gm *GrandpaModule) ProveFinality(r *http.Request, req *ProveFinalityRequest, res *ProveFinalityResponse) error {
blockHash, err := gm.blockAPI.GetHashByNumber(uint(req.BlockNumber))
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions dot/rpc/modules/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func (sm *StateModule) GetStorage(
}

// GetStorageHash returns the blake2b hash of a storage entry at a block's state.
// If no block hash is provided, the latest value is returned.
// If no block hash is provided, the latest value is returned.
func (sm *StateModule) GetStorageHash(
_ *http.Request, req *StateStorageHashRequest, res *StateStorageHashResponse) error {
var (
Expand Down Expand Up @@ -499,9 +499,9 @@ func (sm *StateModule) SubscribeRuntimeVersion(
}

// SubscribeStorage Storage subscription. If storage keys are specified, it creates a message for each block which
// changes the specified storage keys. If none are specified, then it creates a message for every block.
// This endpoint communicates over the Websocket protocol, but this func should remain here so it's
// added to rpc_methods list
// changes the specified storage keys. If none are specified, then it creates a message for every block.
// This endpoint communicates over the Websocket protocol, but this func should remain here so it's
// added to rpc_methods list
func (*StateModule) SubscribeStorage(
_ *http.Request, _ *StateStorageQueryRangeRequest, _ *StorageChangeSetResponse) error {
return nil
Expand Down
4 changes: 2 additions & 2 deletions dot/rpc/modules/sync_state_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package modules

import (
"encoding/json"
"io/ioutil"
"os"
"path/filepath"
"testing"

Expand All @@ -19,7 +19,7 @@ import (
func TestSyncStateModule(t *testing.T) {
fp := utils.GetWestendDevRawGenesisPath(t)

data, err := ioutil.ReadFile(filepath.Clean(fp))
data, err := os.ReadFile(filepath.Clean(fp))
require.NoError(t, err)

g := new(genesis.Genesis)
Expand Down
3 changes: 1 addition & 2 deletions dot/rpc/modules/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ func (sm *SystemModule) LocalListenAddresses(r *http.Request, req *EmptyRequest,
}

// LocalPeerId Returns the base58-encoded PeerId fo the node.
//nolint
func (sm *SystemModule) LocalPeerId(r *http.Request, req *EmptyRequest, res *string) error {
func (sm *SystemModule) LocalPeerId(r *http.Request, req *EmptyRequest, res *string) error { //nolint:revive
netstate := sm.networkAPI.NetworkState()
if netstate.PeerID == "" {
return errors.New("peer id cannot be empty")
Expand Down
6 changes: 3 additions & 3 deletions dot/sync/chain_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -827,9 +827,9 @@ func (cs *chainSync) determineSyncPeers(req *network.BlockRequestMessage, peersT
// validateResponse performs pre-validation of a block response before placing it into either the
// pendingBlocks or readyBlocks set.
// It checks the following:
// - the response is not empty
// - the response contains all the expected fields
// - each block has the correct parent, ie. the response constitutes a valid chain
// - the response is not empty
// - the response contains all the expected fields
// - each block has the correct parent, ie. the response constitutes a valid chain
func (cs *chainSync) validateResponse(req *network.BlockRequestMessage,
resp *network.BlockResponseMessage, p peer.ID) error {
if resp == nil || len(resp.BlockData) == 0 {
Expand Down
3 changes: 1 addition & 2 deletions dot/types/babe.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ var (
)

// BabeConfiguration contains the genesis data for BABE
//nolint:lll
// see: https://github.com/paritytech/substrate/blob/426c26b8bddfcdbaf8d29f45b128e0864b57de1c/core/consensus/babe/primitives/src/lib.rs#L132
// See https://github.com/paritytech/substrate/blob/426c26b8bddfcdbaf8d29f45b128e0864b57de1c/core/consensus/babe/primitives/src/lib.rs#L132
type BabeConfiguration struct {
SlotDuration uint64 // milliseconds
EpochLength uint64 // duration of epoch in slots
Expand Down
2 changes: 1 addition & 1 deletion dot/types/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const (
)

// RuntimeDispatchInfo represents information related to a dispatchable's class, weight, and fee that can be queried
// from the runtime
// from the runtime
type RuntimeDispatchInfo struct {
Weight uint64
// Class could be Normal (0), Operational (1), Mandatory (2)
Expand Down
3 changes: 1 addition & 2 deletions dot/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"crypto/sha256"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -69,7 +68,7 @@ func TestCreateJSONRawFile(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
CreateJSONRawFile(tt.args.bs, tt.args.fp)

b, err := ioutil.ReadFile(tt.args.fp)
b, err := os.ReadFile(tt.args.fp)
require.NoError(t, err)
digest := sha256.Sum256(b)
hexDigest := fmt.Sprintf("%x", digest)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,4 @@ require (
lukechampine.com/blake3 v1.1.7 // indirect
)

go 1.18
go 1.19
2 changes: 1 addition & 1 deletion lib/babe/parachain_inherents.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ type collatorID []byte
// collatorSignature is the signature on a candidate's block data signed by a collator.
type collatorSignature signature

// validationCodeHash is the blake2-256 hash of the validation code bytes.
// validationCodeHash is the blake2-256 hash of the validation code bytes.
type validationCodeHash common.Hash

// candidateDescriptor is a unique descriptor of the candidate receipt.
Expand Down
1 change: 0 additions & 1 deletion lib/babe/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ func newVerifier(blockState BlockState, epoch uint64, info *verifierInfo) *verif
}
}

//gocyclo:ignore
// verifyAuthorshipRight verifies that the authority that produced a block was authorized to produce it.
func (b *verifier) verifyAuthorshipRight(header *types.Header) error {
// header should have 2 digest items (possibly more in the future)
Expand Down
2 changes: 1 addition & 1 deletion lib/grandpa/message_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ func (h *MessageHandler) verifyPreCommitJustification(msg *CatchUpResponse) erro
}

// VerifyBlockJustification verifies the finality justification for a block, returns scale encoded justification with
// any extra bytes removed.
// any extra bytes removed.
func (s *Service) VerifyBlockJustification(hash common.Hash, justification []byte) ([]byte, error) {
fj := Justification{}
err := scale.Unmarshal(justification, &fj)
Expand Down
4 changes: 2 additions & 2 deletions lib/grandpa/round_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func TestPlayGrandpaRound(t *testing.T) {
latestHash = serviceFinalizedHash
}

var latestCommit *CommitMessage = producedCommitMessages[0]
latestCommit := producedCommitMessages[0]
for _, commitMessage := range producedCommitMessages[1:] {
require.NotNil(t, commitMessage)
require.GreaterOrEqual(t, len(commitMessage.Precommits), len(tt.voters)/2)
Expand Down Expand Up @@ -455,7 +455,7 @@ func TestPlayGrandpaRoundMultipleRounds(t *testing.T) {
assertSamefinalisationAndChainGrowth(t, grandpaServices,
uint64(currentRound), setID)

var latestCommit *CommitMessage = producedCommitMessages[0]
latestCommit := producedCommitMessages[0]
for _, commitMessage := range producedCommitMessages[1:] {
require.NotNil(t, commitMessage)
require.GreaterOrEqual(t, len(commitMessage.Precommits), len(voters)/2)
Expand Down
Loading

0 comments on commit 7c01e8f

Please sign in to comment.