ethspecify 0.3.0__py3-none-any.whl → 0.3.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ethspecify might be problematic. Click here for more details.
- ethspecify/cli.py +38 -1
- ethspecify/core.py +170 -1
- ethspecify-0.3.1.dist-info/METADATA +237 -0
- ethspecify-0.3.1.dist-info/RECORD +9 -0
- ethspecify-0.3.0.dist-info/METADATA +0 -351
- ethspecify-0.3.0.dist-info/RECORD +0 -9
- {ethspecify-0.3.0.dist-info → ethspecify-0.3.1.dist-info}/WHEEL +0 -0
- {ethspecify-0.3.0.dist-info → ethspecify-0.3.1.dist-info}/entry_points.txt +0 -0
- {ethspecify-0.3.0.dist-info → ethspecify-0.3.1.dist-info}/licenses/LICENSE +0 -0
- {ethspecify-0.3.0.dist-info → ethspecify-0.3.1.dist-info}/top_level.txt +0 -0
ethspecify/cli.py
CHANGED
|
@@ -3,7 +3,7 @@ import json
|
|
|
3
3
|
import os
|
|
4
4
|
import sys
|
|
5
5
|
|
|
6
|
-
from .core import grep, replace_spec_tags, get_pyspec, get_latest_fork, get_spec_item_history, load_config, run_checks, sort_specref_yaml
|
|
6
|
+
from .core import grep, replace_spec_tags, get_pyspec, get_latest_fork, get_spec_item_history, load_config, run_checks, sort_specref_yaml, generate_specref_files
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
def process(args):
|
|
@@ -182,6 +182,28 @@ def list_forks(args):
|
|
|
182
182
|
return 0
|
|
183
183
|
|
|
184
184
|
|
|
185
|
+
def init(args):
|
|
186
|
+
"""Initialize a specrefs directory with basic configuration and empty source mappings."""
|
|
187
|
+
output_dir = args.path or "specrefs"
|
|
188
|
+
version = args.version
|
|
189
|
+
|
|
190
|
+
# Check if output directory already exists
|
|
191
|
+
if os.path.exists(output_dir):
|
|
192
|
+
print(f"Error: directory {repr(output_dir)} already exists.")
|
|
193
|
+
print("Please specify a different directory or remove the existing one.")
|
|
194
|
+
return 1
|
|
195
|
+
|
|
196
|
+
try:
|
|
197
|
+
# Generate the specref files
|
|
198
|
+
print(f"Initializing specrefs directory: {version}")
|
|
199
|
+
generate_specref_files(output_dir, version, "mainnet")
|
|
200
|
+
print(f"Successfully created specrefs directory at: {output_dir}")
|
|
201
|
+
return 0
|
|
202
|
+
except Exception as e:
|
|
203
|
+
print(f"Error: {e}")
|
|
204
|
+
return 1
|
|
205
|
+
|
|
206
|
+
|
|
185
207
|
def main():
|
|
186
208
|
parser = argparse.ArgumentParser(
|
|
187
209
|
description="Process files containing <spec> tags."
|
|
@@ -256,6 +278,21 @@ def main():
|
|
|
256
278
|
help="Output format (text or json)",
|
|
257
279
|
)
|
|
258
280
|
|
|
281
|
+
# Parser for 'init' command
|
|
282
|
+
init_parser = subparsers.add_parser("init", help="Initialize a specrefs directory")
|
|
283
|
+
init_parser.set_defaults(func=init)
|
|
284
|
+
init_parser.add_argument(
|
|
285
|
+
"version",
|
|
286
|
+
type=str,
|
|
287
|
+
help="Specification version (e.g., 'nightly' or 'v1.6.0-alpha.5')",
|
|
288
|
+
)
|
|
289
|
+
init_parser.add_argument(
|
|
290
|
+
"--path",
|
|
291
|
+
type=str,
|
|
292
|
+
help="Output directory for specrefs (default: specrefs)",
|
|
293
|
+
default="specrefs",
|
|
294
|
+
)
|
|
295
|
+
|
|
259
296
|
# Default to 'process' if no args are provided
|
|
260
297
|
if len(sys.argv) == 1:
|
|
261
298
|
sys.argv.insert(1, "process")
|
ethspecify/core.py
CHANGED
|
@@ -773,7 +773,7 @@ def replace_spec_tags(file_path, config=None):
|
|
|
773
773
|
prefix = content[:match.start()].splitlines()[-1]
|
|
774
774
|
prefixed_spec = "\n".join(
|
|
775
775
|
f"{prefix}{line}" if line.rstrip() else prefix.rstrip()
|
|
776
|
-
for line in spec_content.
|
|
776
|
+
for line in spec_content.split("\n")
|
|
777
777
|
)
|
|
778
778
|
updated_tag = f"{new_opening}\n{prefixed_spec}\n{prefix}</spec>"
|
|
779
779
|
return updated_tag
|
|
@@ -1518,3 +1518,172 @@ def run_checks(project_dir, config):
|
|
|
1518
1518
|
overall_success = False
|
|
1519
1519
|
|
|
1520
1520
|
return overall_success, results
|
|
1521
|
+
|
|
1522
|
+
|
|
1523
|
+
def generate_specref_files(output_dir, version="nightly", preset="mainnet"):
|
|
1524
|
+
"""
|
|
1525
|
+
Generate specref YAML files without sources for manual mapping.
|
|
1526
|
+
Creates a basic directory structure with empty sources.
|
|
1527
|
+
"""
|
|
1528
|
+
# Create output directory if it doesn't exist
|
|
1529
|
+
os.makedirs(output_dir, exist_ok=True)
|
|
1530
|
+
|
|
1531
|
+
# Get all spec items
|
|
1532
|
+
pyspec = get_pyspec(version)
|
|
1533
|
+
if preset not in pyspec:
|
|
1534
|
+
raise ValueError(f"Preset '{preset}' not found")
|
|
1535
|
+
|
|
1536
|
+
# Get all forks in chronological order, excluding EIP forks
|
|
1537
|
+
all_forks = sorted(
|
|
1538
|
+
[fork for fork in pyspec[preset].keys() if not fork.startswith("eip")],
|
|
1539
|
+
key=lambda x: (x != "phase0", x)
|
|
1540
|
+
)
|
|
1541
|
+
|
|
1542
|
+
# Map history keys to file names and spec attribute names
|
|
1543
|
+
category_map = {
|
|
1544
|
+
'constant_vars': ('constants.yml', 'constant_var'),
|
|
1545
|
+
'config_vars': ('configs.yml', 'config_var'),
|
|
1546
|
+
'preset_vars': ('presets.yml', 'preset_var'),
|
|
1547
|
+
'functions': ('functions.yml', 'fn'),
|
|
1548
|
+
'ssz_objects': ('containers.yml', 'container'),
|
|
1549
|
+
'dataclasses': ('dataclasses.yml', 'dataclass'),
|
|
1550
|
+
'custom_types': ('types.yml', 'custom_type'),
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
# Collect all items organized by category
|
|
1554
|
+
items_by_category = {cat: {} for cat in category_map.keys()}
|
|
1555
|
+
|
|
1556
|
+
for fork in all_forks:
|
|
1557
|
+
if fork not in pyspec[preset]:
|
|
1558
|
+
continue
|
|
1559
|
+
fork_data = pyspec[preset][fork]
|
|
1560
|
+
|
|
1561
|
+
for category in items_by_category.keys():
|
|
1562
|
+
if category not in fork_data:
|
|
1563
|
+
continue
|
|
1564
|
+
|
|
1565
|
+
for item_name, item_data in fork_data[category].items():
|
|
1566
|
+
# Track which forks have this item
|
|
1567
|
+
if item_name not in items_by_category[category]:
|
|
1568
|
+
items_by_category[category][item_name] = []
|
|
1569
|
+
items_by_category[category][item_name].append((fork, item_data))
|
|
1570
|
+
|
|
1571
|
+
# Generate YAML files for each category
|
|
1572
|
+
for category, (filename, spec_attr) in category_map.items():
|
|
1573
|
+
if not items_by_category[category]:
|
|
1574
|
+
continue
|
|
1575
|
+
|
|
1576
|
+
output_path = os.path.join(output_dir, filename)
|
|
1577
|
+
entries = []
|
|
1578
|
+
|
|
1579
|
+
# Sort items alphabetically
|
|
1580
|
+
for item_name in sorted(items_by_category[category].keys()):
|
|
1581
|
+
forks_data = items_by_category[category][item_name]
|
|
1582
|
+
|
|
1583
|
+
# Find all unique versions of this item (where content differs)
|
|
1584
|
+
versions = [] # List of (fork, item_data, spec_content)
|
|
1585
|
+
prev_content = None
|
|
1586
|
+
|
|
1587
|
+
for fork, item_data in forks_data:
|
|
1588
|
+
# Build the spec content based on category
|
|
1589
|
+
if category == 'functions':
|
|
1590
|
+
spec_content = item_data
|
|
1591
|
+
elif category in ['constant_vars', 'config_vars', 'preset_vars']:
|
|
1592
|
+
# item_data is a list: [type, value, ...]
|
|
1593
|
+
if isinstance(item_data, (list, tuple)) and len(item_data) >= 2:
|
|
1594
|
+
type_info = item_data[0]
|
|
1595
|
+
value = item_data[1]
|
|
1596
|
+
if type_info:
|
|
1597
|
+
spec_content = f"{item_name}: {type_info} = {value}"
|
|
1598
|
+
else:
|
|
1599
|
+
spec_content = f"{item_name} = {value}"
|
|
1600
|
+
else:
|
|
1601
|
+
spec_content = str(item_data)
|
|
1602
|
+
elif category == 'ssz_objects':
|
|
1603
|
+
spec_content = item_data
|
|
1604
|
+
elif category == 'dataclasses':
|
|
1605
|
+
spec_content = item_data.replace("@dataclass\n", "")
|
|
1606
|
+
elif category == 'custom_types':
|
|
1607
|
+
# custom_types are simple type aliases: TypeName = SomeType
|
|
1608
|
+
spec_content = f"{item_name} = {item_data}"
|
|
1609
|
+
else:
|
|
1610
|
+
spec_content = str(item_data)
|
|
1611
|
+
|
|
1612
|
+
# Only add this version if it's different from the previous one
|
|
1613
|
+
if prev_content is None or spec_content != prev_content:
|
|
1614
|
+
versions.append((fork, item_data, spec_content))
|
|
1615
|
+
prev_content = spec_content
|
|
1616
|
+
|
|
1617
|
+
# Create entries based on number of unique versions
|
|
1618
|
+
use_fork_suffix = len(versions) > 1
|
|
1619
|
+
|
|
1620
|
+
for idx, (fork, item_data, spec_content) in enumerate(versions):
|
|
1621
|
+
# Calculate hash of current version
|
|
1622
|
+
hash_value = hashlib.sha256(spec_content.encode('utf-8')).hexdigest()[:8]
|
|
1623
|
+
|
|
1624
|
+
# For multiple versions after the first, use diff style
|
|
1625
|
+
if use_fork_suffix and idx > 0:
|
|
1626
|
+
# Get previous version for diff
|
|
1627
|
+
prev_fork, _, prev_spec_content = versions[idx - 1]
|
|
1628
|
+
|
|
1629
|
+
# Generate diff
|
|
1630
|
+
diff_content = diff(prev_fork, strip_comments(prev_spec_content), fork, strip_comments(spec_content))
|
|
1631
|
+
|
|
1632
|
+
# Build spec tag with style="diff"
|
|
1633
|
+
spec_tag = f'<spec {spec_attr}="{item_name}" fork="{fork}" style="diff" hash="{hash_value}">'
|
|
1634
|
+
content = diff_content
|
|
1635
|
+
else:
|
|
1636
|
+
# Build spec tag without style="diff"
|
|
1637
|
+
spec_tag = f'<spec {spec_attr}="{item_name}" fork="{fork}" hash="{hash_value}">'
|
|
1638
|
+
content = spec_content
|
|
1639
|
+
|
|
1640
|
+
# Create entry
|
|
1641
|
+
entry_name = f'{item_name}#{fork}' if use_fork_suffix else item_name
|
|
1642
|
+
entry = {
|
|
1643
|
+
'name': entry_name,
|
|
1644
|
+
'sources': [],
|
|
1645
|
+
'spec': f'{spec_tag}\n{content}\n</spec>'
|
|
1646
|
+
}
|
|
1647
|
+
entries.append(entry)
|
|
1648
|
+
|
|
1649
|
+
# Write YAML file
|
|
1650
|
+
if entries:
|
|
1651
|
+
with open(output_path, 'w') as f:
|
|
1652
|
+
for i, entry in enumerate(entries):
|
|
1653
|
+
if i > 0:
|
|
1654
|
+
f.write('\n')
|
|
1655
|
+
f.write(f'- name: {entry["name"]}\n')
|
|
1656
|
+
f.write(' sources: []\n')
|
|
1657
|
+
f.write(' spec: |\n')
|
|
1658
|
+
for line in entry['spec'].split('\n'):
|
|
1659
|
+
f.write(f' {line}\n')
|
|
1660
|
+
|
|
1661
|
+
# Create .ethspecify.yml config file
|
|
1662
|
+
config_path = os.path.join(output_dir, '.ethspecify.yml')
|
|
1663
|
+
with open(config_path, 'w') as f:
|
|
1664
|
+
f.write(f'version: {version}\n')
|
|
1665
|
+
f.write('style: full\n')
|
|
1666
|
+
f.write('\n')
|
|
1667
|
+
f.write('specrefs:\n')
|
|
1668
|
+
f.write(' files:\n')
|
|
1669
|
+
for category, (filename, _) in category_map.items():
|
|
1670
|
+
if items_by_category[category]:
|
|
1671
|
+
f.write(f' - {filename}\n')
|
|
1672
|
+
f.write('\n')
|
|
1673
|
+
f.write(' exceptions:\n')
|
|
1674
|
+
f.write(' # Add any exceptions here\n')
|
|
1675
|
+
|
|
1676
|
+
# Strip trailing whitespace from all generated files
|
|
1677
|
+
all_files = [config_path]
|
|
1678
|
+
for category, (filename, _) in category_map.items():
|
|
1679
|
+
if items_by_category[category]:
|
|
1680
|
+
all_files.append(os.path.join(output_dir, filename))
|
|
1681
|
+
|
|
1682
|
+
for file_path in all_files:
|
|
1683
|
+
with open(file_path, 'r') as f:
|
|
1684
|
+
lines = f.readlines()
|
|
1685
|
+
with open(file_path, 'w') as f:
|
|
1686
|
+
for line in lines:
|
|
1687
|
+
f.write(line.rstrip() + '\n')
|
|
1688
|
+
|
|
1689
|
+
return list(category_map.values())
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ethspecify
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: A utility for processing Ethereum specification tags.
|
|
5
|
+
Home-page: https://github.com/jtraglia/ethspecify
|
|
6
|
+
Author: Justin Traglia
|
|
7
|
+
Author-email: jtraglia@pm.me
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.6
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: requests==2.32.3
|
|
15
|
+
Requires-Dist: PyYAML>=6.0
|
|
16
|
+
Dynamic: author
|
|
17
|
+
Dynamic: author-email
|
|
18
|
+
Dynamic: classifier
|
|
19
|
+
Dynamic: description
|
|
20
|
+
Dynamic: description-content-type
|
|
21
|
+
Dynamic: home-page
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
Dynamic: requires-dist
|
|
24
|
+
Dynamic: requires-python
|
|
25
|
+
Dynamic: summary
|
|
26
|
+
|
|
27
|
+
# ethspecify
|
|
28
|
+
|
|
29
|
+
A tool for referencing the Ethereum specifications in clients.
|
|
30
|
+
|
|
31
|
+
The idea is that ethspecify will help developers keep track of when the specification changes. It
|
|
32
|
+
will also help auditors verify that the client implementations match the specifications. Ideally,
|
|
33
|
+
this is configured as a CI check which notifies client developers when the specification changes.
|
|
34
|
+
When that happens, they can update the implementations appropriately.
|
|
35
|
+
|
|
36
|
+
## Getting started
|
|
37
|
+
|
|
38
|
+
### Installation
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
pipx install ethspecify
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Initialize specrefs
|
|
45
|
+
|
|
46
|
+
From the root of the client source directory, initialize a directory for specrefs:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
$ ethspecify init v1.6.0-beta.0
|
|
50
|
+
Initializing specrefs directory: v1.6.0-beta.0
|
|
51
|
+
Successfully created specrefs directory at: specrefs
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
This creates a `specrefs` directory with `.ethspecify.yml` and YAML files for each spec category
|
|
55
|
+
(constants, configs, presets, functions, containers, dataclasses, types).
|
|
56
|
+
|
|
57
|
+
### Map sources
|
|
58
|
+
|
|
59
|
+
Edit the YAML files to add sources for where each spec item is implemented.
|
|
60
|
+
|
|
61
|
+
If it's the entire file:
|
|
62
|
+
|
|
63
|
+
```yaml
|
|
64
|
+
- name: BlobParameters
|
|
65
|
+
sources:
|
|
66
|
+
- file: ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/fulu/helpers/BlobParameters.java
|
|
67
|
+
spec: |
|
|
68
|
+
<spec dataclass="BlobParameters" fork="fulu" hash="a4575aa8">
|
|
69
|
+
class BlobParameters:
|
|
70
|
+
epoch: Epoch
|
|
71
|
+
max_blobs_per_block: uint64
|
|
72
|
+
</spec>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
If it's multiple entire files:
|
|
76
|
+
|
|
77
|
+
```yaml
|
|
78
|
+
- name: BlobsBundleDeneb
|
|
79
|
+
sources:
|
|
80
|
+
- file: ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/BlobsBundle.java
|
|
81
|
+
- file: ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/builder/BlobsBundleSchema.java
|
|
82
|
+
- file: ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/builder/versions/deneb/BlobsBundleDeneb.java
|
|
83
|
+
- file: ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/builder/versions/deneb/BlobsBundleSchemaDeneb.java
|
|
84
|
+
spec: |
|
|
85
|
+
<spec dataclass="BlobsBundle" fork="deneb" hash="8d6e7be6">
|
|
86
|
+
class BlobsBundle(object):
|
|
87
|
+
commitments: List[KZGCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK]
|
|
88
|
+
proofs: List[KZGProof, MAX_BLOB_COMMITMENTS_PER_BLOCK]
|
|
89
|
+
blobs: List[Blob, MAX_BLOB_COMMITMENTS_PER_BLOCK]
|
|
90
|
+
</spec>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
If it's a specific part of a file:
|
|
94
|
+
|
|
95
|
+
```yaml
|
|
96
|
+
- name: EFFECTIVE_BALANCE_INCREMENT
|
|
97
|
+
sources:
|
|
98
|
+
- file: ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/mainnet/phase0.yaml
|
|
99
|
+
search: "EFFECTIVE_BALANCE_INCREMENT:"
|
|
100
|
+
spec: |
|
|
101
|
+
<spec preset_var="EFFECTIVE_BALANCE_INCREMENT" fork="phase0" hash="23dfe52c">
|
|
102
|
+
EFFECTIVE_BALANCE_INCREMENT: Gwei = 1000000000
|
|
103
|
+
</spec>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
You can also use regex in the searches if that is necessary:
|
|
107
|
+
|
|
108
|
+
```yaml
|
|
109
|
+
- name: ATTESTATION_DUE_BPS
|
|
110
|
+
sources:
|
|
111
|
+
- file: ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/configs/mainnet.yaml
|
|
112
|
+
search: "^ATTESTATION_DUE_BPS:"
|
|
113
|
+
regex: true
|
|
114
|
+
spec: |
|
|
115
|
+
<spec config_var="ATTESTATION_DUE_BPS" fork="phase0" hash="929dd1c9">
|
|
116
|
+
ATTESTATION_DUE_BPS: uint64 = 3333
|
|
117
|
+
</spec>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Check specrefs
|
|
121
|
+
|
|
122
|
+
Run the check command in CI to verify all spec items are properly mapped:
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
$ ethspecify check --path=specrefs
|
|
126
|
+
MISSING: constants.BLS_MODULUS#deneb
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Add exceptions
|
|
130
|
+
|
|
131
|
+
Some spec items may not be implemented in your client. Add them to the exceptions list in
|
|
132
|
+
`specrefs/.ethspecify.yml`:
|
|
133
|
+
|
|
134
|
+
```yaml
|
|
135
|
+
specrefs:
|
|
136
|
+
files:
|
|
137
|
+
- containers.yml
|
|
138
|
+
- functions.yml
|
|
139
|
+
# ...
|
|
140
|
+
|
|
141
|
+
exceptions:
|
|
142
|
+
containers:
|
|
143
|
+
# Not defined, unnecessary
|
|
144
|
+
- Eth1Block
|
|
145
|
+
|
|
146
|
+
functions:
|
|
147
|
+
# No light client support
|
|
148
|
+
- is_valid_light_client_header
|
|
149
|
+
- process_light_client_update
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Style Options
|
|
153
|
+
|
|
154
|
+
This attribute can be used to change how the specification content is shown.
|
|
155
|
+
|
|
156
|
+
### `hash` (default)
|
|
157
|
+
|
|
158
|
+
This style adds a hash of the specification content to the spec tag, without showing the content.
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
<spec fn="apply_deposit" fork="electra" hash="c723ce7b" />
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
> [!NOTE]
|
|
165
|
+
> The hash is the first 8 characters of the specification content's SHA256 digest.
|
|
166
|
+
|
|
167
|
+
### `full`
|
|
168
|
+
|
|
169
|
+
This style displays the whole content of this specification item, including comments.
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
<spec fn="is_fully_withdrawable_validator" fork="deneb" style="full">
|
|
173
|
+
def is_fully_withdrawable_validator(validator: Validator, balance: Gwei, epoch: Epoch) -> bool:
|
|
174
|
+
"""
|
|
175
|
+
Check if ``validator`` is fully withdrawable.
|
|
176
|
+
"""
|
|
177
|
+
return (
|
|
178
|
+
has_eth1_withdrawal_credential(validator)
|
|
179
|
+
and validator.withdrawable_epoch <= epoch
|
|
180
|
+
and balance > 0
|
|
181
|
+
)
|
|
182
|
+
</spec>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### `link`
|
|
186
|
+
|
|
187
|
+
This style displays a GitHub link to the specification item.
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
<spec fn="apply_pending_deposit" fork="electra" style="link" hash="83ee9126">
|
|
191
|
+
https://github.com/ethereum/consensus-specs/blob/dev/specs/electra/beacon-chain.md#new-apply_pending_deposit
|
|
192
|
+
</spec>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### `diff`
|
|
196
|
+
|
|
197
|
+
This style displays a diff with the previous fork's version of the specification.
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
<spec ssz_object="BeaconState" fork="electra" style="diff">
|
|
201
|
+
--- deneb
|
|
202
|
+
+++ electra
|
|
203
|
+
@@ -27,3 +27,12 @@
|
|
204
|
+
next_withdrawal_index: WithdrawalIndex
|
|
205
|
+
next_withdrawal_validator_index: ValidatorIndex
|
|
206
|
+
historical_summaries: List[HistoricalSummary, HISTORICAL_ROOTS_LIMIT]
|
|
207
|
+
+ deposit_requests_start_index: uint64
|
|
208
|
+
+ deposit_balance_to_consume: Gwei
|
|
209
|
+
+ exit_balance_to_consume: Gwei
|
|
210
|
+
+ earliest_exit_epoch: Epoch
|
|
211
|
+
+ consolidation_balance_to_consume: Gwei
|
|
212
|
+
+ earliest_consolidation_epoch: Epoch
|
|
213
|
+
+ pending_deposits: List[PendingDeposit, PENDING_DEPOSITS_LIMIT]
|
|
214
|
+
+ pending_partial_withdrawals: List[PendingPartialWithdrawal, PENDING_PARTIAL_WITHDRAWALS_LIMIT]
|
|
215
|
+
+ pending_consolidations: List[PendingConsolidation, PENDING_CONSOLIDATIONS_LIMIT]
|
|
216
|
+
</spec>
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
> [!NOTE]
|
|
220
|
+
> Comments are stripped from the specifications when the `diff` style is used. We do this because
|
|
221
|
+
> these complicate the diff; the "[Modified in Fork]" comments aren't valuable here.
|
|
222
|
+
|
|
223
|
+
This can be used with any specification item, like functions too:
|
|
224
|
+
|
|
225
|
+
```
|
|
226
|
+
<spec fn="is_eligible_for_activation_queue" fork="electra" style="diff">
|
|
227
|
+
--- phase0
|
|
228
|
+
+++ electra
|
|
229
|
+
@@ -4,5 +4,5 @@
|
|
230
|
+
"""
|
|
231
|
+
return (
|
|
232
|
+
validator.activation_eligibility_epoch == FAR_FUTURE_EPOCH
|
|
233
|
+
- and validator.effective_balance == MAX_EFFECTIVE_BALANCE
|
|
234
|
+
+ and validator.effective_balance >= MIN_ACTIVATION_BALANCE
|
|
235
|
+
)
|
|
236
|
+
</spec>
|
|
237
|
+
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
ethspecify/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
ethspecify/cli.py,sha256=fbHtny1-VS6IZZlDzPSvkyLr4NDYDYcBXzOiGUGOlyU,10093
|
|
3
|
+
ethspecify/core.py,sha256=gfDBeYzrhNM6wHGtoyy_7SnKUQF_w5iFGljQcdUmaJQ,66694
|
|
4
|
+
ethspecify-0.3.1.dist-info/licenses/LICENSE,sha256=Awxsr73mm9YMBVhBYnzeI7bNdRd-bH6RDtO5ItG0DaM,1071
|
|
5
|
+
ethspecify-0.3.1.dist-info/METADATA,sha256=mI1j8bbLAKBH_dvLHKuP1kgNsdjXnUMcGnS2l2SPh_s,6996
|
|
6
|
+
ethspecify-0.3.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
7
|
+
ethspecify-0.3.1.dist-info/entry_points.txt,sha256=09viGkCg9J3h0c9BFRN-BKaJUEaIc4JyULNgBP5EL_g,51
|
|
8
|
+
ethspecify-0.3.1.dist-info/top_level.txt,sha256=0klaMvlVyOkXW09fwZTijJpdybITEp2c9zQKV5v30VM,11
|
|
9
|
+
ethspecify-0.3.1.dist-info/RECORD,,
|
|
@@ -1,351 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: ethspecify
|
|
3
|
-
Version: 0.3.0
|
|
4
|
-
Summary: A utility for processing Ethereum specification tags.
|
|
5
|
-
Home-page: https://github.com/jtraglia/ethspecify
|
|
6
|
-
Author: Justin Traglia
|
|
7
|
-
Author-email: jtraglia@pm.me
|
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
-
Classifier: Operating System :: OS Independent
|
|
11
|
-
Requires-Python: >=3.6
|
|
12
|
-
Description-Content-Type: text/markdown
|
|
13
|
-
License-File: LICENSE
|
|
14
|
-
Requires-Dist: requests==2.32.3
|
|
15
|
-
Requires-Dist: PyYAML>=6.0
|
|
16
|
-
Dynamic: author
|
|
17
|
-
Dynamic: author-email
|
|
18
|
-
Dynamic: classifier
|
|
19
|
-
Dynamic: description
|
|
20
|
-
Dynamic: description-content-type
|
|
21
|
-
Dynamic: home-page
|
|
22
|
-
Dynamic: license-file
|
|
23
|
-
Dynamic: requires-dist
|
|
24
|
-
Dynamic: requires-python
|
|
25
|
-
Dynamic: summary
|
|
26
|
-
|
|
27
|
-
# ethspecify
|
|
28
|
-
|
|
29
|
-
A tool for referencing the Ethereum specifications in clients.
|
|
30
|
-
|
|
31
|
-
The idea is that ethspecify will help developers keep track of when the specification changes. It
|
|
32
|
-
will also help auditors verify that the client implementations match the specifications. Ideally,
|
|
33
|
-
this is configured as a CI check which notifies client developers when the specification changes.
|
|
34
|
-
When that happens, they can update the implementations appropriately.
|
|
35
|
-
|
|
36
|
-
## Getting Started
|
|
37
|
-
|
|
38
|
-
### Installation
|
|
39
|
-
|
|
40
|
-
```
|
|
41
|
-
pipx install ethspecify
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
### Adding Spec Tags
|
|
45
|
-
|
|
46
|
-
In your client, add HTML tags like this:
|
|
47
|
-
|
|
48
|
-
```
|
|
49
|
-
/*
|
|
50
|
-
* <spec fn="is_fully_withdrawable_validator" fork="deneb" />
|
|
51
|
-
*/
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
```
|
|
55
|
-
/*
|
|
56
|
-
* <spec ssz_object="BeaconState" fork="electra" style="diff" />
|
|
57
|
-
*/
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### Populating Spec Tags
|
|
61
|
-
|
|
62
|
-
Then, navigate to your codebase and run `ethspecify`:
|
|
63
|
-
|
|
64
|
-
```
|
|
65
|
-
ethspecify
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Specification Options
|
|
69
|
-
|
|
70
|
-
### Version
|
|
71
|
-
|
|
72
|
-
This attribute specifies which version of the consensus specifications to use. Default is `nightly`.
|
|
73
|
-
|
|
74
|
-
- `nightly` (default) - Uses the latest nightly build from the master branch
|
|
75
|
-
- `v1.6.0-alpha.2`, `v1.6.0-alpha.3`, etc. - Uses a specific tagged release version
|
|
76
|
-
|
|
77
|
-
Example:
|
|
78
|
-
```
|
|
79
|
-
/*
|
|
80
|
-
* <spec fn="apply_deposit" fork="electra" version="v1.6.0-alpha.3" />
|
|
81
|
-
*/
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### Fork
|
|
85
|
-
|
|
86
|
-
This attribute can be any of the [executable
|
|
87
|
-
specifications](https://github.com/ethereum/consensus-specs/blob/e6bddd966214a19d2b97199bbe3c02577a22a8b4/Makefile#L3-L15)
|
|
88
|
-
in the consensus-specs. At the time of writing, these are: phase0, altair, bellatrix, capella,
|
|
89
|
-
deneb, electra, fulu, whisk, eip6800, and eip7732.
|
|
90
|
-
|
|
91
|
-
### Style
|
|
92
|
-
|
|
93
|
-
This attribute can be used to change how the specification content is shown.
|
|
94
|
-
|
|
95
|
-
#### `hash` (default)
|
|
96
|
-
|
|
97
|
-
This style adds a hash of the specification content to the spec tag, without showing the content.
|
|
98
|
-
|
|
99
|
-
```
|
|
100
|
-
/*
|
|
101
|
-
* <spec fn="apply_deposit" fork="electra" hash="c723ce7b" />
|
|
102
|
-
*/
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
> [!NOTE]
|
|
106
|
-
> The hash is the first 8 characters of the specification content's SHA256 digest.
|
|
107
|
-
|
|
108
|
-
#### `full`
|
|
109
|
-
|
|
110
|
-
This style displays the whole content of this specification item, including comments.
|
|
111
|
-
|
|
112
|
-
```
|
|
113
|
-
/*
|
|
114
|
-
* <spec fn="is_fully_withdrawable_validator" fork="deneb" style="full">
|
|
115
|
-
* def is_fully_withdrawable_validator(validator: Validator, balance: Gwei, epoch: Epoch) -> bool:
|
|
116
|
-
* """
|
|
117
|
-
* Check if ``validator`` is fully withdrawable.
|
|
118
|
-
* """
|
|
119
|
-
* return (
|
|
120
|
-
* has_eth1_withdrawal_credential(validator)
|
|
121
|
-
* and validator.withdrawable_epoch <= epoch
|
|
122
|
-
* and balance > 0
|
|
123
|
-
* )
|
|
124
|
-
* </spec>
|
|
125
|
-
*/
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
#### `link`
|
|
129
|
-
|
|
130
|
-
This style displays a GitHub link to the specification item.
|
|
131
|
-
|
|
132
|
-
```
|
|
133
|
-
/*
|
|
134
|
-
* <spec fn="apply_pending_deposit" fork="electra" style="link" hash="83ee9126">
|
|
135
|
-
* https://github.com/ethereum/consensus-specs/blob/dev/specs/electra/beacon-chain.md#new-apply_pending_deposit
|
|
136
|
-
* </spec>
|
|
137
|
-
*/
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
#### `diff`
|
|
141
|
-
|
|
142
|
-
This style displays a diff with the previous fork's version of the specification.
|
|
143
|
-
|
|
144
|
-
```
|
|
145
|
-
/*
|
|
146
|
-
* <spec ssz_object="BeaconState" fork="electra" style="diff">
|
|
147
|
-
* --- deneb
|
|
148
|
-
* +++ electra
|
|
149
|
-
* @@ -27,3 +27,12 @@
|
|
150
|
-
* next_withdrawal_index: WithdrawalIndex
|
|
151
|
-
* next_withdrawal_validator_index: ValidatorIndex
|
|
152
|
-
* historical_summaries: List[HistoricalSummary, HISTORICAL_ROOTS_LIMIT]
|
|
153
|
-
* + deposit_requests_start_index: uint64
|
|
154
|
-
* + deposit_balance_to_consume: Gwei
|
|
155
|
-
* + exit_balance_to_consume: Gwei
|
|
156
|
-
* + earliest_exit_epoch: Epoch
|
|
157
|
-
* + consolidation_balance_to_consume: Gwei
|
|
158
|
-
* + earliest_consolidation_epoch: Epoch
|
|
159
|
-
* + pending_deposits: List[PendingDeposit, PENDING_DEPOSITS_LIMIT]
|
|
160
|
-
* + pending_partial_withdrawals: List[PendingPartialWithdrawal, PENDING_PARTIAL_WITHDRAWALS_LIMIT]
|
|
161
|
-
* + pending_consolidations: List[PendingConsolidation, PENDING_CONSOLIDATIONS_LIMIT]
|
|
162
|
-
* </spec>
|
|
163
|
-
*/
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
> [!NOTE]
|
|
167
|
-
> Comments are stripped from the specifications when the `diff` style is used. We do this because
|
|
168
|
-
> these complicate the diff; the "[Modified in Fork]" comments aren't valuable here.
|
|
169
|
-
|
|
170
|
-
This can be used with any specification item, like functions too:
|
|
171
|
-
|
|
172
|
-
```
|
|
173
|
-
/*
|
|
174
|
-
* <spec fn="is_eligible_for_activation_queue" fork="electra" style="diff">
|
|
175
|
-
* --- phase0
|
|
176
|
-
* +++ electra
|
|
177
|
-
* @@ -4,5 +4,5 @@
|
|
178
|
-
* """
|
|
179
|
-
* return (
|
|
180
|
-
* validator.activation_eligibility_epoch == FAR_FUTURE_EPOCH
|
|
181
|
-
* - and validator.effective_balance == MAX_EFFECTIVE_BALANCE
|
|
182
|
-
* + and validator.effective_balance >= MIN_ACTIVATION_BALANCE
|
|
183
|
-
* )
|
|
184
|
-
* </spec>
|
|
185
|
-
*/
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
## Supported Specification Items
|
|
189
|
-
|
|
190
|
-
### Constants
|
|
191
|
-
|
|
192
|
-
These are items found in the `Constants` section of the specifications.
|
|
193
|
-
|
|
194
|
-
```
|
|
195
|
-
/*
|
|
196
|
-
* <spec constant_var="COMPOUNDING_WITHDRAWAL_PREFIX" fork="electra" style="full">
|
|
197
|
-
* COMPOUNDING_WITHDRAWAL_PREFIX: Bytes1 = '0x02'
|
|
198
|
-
* </spec>
|
|
199
|
-
*/
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
### Custom Types
|
|
203
|
-
|
|
204
|
-
These are items found in the `Custom types` section of the specifications.
|
|
205
|
-
|
|
206
|
-
```
|
|
207
|
-
/*
|
|
208
|
-
* <spec custom_type="Blob" fork="electra" style="full">
|
|
209
|
-
* Blob = ByteVector[BYTES_PER_FIELD_ELEMENT * FIELD_ELEMENTS_PER_BLOB]
|
|
210
|
-
* </spec>
|
|
211
|
-
*/
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
### Preset Variables
|
|
215
|
-
|
|
216
|
-
These are items found in the
|
|
217
|
-
[`presets`](https://github.com/ethereum/consensus-specs/tree/dev/presets) directory.
|
|
218
|
-
|
|
219
|
-
For preset variables, in addition to the `preset_var` attribute, you can specify a `preset`
|
|
220
|
-
attribute: minimal or mainnet.
|
|
221
|
-
|
|
222
|
-
```
|
|
223
|
-
/*
|
|
224
|
-
* <spec preset="minimal" preset_var="PENDING_CONSOLIDATIONS_LIMIT" fork="electra" style="full">
|
|
225
|
-
* PENDING_CONSOLIDATIONS_LIMIT: uint64 = 64
|
|
226
|
-
* </spec>
|
|
227
|
-
*
|
|
228
|
-
* <spec preset="mainnet" preset_var="PENDING_CONSOLIDATIONS_LIMIT" fork="electra" style="full">
|
|
229
|
-
* PENDING_CONSOLIDATIONS_LIMIT: uint64 = 262144
|
|
230
|
-
* </spec>
|
|
231
|
-
*/
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
It's not strictly necessary to specify the preset attribute. The default preset is mainnet.
|
|
235
|
-
|
|
236
|
-
```
|
|
237
|
-
/*
|
|
238
|
-
* <spec preset_var="FIELD_ELEMENTS_PER_BLOB" fork="electra" style="full">
|
|
239
|
-
* FIELD_ELEMENTS_PER_BLOB: uint64 = 4096
|
|
240
|
-
* </spec>
|
|
241
|
-
*/
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
### Config Variables
|
|
245
|
-
|
|
246
|
-
These are items found in the
|
|
247
|
-
[`configs`](https://github.com/ethereum/consensus-specs/tree/dev/presets) directory.
|
|
248
|
-
|
|
249
|
-
```
|
|
250
|
-
/*
|
|
251
|
-
* <spec config_var="MAX_REQUEST_BLOB_SIDECARS" fork="electra" style="full">
|
|
252
|
-
* MAX_REQUEST_BLOB_SIDECARS = 768
|
|
253
|
-
* </spec>
|
|
254
|
-
*/
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
### SSZ Objects
|
|
258
|
-
|
|
259
|
-
These are items found in the `Containers` section of the specifications.
|
|
260
|
-
|
|
261
|
-
```
|
|
262
|
-
/*
|
|
263
|
-
* <spec ssz_object="ConsolidationRequest" fork="electra" style="full">
|
|
264
|
-
* class ConsolidationRequest(Container):
|
|
265
|
-
* source_address: ExecutionAddress
|
|
266
|
-
* source_pubkey: BLSPubkey
|
|
267
|
-
* target_pubkey: BLSPubkey
|
|
268
|
-
* </spec>
|
|
269
|
-
*/
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
### Dataclasses
|
|
273
|
-
|
|
274
|
-
These are classes with the `@dataclass` decorator.
|
|
275
|
-
|
|
276
|
-
```
|
|
277
|
-
/*
|
|
278
|
-
* <spec dataclass="PayloadAttributes" fork="electra" style="full">
|
|
279
|
-
* class PayloadAttributes(object):
|
|
280
|
-
* timestamp: uint64
|
|
281
|
-
* prev_randao: Bytes32
|
|
282
|
-
* suggested_fee_recipient: ExecutionAddress
|
|
283
|
-
* withdrawals: Sequence[Withdrawal]
|
|
284
|
-
* parent_beacon_block_root: Root # [New in Deneb:EIP4788]
|
|
285
|
-
* </spec>
|
|
286
|
-
*/
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
### Functions
|
|
290
|
-
|
|
291
|
-
These are all the functions found in the specifications.
|
|
292
|
-
|
|
293
|
-
For example, two versions of the same function:
|
|
294
|
-
|
|
295
|
-
```
|
|
296
|
-
/*
|
|
297
|
-
* <spec fn="is_fully_withdrawable_validator" fork="deneb" style="full">
|
|
298
|
-
* def is_fully_withdrawable_validator(validator: Validator, balance: Gwei, epoch: Epoch) -> bool:
|
|
299
|
-
* """
|
|
300
|
-
* Check if ``validator`` is fully withdrawable.
|
|
301
|
-
* """
|
|
302
|
-
* return (
|
|
303
|
-
* has_eth1_withdrawal_credential(validator)
|
|
304
|
-
* and validator.withdrawable_epoch <= epoch
|
|
305
|
-
* and balance > 0
|
|
306
|
-
* )
|
|
307
|
-
* </spec>
|
|
308
|
-
*/
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
```
|
|
312
|
-
/*
|
|
313
|
-
* <spec fn="is_fully_withdrawable_validator" fork="electra" style="full">
|
|
314
|
-
* def is_fully_withdrawable_validator(validator: Validator, balance: Gwei, epoch: Epoch) -> bool:
|
|
315
|
-
* """
|
|
316
|
-
* Check if ``validator`` is fully withdrawable.
|
|
317
|
-
* """
|
|
318
|
-
* return (
|
|
319
|
-
* has_execution_withdrawal_credential(validator) # [Modified in Electra:EIP7251]
|
|
320
|
-
* and validator.withdrawable_epoch <= epoch
|
|
321
|
-
* and balance > 0
|
|
322
|
-
* )
|
|
323
|
-
* </spec>
|
|
324
|
-
*/
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
With functions, it's possible to specify which line/lines should be displayed. For example:
|
|
328
|
-
|
|
329
|
-
```
|
|
330
|
-
/*
|
|
331
|
-
* <spec fn="is_fully_withdrawable_validator" fork="electra" style="full" lines="5-9">
|
|
332
|
-
* return (
|
|
333
|
-
* has_execution_withdrawal_credential(validator) # [Modified in Electra:EIP7251]
|
|
334
|
-
* and validator.withdrawable_epoch <= epoch
|
|
335
|
-
* and balance > 0
|
|
336
|
-
* )
|
|
337
|
-
* </spec>
|
|
338
|
-
*/
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
Note that the content is automatically dedented.
|
|
342
|
-
|
|
343
|
-
Or, to display just a single line, only specify a single number. For example:
|
|
344
|
-
|
|
345
|
-
```
|
|
346
|
-
/*
|
|
347
|
-
* <spec fn="is_fully_withdrawable_validator" fork="electra" style="full" lines="6">
|
|
348
|
-
* has_execution_withdrawal_credential(validator) # [Modified in Electra:EIP7251]
|
|
349
|
-
* </spec>
|
|
350
|
-
*/
|
|
351
|
-
```
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
ethspecify/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
ethspecify/cli.py,sha256=wx2ft_Q0qysXzYFqXcluq3XlfCpSncKxr6FUoer_CVo,8825
|
|
3
|
-
ethspecify/core.py,sha256=TuV9CfFMVBO1RyUfutaGWwDsuI92OSteK1XS1R6qI8I,59645
|
|
4
|
-
ethspecify-0.3.0.dist-info/licenses/LICENSE,sha256=Awxsr73mm9YMBVhBYnzeI7bNdRd-bH6RDtO5ItG0DaM,1071
|
|
5
|
-
ethspecify-0.3.0.dist-info/METADATA,sha256=E4tUacR1hGgeRUJcavGoNrhHd0AMIjYEJqiGyEdEoNY,9203
|
|
6
|
-
ethspecify-0.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
7
|
-
ethspecify-0.3.0.dist-info/entry_points.txt,sha256=09viGkCg9J3h0c9BFRN-BKaJUEaIc4JyULNgBP5EL_g,51
|
|
8
|
-
ethspecify-0.3.0.dist-info/top_level.txt,sha256=0klaMvlVyOkXW09fwZTijJpdybITEp2c9zQKV5v30VM,11
|
|
9
|
-
ethspecify-0.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|