Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt EIP-7688: Forward compatible consensus data structures #3844

Draft
wants to merge 20 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion presets/mainnet/eip7594.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ FIELD_ELEMENTS_PER_CELL: 64
# `uint64(2 * 4096)` (= 8192)
FIELD_ELEMENTS_PER_EXT_BLOB: 8192
# uint64(floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments'))
KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH: 4
KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH: 7
5 changes: 5 additions & 0 deletions presets/mainnet/electra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@ MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: 8
# ---------------------------------------------------------------
# 2**4 ( = 4) pending deposits
MAX_PENDING_DEPOSITS_PER_EPOCH: 16

# Misc
# ---------------------------------------------------------------
# `floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments')) + 1 + ceillog2(MAX_BLOB_COMMITMENTS_PER_BLOCK)` = 7 + 1 + 12 = 20
KZG_COMMITMENT_INCLUSION_PROOF_DEPTH_ELECTRA: 20
2 changes: 1 addition & 1 deletion presets/minimal/eip7594.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ FIELD_ELEMENTS_PER_CELL: 64
# `uint64(2 * 4096)` (= 8192)
FIELD_ELEMENTS_PER_EXT_BLOB: 8192
# uint64(floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments'))
KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH: 4
KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH: 7
5 changes: 5 additions & 0 deletions presets/minimal/electra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@ MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: 2
# ---------------------------------------------------------------
# 2**4 ( = 4) pending deposits
MAX_PENDING_DEPOSITS_PER_EPOCH: 16

# Misc
# ---------------------------------------------------------------
# [customized] `floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments')) + 1 + ceillog2(MAX_BLOB_COMMITMENTS_PER_BLOCK)` = 7 + 1 + 4 = 12
KZG_COMMITMENT_INCLUSION_PROOF_DEPTH_ELECTRA: 12
4 changes: 4 additions & 0 deletions pysetup/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ def dependency_order_class_objects(objects: Dict[str, str], custom_types: Dict[s
for key, value in items:
dependencies = []
for line in value.split('\n'):
profile_match = re.match(r'class\s+\w+\s*\(Profile\[\s*(\w+)\s*\]\s*\)\s*:', line)
if profile_match is not None:
dependencies.append(profile_match.group(1)) # SSZ `Profile` base
continue
if not re.match(r'\s+\w+: .+', line):
continue # skip whitespace etc.
line = line[line.index(':') + 1:] # strip of field name
Expand Down
5 changes: 0 additions & 5 deletions pysetup/spec_builders/deneb.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,5 @@ def hardcoded_custom_type_dep_constants(cls, spec_object) -> Dict[str, str]:
'FIELD_ELEMENTS_PER_BLOB': spec_object.preset_vars['FIELD_ELEMENTS_PER_BLOB'].value,
'MAX_BLOBS_PER_BLOCK': spec_object.config_vars['MAX_BLOBS_PER_BLOCK'].value,
'MAX_BLOB_COMMITMENTS_PER_BLOCK': spec_object.preset_vars['MAX_BLOB_COMMITMENTS_PER_BLOCK'].value,
}

@classmethod
def hardcoded_func_dep_presets(cls, spec_object) -> Dict[str, str]:
return {
'KZG_COMMITMENT_INCLUSION_PROOF_DEPTH': spec_object.preset_vars['KZG_COMMITMENT_INCLUSION_PROOF_DEPTH'].value,
}
4 changes: 2 additions & 2 deletions pysetup/spec_builders/eip7732.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ def hardcoded_custom_type_dep_constants(cls, spec_object) -> Dict[str, str]:
@classmethod
def deprecate_constants(cls) -> Set[str]:
return set([
'EXECUTION_PAYLOAD_GINDEX',
'EXECUTION_PAYLOAD_GINDEX_ELECTRA',
])

@classmethod
def deprecate_presets(cls) -> Set[str]:
return set([
'KZG_COMMITMENT_INCLUSION_PROOF_DEPTH',
'KZG_COMMITMENT_INCLUSION_PROOF_DEPTH_ELECTRA',
])
16 changes: 12 additions & 4 deletions pysetup/spec_builders/electra.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,22 @@ def imports(cls, preset_name: str):
return f'''
from eth2spec.deneb import {preset_name} as deneb
from eth2spec.utils.ssz.ssz_impl import ssz_serialize, ssz_deserialize
from eth2spec.utils.ssz.ssz_typing import StableContainer, Profile
'''

@classmethod
def hardcoded_ssz_dep_constants(cls) -> Dict[str, str]:
return {
'FINALIZED_ROOT_GINDEX_ELECTRA': 'GeneralizedIndex(169)',
'CURRENT_SYNC_COMMITTEE_GINDEX_ELECTRA': 'GeneralizedIndex(86)',
'NEXT_SYNC_COMMITTEE_GINDEX_ELECTRA': 'GeneralizedIndex(87)',
'FINALIZED_ROOT_GINDEX_ELECTRA': 'GeneralizedIndex(553)',
'CURRENT_SYNC_COMMITTEE_GINDEX_ELECTRA': 'GeneralizedIndex(278)',
'NEXT_SYNC_COMMITTEE_GINDEX_ELECTRA': 'GeneralizedIndex(279)',
'EXECUTION_PAYLOAD_GINDEX_ELECTRA': 'GeneralizedIndex(137)',
}

@classmethod
def hardcoded_custom_type_dep_constants(cls, spec_object) -> Dict[str, str]:
return {
'KZG_COMMITMENT_INCLUSION_PROOF_DEPTH_ELECTRA': spec_object.preset_vars['KZG_COMMITMENT_INCLUSION_PROOF_DEPTH_ELECTRA'].value,
}


Expand Down Expand Up @@ -57,4 +65,4 @@ def verify_and_notify_new_payload(self: ExecutionEngine,
return True


EXECUTION_ENGINE = NoopExecutionEngine()"""
EXECUTION_ENGINE = NoopExecutionEngine()"""
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def get_spec(file_name: Path, preset: Dict[str, str], config: Dict[str, str], pr
raise

if parent_class:
assert parent_class == "Container"
assert parent_class in ["Container", "StableContainer", "Profile"]
# NOTE: trim whitespace from spec
ssz_objects[current_name] = "\n".join(line.rstrip() for line in source.splitlines())
else:
Expand Down Expand Up @@ -571,7 +571,7 @@ def run(self):
"pycryptodome>=3.19.1",
"py_ecc==6.0.0",
"milagro_bls_binding==1.9.0",
"remerkleable==0.1.28",
"remerkleable @ git+https://github.com/etan-status/remerkleable@dev/etan/sc-default",
"trie>=3,<4",
RUAMEL_YAML_VERSION,
"lru-dict==1.2.0",
Expand Down
Loading