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

Apply new terminology to the merge spec #2319

Merged
merged 4 commits into from
Apr 9, 2021

Conversation

mkalinin
Copy link
Collaborator

@mkalinin mkalinin commented Apr 8, 2021

Updates the spec according to the new terminology.

There is a decision to rename application-layer to execution-layer to avoid potential confusion with the layer where smart contracts and apps built around them are living.

There is an essay utilising new terms to give an idea of how they should be used

UPD

In addition, it renames ExecutionBlockHeader to ExecutionPayloadHeader to emphasize the difference between the payload header and pre-merge PoW BlockHeader.

@hwwhww hwwhww added the Bellatrix CL+EL Merge label Apr 8, 2021
Copy link
Contributor

@hwwhww hwwhww left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rebased #2316 is here: 24f6521

Added comments on the proposed spec changes here. (I'll update #2316 once this PR is merged.) Otherwise, LGTM! 👍

Comment on lines 185 to 195

if not is_transition_completed(state):
assert body.application_payload == ApplicationPayload()
assert body.execution_payload == ExecutionPayload()
return

if not is_transition_block(state, body):
assert body.application_payload.parent_hash == state.latest_application_block_header.block_hash
assert body.application_payload.number == state.latest_application_block_header.number + 1

application_state = get_application_state(state.latest_application_block_header.state_root)
application_state_transition(application_state, body.application_payload)

state.latest_application_block_header = ApplicationBlockHeader(
block_hash=application_payload.block_hash,
parent_hash=application_payload.parent_hash,
coinbase=application_payload.coinbase,
state_root=application_payload.state_root,
number=application_payload.number,
gas_limit=application_payload.gas_limit,
gas_used=application_payload.gas_used,
receipt_root=application_payload.receipt_root,
logs_bloom=application_payload.logs_bloom,
transactions_root=hash_tree_root(application_payload.transactions),
assert body.execution_payload.parent_hash == state.latest_execution_payload_header.block_hash
assert body.execution_payload.number == state.latest_execution_payload_header.number + 1

execution_state = get_execution_state(state.latest_execution_payload_header.state_root)
execution_state_transition(execution_state, body.execution_payload)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

body. was missing on L198. It would be less verbose with:

    execution_payload = body.execution_payload

    if not is_transition_completed(state):
        assert execution_payload == ExecutionPayload()
        return

    if not is_transition_block(state, body):
        assert execution_payload.parent_hash == state.latest_execution_payload_header.block_hash
        assert execution_payload.number == state.latest_execution_payload_header.number + 1

    execution_state = get_execution_state(state.latest_execution_payload_header.state_root)
    execution_state_transition(execution_state, execution_payload)

```

#### `is_transition_block`

```python
def is_transition_block(state: BeaconState, block_body: BeaconBlockBody) -> boolean:
return state.latest_application_block_header.block_hash == Bytes32() and block_body.application_payload.block_hash != Bytes32()
return state.latest_execution_payload_header.block_hash == Bytes32() and block_body.execution_payload.block_hash != Bytes32()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linter max-line length is 120 now.
Suggesting:

Suggested change
return state.latest_execution_payload_header.block_hash == Bytes32() and block_body.execution_payload.block_hash != Bytes32()
is_empty_latest_execution_payload_header_block_hash = state.latest_execution_payload_header.block_hash == Bytes32()
is_empty_execution_payload_block_hash = block_body.execution_payload.block_hash == Bytes32()
return is_empty_latest_execution_payload_header_block_hash and not is_empty_execution_payload_block_hash


Let `application_state_transition(application_state: ApplicationState, application_payload: ApplicationPayload) -> None` be the transition function of ethereum application state.
Let `execution_state_transition(execution_state: ExecutionState, execution_payload: ExecutionPayload) -> None` be the transition function of ethereum execution state.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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) -> None` be the transition function of Ethereum execution state.

@mkalinin
Copy link
Collaborator Author

mkalinin commented Apr 8, 2021

@hwwhww I have addressed all the comments you've made, thanks! Also, fixed a bug in checking pre-conditions of process_execution_payload function.

Copy link
Contributor

@djrtwo djrtwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good! one question about process_execution_payload before the transition

specs/merge/beacon-chain.md Show resolved Hide resolved
@mkalinin
Copy link
Collaborator Author

mkalinin commented Apr 9, 2021

looks good! one question about process_execution_payload before the transition

Fixed now 👍

@djrtwo djrtwo merged commit f8c4977 into ethereum:dev Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bellatrix CL+EL Merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants