Skip to content
Open
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
75 changes: 75 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"permissions": {
"allow": [
"Read",
"Edit",
"Write",
"Glob",
"Grep",
"Bash(git status *)",
"Bash(git diff *)",
"Bash(git log *)",
"Bash(git add *)",
"Bash(git commit *)",
"Bash(git branch *)",
"Bash(git checkout *)",
"Bash(git switch *)",
"Bash(git merge *)",
"Bash(git rebase *)",
"Bash(git stash *)",
"Bash(git fetch *)",
"Bash(git pull *)",
"Bash(git show *)",
"Bash(git blame *)",
"Bash(git cherry-pick *)",
"Bash(git tag *)",
"Bash(git reset --soft HEAD~1)",
"Bash(go build *)",
"Bash(go test *)",
"Bash(go vet *)",
"Bash(go mod *)",
"Bash(go fmt *)",
"Bash(go run *)",
"Bash(bazel build *)",
"Bash(bazel test *)",
"Bash(bazel query *)",
"Bash(bazel run *)",
"Bash(rm *.tmp)",
"Bash(rm *.log)",
"Bash(rm *.bak)",
"Bash(rm *.go)",
"Bash(rm *.proto)",
"Bash(rm *.bazel)",
"Bash(ls *)",
"Bash(wc *)",
"Bash(find *)",
"Bash(mkdir *)",
"Bash(cp *)",
"Bash(rsync *)",
"Bash(cat *)",
"Bash(grep *)",
"Bash(echo *)",
"Bash(tmux has-session:*)",
"WebFetch(domain:github.com)"
],
"deny": [
"Bash(git push *)",
"Bash(git reset --hard *)",
"Bash(git clean *)",
"Bash(rm -r *)",
"Bash(rm -f *)",
"Bash(rm -rf *)",
"Bash(rm -fr *)",
"Bash(rm -r -f *)",
"Bash(rm -f -r *)",
"Bash(rm /* *)",
"Bash(find * -exec *)",
"Bash(find * -delete *)",
"Bash(find * -ok *)",
"Bash(echo * > /*)",
"Bash(sudo *)",
"Bash(chmod *)",
"Bash(chown *)"
]
}
}
41 changes: 41 additions & 0 deletions .claude/skills/e2e/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
name: e2e
description: Run Prysm end-to-end tests. Use after significant changes to verify system integration.
invocation: user
---

# E2E Test Runner

## Usage
- `/e2e` — run basic MinimalConfig (default)
- `/e2e current-fork` — run CurrentFork only (fastest)
- `/e2e builder` — run with builder (MEV changes)
- `/e2e api` — run with REST API (API changes)
- `/e2e slasher` — run with slasher

## Test Map

| Argument | Test Filter | When to use |
|---|---|---|
| (default) | `TestEndToEnd_MinimalConfig` | General/core logic changes |
| `current-fork` | `TestEndToEnd_MinimalConfig_CurrentFork` | Quick sanity check |
| `builder` | `TestEndToEnd_MinimalConfig_WithBuilder` | Builder/MEV changes |
| `api` | `TestEndToEnd_MinimalConfig_ValidatorRESTApi` | API changes |
| `slasher` | `TestEndToEnd_Slasher_MinimalConfig` | Slasher changes |

## Command Template
```bash
cd ~/prysm
bazel test //testing/endtoend:go_default_test \
--//proto:network=minimal \
--test_filter=<TEST_FILTER> \
--test_env=E2E_EPOCHS=10 \
--test_timeout=10000 \
--test_output=streamed
```

## Notes
- E2E tests take several minutes to run
- They spin up actual beacon nodes, validators, and eth1 nodes
- Stream output so progress is visible
- If E2E fails, check component logs in the test output for root cause
67 changes: 67 additions & 0 deletions .claude/skills/pr/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
name: pr
description: Full PR workflow for Prysm — precheck, test, commit, and push to fork
invocation: user
---

# PR Workflow

Complete workflow to prepare and push a Prysm PR.

## Steps

### 1. Pre-checks
Run all pre-commit checks (same as `/precheck`):
- gofmt
- goimports
- gazelle sync
- bazel build

### 2. Unit Tests
Run tests on affected packages (same as `/test`):
- Determine affected packages from diff
- Run bazel test
- Compare against baseline
- Fail if NEW test failures exist

### 3. E2E (if applicable)
Determine if E2E is needed based on changed files:
- `beacon-chain/` changes → run `TestEndToEnd_MinimalConfig`
- `api/` or `rpc/` changes → run `TestEndToEnd_MinimalConfig_ValidatorRESTApi`
- `validator/` changes → run `TestEndToEnd_MinimalConfig`
- Config-only or docs changes → skip E2E

### 4. Commit
```bash
cd ~/prysm
git add -A
git commit -m "<type>: <description>

<body explaining what and why>

Fixes #<issue-number>"
```

Commit types: `fix`, `feat`, `refactor`, `test`, `chore`, `docs`

### 5. Push to Fork
```bash
git push fork <branch-name>
```

⚠️ **NEVER push to origin.** Always push to `fork`.

### 6. Report
```
✅ PR ready!
Branch: <branch-name>
Fork: https://github.com/syjn99/prysm/tree/<branch-name>
Changes: <summary>

Jun, ready for you to open the upstream PR when you're happy with it.
```

## Rules
- Do NOT run `gh pr create` against OffchainLabs/prysm
- Do NOT merge anything
- Jun opens upstream PRs manually
73 changes: 73 additions & 0 deletions .claude/skills/precheck/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
name: precheck
description: Run pre-commit checks (gofmt, goimports, gazelle, hack scripts) before committing Prysm changes
invocation: user
---

# Pre-commit Checks

Run these checks in order on the Prysm repo. Stop and report if any fail.

## Steps

1. **gofmt check** — Ensure all changed .go files are formatted:
```bash
cd ~/prysm
gofmt -l $(git diff --name-only --diff-filter=ACM HEAD | grep '\.go$')
```
If output is non-empty, run `gofmt -w` on those files.

2. **goimports check** — Ensure imports are organized:
```bash
goimports -l $(git diff --name-only --diff-filter=ACM HEAD | grep '\.go$')
```
If output is non-empty, run `goimports -w` on those files.

3. **Gazelle deps.bzl sync**:
```bash
bazel run //:gazelle -- update-repos -from_file=go.mod -to_macro=deps.bzl%prysm_deps -prune=true
git diff --exit-code deps.bzl
```

4. **Gazelle BUILD.bazel sync**:
```bash
bazel run //:gazelle -- fix --mode=diff
```
If diff output is non-empty, run `bazel run //:gazelle -- fix` to auto-fix.

5. **Update generated protobuf files** (if proto files changed):
```bash
hack/update-go-pbs.sh
```

6. **Update generated SSZ files** (if SSZ-related files changed):
```bash
hack/update-go-ssz.sh
```

7. **Update mock files** (if proto service definitions changed):
```bash
hack/update-mockgen.sh
```

8. **Bazel build**:
```bash
bazel build //...
```

## When to run hack scripts
- `hack/update-go-pbs.sh` — when `.proto` files are modified
- `hack/update-go-ssz.sh` — when SSZ-tagged structs are modified
- `hack/update-mockgen.sh` — when proto service interfaces change
- If unsure, run all three — they're idempotent

## Known Warnings (ignore these)
- `go-bip39 file path replacement` — known gazelle limitation
- `date: illegal option` on macOS — workspace_status.sh uses Linux date syntax
- `config/fieldparams/BUILD.bazel: could not merge expression` — known gazelle limitation

## On Success
Report: "✅ All pre-checks passed. Ready to commit."

## On Failure
Report which check failed and suggest the fix command.
51 changes: 51 additions & 0 deletions .claude/skills/test/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
name: test
description: Run Prysm unit tests with baseline comparison. Use when testing changes locally.
invocation: user
---

# Unit Test Runner with Baseline Comparison

## Usage
- `/test` — test affected packages only (based on git diff)
- `/test //beacon-chain/sync/...` — test specific package
- `/test //...` — test everything (slow)

## Steps

1. **Determine test targets**:
- If user specified a target, use that
- Otherwise, find affected packages from git diff:
```bash
cd ~/prysm
git diff --name-only HEAD | grep '\.go$' | xargs -I{} dirname {} | sort -u | sed 's|^|//|;s|$|/...|'
```

2. **Run tests**:
```bash
cd ~/prysm
bazel test <targets> \
--keep_going \
--test_output=errors \
--flaky_test_attempts=3 \
--jobs=4 \
--nostamp \
--build_tests_only
```

3. **Compare against baseline**:
- Read `~/.openclaw/workspace-coding/prysm-baseline-tests.json`
- If a test failure exists in baseline → report as "known failure (pre-existing), ignore"
- If a test failure is NOT in baseline → report as "NEW failure, needs fixing"

4. **Report results**:
```
✅ Passed: X tests
⚠️ Known failures (pre-existing): Y tests
❌ New failures: Z tests
- //package:test_name — error summary
```

## Notes
- If baseline file doesn't exist yet, report all failures as-is and suggest running `/test //...` on clean develop to create baseline
- Flaky tests that pass on retry are fine
49 changes: 49 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Prysm – Ethereum Consensus Layer Client

Module: `github.com/OffchainLabs/prysm/v7` | Go 1.25.1 | Branch: `develop`

> ⚠️ **NEVER commit this file or the `.claude/` directory. Both are excluded via `.git/info/exclude`.**

## Architecture

Executables (`cmd/`): `beacon-chain`, `validator`, `prysmctl`, `client-stats`

- `beacon-chain/core/` – State transitions per fork (Phase0→Altair→Bellatrix→Capella→Deneb→Electra→Fulu→Gloas)
- `beacon-chain/blockchain/` – Block processing, fork choice, execution engine
- `beacon-chain/state/` – BeaconState: copy-on-write, ReadOnly/WriteOnly interfaces
- `beacon-chain/db/` – BoltDB + filesystem (blobs, data columns)
- `beacon-chain/p2p/`, `sync/` – libp2p networking, gossipsub
- `validator/` – Key mgmt, slashing protection, duties
- `api/` – REST + gRPC | `proto/` – Protobuf defs | `consensus-types/` – Wrapped read-only interfaces
- `config/params/` – Chain params | `config/features/` – Feature flags

## Skills

- `/precheck` — gofmt, goimports, gazelle, hack scripts, build
- `/test` — unit tests with baseline comparison
- `/e2e` — end-to-end tests
- `/pr` — full PR workflow (precheck → test → e2e → commit → push)

## Patterns

- **Service Registry**: `runtime.ServiceRegistry` – lifecycle Start/Stop/Status
- **Functional Options**: `WithXxx` for DI (e.g. `blockchain.WithDatabase(db)`)
- **Interface Segregation**: ReadOnly/WriteOnly sub-interfaces; use narrowest type
- **Fork detection**: `block.Version()`, `state.Version()`; per-fork sub-packages in `core/`
- **State immutability**: Copy-on-write; call `state.Copy()` before mutating shared state
- Use `interfaces.ReadOnlySignedBeaconBlock` etc. over concrete proto types

## Build Tags

`develop` (required for `go test`), `minimal`/`mainnet` (config size), `fuzz`, `debug` (E2E)

## Testing

- `testing/assert/` (non-fatal), `testing/require/` (fatal) – custom helpers, not testify
- `DeepSSZEqual` for proto/SSZ comparison
- Spec tests: `testing/spectest/{mainnet,minimal}/` – tag-gated
- E2E: `testing/endtoend/` – multi-node in-process

## Nogo Analyzers

20+ custom analyzers in `tools/analyzers/` enforced by Bazel. Key rules: `cryptorand` (no math/rand), `errcheck`, `logcapitalization` (lowercase logs), `nopanic` (no panics), `featureconfig`, `recursivelock`. Build fails on violations.