Introduce Hash32 custom type

This commit is contained in:
Mikhail Kalinin 2021-04-08 14:48:03 +06:00
parent 6f095fc691
commit a1ded22b3a
3 changed files with 8 additions and 7 deletions

View File

@ -47,6 +47,7 @@ We define the following Python custom types for type hinting and readability:
| Name | SSZ equivalent | Description | | Name | SSZ equivalent | Description |
| - | - | - | | - | - | - |
| `OpaqueTransaction` | `ByteList[MAX_BYTES_PER_OPAQUE_TRANSACTION]` | a byte-list containing a single [typed transaction envelope](https://eips.ethereum.org/EIPS/eip-2718#opaque-byte-array-rather-than-an-rlp-array) structured as `TransactionType \|\| TransactionPayload` | | `OpaqueTransaction` | `ByteList[MAX_BYTES_PER_OPAQUE_TRANSACTION]` | a byte-list containing a single [typed transaction envelope](https://eips.ethereum.org/EIPS/eip-2718#opaque-byte-array-rather-than-an-rlp-array) structured as `TransactionType \|\| TransactionPayload` |
| `Hash32` | `Bytes32` | a 256-bit hash |
## Constants ## Constants
@ -98,8 +99,8 @@ The execution payload included in a `BeaconBlockBody`.
```python ```python
class ExecutionPayload(Container): class ExecutionPayload(Container):
block_hash: Bytes32 # Hash of execution block block_hash: Hash32 # Hash of execution block
parent_hash: Bytes32 parent_hash: Hash32
coinbase: Bytes20 coinbase: Bytes20
state_root: Bytes32 state_root: Bytes32
number: uint64 number: uint64
@ -118,8 +119,8 @@ The execution payload header included in a `BeaconState`.
```python ```python
class ExecutionPayloadHeader(Container): class ExecutionPayloadHeader(Container):
block_hash: Bytes32 # Hash of execution block block_hash: Hash32 # Hash of execution block
parent_hash: Bytes32 parent_hash: Hash32
coinbase: Bytes20 coinbase: Bytes20
state_root: Bytes32 state_root: Bytes32
number: uint64 number: uint64

View File

@ -30,7 +30,7 @@ This is the modification of the fork choice according to the executable beacon c
```python ```python
class PowBlock(Container): class PowBlock(Container):
block_hash: Bytes32 block_hash: Hash32
is_processed: boolean is_processed: boolean
is_valid: boolean is_valid: boolean
total_difficulty: uint256 total_difficulty: uint256
@ -38,7 +38,7 @@ class PowBlock(Container):
#### `get_pow_block` #### `get_pow_block`
Let `get_pow_block(hash: Bytes32) -> PowBlock` be the function that given the hash of the PoW block returns its data. Let `get_pow_block(hash: Hash32) -> PowBlock` be the function that given the hash of the PoW block returns its data.
*Note*: The `eth_getBlockByHash` JSON-RPC method does not distinguish invalid blocks from blocks that haven't been processed yet. Either extending this existing method or implementing a new one is required. *Note*: The `eth_getBlockByHash` JSON-RPC method does not distinguish invalid blocks from blocks that haven't been processed yet. Either extending this existing method or implementing a new one is required.

View File

@ -48,7 +48,7 @@ Let `get_pow_chain_head() -> PowBlock` be the function that returns the head of
###### `produce_execution_payload` ###### `produce_execution_payload`
Let `produce_execution_payload(parent_hash: Bytes32) -> ExecutionPayload` be the function that produces new instance of execution payload. Let `produce_execution_payload(parent_hash: Hash32) -> ExecutionPayload` be the function that produces new instance of execution payload.
The body of this function is implementation dependent. The body of this function is implementation dependent.
* Set `block.body.execution_payload = get_execution_payload(state)` where: * Set `block.body.execution_payload = get_execution_payload(state)` where: