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'
EIP6800 = 'eip6800'
WHISK = 'whisk'
EIPXXXX = 'eipxxxx'
# The helper functions that are used when defining constants

View File

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

View File

@ -7,12 +7,13 @@ from .electra import ElectraSpecBuilder
from .whisk import WhiskSpecBuilder
from .eip7594 import EIP7594SpecBuilder
from .eip6800 import EIP6800SpecBuilder
from .eipxxxx import EIPXXXXSpecBuilder
spec_builders = {
builder.fork: builder
for builder in (
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
class PayloadAttestation(Container):
aggregation_bits: BitVector[PTC_SIZE]
aggregation_bits: Bitvector[PTC_SIZE]
data: PayloadAttestationData
signature: BLSSignature
```
@ -151,7 +151,7 @@ class ExecutionPayloadEnvelope(Container):
builder_index: ValidatorIndex
beacon_block_root: Root
blob_kzg_commitments: List[KZGCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK]
payload_withheld: bool
payload_withheld: boolean
state_root: Root
```

View File

@ -296,7 +296,7 @@ def get_head(store: Store) -> ChildNode:
justified_block = store.blocks[justified_root]
justified_slot = justified_block.slot
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:
children = [
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:
return best_child
# 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
# Ties broken by favoring full blocks according to the PTC vote
# 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
# 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
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:

View File

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

View File

@ -20,6 +20,7 @@ DAS = SpecForkName('das')
ELECTRA = SpecForkName('electra')
WHISK = SpecForkName('whisk')
EIP7594 = SpecForkName('eip7594')
EIPXXXX = SpecForkName('eipxxxx')
#
# SpecFork settings
@ -37,11 +38,12 @@ ALL_PHASES = (
ELECTRA,
# Experimental patches
EIP7594,
EIPXXXX,
)
# The forks that have light client specs
LIGHT_CLIENT_TESTING_FORKS = (*[item for item in MAINNET_FORKS if item != PHASE0],)
# 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
ALLOWED_TEST_RUNNER_FORKS = (*ALL_PHASES, WHISK)
@ -57,6 +59,7 @@ PREVIOUS_FORK_OF = {
# Experimental patches
WHISK: CAPELLA,
EIP7594: DENEB,
EIPXXXX: ELECTRA,
}
# For fork transition tests
@ -67,6 +70,7 @@ POST_FORK_OF = {
BELLATRIX: CAPELLA,
CAPELLA: DENEB,
DENEB: ELECTRA,
ELECTRA: EIPXXXX,
}
ALL_PRE_POST_FORKS = POST_FORK_OF.items()