ethspecify 0.1.0__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.
Potentially problematic release.
This version of ethspecify might be problematic. Click here for more details.
- ethspecify-0.1.0/LICENSE +21 -0
- ethspecify-0.1.0/PKG-INFO +369 -0
- ethspecify-0.1.0/README.md +345 -0
- ethspecify-0.1.0/ethspecify/__init__.py +0 -0
- ethspecify-0.1.0/ethspecify/cli.py +34 -0
- ethspecify-0.1.0/ethspecify/core.py +325 -0
- ethspecify-0.1.0/ethspecify.egg-info/PKG-INFO +369 -0
- ethspecify-0.1.0/ethspecify.egg-info/SOURCES.txt +12 -0
- ethspecify-0.1.0/ethspecify.egg-info/dependency_links.txt +1 -0
- ethspecify-0.1.0/ethspecify.egg-info/entry_points.txt +2 -0
- ethspecify-0.1.0/ethspecify.egg-info/requires.txt +1 -0
- ethspecify-0.1.0/ethspecify.egg-info/top_level.txt +1 -0
- ethspecify-0.1.0/setup.cfg +4 -0
- ethspecify-0.1.0/setup.py +33 -0
ethspecify-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Justin Traglia
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: ethspecify
|
|
3
|
+
Version: 0.1.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
|
+
Dynamic: author
|
|
16
|
+
Dynamic: author-email
|
|
17
|
+
Dynamic: classifier
|
|
18
|
+
Dynamic: description
|
|
19
|
+
Dynamic: description-content-type
|
|
20
|
+
Dynamic: home-page
|
|
21
|
+
Dynamic: requires-dist
|
|
22
|
+
Dynamic: requires-python
|
|
23
|
+
Dynamic: summary
|
|
24
|
+
|
|
25
|
+
# ethspecify
|
|
26
|
+
|
|
27
|
+
A tool for referencing the Ethereum specifications in clients.
|
|
28
|
+
|
|
29
|
+
The idea is that ethspecify will help developers keep track of when the specification changes. It
|
|
30
|
+
will also help auditors verify that the client implementations match the specifications. Ideally,
|
|
31
|
+
this is configured as a CI check which notifies client developers when the specification changes.
|
|
32
|
+
When that happens, they can update the implementations appropriately.
|
|
33
|
+
|
|
34
|
+
## Getting Started
|
|
35
|
+
|
|
36
|
+
### Adding Spec Tags
|
|
37
|
+
|
|
38
|
+
In your client, add an HTML tag like this:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
/*
|
|
42
|
+
* <spec fn="is_fully_withdrawable_validator" fork="deneb">
|
|
43
|
+
*/
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
This supports all languages and comment styles. It preserves indentation, so something like this
|
|
47
|
+
would also work:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
/// <spec fn="is_fully_withdrawable_validator" fork="deneb">
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
After the script is finished executing, a new `hash` field will exist in the tag. This tag is used
|
|
54
|
+
to tell if the specification changed, without having to include the specification content.
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
/// <spec fn="is_fully_withdrawable_validator" fork="deneb" hash="e936da25" />
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
> [!NOTE]
|
|
61
|
+
> Closing tags will be added automatically. For `style="hash"` tags, a self-closing tag is used for
|
|
62
|
+
> conciseness. For `style="full"` and `style="diff"` tags, a paired closing tag must be used.
|
|
63
|
+
|
|
64
|
+
### Installation
|
|
65
|
+
|
|
66
|
+
#### Install with Pip
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
python3 -mpip install ethspecify
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
#### Manual Install
|
|
73
|
+
|
|
74
|
+
First, clone the repository. You only need the latest commit.
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
git clone https://github.com/jtraglia/ethspecify.git --depth=1
|
|
78
|
+
cd ethspecify
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Next, build and install the utility.
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
python3 -mpip install .
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Then, change directory to the source source directory and run `ethspecify`.
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
Projects/client$ ethspecify
|
|
91
|
+
Processing file: /Users/user/Projects/client/src/file.ext
|
|
92
|
+
spec tag: {'custom_type': 'Blob', 'fork': 'electra'}
|
|
93
|
+
spec tag: {'dataclass': 'PayloadAttributes', 'fork': 'electra'}
|
|
94
|
+
spec tag: {'ssz_object': 'ConsolidationRequest', 'fork': 'electra'}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Specification Options
|
|
98
|
+
|
|
99
|
+
#### Fork
|
|
100
|
+
|
|
101
|
+
This attribute can be any of the [executable
|
|
102
|
+
specifications](https://github.com/ethereum/consensus-specs/blob/e6bddd966214a19d2b97199bbe3c02577a22a8b4/Makefile#L3-L15)
|
|
103
|
+
in the consensus-specs. At the time of writing, these are: phase0, altair, bellatrix, capella,
|
|
104
|
+
deneb, electra, fulu, whisk, eip6800, and eip7732.
|
|
105
|
+
|
|
106
|
+
#### Style
|
|
107
|
+
|
|
108
|
+
This attribute can be used to change how the specification content is shown.
|
|
109
|
+
|
|
110
|
+
##### `hash` (default)
|
|
111
|
+
|
|
112
|
+
This style adds a hash of the specification content to the spec tag, without showing the content.
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
/*
|
|
116
|
+
* <spec fn="apply_deposit" fork="electra" hash="c723ce7b" />
|
|
117
|
+
*/
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
> [!NOTE]
|
|
121
|
+
> The hash is the first 8 characters of the specification content's SHA256 digest.
|
|
122
|
+
|
|
123
|
+
##### `full`
|
|
124
|
+
|
|
125
|
+
This style displays the whole content of this specification item, including comments.
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
/*
|
|
129
|
+
* <spec fn="is_fully_withdrawable_validator" fork="deneb" style="full">
|
|
130
|
+
* def is_fully_withdrawable_validator(validator: Validator, balance: Gwei, epoch: Epoch) -> bool:
|
|
131
|
+
* """
|
|
132
|
+
* Check if ``validator`` is fully withdrawable.
|
|
133
|
+
* """
|
|
134
|
+
* return (
|
|
135
|
+
* has_eth1_withdrawal_credential(validator)
|
|
136
|
+
* and validator.withdrawable_epoch <= epoch
|
|
137
|
+
* and balance > 0
|
|
138
|
+
* )
|
|
139
|
+
* </spec>
|
|
140
|
+
*/
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
##### `link`
|
|
144
|
+
|
|
145
|
+
> [!WARNING]
|
|
146
|
+
> This feature is a work-in-progress.
|
|
147
|
+
|
|
148
|
+
This style displays a GitHub link to the specification item.
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
/*
|
|
152
|
+
* <spec fn="apply_pending_deposit" fork="electra" style="link" hash="83ee9126">
|
|
153
|
+
* https://github.com/ethereum/consensus-specs/blob/dev/specs/electra/beacon-chain.md#new-apply_pending_deposit
|
|
154
|
+
* </spec>
|
|
155
|
+
*/
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
##### `diff`
|
|
159
|
+
|
|
160
|
+
This style displays a diff with the previous fork's version of the specification.
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
/*
|
|
164
|
+
* <spec ssz_object="BeaconState" fork="electra" style="diff">
|
|
165
|
+
* --- deneb
|
|
166
|
+
* +++ electra
|
|
167
|
+
* @@ -27,3 +27,12 @@
|
|
168
|
+
* next_withdrawal_index: WithdrawalIndex
|
|
169
|
+
* next_withdrawal_validator_index: ValidatorIndex
|
|
170
|
+
* historical_summaries: List[HistoricalSummary, HISTORICAL_ROOTS_LIMIT]
|
|
171
|
+
* + deposit_requests_start_index: uint64
|
|
172
|
+
* + deposit_balance_to_consume: Gwei
|
|
173
|
+
* + exit_balance_to_consume: Gwei
|
|
174
|
+
* + earliest_exit_epoch: Epoch
|
|
175
|
+
* + consolidation_balance_to_consume: Gwei
|
|
176
|
+
* + earliest_consolidation_epoch: Epoch
|
|
177
|
+
* + pending_deposits: List[PendingDeposit, PENDING_DEPOSITS_LIMIT]
|
|
178
|
+
* + pending_partial_withdrawals: List[PendingPartialWithdrawal, PENDING_PARTIAL_WITHDRAWALS_LIMIT]
|
|
179
|
+
* + pending_consolidations: List[PendingConsolidation, PENDING_CONSOLIDATIONS_LIMIT]
|
|
180
|
+
* </spec>
|
|
181
|
+
*/
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
> [!NOTE]
|
|
185
|
+
> Comments are stripped from the specifications when the `diff` style is used. We do this because
|
|
186
|
+
> these complicate the diff; the "[Modified in Fork]" comments aren't valuable here.
|
|
187
|
+
|
|
188
|
+
This can be used with any specification item, like functions too:
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
/*
|
|
192
|
+
* <spec fn="is_eligible_for_activation_queue" fork="electra" style="diff">
|
|
193
|
+
* --- phase0
|
|
194
|
+
* +++ electra
|
|
195
|
+
* @@ -4,5 +4,5 @@
|
|
196
|
+
* """
|
|
197
|
+
* return (
|
|
198
|
+
* validator.activation_eligibility_epoch == FAR_FUTURE_EPOCH
|
|
199
|
+
* - and validator.effective_balance == MAX_EFFECTIVE_BALANCE
|
|
200
|
+
* + and validator.effective_balance >= MIN_ACTIVATION_BALANCE
|
|
201
|
+
* )
|
|
202
|
+
* </spec>
|
|
203
|
+
*/
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Supported Specification Items
|
|
207
|
+
|
|
208
|
+
#### Constants
|
|
209
|
+
|
|
210
|
+
These are items found in the `Constants` section of the specifications.
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
/*
|
|
214
|
+
* <spec constant_var="COMPOUNDING_WITHDRAWAL_PREFIX" fork="electra" style="full">
|
|
215
|
+
* COMPOUNDING_WITHDRAWAL_PREFIX: Bytes1 = '0x02'
|
|
216
|
+
* </spec>
|
|
217
|
+
*/
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
#### Custom Types
|
|
221
|
+
|
|
222
|
+
These are items found in the `Custom types` section of the specifications.
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
/*
|
|
226
|
+
* <spec custom_type="Blob" fork="electra" style="full">
|
|
227
|
+
* Blob = ByteVector[BYTES_PER_FIELD_ELEMENT * FIELD_ELEMENTS_PER_BLOB]
|
|
228
|
+
* </spec>
|
|
229
|
+
*/
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
#### Preset Variables
|
|
233
|
+
|
|
234
|
+
These are items found in the
|
|
235
|
+
[`presets`](https://github.com/ethereum/consensus-specs/tree/dev/presets) directory.
|
|
236
|
+
|
|
237
|
+
For preset variables, in addition to the `preset_var` attribute, you can specify a `preset`
|
|
238
|
+
attribute: minimal or mainnet.
|
|
239
|
+
|
|
240
|
+
```
|
|
241
|
+
/*
|
|
242
|
+
* <spec preset="minimal" preset_var="PENDING_CONSOLIDATIONS_LIMIT" fork="electra" style="full">
|
|
243
|
+
* PENDING_CONSOLIDATIONS_LIMIT: uint64 = 64
|
|
244
|
+
* </spec>
|
|
245
|
+
*
|
|
246
|
+
* <spec preset="mainnet" preset_var="PENDING_CONSOLIDATIONS_LIMIT" fork="electra" style="full">
|
|
247
|
+
* PENDING_CONSOLIDATIONS_LIMIT: uint64 = 262144
|
|
248
|
+
* </spec>
|
|
249
|
+
*/
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
It's not strictly necessary to specify the preset attribute. The default preset is mainnet.
|
|
253
|
+
|
|
254
|
+
```
|
|
255
|
+
/*
|
|
256
|
+
* <spec preset_var="FIELD_ELEMENTS_PER_BLOB" fork="electra" style="full">
|
|
257
|
+
* FIELD_ELEMENTS_PER_BLOB: uint64 = 4096
|
|
258
|
+
* </spec>
|
|
259
|
+
*/
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
#### Config Variables
|
|
263
|
+
|
|
264
|
+
These are items found in the
|
|
265
|
+
[`configs`](https://github.com/ethereum/consensus-specs/tree/dev/presets) directory.
|
|
266
|
+
|
|
267
|
+
```
|
|
268
|
+
/*
|
|
269
|
+
* <spec config_var="MAX_REQUEST_BLOB_SIDECARS" fork="electra" style="full">
|
|
270
|
+
* MAX_REQUEST_BLOB_SIDECARS = 768
|
|
271
|
+
* </spec>
|
|
272
|
+
*/
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
#### SSZ Objects
|
|
276
|
+
|
|
277
|
+
These are items found in the `Containers` section of the specifications.
|
|
278
|
+
|
|
279
|
+
```
|
|
280
|
+
/*
|
|
281
|
+
* <spec ssz_object="ConsolidationRequest" fork="electra" style="full">
|
|
282
|
+
* class ConsolidationRequest(Container):
|
|
283
|
+
* source_address: ExecutionAddress
|
|
284
|
+
* source_pubkey: BLSPubkey
|
|
285
|
+
* target_pubkey: BLSPubkey
|
|
286
|
+
* </spec>
|
|
287
|
+
*/
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
#### Dataclasses
|
|
291
|
+
|
|
292
|
+
These are classes with the `@dataclass` decorator.
|
|
293
|
+
|
|
294
|
+
```
|
|
295
|
+
/*
|
|
296
|
+
* <spec dataclass="PayloadAttributes" fork="electra" style="full">
|
|
297
|
+
* class PayloadAttributes(object):
|
|
298
|
+
* timestamp: uint64
|
|
299
|
+
* prev_randao: Bytes32
|
|
300
|
+
* suggested_fee_recipient: ExecutionAddress
|
|
301
|
+
* withdrawals: Sequence[Withdrawal]
|
|
302
|
+
* parent_beacon_block_root: Root # [New in Deneb:EIP4788]
|
|
303
|
+
* </spec>
|
|
304
|
+
*/
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
#### Functions
|
|
308
|
+
|
|
309
|
+
These are all the functions found in the specifications.
|
|
310
|
+
|
|
311
|
+
For example, two versions of the same function:
|
|
312
|
+
|
|
313
|
+
```
|
|
314
|
+
/*
|
|
315
|
+
* <spec fn="is_fully_withdrawable_validator" fork="deneb" style="full">
|
|
316
|
+
* def is_fully_withdrawable_validator(validator: Validator, balance: Gwei, epoch: Epoch) -> bool:
|
|
317
|
+
* """
|
|
318
|
+
* Check if ``validator`` is fully withdrawable.
|
|
319
|
+
* """
|
|
320
|
+
* return (
|
|
321
|
+
* has_eth1_withdrawal_credential(validator)
|
|
322
|
+
* and validator.withdrawable_epoch <= epoch
|
|
323
|
+
* and balance > 0
|
|
324
|
+
* )
|
|
325
|
+
* </spec>
|
|
326
|
+
*/
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
```
|
|
330
|
+
/*
|
|
331
|
+
* <spec fn="is_fully_withdrawable_validator" fork="electra" style="full">
|
|
332
|
+
* def is_fully_withdrawable_validator(validator: Validator, balance: Gwei, epoch: Epoch) -> bool:
|
|
333
|
+
* """
|
|
334
|
+
* Check if ``validator`` is fully withdrawable.
|
|
335
|
+
* """
|
|
336
|
+
* return (
|
|
337
|
+
* has_execution_withdrawal_credential(validator) # [Modified in Electra:EIP7251]
|
|
338
|
+
* and validator.withdrawable_epoch <= epoch
|
|
339
|
+
* and balance > 0
|
|
340
|
+
* )
|
|
341
|
+
* </spec>
|
|
342
|
+
*/
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
With functions, it's possible to specify which line/lines should be displayed. For example:
|
|
346
|
+
|
|
347
|
+
```
|
|
348
|
+
/*
|
|
349
|
+
* <spec fn="is_fully_withdrawable_validator" fork="electra" style="full" lines="5-9">
|
|
350
|
+
* return (
|
|
351
|
+
* has_execution_withdrawal_credential(validator) # [Modified in Electra:EIP7251]
|
|
352
|
+
* and validator.withdrawable_epoch <= epoch
|
|
353
|
+
* and balance > 0
|
|
354
|
+
* )
|
|
355
|
+
* </spec>
|
|
356
|
+
*/
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
Note that the content is automatically dedented.
|
|
360
|
+
|
|
361
|
+
Or, to display just a single line, only specify a single number. For example:
|
|
362
|
+
|
|
363
|
+
```
|
|
364
|
+
/*
|
|
365
|
+
* <spec fn="is_fully_withdrawable_validator" fork="electra" style="full" lines="6">
|
|
366
|
+
* has_execution_withdrawal_credential(validator) # [Modified in Electra:EIP7251]
|
|
367
|
+
* </spec>
|
|
368
|
+
*/
|
|
369
|
+
```
|