Skip to content

Commit 3961602

Browse files
committed
Merge branch 'main' into rkuris/change-proofs
2 parents 9950f8c + 289d442 commit 3961602

File tree

20 files changed

+1029
-168
lines changed

20 files changed

+1029
-168
lines changed
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
name: attach-static-libs
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
create_branch_name:
7+
description: "Name of the new branch to create and attach static libs"
8+
required: true
9+
push:
10+
tags:
11+
- "*"
12+
pull_request:
13+
14+
env:
15+
CARGO_TERM_COLOR: always
16+
17+
# Build, upload, and collect static libraries for each target architecture,
18+
# so that golang projects can import the FFI package without needing to
19+
# recompile Firewood locally.
20+
# Supported architectures are:
21+
# - x86_64-unknown-linux-gnu
22+
# - aarch64-unknown-linux-gnu
23+
# - x86_64-apple-darwin
24+
# - aarch64-apple-darwin
25+
jobs:
26+
# Build the static libraries for each target architecture and upload
27+
# them as artifacts to collect and attach in the next job.
28+
build-firewood-ffi-libs:
29+
runs-on: ${{ matrix.os }}
30+
strategy:
31+
matrix:
32+
include:
33+
- os: ubuntu-latest
34+
target: x86_64-unknown-linux-gnu
35+
- os: ubuntu-22.04-arm
36+
target: aarch64-unknown-linux-gnu
37+
- os: macos-latest
38+
target: aarch64-apple-darwin
39+
- os: macos-13
40+
target: x86_64-apple-darwin
41+
steps:
42+
- uses: actions/checkout@v4
43+
- uses: dtolnay/rust-toolchain@stable
44+
- uses: arduino/setup-protoc@v3
45+
with:
46+
repo-token: ${{ secrets.GITHUB_TOKEN }}
47+
- uses: Swatinem/rust-cache@v2
48+
49+
- name: Build for ${{ matrix.target }}
50+
run: cargo build --profile maxperf --features ethhash,logger --target ${{ matrix.target }} -p firewood-ffi
51+
52+
- name: Upload binary
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: ${{ matrix.target }}
56+
path: target/${{ matrix.target }}/maxperf/libfirewood_ffi.a
57+
if-no-files-found: error
58+
59+
# Collect all the static libraries built on the previous matrix of jobs
60+
# and add them into ffi/libs directory.
61+
# We commit and push this as a new branch with "--force" to overwrite
62+
# the previous static libs that will not be on our branch.
63+
push-firewood-ffi-libs:
64+
needs: build-firewood-ffi-libs
65+
runs-on: ubuntu-latest
66+
outputs:
67+
target_branch: ${{ steps.determine_branch.outputs.target_branch }}
68+
steps:
69+
- name: Determine branch name
70+
id: determine_branch
71+
run: |
72+
if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ github.event.inputs.create_branch_name }}" ]]; then
73+
export target_branch="${{ github.event.inputs.create_branch_name }}"
74+
echo "Using workflow input as target branch: $target_branch"
75+
echo "target_branch=$target_branch" >> "$GITHUB_OUTPUT"
76+
elif [[ "${{ github.event_name }}" == "push" && "${{ github.ref_type }}" == "tag" ]]; then
77+
export target_branch="${GITHUB_REF#refs/tags/}"
78+
echo "Using tag name as target_branch: $target_branch"
79+
echo "target_branch=$target_branch" >> "$GITHUB_OUTPUT"
80+
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
81+
export target_branch="${{ github.event.pull_request.head.ref }}"
82+
echo "Using PR head name as target branch: $target_branch"
83+
echo "target_branch=$target_branch" >> "$GITHUB_OUTPUT"
84+
else
85+
echo "No valid input or tag found."
86+
exit 1
87+
fi
88+
89+
- uses: actions/checkout@v4
90+
with:
91+
path: firewood
92+
93+
- uses: actions/checkout@v4
94+
with:
95+
repository: ava-labs/firewood-go
96+
token: ${{ secrets.FIREWOOD_GO_GITHUB_TOKEN }}
97+
path: firewood-go
98+
99+
- name: Copy FFI Source Code
100+
run: cp -r firewood/ffi firewood-go
101+
102+
- name: Download binaries into libs directory
103+
uses: actions/download-artifact@v4
104+
with:
105+
path: firewood-go/ffi/libs
106+
107+
- name: List downloaded target directory
108+
run: find firewood-go -type f | sort
109+
110+
- name: Push static libs to branch
111+
working-directory: firewood-go
112+
# GITHUB_TOKEN is configured in the last actions/checkout step
113+
# to have read/write permissions to the firewood-go repo.
114+
run: |
115+
git config --global user.name "FirewoodCI"
116+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
117+
git checkout -b ${{ steps.determine_branch.outputs.target_branch }}
118+
git add .
119+
git commit -m "firewood ci ${{ github.sha }}: attach firewood static libs"
120+
121+
if [[ "${{ github.ref_type }}" == "tag" ]]; then
122+
git tag -a "${GITHUB_REF#refs/tags/}" -m "firewood ci ${{ github.sha }}: attach firewood static libs"
123+
git push origin "refs/tags/${GITHUB_REF#refs/tags/}"
124+
else
125+
git push -u origin ${{ steps.determine_branch.outputs.target_branch }} --force
126+
fi
127+
128+
# Check out the branch created in the previous job on a matrix of
129+
# our target architectures and test the FFI package on a fresh
130+
# machine without re-compiling Firewood locally.
131+
# This tests that the Firewood FFI package passes tests on the target
132+
# architecture when it is forced to depend on the attached static libs.
133+
test-firewood-ffi-libs:
134+
runs-on: ${{ matrix.os }}
135+
strategy:
136+
matrix:
137+
os: [ubuntu-latest, ubuntu-22.04-arm, macos-latest, macos-13]
138+
needs: push-firewood-ffi-libs
139+
continue-on-error: true
140+
steps:
141+
- uses: actions/checkout@v4
142+
with:
143+
repository: ava-labs/firewood-go
144+
token: ${{ secrets.FIREWOOD_GO_GITHUB_TOKEN }}
145+
ref: ${{ needs.push-firewood-ffi-libs.outputs.target_branch }}
146+
- name: Set up Go
147+
uses: actions/setup-go@v5
148+
with:
149+
go-version-file: "ffi/go.mod"
150+
cache-dependency-path: "ffi/go.sum"
151+
- name: Test Go FFI bindings
152+
working-directory: ffi
153+
# cgocheck2 is expensive but provides complete pointer checks
154+
run: GOEXPERIMENT=cgocheck2 TEST_FIREWOOD_HASH_MODE=ethhash go test ./...
155+
156+
remove-if-pr-only:
157+
runs-on: ubuntu-latest
158+
needs: [push-firewood-ffi-libs, test-firewood-ffi-libs]
159+
if: needs.push-firewood-ffi-libs.result == 'success' && github.event_name == 'pull_request'
160+
permissions:
161+
# Give the GITHUB_TOKEN write permission to delete the
162+
# branch created by the previous job if it is a pull request.
163+
contents: write
164+
steps:
165+
- uses: actions/checkout@v4
166+
with:
167+
repository: ava-labs/firewood-go
168+
token: ${{ secrets.FIREWOOD_GO_GITHUB_TOKEN }}
169+
ref: ${{ needs.push-firewood-ffi-libs.outputs.target_branch }}
170+
- name: Delete branch
171+
run: |
172+
git push origin --delete ${{ needs.push-firewood-ffi-libs.outputs.target_branch }}

.github/workflows/ci.yaml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: ci
22

33
on:
44
pull_request:
5-
branches: ['*']
65
push:
76
branches: [main]
87

@@ -106,7 +105,10 @@ jobs:
106105

107106
ffi:
108107
needs: build
109-
runs-on: ubuntu-latest
108+
runs-on: ${{ matrix.os }}
109+
strategy:
110+
matrix:
111+
os: [ubuntu-latest, macos-latest]
110112
steps:
111113
- uses: actions/checkout@v4
112114
- uses: dtolnay/rust-toolchain@stable
@@ -125,10 +127,15 @@ jobs:
125127
with:
126128
go-version-file: "ffi/go.mod"
127129
cache-dependency-path: "ffi/go.sum"
130+
- name: Run golanci-lint
131+
uses: golangci/golangci-lint-action@v3
132+
with:
133+
version: latest
134+
working-directory: ffi
128135
- name: Test Go FFI bindings
129136
working-directory: ffi
130137
# cgocheck2 is expensive but provides complete pointer checks
131-
run: GOEXPERIMENT=cgocheck2 go test ./...
138+
run: GOEXPERIMENT=cgocheck2 TEST_FIREWOOD_HASH_MODE=firewood go test ./...
132139

133140
ethhash:
134141
runs-on: ubuntu-latest
@@ -146,6 +153,10 @@ jobs:
146153
with:
147154
go-version-file: "ffi/tests/go.mod"
148155
cache-dependency-path: "ffi/tests/go.sum"
156+
- name: Test Go FFI bindings
157+
working-directory: ffi
158+
# cgocheck2 is expensive but provides complete pointer checks
159+
run: GOEXPERIMENT=cgocheck2 TEST_FIREWOOD_HASH_MODE=ethhash go test ./...
149160
- name: Test Ethereum hash compatability
150161
working-directory: ffi/tests
151162
run: go test ./...

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# CODEOWNERS
22
* @rkuris @aaronbuchwald
3-
3+
/ffi @alarso16

ffi/.golangci.yaml

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# https://golangci-lint.run/usage/configuration/
2+
run:
3+
timeout: 10m
4+
5+
# If set we pass it to "go list -mod={option}". From "go help modules":
6+
# If invoked with -mod=readonly, the go command is disallowed from the implicit
7+
# automatic updating of go.mod described above. Instead, it fails when any changes
8+
# to go.mod are needed. This setting is most useful to check that go.mod does
9+
# not need updates, such as in a continuous integration and testing system.
10+
# If invoked with -mod=vendor, the go command assumes that the vendor
11+
# directory holds the correct copies of dependencies and ignores
12+
# the dependency descriptions in go.mod.
13+
#
14+
# Allowed values: readonly|vendor|mod
15+
# By default, it isn't set.
16+
modules-download-mode: readonly
17+
18+
issues:
19+
# Make issues output unique by line.
20+
# Default: true
21+
uniq-by-line: false
22+
23+
# Maximum issues count per one linter.
24+
# Set to 0 to disable.
25+
# Default: 50
26+
max-issues-per-linter: 0
27+
28+
# Maximum count of issues with the same text.
29+
# Set to 0 to disable.
30+
# Default: 3
31+
max-same-issues: 0
32+
33+
# Enables skipping of directories:
34+
# - vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
35+
# Default: true
36+
exclude-dirs-use-default: false
37+
38+
linters:
39+
disable-all: true
40+
enable:
41+
- asciicheck
42+
- bodyclose
43+
- copyloopvar
44+
- depguard
45+
- dupword
46+
- dupl
47+
- errcheck
48+
- errname
49+
- errorlint
50+
- forbidigo
51+
- gci
52+
- goconst
53+
- gocritic
54+
# - err113 - encourages wrapping static errors
55+
- gofmt
56+
- gofumpt
57+
# - mnd - unnecessary magic numbers
58+
- goprintffuncname
59+
- gosec
60+
- gosimple
61+
- govet
62+
- importas
63+
- ineffassign
64+
# - lll line length linter
65+
- misspell
66+
- nakedret
67+
- nilerr
68+
- noctx
69+
- nolintlint
70+
- perfsprint
71+
- prealloc
72+
- predeclared
73+
- revive
74+
- spancheck
75+
- staticcheck
76+
- stylecheck
77+
- tagalign
78+
- testifylint
79+
- typecheck
80+
- unconvert
81+
- unparam
82+
- unused
83+
- usestdlibvars
84+
- whitespace
85+
86+
linters-settings:
87+
depguard:
88+
rules:
89+
packages:
90+
deny:
91+
- pkg: "github.com/golang/mock/gomock"
92+
desc: go.uber.org/mock/gomock should be used instead.
93+
- pkg: "github.com/stretchr/testify/assert"
94+
desc: github.com/stretchr/testify/require should be used instead.
95+
- pkg: "io/ioutil"
96+
desc: io/ioutil is deprecated. Use package io or os instead.
97+
errorlint:
98+
# Check for plain type assertions and type switches.
99+
asserts: false
100+
# Check for plain error comparisons.
101+
comparison: false
102+
forbidigo:
103+
# Forbid the following identifiers (list of regexp).
104+
forbid:
105+
- 'require\.Error$(# ErrorIs should be used instead)?'
106+
- 'require\.ErrorContains$(# ErrorIs should be used instead)?'
107+
- 'require\.EqualValues$(# Equal should be used instead)?'
108+
- 'require\.NotEqualValues$(# NotEqual should be used instead)?'
109+
- '^(t|b|tb|f)\.(Fatal|Fatalf|Error|Errorf)$(# the require library should be used instead)?'
110+
revive:
111+
rules:
112+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bool-literal-in-expr
113+
- name: bool-literal-in-expr
114+
disabled: false
115+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#early-return
116+
- name: early-return
117+
disabled: false
118+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-lines
119+
- name: empty-lines
120+
disabled: false
121+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-format
122+
- name: string-format
123+
disabled: false
124+
arguments:
125+
- ["b.Logf[0]", "/.*%.*/", "no format directive, use b.Log instead"]
126+
- ["fmt.Errorf[0]", "/.*%.*/", "no format directive, use errors.New instead"]
127+
- ["fmt.Fprintf[1]", "/.*%.*/", "no format directive, use fmt.Fprint instead"]
128+
- ["fmt.Printf[0]", "/.*%.*/", "no format directive, use fmt.Print instead"]
129+
- ["fmt.Sprintf[0]", "/.*%.*/", "no format directive, use fmt.Sprint instead"]
130+
- ["log.Fatalf[0]", "/.*%.*/", "no format directive, use log.Fatal instead"]
131+
- ["log.Printf[0]", "/.*%.*/", "no format directive, use log.Print instead"]
132+
- ["t.Logf[0]", "/.*%.*/", "no format directive, use t.Log instead"]
133+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#struct-tag
134+
- name: struct-tag
135+
disabled: false
136+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-naming
137+
- name: unexported-naming
138+
disabled: false
139+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unhandled-error
140+
- name: unhandled-error
141+
# prefer the errcheck linter since it can be disabled directly with nolint directive
142+
# but revive's disable directive (e.g. //revive:disable:unhandled-error) is not
143+
# supported when run under golangci_lint
144+
disabled: true
145+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter
146+
- name: unused-parameter
147+
disabled: false
148+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-receiver
149+
- name: unused-receiver
150+
disabled: false
151+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break
152+
- name: useless-break
153+
disabled: false
154+
tagalign:
155+
align: true
156+
sort: true
157+
strict: true
158+
order:
159+
- serialize
160+
testifylint:
161+
# Enable all checkers (https://github.com/Antonboom/testifylint#checkers).
162+
# Default: false
163+
enable-all: true
164+
# Disable checkers by name
165+
# (in addition to default
166+
# suite-thelper
167+
# ).
168+
disable:
169+
- go-require
170+
- float-compare

0 commit comments

Comments
 (0)