|
| 1 | +# EIP Checklist Generation |
| 2 | + |
| 3 | +The EIP checklist feature helps track test coverage for EIP implementations by automatically generating filled checklists based on test markers. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +When implementing tests for an EIP, you can mark specific tests as covering checklist items from the [EIP testing checklist template](../writing_tests/checklist_templates/eip_testing_checklist_template.md). The framework will then generate a filled checklist showing which items have been implemented. |
| 8 | + |
| 9 | +## Using the `pytest.mark.eip_checklist` Marker |
| 10 | + |
| 11 | +To mark a test as implementing a specific checklist item: |
| 12 | + |
| 13 | +```python |
| 14 | +import pytest |
| 15 | +from ethereum_test_tools import StateTestFiller |
| 16 | + |
| 17 | +@pytest.mark.eip_checklist("new_transaction_type/test/intrinsic_validity/gas_limit/exact") |
| 18 | +def test_exact_intrinsic_gas(state_test: StateTestFiller): |
| 19 | + """Test transaction with exact intrinsic gas limit.""" |
| 20 | + # Test implementation |
| 21 | + pass |
| 22 | +``` |
| 23 | + |
| 24 | +### Marker Parameters |
| 25 | + |
| 26 | +- **First positional parameter** (required): The checklist item ID from the template |
| 27 | +- **`eip` keyword parameter** (optional): List of additional EIPs covered by the test |
| 28 | + |
| 29 | +Example with multiple EIPs covered by the same test: |
| 30 | + |
| 31 | +```python |
| 32 | +@pytest.mark.eip_checklist("new_transaction_type/test/signature/invalid/v/0", eip=[7702, 2930]) |
| 33 | +def test_invalid_signature(state_test: StateTestFiller): |
| 34 | + """Test invalid signature that affects multiple EIPs.""" |
| 35 | + pass |
| 36 | +``` |
| 37 | + |
| 38 | +### Partial ID Matching |
| 39 | + |
| 40 | +You can use partial IDs that will match all checklist items starting with that prefix: |
| 41 | + |
| 42 | +```python |
| 43 | +# This will mark all items under "new_transaction_type/test/signature/invalid/" as covered |
| 44 | +@pytest.mark.eip_checklist("new_transaction_type/test/signature/invalid/") |
| 45 | +def test_all_invalid_signatures(state_test: StateTestFiller): |
| 46 | + """Test covering all invalid signature scenarios.""" |
| 47 | + pass |
| 48 | +``` |
| 49 | + |
| 50 | +## Generating Checklists |
| 51 | + |
| 52 | +### Using the Dedicated `checklist` Command |
| 53 | + |
| 54 | +To generate only checklists without filling fixtures: |
| 55 | + |
| 56 | +```bash |
| 57 | +# Generate checklists for all EIPs |
| 58 | +uv run checklist |
| 59 | + |
| 60 | +# Generate checklist for specific EIP |
| 61 | +uv run checklist --eip 7702 |
| 62 | + |
| 63 | +# Specify output directory |
| 64 | +uv run checklist --output ./my-checklists |
| 65 | + |
| 66 | +# Multiple EIPs |
| 67 | +uv run checklist --eip 7702 --eip 2930 |
| 68 | +``` |
| 69 | + |
| 70 | +### Automatic Generation in Documentation |
| 71 | + |
| 72 | +When building the documentation with `mkdocs`, checklists are automatically generated for all EIPs that have tests with checklist markers. The checklists appear in the test documentation alongside the test modules. |
| 73 | + |
| 74 | +## External Coverage and Not Applicable Items |
| 75 | + |
| 76 | +### External Coverage |
| 77 | + |
| 78 | +For checklist items that are covered by external tests, procedures, or tools (e.g., EELS coverage), create a file named `eip_checklist_external_coverage.txt` in the EIP test directory: |
| 79 | + |
| 80 | +```text |
| 81 | +# tests/prague/eip7702_set_code_tx/eip_checklist_external_coverage.txt |
| 82 | +general/code_coverage/eels = Covered by EELS test suite |
| 83 | +general/code_coverage/second_client = Covered by Nethermind tests |
| 84 | +``` |
| 85 | + |
| 86 | +Format: `checklist_item_id = reason` |
| 87 | + |
| 88 | +### Not Applicable Items |
| 89 | + |
| 90 | +For checklist items that are not applicable to a specific EIP, create a file named `eip_checklist_not_applicable.txt` in the EIP test directory: |
| 91 | + |
| 92 | +```text |
| 93 | +# tests/prague/eip7702_set_code_tx/eip_checklist_not_applicable.txt |
| 94 | +new_system_contract = EIP-7702 does not introduce a system contract |
| 95 | +new_precompile = EIP-7702 does not introduce a precompile |
| 96 | +``` |
| 97 | + |
| 98 | +Format: `checklist_item_id = reason` |
| 99 | + |
| 100 | +Both files support partial ID matching, so you can mark entire sections as not applicable: |
| 101 | + |
| 102 | +```text |
| 103 | +# Mark all system contract items as not applicable |
| 104 | +new_system_contract/ = EIP does not introduce system contracts |
| 105 | +``` |
| 106 | + |
| 107 | +## Output Format |
| 108 | + |
| 109 | +The generated checklist will show: |
| 110 | + |
| 111 | +- ✅ for completed items (either by tests or external coverage) |
| 112 | +- N/A for not applicable items |
| 113 | +- Test names that implement each item |
| 114 | +- External coverage reasons where applicable |
| 115 | +- A percentage of covered checklist items (excluding N/A items) |
| 116 | +- Color-coded completion status: 🟢 (100%), 🟡 (>50%), 🔴 (≤50%) |
| 117 | + |
| 118 | +Example output snippet: |
| 119 | + |
| 120 | +```markdown |
| 121 | +# EIP-7702 Test Checklist |
| 122 | + |
| 123 | +## Checklist Progress Tracker |
| 124 | + |
| 125 | +| Total Checklist Items | Covered Checklist Items | Percentage | |
| 126 | +| --------------------- | ----------------------- | ---------- | |
| 127 | +| 45 | 32 | 🟡 71.11% | |
| 128 | + |
| 129 | +## General |
| 130 | + |
| 131 | +#### Code coverage |
| 132 | + |
| 133 | +| ID | Description | Status | Tests | |
| 134 | +| -- | ----------- | ------ | ----- | |
| 135 | +| `general/code_coverage/eels` | Run produced tests against EELS... | ✅ | Covered by EELS test suite | |
| 136 | +| `general/code_coverage/test_coverage` | Run coverage on the test code itself... | ✅ | `tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_txs` | |
| 137 | + |
| 138 | +## New Transaction Type |
| 139 | + |
| 140 | +| ID | Description | Status | Tests | |
| 141 | +| -- | ----------- | ------ | ----- | |
| 142 | +| `new_transaction_type/test/intrinsic_validity/gas_limit/exact` | Provide the exact intrinsic gas... | ✅ | `tests/prague/eip7702_set_code_tx/test_checklist_example.py::test_exact_intrinsic_gas` | |
| 143 | +| `new_transaction_type/test/intrinsic_validity/gas_limit/insufficient` | Provide the exact intrinsic gas minus one... | | | |
| 144 | + |
| 145 | +## New System Contract |
| 146 | + |
| 147 | +| ID | Description | Status | Tests | |
| 148 | +| -- | ----------- | ------ | ----- | |
| 149 | +| `new_system_contract/test/deployment/missing` | Verify block execution behavior... | N/A | EIP-7702 does not introduce a system contract | |
| 150 | +``` |
| 151 | + |
| 152 | +## Best Practices |
| 153 | + |
| 154 | +1. **Start with the checklist**: Review the checklist template before writing tests to ensure comprehensive coverage |
| 155 | +2. **Use descriptive test names**: The test name will appear in the checklist, so make it clear what the test covers |
| 156 | +3. **Mark items as you go**: Add `eip_checklist` markers while writing tests, not as an afterthought |
| 157 | +4. **Document external coverage**: If items are covered by external tools/tests, document this in `eip_checklist_external_coverage.txt` |
| 158 | +5. **Be explicit about N/A items**: Document why items are not applicable in `eip_checklist_not_applicable.txt` |
| 159 | +6. **Use partial IDs wisely**: When a test covers multiple related items, use partial IDs to mark them all |
| 160 | + |
| 161 | +## Workflow Example |
| 162 | + |
| 163 | +1. **Create test directory structure**: |
| 164 | + |
| 165 | + ```bash |
| 166 | + tests/prague/eip9999_new_feature/ |
| 167 | + ├── __init__.py |
| 168 | + ├── spec.py |
| 169 | + ├── test_basic.py |
| 170 | + ├── eip_checklist_external_coverage.txt |
| 171 | + └── eip_checklist_not_applicable.txt |
| 172 | + ``` |
| 173 | + |
| 174 | +2. **Mark tests as you implement them**: |
| 175 | + |
| 176 | + ```python |
| 177 | + @pytest.mark.eip_checklist("new_opcode/test/gas_usage/normal") |
| 178 | + def test_opcode_gas_consumption(state_test: StateTestFiller): |
| 179 | + """Test normal gas consumption of the new opcode.""" |
| 180 | + pass |
| 181 | + ``` |
| 182 | + |
| 183 | +3. **Document external coverage**: |
| 184 | + |
| 185 | + ```text |
| 186 | + # eip_checklist_external_coverage.txt |
| 187 | + general/code_coverage/eels = Covered by ethereum/execution-specs PR #1234 |
| 188 | + ``` |
| 189 | + |
| 190 | +4. **Mark non-applicable items**: |
| 191 | + |
| 192 | + ```text |
| 193 | + # eip_checklist_not_applicable.txt |
| 194 | + new_precompile/ = EIP-9999 introduces an opcode, not a precompile |
| 195 | + ``` |
| 196 | + |
| 197 | +5. **Generate and review checklist**: |
| 198 | + |
| 199 | + ```bash |
| 200 | + checklist --eip 9999 |
| 201 | + # Review the generated checklist for completeness |
| 202 | + ``` |
| 203 | + |
| 204 | +## See Also |
| 205 | + |
| 206 | +- [EIP Testing Checklist Template](./checklist_templates/eip_testing_checklist_template.md) - The full checklist template |
0 commit comments