Skip to content

Commit bb6fff4

Browse files
Merge branch 'main' into bing/utils-is-valid-attestation-slot
2 parents f165c53 + bb37a46 commit bb6fff4

File tree

560 files changed

+26853
-7565
lines changed

Some content is hidden

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

560 files changed

+26853
-7565
lines changed

.claude/settings.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"$schema": "https://json.schemastore.org/claude-code-settings.json",
3+
"permissions": {
4+
"allow": [
5+
"Bash(zig build *)",
6+
"Bash(zig test *)",
7+
"Bash(zig fmt *)",
8+
"Bash(pnpm biome *)",
9+
"Bash(pnpm install)",
10+
"Bash(git status *)",
11+
"Bash(git diff *)",
12+
"Bash(git log *)",
13+
"Bash(git branch *)",
14+
"Bash(git show *)",
15+
"Bash(git fetch *)",
16+
"Bash(gh pr *)",
17+
"Bash(gh issue *)",
18+
"Bash(gh api *)",
19+
"Bash(gh run *)",
20+
"Bash(gh search *)",
21+
"Bash(grep *)",
22+
"Bash(find *)",
23+
"Bash(cat *)",
24+
"Bash(head *)",
25+
"Bash(tail *)",
26+
"Bash(wc *)",
27+
"Bash(ls *)"
28+
],
29+
"deny": [
30+
"Bash(rm -rf / *)",
31+
"Bash(sudo *)"
32+
]
33+
},
34+
"enabledPlugins": {
35+
"ethereum-rnd@lodestar-claude-plugins": true,
36+
"consensus-clients@lodestar-claude-plugins": true,
37+
"zig-lsp@lodestar-claude-plugins": true
38+
},
39+
"extraKnownMarketplaces": {
40+
"lodestar-claude-plugins": {
41+
"source": {
42+
"source": "github",
43+
"repo": "ChainSafe/lodestar-claude-plugins"
44+
}
45+
}
46+
}
47+
}

.gemini/styleguide.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,17 @@ Code](https://spinroot.com/gerard/pdf/P10.pdf) will change the way you code fore
9090
- and use VOPR as the final line of defense, to find bugs in your and reviewer's understanding
9191
of code.
9292

93-
- All memory must be statically allocated at startup. **No memory may be dynamically allocated (or
94-
freed and reallocated) after initialization.** This avoids unpredictable behavior that can
95-
significantly affect performance, and avoids use-after-free. As a second-order effect, it is our
96-
experience that this also makes for more efficient, simpler designs that are more performant and
93+
- Most memory should be statically allocated at startup, where **possible** and **optimal**.
94+
TigerBeetle does all allocation at startup but that is nearly impossible for Lodestar's use case,
95+
since some data changes from epoch to epoch.
96+
97+
This makes for more efficient, simpler designs that are more performant and
9798
easier to maintain and reason about, compared to designs that do not consider all possible memory
9899
usage patterns upfront as part of the design.
99100

101+
As such, we should aspire to define boundaries to make
102+
this possible, but we should not blindly avoid dynamic memory allocation.
103+
100104
- Declare variables at the **smallest possible scope**, and **minimize the number of variables in
101105
scope**, to reduce the probability that variables are misused.
102106

@@ -209,7 +213,7 @@ Beyond these rules:
209213
understand the domain. Take time to find the perfect name, to find nouns and verbs that work
210214
together, so that the whole is greater than the sum of its parts.
211215

212-
- Use `camelCase` for function, and variable names. Use `snake_case` for file names. The underscore is the closest thing we
216+
- Use `camelCase` for function names. Use `snake_case` for file names and variable names. The underscore is the closest thing we
213217
have as programmers to a space, and helps to separate words and encourage descriptive names. We
214218
don't use Zig's `CamelCase.zig` style for "struct" files to keep the convention simple and
215219
consistent.
@@ -424,4 +428,4 @@ hitting a Bash/Shell/OS-specific issue.
424428

425429
Standardizing on Zig for tooling is important to ensure that we reduce dimensionality, as the team,
426430
and therefore the range of personal tastes, grows. This may be slower for you in the short term, but
427-
makes for more velocity for the team in the long term.
431+
makes for more velocity for the team in the long term.

.github/workflows/CI.yml

Lines changed: 126 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ concurrency:
1414

1515
env:
1616
ZIG_VERSION: "0.14.1"
17+
NODE_VERSION: "24"
1718

1819
jobs:
1920
zbuild:
@@ -90,18 +91,31 @@ jobs:
9091
- name: Run config tests
9192
run: |
9293
zig build test:config
94+
- name: Run constants tests
95+
run: |
96+
zig build test:constants
9397
- name: Run consensus-type tests
9498
run: |
9599
zig build test:consensus_types
100+
- name: Run fork_types tests
101+
run: |
102+
zig build test:fork_types
103+
- name: Run era tests
104+
run: |
105+
zig build test:era
96106
- name: Run preset tests
97107
run: |
98108
zig build test:preset
109+
- name: Run bls tests
110+
run: |
111+
zig build test:bls
99112
- name: Run state-transition tests
100113
run: |
101114
zig build test:state_transition
102-
- name: Run Int Tests
115+
116+
- name: Build benchmarks
103117
run: |
104-
zig build test:int
118+
zig build build-exe:bench_hashing build-exe:bench_merkle_gindex build-exe:bench_merkle_node build-exe:bench_ssz_attestation build-exe:bench_ssz_block build-exe:bench_ssz_state build-exe:bench_process_block build-exe:bench_process_epoch
105119
106120
build-test-slow:
107121
name: slow tests
@@ -126,7 +140,7 @@ jobs:
126140
zig build run:download_era_files
127141
- name: Run slow int tests
128142
run: |
129-
zig build test:int_slow
143+
zig build test:int
130144
131145
spec-test-ssz:
132146
name: spec tests - ssz
@@ -169,6 +183,33 @@ jobs:
169183
run: |
170184
zig build test:ssz_static_spec_tests -Dpreset=mainnet
171185
186+
spec-test-bls:
187+
name: spec tests - bls
188+
runs-on: ubuntu-latest
189+
needs: build-test
190+
steps:
191+
- name: Checkout Repository
192+
uses: actions/checkout@v4
193+
- name: Install Zig
194+
uses: mlugg/setup-zig@v2
195+
with:
196+
version: ${{ env.ZIG_VERSION }}
197+
cache-key: ubuntu-latest-${{ env.ZIG_VERSION }}
198+
- name: Restore spec tests cache
199+
uses: actions/cache@v4
200+
with:
201+
path: test/spec/spec_tests
202+
key: spec-test-data-${{ hashFiles('build.zig') }}
203+
- name: Download spec tests
204+
run: |
205+
zig build run:download_spec_tests
206+
- name: Write BLS spec tests
207+
run: |
208+
zig build run:write_bls_spec_tests
209+
- name: Run BLS spec tests
210+
run: |
211+
zig build test:bls_spec_tests
212+
172213
spec-test-minimal:
173214
name: spec tests - minimal
174215
# It takes time to download and run spec tests, so we only run them on ubuntu-latest
@@ -226,3 +267,85 @@ jobs:
226267
- name: Run spec tests - mainnet
227268
run: |
228269
zig build test:spec_tests -Dpreset=mainnet
270+
271+
build-fuzz:
272+
name: build fuzz harnesses
273+
runs-on: ubuntu-latest
274+
needs: build-test
275+
steps:
276+
- name: Checkout Repository
277+
uses: actions/checkout@v4
278+
- name: Install Zig
279+
uses: mlugg/setup-zig@v2
280+
with:
281+
version: ${{ env.ZIG_VERSION }}
282+
cache-key: ubuntu-latest-${{ env.ZIG_VERSION }}
283+
- name: Install AFL++ and LLVM
284+
run: |
285+
sudo apt-get update
286+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y afl++ llvm
287+
- name: Verify AFL++ and LLVM are available
288+
run: |
289+
afl-cc --version
290+
if command -v llvm-config >/dev/null 2>&1; then
291+
llvm-config --version
292+
else
293+
llvm-config-18 --version
294+
fi
295+
- name: Build fuzz harnesses
296+
run: |
297+
cd test/fuzz && zig build
298+
299+
bindings-test:
300+
name: bindings - test
301+
runs-on: ubuntu-latest
302+
steps:
303+
- name: Checkout Repository
304+
uses: actions/checkout@v4
305+
- name: Setup pnpm
306+
uses: pnpm/action-setup@v4
307+
- name: Setup Node.js
308+
uses: actions/setup-node@v6
309+
with:
310+
node-version: ${{ env.NODE_VERSION }}
311+
cache: pnpm
312+
- name: Install Zig
313+
uses: mlugg/setup-zig@v2
314+
with:
315+
version: ${{ env.ZIG_VERSION }}
316+
cache-key: ubuntu-latest-${{ env.ZIG_VERSION }}
317+
- name: Install dependencies
318+
run: |
319+
pnpm install
320+
- name: Run bindings formatter
321+
run: |
322+
pnpm biome ci
323+
- name: Build bindings
324+
run: |
325+
zig build build-lib:bindings -Doptimize=ReleaseSafe
326+
- name: Restore era files cache
327+
uses: actions/cache@v4
328+
with:
329+
path: fixtures/era
330+
key: era-files-${{ hashFiles('build.zig') }} # downloaded era files defined in build.zig
331+
- name: Download era files
332+
run: |
333+
zig build run:download_era_files
334+
- name: Test bindings
335+
run: |
336+
pnpm test
337+
338+
build-examples:
339+
name: build examples
340+
runs-on: ubuntu-latest
341+
steps:
342+
- name: Checkout Repository
343+
uses: actions/checkout@v4
344+
- name: Install Zig
345+
uses: mlugg/setup-zig@v2
346+
with:
347+
version: ${{ env.ZIG_VERSION }}
348+
cache-key: ubuntu-latest-${{ env.ZIG_VERSION }}
349+
- name: Build metrics example
350+
run: |
351+
zig build build-exe:metrics_stf
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: "Lint PR title"
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
- labeled
10+
- unlabeled
11+
12+
jobs:
13+
main:
14+
name: Validate PR title
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: amannn/action-semantic-pull-request@v5
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
with:
21+
# Configure which types are allowed (newline-delimited).
22+
# Default: https://github.com/commitizen/conventional-commit-types
23+
# Customized based on sections defined in scripts/generate_changelog.mjs
24+
types: |
25+
feat
26+
fix
27+
perf
28+
refactor
29+
revert
30+
deps
31+
build
32+
ci
33+
test
34+
style
35+
chore
36+
docs
37+
38+
# Configure which scopes are allowed (newline-delimited).
39+
# These are regex patterns auto-wrapped in `^ $`.
40+
#scopes: |
41+
42+
# Configure that a scope must always be provided.
43+
requireScope: false
44+
45+
# Configure which scopes are disallowed in PR titles (newline-delimited).
46+
# For instance by setting the value below, `chore(release): ...` (lowercase)
47+
# and `ci(e2e,release): ...` (unknown scope) will be rejected.
48+
# These are regex patterns auto-wrapped in `^ $`.
49+
#disallowScopes: |
50+
51+
# Configure additional validation for the subject based on a regex.
52+
# This example ensures the subject doesn't start with an uppercase character.
53+
subjectPattern: ^(?![A-Z]).+$
54+
55+
# If `subjectPattern` is configured, you can use this property to override
56+
# the default error message that is shown when the pattern doesn't match.
57+
# The variables `subject` and `title` can be used within the message.
58+
subjectPatternError: |
59+
The subject "{subject}" found in the pull request title "{title}"
60+
didn't match the configured pattern. Please ensure that the subject
61+
doesn't start with an uppercase character.
62+
63+
# If the PR contains one of these newline-delimited labels, the
64+
# validation is skipped. If you want to rerun the validation when
65+
# labels change, you might want to use the `labeled` and `unlabeled`
66+
# event triggers in your workflow.
67+
ignoreLabels: |
68+
bot
69+
ignore-semantic-pull-request
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Publish NAPI Bindings
2+
on:
3+
workflow_dispatch:
4+
5+
env:
6+
ZIG_VERSION: "0.14.1"
7+
NODE_VERSION: "24"
8+
9+
jobs:
10+
publish-bindings:
11+
name: publish bindings
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout Repository
15+
uses: actions/checkout@v4
16+
- name: Setup pnpm
17+
uses: pnpm/action-setup@v4
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v6
20+
with:
21+
node-version: ${{ env.NODE_VERSION }}
22+
cache: pnpm
23+
- name: Install Zig
24+
uses: mlugg/setup-zig@v2
25+
with:
26+
version: ${{ env.ZIG_VERSION }}
27+
cache-key: ubuntu-latest-${{ env.ZIG_VERSION }}
28+
- name: Install dependencies
29+
run: |
30+
pnpm install
31+
- name: Run bindings formatter
32+
run: |
33+
pnpm biome ci
34+
- name: Build and publish to npm
35+
run: |
36+
pnpm zapi build-artifacts --optimize ReleaseSafe
37+
pnpm zapi prepublish
38+
pnpm zapi publish --access public
39+

.gitignore

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,18 @@ test/spec/test_case/
55
*.ssz
66
test/spec/ssz/generic_tests.zig
77
test/spec/ssz/static_tests.zig
8-
*.era
8+
test/spec/bls/spec_tests.zig
9+
*.era
10+
*.pkix
11+
12+
# perf
13+
flamegraph.html
14+
perf.data
15+
perf.data.old
16+
17+
# js
18+
node_modules/
19+
20+
# Claude Code local config
21+
.claude/settings.local.json
22+
.claude/plans/

0 commit comments

Comments
 (0)