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 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
63 changes: 31 additions & 32 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ name: "CodeQL"

on:
push:
branches: [ "master" ]
branches: ["master"]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "master" ]
branches: ["master"]
schedule:
- cron: '30 17 * * 1'
- cron: "30 17 * * 1"

jobs:
analyze:
Expand All @@ -32,43 +32,42 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'go' ]
language: ["go"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
6 changes: 3 additions & 3 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# Source repository: https://github.com/actions/dependency-review-action
# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
name: 'Dependency Review'
name: "Dependency Review"
on: [pull_request]

permissions:
Expand All @@ -14,7 +14,7 @@ jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
- name: "Checkout Repository"
uses: actions/checkout@v3
- name: 'Dependency Review'
- name: "Dependency Review"
uses: actions/dependency-review-action@v3
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
- name: Build
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.

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]
runs-on: ${{ matrix.os }}
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.

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
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
Loading