Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion specs/_deprecated/sharding/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def process_execution_payload(
# Verify random
assert payload.random == get_randao_mix(state, get_current_epoch(state))
# Verify timestamp
assert payload.timestamp == compute_timestamp_at_slot(state, state.slot)
assert payload.timestamp == compute_time_at_slot(state, state.slot)

# Get sharded data commitments
sharded_commitments_container = block.body.sharded_commitments_container
Expand Down
2 changes: 1 addition & 1 deletion specs/_features/eip6800/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def process_execution_payload(
# Verify prev_randao
assert payload.prev_randao == get_randao_mix(state, get_current_epoch(state))
# Verify timestamp
assert payload.timestamp == compute_timestamp_at_slot(state, state.slot)
assert payload.timestamp == compute_time_at_slot(state, state.slot)

# Verify commitments are under limit
assert len(body.blob_kzg_commitments) <= MAX_BLOBS_PER_BLOCK
Expand Down
2 changes: 1 addition & 1 deletion specs/_features/eip7732/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ def process_execution_payload(
# Verify prev_randao
assert payload.prev_randao == get_randao_mix(state, get_current_epoch(state))
# Verify timestamp
assert payload.timestamp == compute_timestamp_at_slot(state, state.slot)
assert payload.timestamp == compute_time_at_slot(state, state.slot)
# Verify commitments are under limit
assert len(envelope.blob_kzg_commitments) <= MAX_BLOBS_PER_BLOCK
# Verify the execution payload is valid
Expand Down
2 changes: 1 addition & 1 deletion specs/_features/eip7732/p2p-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ regards to the `ExecutionPayload` are removed:
`len(signed_beacon_block.message.body.blob_kzg_commitments) <= MAX_BLOBS_PER_BLOCK`
- _[REJECT]_ The block's execution payload timestamp is correct with respect to
the slot -- i.e.
`execution_payload.timestamp == compute_timestamp_at_slot(state, block.slot)`.
`execution_payload.timestamp == compute_time_at_slot(state, block.slot)`.
- If `execution_payload` verification of block's parent by an execution node is
*not* complete:
- [REJECT] The block's parent (defined by `block.parent_root`) passes all
Expand Down
2 changes: 1 addition & 1 deletion specs/_features/eip7805/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def process_execution_payload(
# Verify prev_randao
assert payload.prev_randao == get_randao_mix(state, get_current_epoch(state))
# Verify timestamp
assert payload.timestamp == compute_timestamp_at_slot(state, state.slot)
assert payload.timestamp == compute_time_at_slot(state, state.slot)
# Verify commitments are under limit
assert len(body.blob_kzg_commitments) <= MAX_BLOBS_PER_BLOCK_ELECTRA
# Verify the execution payload is valid
Expand Down
16 changes: 1 addition & 15 deletions specs/bellatrix/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
- [`is_merge_transition_complete`](#is_merge_transition_complete)
- [`is_merge_transition_block`](#is_merge_transition_block)
- [`is_execution_enabled`](#is_execution_enabled)
- [Misc](#misc)
- [`compute_timestamp_at_slot`](#compute_timestamp_at_slot)
- [Beacon state accessors](#beacon-state-accessors)
- [Modified `get_inactivity_penalty_deltas`](#modified-get_inactivity_penalty_deltas)
- [Beacon state mutators](#beacon-state-mutators)
Expand Down Expand Up @@ -223,18 +221,6 @@ def is_execution_enabled(state: BeaconState, body: BeaconBlockBody) -> bool:
return is_merge_transition_block(state, body) or is_merge_transition_complete(state)
```

### Misc

#### `compute_timestamp_at_slot`

*Note*: This function is unsafe with respect to overflows and underflows.

```python
def compute_timestamp_at_slot(state: BeaconState, slot: Slot) -> uint64:
slots_since_genesis = slot - GENESIS_SLOT
return uint64(state.genesis_time + slots_since_genesis * SECONDS_PER_SLOT)
```

### Beacon state accessors

#### Modified `get_inactivity_penalty_deltas`
Expand Down Expand Up @@ -406,7 +392,7 @@ def process_execution_payload(
# Verify prev_randao
assert payload.prev_randao == get_randao_mix(state, get_current_epoch(state))
# Verify timestamp
assert payload.timestamp == compute_timestamp_at_slot(state, state.slot)
assert payload.timestamp == compute_time_at_slot(state, state.slot)
# Verify the execution payload is valid
assert execution_engine.verify_and_notify_new_payload(
NewPayloadRequest(execution_payload=payload)
Expand Down
2 changes: 1 addition & 1 deletion specs/bellatrix/p2p-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ If the execution is enabled for the block -- i.e.

- _[REJECT]_ The block's execution payload timestamp is correct with respect to
the slot -- i.e.
`execution_payload.timestamp == compute_timestamp_at_slot(state, block.slot)`.
`execution_payload.timestamp == compute_time_at_slot(state, block.slot)`.
- If `execution_payload` verification of block's parent by an execution node is
*not* complete:
- _[REJECT]_ The block's parent (defined by `block.parent_root`) passes all
Expand Down
2 changes: 1 addition & 1 deletion specs/bellatrix/validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def prepare_execution_payload(

# Set the forkchoice head and initiate the payload build process
payload_attributes = PayloadAttributes(
timestamp=compute_timestamp_at_slot(state, state.slot),
timestamp=compute_time_at_slot(state, state.slot),
prev_randao=get_randao_mix(state, get_current_epoch(state)),
suggested_fee_recipient=suggested_fee_recipient,
)
Expand Down
2 changes: 1 addition & 1 deletion specs/capella/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def process_execution_payload(
# Verify prev_randao
assert payload.prev_randao == get_randao_mix(state, get_current_epoch(state))
# Verify timestamp
assert payload.timestamp == compute_timestamp_at_slot(state, state.slot)
assert payload.timestamp == compute_time_at_slot(state, state.slot)
# Verify the execution payload is valid
assert execution_engine.verify_and_notify_new_payload(
NewPayloadRequest(execution_payload=payload)
Expand Down
2 changes: 1 addition & 1 deletion specs/capella/validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def prepare_execution_payload(

# Set the forkchoice head and initiate the payload build process
payload_attributes = PayloadAttributes(
timestamp=compute_timestamp_at_slot(state, state.slot),
timestamp=compute_time_at_slot(state, state.slot),
prev_randao=get_randao_mix(state, get_current_epoch(state)),
suggested_fee_recipient=suggested_fee_recipient,
withdrawals=get_expected_withdrawals(state), # [New in Capella]
Expand Down
2 changes: 1 addition & 1 deletion specs/deneb/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def process_execution_payload(
# Verify prev_randao
assert payload.prev_randao == get_randao_mix(state, get_current_epoch(state))
# Verify timestamp
assert payload.timestamp == compute_timestamp_at_slot(state, state.slot)
assert payload.timestamp == compute_time_at_slot(state, state.slot)

# [New in Deneb:EIP4844] Verify commitments are under limit
assert len(body.blob_kzg_commitments) <= MAX_BLOBS_PER_BLOCK
Expand Down
2 changes: 1 addition & 1 deletion specs/deneb/validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def prepare_execution_payload(

# Set the forkchoice head and initiate the payload build process
payload_attributes = PayloadAttributes(
timestamp=compute_timestamp_at_slot(state, state.slot),
timestamp=compute_time_at_slot(state, state.slot),
prev_randao=get_randao_mix(state, get_current_epoch(state)),
suggested_fee_recipient=suggested_fee_recipient,
withdrawals=get_expected_withdrawals(state),
Expand Down
2 changes: 1 addition & 1 deletion specs/electra/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,7 @@ def process_execution_payload(
# Verify prev_randao
assert payload.prev_randao == get_randao_mix(state, get_current_epoch(state))
# Verify timestamp
assert payload.timestamp == compute_timestamp_at_slot(state, state.slot)
assert payload.timestamp == compute_time_at_slot(state, state.slot)
# [Modified in Electra:EIP7691] Verify commitments are under limit
assert len(body.blob_kzg_commitments) <= MAX_BLOBS_PER_BLOCK_ELECTRA
# Verify the execution payload is valid
Expand Down
2 changes: 1 addition & 1 deletion specs/electra/validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def prepare_execution_payload(
withdrawals, _ = get_expected_withdrawals(state) # [Modified in EIP-7251]

payload_attributes = PayloadAttributes(
timestamp=compute_timestamp_at_slot(state, state.slot),
timestamp=compute_time_at_slot(state, state.slot),
prev_randao=get_randao_mix(state, get_current_epoch(state)),
suggested_fee_recipient=suggested_fee_recipient,
withdrawals=withdrawals,
Expand Down
2 changes: 1 addition & 1 deletion specs/fulu/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def process_execution_payload(
# Verify prev_randao
assert payload.prev_randao == get_randao_mix(state, get_current_epoch(state))
# Verify timestamp
assert payload.timestamp == compute_timestamp_at_slot(state, state.slot)
assert payload.timestamp == compute_time_at_slot(state, state.slot)
# [Modified in Fulu:EIP7892] Verify commitments are under limit
assert (
len(body.blob_kzg_commitments)
Expand Down
8 changes: 8 additions & 0 deletions specs/phase0/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
- [`compute_shuffled_index`](#compute_shuffled_index)
- [`compute_proposer_index`](#compute_proposer_index)
- [`compute_committee`](#compute_committee)
- [`compute_time_at_slot`](#compute_time_at_slot)
- [`compute_epoch_at_slot`](#compute_epoch_at_slot)
- [`compute_start_slot_at_epoch`](#compute_start_slot_at_epoch)
- [`compute_activation_exit_epoch`](#compute_activation_exit_epoch)
Expand Down Expand Up @@ -873,6 +874,13 @@ def compute_committee(
]
```

#### `compute_time_at_slot`

```python
def compute_time_at_slot(state: BeaconState, slot: Slot) -> uint64:
return uint64(state.genesis_time + slot * SECONDS_PER_SLOT)
```

#### `compute_epoch_at_slot`

```python
Expand Down
5 changes: 0 additions & 5 deletions specs/phase0/validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,6 @@ the Eth1 data for a given Eth1 block.
An honest block proposer sets
`block.body.eth1_data = get_eth1_vote(state, eth1_chain)` where:

```python
def compute_time_at_slot(state: BeaconState, slot: Slot) -> uint64:
return uint64(state.genesis_time + slot * SECONDS_PER_SLOT)
```

```python
def voting_period_start_time(state: BeaconState) -> uint64:
eth1_voting_period_start_slot = Slot(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def build_empty_execution_payload(spec, state, randao_mix=None):
Assuming a pre-state of the same slot, build a valid ExecutionPayload without any transactions.
"""
latest = state.latest_execution_payload_header
timestamp = spec.compute_timestamp_at_slot(state, state.slot)
timestamp = spec.compute_time_at_slot(state, state.slot)
empty_txs = spec.List[spec.Transaction, spec.MAX_TRANSACTIONS_PER_PAYLOAD]()

if randao_mix is None:
Expand Down