mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-01 21:36:07 +00:00
Remove is_merge_transition_complete
check from Capella
This commit is contained in:
parent
0f5ac1186e
commit
92324ca845
@ -64,26 +64,11 @@ parameter to the `PayloadAttributes`.
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
def prepare_execution_payload(state: BeaconState,
|
def prepare_execution_payload(state: BeaconState,
|
||||||
pow_chain: Dict[Hash32, PowBlock],
|
|
||||||
safe_block_hash: Hash32,
|
safe_block_hash: Hash32,
|
||||||
finalized_block_hash: Hash32,
|
finalized_block_hash: Hash32,
|
||||||
suggested_fee_recipient: ExecutionAddress,
|
suggested_fee_recipient: ExecutionAddress,
|
||||||
execution_engine: ExecutionEngine) -> Optional[PayloadId]:
|
execution_engine: ExecutionEngine) -> Optional[PayloadId]:
|
||||||
if not is_merge_transition_complete(state):
|
# Verify consistency of the parent hash with respect to the previous execution payload header
|
||||||
is_terminal_block_hash_set = TERMINAL_BLOCK_HASH != Hash32()
|
|
||||||
is_activation_epoch_reached = get_current_epoch(state) >= TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH
|
|
||||||
if is_terminal_block_hash_set and not is_activation_epoch_reached:
|
|
||||||
# Terminal block hash is set but activation epoch is not yet reached, no prepare payload call is needed
|
|
||||||
return None
|
|
||||||
|
|
||||||
terminal_pow_block = get_terminal_pow_block(pow_chain)
|
|
||||||
if terminal_pow_block is None:
|
|
||||||
# Pre-merge, no prepare payload call is needed
|
|
||||||
return None
|
|
||||||
# Signify merge via producing on top of the terminal PoW block
|
|
||||||
parent_hash = terminal_pow_block.block_hash
|
|
||||||
else:
|
|
||||||
# Post-merge, normal payload
|
|
||||||
parent_hash = state.latest_execution_payload_header.block_hash
|
parent_hash = state.latest_execution_payload_header.block_hash
|
||||||
|
|
||||||
# Set the forkchoice head and initiate the payload build process
|
# Set the forkchoice head and initiate the payload build process
|
||||||
|
@ -238,7 +238,6 @@ def process_deposit_receipt(state: BeaconState, deposit_receipt: DepositReceipt)
|
|||||||
```python
|
```python
|
||||||
def process_execution_payload(state: BeaconState, payload: ExecutionPayload, execution_engine: ExecutionEngine) -> None:
|
def process_execution_payload(state: BeaconState, payload: ExecutionPayload, execution_engine: ExecutionEngine) -> None:
|
||||||
# Verify consistency of the parent hash with respect to the previous execution payload header
|
# Verify consistency of the parent hash with respect to the previous execution payload header
|
||||||
if is_merge_transition_complete(state):
|
|
||||||
assert payload.parent_hash == state.latest_execution_payload_header.block_hash
|
assert payload.parent_hash == state.latest_execution_payload_header.block_hash
|
||||||
# Verify prev_randao
|
# Verify prev_randao
|
||||||
assert payload.prev_randao == get_randao_mix(state, get_current_epoch(state))
|
assert payload.prev_randao == get_randao_mix(state, get_current_epoch(state))
|
||||||
|
@ -370,7 +370,6 @@ def process_execution_payload(state: BeaconState, block: BeaconBlock, execution_
|
|||||||
payload = block.body.payload_data.value.execution_payload
|
payload = block.body.payload_data.value.execution_payload
|
||||||
|
|
||||||
# Verify consistency of the parent hash with respect to the previous execution payload header
|
# Verify consistency of the parent hash with respect to the previous execution payload header
|
||||||
if is_merge_transition_complete(state):
|
|
||||||
assert payload.parent_hash == state.latest_execution_payload_header.block_hash
|
assert payload.parent_hash == state.latest_execution_payload_header.block_hash
|
||||||
# Verify random
|
# Verify random
|
||||||
assert payload.random == get_randao_mix(state, get_current_epoch(state))
|
assert payload.random == get_randao_mix(state, get_current_epoch(state))
|
||||||
|
@ -118,12 +118,13 @@ To obtain an execution payload, a block proposer building a block on top of a `s
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
def prepare_execution_payload(state: BeaconState,
|
def prepare_execution_payload(state: BeaconState,
|
||||||
pow_chain: Dict[Hash32, PowBlock],
|
|
||||||
safe_block_hash: Hash32,
|
safe_block_hash: Hash32,
|
||||||
finalized_block_hash: Hash32,
|
finalized_block_hash: Hash32,
|
||||||
suggested_fee_recipient: ExecutionAddress,
|
suggested_fee_recipient: ExecutionAddress,
|
||||||
execution_engine: ExecutionEngine) -> Optional[PayloadId]:
|
execution_engine: ExecutionEngine,
|
||||||
|
pow_chain: Optional[Dict[Hash32, PowBlock]]=None) -> Optional[PayloadId]:
|
||||||
if not is_merge_transition_complete(state):
|
if not is_merge_transition_complete(state):
|
||||||
|
assert pow_chain is not None
|
||||||
is_terminal_block_hash_set = TERMINAL_BLOCK_HASH != Hash32()
|
is_terminal_block_hash_set = TERMINAL_BLOCK_HASH != Hash32()
|
||||||
is_activation_epoch_reached = get_current_epoch(state) >= TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH
|
is_activation_epoch_reached = get_current_epoch(state) >= TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH
|
||||||
if is_terminal_block_hash_set and not is_activation_epoch_reached:
|
if is_terminal_block_hash_set and not is_activation_epoch_reached:
|
||||||
|
@ -331,7 +331,7 @@ def process_historical_summaries_update(state: BeaconState) -> None:
|
|||||||
```python
|
```python
|
||||||
def process_block(state: BeaconState, block: BeaconBlock) -> None:
|
def process_block(state: BeaconState, block: BeaconBlock) -> None:
|
||||||
process_block_header(state, block)
|
process_block_header(state, block)
|
||||||
# Removed `is_execution_enabled` check
|
# [Modified in Capella] Removed `is_execution_enabled` check in Capella
|
||||||
process_withdrawals(state, block.body.execution_payload) # [New in Capella]
|
process_withdrawals(state, block.body.execution_payload) # [New in Capella]
|
||||||
process_execution_payload(state, block.body.execution_payload, EXECUTION_ENGINE) # [Modified in Capella]
|
process_execution_payload(state, block.body.execution_payload, EXECUTION_ENGINE) # [Modified in Capella]
|
||||||
process_randao(state, block.body)
|
process_randao(state, block.body)
|
||||||
@ -408,8 +408,8 @@ def process_withdrawals(state: BeaconState, payload: ExecutionPayload) -> None:
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
def process_execution_payload(state: BeaconState, payload: ExecutionPayload, execution_engine: ExecutionEngine) -> None:
|
def process_execution_payload(state: BeaconState, payload: ExecutionPayload, execution_engine: ExecutionEngine) -> None:
|
||||||
|
# [Modified in Capella] Removed `is_merge_transition_complete` check in Capella
|
||||||
# Verify consistency of the parent hash with respect to the previous execution payload header
|
# Verify consistency of the parent hash with respect to the previous execution payload header
|
||||||
if is_merge_transition_complete(state):
|
|
||||||
assert payload.parent_hash == state.latest_execution_payload_header.block_hash
|
assert payload.parent_hash == state.latest_execution_payload_header.block_hash
|
||||||
# Verify prev_randao
|
# Verify prev_randao
|
||||||
assert payload.prev_randao == get_randao_mix(state, get_current_epoch(state))
|
assert payload.prev_randao == get_randao_mix(state, get_current_epoch(state))
|
||||||
|
@ -69,26 +69,11 @@ That is, `state` is the `previous_state` processed through any empty slots up to
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
def prepare_execution_payload(state: BeaconState,
|
def prepare_execution_payload(state: BeaconState,
|
||||||
pow_chain: Dict[Hash32, PowBlock],
|
|
||||||
safe_block_hash: Hash32,
|
safe_block_hash: Hash32,
|
||||||
finalized_block_hash: Hash32,
|
finalized_block_hash: Hash32,
|
||||||
suggested_fee_recipient: ExecutionAddress,
|
suggested_fee_recipient: ExecutionAddress,
|
||||||
execution_engine: ExecutionEngine) -> Optional[PayloadId]:
|
execution_engine: ExecutionEngine) -> Optional[PayloadId]:
|
||||||
if not is_merge_transition_complete(state):
|
# [Modified in Capella] Removed `is_merge_transition_complete` check in Capella
|
||||||
is_terminal_block_hash_set = TERMINAL_BLOCK_HASH != Hash32()
|
|
||||||
is_activation_epoch_reached = get_current_epoch(state) >= TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH
|
|
||||||
if is_terminal_block_hash_set and not is_activation_epoch_reached:
|
|
||||||
# Terminal block hash is set but activation epoch is not yet reached, no prepare payload call is needed
|
|
||||||
return None
|
|
||||||
|
|
||||||
terminal_pow_block = get_terminal_pow_block(pow_chain)
|
|
||||||
if terminal_pow_block is None:
|
|
||||||
# Pre-merge, no prepare payload call is needed
|
|
||||||
return None
|
|
||||||
# Signify merge via producing on top of the terminal PoW block
|
|
||||||
parent_hash = terminal_pow_block.block_hash
|
|
||||||
else:
|
|
||||||
# Post-merge, normal payload
|
|
||||||
parent_hash = state.latest_execution_payload_header.block_hash
|
parent_hash = state.latest_execution_payload_header.block_hash
|
||||||
|
|
||||||
# Set the forkchoice head and initiate the payload build process
|
# Set the forkchoice head and initiate the payload build process
|
||||||
|
@ -216,7 +216,6 @@ def process_block(state: BeaconState, block: BeaconBlock) -> None:
|
|||||||
```python
|
```python
|
||||||
def process_execution_payload(state: BeaconState, payload: ExecutionPayload, execution_engine: ExecutionEngine) -> None:
|
def process_execution_payload(state: BeaconState, payload: ExecutionPayload, execution_engine: ExecutionEngine) -> None:
|
||||||
# Verify consistency of the parent hash with respect to the previous execution payload header
|
# Verify consistency of the parent hash with respect to the previous execution payload header
|
||||||
if is_merge_transition_complete(state):
|
|
||||||
assert payload.parent_hash == state.latest_execution_payload_header.block_hash
|
assert payload.parent_hash == state.latest_execution_payload_header.block_hash
|
||||||
# Verify prev_randao
|
# Verify prev_randao
|
||||||
assert payload.prev_randao == get_randao_mix(state, get_current_epoch(state))
|
assert payload.prev_randao == get_randao_mix(state, get_current_epoch(state))
|
||||||
|
@ -4,9 +4,12 @@ from typing import Optional
|
|||||||
from eth2spec.test.helpers.pow_block import (
|
from eth2spec.test.helpers.pow_block import (
|
||||||
prepare_random_pow_chain,
|
prepare_random_pow_chain,
|
||||||
)
|
)
|
||||||
|
from eth2spec.test.helpers.constants import (
|
||||||
|
BELLATRIX,
|
||||||
|
)
|
||||||
from eth2spec.test.context import (
|
from eth2spec.test.context import (
|
||||||
spec_state_test,
|
spec_state_test,
|
||||||
with_bellatrix_and_later,
|
with_phases,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -30,7 +33,7 @@ expected_results = [
|
|||||||
# it would return the first block (IS_HEAD_PARENT_BLOCK).
|
# it would return the first block (IS_HEAD_PARENT_BLOCK).
|
||||||
|
|
||||||
|
|
||||||
@with_bellatrix_and_later
|
@with_phases([BELLATRIX])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_get_pow_block_at_terminal_total_difficulty(spec, state):
|
def test_get_pow_block_at_terminal_total_difficulty(spec, state):
|
||||||
for result in expected_results:
|
for result in expected_results:
|
||||||
@ -90,7 +93,7 @@ prepare_execution_payload_expected_results = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@with_bellatrix_and_later
|
@with_phases([BELLATRIX])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_prepare_execution_payload(spec, state):
|
def test_prepare_execution_payload(spec, state):
|
||||||
for result in prepare_execution_payload_expected_results:
|
for result in prepare_execution_payload_expected_results:
|
||||||
@ -157,11 +160,11 @@ def test_prepare_execution_payload(spec, state):
|
|||||||
|
|
||||||
payload_id = spec.prepare_execution_payload(
|
payload_id = spec.prepare_execution_payload(
|
||||||
state=state,
|
state=state,
|
||||||
pow_chain=pow_chain.to_dict(),
|
|
||||||
safe_block_hash=safe_block_hash,
|
safe_block_hash=safe_block_hash,
|
||||||
finalized_block_hash=finalized_block_hash,
|
finalized_block_hash=finalized_block_hash,
|
||||||
suggested_fee_recipient=suggested_fee_recipient,
|
suggested_fee_recipient=suggested_fee_recipient,
|
||||||
execution_engine=TestEngine(),
|
execution_engine=TestEngine(),
|
||||||
|
pow_chain=pow_chain.to_dict(),
|
||||||
)
|
)
|
||||||
assert payload_id == result_payload_id
|
assert payload_id == result_payload_id
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user