diff --git a/specs/merge/beacon-chain.md b/specs/merge/beacon-chain.md index a93076001..2793a4579 100644 --- a/specs/merge/beacon-chain.md +++ b/specs/merge/beacon-chain.md @@ -26,6 +26,7 @@ - [Misc](#misc) - [`is_transition_completed`](#is_transition_completed) - [`is_transition_block`](#is_transition_block) + - [`compute_time_at_slot`](#compute_time_at_slot) - [Block processing](#block-processing) - [Execution payload processing](#execution-payload-processing) - [`get_execution_state`](#get_execution_state) @@ -149,6 +150,14 @@ def is_transition_block(state: BeaconState, block_body: BeaconBlockBody) -> bool return not is_transition_completed(state) and block_body.execution_payload != ExecutionPayload() ``` +#### `compute_time_at_slot` + +```python +def compute_time_at_slot(state: BeaconState, slot: Slot) -> uint64: + slots_since_genesis = slot - GENESIS_SLOT + return uint64(state.genesis_time + slots_since_genesis * SECONDS_PER_SLOT) +``` + ### Block processing ```python @@ -171,7 +180,7 @@ The body of the function is implementation dependent. ##### `execution_state_transition` -Let `execution_state_transition(execution_state: ExecutionState, execution_payload: ExecutionPayload) -> None` be the transition function of Ethereum execution state. +Let `execution_state_transition(execution_state: ExecutionState, execution_payload: ExecutionPayload, timestamp: uint64) -> None` be the transition function of Ethereum execution state. The body of the function is implementation dependent. *Note*: `execution_state_transition` must throw `AssertionError` if either the transition itself or one of the pre or post conditions has failed. @@ -193,8 +202,9 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody) -> None assert execution_payload.parent_hash == state.latest_execution_payload_header.block_hash assert execution_payload.number == state.latest_execution_payload_header.number + 1 + timestamp = compute_time_at_slot(state, state.slot) execution_state = get_execution_state(state.latest_execution_payload_header.state_root) - execution_state_transition(execution_state, execution_payload) + execution_state_transition(execution_state, body.execution_payload, timestamp) state.latest_execution_payload_header = ExecutionPayloadHeader( block_hash=execution_payload.block_hash, diff --git a/specs/merge/validator.md b/specs/merge/validator.md index 42fe7adcf..2a23fd3e8 100644 --- a/specs/merge/validator.md +++ b/specs/merge/validator.md @@ -48,7 +48,7 @@ Let `get_pow_chain_head() -> PowBlock` be the function that returns the head of ###### `produce_execution_payload` -Let `produce_execution_payload(parent_hash: Hash32) -> ExecutionPayload` be the function that produces new instance of execution payload. +Let `produce_execution_payload(parent_hash: Hash32, timestamp: uint64) -> ExecutionPayload` be the function that produces new instance of execution payload. The body of this function is implementation dependent. * Set `block.body.execution_payload = get_execution_payload(state)` where: @@ -66,5 +66,6 @@ def get_execution_payload(state: BeaconState) -> ExecutionPayload: # Post-merge, normal payload execution_parent_hash = state.latest_execution_payload_header.block_hash - return produce_execution_payload(execution_parent_hash) + timestamp = compute_time_at_slot(state, state.slot) + return produce_execution_payload(execution_parent_hash, timestamp) ```