Skip to content

Commit 0fd7f7b

Browse files
committed
Rebase FOCIL onto ePBS
1 parent 35f8191 commit 0fd7f7b

File tree

5 files changed

+689
-10
lines changed

5 files changed

+689
-10
lines changed

pysetup/spec_builders/eip7732.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,63 @@ def imports(cls, preset_name: str):
1414
@classmethod
1515
def sundry_functions(cls) -> str:
1616
return """
17+
def cached_or_new_inclusion_list_store() -> InclusionListStore:
18+
# pylint: disable=unused-argument
19+
return InclusionListStore()
20+
1721
def concat_generalized_indices(*indices: GeneralizedIndex) -> GeneralizedIndex:
1822
o = GeneralizedIndex(1)
1923
for i in indices:
2024
o = GeneralizedIndex(o * bit_floor(i) + (i - bit_floor(i)))
2125
return o"""
2226

27+
@classmethod
28+
def execution_engine_cls(cls) -> str:
29+
return """
30+
class NoopExecutionEngine(ExecutionEngine):
31+
32+
def notify_new_payload(self: ExecutionEngine,
33+
execution_payload: ExecutionPayload,
34+
parent_beacon_block_root: Root,
35+
execution_requests_list: Sequence[bytes]) -> bool:
36+
return True
37+
38+
def notify_forkchoice_updated(self: ExecutionEngine,
39+
head_block_hash: Hash32,
40+
safe_block_hash: Hash32,
41+
finalized_block_hash: Hash32,
42+
payload_attributes: Optional[PayloadAttributes]) -> Optional[PayloadId]:
43+
pass
44+
45+
def get_payload(self: ExecutionEngine, payload_id: PayloadId) -> GetPayloadResponse:
46+
# pylint: disable=unused-argument
47+
raise NotImplementedError("no default block production")
48+
49+
def is_valid_block_hash(self: ExecutionEngine,
50+
execution_payload: ExecutionPayload,
51+
parent_beacon_block_root: Root,
52+
execution_requests_list: Sequence[bytes]) -> bool:
53+
return True
54+
55+
def is_valid_versioned_hashes(self: ExecutionEngine, new_payload_request: NewPayloadRequest) -> bool:
56+
return True
57+
58+
def verify_and_notify_new_payload(self: ExecutionEngine,
59+
new_payload_request: NewPayloadRequest) -> bool:
60+
return True
61+
62+
def get_inclusion_list(self: ExecutionEngine) -> GetInclusionListResponse:
63+
# pylint: disable=unused-argument
64+
raise NotImplementedError("no default inclusion list production")
65+
66+
def is_inclusion_list_satisfied(self: ExecutionEngine,
67+
execution_payload: ExecutionPayload,
68+
inclusion_list_transactions: Sequence[Transaction]) -> bool:
69+
return True
70+
71+
72+
EXECUTION_ENGINE = NoopExecutionEngine()"""
73+
2374
@classmethod
2475
def deprecate_constants(cls) -> set[str]:
2576
return set(

specs/_features/eip7732/beacon-chain.md

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
- [`SignedExecutionPayloadHeader`](#signedexecutionpayloadheader)
2525
- [`ExecutionPayloadEnvelope`](#executionpayloadenvelope)
2626
- [`SignedExecutionPayloadEnvelope`](#signedexecutionpayloadenvelope)
27+
- [`InclusionList`](#inclusionlist)
28+
- [`SignedInclusionList`](#signedinclusionlist)
2729
- [Modified containers](#modified-containers)
2830
- [`BeaconBlockBody`](#beaconblockbody)
2931
- [`ExecutionPayloadHeader`](#executionpayloadheader)
@@ -40,11 +42,13 @@
4042
- [New `is_builder_withdrawal_credential`](#new-is_builder_withdrawal_credential)
4143
- [New `is_valid_indexed_payload_attestation`](#new-is_valid_indexed_payload_attestation)
4244
- [New `is_parent_block_full`](#new-is_parent_block_full)
45+
- [New `is_valid_inclusion_list_signature`](#new-is_valid_inclusion_list_signature)
4346
- [Beacon State accessors](#beacon-state-accessors)
4447
- [New `get_attestation_participation_flag_indices`](#new-get_attestation_participation_flag_indices)
4548
- [New `get_ptc`](#new-get_ptc)
4649
- [New `get_payload_attesting_indices`](#new-get_payload_attesting_indices)
4750
- [New `get_indexed_payload_attestation`](#new-get_indexed_payload_attestation)
51+
- [New `get_inclusion_list_committee`](#new-get_inclusion_list_committee)
4852
- [Beacon chain state transition function](#beacon-chain-state-transition-function)
4953
- [Modified `process_slot`](#modified-process_slot)
5054
- [Epoch processing](#epoch-processing)
@@ -106,10 +110,11 @@ At any given slot, the status of the blockchain's head may be either
106110

107111
### Domain types
108112

109-
| Name | Value |
110-
| ----------------------- | -------------------------- |
111-
| `DOMAIN_BEACON_BUILDER` | `DomainType('0x1B000000')` |
112-
| `DOMAIN_PTC_ATTESTER` | `DomainType('0x0C000000')` |
113+
| Name | Value |
114+
| --------------------------------- | -------------------------- |
115+
| `DOMAIN_BEACON_BUILDER` | `DomainType('0x1B000000')` |
116+
| `DOMAIN_PTC_ATTESTER` | `DomainType('0x0C000000')` |
117+
| `DOMAIN_INCLUSION_LIST_COMMITTEE` | `DomainType('0x0C000000')` |
113118

114119
### Misc
115120

@@ -122,9 +127,10 @@ At any given slot, the status of the blockchain's head may be either
122127

123128
### Misc
124129

125-
| Name | Value |
126-
| ---------- | --------------------- |
127-
| `PTC_SIZE` | `uint64(2**9)` (=512) |
130+
| Name | Value |
131+
| ------------------------------- | --------------------- |
132+
| `PTC_SIZE` | `uint64(2**9)` (=512) |
133+
| `INCLUSION_LIST_COMMITTEE_SIZE` | `uint64(2**4)` (=16) |
128134

129135
### Max operations per block
130136

@@ -232,6 +238,24 @@ class SignedExecutionPayloadEnvelope(Container):
232238
signature: BLSSignature
233239
```
234240

241+
#### `InclusionList`
242+
243+
```python
244+
class InclusionList(Container):
245+
slot: Slot
246+
validator_index: ValidatorIndex
247+
inclusion_list_committee_root: Root
248+
transactions: List[Transaction, MAX_TRANSACTIONS_PER_PAYLOAD]
249+
```
250+
251+
#### `SignedInclusionList`
252+
253+
```python
254+
class SignedInclusionList(Container):
255+
message: InclusionList
256+
signature: BLSSignature
257+
```
258+
235259
### Modified containers
236260

237261
#### `BeaconBlockBody`
@@ -264,6 +288,7 @@ class BeaconBlockBody(Container):
264288
signed_execution_payload_header: SignedExecutionPayloadHeader
265289
# [New in EIP7732]
266290
payload_attestations: List[PayloadAttestation, MAX_PAYLOAD_ATTESTATIONS]
291+
inclusion_list_bits: Bitvector[INCLUSION_LIST_COMMITTEE_SIZE]
267292
```
268293

269294
#### `ExecutionPayloadHeader`
@@ -457,6 +482,23 @@ def is_parent_block_full(state: BeaconState) -> bool:
457482
return state.latest_execution_payload_header.block_hash == state.latest_block_hash
458483
```
459484

485+
#### New `is_valid_inclusion_list_signature`
486+
487+
```python
488+
def is_valid_inclusion_list_signature(
489+
state: BeaconState, signed_inclusion_list: SignedInclusionList
490+
) -> bool:
491+
"""
492+
Check if ``signed_inclusion_list`` has a valid signature.
493+
"""
494+
message = signed_inclusion_list.message
495+
index = message.validator_index
496+
pubkey = state.validators[index].pubkey
497+
domain = get_domain(state, DOMAIN_INCLUSION_LIST_COMMITTEE, compute_epoch_at_slot(message.slot))
498+
signing_root = compute_signing_root(message, domain)
499+
return bls.Verify(pubkey, signing_root, signed_inclusion_list.signature)
500+
```
501+
460502
### Beacon State accessors
461503

462504
#### New `get_attestation_participation_flag_indices`
@@ -554,6 +596,25 @@ def get_indexed_payload_attestation(
554596
)
555597
```
556598

599+
#### New `get_inclusion_list_committee`
600+
601+
```python
602+
def get_inclusion_list_committee(
603+
state: BeaconState, slot: Slot
604+
) -> Vector[ValidatorIndex, INCLUSION_LIST_COMMITTEE_SIZE]:
605+
epoch = compute_epoch_at_slot(slot)
606+
seed = get_seed(state, epoch, DOMAIN_INCLUSION_LIST_COMMITTEE)
607+
indices = get_active_validator_indices(state, epoch)
608+
start = (slot % SLOTS_PER_EPOCH) * INCLUSION_LIST_COMMITTEE_SIZE
609+
end = start + INCLUSION_LIST_COMMITTEE_SIZE
610+
return Vector[ValidatorIndex, INCLUSION_LIST_COMMITTEE_SIZE](
611+
[
612+
indices[compute_shuffled_index(uint64(i % len(indices)), uint64(len(indices)), seed)]
613+
for i in range(start, end)
614+
]
615+
)
616+
```
617+
557618
## Beacon chain state transition function
558619

559620
*Note*: state transition is fundamentally modified in EIP-7732. The full state

0 commit comments

Comments
 (0)