Skip to content

Commit

Permalink
Fix epbs consensus spec to be executable
Browse files Browse the repository at this point in the history
  • Loading branch information
terencechain committed Jun 24, 2024
1 parent 652060b commit e0a555e
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 4 deletions.
8 changes: 8 additions & 0 deletions presets/mainnet/epbs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Mainnet preset - epbs

# Execution
# ---------------------------------------------------------------
# 2**9 (= 512)
PTC_SIZE: 512
# 2**2 (= 4)
MAX_PAYLOAD_ATTESTATIONS: 4
8 changes: 8 additions & 0 deletions presets/minimal/epbs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Minimal preset - epbs

# Execution
# ---------------------------------------------------------------
# 2**1(= 2)
PTC_SIZE: 2
# 2**2 (= 4)
MAX_PAYLOAD_ATTESTATIONS: 4
1 change: 1 addition & 0 deletions pysetup/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
EIP7594 = 'eip7594'
EIP6800 = 'eip6800'
WHISK = 'whisk'
EPBS = 'epbs'


# The helper functions that are used when defining constants
Expand Down
2 changes: 2 additions & 0 deletions pysetup/md_doc_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
WHISK,
EIP7594,
EIP6800,
EPBS,
)


Expand All @@ -23,6 +24,7 @@
WHISK: CAPELLA,
EIP7594: DENEB,
EIP6800: DENEB,
EPBS: ELECTRA,
}

ALL_FORKS = list(PREVIOUS_FORK_OF.keys())
Expand Down
3 changes: 2 additions & 1 deletion pysetup/spec_builders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
from .whisk import WhiskSpecBuilder
from .eip7594 import EIP7594SpecBuilder
from .eip6800 import EIP6800SpecBuilder
from .epbs import EPBSSpecBuilder


spec_builders = {
builder.fork: builder
for builder in (
Phase0SpecBuilder, AltairSpecBuilder, BellatrixSpecBuilder, CapellaSpecBuilder, DenebSpecBuilder,
ElectraSpecBuilder, WhiskSpecBuilder, EIP7594SpecBuilder, EIP6800SpecBuilder,
ElectraSpecBuilder, WhiskSpecBuilder, EIP7594SpecBuilder, EIP6800SpecBuilder, EPBSSpecBuilder,
)
}
21 changes: 21 additions & 0 deletions pysetup/spec_builders/epbs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from typing import Dict

from .base import BaseSpecBuilder
from ..constants import EPBS


class EPBSSpecBuilder(BaseSpecBuilder):
fork: str = EPBS

@classmethod
def imports(cls, preset_name: str):
return f'''
from eth2spec.epbs import {preset_name} as epbs
'''

@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,
}
4 changes: 2 additions & 2 deletions specs/_features/epbs/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions tests/core/pyspec/eth2spec/epbs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import mainnet as spec # noqa:F401
6 changes: 5 additions & 1 deletion tests/core/pyspec/eth2spec/test/helpers/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
ELECTRA = SpecForkName('electra')
WHISK = SpecForkName('whisk')
EIP7594 = SpecForkName('eip7594')
EPBS = SpecForkName('epbs')

#
# SpecFork settings
Expand All @@ -37,11 +38,12 @@
ELECTRA,
# Experimental patches
EIP7594,
EPBS,
)
# 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, EPBS)
# Forks allowed in the test runner `--fork` flag, to fail fast in case of typos
ALLOWED_TEST_RUNNER_FORKS = (*ALL_PHASES, WHISK)

Expand All @@ -57,6 +59,7 @@
# Experimental patches
WHISK: CAPELLA,
EIP7594: DENEB,
EPBS: ELECTRA,
}

# For fork transition tests
Expand All @@ -67,6 +70,7 @@
BELLATRIX: CAPELLA,
CAPELLA: DENEB,
DENEB: ELECTRA,
ELECTRA: EPBS,
}

ALL_PRE_POST_FORKS = POST_FORK_OF.items()
Expand Down

0 comments on commit e0a555e

Please sign in to comment.