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: set beelocal branch to update-k3s-1.30.3 and go 1.23 upgrade #4878

Merged
merged 10 commits into from
Nov 5, 2024
Merged
6 changes: 3 additions & 3 deletions .github/workflows/beekeeper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ on:
- "**"

env:
K3S_VERSION: "v1.22.17+k3s1"
K3S_VERSION: "v1.30.3+k3s1"
REPLICA: 3
RUN_TYPE: "PR RUN"
SETUP_CONTRACT_IMAGE: "ethersphere/bee-localchain"
SETUP_CONTRACT_IMAGE_TAG: "0.9.2-rc1"
BEELOCAL_BRANCH: "main"
BEEKEEPER_BRANCH: "master"
BEELOCAL_BRANCH: "update-k3s-0.30.3"
BEEKEEPER_BRANCH: "update-k8s-0.30.3"
BEEKEEPER_METRICS_ENABLED: false
REACHABILITY_OVERRIDE_PUBLIC: true
BATCHFACTOR_OVERRIDE_PUBLIC: 2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ jobs:
if: github.ref != 'refs/heads/master'
uses: wagoid/commitlint-github-action@v5
- name: GolangCI-Lint
uses: golangci/golangci-lint-action@v4
uses: golangci/golangci-lint-action@v6
with:
skip-cache: false
version: v1.54.1
version: v1.61.0
- name: Whitespace check
run: make check-whitespace
- name: go mod tidy check
Expand Down
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ linters:
enable:
- asciicheck
- bidichk
# - depguard disable temporary until this issue is resolved: https://github.com/golangci/golangci-lint/issues/3906
- copyloopvar
- dogsled
- durationcheck
- errcheck
- errname
- errorlint
- exportloopref
- forbidigo
- gochecknoinits
- goconst
Expand All @@ -33,6 +32,7 @@ linters:
- typecheck
- unconvert
- unused
# - depguard disable temporary until this issue is resolved: https://github.com/golangci/golangci-lint/issues/3906

linters-settings:
govet:
Expand Down
3 changes: 1 addition & 2 deletions CODINGSTYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,10 @@ Use the Golang [testing package](https://pkg.go.dev/testing) from the standard l

### Parallel Test Execution

Run tests in parallel where possible but don't forget about variable scope gotchas.
Run tests in parallel where possible.

```go
for tc := range tt {
tc := tc // must not forget this
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
//execute
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22 AS build
FROM golang:1.23 AS build

WORKDIR /src
# enable modules caching in separate layer
Expand All @@ -8,7 +8,7 @@ COPY . ./

RUN make binary

FROM debian:12.4-slim
FROM debian:12.7-slim

ENV DEBIAN_FRONTEND noninteractive

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.goreleaser
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:12.4-slim
FROM debian:12.7-slim

ENV DEBIAN_FRONTEND noninteractive

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.scratch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:12.4-slim
FROM debian:12.7-slim

ENV DEBIAN_FRONTEND noninteractive

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GO ?= go
GOBIN ?= $$($(GO) env GOPATH)/bin
GOLANGCI_LINT ?= $(GOBIN)/golangci-lint
GOLANGCI_LINT_VERSION ?= v1.55.0
GOLANGCI_LINT_VERSION ?= v1.61.0
GOGOPROTOBUF ?= protoc-gen-gogofaster
GOGOPROTOBUF_VERSION ?= v1.3.1
BEEKEEPER_INSTALL_DIR ?= $(GOBIN)
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/ethersphere/bee/v2

go 1.22
go 1.23

toolchain go1.22.0
toolchain go1.23.0

require (
contrib.go.opencensus.io/exporter/prometheus v0.4.2
Expand Down
21 changes: 12 additions & 9 deletions pkg/accesscontrol/grantee.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ package accesscontrol
import (
"context"
"crypto/ecdsa"
"crypto/elliptic"
"errors"
"fmt"

"github.com/btcsuite/btcd/btcec/v2"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethersphere/bee/v2/pkg/file"
"github.com/ethersphere/bee/v2/pkg/swarm"
)
Expand Down Expand Up @@ -85,7 +85,10 @@ func (g *GranteeListStruct) Add(addList []*ecdsa.PublicKey) error {

// Save saves the grantee list to the underlying storage and returns the reference.
func (g *GranteeListStruct) Save(ctx context.Context) (swarm.Address, error) {
data := serialize(g.grantees)
data, err := serialize(g.grantees)
if err != nil {
return swarm.ZeroAddress, fmt.Errorf("grantee serialize error: %w", err)
}
refBytes, err := g.loadSave.Save(ctx, data)
if err != nil {
return swarm.ZeroAddress, fmt.Errorf("grantee save error: %w", err)
Expand Down Expand Up @@ -140,16 +143,16 @@ func NewGranteeListReference(ctx context.Context, ls file.LoadSaver, reference s
}, nil
}

func serialize(publicKeys []*ecdsa.PublicKey) []byte {
func serialize(publicKeys []*ecdsa.PublicKey) ([]byte, error) {
b := make([]byte, 0, len(publicKeys)*publicKeyLen)
for _, key := range publicKeys {
b = append(b, serializePublicKey(key)...)
// TODO: check if this is the correct way to serialize the public key
// Is this the only curve we support?
// Should we have switch case for different curves?
pubBytes := crypto.S256().Marshal(key.X, key.Y)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since elliptic.Marshal was deprecated is there a reason we are not using equivalent from crypto/ecdh, similar with you have changed in pkg/keystore/file/key.go ? Reference: https://pkg.go.dev/crypto/elliptic#Marshal

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, we only have public key, and we could have something like this:

pubKey, err := key.ECDH()
if err != nil {
	return nil, fmt.Errorf("generate key: %w", err)
}
b = append(b, pubKey.Bytes()...)

But unit tests will return: unsupported curve by crypto/ecdh. Because of this I used specific curve that we are also using in NewEthereumAddress function.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment still relevant?

b = append(b, pubBytes...)
}
return b
}

func serializePublicKey(pub *ecdsa.PublicKey) []byte {
return elliptic.Marshal(pub.Curve, pub.X, pub.Y)
return b, nil
}

func deserialize(data []byte) []*ecdsa.PublicKey {
Expand Down
5 changes: 0 additions & 5 deletions pkg/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ func TestParseName(t *testing.T) {
s.Mount()
s.EnableFullAPI()

tC := tC
t.Run(tC.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -453,7 +452,6 @@ func TestPostageHeaderError(t *testing.T) {
)
content := []byte{7: 0} // 8 zeros
for _, endpoint := range endpoints {
endpoint := endpoint
t.Run(endpoint+": empty batch", func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -538,7 +536,6 @@ func TestOptions(t *testing.T) {
expectedMethods: "GET, HEAD",
},
} {
tc := tc
t.Run(tc.endpoint+" options test", func(t *testing.T) {
t.Parallel()

Expand All @@ -555,8 +552,6 @@ func TestPostageDirectAndDeferred(t *testing.T) {
t.Parallel()

for _, endpoint := range []string{"bytes", "bzz", "chunks"} {
endpoint := endpoint

if endpoint != "chunks" {
t.Run(endpoint+" deferred", func(t *testing.T) {
t.Parallel()
Expand Down
3 changes: 0 additions & 3 deletions pkg/api/balances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ func TestConsumedBalances(t *testing.T) {
if !equalBalances(got, expected) {
t.Errorf("got balances: %v, expected: %v", got, expected)
}

}

func TestConsumedError(t *testing.T) {
Expand Down Expand Up @@ -328,7 +327,6 @@ func Test_peerBalanceHandler_invalidInputs(t *testing.T) {
}}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -377,7 +375,6 @@ func Test_compensatedPeerBalanceHandler_invalidInputs(t *testing.T) {
}}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
3 changes: 0 additions & 3 deletions pkg/api/bytes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ func TestBytesInvalidStamp(t *testing.T) {
jsonhttptest.WithRequestBody(bytes.NewReader(content)),
)
})

}

func TestBytesUploadHandlerInvalidInputs(t *testing.T) {
Expand Down Expand Up @@ -314,7 +313,6 @@ func TestBytesUploadHandlerInvalidInputs(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -364,7 +362,6 @@ func TestBytesGetHandlerInvalidInputs(t *testing.T) {
}}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
8 changes: 0 additions & 8 deletions pkg/api/bzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,8 @@ func TestBzzUploadDownloadWithRedundancy_FLAKY(t *testing.T) {
})
}
for _, rLevel := range []redundancy.Level{1, 2, 3, 4} {
rLevel := rLevel
t.Run(fmt.Sprintf("level=%d", rLevel), func(t *testing.T) {
for _, encrypt := range []bool{false, true} {
encrypt := encrypt
shardCnt := rLevel.GetMaxShards()
parityCnt := rLevel.GetParities(shardCnt)
if encrypt {
Expand All @@ -230,7 +228,6 @@ func TestBzzUploadDownloadWithRedundancy_FLAKY(t *testing.T) {
case 3:
chunkCnt = shardCnt*shardCnt + 1
}
levels := levels
t.Run(fmt.Sprintf("encrypt=%v levels=%d chunks=%d", encrypt, levels, chunkCnt), func(t *testing.T) {
if levels > 2 && (encrypt == (rLevel%2 == 1)) {
t.Skip("skipping to save time")
Expand Down Expand Up @@ -619,7 +616,6 @@ func TestBzzFilesRangeRequests(t *testing.T) {
}

for _, upload := range uploads {
upload := upload
t.Run(upload.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -886,7 +882,6 @@ func Test_bzzDownloadHandler_invalidInputs(t *testing.T) {
}}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -934,7 +929,6 @@ func TestInvalidBzzParams(t *testing.T) {
jsonhttptest.WithRequestBody(tr),
jsonhttptest.WithRequestHeader(api.ContentTypeHeader, api.ContentTypeTar),
)

})

t.Run("batch exists", func(t *testing.T) {
Expand Down Expand Up @@ -962,7 +956,6 @@ func TestInvalidBzzParams(t *testing.T) {
jsonhttptest.WithRequestBody(tr),
jsonhttptest.WithRequestHeader(api.ContentTypeHeader, api.ContentTypeTar),
)

})

t.Run("batch not found", func(t *testing.T) {
Expand Down Expand Up @@ -1057,7 +1050,6 @@ func TestInvalidBzzParams(t *testing.T) {
address := "f30c0aa7e9e2a0ef4c9b1b750ebfeaeb7c7c24da700bb089da19a46e3677824b"
jsonhttptest.Request(t, client, http.MethodGet, fmt.Sprintf("/bzz/%s/", address), http.StatusNotFound)
})

}

// TestDirectUploadBzz tests that the direct upload endpoint give correct error message in dev mode
Expand Down
6 changes: 0 additions & 6 deletions pkg/api/chequebook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ func TestChequebookLastCheques(t *testing.T) {
if !LastChequesEqual(got, expected) {
t.Fatalf("Got: \n %+v \n\n Expected: \n %+v \n\n", got, expected)
}

}

func TestChequebookLastChequesPeer(t *testing.T) {
Expand All @@ -433,7 +432,6 @@ func TestChequebookLastChequesPeer(t *testing.T) {
sig := make([]byte, 65)

lastSentChequeFunc := func(swarm.Address) (*chequebook.SignedCheque, error) {

sig := make([]byte, 65)

lastSentCheque := &chequebook.SignedCheque{
Expand All @@ -449,7 +447,6 @@ func TestChequebookLastChequesPeer(t *testing.T) {
}

lastReceivedChequeFunc := func(swarm.Address) (*chequebook.SignedCheque, error) {

lastReceivedCheque := &chequebook.SignedCheque{
Cheque: chequebook.Cheque{
Beneficiary: beneficiary0,
Expand Down Expand Up @@ -488,7 +485,6 @@ func TestChequebookLastChequesPeer(t *testing.T) {
if !reflect.DeepEqual(got, expected) {
t.Fatalf("Got: \n %+v \n\n Expected: \n %+v \n\n", got, expected)
}

}

func TestChequebookCashout(t *testing.T) {
Expand Down Expand Up @@ -753,7 +749,6 @@ func Test_chequebookLastPeerHandler_invalidInputs(t *testing.T) {
}}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand All @@ -765,7 +760,6 @@ func Test_chequebookLastPeerHandler_invalidInputs(t *testing.T) {
}

func LastChequesEqual(a, b *api.ChequebookLastChequesResponse) bool {

var state bool

for akeys := range a.LastCheques {
Expand Down
1 change: 0 additions & 1 deletion pkg/api/chunk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ func TestChunkHandlersInvalidInputs(t *testing.T) {

method := http.MethodGet
for _, tc := range tests {
tc := tc
t.Run(method+" "+tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
7 changes: 2 additions & 5 deletions pkg/api/cors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ func TestCORSHeaders(t *testing.T) {
wantCORS: false,
},
} {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -116,7 +115,6 @@ func TestCORSHeaders(t *testing.T) {
}
})
}

}

// TestCors tests whether CORs work correctly with OPTIONS method
Expand All @@ -135,7 +133,8 @@ func TestCors(t *testing.T) {
{
endpoint: "bzz",
expectedMethods: "POST",
}, {
},
{
endpoint: "bzz/0101011",
expectedMethods: "GET, HEAD",
},
Expand All @@ -156,7 +155,6 @@ func TestCors(t *testing.T) {
expectedMethods: "GET, HEAD",
},
} {
tc := tc
t.Run(tc.endpoint, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -212,7 +210,6 @@ func TestCorsStatus(t *testing.T) {
allowedMethods: "GET, HEAD",
},
} {
tc := tc
t.Run(tc.endpoint, func(t *testing.T) {
t.Parallel()

Expand Down
Loading
Loading