HackMD
    • Sharing Link copied
    • /edit
    • View mode
      • Edit mode
      • View mode
      • Book mode
      • Slide mode
      Edit mode View mode Book mode Slide mode
    • Note Permission
    • Read
      • Only me
      • Signed-in users
      • Everyone
      Only me Signed-in users Everyone
    • Write
      • Only me
      • Signed-in users
      • Everyone
      Only me Signed-in users Everyone
    • More (Comment, Invitee)
    • Publishing
    • Commenting Enable
      Disabled Forbidden Owners Signed-in users Everyone
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Invitee
    • No invitee
    • Options
    • Versions and GitHub Sync
    • Transfer ownership
    • Delete this note
    • Template
    • Save as template
    • Insert from template
    • Export
    • Google Drive Export to Google Drive
    • Gist
    • Import
    • Google Drive Import from Google Drive
    • Gist
    • Clipboard
    • Download
    • Markdown
    • HTML
    • Raw HTML
Menu Sharing Help
Menu
Options
Versions and GitHub Sync Transfer ownership Delete this note
Export
Google Drive Export to Google Drive Gist
Import
Google Drive Import from Google Drive Gist Clipboard
Download
Markdown HTML Raw HTML
Back
Sharing
Sharing Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
More (Comment, Invitee)
Publishing
More (Comment, Invitee)
Commenting Enable
Disabled Forbidden Owners Signed-in users Everyone
Permission
Owners
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Invitee
No invitee
   owned this note    owned this note      
Published Linked with GitHub
Like BookmarkBookmarked
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Quick merge via fork choice change The goal of this document is to describe a mechanism by which a merge can happen quickly, with little modification to either the ethpow or beacon clients. The only change required on the ethpow side is that the client must have a communication channel with a trusted beacon node and must change its fork choice rule. ### Beacon chain changes (consensus and fork choice) * We add a new field to the `BeaconBlockBody`: `application_block: bytes[<= 2**24]` * We add a new field to the `BeaconState`: `previous_application_block_hash: bytes32` (initialized to `ZERO_HASH`) If `state.previous_application_block_hash == ZERO_HASH`, then there are two valid options for the `block.application_block`: 1. Empty 2. A ethpow block that passes formatting checks, with `difficulty=1` If a beacon block chooses option (2), then the fork choice rule delays accepting the block until the ethpow node accepts it (regardless of whether or not an ethpow node considers it to be in the canonical chain). Additionally, the beacon node must ask the ethpow node for the `totalDifficulty` of the block (the `eth_getBlockByHash` RPC [already does this](https://eth.wiki/json-rpc/API#eth_getblockbyhash)), and the response must be `>= TRANSITION_TOTAL_DIFFICULTY`. Note that this requires the beacon node to be able to submit the application block body to the ethpow node by RPC. Additionally, the ethpow node must have a rule that PoW checks are disabled for ethpow blocks that originate from RPC requests from the beacon node. Note also one subtlety, which explains why the extra criterion for option (2) must be a fork choice rule and not a validity condition: suppose that someone submits a beacon block `B` containing application block `A`, and at the time of receiving `B`, the ethpow node does not know about `parent(A)` and so cannot accept `A`. However, five seconds later, the ethpow node learns about `parent(A)`. At that point, the ethpow node should also accept A, and the beacon node should then accept `B`. So an ineligible application block can later become eligible if the dependencies are satisfied after the fact. If `state.previous_application_block_hash != ZERO_HASH`, then a beacon block is valid if BOTH: 1. `RLPDecode(block.application_block).parent_hash == state.previous_application_block_hash` 2. The ethpow node has accepted the application block. If the beacon block is accepted in either case, we set `state.previous_application_block_hash = sha3(block.application_block)` ### Ethpow node changes As mentioned in the previous section, the ethpow node must add an RPC `submitBlock` mechanism, and **if a block is submitted using this mechanism by the beacon node, PoW checks (including difficulty update formula checks) must be disabled**. Additionally, the ethpow node fork choice changes: * If the beacon block that is the current head has `state.previous_application_block_hash == ZERO_HASH`, the fork choice is as normal * If the beacon block that is the current head has `state.previous_application_block_hash != ZERO_HASH`, the fork choice is to select the head as being the ethpow block that is contained as the `application_block` of the head beacon block ### Expected transition behavior * The PoW chain grows until there is at least one block whose `totalDifficulty >= TRANSITION_TOTAL_DIFFICULTY`. * As soon as the next honest proposer is scheduled, they will put that block (or a sister or descendant) into their beacon block. * Soon, all clients will receive both the ethpow block (plus all dependencies) on the ethpow side, and the beacon block on the beacon chain side. * From that point on, the ethpow fork choice switches over to the beacon chain, and the ethereum application chain continues from there. ### FAQ: Possible attacks #### Can the first proposer after the transition time be malicious by including an ethpow block that is not the head of the ethpow chain? We expect that an ethpow block will be included into the beacon chain within a minute of it becoming possible to do so (otherwise, there must be 5 malicious proposers in a row). At that point, there are very few possibilities for what ethpow blocks could be incuded: it must be the first transition block, a descendant or an uncle. In either case, the ethpow chain would not revert more than a few blocks. #### Could miners collude to do something malicious? Miners could do a "balance attack" and mine multiple chains, so there are many choices for what ethpow block to include. But ultimately, as long as there is at least one honest miner, eventually at least one block with `totalDifficulty >= TRANSITION_TOTAL_DIFFICULTY` gets created. If multiple options appear simultaneously, the first proposer would pick one, and as soon as the ethpow fork choice repoints to the beacon fork choice, the ethpow chain would proceed smoothly inside the beacon chain. #### What if the beacon chain reorgs around the transition boundary? If the beacon chain reorgs, then this would lead to the ethpow chain reorging. However, once the beacon chain stops reorging (or at least the blocks around the transition period stabilize), the ethpow fork choice would also stabilize, because the ethpow fork choice favors the chain embedded within the beacon chain if such a chain exists. ### Other FAQ #### Does this mean we're throwing out the plans to make the beacon chain interact with the application state more directly as [Mikhail Kalinin and co are working on](https://github.com/ethereum/eth2.0-specs/pull/2229)? **No.** Rather, the minimal merge as described above would only be the first step, and a post-merge hard fork would simplify the protocol and clean out unnecessary bits and make the interaction between the application layer and the beacon chain more "natural". Eventually we would go even further and, for example, replace the `application_block: bytes` with `application_txs: List[bytes]`) and even make the application state a "normal" part of the `BeaconState` (even though it's hashed in a non-SSZ way). In fact, the minimal merge will make these things _easier_ to work on, as it would no longer be needed to worry about merging two chains at the same time. #### When withdrawals? A post-merge hard fork can add support for withdrawals.

Import from clipboard

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lost their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.


Upgrade

All
  • All
  • Team
No template.

Create a template


Upgrade

Delete template

Do you really want to delete this template?

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Sign in via SAML

or

Sign in via GitHub

Help

  • English
  • 中文
  • 日本語

Documents

Tutorials

Book Mode Tutorial

Slide Example

YAML Metadata

Resources

Releases

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions

Versions and GitHub Sync

Sign in to link this note to GitHub Learn more
This note is not linked with GitHub Learn more
 
Add badge Pull Push GitHub Link Settings
Upgrade now

Version named by    

More Less
  • Edit
  • Delete

Note content is identical to the latest version.
Compare with
    Choose a version
    No search result
    Version not found

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub

      Please sign in to GitHub and install the HackMD app on your GitHub repo. Learn more

       Sign in to GitHub

      HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Available push count

      Upgrade

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Upgrade

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully