ethspecify 0.2.0__py3-none-any.whl → 0.2.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/core.py CHANGED
@@ -83,23 +83,23 @@ def diff(a_name, a_content, b_name, b_content):
83
83
 
84
84
 
85
85
  @functools.lru_cache()
86
- def get_links():
87
- url = f"https://raw.githubusercontent.com/jtraglia/ethspecify/main/links.json"
86
+ def get_links(version="nightly"):
87
+ url = f"https://raw.githubusercontent.com/jtraglia/ethspecify/main/pyspec/{version}/links.json"
88
88
  response = requests.get(url)
89
89
  response.raise_for_status()
90
90
  return response.json()
91
91
 
92
92
 
93
93
  @functools.lru_cache()
94
- def get_pyspec():
95
- url = f"https://raw.githubusercontent.com/jtraglia/ethspecify/main/pyspec.json"
94
+ def get_pyspec(version="nightly"):
95
+ url = f"https://raw.githubusercontent.com/jtraglia/ethspecify/main/pyspec/{version}/pyspec.json"
96
96
  response = requests.get(url)
97
97
  response.raise_for_status()
98
98
  return response.json()
99
99
 
100
100
 
101
- def get_previous_forks(fork):
102
- pyspec = get_pyspec()
101
+ def get_previous_forks(fork, version="nightly"):
102
+ pyspec = get_pyspec(version)
103
103
  config_vars = pyspec["mainnet"][fork]["config_vars"]
104
104
  previous_forks = ["phase0"]
105
105
  for key in config_vars.keys():
@@ -111,8 +111,8 @@ def get_previous_forks(fork):
111
111
  return list(reversed(previous_forks))
112
112
 
113
113
 
114
- def get_spec(attributes, preset, fork):
115
- pyspec = get_pyspec()
114
+ def get_spec(attributes, preset, fork, version="nightly"):
115
+ pyspec = get_pyspec(version)
116
116
  spec = None
117
117
  if "function" in attributes or "fn" in attributes:
118
118
  if "function" in attributes and "fn" in attributes:
@@ -197,9 +197,9 @@ def get_spec(attributes, preset, fork):
197
197
  raise Exception("invalid spec tag")
198
198
  return spec
199
199
 
200
- def get_latest_fork():
200
+ def get_latest_fork(version="nightly"):
201
201
  """A helper function to get the latest non-eip fork."""
202
- pyspec = get_pyspec()
202
+ pyspec = get_pyspec(version)
203
203
  forks = sorted(
204
204
  pyspec["mainnet"].keys(),
205
205
  key=lambda x: (x != "phase0", x.startswith("eip"), x)
@@ -214,36 +214,41 @@ def parse_common_attributes(attributes):
214
214
  except KeyError:
215
215
  preset = "mainnet"
216
216
 
217
+ try:
218
+ version = attributes["version"]
219
+ except KeyError:
220
+ version = "nightly"
221
+
217
222
  try:
218
223
  fork = attributes["fork"]
219
224
  except KeyError:
220
- fork = get_latest_fork()
225
+ fork = get_latest_fork(version)
221
226
 
222
227
  try:
223
228
  style = attributes["style"]
224
229
  except KeyError:
225
230
  style = "hash"
226
231
 
227
- return preset, fork, style
232
+ return preset, fork, style, version
228
233
 
229
234
  def get_spec_item(attributes):
230
- preset, fork, style = parse_common_attributes(attributes)
231
- spec = get_spec(attributes, preset, fork)
235
+ preset, fork, style, version = parse_common_attributes(attributes)
236
+ spec = get_spec(attributes, preset, fork, version)
232
237
 
233
238
  if style == "full" or style == "hash":
234
239
  return spec
235
240
  elif style == "diff":
236
- previous_forks = get_previous_forks(fork)
241
+ previous_forks = get_previous_forks(fork, version)
237
242
 
238
243
  previous_fork = None
239
244
  previous_spec = None
240
245
  for i, _ in enumerate(previous_forks):
241
246
  previous_fork = previous_forks[i]
242
- previous_spec = get_spec(attributes, preset, previous_fork)
247
+ previous_spec = get_spec(attributes, preset, previous_fork, version)
243
248
  if previous_spec != "phase0":
244
249
  try:
245
250
  previous_previous_fork = previous_forks[i+1]
246
- previous_previous_spec = get_spec(attributes, preset, previous_previous_fork)
251
+ previous_previous_spec = get_spec(attributes, preset, previous_previous_fork, version)
247
252
  if previous_previous_spec == previous_spec:
248
253
  continue
249
254
  except KeyError:
@@ -263,7 +268,7 @@ def get_spec_item(attributes):
263
268
  function_name = attributes["function"]
264
269
  else:
265
270
  function_name = attributes["fn"]
266
- for key, value in get_links().items():
271
+ for key, value in get_links(version).items():
267
272
  if fork in key and key.endswith(function_name):
268
273
  return value
269
274
  return "Could not find link"
@@ -322,8 +327,8 @@ def replace_spec_tags(file_path):
322
327
 
323
328
  attributes = extract_attributes(original_tag_text)
324
329
  print(f"spec tag: {attributes}")
325
- preset, fork, style = parse_common_attributes(attributes)
326
- spec = get_spec(attributes, preset, fork)
330
+ preset, fork, style, version = parse_common_attributes(attributes)
331
+ spec = get_spec(attributes, preset, fork, version)
327
332
  hash_value = hashlib.sha256(spec.encode('utf-8')).hexdigest()[:8]
328
333
 
329
334
  if style == "hash":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ethspecify
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: A utility for processing Ethereum specification tags.
5
5
  Home-page: https://github.com/jtraglia/ethspecify
6
6
  Author: Justin Traglia
@@ -66,6 +66,20 @@ ethspecify
66
66
 
67
67
  ## Specification Options
68
68
 
69
+ ### Version
70
+
71
+ This attribute specifies which version of the consensus specifications to use. Default is `nightly`.
72
+
73
+ - `nightly` (default) - Uses the latest nightly build from the master branch
74
+ - `v1.6.0-alpha.2`, `v1.6.0-alpha.3`, etc. - Uses a specific tagged release version
75
+
76
+ Example:
77
+ ```
78
+ /*
79
+ * <spec fn="apply_deposit" fork="electra" version="v1.6.0-alpha.3" />
80
+ */
81
+ ```
82
+
69
83
  ### Fork
70
84
 
71
85
  This attribute can be any of the [executable
@@ -0,0 +1,9 @@
1
+ ethspecify/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ ethspecify/cli.py,sha256=73NnY6-xvFcxMnpeZ1LqvU02EiNiPx5jOor1KPERenk,6903
3
+ ethspecify/core.py,sha256=Nu5-onBdtmibdO9FkwZL1gGWjRAvZkTPeWZ0H9v2NoI,13292
4
+ ethspecify-0.2.1.dist-info/licenses/LICENSE,sha256=Awxsr73mm9YMBVhBYnzeI7bNdRd-bH6RDtO5ItG0DaM,1071
5
+ ethspecify-0.2.1.dist-info/METADATA,sha256=qYoT3-9O7b2SbY7mDJrDJo7T--VpjkIJTPrD2Ob03rc,9185
6
+ ethspecify-0.2.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
+ ethspecify-0.2.1.dist-info/entry_points.txt,sha256=09viGkCg9J3h0c9BFRN-BKaJUEaIc4JyULNgBP5EL_g,51
8
+ ethspecify-0.2.1.dist-info/top_level.txt,sha256=0klaMvlVyOkXW09fwZTijJpdybITEp2c9zQKV5v30VM,11
9
+ ethspecify-0.2.1.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- ethspecify/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- ethspecify/cli.py,sha256=73NnY6-xvFcxMnpeZ1LqvU02EiNiPx5jOor1KPERenk,6903
3
- ethspecify/core.py,sha256=tkkuBXXJtjWZOSvrpohaFa89VsiocgdAm9QrB55dtGE,12963
4
- ethspecify-0.2.0.dist-info/licenses/LICENSE,sha256=Awxsr73mm9YMBVhBYnzeI7bNdRd-bH6RDtO5ItG0DaM,1071
5
- ethspecify-0.2.0.dist-info/METADATA,sha256=wE94OOQKuoZL8hGliq93NX7LQRLsU5eGbtD380J1kzc,8812
6
- ethspecify-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- ethspecify-0.2.0.dist-info/entry_points.txt,sha256=09viGkCg9J3h0c9BFRN-BKaJUEaIc4JyULNgBP5EL_g,51
8
- ethspecify-0.2.0.dist-info/top_level.txt,sha256=0klaMvlVyOkXW09fwZTijJpdybITEp2c9zQKV5v30VM,11
9
- ethspecify-0.2.0.dist-info/RECORD,,