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

New application payload fields #2295

Merged
merged 4 commits into from
Apr 6, 2021

Conversation

mkalinin
Copy link
Contributor

What's done

Adds the following fields to the ApplicationPayload:

  • parent_hash: Bytes32
  • number: uint64

Adds application_block_number to the BeaconState and incorporates following rules that ensures the validity of the application block tree:

assert body.application_payload.parent_hash == state.application_block_hash
assert body.application_payload.number == state.application_block_number + 1

It would also make sense to add gas_limit/base_fee to the state with corresponding validity rules once EIP-1559 is shipped.

Rationale

The main reason of doing this is making structures and code forward compatible with stateless execution which implies that there is no application block tree that is maintained by the application-layer. It results in a following requirements on consensus-layer:

  • provide all data required to re-assemble a block to the application-layer
  • check validity conditions of the application block tree

A byproduct of adding parent_hash is the following simplification in the transition process. Instead of submitting an empty ApplicationPayload with block_hash = last_pow_block.hash to signify the transition block, proposer becomes eligible to propose full ApplicationPayload with parent_hash referring to the last PoW block. Aside of simplification it also have a small incentivising effect as proposer of the transition block gets transaction fees now.

The cost of this change is additional 40 bytes in BeaconBlockBody structure.


```python
class BeaconState(phase0.BeaconState):
# Application-layer
application_state_root: Bytes32 # [New in Merge]
application_block_hash: Bytes32 # [New in Merge]
application_block_number: uint64 # [New in Merge]
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it better to define an ApplicationState container and bundle these in?

class ApplicationState(Container): 
    root: Bytes32 
    block_hash: Bytes32
    block_number: uint64


class BeaconState(phase0.BeaconState):
    application_state: ApplicationState

Especially if we are going to add eip1559 fields later on

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking about this as well, but this is rather an ApplicationBlockHeader than ApplicationState. It would probably make sense to include all fields except for transactions into beacon state.

class ApplicationBlockHeader(Container):
    block_hash: Bytes32
    parent_hash: Bytes32
    coinbase: Bytes20
    state_root: Bytes32
    number: uint64
    gas_limit: uint64
    gas_used: uint64
    receipt_root: Bytes32
    logs_bloom: ByteVector[BYTES_PER_LOGS_BLOOM]


class BeaconState(phase0.BeaconState)
    latest_application_block_header: ApplicationBlockHeader  # Akin to `latest_block_header`

@djrtwo
Copy link
Contributor

djrtwo commented Apr 1, 2021

@mkalinin are you considering trying the app-block-header in this PR or do you want it reviewed as is?

@mkalinin
Copy link
Contributor Author

mkalinin commented Apr 1, 2021

@mkalinin are you considering trying the app-block-header in this PR or do you want it reviewed as is?

Let me try and see how it will look like

@mkalinin mkalinin force-pushed the application-payload-fields branch from 0953a2b to 79aee86 Compare April 2, 2021 15:02
@hwwhww hwwhww added the Bellatrix CL+EL Merge label Apr 5, 2021
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! I'd mainly suggest embedding transactions_root into the header to allow for sharing htr across the two objects

gas_limit: uint64
gas_used: uint64
receipt_root: Bytes32
logs_bloom: ByteVector[BYTES_PER_LOGS_BLOOM]
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest we add transactions_root so that this merklizes to the same root of ApplicationPayload

We can then rename this to ApplicationPayloadHeader or rename the payload to ApplicationBlock.

(side note, we mgiht be renaming these all to use Execution prefix but thats a separate PR

@mkalinin
Copy link
Contributor Author

mkalinin commented Apr 6, 2021

Looks good! I'd mainly suggest embedding transactions_root into the header to allow for sharing htr across the two objects

@djrtwo Implemented transactions_root as per suggested 👍

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.

great work!

@djrtwo djrtwo merged commit 680e264 into ethereum:dev Apr 6, 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.

4 participants