ethspecify 0.3.0__tar.gz → 0.3.2__tar.gz
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.
- ethspecify-0.3.2/PKG-INFO +237 -0
- ethspecify-0.3.2/README.md +211 -0
- {ethspecify-0.3.0 → ethspecify-0.3.2}/ethspecify/cli.py +61 -7
- {ethspecify-0.3.0 → ethspecify-0.3.2}/ethspecify/core.py +534 -2
- ethspecify-0.3.2/ethspecify.egg-info/PKG-INFO +237 -0
- {ethspecify-0.3.0 → ethspecify-0.3.2}/setup.py +1 -1
- ethspecify-0.3.0/PKG-INFO +0 -351
- ethspecify-0.3.0/README.md +0 -325
- ethspecify-0.3.0/ethspecify.egg-info/PKG-INFO +0 -351
- {ethspecify-0.3.0 → ethspecify-0.3.2}/LICENSE +0 -0
- {ethspecify-0.3.0 → ethspecify-0.3.2}/ethspecify/__init__.py +0 -0
- {ethspecify-0.3.0 → ethspecify-0.3.2}/ethspecify.egg-info/SOURCES.txt +0 -0
- {ethspecify-0.3.0 → ethspecify-0.3.2}/ethspecify.egg-info/dependency_links.txt +0 -0
- {ethspecify-0.3.0 → ethspecify-0.3.2}/ethspecify.egg-info/entry_points.txt +0 -0
- {ethspecify-0.3.0 → ethspecify-0.3.2}/ethspecify.egg-info/requires.txt +0 -0
- {ethspecify-0.3.0 → ethspecify-0.3.2}/ethspecify.egg-info/top_level.txt +0 -0
- {ethspecify-0.3.0 → ethspecify-0.3.2}/setup.cfg +0 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ethspecify
|
|
3
|
+
Version: 0.3.2
|
|
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,211 @@
|
|
|
1
|
+
# ethspecify
|
|
2
|
+
|
|
3
|
+
A tool for referencing the Ethereum specifications in clients.
|
|
4
|
+
|
|
5
|
+
The idea is that ethspecify will help developers keep track of when the specification changes. It
|
|
6
|
+
will also help auditors verify that the client implementations match the specifications. Ideally,
|
|
7
|
+
this is configured as a CI check which notifies client developers when the specification changes.
|
|
8
|
+
When that happens, they can update the implementations appropriately.
|
|
9
|
+
|
|
10
|
+
## Getting started
|
|
11
|
+
|
|
12
|
+
### Installation
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
pipx install ethspecify
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Initialize specrefs
|
|
19
|
+
|
|
20
|
+
From the root of the client source directory, initialize a directory for specrefs:
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
$ ethspecify init v1.6.0-beta.0
|
|
24
|
+
Initializing specrefs directory: v1.6.0-beta.0
|
|
25
|
+
Successfully created specrefs directory at: specrefs
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
This creates a `specrefs` directory with `.ethspecify.yml` and YAML files for each spec category
|
|
29
|
+
(constants, configs, presets, functions, containers, dataclasses, types).
|
|
30
|
+
|
|
31
|
+
### Map sources
|
|
32
|
+
|
|
33
|
+
Edit the YAML files to add sources for where each spec item is implemented.
|
|
34
|
+
|
|
35
|
+
If it's the entire file:
|
|
36
|
+
|
|
37
|
+
```yaml
|
|
38
|
+
- name: BlobParameters
|
|
39
|
+
sources:
|
|
40
|
+
- file: ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/fulu/helpers/BlobParameters.java
|
|
41
|
+
spec: |
|
|
42
|
+
<spec dataclass="BlobParameters" fork="fulu" hash="a4575aa8">
|
|
43
|
+
class BlobParameters:
|
|
44
|
+
epoch: Epoch
|
|
45
|
+
max_blobs_per_block: uint64
|
|
46
|
+
</spec>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
If it's multiple entire files:
|
|
50
|
+
|
|
51
|
+
```yaml
|
|
52
|
+
- name: BlobsBundleDeneb
|
|
53
|
+
sources:
|
|
54
|
+
- file: ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/BlobsBundle.java
|
|
55
|
+
- file: ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/builder/BlobsBundleSchema.java
|
|
56
|
+
- file: ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/builder/versions/deneb/BlobsBundleDeneb.java
|
|
57
|
+
- file: ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/builder/versions/deneb/BlobsBundleSchemaDeneb.java
|
|
58
|
+
spec: |
|
|
59
|
+
<spec dataclass="BlobsBundle" fork="deneb" hash="8d6e7be6">
|
|
60
|
+
class BlobsBundle(object):
|
|
61
|
+
commitments: List[KZGCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK]
|
|
62
|
+
proofs: List[KZGProof, MAX_BLOB_COMMITMENTS_PER_BLOCK]
|
|
63
|
+
blobs: List[Blob, MAX_BLOB_COMMITMENTS_PER_BLOCK]
|
|
64
|
+
</spec>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
If it's a specific part of a file:
|
|
68
|
+
|
|
69
|
+
```yaml
|
|
70
|
+
- name: EFFECTIVE_BALANCE_INCREMENT
|
|
71
|
+
sources:
|
|
72
|
+
- file: ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/mainnet/phase0.yaml
|
|
73
|
+
search: "EFFECTIVE_BALANCE_INCREMENT:"
|
|
74
|
+
spec: |
|
|
75
|
+
<spec preset_var="EFFECTIVE_BALANCE_INCREMENT" fork="phase0" hash="23dfe52c">
|
|
76
|
+
EFFECTIVE_BALANCE_INCREMENT: Gwei = 1000000000
|
|
77
|
+
</spec>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
You can also use regex in the searches if that is necessary:
|
|
81
|
+
|
|
82
|
+
```yaml
|
|
83
|
+
- name: ATTESTATION_DUE_BPS
|
|
84
|
+
sources:
|
|
85
|
+
- file: ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/configs/mainnet.yaml
|
|
86
|
+
search: "^ATTESTATION_DUE_BPS:"
|
|
87
|
+
regex: true
|
|
88
|
+
spec: |
|
|
89
|
+
<spec config_var="ATTESTATION_DUE_BPS" fork="phase0" hash="929dd1c9">
|
|
90
|
+
ATTESTATION_DUE_BPS: uint64 = 3333
|
|
91
|
+
</spec>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Check specrefs
|
|
95
|
+
|
|
96
|
+
Run the check command in CI to verify all spec items are properly mapped:
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
$ ethspecify check --path=specrefs
|
|
100
|
+
MISSING: constants.BLS_MODULUS#deneb
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Add exceptions
|
|
104
|
+
|
|
105
|
+
Some spec items may not be implemented in your client. Add them to the exceptions list in
|
|
106
|
+
`specrefs/.ethspecify.yml`:
|
|
107
|
+
|
|
108
|
+
```yaml
|
|
109
|
+
specrefs:
|
|
110
|
+
files:
|
|
111
|
+
- containers.yml
|
|
112
|
+
- functions.yml
|
|
113
|
+
# ...
|
|
114
|
+
|
|
115
|
+
exceptions:
|
|
116
|
+
containers:
|
|
117
|
+
# Not defined, unnecessary
|
|
118
|
+
- Eth1Block
|
|
119
|
+
|
|
120
|
+
functions:
|
|
121
|
+
# No light client support
|
|
122
|
+
- is_valid_light_client_header
|
|
123
|
+
- process_light_client_update
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Style Options
|
|
127
|
+
|
|
128
|
+
This attribute can be used to change how the specification content is shown.
|
|
129
|
+
|
|
130
|
+
### `hash` (default)
|
|
131
|
+
|
|
132
|
+
This style adds a hash of the specification content to the spec tag, without showing the content.
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
<spec fn="apply_deposit" fork="electra" hash="c723ce7b" />
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
> [!NOTE]
|
|
139
|
+
> The hash is the first 8 characters of the specification content's SHA256 digest.
|
|
140
|
+
|
|
141
|
+
### `full`
|
|
142
|
+
|
|
143
|
+
This style displays the whole content of this specification item, including comments.
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
<spec fn="is_fully_withdrawable_validator" fork="deneb" style="full">
|
|
147
|
+
def is_fully_withdrawable_validator(validator: Validator, balance: Gwei, epoch: Epoch) -> bool:
|
|
148
|
+
"""
|
|
149
|
+
Check if ``validator`` is fully withdrawable.
|
|
150
|
+
"""
|
|
151
|
+
return (
|
|
152
|
+
has_eth1_withdrawal_credential(validator)
|
|
153
|
+
and validator.withdrawable_epoch <= epoch
|
|
154
|
+
and balance > 0
|
|
155
|
+
)
|
|
156
|
+
</spec>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### `link`
|
|
160
|
+
|
|
161
|
+
This style displays a GitHub link to the specification item.
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
<spec fn="apply_pending_deposit" fork="electra" style="link" hash="83ee9126">
|
|
165
|
+
https://github.com/ethereum/consensus-specs/blob/dev/specs/electra/beacon-chain.md#new-apply_pending_deposit
|
|
166
|
+
</spec>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### `diff`
|
|
170
|
+
|
|
171
|
+
This style displays a diff with the previous fork's version of the specification.
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
<spec ssz_object="BeaconState" fork="electra" style="diff">
|
|
175
|
+
--- deneb
|
|
176
|
+
+++ electra
|
|
177
|
+
@@ -27,3 +27,12 @@
|
|
178
|
+
next_withdrawal_index: WithdrawalIndex
|
|
179
|
+
next_withdrawal_validator_index: ValidatorIndex
|
|
180
|
+
historical_summaries: List[HistoricalSummary, HISTORICAL_ROOTS_LIMIT]
|
|
181
|
+
+ deposit_requests_start_index: uint64
|
|
182
|
+
+ deposit_balance_to_consume: Gwei
|
|
183
|
+
+ exit_balance_to_consume: Gwei
|
|
184
|
+
+ earliest_exit_epoch: Epoch
|
|
185
|
+
+ consolidation_balance_to_consume: Gwei
|
|
186
|
+
+ earliest_consolidation_epoch: Epoch
|
|
187
|
+
+ pending_deposits: List[PendingDeposit, PENDING_DEPOSITS_LIMIT]
|
|
188
|
+
+ pending_partial_withdrawals: List[PendingPartialWithdrawal, PENDING_PARTIAL_WITHDRAWALS_LIMIT]
|
|
189
|
+
+ pending_consolidations: List[PendingConsolidation, PENDING_CONSOLIDATIONS_LIMIT]
|
|
190
|
+
</spec>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
> [!NOTE]
|
|
194
|
+
> Comments are stripped from the specifications when the `diff` style is used. We do this because
|
|
195
|
+
> these complicate the diff; the "[Modified in Fork]" comments aren't valuable here.
|
|
196
|
+
|
|
197
|
+
This can be used with any specification item, like functions too:
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
<spec fn="is_eligible_for_activation_queue" fork="electra" style="diff">
|
|
201
|
+
--- phase0
|
|
202
|
+
+++ electra
|
|
203
|
+
@@ -4,5 +4,5 @@
|
|
204
|
+
"""
|
|
205
|
+
return (
|
|
206
|
+
validator.activation_eligibility_epoch == FAR_FUTURE_EPOCH
|
|
207
|
+
- and validator.effective_balance == MAX_EFFECTIVE_BALANCE
|
|
208
|
+
+ and validator.effective_balance >= MIN_ACTIVATION_BALANCE
|
|
209
|
+
)
|
|
210
|
+
</spec>
|
|
211
|
+
```
|
|
@@ -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, get_yaml_filename_for_spec_attr, get_spec_attr_and_name, add_missing_entries_to_yaml
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
def process(args):
|
|
@@ -16,20 +16,37 @@ def process(args):
|
|
|
16
16
|
# Load config once from the project directory
|
|
17
17
|
config = load_config(project_dir)
|
|
18
18
|
|
|
19
|
-
#
|
|
20
|
-
for f in grep(project_dir, r"<spec\b.*?>", args.exclude):
|
|
21
|
-
print(f"Processing file: {f}")
|
|
22
|
-
replace_spec_tags(f, config)
|
|
23
|
-
|
|
24
|
-
# Sort specref YAML files if they exist in config
|
|
19
|
+
# Check if auto_add_missing_entries and auto_standardize_names are enabled
|
|
25
20
|
specrefs_config = config.get('specrefs', {})
|
|
26
21
|
if isinstance(specrefs_config, dict):
|
|
22
|
+
auto_add_missing = specrefs_config.get('auto_add_missing_entries', False)
|
|
23
|
+
auto_standardize_names = specrefs_config.get('auto_standardize_names', False)
|
|
27
24
|
specrefs_files = specrefs_config.get('files', [])
|
|
28
25
|
elif isinstance(specrefs_config, list):
|
|
26
|
+
auto_add_missing = False
|
|
27
|
+
auto_standardize_names = False
|
|
29
28
|
specrefs_files = specrefs_config
|
|
30
29
|
else:
|
|
30
|
+
auto_add_missing = False
|
|
31
|
+
auto_standardize_names = False
|
|
31
32
|
specrefs_files = []
|
|
32
33
|
|
|
34
|
+
# Process spec tags in files
|
|
35
|
+
for f in grep(project_dir, r"<spec\b.*?>", args.exclude):
|
|
36
|
+
print(f"Processing file: {f}")
|
|
37
|
+
replace_spec_tags(f, config)
|
|
38
|
+
|
|
39
|
+
# Add missing spec items to YAML files if enabled
|
|
40
|
+
if auto_add_missing:
|
|
41
|
+
from .core import add_missing_spec_items_to_yaml_files
|
|
42
|
+
add_missing_spec_items_to_yaml_files(project_dir, config, specrefs_files)
|
|
43
|
+
|
|
44
|
+
# Update entry names to <spec_item>#<fork> format if enabled
|
|
45
|
+
if auto_standardize_names:
|
|
46
|
+
from .core import update_entry_names_in_yaml_files
|
|
47
|
+
update_entry_names_in_yaml_files(project_dir, specrefs_files)
|
|
48
|
+
|
|
49
|
+
# Sort specref YAML files if they exist in config
|
|
33
50
|
for yaml_file in specrefs_files:
|
|
34
51
|
yaml_path = os.path.join(project_dir, yaml_file)
|
|
35
52
|
if os.path.exists(yaml_path):
|
|
@@ -182,6 +199,28 @@ def list_forks(args):
|
|
|
182
199
|
return 0
|
|
183
200
|
|
|
184
201
|
|
|
202
|
+
def init(args):
|
|
203
|
+
"""Initialize a specrefs directory with basic configuration and empty source mappings."""
|
|
204
|
+
output_dir = args.path or "specrefs"
|
|
205
|
+
version = args.version
|
|
206
|
+
|
|
207
|
+
# Check if output directory already exists
|
|
208
|
+
if os.path.exists(output_dir):
|
|
209
|
+
print(f"Error: directory {repr(output_dir)} already exists.")
|
|
210
|
+
print("Please specify a different directory or remove the existing one.")
|
|
211
|
+
return 1
|
|
212
|
+
|
|
213
|
+
try:
|
|
214
|
+
# Generate the specref files
|
|
215
|
+
print(f"Initializing specrefs directory: {version}")
|
|
216
|
+
generate_specref_files(output_dir, version, "mainnet")
|
|
217
|
+
print(f"Successfully created specrefs directory at: {output_dir}")
|
|
218
|
+
return 0
|
|
219
|
+
except Exception as e:
|
|
220
|
+
print(f"Error: {e}")
|
|
221
|
+
return 1
|
|
222
|
+
|
|
223
|
+
|
|
185
224
|
def main():
|
|
186
225
|
parser = argparse.ArgumentParser(
|
|
187
226
|
description="Process files containing <spec> tags."
|
|
@@ -256,6 +295,21 @@ def main():
|
|
|
256
295
|
help="Output format (text or json)",
|
|
257
296
|
)
|
|
258
297
|
|
|
298
|
+
# Parser for 'init' command
|
|
299
|
+
init_parser = subparsers.add_parser("init", help="Initialize a specrefs directory")
|
|
300
|
+
init_parser.set_defaults(func=init)
|
|
301
|
+
init_parser.add_argument(
|
|
302
|
+
"version",
|
|
303
|
+
type=str,
|
|
304
|
+
help="Specification version (e.g., 'nightly' or 'v1.6.0-alpha.5')",
|
|
305
|
+
)
|
|
306
|
+
init_parser.add_argument(
|
|
307
|
+
"--path",
|
|
308
|
+
type=str,
|
|
309
|
+
help="Output directory for specrefs (default: specrefs)",
|
|
310
|
+
default="specrefs",
|
|
311
|
+
)
|
|
312
|
+
|
|
259
313
|
# Default to 'process' if no args are provided
|
|
260
314
|
if len(sys.argv) == 1:
|
|
261
315
|
sys.argv.insert(1, "process")
|