Skip to content

Commit 28c1fad

Browse files
authored
Merge pull request #6540 from oasisprotocol/peternose/internal/bump-go-1.26.3
go: Bump Go to 1.26.3
2 parents 2df371d + 18756c5 commit 28c1fad

70 files changed

Lines changed: 618 additions & 417 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changelog/6540.internal.1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
go: Bump Go to 1.26.3

.changelog/6540.internal.2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
go: Bump golangci-lint to v2.12.2

docker/oasis-core-dev/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
FROM ubuntu:24.04
22

33
# Package versions.
4-
ARG GO_VERSION=1.26.0
4+
ARG GO_VERSION=1.26.3
55
ARG GO_NANCY_VERSION=1.0.33
66
ARG GO_NANCY_CHECKSUM=a4bf5290d41b095c04f941ed5380674770c79d59735e33b1bd07a5cd5fbb135d
77
ARG GO_PROTOC_VERSION=3.6.1
88
ARG GO_PROTOC_GEN_GO_VERSION=1.21.0
9-
ARG GOLANGCILINT_VERSION=2.10.1
9+
ARG GOLANGCILINT_VERSION=2.12.2
1010
ARG GOCOVMERGE_VERSION=b5bfa59ec0adc420475f97f89b58045c721d761c
1111
ARG GOFUMPT_VERSION=v0.8.0
1212
ARG GOIMPORTS_VERSION=v0.36.0

docs/development-setup/prerequisites.md

Lines changed: 48 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33
The following is a list of prerequisites required to start developing on Oasis
44
Core:
55

6-
* Linux (if you are not on Linux, you will need to either set up a VM with the
6+
- Linux (if you are not on Linux, you will need to either set up a VM with the
77
proper environment or, if Docker is available for your platform, use the
88
provided Docker image which does this for you,
99
[see below](#using-the-development-docker-image)).
1010

11-
* System packages:
12-
* [Bubblewrap] (at least version 0.3.3).
13-
* [GCC] (including C++ subpackage).
14-
* [Clang] (including development package).
15-
* [Protobuf] compiler.
16-
* [GNU Make].
17-
* [CMake].
18-
* [pkg-config].
19-
* [OpenSSL] development package.
20-
* [libseccomp] development package.
11+
- System packages:
12+
- [Bubblewrap] (at least version 0.3.3).
13+
- [GCC] (including C++ subpackage).
14+
- [Clang] (including development package).
15+
- [Protobuf] compiler.
16+
- [GNU Make].
17+
- [CMake].
18+
- [pkg-config].
19+
- [OpenSSL] development package.
20+
- [libseccomp] development package.
2121

2222
_NOTE: On Ubuntu/Debian systems, compiling [mbedtls] crate when building the
2323
`oasis-core-runtime` binary requires having the `gcc-multilib` package
@@ -26,47 +26,52 @@ Core:
2626
On Fedora 29+, you can install all the above with:
2727

2828
<!-- markdownlint-disable line-length -->
29+
2930
```
3031
sudo dnf install bubblewrap gcc gcc-c++ clang-devel clang protobuf-compiler make cmake openssl-devel libseccomp-devel pkg-config
3132
```
33+
3234
<!-- markdownlint-enable line-length -->
3335

3436
On Ubuntu 18.10+ (18.04 LTS provides overly-old `bubblewrap`), you can install
3537
all the above with:
3638

3739
<!-- markdownlint-disable line-length -->
40+
3841
```
3942
sudo apt install bubblewrap gcc g++ gcc-multilib libclang-dev clang protobuf-compiler make cmake libssl-dev libseccomp-dev pkg-config
4043
```
44+
4145
<!-- markdownlint-enable line-length -->
4246

43-
* [Go] (at least version 1.26.0).
47+
- [Go] (at least version 1.26.3).
4448

4549
If your distribution provides a new-enough version of Go, just use that.
4650

4751
Please note that if you want to compile Oasis Core v22.1.9 or earlier,
4852
then go >=1.19 is not supported yet; you need to use 1.18.x.
4953

5054
Otherwise:
51-
* install the Go version provided by your distribution,
52-
* [ensure `$GOPATH/bin` is in your `PATH`](
53-
https://tip.golang.org/doc/code.html#GOPATH),
54-
* [install the desired version of Go](
55-
https://golang.org/doc/install#extra_versions), e.g. 1.26.0, with:
55+
- install the Go version provided by your distribution,
56+
- ensure `$GOPATH/bin` is in your
57+
[`PATH`](https://tip.golang.org/doc/code.html#GOPATH),
58+
- install the desired
59+
[version of Go](https://golang.org/doc/install#extra_versions),
60+
e.g. 1.26.3, with:
5661

5762
```
58-
go install golang.org/dl/go1.26.0@latest
59-
go1.26.0 download
63+
go install golang.org/dl/go1.26.3@latest
64+
go1.26.3 download
6065
```
6166
62-
* instruct the build system to use this particular version of Go by setting
67+
- instruct the build system to use this particular version of Go by setting
6368
the `OASIS_GO` environment variable in your `~/.bashrc`:
6469
6570
```
66-
export OASIS_GO=go1.26.0
71+
export OASIS_GO=go1.26.3
6772
```
6873
69-
* [Rust].
74+
- [Rust].
7075
7176
We follow [Rust upstream's recommendation][rust-upstream-rustup] on using
7277
[rustup] to install and manage Rust versions.
@@ -88,18 +93,20 @@ Core:
8893
This will run `rustup-init` which will download and install the latest stable
8994
version of Rust on your system.
9095
91-
* [Fortanix Rust EDP] utilities.
96+
- [Fortanix Rust EDP] utilities.
9297
9398
Install the Fortanix Rust EDP utilities by running:
9499
95100
<!-- markdownlint-disable line-length -->
101+
96102
```
97103
cargo install fortanix-sgx-tools
98104
cargo install sgxs-tools
99105
```
106+
100107
<!-- markdownlint-enable line-length -->
101108
102-
* Oasis Core's Rust toolchain version with Fortanix SGX target.
109+
- Oasis Core's Rust toolchain version with Fortanix SGX target.
103110
104111
The version of the Rust toolchain we use in Oasis Core is specified in the
105112
[`rust-toolchain.toml`] file.
@@ -129,7 +136,7 @@ Core:
129136
rustc 1.77.0-nightly (75c68cfd2 2024-01-07)
130137
```
131138
132-
* (**OPTIONAL**) [gofumpt] and [goimports].
139+
- (**OPTIONAL**) [gofumpt] and [goimports].
133140
134141
Required if you plan to change any of the Go code in order for automated code
135142
formatting (`make fmt`) to work.
@@ -141,7 +148,7 @@ Core:
141148
${OASIS_GO:-go} install golang.org/x/tools/cmd/goimports@v0.36.0
142149
```
143150
144-
* (**OPTIONAL**) [golangci-lint].
151+
- (**OPTIONAL**) [golangci-lint].
145152
146153
Required if you plan to change any of the Go code in order for automated code
147154
linting (`make lint`) to work.
@@ -151,10 +158,10 @@ Core:
151158
```
152159
curl -sSfL \
153160
https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \
154-
| sh -s -- -b $(${OASIS_GO:-go} env GOPATH)/bin v2.10.1
161+
| sh -s -- -b $(${OASIS_GO:-go} env GOPATH)/bin v2.12.2
155162
```
156163
157-
* (**OPTIONAL**) [protoc-gen-go].
164+
- (**OPTIONAL**) [protoc-gen-go].
158165
159166
Download and install it with:
160167
@@ -166,16 +173,18 @@ Core:
166173
`protoc-gen-go` to `/usr/local/bin` (which is in `$PATH`) with:_
167174
168175
<!-- markdownlint-disable line-length -->
176+
169177
```
170178
sudo GOBIN=/usr/local/bin ${OASIS_GO:-go} install google.golang.org/protobuf/cmd/protoc-gen-go@v1.21.0
171179
```
180+
172181
<!-- markdownlint-enable line-length -->
173182
174183
_NOTE: The repository has the most up-to-date files generated by protoc-gen-go
175-
committed for convenience. Installing protoc-gen-go is only required if you
184+
committed for convenience. Installing protoc-gen-go is only required if you
176185
are a developer making changes to protobuf definitions used by Go._
177186
178-
* (**OPTIONAL**) [jemalloc] (version 5.2.1, built with `'je_'` jemalloc-prefix)
187+
- (**OPTIONAL**) [jemalloc] (version 5.2.1, built with `'je_'` jemalloc-prefix)
179188
180189
Alternatively set `OASIS_BADGER_NO_JEMALLOC=1` environment variable when
181190
building `oasis-node` code, to build [BadgerDB] without `jemalloc` support.
@@ -214,6 +223,7 @@ In the following instructions, the top-level directory is the directory
214223
where the code has been checked out.
215224
216225
<!-- markdownlint-disable line-length -->
226+
217227
[Bubblewrap]: https://github.com/projectatomic/bubblewrap
218228
[GCC]: http://gcc.gnu.org/
219229
[Clang]: https://clang.llvm.org/
@@ -227,30 +237,27 @@ where the code has been checked out.
227237
[Go]: https://golang.org
228238
[rustup]: https://rustup.rs/
229239
[rust-upstream-rustup]: https://www.rust-lang.org/tools/install
230-
[download `rustup-init` executable for your platform]:
231-
https://github.com/rust-lang/rustup#other-installation-methods
240+
[download `rustup-init` executable for your platform]: https://github.com/rust-lang/rustup#other-installation-methods
232241
[Rust]: https://www.rust-lang.org/
233-
[`rust-toolchain.toml`]:
234-
https://github.com/oasisprotocol/oasis-core/tree/master/rust-toolchain.toml
235-
[rust-toolchain-precedence]:
236-
https://github.com/rust-lang/rustup/blob/master/README.md#override-precedence
242+
[`rust-toolchain.toml`]: https://github.com/oasisprotocol/oasis-core/tree/master/rust-toolchain.toml
243+
[rust-toolchain-precedence]: https://github.com/rust-lang/rustup/blob/master/README.md#override-precedence
237244
[Fortanix Rust EDP]: https://edp.fortanix.com
238245
[gofumpt]: https://github.com/mvdan/gofumpt
239246
[goimports]: https://pkg.go.dev/golang.org/x/tools/cmd/goimports
240247
[golangci-lint]: https://golangci-lint.run/
241248
[protoc-gen-go]: https://github.com/golang/protobuf
242249
[jemalloc]: https://github.com/jemalloc/jemalloc
243250
[BadgerDB]: https://github.com/dgraph-io/badger/
244-
[jemalloc-hardcode-path]:
245-
https://github.com/dgraph-io/ristretto/blob/221ca9b2091d12e5d24aa5d7d56e49745fc175d8/z/calloc_jemalloc.go#L9-L13
251+
[jemalloc-hardcode-path]: https://github.com/dgraph-io/ristretto/blob/221ca9b2091d12e5d24aa5d7d56e49745fc175d8/z/calloc_jemalloc.go#L9-L13
252+
246253
<!-- markdownlint-enable line-length -->
247254
248255
## Using the Development Docker Image
249256
250257
If for some reason you don't want or can't install the specified prerequisites
251-
on the host system, you can use our development Docker image. This requires that
252-
you have a [recent version of Docker installed](
253-
https://docs.docker.com/install/).
258+
on the host system, you can use our development Docker image. This requires
259+
that you have a
260+
[recent version of Docker installed](https://docs.docker.com/install/).
254261
255262
Oasis development environment with all the dependencies preinstalled is
256263
available in the `ghcr.io/oasisprotocol/oasis-core-dev:master` image.

go/common/cbor/codec.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@ import (
99
"github.com/prometheus/client_golang/prometheus"
1010
)
1111

12-
// Maximum message size.
13-
const maxMessageSize = 64 * 1024 * 1024 // 64 MiB
12+
const (
13+
// maxMessageSize is the maximum message size.
14+
maxMessageSize = 64 * 1024 * 1024 // 64 MiB
15+
// labelCall is the label for the call method.
16+
labelCall = "call"
17+
// labelModule is the label for the module name.
18+
labelModule = "module"
19+
)
1420

1521
var (
1622
errMessageTooLarge = errors.New("codec: message too large")
@@ -21,7 +27,7 @@ var (
2127
Name: "oasis_codec_size",
2228
Help: "CBOR codec message size (bytes).",
2329
},
24-
[]string{"call", "module"},
30+
[]string{labelCall, labelModule},
2531
)
2632

2733
codecCollectors = []prometheus.Collector{
@@ -47,7 +53,7 @@ func (c *MessageReader) Read(msg any) error {
4753
return err
4854
}
4955

50-
labels := prometheus.Labels{"module": c.module, "call": "read"}
56+
labels := prometheus.Labels{labelModule: c.module, labelCall: "read"}
5157
length := binary.BigEndian.Uint32(rawLength)
5258
codecValueSize.With(labels).Observe(float64(length))
5359
if length > maxMessageSize {
@@ -80,7 +86,7 @@ func (c *MessageWriter) Write(msg any) error {
8086
// Encode into CBOR.
8187
data := Marshal(msg)
8288
length := len(data)
83-
labels := prometheus.Labels{"module": c.module, "call": "write"}
89+
labels := prometheus.Labels{labelModule: c.module, labelCall: "write"}
8490
codecValueSize.With(labels).Observe(float64(length))
8591
if length > maxMessageSize {
8692
return errMessageTooLarge

go/common/crypto/tls/verify.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,20 @@ type VerifyOptions struct {
2424
AllowNoCertificate bool
2525
}
2626

27-
// VerifyCertificate verifies a TLS certificate as required by Oasis Core. Instead of using CAs,
27+
// VerifyCertificates verifies a TLS certificates as required by Oasis Core. Instead of using CAs,
2828
// public key pinning is used and certificates must follow the template.
29-
func VerifyCertificate(rawCerts [][]byte, opts VerifyOptions) error {
29+
func VerifyCertificates(certs []*x509.Certificate, opts VerifyOptions) error {
3030
// Allowing no certificate is useful in case access control is performed by a higher layer.
31-
if len(rawCerts) == 0 && opts.AllowNoCertificate {
31+
if len(certs) == 0 && opts.AllowNoCertificate {
3232
return nil
3333
}
3434

3535
// Make sure there is only a single certificate.
36-
if len(rawCerts) != 1 {
37-
return fmt.Errorf("tls: expecting a single certificate (got: %d)", len(rawCerts))
36+
if len(certs) != 1 {
37+
return fmt.Errorf("tls: expecting a single certificate (got: %d)", len(certs))
3838
}
3939

40-
cert, err := x509.ParseCertificate(rawCerts[0])
41-
if err != nil {
42-
return fmt.Errorf("tls: bad X509 certificate: %w", err)
43-
}
40+
cert := certs[0]
4441

4542
// Public key should match the pinned key.
4643
if cert.PublicKeyAlgorithm != x509.Ed25519 || cert.SignatureAlgorithm != x509.PureEd25519 {
@@ -53,7 +50,7 @@ func VerifyCertificate(rawCerts [][]byte, opts VerifyOptions) error {
5350
}
5451
if !opts.AllowUnknownKeys || opts.Keys != nil {
5552
var spk signature.PublicKey
56-
if err = spk.UnmarshalBinary(pk[:]); err != nil {
53+
if err := spk.UnmarshalBinary(pk[:]); err != nil {
5754
// This should NEVER happen.
5855
return fmt.Errorf("tls: bad public key: %w", err)
5956
}
@@ -113,7 +110,7 @@ func VerifyCertificate(rawCerts [][]byte, opts VerifyOptions) error {
113110
}
114111

115112
// Signature should be valid.
116-
if err = cert.CheckSignature(cert.SignatureAlgorithm, cert.RawTBSCertificate, cert.Signature); err != nil {
113+
if err := cert.CheckSignature(cert.SignatureAlgorithm, cert.RawTBSCertificate, cert.Signature); err != nil {
117114
return fmt.Errorf("tls: bad signature: %w", err)
118115
}
119116

go/common/crypto/tls/verify_test.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package tls
22

33
import (
44
"crypto/ed25519"
5+
"crypto/x509"
56
"testing"
67

78
"github.com/stretchr/testify/require"
@@ -19,36 +20,42 @@ func TestVerifyCertificate(t *testing.T) {
1920
signer := memory.NewFromRuntime(cert.PrivateKey.(ed25519.PrivateKey))
2021
signer2 := memory.NewTestSigner("common/crypto/tls: test signer")
2122

22-
rawCerts := cert.Certificate
23-
err = VerifyCertificate(rawCerts, VerifyOptions{
23+
certs := make([]*x509.Certificate, 0)
24+
for _, der := range cert.Certificate {
25+
c, err := x509.ParseCertificate(der)
26+
require.NoError(err, "ParseCertificate")
27+
certs = append(certs, c)
28+
}
29+
30+
err = VerifyCertificates(certs, VerifyOptions{
2431
CommonName: "my-common-name",
2532
Keys: map[signature.PublicKey]bool{
2633
signer.Public(): true,
2734
},
2835
})
2936
require.NoError(err, "VerifyCertificate")
3037

31-
err = VerifyCertificate(rawCerts, VerifyOptions{
38+
err = VerifyCertificates(certs, VerifyOptions{
3239
CommonName: "my-common-name",
3340
AllowUnknownKeys: true,
3441
})
3542
require.NoError(err, "VerifyCertificate")
3643

37-
err = VerifyCertificate(nil, VerifyOptions{
44+
err = VerifyCertificates(nil, VerifyOptions{
3845
CommonName: "my-common-name",
3946
AllowNoCertificate: true,
4047
})
4148
require.NoError(err, "VerifyCertificate")
4249

43-
err = VerifyCertificate(rawCerts, VerifyOptions{
50+
err = VerifyCertificates(certs, VerifyOptions{
4451
CommonName: "other-common-name",
4552
Keys: map[signature.PublicKey]bool{
4653
signer.Public(): true,
4754
},
4855
})
4956
require.Error(err, "VerifyCertificate should fail with mismatched common name")
5057

51-
err = VerifyCertificate(rawCerts, VerifyOptions{
58+
err = VerifyCertificates(certs, VerifyOptions{
5259
CommonName: "my-common-name",
5360
Keys: map[signature.PublicKey]bool{
5461
signer2.Public(): true,

0 commit comments

Comments
 (0)