Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is_merge -> is_merge_transition #2738

Merged
merged 1 commit into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 9 additions & 9 deletions specs/merge/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
- [`ExecutionPayloadHeader`](#executionpayloadheader)
- [Helper functions](#helper-functions)
- [Predicates](#predicates)
- [`is_merge_complete`](#is_merge_complete)
- [`is_merge_block`](#is_merge_block)
- [`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)
Expand Down Expand Up @@ -209,25 +209,25 @@ class ExecutionPayloadHeader(Container):

### Predicates

#### `is_merge_complete`
#### `is_merge_transition_complete`

```python
def is_merge_complete(state: BeaconState) -> bool:
def is_merge_transition_complete(state: BeaconState) -> bool:
return state.latest_execution_payload_header != ExecutionPayloadHeader()
```

#### `is_merge_block`
#### `is_merge_transition_block`

```python
def is_merge_block(state: BeaconState, body: BeaconBlockBody) -> bool:
return not is_merge_complete(state) and body.execution_payload != ExecutionPayload()
def is_merge_transition_block(state: BeaconState, body: BeaconBlockBody) -> bool:
return not is_merge_transition_complete(state) and body.execution_payload != ExecutionPayload()
```

#### `is_execution_enabled`

```python
def is_execution_enabled(state: BeaconState, body: BeaconBlockBody) -> bool:
return is_merge_block(state, body) or is_merge_complete(state)
return is_merge_transition_block(state, body) or is_merge_transition_complete(state)
```

### Misc
Expand Down Expand Up @@ -346,7 +346,7 @@ def process_block(state: BeaconState, block: BeaconBlock) -> None:
```python
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
if is_merge_complete(state):
if is_merge_transition_complete(state):
assert payload.parent_hash == state.latest_execution_payload_header.block_hash
# Verify random
assert payload.random == get_randao_mix(state, get_current_epoch(state))
Expand Down
2 changes: 1 addition & 1 deletion specs/merge/fork-choice.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def on_block(store: Store, signed_block: SignedBeaconBlock) -> None:
state_transition(state, signed_block, True)

# [New in Merge]
if is_merge_block(pre_state, block.body):
if is_merge_transition_block(pre_state, block.body):
validate_merge_block(block)

# Add new block to the store
Expand Down
2 changes: 1 addition & 1 deletion specs/merge/validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def prepare_execution_payload(state: BeaconState,
finalized_block_hash: Hash32,
suggested_fee_recipient: ExecutionAddress,
execution_engine: ExecutionEngine) -> Optional[PayloadId]:
if not is_merge_complete(state):
if not is_merge_transition_complete(state):
is_terminal_block_hash_set = TERMINAL_BLOCK_HASH != Hash32()
is_activation_epoch_reached = get_current_epoch(state.slot) >= TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH
if is_terminal_block_hash_set and not is_activation_epoch_reached:
Expand Down
2 changes: 1 addition & 1 deletion tests/core/pyspec/eth2spec/test/helpers/fork_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def tick_and_add_block(spec, store, signed_block, test_steps, valid=True,
pre_state = store.block_states[signed_block.message.parent_root]
block_time = pre_state.genesis_time + signed_block.message.slot * spec.config.SECONDS_PER_SLOT
if merge_block:
assert spec.is_merge_block(pre_state, signed_block.message.body)
assert spec.is_merge_transition_block(pre_state, signed_block.message.body)

if store.time < block_time:
on_tick_and_append_step(spec, store, block_time, test_steps)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_initialize_pre_transition_no_param(spec):
yield 'execution_payload_header', 'meta', False
state = spec.initialize_beacon_state_from_eth1(eth1_block_hash, eth1_timestamp, deposits)

assert not spec.is_merge_complete(state)
assert not spec.is_merge_transition_complete(state)

yield 'state', state

Expand Down Expand Up @@ -79,7 +79,7 @@ def test_initialize_pre_transition_empty_payload(spec):
execution_payload_header=execution_payload_header,
)

assert not spec.is_merge_complete(state)
assert not spec.is_merge_transition_complete(state)

yield 'execution_payload_header', execution_payload_header

Expand Down Expand Up @@ -117,6 +117,6 @@ def test_initialize_post_transition(spec):

yield 'execution_payload_header', genesis_execution_payload_header

assert spec.is_merge_complete(state)
assert spec.is_merge_transition_complete(state)

yield 'state', state
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
@spec_state_test
def test_fail_merge_complete(spec, state):
state = build_state_with_incomplete_transition(spec, state)
assert not spec.is_merge_complete(state)
assert not spec.is_merge_transition_complete(state)


@with_merge_and_later
@spec_state_test
def test_success_merge_complete(spec, state):
state = build_state_with_complete_transition(spec, state)
assert spec.is_merge_complete(state)
assert spec.is_merge_transition_complete(state)


# with_complete_transition', 'with_execution_payload', 'is_merge_block', 'is_execution_enabled'
# with_complete_transition', 'with_execution_payload', 'is_merge_transition_block', 'is_execution_enabled'
expected_results = [
(True, True, False, True),
(True, False, False, True),
Expand All @@ -39,7 +39,7 @@ def test_is_merge_block_and_is_execution_enabled(spec, state):
(
with_complete_transition,
with_execution_payload,
is_merge_block,
is_merge_transition_block,
is_execution_enabled
) = result
if with_complete_transition:
Expand All @@ -51,5 +51,5 @@ def test_is_merge_block_and_is_execution_enabled(spec, state):
if with_execution_payload:
body.execution_payload = build_empty_execution_payload(spec, state)

assert spec.is_merge_block(state, body) == is_merge_block
assert spec.is_merge_transition_block(state, body) == is_merge_transition_block
assert spec.is_execution_enabled(state, body) == is_execution_enabled