Skip to content

Commit

Permalink
no commitment to summary, and adjusted p2p
Browse files Browse the repository at this point in the history
  • Loading branch information
fradamt committed Mar 6, 2024
1 parent 9de2941 commit bca66b0
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 51 deletions.
84 changes: 55 additions & 29 deletions specs/_features/eip7547/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ This is the beacon chain specification to add an inclusion list mechanism to all

*Note:* This specification is built upon [Deneb](../../deneb/beacon_chain.md) and is under active development.

## Constants

### Domain types

| Name | Value |
| - | - |
| `DOMAIN_INCLUSION_LIST_SUMMARY` | `DomainType('0x0B000000')` |

## Preset

### Execution
Expand All @@ -35,31 +43,16 @@ This is the beacon chain specification to add an inclusion list mechanism to all

## Containers

### Extended containers

#### `BeaconBlockBody`

Note: `BeaconBlock` and `SignedBeaconBlock` types are updated indirectly.
### New Containers

```python
class BeaconBlockBody(Container):
randao_reveal: BLSSignature
eth1_data: Eth1Data # Eth1 data vote
graffiti: Bytes32 # Arbitrary data
# Operations
proposer_slashings: List[ProposerSlashing, MAX_PROPOSER_SLASHINGS]
attester_slashings: List[AttesterSlashing, MAX_ATTESTER_SLASHINGS]
attestations: List[Attestation, MAX_ATTESTATIONS]
deposits: List[Deposit, MAX_DEPOSITS]
voluntary_exits: List[SignedVoluntaryExit, MAX_VOLUNTARY_EXITS]
sync_aggregate: SyncAggregate
# Execution
execution_payload: ExecutionPayload
bls_to_execution_changes: List[SignedBLSToExecutionChange, MAX_BLS_TO_EXECUTION_CHANGES]
blob_kzg_commitments: List[KZGCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK]
inclusion_list_summary_root: Root # [New in EIP7547]
class SignedInclusionListSummary(Container):
summary: List[ExecutionAddress, MAX_TRANSACTIONS_PER_INCLUSION_LIST]
signature: BLSSignature
```

### Extended containers

#### `ExecutionPayload`

```python
Expand All @@ -82,8 +75,8 @@ class ExecutionPayload(Container):
transactions: List[Transaction, MAX_TRANSACTIONS_PER_PAYLOAD]
withdrawals: List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD]
blob_gas_used: uint64
excess_blob_gas: uint64
previous_inclusion_list_summary: List[ExecutionAddress, MAX_TRANSACTIONS_PER_INCLUSION_LIST] # [New in EIP7547]
excess_blob_gas: uint64
previous_inclusion_list_summary: SignedInclusionListSummary # [New in EIP7547]
```

#### `ExecutionPayloadHeader`
Expand Down Expand Up @@ -158,12 +151,39 @@ class BeaconState(Container):
# Deep history valid from Capella onwards
historical_summaries: List[HistoricalSummary, HISTORICAL_ROOTS_LIMIT]
# Inclusion List
previous_inclusion_list_summary_root: Root # [New in EIP7547]
previous_proposer_index: ValidatorIndex # [New in EIP7547]
```


### Block processing

#### Block header

```python
def process_block_header(state: BeaconState, block: BeaconBlock) -> None:
# Verify that the slots match
assert block.slot == state.slot
# Verify that the block is newer than latest block header
assert block.slot > state.latest_block_header.slot
# Verify that proposer index is the correct index
assert block.proposer_index == get_beacon_proposer_index(state)
# Verify that the parent matches
assert block.parent_root == hash_tree_root(state.latest_block_header)
# Set previous proposer index before overwriting latest block header
state.previous_proposer_index = state.latest_block_header.proposer_index # [New in EIP7547]
# Cache current block as the new latest block
state.latest_block_header = BeaconBlockHeader(
slot=block.slot,
proposer_index=block.proposer_index,
parent_root=block.parent_root,
state_root=Bytes32(), # Overwritten in the next process_slot call
body_root=hash_tree_root(block.body),
)

# Verify proposer is not slashed
proposer = state.validators[block.proposer_index]
assert not proposer.slashed
```

#### Execution payload

##### Modified `process_execution_payload`
Expand All @@ -178,9 +198,8 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody, executi
assert payload.prev_randao == get_randao_mix(state, get_current_epoch(state))
# Verify timestamp
assert payload.timestamp == compute_timestamp_at_slot(state, state.slot)
# [New in EIP7547] Verify inclusion list summary
previous_inclusion_list_summary_root = hash_tree_root(payload.previous_inclusion_list_summary)
assert previous_inclusion_list_summary_root == state.previous_inclusion_list_summary_root
# [New in EIP7547] Verify previous proposer signature on inclusion list summary
assert verify_inclusion_list_summary_signature(state, payload.previous_inclusion_list_summary)

# Verify commitments are under limit
assert len(body.blob_kzg_commitments) <= MAX_BLOBS_PER_BLOCK
Expand Down Expand Up @@ -216,6 +235,13 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody, executi
withdrawals_root=hash_tree_root(payload.withdrawals),
blob_gas_used=payload.blob_gas_used,
excess_blob_gas=payload.excess_blob_gas,
previous_inclusion_list_summary_root=previous_inclusion_list_summary_root # [New in EIP7547]
previous_inclusion_list_summary_root=hash_tree_root(payload.previous_inclusion_list_summary) # [New in EIP7547]
)
```

```python
def verify_inclusion_list_summary_signature(state: BeaconState, inclusion_list_summary: SignedInclusionListSummary) -> bool:
signing_root = compute_signing_root(inclusion_list_summary.message, get_domain(state, DOMAIN_INCLUSION_LIST_SUMMARY))
previous_proposer = state.validators[state.previous_proposer_index]
return bls.Verify(previous_proposer.pubkey, signing_root, inclusion_list_summary.signature)
```
47 changes: 25 additions & 22 deletions specs/_features/eip7547/p2p-networking.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,29 @@ This document contains the consensus-layer networking specification for EIP-7547

The specification of these changes continues in the same format as the network specifications of previous upgrades, and assumes them as pre-requisite.

## Preset

### Execution

| Name | Value |
| - | - |
| `MAX_TRANSACTIONS_PER_INCLUSION_LIST` | `uint64(2**4)` (= 16) |

## Containers

### New Containers

#### `SignedInclusionListTransactions`
#### `InclusionListSidecar`

```python
class SignedInclusionListTransactions(Container):
transactions: transactions: List[Transaction, MAX_TRANSACTIONS_PER_PAYLOAD]
signature: BLSSignature
class InclusionListSidecar(Container):
transactions: List[Transaction, MAX_TRANSACTIONS_PER_INCLUSION_LIST]
proposer_index: ValidatorIndex
parent_root: Root
slot: Slot
signed_inclusion_list_summary: SignedInclusionListSummary
```

#### `SignedBeaconBlockAndInclusionList`
#### `SignedInclusionListSidecar`

```python
class SignedBeaconBlockAndInclusionList(Container):
signed_block: SignedBeaconBlock
signed_transactions: SignedInclusionListTransactions
class SignedInclusionListSidecar(Container):
message: InclusionListSidecar
signature: BLSSignature
```

## Modifications in EIP7547
Expand All @@ -68,18 +65,24 @@ The derivation of the `message-id` remains stable.

##### Global topics

###### `beacon_block`
###### `inclusion_list_sidecar`

The *type* of the payload of this topic changes to the (modified) `BeaconBlockAndInclusionList`.
The *type* of the payload of is `SignedInclusionListSidecar`, assuming the aliases `inclusion_list_sidecar = signed_inclusion_list_sidecar.message` and `signed_inclusion_list_summary = inclusion_list_sidecar.signed_inclusion_list_summary`.

New validation:
The following validations MUST pass before forwarding the `signed_inclusion_list_sidecar` on the network.

The following validations MUST pass before forwarding the `beacon_block` on the network.
- _[REJECT]_ The inclusion list transactions `inclusion_list_sidecar.transactions` length is within upperbound `MAX_TRANSACTIONS_PER_INCLUSION_LIST`.
- _[IGNORE]_ The sidecar is not from a future slot (with a `MAXIMUM_GOSSIP_CLOCK_DISPARITY` allowance) -- i.e. validate that `inclusion_list_sidecar.slot <= current_slot` (a client MAY queue future sidecars for processing at the appropriate slot).
- _[IGNORE]_ The sidecar is from a slot greater than the latest finalized slot -- i.e. validate that `inclusion_list_sidecar.slot > compute_start_slot_at_epoch(store.finalized_checkpoint.epoch)`
- _[REJECT]_ The inclusion list sidecar signature, `signed_inclusion_list_sidecar.signature`, is valid with respect to the `inclusion_list_sidecar.proposer_index` pubkey.
- _[REJECT]_ The inclusion list summary signature, `signed_inclusion_list_summary.signature`, is a valid signature of `signed_inclusion_list_summary.summary` with respect to the `inclusion_list_sidecar.proposer_index` pubkey.
- _[IGNORE]_ The sidecar's block's parent (defined by `inclusion_list_sidecar.parent_root`) has been seen (via both gossip and non-gossip sources) (a client MAY queue sidecars for processing once the parent block is retrieved).
- _[REJECT]_ The sidecar's block's parent (defined by `inclusion_list_sidecar.parent_root`) passes validation.
- _[REJECT]_ The sidecar is from a higher slot than the sidecar's block's parent (defined by `inclusion_list_sidecar.parent_root`).
- _[REJECT]_ The current finalized_checkpoint is an ancestor of the sidecar's block -- i.e. `get_checkpoint_block(store, inclusion_list_sidecar.parent_root, store.finalized_checkpoint.epoch) == store.finalized_checkpoint.root`.
- _[IGNORE]_ The sidecar is the first sidecar for the tuple (inclusion_list_sidecar.slot, inclusion_list_sidecar.proposer_index) with valid signature.
- _[REJECT]_ The sidecar is proposed by the expected proposer_index for the `inclusion_list_sidecar.slot` in the context of the current shuffling (defined by parent_root/slot). If the proposer_index cannot immediately be verified against the expected shuffling, the sidecar MAY be queued for later processing while proposers for the summary's branch are calculated -- in such a case do not REJECT, instead IGNORE this message.

- _[REJECT]_ The inclusion list transactions `beacon_block.transactions` length is within upperbound `MAX_TRANSACTIONS_PER_INCLUSION_LIST`.
- _[REJECT]_ The inclusion list summary has the same length of transactions `len(beacon_block.signed_block.inclusion_list_summary) == len(beacon_block.transactions)`.
- _[REJECT]_ The inclusion list transactions signature, `beacon_block.signed_transactions.signature`, is valid with respect to the `proposer_index` pubkey.
- _[REJECT]_ The summary is proposed by the expected proposer_index for the summary's slot in the context of the current shuffling (defined by parent_root/slot). If the proposer_index cannot immediately be verified against the expected shuffling, the inclusion list MAY be queued for later processing while proposers for the summary's branch are calculated -- in such a case do not REJECT, instead IGNORE this message.

#### Transitioning the gossip

Expand Down

0 comments on commit bca66b0

Please sign in to comment.