ethspecify 0.3.4__tar.gz → 0.3.6__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.4 → ethspecify-0.3.6}/PKG-INFO +3 -3
- {ethspecify-0.3.4 → ethspecify-0.3.6}/README.md +2 -2
- {ethspecify-0.3.4 → ethspecify-0.3.6}/ethspecify/cli.py +1 -1
- {ethspecify-0.3.4 → ethspecify-0.3.6}/ethspecify/core.py +83 -23
- {ethspecify-0.3.4 → ethspecify-0.3.6}/ethspecify.egg-info/PKG-INFO +3 -3
- {ethspecify-0.3.4 → ethspecify-0.3.6}/setup.py +1 -1
- {ethspecify-0.3.4 → ethspecify-0.3.6}/LICENSE +0 -0
- {ethspecify-0.3.4 → ethspecify-0.3.6}/ethspecify/__init__.py +0 -0
- {ethspecify-0.3.4 → ethspecify-0.3.6}/ethspecify.egg-info/SOURCES.txt +0 -0
- {ethspecify-0.3.4 → ethspecify-0.3.6}/ethspecify.egg-info/dependency_links.txt +0 -0
- {ethspecify-0.3.4 → ethspecify-0.3.6}/ethspecify.egg-info/entry_points.txt +0 -0
- {ethspecify-0.3.4 → ethspecify-0.3.6}/ethspecify.egg-info/requires.txt +0 -0
- {ethspecify-0.3.4 → ethspecify-0.3.6}/ethspecify.egg-info/top_level.txt +0 -0
- {ethspecify-0.3.4 → ethspecify-0.3.6}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ethspecify
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.6
|
|
4
4
|
Summary: A utility for processing Ethereum specification tags.
|
|
5
5
|
Home-page: https://github.com/jtraglia/ethspecify
|
|
6
6
|
Author: Justin Traglia
|
|
@@ -184,11 +184,11 @@ def is_fully_withdrawable_validator(validator: Validator, balance: Gwei, epoch:
|
|
|
184
184
|
|
|
185
185
|
### `link`
|
|
186
186
|
|
|
187
|
-
This style displays
|
|
187
|
+
This style displays an ethspec.tools link to the specification item.
|
|
188
188
|
|
|
189
189
|
```
|
|
190
190
|
<spec fn="apply_pending_deposit" fork="electra" style="link" hash="83ee9126">
|
|
191
|
-
https://
|
|
191
|
+
https://ethspec.tools/#specs/v1.7.0-alpha.1/functions-apply_pending_deposit-electra
|
|
192
192
|
</spec>
|
|
193
193
|
```
|
|
194
194
|
|
|
@@ -158,11 +158,11 @@ def is_fully_withdrawable_validator(validator: Validator, balance: Gwei, epoch:
|
|
|
158
158
|
|
|
159
159
|
### `link`
|
|
160
160
|
|
|
161
|
-
This style displays
|
|
161
|
+
This style displays an ethspec.tools link to the specification item.
|
|
162
162
|
|
|
163
163
|
```
|
|
164
164
|
<spec fn="apply_pending_deposit" fork="electra" style="link" hash="83ee9126">
|
|
165
|
-
https://
|
|
165
|
+
https://ethspec.tools/#specs/v1.7.0-alpha.1/functions-apply_pending_deposit-electra
|
|
166
166
|
</spec>
|
|
167
167
|
```
|
|
168
168
|
|
|
@@ -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,
|
|
6
|
+
from .core import grep, replace_spec_tags, get_pyspec, get_spec_item_history, load_config, run_checks, sort_specref_yaml, generate_specref_files
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
def process(args):
|
|
@@ -11,7 +11,7 @@ import tokenize
|
|
|
11
11
|
import yaml
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
def validate_exception_items(exceptions, version):
|
|
14
|
+
def validate_exception_items(exceptions, version, require_exceptions_have_fork=False):
|
|
15
15
|
"""
|
|
16
16
|
Validate that exception items actually exist in the spec.
|
|
17
17
|
Raises an exception if any item doesn't exist.
|
|
@@ -69,6 +69,9 @@ def validate_exception_items(exceptions, version):
|
|
|
69
69
|
# If no fork specified, we'll check if it exists in any fork
|
|
70
70
|
item_name = item
|
|
71
71
|
fork = None
|
|
72
|
+
if require_exceptions_have_fork:
|
|
73
|
+
errors.append(f"invalid key: {exception_key}.{item_name} (missing fork)")
|
|
74
|
+
continue
|
|
72
75
|
|
|
73
76
|
# Check if the item exists
|
|
74
77
|
item_found = False
|
|
@@ -116,14 +119,19 @@ def load_config(directory=None):
|
|
|
116
119
|
# Get version from config, default to 'nightly'
|
|
117
120
|
version = config.get('version', 'nightly')
|
|
118
121
|
|
|
122
|
+
specrefs_require = False
|
|
123
|
+
if 'specrefs' in config and isinstance(config['specrefs'], dict):
|
|
124
|
+
specrefs_require = config['specrefs'].get('require_exceptions_have_fork', False)
|
|
125
|
+
require_exceptions_have_fork = config.get('require_exceptions_have_fork', False) or specrefs_require
|
|
126
|
+
|
|
119
127
|
# Validate exceptions in root config
|
|
120
128
|
if 'exceptions' in config:
|
|
121
|
-
validate_exception_items(config['exceptions'], version)
|
|
129
|
+
validate_exception_items(config['exceptions'], version, require_exceptions_have_fork)
|
|
122
130
|
|
|
123
131
|
# Also validate exceptions in specrefs section if present
|
|
124
132
|
if 'specrefs' in config and isinstance(config['specrefs'], dict):
|
|
125
133
|
if 'exceptions' in config['specrefs']:
|
|
126
|
-
validate_exception_items(config['specrefs']['exceptions'], version)
|
|
134
|
+
validate_exception_items(config['specrefs']['exceptions'], version, require_exceptions_have_fork)
|
|
127
135
|
|
|
128
136
|
return config
|
|
129
137
|
except (yaml.YAMLError, IOError) as e:
|
|
@@ -227,14 +235,6 @@ def diff(a_name, a_content, b_name, b_content):
|
|
|
227
235
|
return "\n".join(diff)
|
|
228
236
|
|
|
229
237
|
|
|
230
|
-
@functools.lru_cache()
|
|
231
|
-
def get_links(version="nightly"):
|
|
232
|
-
url = f"https://raw.githubusercontent.com/jtraglia/ethspecify/main/pyspec/{version}/links.json"
|
|
233
|
-
response = requests.get(url)
|
|
234
|
-
response.raise_for_status()
|
|
235
|
-
return response.json()
|
|
236
|
-
|
|
237
|
-
|
|
238
238
|
@functools.lru_cache()
|
|
239
239
|
def get_pyspec(version="nightly"):
|
|
240
240
|
url = f"https://raw.githubusercontent.com/jtraglia/ethspecify/main/pyspec/{version}/pyspec.json"
|
|
@@ -555,23 +555,39 @@ def get_spec_item(attributes, config=None):
|
|
|
555
555
|
raise Exception("there is no previous spec for this")
|
|
556
556
|
return diff(previous_fork, strip_comments(previous_spec), fork, strip_comments(spec))
|
|
557
557
|
if style == "link":
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
raise Exception(f"cannot contain 'function' and 'fn'")
|
|
561
|
-
if "function" in attributes:
|
|
562
|
-
function_name = attributes["function"]
|
|
563
|
-
else:
|
|
564
|
-
function_name = attributes["fn"]
|
|
565
|
-
for key, value in get_links(version).items():
|
|
566
|
-
if fork in key and key.endswith(function_name):
|
|
567
|
-
return value
|
|
568
|
-
return "Could not find link"
|
|
569
|
-
else:
|
|
558
|
+
link = build_spec_link(attributes, fork, version)
|
|
559
|
+
if link is None:
|
|
570
560
|
return "Not available for this type of spec"
|
|
561
|
+
return link
|
|
571
562
|
else:
|
|
572
563
|
raise Exception("invalid style type")
|
|
573
564
|
|
|
574
565
|
|
|
566
|
+
def build_spec_link(attributes, fork, version):
|
|
567
|
+
base = f"https://ethspec.tools/#specs/{version}"
|
|
568
|
+
if "function" in attributes or "fn" in attributes:
|
|
569
|
+
if "function" in attributes and "fn" in attributes:
|
|
570
|
+
raise Exception(f"cannot contain 'function' and 'fn'")
|
|
571
|
+
function_name = attributes.get("function", attributes.get("fn"))
|
|
572
|
+
return f"{base}/functions-{function_name}-{fork}"
|
|
573
|
+
if "constant_var" in attributes:
|
|
574
|
+
return f"{base}/constant_vars-{attributes['constant_var']}-{fork}"
|
|
575
|
+
if "preset_var" in attributes:
|
|
576
|
+
return f"{base}/preset_vars-{attributes['preset_var']}-{fork}"
|
|
577
|
+
if "config_var" in attributes:
|
|
578
|
+
return f"{base}/config_vars-{attributes['config_var']}-{fork}"
|
|
579
|
+
if "custom_type" in attributes:
|
|
580
|
+
return f"{base}/custom_types-{attributes['custom_type']}-{fork}"
|
|
581
|
+
if "ssz_object" in attributes or "container" in attributes:
|
|
582
|
+
if "ssz_object" in attributes and "container" in attributes:
|
|
583
|
+
raise Exception(f"cannot contain 'ssz_object' and 'container'")
|
|
584
|
+
object_name = attributes.get("ssz_object", attributes.get("container"))
|
|
585
|
+
return f"{base}/ssz_objects-{object_name}-{fork}"
|
|
586
|
+
if "dataclass" in attributes:
|
|
587
|
+
return f"{base}/dataclasses-{attributes['dataclass']}-{fork}"
|
|
588
|
+
return None
|
|
589
|
+
|
|
590
|
+
|
|
575
591
|
def extract_attributes(tag):
|
|
576
592
|
attr_pattern = re.compile(r'(\w+)="(.*?)"')
|
|
577
593
|
return dict(attr_pattern.findall(tag))
|
|
@@ -1798,6 +1814,31 @@ def add_missing_spec_items_to_yaml_files(project_dir, config, specrefs_files):
|
|
|
1798
1814
|
"""
|
|
1799
1815
|
version = config.get('version', 'nightly')
|
|
1800
1816
|
preset = 'mainnet' # Could make this configurable
|
|
1817
|
+
specrefs_config = config.get('specrefs', {})
|
|
1818
|
+
|
|
1819
|
+
# Resolve exceptions (support root or specrefs section, but not both)
|
|
1820
|
+
if isinstance(specrefs_config, list):
|
|
1821
|
+
exceptions = config.get('exceptions', {})
|
|
1822
|
+
else:
|
|
1823
|
+
specrefs_exceptions = specrefs_config.get('exceptions', {})
|
|
1824
|
+
root_exceptions = config.get('exceptions', {})
|
|
1825
|
+
if specrefs_exceptions and root_exceptions:
|
|
1826
|
+
print("Warning: Exceptions found in both root and specrefs sections. Using specrefs exceptions.")
|
|
1827
|
+
exceptions = specrefs_exceptions
|
|
1828
|
+
elif specrefs_exceptions:
|
|
1829
|
+
exceptions = specrefs_exceptions
|
|
1830
|
+
else:
|
|
1831
|
+
exceptions = root_exceptions
|
|
1832
|
+
|
|
1833
|
+
category_exception_keys = {
|
|
1834
|
+
'ssz_objects': ['ssz_objects', 'ssz_object', 'containers', 'container'],
|
|
1835
|
+
'config_vars': ['configs', 'config_variables', 'config_var'],
|
|
1836
|
+
'preset_vars': ['presets', 'preset_variables', 'preset_var'],
|
|
1837
|
+
'dataclasses': ['dataclasses', 'dataclass'],
|
|
1838
|
+
'functions': ['functions', 'fn'],
|
|
1839
|
+
'constant_vars': ['constants', 'constant_variables', 'constant_var'],
|
|
1840
|
+
'custom_types': ['custom_types', 'custom_type']
|
|
1841
|
+
}
|
|
1801
1842
|
|
|
1802
1843
|
# Get all spec items
|
|
1803
1844
|
pyspec = get_pyspec(version)
|
|
@@ -1830,6 +1871,14 @@ def add_missing_spec_items_to_yaml_files(project_dir, config, specrefs_files):
|
|
|
1830
1871
|
continue
|
|
1831
1872
|
|
|
1832
1873
|
category, spec_attr = filename_to_category[yaml_basename]
|
|
1874
|
+
type_exceptions = []
|
|
1875
|
+
if isinstance(exceptions, dict) and category in category_exception_keys:
|
|
1876
|
+
for key in category_exception_keys[category]:
|
|
1877
|
+
if key in exceptions:
|
|
1878
|
+
type_exceptions = exceptions[key]
|
|
1879
|
+
break
|
|
1880
|
+
if type_exceptions and not isinstance(type_exceptions, list):
|
|
1881
|
+
type_exceptions = [type_exceptions]
|
|
1833
1882
|
|
|
1834
1883
|
# Collect all items in this category organized by name and fork
|
|
1835
1884
|
items_by_name = {}
|
|
@@ -1885,6 +1934,17 @@ def add_missing_spec_items_to_yaml_files(project_dir, config, specrefs_files):
|
|
|
1885
1934
|
versions.append((fork, item_data, spec_content))
|
|
1886
1935
|
prev_content = spec_content
|
|
1887
1936
|
|
|
1937
|
+
# Skip versions that are excepted for this item
|
|
1938
|
+
if type_exceptions:
|
|
1939
|
+
versions = [
|
|
1940
|
+
(fork, item_data, spec_content)
|
|
1941
|
+
for fork, item_data, spec_content in versions
|
|
1942
|
+
if not is_excepted(item_name, fork, type_exceptions)
|
|
1943
|
+
]
|
|
1944
|
+
|
|
1945
|
+
if not versions:
|
|
1946
|
+
continue
|
|
1947
|
+
|
|
1888
1948
|
# Create entries based on number of unique versions
|
|
1889
1949
|
use_fork_suffix = len(versions) > 1
|
|
1890
1950
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ethspecify
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.6
|
|
4
4
|
Summary: A utility for processing Ethereum specification tags.
|
|
5
5
|
Home-page: https://github.com/jtraglia/ethspecify
|
|
6
6
|
Author: Justin Traglia
|
|
@@ -184,11 +184,11 @@ def is_fully_withdrawable_validator(validator: Validator, balance: Gwei, epoch:
|
|
|
184
184
|
|
|
185
185
|
### `link`
|
|
186
186
|
|
|
187
|
-
This style displays
|
|
187
|
+
This style displays an ethspec.tools link to the specification item.
|
|
188
188
|
|
|
189
189
|
```
|
|
190
190
|
<spec fn="apply_pending_deposit" fork="electra" style="link" hash="83ee9126">
|
|
191
|
-
https://
|
|
191
|
+
https://ethspec.tools/#specs/v1.7.0-alpha.1/functions-apply_pending_deposit-electra
|
|
192
192
|
</spec>
|
|
193
193
|
```
|
|
194
194
|
|
|
@@ -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.3.
|
|
11
|
+
version="0.3.6",
|
|
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
|