Skip to content

Commit 114ca55

Browse files
committed
Adopt EIP-7688: Forward compatible consensus data structures
EIP-4788 exposes the beacon root to smart contracts, but smart contracts using it need to be redeployed / upgraded whenever the indexing changes during a fork, even if that fork does not touch any used functionality. This problem expands further to bridges on other blockchains, or even into wallet apps on a phone that verify data from the beacon chain instead of trusting the server. It is quite unrealistic to expect such projects to all align their release cadence with Ethereum's forks. EIP-7688 fixes this by defining forward compatibility for beacon chain data structures. Electra `Profile` retain their Merkleization even when rebased to `StableContainer` definitions from future forks, enabling decentralized protocols to drop the requirement for trusted parties to periodically upgrade beacon state proof verifiers.
1 parent e5b8b00 commit 114ca55

File tree

24 files changed

+675
-99
lines changed

24 files changed

+675
-99
lines changed

presets/mainnet/eip7594.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ FIELD_ELEMENTS_PER_CELL: 64
77
# `uint64(2 * 4096)` (= 8192)
88
FIELD_ELEMENTS_PER_EXT_BLOB: 8192
99
# uint64(floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments'))
10-
KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH: 4
10+
KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH: 7

presets/mainnet/electra.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,8 @@ MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: 8
4848
# ---------------------------------------------------------------
4949
# 2**4 ( = 4) pending deposits
5050
MAX_PENDING_DEPOSITS_PER_EPOCH: 16
51+
52+
# Misc
53+
# ---------------------------------------------------------------
54+
# `floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments')) + 1 + ceillog2(MAX_BLOB_COMMITMENTS_PER_BLOCK)` = 7 + 1 + 12 = 20
55+
KZG_COMMITMENT_INCLUSION_PROOF_DEPTH_ELECTRA: 20

presets/minimal/eip7594.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ FIELD_ELEMENTS_PER_CELL: 64
77
# `uint64(2 * 4096)` (= 8192)
88
FIELD_ELEMENTS_PER_EXT_BLOB: 8192
99
# uint64(floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments'))
10-
KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH: 4
10+
KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH: 7

presets/minimal/electra.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,8 @@ MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: 2
4848
# ---------------------------------------------------------------
4949
# 2**4 ( = 4) pending deposits
5050
MAX_PENDING_DEPOSITS_PER_EPOCH: 16
51+
52+
# Misc
53+
# ---------------------------------------------------------------
54+
# [customized] `floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments')) + 1 + ceillog2(MAX_BLOB_COMMITMENTS_PER_BLOCK)` = 7 + 1 + 4 = 12
55+
KZG_COMMITMENT_INCLUSION_PROOF_DEPTH_ELECTRA: 12

pysetup/spec_builders/deneb.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,5 @@ def hardcoded_custom_type_dep_constants(cls, spec_object) -> Dict[str, str]:
8787
'FIELD_ELEMENTS_PER_BLOB': spec_object.preset_vars['FIELD_ELEMENTS_PER_BLOB'].value,
8888
'MAX_BLOBS_PER_BLOCK': spec_object.config_vars['MAX_BLOBS_PER_BLOCK'].value,
8989
'MAX_BLOB_COMMITMENTS_PER_BLOCK': spec_object.preset_vars['MAX_BLOB_COMMITMENTS_PER_BLOCK'].value,
90-
}
91-
92-
@classmethod
93-
def hardcoded_func_dep_presets(cls, spec_object) -> Dict[str, str]:
94-
return {
9590
'KZG_COMMITMENT_INCLUSION_PROOF_DEPTH': spec_object.preset_vars['KZG_COMMITMENT_INCLUSION_PROOF_DEPTH'].value,
9691
}

pysetup/spec_builders/eip7732.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ def hardcoded_custom_type_dep_constants(cls, spec_object) -> Dict[str, str]:
3535
@classmethod
3636
def deprecate_constants(cls) -> Set[str]:
3737
return set([
38-
'EXECUTION_PAYLOAD_GINDEX',
38+
'EXECUTION_PAYLOAD_GINDEX_ELECTRA',
3939
])
4040

4141
@classmethod
4242
def deprecate_presets(cls) -> Set[str]:
4343
return set([
44-
'KZG_COMMITMENT_INCLUSION_PROOF_DEPTH',
44+
'KZG_COMMITMENT_INCLUSION_PROOF_DEPTH_ELECTRA',
4545
])

pysetup/spec_builders/electra.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,22 @@ def imports(cls, preset_name: str):
1111
return f'''
1212
from eth2spec.deneb import {preset_name} as deneb
1313
from eth2spec.utils.ssz.ssz_impl import ssz_serialize, ssz_deserialize
14+
from eth2spec.utils.ssz.ssz_typing import StableContainer, Profile
1415
'''
1516

1617
@classmethod
1718
def hardcoded_ssz_dep_constants(cls) -> Dict[str, str]:
1819
return {
19-
'FINALIZED_ROOT_GINDEX_ELECTRA': 'GeneralizedIndex(169)',
20-
'CURRENT_SYNC_COMMITTEE_GINDEX_ELECTRA': 'GeneralizedIndex(86)',
21-
'NEXT_SYNC_COMMITTEE_GINDEX_ELECTRA': 'GeneralizedIndex(87)',
20+
'FINALIZED_ROOT_GINDEX_ELECTRA': 'GeneralizedIndex(553)',
21+
'CURRENT_SYNC_COMMITTEE_GINDEX_ELECTRA': 'GeneralizedIndex(278)',
22+
'NEXT_SYNC_COMMITTEE_GINDEX_ELECTRA': 'GeneralizedIndex(279)',
23+
'EXECUTION_PAYLOAD_GINDEX_ELECTRA': 'GeneralizedIndex(137)',
24+
}
25+
26+
@classmethod
27+
def hardcoded_custom_type_dep_constants(cls, spec_object) -> Dict[str, str]:
28+
return {
29+
'KZG_COMMITMENT_INCLUSION_PROOF_DEPTH_ELECTRA': spec_object.preset_vars['KZG_COMMITMENT_INCLUSION_PROOF_DEPTH_ELECTRA'].value,
2230
}
2331

2432

@@ -57,4 +65,4 @@ def verify_and_notify_new_payload(self: ExecutionEngine,
5765
return True
5866
5967
60-
EXECUTION_ENGINE = NoopExecutionEngine()"""
68+
EXECUTION_ENGINE = NoopExecutionEngine()"""

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ def run(self):
571571
"pycryptodome>=3.19.1",
572572
"py_ecc==6.0.0",
573573
"milagro_bls_binding==1.9.0",
574-
"remerkleable==0.1.28",
574+
"remerkleable @ git+https://github.com/etan-status/remerkleable@dev/etan/sc-default",
575575
"trie>=3,<4",
576576
RUAMEL_YAML_VERSION,
577577
"lru-dict==1.2.0",

specs/_features/eip7732/beacon-chain.md

Lines changed: 137 additions & 37 deletions
Large diffs are not rendered by default.

specs/capella/light-client/full-node.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def block_to_light_client_header(block: SignedBeaconBlock) -> LightClientHeader:
4747
withdrawals_root=hash_tree_root(payload.withdrawals),
4848
)
4949
execution_branch = ExecutionBranch(
50-
compute_merkle_proof(block.message.body, EXECUTION_PAYLOAD_GINDEX))
50+
compute_merkle_proof(block.message.body, execution_payload_gindex_at_slot(block.message.slot)))
5151
else:
5252
# Note that during fork transitions, `finalized_header` may still point to earlier forks.
5353
# While Bellatrix blocks also contain an `ExecutionPayload` (minus `withdrawals_root`),

0 commit comments

Comments
 (0)