# [DRAFT] Eth1-Eth2 Communication Protocol **This document has been deprecated and superseded by https://notes.ethereum.org/@n0ble/rayonism-the-merge-spec** The Communication Protocol between eth2 and eth1 nodes sufficient for implementation of [Executable Beacon Chain](https://ethresear.ch/t/executable-beacon-chain/8271) proposal. ## Reference - [eth2_produceBlock](#eth2_produceBlock) - [eth2_insertBlock](#eth2_insertBlock) - [eth2_setHead](#eth2_setHead) - [eth2_finalizeBlock](#eth2_finalizeBlock) ### Constants |Name|Value| |-|-| |LOGS_BLOOM_SIZE|256| |MAX_TRANSACTIONS|2**32| |MAX_PAYLOAD_SIZE|2**32| |RECENT_BLOCK_ROOTS_SIZE|256| ### Structures #### ExecutableData ```python= class Transaction(Container): nonce: uint64 gas_price: uint256 gas: uint64 to: bytes20 value: uint256 v: uint256 r: uint256 s: uint256 input: ByteList[MAX_PAYLOAD_SIZE] class ExecutableData(Container): parent_hash: bytes32 block_hash: bytes32 coinbase: bytes20 state_root: bytes32 gas_limit: uint64 gas_used: uint64 receipt_root: bytes32 logs_bloom: ByteVector[LOGS_BLOOM_SIZE] transactions: [Transaction, MAX_TRANSACTIONS] # for easier eth1-engine upgradability # will be removed later on difficulty: uint64 ``` #### Eth1 Block ```python= class BlockHeader: # = rpc_params.parent_hash / executable_data.parent_hash parent_hash: bytes32 uncles_hash: bytes32 # = EMPTY_LIST_HASH coinbase: bytes20 # = exec_data.coinbase state_root: bytes32 # = exec_data.state_root txs_root: bytes32 # = exec_data.txs_root receipts_root: bytes32 # = exec_data.receipts_root logs_bloom: bytes256 # = exec_data.logs_bloom difficulty: uint64 # = exec_data.difficulty timestamp: uint64 # = rpc_params.timestamp number: uint64 # = exec_data.number gas_limit: uint64 # = exec_data.gas_limit gas_used: uint64 # = exec_data.gas_used mix_hash: bytes32 # = zero bytes extra_data: bytes32 # = rpc_params.randao_mix nonce: uint64 # = 0 class Block: header: BlockHeader transactions: [Transaction] # = exec_data.transactions uncles: [] # = empty list ``` ### eth2_produceBlock Creates a new executable data on top of given parent. #### Parameters 1. `parent_hash`: `Hash` - parent eth1 block hash. 2. `randao_mix`: `Root` - randao mix. 3. `slot`: `UInt64` - current slot. 4. `timestamp:` `UInt64` - timestamp, computed with the formula `genesis_time + slot * SECONDS_PER_SLOT`. 5. `recent_beacon_block_roots`: `SSZVector[Root, RECENT_BLOCK_ROOTS_SIZE]`. #### Returns 1. `executable_data`: `ExecutableData`, SSZ encoded. ### eth2_insertBlock Inserts a block into a chain and returns a result. #### Parameters 1. `randao_mix`: `Root` - randao mix. 2. `slot`: `UInt64` - current slot. 3. `timestamp:` `UInt64` - timestamp, computed with the formula `genesis_time + slot * SECONDS_PER_SLOT`. 4. `recent_beacon_block_roots`: `SSZVector[Root, RECENT_BLOCK_ROOTS_SIZE]`. 5. `executable_data`: `ExecutableData`, SSZ encoded. #### Returns 1. `Object` - the result of block processing: - `result`: `Boolean` ### eth2_setHead #### Parameters 1. `block_hash`: `Hash` - the hash of the head of the application chain. #### Returns 1. `Object` - the result of processing: - `result`: `Boolean` ### eth2_finalizeBlock #### Parameters 1. `block_hash`: `Hash` - the hash of finalized eth1 block. #### Returns 1. `Object` - the result of block processing: - `result`: `Boolean`