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

chore: upgrade to Go 1.20 #1692

Merged
merged 7 commits into from
May 5, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ name: lint
on:
workflow_call:

env:
GO_VERSION: '1.20'

jobs:
golangci-lint:
name: golangci-lint
runs-on: ubuntu-latest
timeout-minutes: 8
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.19
- uses: actions/checkout@v3
go-version: ${{ env.GO_VERSION }}
- uses: technote-space/get-diff-action@v6.1.2
with:
# This job will pass without running if go.mod, go.sum, and *.go
Expand All @@ -24,7 +27,7 @@ jobs:
go.sum
- uses: golangci/golangci-lint-action@v3.4.0
with:
version: v1.50.1
version: v1.52.2
args: --timeout 10m
github-token: ${{ secrets.github_token }}
if: env.GIT_DIFF
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ name: Tests / Code Coverage
on:
workflow_call:

env:
GO_VERSION: '1.20'

concurrency:
# do not cancel jobs from earlier commits for tags or the main branch
group: ${{ github.workflow }}-${{ !startsWith(github.ref, 'refs/tags/') &&
Expand All @@ -18,13 +21,13 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: ${{ env.GO_VERSION }}
- name: Display go version
run: go version
- name: install tparse
run: >
export GO111MODULE="on" &&
go install github.com/mfridman/tparse@v0.8.3
go install github.com/mfridman/tparse@v0.12.1
- uses: actions/cache@v3.3.1
with:
path: ~/go/bin
Expand All @@ -37,7 +40,7 @@ jobs:
# - uses: actions/checkout@v3
# - uses: actions/setup-go@v4
# with:
# go-version: 1.19
# go-version: ${{ env.GO_VERSION }}
# - name: Display go version
# run: go version
# - uses: technote-space/get-diff-action@v6.1.2
Expand Down Expand Up @@ -90,7 +93,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: ${{ env.GO_VERSION }}
- uses: technote-space/get-diff-action@v6.1.2
with:
PATTERNS: |
Expand Down Expand Up @@ -173,7 +176,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: ${{ env.GO_VERSION }}
- uses: technote-space/get-diff-action@v6.1.2
with:
PATTERNS: |
Expand Down Expand Up @@ -241,7 +244,7 @@ jobs:
# - uses: actions/checkout@v3
# - uses: actions/setup-go@v4
# with:
# go-version: 1.19
# go-version: ${{ env.GO_VERSION }}
# - uses: technote-space/get-diff-action@v6.1.2
# id: git_diff
# with:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ build: mod
@cd ./cmd/celestia-appd
@mkdir -p build/
@go build $(BUILD_FLAGS) -o build/ ./cmd/celestia-appd
@go mod tidy -compat=1.19
@go mod tidy -compat=1.20
.PHONY: build

## install: Build and install the celestia-appd binary into the $GOPATH/bin directory.
Expand All @@ -42,7 +42,7 @@ install: go.sum
## mod: Update go.mod.
mod:
@echo "--> Updating go.mod"
@go mod tidy -compat=1.19
@go mod tidy -compat=1.20
.PHONY: mod

## mod-verify: Verify dependencies have expected content.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ node | | | |

## Install

1. [Install Go](https://go.dev/doc/install) 1.19
1. [Install Go](https://go.dev/doc/install) 1.20
1. Clone this repo
1. Install the celestia-app CLI

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/celestiaorg/celestia-app

go 1.19
go 1.20

require (
github.com/celestiaorg/nmt v0.15.0
Expand Down
15 changes: 8 additions & 7 deletions pkg/shares/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package shares

import (
"bytes"
"crypto/rand"
"encoding/binary"
"math/rand"
"reflect"
"testing"

Expand Down Expand Up @@ -35,11 +35,11 @@ func TestParseShares(t *testing.T) {
blobTwoContinuation := blobTwoShares[1]

// invalidShare is longer than the length of a valid share
invalidShare := Share{data: append(generateRawShare(ns1, true, 1), []byte{0}...)}
invalidShare := Share{data: append(generateRawShare(t, ns1, true, 1), []byte{0}...)}

// tooLargeSequenceLen is a single share with too large of a sequence len
// because it takes more than one share to store a sequence of 1000 bytes
tooLargeSequenceLen := generateRawShare(ns1, true, uint32(1000))
tooLargeSequenceLen := generateRawShare(t, ns1, true, uint32(1000))

ns1Padding, err := NamespacePaddingShare(ns1)
require.NoError(t, err)
Expand Down Expand Up @@ -210,7 +210,7 @@ func TestParseShares(t *testing.T) {
}
}

func generateRawShare(namespace appns.Namespace, isSequenceStart bool, sequenceLen uint32) (rawShare []byte) {
func generateRawShare(t *testing.T, namespace appns.Namespace, isSequenceStart bool, sequenceLen uint32) (rawShare []byte) {
infoByte, _ := NewInfoByte(appconsts.ShareVersionZero, isSequenceStart)

sequenceLenBuf := make([]byte, appconsts.SequenceLenBytes)
Expand All @@ -220,13 +220,14 @@ func generateRawShare(namespace appns.Namespace, isSequenceStart bool, sequenceL
rawShare = append(rawShare, byte(infoByte))
rawShare = append(rawShare, sequenceLenBuf...)

return padWithRandomBytes(rawShare)
return padWithRandomBytes(t, rawShare)
}

func padWithRandomBytes(partialShare []byte) (paddedShare []byte) {
func padWithRandomBytes(t *testing.T, partialShare []byte) (paddedShare []byte) {
paddedShare = make([]byte, appconsts.ShareSize)
copy(paddedShare, partialShare)
rand.Read(paddedShare[len(partialShare):])
_, err := rand.Read(paddedShare[len(partialShare):])
require.NoError(t, err)
return paddedShare
}

Expand Down