Fix epbs consensus spec to be executable (#10)

Fix epbs consensus spec to be executable
This commit is contained in:
terence 2024-06-28 06:51:20 -07:00 committed by Potuz
parent 0d082fdc0e
commit 6e02cb4ea4
14 changed files with 53 additions and 7 deletions

View File

@ -0,0 +1,8 @@
# Mainnet preset - EIPXXXX
# Execution
# ---------------------------------------------------------------
# 2**9 (= 512)
PTC_SIZE: 512
# 2**2 (= 4)
MAX_PAYLOAD_ATTESTATIONS: 4

View File

@ -0,0 +1,8 @@
# Minimal preset - EIPXXXX
# Execution
# ---------------------------------------------------------------
# 2**1(= 2)
PTC_SIZE: 2
# 2**2 (= 4)
MAX_PAYLOAD_ATTESTATIONS: 4

View File

@ -8,6 +8,7 @@ ELECTRA = 'electra'
EIP7594 = 'eip7594' EIP7594 = 'eip7594'
EIP6800 = 'eip6800' EIP6800 = 'eip6800'
WHISK = 'whisk' WHISK = 'whisk'
EIPXXXX = 'eipxxxx'
# The helper functions that are used when defining constants # The helper functions that are used when defining constants

View File

@ -10,6 +10,7 @@ from .constants import (
WHISK, WHISK,
EIP7594, EIP7594,
EIP6800, EIP6800,
EIPXXXX,
) )
@ -23,6 +24,7 @@ PREVIOUS_FORK_OF = {
WHISK: CAPELLA, WHISK: CAPELLA,
EIP7594: DENEB, EIP7594: DENEB,
EIP6800: DENEB, EIP6800: DENEB,
EIPXXXX: ELECTRA,
} }
ALL_FORKS = list(PREVIOUS_FORK_OF.keys()) ALL_FORKS = list(PREVIOUS_FORK_OF.keys())

View File

@ -7,12 +7,13 @@ from .electra import ElectraSpecBuilder
from .whisk import WhiskSpecBuilder from .whisk import WhiskSpecBuilder
from .eip7594 import EIP7594SpecBuilder from .eip7594 import EIP7594SpecBuilder
from .eip6800 import EIP6800SpecBuilder from .eip6800 import EIP6800SpecBuilder
from .eipxxxx import EIPXXXXSpecBuilder
spec_builders = { spec_builders = {
builder.fork: builder builder.fork: builder
for builder in ( for builder in (
Phase0SpecBuilder, AltairSpecBuilder, BellatrixSpecBuilder, CapellaSpecBuilder, DenebSpecBuilder, Phase0SpecBuilder, AltairSpecBuilder, BellatrixSpecBuilder, CapellaSpecBuilder, DenebSpecBuilder,
ElectraSpecBuilder, WhiskSpecBuilder, EIP7594SpecBuilder, EIP6800SpecBuilder, ElectraSpecBuilder, WhiskSpecBuilder, EIP7594SpecBuilder, EIP6800SpecBuilder, EIPXXXXSpecBuilder,
) )
} }

View File

@ -0,0 +1,21 @@
from typing import Dict
from .base import BaseSpecBuilder
from ..constants import EIPXXXX
class EIPXXXXSpecBuilder(BaseSpecBuilder):
fork: str = EIPXXXX
@classmethod
def imports(cls, preset_name: str):
return f'''
from eth2spec.eipxxxx import {preset_name} as eipxxxx
'''
@classmethod
def hardcoded_custom_type_dep_constants(cls, spec_object) -> Dict[str, str]:
return {
'PTC_SIZE': spec_object.preset_vars['PTC_SIZE'].value,
'MAX_PAYLOAD_ATTESTATIONS': spec_object.preset_vars['MAX_PAYLOAD_ATTESTATIONS'].value,
}

View File

@ -112,7 +112,7 @@ class PayloadAttestationData(Container):
```python ```python
class PayloadAttestation(Container): class PayloadAttestation(Container):
aggregation_bits: BitVector[PTC_SIZE] aggregation_bits: Bitvector[PTC_SIZE]
data: PayloadAttestationData data: PayloadAttestationData
signature: BLSSignature signature: BLSSignature
``` ```
@ -151,7 +151,7 @@ class ExecutionPayloadEnvelope(Container):
builder_index: ValidatorIndex builder_index: ValidatorIndex
beacon_block_root: Root beacon_block_root: Root
blob_kzg_commitments: List[KZGCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK] blob_kzg_commitments: List[KZGCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK]
payload_withheld: bool payload_withheld: boolean
state_root: Root state_root: Root
``` ```

View File

@ -296,7 +296,7 @@ def get_head(store: Store) -> ChildNode:
justified_block = store.blocks[justified_root] justified_block = store.blocks[justified_root]
justified_slot = justified_block.slot justified_slot = justified_block.slot
justified_full = is_payload_present(store, justified_root) justified_full = is_payload_present(store, justified_root)
best_child = ChildNode(root=head_root, slot=head_slot, is_payload_present=head_full) best_child = ChildNode(root=justified_root, slot=justified_slot, is_payload_present=justified_full)
while True: while True:
children = [ children = [
ChildNode(root=root, slot=block.slot, is_payload_present=present) for (root, block) in blocks.items() ChildNode(root=root, slot=block.slot, is_payload_present=present) for (root, block) in blocks.items()
@ -307,7 +307,7 @@ def get_head(store: Store) -> ChildNode:
if len(children) == 0: if len(children) == 0:
return best_child return best_child
# if we have children we consider the current head advanced as a possible head # if we have children we consider the current head advanced as a possible head
children += [ChildNode(root=best_child.root, slot=best_child.slot + 1, best_child.is_payload_present)] children += [ChildNode(root=best_child.root, slot=best_child.slot + 1, is_payload_present=best_child.is_payload_present)]
# Sort by latest attesting balance with ties broken lexicographically # Sort by latest attesting balance with ties broken lexicographically
# Ties broken by favoring full blocks according to the PTC vote # Ties broken by favoring full blocks according to the PTC vote
# Ties are then broken by favoring full blocks # Ties are then broken by favoring full blocks
@ -484,7 +484,7 @@ def on_payload_attestation_message(store: Store,
ptc_vote[ptc_index] = data.payload_status ptc_vote[ptc_index] = data.payload_status
# Only update payload boosts with attestations from a block if the block is for the current slot and it's early # Only update payload boosts with attestations from a block if the block is for the current slot and it's early
if is_from_block && data.slot + 1 != get_current_slot(store): if is_from_block and data.slot + 1 != get_current_slot(store):
return return
time_into_slot = (store.time - store.genesis_time) % SECONDS_PER_SLOT time_into_slot = (store.time - store.genesis_time) % SECONDS_PER_SLOT
if is_from_block and time_into_slot >= SECONDS_PER_SLOT // INTERVALS_PER_SLOT: if is_from_block and time_into_slot >= SECONDS_PER_SLOT // INTERVALS_PER_SLOT:

View File

@ -0,0 +1 @@
from . import mainnet as spec # noqa:F401

View File

@ -20,6 +20,7 @@ DAS = SpecForkName('das')
ELECTRA = SpecForkName('electra') ELECTRA = SpecForkName('electra')
WHISK = SpecForkName('whisk') WHISK = SpecForkName('whisk')
EIP7594 = SpecForkName('eip7594') EIP7594 = SpecForkName('eip7594')
EIPXXXX = SpecForkName('eipxxxx')
# #
# SpecFork settings # SpecFork settings
@ -37,11 +38,12 @@ ALL_PHASES = (
ELECTRA, ELECTRA,
# Experimental patches # Experimental patches
EIP7594, EIP7594,
EIPXXXX,
) )
# The forks that have light client specs # The forks that have light client specs
LIGHT_CLIENT_TESTING_FORKS = (*[item for item in MAINNET_FORKS if item != PHASE0],) LIGHT_CLIENT_TESTING_FORKS = (*[item for item in MAINNET_FORKS if item != PHASE0],)
# The forks that output to the test vectors. # The forks that output to the test vectors.
TESTGEN_FORKS = (*MAINNET_FORKS, ELECTRA, EIP7594, WHISK) TESTGEN_FORKS = (*MAINNET_FORKS, ELECTRA, EIP7594, WHISK, EIPXXXX)
# Forks allowed in the test runner `--fork` flag, to fail fast in case of typos # Forks allowed in the test runner `--fork` flag, to fail fast in case of typos
ALLOWED_TEST_RUNNER_FORKS = (*ALL_PHASES, WHISK) ALLOWED_TEST_RUNNER_FORKS = (*ALL_PHASES, WHISK)
@ -57,6 +59,7 @@ PREVIOUS_FORK_OF = {
# Experimental patches # Experimental patches
WHISK: CAPELLA, WHISK: CAPELLA,
EIP7594: DENEB, EIP7594: DENEB,
EIPXXXX: ELECTRA,
} }
# For fork transition tests # For fork transition tests
@ -67,6 +70,7 @@ POST_FORK_OF = {
BELLATRIX: CAPELLA, BELLATRIX: CAPELLA,
CAPELLA: DENEB, CAPELLA: DENEB,
DENEB: ELECTRA, DENEB: ELECTRA,
ELECTRA: EIPXXXX,
} }
ALL_PRE_POST_FORKS = POST_FORK_OF.items() ALL_PRE_POST_FORKS = POST_FORK_OF.items()