Skip to content

Commit c4aa482

Browse files
authored
Merge pull request #7 from monad-developers/upstream
Merge upstreadm changes - reopened
2 parents c31cd52 + 7e3acf1 commit c4aa482

935 files changed

Lines changed: 30497 additions & 42797 deletions

File tree

Some content is hidden

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

.claude/commands/assess-eip.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Assess EIP
2+
3+
Structured assessment of EIP implementation complexity. When invoked with an EIP number or description, perform the following analysis.
4+
5+
## 1. Classify the Change Type(s)
6+
7+
- **New opcode** — requires: `vm/instructions/`, gas cost, `op_implementation` registration
8+
- **New precompile** — requires: `vm/precompiled_contracts/`, address constant, mapping, gas cost
9+
- **New transaction type** — requires: `transactions.py`, `fork.py` validation, exception types
10+
- **System contract** — requires: contract deployment in genesis, state handling
11+
- **Block header/body field** — requires: `blocks.py`, RLP encoding changes
12+
- **Gas cost change** — requires: `vm/gas.py` constant updates, possibly interpreter changes
13+
- **Execution layer request** — requires: request handling in `requests.py`
14+
- **Constraint change** — requires: validation logic in `fork.py` or `blocks.py`
15+
16+
## 2. Estimate Scope
17+
18+
- **Small** (1-2 files in spec, 1 test file): gas repricing, simple constraint
19+
- **Medium** (3-5 files in spec, 2-3 test files): new opcode, new precompile
20+
- **Large** (5-10 files in spec, 5+ test files): new tx type, new system contract
21+
- **XL** (10+ files, multi-EIP umbrella): VM overhaul (e.g., EOF)
22+
23+
## 3. Identify Required Test Categories
24+
25+
Map the change types to the relevant `EIPChecklist` categories (from `execution_testing.checklists.eip_checklist`). List the checklist items that need to be covered.
26+
27+
## 4. Identify Prior Art
28+
29+
Find similar completed EIPs in the repo to use as implementation reference:
30+
31+
- New opcode → check recent opcode additions in latest fork's `vm/instructions/`
32+
- New precompile → `tests/osaka/eip7951_p256verify_precompiles/`
33+
- New tx type → `tests/prague/eip7702_set_code_tx/`
34+
- Gas changes → check `vm/gas.py` diffs between recent forks
35+
36+
## 5. Output Structured Assessment
37+
38+
Produce a summary with:
39+
40+
- Change types identified
41+
- Estimated scope (Small / Medium / Large / XL)
42+
- Spec files to modify (with paths)
43+
- Test files to create
44+
- EIPChecklist categories to cover
45+
- Reference implementations to follow

.claude/commands/audit-config.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Audit Config
2+
3+
Periodic verification skill to prevent CLAUDE.md and skills from going stale. Run this manually to check freshness (e.g., after a major refactor, before a release, or when onboarding).
4+
5+
## Checks to Perform
6+
7+
### 1. Verify File Paths
8+
9+
Check that every file path or directory referenced in `CLAUDE.md` and `.claude/commands/*.md` still exists. Report any broken references.
10+
11+
### 2. Verify CLI Commands
12+
13+
Run `--help` on referenced commands and confirm mentioned flags still exist:
14+
15+
- `uv run fill --help`
16+
- `uv run ethereum-spec-new-fork --help`
17+
- `uv run ethereum-spec-lint --help`
18+
- `uv run checklist --help`
19+
20+
### 3. Verify Code Patterns
21+
22+
Spot-check code patterns mentioned in skills against actual code:
23+
24+
- Does `op_implementation` dict exist in the latest fork's `vm/instructions/__init__.py`?
25+
- Does `PRE_COMPILED_CONTRACTS` exist in the latest fork's `vm/precompiled_contracts/mapping.py`?
26+
- Does the `Ops` enum exist in `vm/instructions/__init__.py`?
27+
- Does `FORK_CRITERIA` or equivalent exist in the latest fork's `__init__.py`?
28+
29+
### 4. Verify Fork List
30+
31+
Check that the fork order and default branch mentioned in `CLAUDE.md` match reality by inspecting `src/ethereum/forks/` and git branch configuration.
32+
33+
### 5. Verify Docs References
34+
35+
Confirm that `docs/` paths referenced in skills still exist:
36+
37+
- `docs/writing_tests/`
38+
- `docs/writing_tests/opcode_metadata.md`
39+
- `docs/writing_tests/checklist_templates/`
40+
- `docs/filling_tests/`
41+
42+
## Output
43+
44+
Produce a summary with:
45+
46+
- **Current**: references that are still valid
47+
- **Stale**: references that need updating, with suggested fixes

.claude/commands/edit-workflow.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Edit Workflow
2+
3+
GitHub Actions conventions. Run this skill before modifying workflow files in `.github/`.
4+
5+
## Action Version Pinning (Required)
6+
7+
All actions must be pinned to commit SHA with version comment:
8+
9+
```yaml
10+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
11+
```
12+
13+
- Never use version tags alone (`@v4` is wrong)
14+
- Local actions (`./.github/actions/*`) are exempt from pinning
15+
16+
## Validation
17+
18+
Run `uvx tox -e static` before committing — this runs `actionlint` to validate YAML syntax and structure.

.claude/commands/eip-checklist.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# EIP Checklist
2+
3+
Guide for using the EIP testing checklist system to track test coverage. Run this skill when working on EIP test coverage or checklists.
4+
5+
## What It Is
6+
7+
The `EIPChecklist` class (in `execution_testing.checklists.eip_checklist`) provides a hierarchical marker system for tagging tests with what aspect of an EIP they cover. Categories include:
8+
9+
- `General`, `Opcode`, `Precompile`, `SystemContract`, `TransactionType`
10+
- `BlockHeaderField`, `BlockBodyField`, `GasCostChanges`, `GasRefundsChanges`
11+
- `ExecutionLayerRequest`, `BlobCountChanges`
12+
13+
Each category has deep sub-items (e.g., `EIPChecklist.Opcode.Test.GasUsage.Normal`).
14+
15+
## Usage in Tests
16+
17+
```python
18+
@EIPChecklist.TransactionType.Test.IntrinsicValidity.GasLimit.Exact()
19+
def test_exact_intrinsic_gas(state_test: StateTestFiller):
20+
...
21+
22+
# Multi-EIP coverage:
23+
@EIPChecklist.TransactionType.Test.Signature.Invalid.V.Two(eip=[2930])
24+
def test_invalid_v(state_test: StateTestFiller):
25+
...
26+
```
27+
28+
## Generating Checklists
29+
30+
Run `uv run checklist` to generate coverage reports. Template at `docs/writing_tests/checklist_templates/eip_testing_checklist_template.md`.
31+
32+
## Marking Items as Externally Covered or N/A
33+
34+
Create `eip_checklist_external_coverage.txt` in the EIP test directory:
35+
36+
```
37+
general/code_coverage/eels = Covered by EELS test suite
38+
```
39+
40+
Create `eip_checklist_not_applicable.txt` for inapplicable items:
41+
42+
```
43+
system_contract = EIP-7702 does not introduce a system contract
44+
precompile/ = EIP-7702 does not introduce a precompile
45+
```
46+
47+
(trailing `/` marks entire category as N/A)
48+
49+
## Completed Examples
50+
51+
Reference these for patterns:
52+
53+
- `tests/prague/eip7702_set_code_tx/` — comprehensive checklist for a transaction type EIP
54+
- `tests/osaka/eip7951_p256verify_precompiles/` — precompile checklist example
55+
56+
## References
57+
58+
See `docs/writing_tests/checklist_templates/` for templates and detailed documentation.

.claude/commands/fill-tests.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Fill Tests
2+
3+
CLI reference for the `fill` command. Run this skill before filling test fixtures. The `fill` command is pytest-based — all standard pytest flags work.
4+
5+
## Basic Usage
6+
7+
```
8+
uv run fill tests/ # Fill all tests
9+
uv run fill tests/cancun/ --fork Cancun # Specific fork
10+
uv run fill tests/path/to/test.py -k "test_name" # Specific test
11+
uv run fill tests/osaka/ --until Osaka # Up to fork (inclusive)
12+
uv run fill --collect-only tests/ # Dry run: list tests without executing
13+
```
14+
15+
## Key Flags
16+
17+
- `--fork FORK` / `--until FORK` — target specific fork or range
18+
- `--output DIR` + `--clean` — output directory; `--clean` required when re-filling
19+
- `-k "pattern"` — filter tests by name pattern
20+
- `-m "marker"` — filter by pytest marker (e.g. `-m state_test`, `-m blockchain_test`)
21+
- `-n auto --maxprocesses N` — parallel execution (use `--dist=loadgroup`)
22+
- `--evm-bin PATH` — specify t8n tool (default: `ethereum-spec-evm-resolver`)
23+
- `--verify-fixtures` — verify generated fixtures against geth blocktest
24+
- `--generate-all-formats` — generate all fixture formats (2-phase)
25+
26+
## Debugging
27+
28+
- `--evm-dump-dir DIR` — dump t8n input/output for debugging
29+
- `--traces` — collect execution traces
30+
- `--pdb` — drop into debugger on failure
31+
- `-vv` — verbose output; `-x` — stop on first failure; `-s` — print stdout
32+
33+
## Watch Mode
34+
35+
- `--watch` — re-run on file changes (clears screen between runs)
36+
- `--watcherfall` — same but keeps output history
37+
38+
## Benchmark Tests
39+
40+
- Must use `-m benchmark` — benchmark tests are excluded by default
41+
- Require evmone as backend: `--evm-bin=evmone-t8n`
42+
- Default benchmark fork is Prague (set in `tests/benchmark/conftest.py`)
43+
- Gas values mode: `--gas-benchmark-values 1,10,100` (values in millions of gas)
44+
- Fixed opcode count mode: `--fixed-opcode-count 1,10,100` (values in thousands)
45+
- These two modes are **mutually exclusive**
46+
- Use `--generate-pre-alloc-groups` for stateful benchmarks
47+
48+
## Static Tests (Legacy)
49+
50+
- `uv run fill --fill-static-tests tests/static/` — fills YAML/JSON fillers from `ethereum/tests`
51+
- Legacy only — do NOT add new static fillers. Use Python tests instead
52+
- Useful to check if spec changes broke how legacy tests fill
53+
54+
## Fixture Formats
55+
56+
One test function auto-generates multiple formats: `StateFixture`, `BlockchainFixture`, `BlockchainEngineFixture`. Use `--generate-all-formats` for additional formats via 2-phase execution.
57+
58+
## References
59+
60+
See `docs/filling_tests/` for detailed documentation.

.claude/commands/grammar-check.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Grammar Check
2+
3+
Audit grammar in documentation and code comments.
4+
5+
## Files to Check
6+
7+
Check `$ARGUMENTS` (default: `src/`). Use Glob to find:
8+
9+
- `**/*.py` - check docstrings and `#` comments only
10+
- `**/*.md` - check prose content, skip code blocks
11+
12+
## What to Detect
13+
14+
1. Missing prepositions ("refer the" → "refer to the", "comply the" → "comply with the")
15+
2. Subject-verb disagreement
16+
3. Missing articles where required
17+
4. Incorrect word order
18+
5. Sentence fragments in documentation
19+
6. Double words ("the the", "is is")
20+
21+
## What to Ignore
22+
23+
- Code syntax and variable names
24+
- Technical terms, EIP numbers, hex values
25+
- Intentional shorthand in inline code comments
26+
- Content inside code blocks (``` or indented blocks in markdown)
27+
- URLs and email addresses
28+
29+
## Output Format
30+
31+
For each issue, output a clickable link with line number:
32+
33+
```
34+
path/to/file.md:42 - "original problematic text"
35+
Suggestion: "corrected text"
36+
Reason: brief explanation
37+
```
38+
39+
For issues spanning multiple lines, use range format:
40+
41+
```
42+
path/to/file.py:15-17 - "multi-line docstring issue"
43+
Suggestion: "corrected text"
44+
Reason: brief explanation
45+
```
46+
47+
## Process
48+
49+
1. Find all matching files
50+
2. For `.md` files: check full prose content, skip code blocks
51+
3. For `.py` files: extract and check only docstrings (triple-quoted) and `#` comments
52+
4. Group findings by file
53+
5. End with summary: "Found N grammar issues in M files." or "No grammar issues found."
54+
55+
## Important
56+
57+
- Report findings only, do not auto-fix
58+
- Be conservative: only flag clear errors, not style preferences
59+
- When uncertain, skip rather than false-positive

.claude/commands/implement-eip.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Implement EIP
2+
3+
Patterns for implementing spec changes in `src/ethereum/forks/`. Run this skill before implementing an EIP or modifying fork code.
4+
5+
## Fork Directory Layout
6+
7+
Each fork lives at `src/ethereum/forks/<fork_name>/`. Explore the latest fork directory for current structure. Key files:
8+
9+
- `__init__.py` — FORK_CRITERIA, fork metadata
10+
- `fork.py` — state transition functions
11+
- `blocks.py` — block structure and validation
12+
- `transactions.py` — transaction types and processing
13+
- `state.py` — state trie operations
14+
- `vm/instructions/__init__.py` — Ops enum + `op_implementation` dict
15+
- `vm/gas.py` — gas constants and calculations
16+
- `vm/precompiled_contracts/__init__.py` — precompile address constants
17+
- `vm/precompiled_contracts/mapping.py``PRE_COMPILED_CONTRACTS` registry
18+
19+
## Import Isolation (enforced by `ethereum-spec-lint`)
20+
21+
- **Within same fork**: relative imports (`from . import vm`, `from .state import ...`)
22+
- **Previous fork only**: absolute imports (`from ethereum.cancun import ...`)
23+
- **Shared modules**: always OK (`ethereum.crypto`, `ethereum.utils`, `ethereum.exceptions`)
24+
- **Future forks**: NEVER allowed
25+
- **Ancient forks (2+ back)**: NEVER allowed
26+
- Run `ethereum-spec-lint` to verify before committing
27+
28+
## Adding a New Opcode
29+
30+
1. Add to `Ops` enum in `vm/instructions/__init__.py` with hex value
31+
2. Implement function in appropriate `vm/instructions/<category>.py` — follows pattern: STACK → GAS (`charge_gas`) → OPERATION → PROGRAM COUNTER
32+
3. Register in `op_implementation` dict in `vm/instructions/__init__.py`
33+
4. Add gas constant in `vm/gas.py` if needed
34+
35+
## Adding a New Precompile
36+
37+
1. Define address constant in `vm/precompiled_contracts/__init__.py` using `hex_to_address("0x...")`
38+
2. Create implementation file `vm/precompiled_contracts/<name>.py`
39+
3. Register in `PRE_COMPILED_CONTRACTS` dict in `vm/precompiled_contracts/mapping.py`
40+
4. Add gas constant in `vm/gas.py`
41+
42+
## Adding a New Transaction Type
43+
44+
1. Define `@slotted_freezable @dataclass` class in `transactions.py`
45+
2. Add to `Transaction` union type at bottom of file
46+
3. Handle in `fork.py` validation/processing logic
47+
4. Add exception type in `exceptions.py` if needed
48+
49+
## Creating a New Fork
50+
51+
```bash
52+
uv run ethereum-spec-new-fork --new-fork=<name> --template-fork=<template>
53+
```
54+
55+
- Copies all files from template fork and applies codemods (renames, constant updates)
56+
- After running: update `__init__.py` docstring, fork-specific constants, run `uv run ruff format`
57+
- Fork criteria types: `ByBlockNumber(N)` (pre-merge), `ByTimestamp(T)` (post-merge), `Unscheduled(order_index=N)` (in development)
58+
59+
## Branch Naming
60+
61+
- Feature branches: `eips/<fork_name>/eip-<number>`
62+
- PR targets: `forks/<fork_name>`

.claude/commands/lint.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Lint
2+
3+
Run the full static analysis suite and fix issues. This matches the CI check on every PR.
4+
5+
## Step 1: Run the Full Check
6+
7+
```bash
8+
uvx tox -e static
9+
```
10+
11+
This runs ruff, mypy, codespell, ethereum-spec-lint, and actionlint in one pass. If everything passes, you're done.
12+
13+
## Step 2: Auto-Fix Formatting and Lint Issues
14+
15+
If tox reports ruff errors, run these first — they resolve most issues automatically:
16+
17+
```bash
18+
uv run ruff format
19+
uv run ruff check --fix
20+
```
21+
22+
## Step 3: Resolve Remaining Issues Manually
23+
24+
After auto-fix, re-run to see what's left:
25+
26+
```bash
27+
uvx tox -e static
28+
```
29+
30+
- **Remaining ruff issues**: fix manually (auto-fix can't handle all rules)
31+
- **mypy errors**: fix type annotations, add missing types, correct signatures
32+
- **codespell errors**: fix typos, or add intentional words to `whitelist.txt`
33+
- **ethereum-spec-lint errors**: fix import isolation violations (see `/implement-eip` for import rules)
34+
- **actionlint errors**: fix workflow YAML issues (see `/edit-workflow`)
35+
36+
## Step 4: Final Verification
37+
38+
Re-run until clean:
39+
40+
```bash
41+
uvx tox -e static
42+
```

0 commit comments

Comments
 (0)