diff --git a/specs/merge/beacon-chain.md b/specs/merge/beacon-chain.md index ed12d3eb6..ee5f59aa8 100644 --- a/specs/merge/beacon-chain.md +++ b/specs/merge/beacon-chain.md @@ -246,15 +246,17 @@ The above function is accessed through the `EXECUTION_ENGINE` module which insta ### Block processing +*Note*: The call to the `process_execution_payload` must happen before the call to `process_randao` as the former depends on the `randao_mix` computed with the reveal of the previous block. + ```python def process_block(state: BeaconState, block: BeaconBlock) -> None: process_block_header(state, block) + if is_execution_enabled(state, block.body): + process_execution_payload(state, block.body.execution_payload, EXECUTION_ENGINE) # [New in Merge] process_randao(state, block.body) process_eth1_data(state, block.body) process_operations(state, block.body) process_sync_aggregate(state, block.body.sync_aggregate) - if is_execution_enabled(state, block.body): - process_execution_payload(state, block.body.execution_payload, EXECUTION_ENGINE) # [New in Merge] ``` ### Execution payload processing @@ -284,8 +286,6 @@ def is_valid_gas_limit(payload: ExecutionPayload, parent: ExecutionPayloadHeader #### `process_execution_payload` -*Note:* This function depends on `process_randao` function call as it retrieves the most recent randao mix from the `state`. Implementations that are considering parallel processing of execution payload with respect to beacon chain state transition function should work around this dependency. - ```python def process_execution_payload(state: BeaconState, payload: ExecutionPayload, execution_engine: ExecutionEngine) -> None: # Verify consistency of the parent hash, block number, random, base fee per gas and gas limit diff --git a/specs/merge/validator.md b/specs/merge/validator.md index efeeca061..e71ee74a8 100644 --- a/specs/merge/validator.md +++ b/specs/merge/validator.md @@ -75,17 +75,12 @@ def get_pow_block_at_total_difficulty(total_difficulty: uint256, pow_chain: Sequ return None -def compute_randao_mix(state: BeaconState, randao_reveal: BLSSignature) -> Bytes32: - epoch = get_current_epoch(state) - return xor(get_randao_mix(state, epoch), hash(randao_reveal)) - - def produce_execution_payload(state: BeaconState, parent_hash: Hash32, randao_reveal: BLSSignature, execution_engine: ExecutionEngine) -> ExecutionPayload: timestamp = compute_timestamp_at_slot(state, state.slot) - randao_mix = compute_randao_mix(state, randao_reveal) + randao_mix = get_randao_mix(state, get_current_epoch(state)) return execution_engine.assemble_block(parent_hash, timestamp, randao_mix) diff --git a/specs/sharding/beacon-chain.md b/specs/sharding/beacon-chain.md index f54394275..2c8e8f20b 100644 --- a/specs/sharding/beacon-chain.md +++ b/specs/sharding/beacon-chain.md @@ -552,12 +552,12 @@ def compute_committee_index_from_shard(state: BeaconState, slot: Slot, shard: Sh ```python def process_block(state: BeaconState, block: BeaconBlock) -> None: process_block_header(state, block) + # is_execution_enabled is omitted, execution is enabled by default. + process_execution_payload(state, block.body.execution_payload, EXECUTION_ENGINE) process_randao(state, block.body) process_eth1_data(state, block.body) process_operations(state, block.body) # [Modified in Sharding] process_sync_aggregate(state, block.body.sync_aggregate) - # is_execution_enabled is omitted, execution is enabled by default. - process_execution_payload(state, block.body.execution_payload, EXECUTION_ENGINE) ``` #### Operations diff --git a/tests/core/pyspec/eth2spec/test/helpers/block.py b/tests/core/pyspec/eth2spec/test/helpers/block.py index b8f7c4bcb..78b90b165 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/block.py +++ b/tests/core/pyspec/eth2spec/test/helpers/block.py @@ -99,8 +99,7 @@ def build_empty_block(spec, state, slot=None): empty_block.body.sync_aggregate.sync_committee_signature = spec.G2_POINT_AT_INFINITY if is_post_merge(spec): - randao_mix = spec.compute_randao_mix(state, empty_block.body.randao_reveal) - empty_block.body.execution_payload = build_empty_execution_payload(spec, state, randao_mix) + empty_block.body.execution_payload = build_empty_execution_payload(spec, state) return empty_block