Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions pysetup/spec_builders/eip7732.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,63 @@ def imports(cls, preset_name: str):
@classmethod
def sundry_functions(cls) -> str:
return """
def cached_or_new_inclusion_list_store() -> InclusionListStore:
# pylint: disable=unused-argument
return InclusionListStore()

def concat_generalized_indices(*indices: GeneralizedIndex) -> GeneralizedIndex:
o = GeneralizedIndex(1)
for i in indices:
o = GeneralizedIndex(o * bit_floor(i) + (i - bit_floor(i)))
return o"""

@classmethod
def execution_engine_cls(cls) -> str:
return """
class NoopExecutionEngine(ExecutionEngine):

def notify_new_payload(self: ExecutionEngine,
execution_payload: ExecutionPayload,
parent_beacon_block_root: Root,
execution_requests_list: Sequence[bytes]) -> bool:
return True

def notify_forkchoice_updated(self: ExecutionEngine,
head_block_hash: Hash32,
safe_block_hash: Hash32,
finalized_block_hash: Hash32,
payload_attributes: Optional[PayloadAttributes]) -> Optional[PayloadId]:
pass

def get_payload(self: ExecutionEngine, payload_id: PayloadId) -> GetPayloadResponse:
# pylint: disable=unused-argument
raise NotImplementedError("no default block production")

def is_valid_block_hash(self: ExecutionEngine,
execution_payload: ExecutionPayload,
parent_beacon_block_root: Root,
execution_requests_list: Sequence[bytes]) -> bool:
return True

def is_valid_versioned_hashes(self: ExecutionEngine, new_payload_request: NewPayloadRequest) -> bool:
return True

def verify_and_notify_new_payload(self: ExecutionEngine,
new_payload_request: NewPayloadRequest) -> bool:
return True

def get_inclusion_list(self: ExecutionEngine) -> GetInclusionListResponse:
# pylint: disable=unused-argument
raise NotImplementedError("no default inclusion list production")

def is_inclusion_list_satisfied(self: ExecutionEngine,
execution_payload: ExecutionPayload,
inclusion_list_transactions: Sequence[Transaction]) -> bool:
return True


EXECUTION_ENGINE = NoopExecutionEngine()"""

@classmethod
def deprecate_constants(cls) -> set[str]:
return set(
Expand Down
75 changes: 68 additions & 7 deletions specs/_features/eip7732/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
- [`SignedExecutionPayloadHeader`](#signedexecutionpayloadheader)
- [`ExecutionPayloadEnvelope`](#executionpayloadenvelope)
- [`SignedExecutionPayloadEnvelope`](#signedexecutionpayloadenvelope)
- [`InclusionList`](#inclusionlist)
- [`SignedInclusionList`](#signedinclusionlist)
- [Modified containers](#modified-containers)
- [`BeaconBlockBody`](#beaconblockbody)
- [`ExecutionPayloadHeader`](#executionpayloadheader)
Expand All @@ -40,11 +42,13 @@
- [New `is_builder_withdrawal_credential`](#new-is_builder_withdrawal_credential)
- [New `is_valid_indexed_payload_attestation`](#new-is_valid_indexed_payload_attestation)
- [New `is_parent_block_full`](#new-is_parent_block_full)
- [New `is_valid_inclusion_list_signature`](#new-is_valid_inclusion_list_signature)
- [Beacon State accessors](#beacon-state-accessors)
- [New `get_attestation_participation_flag_indices`](#new-get_attestation_participation_flag_indices)
- [New `get_ptc`](#new-get_ptc)
- [New `get_payload_attesting_indices`](#new-get_payload_attesting_indices)
- [New `get_indexed_payload_attestation`](#new-get_indexed_payload_attestation)
- [New `get_inclusion_list_committee`](#new-get_inclusion_list_committee)
- [Beacon chain state transition function](#beacon-chain-state-transition-function)
- [Modified `process_slot`](#modified-process_slot)
- [Epoch processing](#epoch-processing)
Expand Down Expand Up @@ -106,10 +110,11 @@ At any given slot, the status of the blockchain's head may be either

### Domain types

| Name | Value |
| ----------------------- | -------------------------- |
| `DOMAIN_BEACON_BUILDER` | `DomainType('0x1B000000')` |
| `DOMAIN_PTC_ATTESTER` | `DomainType('0x0C000000')` |
| Name | Value |
| --------------------------------- | -------------------------- |
| `DOMAIN_BEACON_BUILDER` | `DomainType('0x1B000000')` |
| `DOMAIN_PTC_ATTESTER` | `DomainType('0x0C000000')` |
| `DOMAIN_INCLUSION_LIST_COMMITTEE` | `DomainType('0x0C000000')` |

### Misc

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

### Misc

| Name | Value |
| ---------- | --------------------- |
| `PTC_SIZE` | `uint64(2**9)` (=512) |
| Name | Value |
| ------------------------------- | --------------------- |
| `PTC_SIZE` | `uint64(2**9)` (=512) |
| `INCLUSION_LIST_COMMITTEE_SIZE` | `uint64(2**4)` (=16) |

### Max operations per block

Expand Down Expand Up @@ -232,6 +238,24 @@ class SignedExecutionPayloadEnvelope(Container):
signature: BLSSignature
```

#### `InclusionList`

```python
class InclusionList(Container):
slot: Slot
validator_index: ValidatorIndex
inclusion_list_committee_root: Root
transactions: List[Transaction, MAX_TRANSACTIONS_PER_PAYLOAD]
```

#### `SignedInclusionList`

```python
class SignedInclusionList(Container):
message: InclusionList
signature: BLSSignature
```

### Modified containers

#### `BeaconBlockBody`
Expand Down Expand Up @@ -264,6 +288,7 @@ class BeaconBlockBody(Container):
signed_execution_payload_header: SignedExecutionPayloadHeader
# [New in EIP7732]
payload_attestations: List[PayloadAttestation, MAX_PAYLOAD_ATTESTATIONS]
inclusion_list_bits: Bitvector[INCLUSION_LIST_COMMITTEE_SIZE]
```

#### `ExecutionPayloadHeader`
Expand Down Expand Up @@ -457,6 +482,23 @@ def is_parent_block_full(state: BeaconState) -> bool:
return state.latest_execution_payload_header.block_hash == state.latest_block_hash
```

#### New `is_valid_inclusion_list_signature`

```python
def is_valid_inclusion_list_signature(
state: BeaconState, signed_inclusion_list: SignedInclusionList
) -> bool:
"""
Check if ``signed_inclusion_list`` has a valid signature.
"""
message = signed_inclusion_list.message
index = message.validator_index
pubkey = state.validators[index].pubkey
domain = get_domain(state, DOMAIN_INCLUSION_LIST_COMMITTEE, compute_epoch_at_slot(message.slot))
signing_root = compute_signing_root(message, domain)
return bls.Verify(pubkey, signing_root, signed_inclusion_list.signature)
```

### Beacon State accessors

#### New `get_attestation_participation_flag_indices`
Expand Down Expand Up @@ -554,6 +596,25 @@ def get_indexed_payload_attestation(
)
```

#### New `get_inclusion_list_committee`

```python
def get_inclusion_list_committee(
state: BeaconState, slot: Slot
) -> Vector[ValidatorIndex, INCLUSION_LIST_COMMITTEE_SIZE]:
epoch = compute_epoch_at_slot(slot)
seed = get_seed(state, epoch, DOMAIN_INCLUSION_LIST_COMMITTEE)
indices = get_active_validator_indices(state, epoch)
start = (slot % SLOTS_PER_EPOCH) * INCLUSION_LIST_COMMITTEE_SIZE
end = start + INCLUSION_LIST_COMMITTEE_SIZE
return Vector[ValidatorIndex, INCLUSION_LIST_COMMITTEE_SIZE](
[
indices[compute_shuffled_index(uint64(i % len(indices)), uint64(len(indices)), seed)]
for i in range(start, end)
]
)
```

## Beacon chain state transition function

*Note*: state transition is fundamentally modified in EIP-7732. The full state
Expand Down
Loading