Skip to content

Commit

Permalink
update validator spec
Browse files Browse the repository at this point in the history
  • Loading branch information
terencechain committed Sep 3, 2023
1 parent 860d88e commit 1c27029
Showing 1 changed file with 55 additions and 18 deletions.
73 changes: 55 additions & 18 deletions specs/_features/ePBS/validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
- [Introduction](#introduction)
- [Prerequisites](#prerequisites)
- [Beacon chain responsibilities](#beacon-chain-responsibilities)
- [Validator assignment](#validator-assignment)
- [Lookahead](#lookahead)
- [Block proposal](#block-proposal)
- [Constructing the `BeaconBlockBody`](#constructing-the-beaconblockbody)
- [Constructing the new `signed_execution_payload_header_envelope` field in `BeaconBlockBody`](#constructing-the-new-signed_execution_payload_header_envelope-field-in--beaconblockbody)
- [Constructing the new `payload_attestations` field in `BeaconBlockBody`](#constructing-the-new-payload_attestations-field-in--beaconblockbody)
- [Consensus attesting remains unchanged](#consensus-attesting-remains-unchanged)
- [Consensus attestation aggregation reminds unchanged](#consensus-attestation-aggregation-reminds-unchanged)
- [Payload timeliness attestation](#payload-timeliness-attestation)
- [Construct payload timeliness attestation](#construct-payload-timeliness-attestation)
- [Broadcast execution attestation](#broadcast-execution-attestation)
- [Constructing payload attestation](#constructing-payload-attestation)
- [Prepare payload attestation message](#prepare-payload-attestation-message)
- [Broadcast payload attestation](#broadcast-payload-attestation)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand All @@ -35,17 +39,36 @@ Please see related Beacon Chain doc before continuing and use them as a referenc

## Beacon chain responsibilities

All validator responsibilities remain unchanged other than those noted below. Namely, proposer normal block production switched to using `SignedBeaconBlockWithBid` and attester with an additional duty to submit `ExecutionAttestation`
All validator responsibilities remain unchanged other than those noted below. Namely, proposer normal block production switched to a new `BeaconBlockBody`.
Proposer with additional duty to broadcast `InclusionList`.
Attester with chance with an additional duty to submit `PayloadAttestationMessage`.

## Validator assignment

### Lookahead

The beacon chain shufflings are designed to provide a minimum of 1 epoch lookahead
on the validator's upcoming payload attestation committee assignments for attesting dictated by the shuffling and slot.

`get_ptc` should be called at the start of each epoch
to get the assignment for the next epoch (`current_epoch + 1`).
A validator should plan for future assignments by noting their assigned attestation

### Block proposal

#### Constructing the `BeaconBlockBody`
#### Constructing the new `signed_execution_payload_header_envelope` field in `BeaconBlockBody`

To obtain `signed_execution_payload_header_envelope`, a block proposer building a block on top of a `state` must take the following actions:
* Listen to the `execution_payload_header` gossip subnet
* Filter out the bids where `signed_execution_payload_header_envelope.message.header.parent_hash` matches `state.latest_execution_payload_header.block_hash`
* The `signed_execution_payload_header_envelope` must satisfy the verification conditions found in `process_execution_payload_header`.
* Select the best bid and set `body.signed_execution_payload_header_envelope = signed_execution_payload_header_envelope`

To obtain an signed builder bid, a block proposer building a block on top of a `state` must take the following actions:
* Listen to the `builder_bid` gossip subnet
* Filter the bids where where `bid.header.parent_hash` matches `head.payload.block_hash`
* Select the best bid (the one with the highest value) and set `body.bid = signed_builder_bid`
#### Constructing the new `payload_attestations` field in `BeaconBlockBody`

Up to `MAX_PAYLOAD_ATTESTATIONS`, aggregate payload attestations can be included in the block.
The payload attestations added must satisfy the verification conditions found in payload attestation processing.
To maximize profit, the validator should attempt to gather aggregate payload attestations that include singular attestations from the largest number of validators whose signatures from the same epoch have not previously been added on chain.

### Consensus attesting remains unchanged

Expand All @@ -57,21 +80,35 @@ Some validators are selected to submit payload timeliness attestation. The `comm

A validator should create and broadcast the `execution_attestation` to the global execution attestation subnet at `SECONDS_PER_SLOT * 3 / INTERVALS_PER_SLOT` seconds after the start of `slot`

#### Construct payload timeliness attestation
#### Constructing payload attestation

##### Prepare payload attestation message
If a validator is in the payload attestation committee (i.e. `is_assigned_to_payload_committee()` above returns True),
then the validator should prepare a `PayloadAttestationMessage` for the current slot,
according to the logic in `get_payload_attestation_message` at `SECONDS_PER_SLOT * 3 / INTERVALS_PER_SLOT` interval.

```python
def is_assigned_to_payload_committee(state: BeaconState,
slot: Slot,
validator_index: ValidatorIndex) -> bool:

committe = get_ptc(state, slot)
return validator_index in committee
```

Next, the validator creates `signed_execution_attestation`
* Set `execution_attestation.slot = slot` where `slot` is the assigned slot.
* Set `execution_attestation.block_hash = block_hash` where `block_hash` is the block hash seen from the block builder reveal at `SECONDS_PER_SLOT * 2 / INTERVALS_PER_SLOT`
* Set `execution_attestation.validator_index = validator_index` where `validator_index` is the validator chosen to submit. The private key mapping to `state.validators[validator_index].pubkey` is used to sign the payload timeliness attestation.
* Set `signed_execution_attestation = SignedExecution(message=execution_attestation, signature=execution_attestation_signature)`, where `execution_attestation_signature` is obtained from:
Next, the validator creates `payload_attestation_message` as follows:
* Set `payload_attestation_data.slot = slot` where `slot` is the assigned slot.
* Set `payload_attestation_data.beacon_block_root = block_root` where `block_root` is the block hash seen from the block builder reveal at `SECONDS_PER_SLOT * 2 / INTERVALS_PER_SLOT`. If the `SignedExecutionPayloadEnvelope`
* Set `payload_attestation_message.validator_index = validator_index` where `validator_index` is the validator chosen to submit. The private key mapping to `state.validators[validator_index].pubkey` is used to sign the payload timeliness attestation.
* Set `payload_attestation_message = PayloadAttestationMessage(data=payload_attestation_data, signature=payload_attestation_signature)`, where `payload_attestation_signature` is obtained from:

```python
def get_execution_attestation_signature(state: BeaconState, attestation: ExecutionAttestation, privkey: int) -> BLSSignature:
def get_payload_attestation_signature(state: BeaconState, attestation: PayloadAttestationMessage, privkey: int) -> BLSSignature:
domain = get_domain(state, DOMAIN_PAYLOAD_TIMELINESS_COMMITTEE, compute_epoch_at_slot(attestation.slot))
signing_root = compute_signing_root(attestation, domain)
return bls.Sign(privkey, signing_root)
```

#### Broadcast execution attestation
#### Broadcast payload attestation

Finally, the validator broadcasts `signed_execution_attestation` to the global `execution_attestation` pubsub topic.
Finally, the validator broadcasts `payload_attestation_message` to the global `payload_attestation_message` pubsub topic.

0 comments on commit 1c27029

Please sign in to comment.