ethspecify 0.1.0__tar.gz → 0.1.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.
Potentially problematic release.
This version of ethspecify might be problematic. Click here for more details.
- {ethspecify-0.1.0 → ethspecify-0.1.2}/PKG-INFO +28 -62
- {ethspecify-0.1.0 → ethspecify-0.1.2}/README.md +27 -61
- {ethspecify-0.1.0 → ethspecify-0.1.2}/ethspecify/cli.py +1 -1
- {ethspecify-0.1.0 → ethspecify-0.1.2}/ethspecify/core.py +56 -40
- {ethspecify-0.1.0 → ethspecify-0.1.2}/ethspecify.egg-info/PKG-INFO +28 -62
- {ethspecify-0.1.0 → ethspecify-0.1.2}/setup.py +1 -1
- {ethspecify-0.1.0 → ethspecify-0.1.2}/LICENSE +0 -0
- {ethspecify-0.1.0 → ethspecify-0.1.2}/ethspecify/__init__.py +0 -0
- {ethspecify-0.1.0 → ethspecify-0.1.2}/ethspecify.egg-info/SOURCES.txt +0 -0
- {ethspecify-0.1.0 → ethspecify-0.1.2}/ethspecify.egg-info/dependency_links.txt +0 -0
- {ethspecify-0.1.0 → ethspecify-0.1.2}/ethspecify.egg-info/entry_points.txt +0 -0
- {ethspecify-0.1.0 → ethspecify-0.1.2}/ethspecify.egg-info/requires.txt +0 -0
- {ethspecify-0.1.0 → ethspecify-0.1.2}/ethspecify.egg-info/top_level.txt +0 -0
- {ethspecify-0.1.0 → ethspecify-0.1.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: ethspecify
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: A utility for processing Ethereum specification tags.
|
|
5
5
|
Home-page: https://github.com/jtraglia/ethspecify
|
|
6
6
|
Author: Justin Traglia
|
|
@@ -33,81 +33,50 @@ When that happens, they can update the implementations appropriately.
|
|
|
33
33
|
|
|
34
34
|
## Getting Started
|
|
35
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
36
|
### Installation
|
|
65
37
|
|
|
66
|
-
#### Install with Pip
|
|
67
|
-
|
|
68
38
|
```
|
|
69
39
|
python3 -mpip install ethspecify
|
|
70
40
|
```
|
|
71
41
|
|
|
72
|
-
|
|
42
|
+
### Adding Spec Tags
|
|
73
43
|
|
|
74
|
-
|
|
44
|
+
In your client, add HTML tags like this:
|
|
75
45
|
|
|
76
46
|
```
|
|
77
|
-
|
|
78
|
-
|
|
47
|
+
/*
|
|
48
|
+
* <spec fn="is_fully_withdrawable_validator" fork="deneb">
|
|
49
|
+
*/
|
|
79
50
|
```
|
|
80
51
|
|
|
81
|
-
Next, build and install the utility.
|
|
82
|
-
|
|
83
52
|
```
|
|
84
|
-
|
|
53
|
+
/*
|
|
54
|
+
* <spec ssz_object="BeaconState" fork="electra" style="diff">
|
|
55
|
+
*/
|
|
85
56
|
```
|
|
86
57
|
|
|
87
|
-
|
|
58
|
+
### Populating Spec Tags
|
|
59
|
+
|
|
60
|
+
Then, navigate to your codebase and run `ethspecify`:
|
|
88
61
|
|
|
89
62
|
```
|
|
90
|
-
|
|
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'}
|
|
63
|
+
ethspecify
|
|
95
64
|
```
|
|
96
65
|
|
|
97
|
-
|
|
66
|
+
## Specification Options
|
|
98
67
|
|
|
99
|
-
|
|
68
|
+
### Fork
|
|
100
69
|
|
|
101
70
|
This attribute can be any of the [executable
|
|
102
71
|
specifications](https://github.com/ethereum/consensus-specs/blob/e6bddd966214a19d2b97199bbe3c02577a22a8b4/Makefile#L3-L15)
|
|
103
72
|
in the consensus-specs. At the time of writing, these are: phase0, altair, bellatrix, capella,
|
|
104
73
|
deneb, electra, fulu, whisk, eip6800, and eip7732.
|
|
105
74
|
|
|
106
|
-
|
|
75
|
+
### Style
|
|
107
76
|
|
|
108
77
|
This attribute can be used to change how the specification content is shown.
|
|
109
78
|
|
|
110
|
-
|
|
79
|
+
#### `hash` (default)
|
|
111
80
|
|
|
112
81
|
This style adds a hash of the specification content to the spec tag, without showing the content.
|
|
113
82
|
|
|
@@ -120,7 +89,7 @@ This style adds a hash of the specification content to the spec tag, without sho
|
|
|
120
89
|
> [!NOTE]
|
|
121
90
|
> The hash is the first 8 characters of the specification content's SHA256 digest.
|
|
122
91
|
|
|
123
|
-
|
|
92
|
+
#### `full`
|
|
124
93
|
|
|
125
94
|
This style displays the whole content of this specification item, including comments.
|
|
126
95
|
|
|
@@ -140,10 +109,7 @@ This style displays the whole content of this specification item, including comm
|
|
|
140
109
|
*/
|
|
141
110
|
```
|
|
142
111
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
> [!WARNING]
|
|
146
|
-
> This feature is a work-in-progress.
|
|
112
|
+
#### `link`
|
|
147
113
|
|
|
148
114
|
This style displays a GitHub link to the specification item.
|
|
149
115
|
|
|
@@ -155,7 +121,7 @@ This style displays a GitHub link to the specification item.
|
|
|
155
121
|
*/
|
|
156
122
|
```
|
|
157
123
|
|
|
158
|
-
|
|
124
|
+
#### `diff`
|
|
159
125
|
|
|
160
126
|
This style displays a diff with the previous fork's version of the specification.
|
|
161
127
|
|
|
@@ -203,9 +169,9 @@ This can be used with any specification item, like functions too:
|
|
|
203
169
|
*/
|
|
204
170
|
```
|
|
205
171
|
|
|
206
|
-
|
|
172
|
+
## Supported Specification Items
|
|
207
173
|
|
|
208
|
-
|
|
174
|
+
### Constants
|
|
209
175
|
|
|
210
176
|
These are items found in the `Constants` section of the specifications.
|
|
211
177
|
|
|
@@ -217,7 +183,7 @@ These are items found in the `Constants` section of the specifications.
|
|
|
217
183
|
*/
|
|
218
184
|
```
|
|
219
185
|
|
|
220
|
-
|
|
186
|
+
### Custom Types
|
|
221
187
|
|
|
222
188
|
These are items found in the `Custom types` section of the specifications.
|
|
223
189
|
|
|
@@ -229,7 +195,7 @@ These are items found in the `Custom types` section of the specifications.
|
|
|
229
195
|
*/
|
|
230
196
|
```
|
|
231
197
|
|
|
232
|
-
|
|
198
|
+
### Preset Variables
|
|
233
199
|
|
|
234
200
|
These are items found in the
|
|
235
201
|
[`presets`](https://github.com/ethereum/consensus-specs/tree/dev/presets) directory.
|
|
@@ -259,7 +225,7 @@ It's not strictly necessary to specify the preset attribute. The default preset
|
|
|
259
225
|
*/
|
|
260
226
|
```
|
|
261
227
|
|
|
262
|
-
|
|
228
|
+
### Config Variables
|
|
263
229
|
|
|
264
230
|
These are items found in the
|
|
265
231
|
[`configs`](https://github.com/ethereum/consensus-specs/tree/dev/presets) directory.
|
|
@@ -272,7 +238,7 @@ These are items found in the
|
|
|
272
238
|
*/
|
|
273
239
|
```
|
|
274
240
|
|
|
275
|
-
|
|
241
|
+
### SSZ Objects
|
|
276
242
|
|
|
277
243
|
These are items found in the `Containers` section of the specifications.
|
|
278
244
|
|
|
@@ -287,7 +253,7 @@ These are items found in the `Containers` section of the specifications.
|
|
|
287
253
|
*/
|
|
288
254
|
```
|
|
289
255
|
|
|
290
|
-
|
|
256
|
+
### Dataclasses
|
|
291
257
|
|
|
292
258
|
These are classes with the `@dataclass` decorator.
|
|
293
259
|
|
|
@@ -304,7 +270,7 @@ These are classes with the `@dataclass` decorator.
|
|
|
304
270
|
*/
|
|
305
271
|
```
|
|
306
272
|
|
|
307
|
-
|
|
273
|
+
### Functions
|
|
308
274
|
|
|
309
275
|
These are all the functions found in the specifications.
|
|
310
276
|
|
|
@@ -9,81 +9,50 @@ When that happens, they can update the implementations appropriately.
|
|
|
9
9
|
|
|
10
10
|
## Getting Started
|
|
11
11
|
|
|
12
|
-
### Adding Spec Tags
|
|
13
|
-
|
|
14
|
-
In your client, add an HTML tag like this:
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
/*
|
|
18
|
-
* <spec fn="is_fully_withdrawable_validator" fork="deneb">
|
|
19
|
-
*/
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
This supports all languages and comment styles. It preserves indentation, so something like this
|
|
23
|
-
would also work:
|
|
24
|
-
|
|
25
|
-
```
|
|
26
|
-
/// <spec fn="is_fully_withdrawable_validator" fork="deneb">
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
After the script is finished executing, a new `hash` field will exist in the tag. This tag is used
|
|
30
|
-
to tell if the specification changed, without having to include the specification content.
|
|
31
|
-
|
|
32
|
-
```
|
|
33
|
-
/// <spec fn="is_fully_withdrawable_validator" fork="deneb" hash="e936da25" />
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
> [!NOTE]
|
|
37
|
-
> Closing tags will be added automatically. For `style="hash"` tags, a self-closing tag is used for
|
|
38
|
-
> conciseness. For `style="full"` and `style="diff"` tags, a paired closing tag must be used.
|
|
39
|
-
|
|
40
12
|
### Installation
|
|
41
13
|
|
|
42
|
-
#### Install with Pip
|
|
43
|
-
|
|
44
14
|
```
|
|
45
15
|
python3 -mpip install ethspecify
|
|
46
16
|
```
|
|
47
17
|
|
|
48
|
-
|
|
18
|
+
### Adding Spec Tags
|
|
49
19
|
|
|
50
|
-
|
|
20
|
+
In your client, add HTML tags like this:
|
|
51
21
|
|
|
52
22
|
```
|
|
53
|
-
|
|
54
|
-
|
|
23
|
+
/*
|
|
24
|
+
* <spec fn="is_fully_withdrawable_validator" fork="deneb">
|
|
25
|
+
*/
|
|
55
26
|
```
|
|
56
27
|
|
|
57
|
-
Next, build and install the utility.
|
|
58
|
-
|
|
59
28
|
```
|
|
60
|
-
|
|
29
|
+
/*
|
|
30
|
+
* <spec ssz_object="BeaconState" fork="electra" style="diff">
|
|
31
|
+
*/
|
|
61
32
|
```
|
|
62
33
|
|
|
63
|
-
|
|
34
|
+
### Populating Spec Tags
|
|
35
|
+
|
|
36
|
+
Then, navigate to your codebase and run `ethspecify`:
|
|
64
37
|
|
|
65
38
|
```
|
|
66
|
-
|
|
67
|
-
Processing file: /Users/user/Projects/client/src/file.ext
|
|
68
|
-
spec tag: {'custom_type': 'Blob', 'fork': 'electra'}
|
|
69
|
-
spec tag: {'dataclass': 'PayloadAttributes', 'fork': 'electra'}
|
|
70
|
-
spec tag: {'ssz_object': 'ConsolidationRequest', 'fork': 'electra'}
|
|
39
|
+
ethspecify
|
|
71
40
|
```
|
|
72
41
|
|
|
73
|
-
|
|
42
|
+
## Specification Options
|
|
74
43
|
|
|
75
|
-
|
|
44
|
+
### Fork
|
|
76
45
|
|
|
77
46
|
This attribute can be any of the [executable
|
|
78
47
|
specifications](https://github.com/ethereum/consensus-specs/blob/e6bddd966214a19d2b97199bbe3c02577a22a8b4/Makefile#L3-L15)
|
|
79
48
|
in the consensus-specs. At the time of writing, these are: phase0, altair, bellatrix, capella,
|
|
80
49
|
deneb, electra, fulu, whisk, eip6800, and eip7732.
|
|
81
50
|
|
|
82
|
-
|
|
51
|
+
### Style
|
|
83
52
|
|
|
84
53
|
This attribute can be used to change how the specification content is shown.
|
|
85
54
|
|
|
86
|
-
|
|
55
|
+
#### `hash` (default)
|
|
87
56
|
|
|
88
57
|
This style adds a hash of the specification content to the spec tag, without showing the content.
|
|
89
58
|
|
|
@@ -96,7 +65,7 @@ This style adds a hash of the specification content to the spec tag, without sho
|
|
|
96
65
|
> [!NOTE]
|
|
97
66
|
> The hash is the first 8 characters of the specification content's SHA256 digest.
|
|
98
67
|
|
|
99
|
-
|
|
68
|
+
#### `full`
|
|
100
69
|
|
|
101
70
|
This style displays the whole content of this specification item, including comments.
|
|
102
71
|
|
|
@@ -116,10 +85,7 @@ This style displays the whole content of this specification item, including comm
|
|
|
116
85
|
*/
|
|
117
86
|
```
|
|
118
87
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
> [!WARNING]
|
|
122
|
-
> This feature is a work-in-progress.
|
|
88
|
+
#### `link`
|
|
123
89
|
|
|
124
90
|
This style displays a GitHub link to the specification item.
|
|
125
91
|
|
|
@@ -131,7 +97,7 @@ This style displays a GitHub link to the specification item.
|
|
|
131
97
|
*/
|
|
132
98
|
```
|
|
133
99
|
|
|
134
|
-
|
|
100
|
+
#### `diff`
|
|
135
101
|
|
|
136
102
|
This style displays a diff with the previous fork's version of the specification.
|
|
137
103
|
|
|
@@ -179,9 +145,9 @@ This can be used with any specification item, like functions too:
|
|
|
179
145
|
*/
|
|
180
146
|
```
|
|
181
147
|
|
|
182
|
-
|
|
148
|
+
## Supported Specification Items
|
|
183
149
|
|
|
184
|
-
|
|
150
|
+
### Constants
|
|
185
151
|
|
|
186
152
|
These are items found in the `Constants` section of the specifications.
|
|
187
153
|
|
|
@@ -193,7 +159,7 @@ These are items found in the `Constants` section of the specifications.
|
|
|
193
159
|
*/
|
|
194
160
|
```
|
|
195
161
|
|
|
196
|
-
|
|
162
|
+
### Custom Types
|
|
197
163
|
|
|
198
164
|
These are items found in the `Custom types` section of the specifications.
|
|
199
165
|
|
|
@@ -205,7 +171,7 @@ These are items found in the `Custom types` section of the specifications.
|
|
|
205
171
|
*/
|
|
206
172
|
```
|
|
207
173
|
|
|
208
|
-
|
|
174
|
+
### Preset Variables
|
|
209
175
|
|
|
210
176
|
These are items found in the
|
|
211
177
|
[`presets`](https://github.com/ethereum/consensus-specs/tree/dev/presets) directory.
|
|
@@ -235,7 +201,7 @@ It's not strictly necessary to specify the preset attribute. The default preset
|
|
|
235
201
|
*/
|
|
236
202
|
```
|
|
237
203
|
|
|
238
|
-
|
|
204
|
+
### Config Variables
|
|
239
205
|
|
|
240
206
|
These are items found in the
|
|
241
207
|
[`configs`](https://github.com/ethereum/consensus-specs/tree/dev/presets) directory.
|
|
@@ -248,7 +214,7 @@ These are items found in the
|
|
|
248
214
|
*/
|
|
249
215
|
```
|
|
250
216
|
|
|
251
|
-
|
|
217
|
+
### SSZ Objects
|
|
252
218
|
|
|
253
219
|
These are items found in the `Containers` section of the specifications.
|
|
254
220
|
|
|
@@ -263,7 +229,7 @@ These are items found in the `Containers` section of the specifications.
|
|
|
263
229
|
*/
|
|
264
230
|
```
|
|
265
231
|
|
|
266
|
-
|
|
232
|
+
### Dataclasses
|
|
267
233
|
|
|
268
234
|
These are classes with the `@dataclass` decorator.
|
|
269
235
|
|
|
@@ -280,7 +246,7 @@ These are classes with the `@dataclass` decorator.
|
|
|
280
246
|
*/
|
|
281
247
|
```
|
|
282
248
|
|
|
283
|
-
|
|
249
|
+
### Functions
|
|
284
250
|
|
|
285
251
|
These are all the functions found in the specifications.
|
|
286
252
|
|
|
@@ -272,50 +272,66 @@ def replace_spec_tags(file_path):
|
|
|
272
272
|
with open(file_path, 'r') as file:
|
|
273
273
|
content = file.read()
|
|
274
274
|
|
|
275
|
-
# Define regex to match
|
|
276
|
-
pattern = re.compile(
|
|
275
|
+
# Define regex to match self-closing tags and long (paired) tags separately
|
|
276
|
+
pattern = re.compile(
|
|
277
|
+
r'(?P<self><spec\b[^>]*\/>)|(?P<long><spec\b[^>]*>[\s\S]*?</spec>)',
|
|
278
|
+
re.DOTALL
|
|
279
|
+
)
|
|
277
280
|
|
|
278
281
|
def replacer(match):
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
# Update the full opening tag (opening_tag_full) to include the hash attribute.
|
|
298
|
-
if 'hash="' in opening_tag_full:
|
|
299
|
-
updated_opening = re.sub(
|
|
300
|
-
r'(hash=")[^"]*(")',
|
|
301
|
-
lambda m: f'{m.group(1)}{hash_value}{m.group(2)}',
|
|
302
|
-
opening_tag_full
|
|
303
|
-
)
|
|
282
|
+
if match.group("self") is not None:
|
|
283
|
+
# Process self-closing tag
|
|
284
|
+
tag_text = match.group("self")
|
|
285
|
+
attributes = extract_attributes(tag_text)
|
|
286
|
+
print(f"spec tag: {attributes}")
|
|
287
|
+
preset, fork, style = parse_common_attributes(attributes)
|
|
288
|
+
spec = get_spec(attributes, preset, fork)
|
|
289
|
+
hash_value = hashlib.sha256(spec.encode('utf-8')).hexdigest()[:8]
|
|
290
|
+
if 'hash="' in tag_text:
|
|
291
|
+
updated_tag = re.sub(
|
|
292
|
+
r'(hash=")[^"]*(")',
|
|
293
|
+
lambda m: f'{m.group(1)}{hash_value}{m.group(2)}',
|
|
294
|
+
tag_text
|
|
295
|
+
)
|
|
296
|
+
else:
|
|
297
|
+
# Insert hash attribute before the trailing '/>'
|
|
298
|
+
updated_tag = tag_text[:-2] + f' hash="{hash_value}"' + tag_text[-2:]
|
|
299
|
+
return updated_tag
|
|
304
300
|
else:
|
|
305
|
-
|
|
301
|
+
# Process long (paired) tag
|
|
302
|
+
tag_text = match.group("long")
|
|
303
|
+
# Extract the opening tag from the long tag (everything up to the first '>')
|
|
304
|
+
opening_match = re.match(r'(<spec\b[^>]*>)([\s\S]*)(</spec>)', tag_text, re.DOTALL)
|
|
305
|
+
if not opening_match:
|
|
306
|
+
return tag_text
|
|
307
|
+
opening_tag_full = opening_match.group(1)
|
|
308
|
+
attributes = extract_attributes(opening_tag_full)
|
|
309
|
+
print(f"spec tag: {attributes}")
|
|
310
|
+
preset, fork, style = parse_common_attributes(attributes)
|
|
311
|
+
spec = get_spec(attributes, preset, fork)
|
|
312
|
+
hash_value = hashlib.sha256(spec.encode('utf-8')).hexdigest()[:8]
|
|
313
|
+
if 'hash="' in opening_tag_full:
|
|
314
|
+
updated_opening = re.sub(
|
|
315
|
+
r'(hash=")[^"]*(")',
|
|
316
|
+
lambda m: f'{m.group(1)}{hash_value}{m.group(2)}',
|
|
317
|
+
opening_tag_full
|
|
318
|
+
)
|
|
319
|
+
else:
|
|
320
|
+
updated_opening = opening_tag_full[:-1] + f' hash="{hash_value}">'
|
|
321
|
+
if style == "hash":
|
|
322
|
+
updated_tag = re.sub(r'\s*</spec>\s*$', '', updated_opening)
|
|
323
|
+
updated_tag = re.sub(r'\s*>$', '', updated_tag) + " />"
|
|
324
|
+
else:
|
|
325
|
+
spec_content = get_spec_item(attributes)
|
|
326
|
+
prefix = content[:match.start()].splitlines()[-1]
|
|
327
|
+
prefixed_spec = "\n".join(
|
|
328
|
+
f"{prefix}{line}" if line.rstrip() else prefix.rstrip()
|
|
329
|
+
for line in spec_content.rstrip().split("\n")
|
|
330
|
+
)
|
|
331
|
+
long_opening = updated_opening.rstrip(">/") + ">"
|
|
332
|
+
updated_tag = f"{long_opening}\n{prefixed_spec}\n{prefix}</spec>"
|
|
333
|
+
return updated_tag
|
|
306
334
|
|
|
307
|
-
if style == "hash":
|
|
308
|
-
# For hash style, output a short self-closing tag with normalized spacing.
|
|
309
|
-
updated_tag = re.sub(r'\s*/?>\s*$', '', updated_opening) + " />"
|
|
310
|
-
else:
|
|
311
|
-
# For full/diff styles, output the long form with content.
|
|
312
|
-
spec_content = get_spec_item(attributes)
|
|
313
|
-
prefix = content[:match.start()].splitlines()[-1]
|
|
314
|
-
prefixed_spec = "\n".join(f"{prefix}{line}" if line.rstrip() else prefix.rstrip() for line in spec_content.rstrip().split("\n"))
|
|
315
|
-
long_opening = updated_opening.rstrip(">/") + ">"
|
|
316
|
-
updated_tag = f"{long_opening}\n{prefixed_spec}\n{prefix}</spec>"
|
|
317
|
-
|
|
318
|
-
return updated_tag
|
|
319
335
|
|
|
320
336
|
# Replace all matches in the content
|
|
321
337
|
updated_content = pattern.sub(replacer, content)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: ethspecify
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: A utility for processing Ethereum specification tags.
|
|
5
5
|
Home-page: https://github.com/jtraglia/ethspecify
|
|
6
6
|
Author: Justin Traglia
|
|
@@ -33,81 +33,50 @@ When that happens, they can update the implementations appropriately.
|
|
|
33
33
|
|
|
34
34
|
## Getting Started
|
|
35
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
36
|
### Installation
|
|
65
37
|
|
|
66
|
-
#### Install with Pip
|
|
67
|
-
|
|
68
38
|
```
|
|
69
39
|
python3 -mpip install ethspecify
|
|
70
40
|
```
|
|
71
41
|
|
|
72
|
-
|
|
42
|
+
### Adding Spec Tags
|
|
73
43
|
|
|
74
|
-
|
|
44
|
+
In your client, add HTML tags like this:
|
|
75
45
|
|
|
76
46
|
```
|
|
77
|
-
|
|
78
|
-
|
|
47
|
+
/*
|
|
48
|
+
* <spec fn="is_fully_withdrawable_validator" fork="deneb">
|
|
49
|
+
*/
|
|
79
50
|
```
|
|
80
51
|
|
|
81
|
-
Next, build and install the utility.
|
|
82
|
-
|
|
83
52
|
```
|
|
84
|
-
|
|
53
|
+
/*
|
|
54
|
+
* <spec ssz_object="BeaconState" fork="electra" style="diff">
|
|
55
|
+
*/
|
|
85
56
|
```
|
|
86
57
|
|
|
87
|
-
|
|
58
|
+
### Populating Spec Tags
|
|
59
|
+
|
|
60
|
+
Then, navigate to your codebase and run `ethspecify`:
|
|
88
61
|
|
|
89
62
|
```
|
|
90
|
-
|
|
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'}
|
|
63
|
+
ethspecify
|
|
95
64
|
```
|
|
96
65
|
|
|
97
|
-
|
|
66
|
+
## Specification Options
|
|
98
67
|
|
|
99
|
-
|
|
68
|
+
### Fork
|
|
100
69
|
|
|
101
70
|
This attribute can be any of the [executable
|
|
102
71
|
specifications](https://github.com/ethereum/consensus-specs/blob/e6bddd966214a19d2b97199bbe3c02577a22a8b4/Makefile#L3-L15)
|
|
103
72
|
in the consensus-specs. At the time of writing, these are: phase0, altair, bellatrix, capella,
|
|
104
73
|
deneb, electra, fulu, whisk, eip6800, and eip7732.
|
|
105
74
|
|
|
106
|
-
|
|
75
|
+
### Style
|
|
107
76
|
|
|
108
77
|
This attribute can be used to change how the specification content is shown.
|
|
109
78
|
|
|
110
|
-
|
|
79
|
+
#### `hash` (default)
|
|
111
80
|
|
|
112
81
|
This style adds a hash of the specification content to the spec tag, without showing the content.
|
|
113
82
|
|
|
@@ -120,7 +89,7 @@ This style adds a hash of the specification content to the spec tag, without sho
|
|
|
120
89
|
> [!NOTE]
|
|
121
90
|
> The hash is the first 8 characters of the specification content's SHA256 digest.
|
|
122
91
|
|
|
123
|
-
|
|
92
|
+
#### `full`
|
|
124
93
|
|
|
125
94
|
This style displays the whole content of this specification item, including comments.
|
|
126
95
|
|
|
@@ -140,10 +109,7 @@ This style displays the whole content of this specification item, including comm
|
|
|
140
109
|
*/
|
|
141
110
|
```
|
|
142
111
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
> [!WARNING]
|
|
146
|
-
> This feature is a work-in-progress.
|
|
112
|
+
#### `link`
|
|
147
113
|
|
|
148
114
|
This style displays a GitHub link to the specification item.
|
|
149
115
|
|
|
@@ -155,7 +121,7 @@ This style displays a GitHub link to the specification item.
|
|
|
155
121
|
*/
|
|
156
122
|
```
|
|
157
123
|
|
|
158
|
-
|
|
124
|
+
#### `diff`
|
|
159
125
|
|
|
160
126
|
This style displays a diff with the previous fork's version of the specification.
|
|
161
127
|
|
|
@@ -203,9 +169,9 @@ This can be used with any specification item, like functions too:
|
|
|
203
169
|
*/
|
|
204
170
|
```
|
|
205
171
|
|
|
206
|
-
|
|
172
|
+
## Supported Specification Items
|
|
207
173
|
|
|
208
|
-
|
|
174
|
+
### Constants
|
|
209
175
|
|
|
210
176
|
These are items found in the `Constants` section of the specifications.
|
|
211
177
|
|
|
@@ -217,7 +183,7 @@ These are items found in the `Constants` section of the specifications.
|
|
|
217
183
|
*/
|
|
218
184
|
```
|
|
219
185
|
|
|
220
|
-
|
|
186
|
+
### Custom Types
|
|
221
187
|
|
|
222
188
|
These are items found in the `Custom types` section of the specifications.
|
|
223
189
|
|
|
@@ -229,7 +195,7 @@ These are items found in the `Custom types` section of the specifications.
|
|
|
229
195
|
*/
|
|
230
196
|
```
|
|
231
197
|
|
|
232
|
-
|
|
198
|
+
### Preset Variables
|
|
233
199
|
|
|
234
200
|
These are items found in the
|
|
235
201
|
[`presets`](https://github.com/ethereum/consensus-specs/tree/dev/presets) directory.
|
|
@@ -259,7 +225,7 @@ It's not strictly necessary to specify the preset attribute. The default preset
|
|
|
259
225
|
*/
|
|
260
226
|
```
|
|
261
227
|
|
|
262
|
-
|
|
228
|
+
### Config Variables
|
|
263
229
|
|
|
264
230
|
These are items found in the
|
|
265
231
|
[`configs`](https://github.com/ethereum/consensus-specs/tree/dev/presets) directory.
|
|
@@ -272,7 +238,7 @@ These are items found in the
|
|
|
272
238
|
*/
|
|
273
239
|
```
|
|
274
240
|
|
|
275
|
-
|
|
241
|
+
### SSZ Objects
|
|
276
242
|
|
|
277
243
|
These are items found in the `Containers` section of the specifications.
|
|
278
244
|
|
|
@@ -287,7 +253,7 @@ These are items found in the `Containers` section of the specifications.
|
|
|
287
253
|
*/
|
|
288
254
|
```
|
|
289
255
|
|
|
290
|
-
|
|
256
|
+
### Dataclasses
|
|
291
257
|
|
|
292
258
|
These are classes with the `@dataclass` decorator.
|
|
293
259
|
|
|
@@ -304,7 +270,7 @@ These are classes with the `@dataclass` decorator.
|
|
|
304
270
|
*/
|
|
305
271
|
```
|
|
306
272
|
|
|
307
|
-
|
|
273
|
+
### Functions
|
|
308
274
|
|
|
309
275
|
These are all the functions found in the specifications.
|
|
310
276
|
|
|
@@ -8,7 +8,7 @@ long_description = (this_directory / "README.md").read_text(encoding="utf-8")
|
|
|
8
8
|
|
|
9
9
|
setup(
|
|
10
10
|
name="ethspecify",
|
|
11
|
-
version="0.1.
|
|
11
|
+
version="0.1.2",
|
|
12
12
|
description="A utility for processing Ethereum specification tags.",
|
|
13
13
|
long_description=long_description,
|
|
14
14
|
long_description_content_type="text/markdown",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|