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

ci: improvements #451

Merged
merged 6 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
74 changes: 0 additions & 74 deletions .github/workflows/codeql.yml
jsign marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/dependency-review.yml

This file was deleted.

74 changes: 40 additions & 34 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,52 @@
name: Go lint and test
name: Lint & test

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
workflow_dispatch:
branches: [master]
workflow_dispatch:

jobs:
build:
runs-on: self-hosted
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.18
- name: Build
run: go build -v ./...
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Targeting the same version as the minimum required today in go-ethereum.

- name: Build
run: go build -v ./...

lint:
runs-on: self-hosted
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Download golangci-lint
run: wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s latest
- name: Lint
run: ./bin/golangci-lint run
- name: Vet
run: go vet

- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.22
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.60
- name: Vet
run: go vet

test:
runs-on: self-hosted
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Running tests in three OSs.

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Test
run: go test -v -race ./...
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Test
run: go test -v -race ./... -timeout=15m
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Looks like the macos-latest is a bit slow, so it requires a bit more time.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Uhm, last run took 7m. But I saw at least one take >10min thus failing.
Let's keep 15m since maybe GH have different machines -- let's avoid potential false positives.

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/ethereum/go-verkle

go 1.19
go 1.22

require (
github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c
Expand Down
4 changes: 3 additions & 1 deletion proof_ipa.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,9 @@ func Verify(vp *VerkleProof, preStateRoot []byte, postStateRoot []byte, statedif
}

rootC := new(Point)
rootC.SetBytes(preStateRoot)
if err := rootC.SetBytes(preStateRoot); err != nil {
return fmt.Errorf("error setting prestate root: %w", err)
}
pretree, err := PreStateTreeFromProof(proof, rootC)
if err != nil {
return fmt.Errorf("error rebuilding the pre-tree from proof: %w", err)
Expand Down
24 changes: 11 additions & 13 deletions tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import (
"errors"
"fmt"
"io"
mRand "math/rand"
mRandV1 "math/rand"
Copy link
Member

Choose a reason for hiding this comment

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

can we not convert everything to v2?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unfortuantely no until we can use Go v1.23 which creates an API to do that exactly.

mRand "math/rand/v2"
"reflect"
"runtime"
"sort"
Expand Down Expand Up @@ -688,8 +689,6 @@ func benchmarkCommitNLeaves(b *testing.B, n int) {
}

func BenchmarkModifyLeaves(b *testing.B) {
mRand.Seed(time.Now().UnixNano()) // skipcq: GO-S1033

n := 200000
toEdit := 10000
val := []byte{0}
Expand All @@ -714,8 +713,7 @@ func BenchmarkModifyLeaves(b *testing.B) {
for i := 0; i < b.N; i++ {
binary.BigEndian.PutUint32(val, uint32(i))
for j := 0; j < toEdit; j++ {
// skipcq: GSC-G404
k := keys[mRand.Intn(n)]
k := keys[mRand.IntN(n)]
if err := root.Insert(k, val, nil); err != nil {
b.Error(err)
}
Expand Down Expand Up @@ -1454,8 +1452,8 @@ func TestBatchMigratedKeyValues(t *testing.T) {
for i := 0; i < iterations; i++ {
runtime.GC()

// ***Insert the key pairs 'naively' ***
rand := mRand.New(mRand.NewSource(42)) //skipcq: GSC-G404
// Insert the key pairs 'naively'
rand := mRandV1.New(mRandV1.NewSource(42))
tree := genRandomTree(rand, treeInitialKeyValCount)
randomKeyValues := genRandomKeyValues(rand, migrationKeyValueCount)

Expand All @@ -1471,8 +1469,8 @@ func TestBatchMigratedKeyValues(t *testing.T) {
}
unbatchedDuration += time.Since(now)

// ***Insert the key pairs with optimized strategy & methods***
rand = mRand.New(mRand.NewSource(42)) //skipcq: GSC-G404
// Insert the key pairs with optimized strategy & methods
rand = mRandV1.New(mRandV1.NewSource(42))
tree = genRandomTree(rand, treeInitialKeyValCount)
randomKeyValues = genRandomKeyValues(rand, migrationKeyValueCount)

Expand Down Expand Up @@ -1528,7 +1526,7 @@ func TestBatchMigratedKeyValues(t *testing.T) {
}
}

func genRandomTree(rand *mRand.Rand, keyValueCount int) VerkleNode {
func genRandomTree(rand *mRandV1.Rand, keyValueCount int) VerkleNode {
tree := New()
for _, kv := range genRandomKeyValues(rand, keyValueCount) {
if err := tree.Insert(kv.key, kv.value, nil); err != nil {
Expand All @@ -1543,7 +1541,7 @@ type keyValue struct {
value []byte
}

func genRandomKeyValues(rand *mRand.Rand, count int) []keyValue {
func genRandomKeyValues(rand *mRandV1.Rand, count int) []keyValue {
ret := make([]keyValue, count)
for i := 0; i < count; i++ {
keyval := make([]byte, 64)
Expand All @@ -1564,7 +1562,7 @@ func BenchmarkBatchLeavesInsert(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
b.StopTimer()
rand := mRand.New(mRand.NewSource(42)) //skipcq: GSC-G404
rand := mRandV1.New(mRandV1.NewSource(42)) //skipcq: GSC-G404
tree := genRandomTree(rand, treeInitialKeyValCount)
randomKeyValues := genRandomKeyValues(rand, migrationKeyValueCount)
b.StartTimer()
Expand Down Expand Up @@ -1724,7 +1722,7 @@ const (

// Generate implements the quick.Generator interface from testing/quick
// to generate random test cases.
func (randTest) Generate(r *mRand.Rand, size int) reflect.Value {
func (randTest) Generate(r *mRandV1.Rand, size int) reflect.Value {
var finishedFn = func() bool {
if size == 0 {
return true
Expand Down