From 3f9f8a67e84479740519048054a1f3b27bf8db61 Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Thu, 7 Mar 2019 11:05:54 -0700 Subject: [PATCH] reorder ssz types to match https://github.com/ethereum/eth2.0-specs/pull/731 --- spec_pythonizer/spec.md | 246 +++++++++++++++++++--------------------- 1 file changed, 116 insertions(+), 130 deletions(-) diff --git a/spec_pythonizer/spec.md b/spec_pythonizer/spec.md index 6f0c9743..f6c5b292 100644 --- a/spec_pythonizer/spec.md +++ b/spec_pythonizer/spec.md @@ -21,35 +21,30 @@ - [Max transactions per block](#max-transactions-per-block) - [Signature domains](#signature-domains) - [Data structures](#data-structures) + - [Misc dependencies](#misc-dependencies) - [`Fork`](#fork) - [`Crosslink`](#crosslink) - [`Eth1Data`](#eth1data) - [`Eth1DataVote`](#eth1datavote) - - [Beacon chain transactions](#beacon-chain-transactions) - - [Attestations](#attestations) - - [`AttestationData`](#attestationdata) - - [`AttestationDataAndCustodyBit`](#attestationdataandcustodybit) - - [`Attestation`](#attestation) - - [Deposits](#deposits) - - [`DepositInput`](#depositinput) - - [`DepositData`](#depositdata) - - [`Deposit`](#deposit) - - [Voluntary exits](#voluntary-exits) - - [`VoluntaryExit`](#voluntaryexit) - - [Transfers](#transfers) - - [`Transfer`](#transfer) - - [Beacon chain blocks](#beacon-chain-blocks) + - [`AttestationData`](#attestationdata) + - [`AttestationDataAndCustodyBit`](#attestationdataandcustodybit) + - [`SlashableAttestation`](#slashableattestation) + - [`DepositInput`](#depositinput) + - [`DepositData`](#depositdata) - [`BeaconBlockHeader`](#beaconblockheader) - - [Proposer slashings](#proposer-slashings) - - [`ProposerSlashing`](#proposerslashing) - - [Attester slashings](#attester-slashings) - - [`SlashableAttestation`](#slashableattestation) - - [`AttesterSlashing`](#attesterslashing) - - [`BeaconBlockBody`](#beaconblockbody) - - [`BeaconBlock`](#beaconblock) - - [Beacon chain state](#beacon-chain-state) - [`Validator`](#validator) - [`PendingAttestation`](#pendingattestation) + - [Beacon transactions](#beacon-transactions) + - [`ProposerSlashing`](#proposerslashing) + - [`AttesterSlashing`](#attesterslashing) + - [`Attestation`](#attestation) + - [`Deposit`](#deposit) + - [`VoluntaryExit`](#voluntaryexit) + - [`Transfer`](#transfer) + - [Beacon blocks](#beacon-blocks) + - [`BeaconBlockBody`](#beaconblockbody) + - [`BeaconBlock`](#beaconblock) + - [Beacon state](#beacon-state) - [`BeaconState`](#beaconstate) - [Custom Types](#custom-types) - [Helper functions](#helper-functions) @@ -284,6 +279,10 @@ Code snippets appearing in `this style` are to be interpreted as Python code. The following data structures are defined as [SimpleSerialize (SSZ)](https://github.com/ethereum/eth2.0-specs/blob/master/specs/simple-serialize.md) objects. +The types are defined topologically to aid in facilitating an executable version of the spec. + +### Misc dependencies + #### `Fork` ```python @@ -330,11 +329,7 @@ The following data structures are defined as [SimpleSerialize (SSZ)](https://git } ``` -### Beacon chain transactions - -#### Attestations - -##### `AttestationData` +#### `AttestationData` ```python { @@ -357,7 +352,7 @@ The following data structures are defined as [SimpleSerialize (SSZ)](https://git } ``` -##### `AttestationDataAndCustodyBit` +#### `AttestationDataAndCustodyBit` ```python { @@ -368,24 +363,22 @@ The following data structures are defined as [SimpleSerialize (SSZ)](https://git } ``` -##### `Attestation` +#### `SlashableAttestation` ```python { - # Attester aggregation bitfield - 'aggregation_bitfield': 'bytes', + # Validator indices + 'validator_indices': ['uint64'], # Attestation data 'data': AttestationData, # Custody bitfield 'custody_bitfield': 'bytes', - # BLS aggregate signature + # Aggregate signature 'aggregate_signature': 'bytes96', } ``` -#### Deposits - -##### `DepositInput` +#### `DepositInput` ```python { @@ -398,7 +391,7 @@ The following data structures are defined as [SimpleSerialize (SSZ)](https://git } ``` -##### `DepositData` +#### `DepositData` ```python { @@ -411,74 +404,57 @@ The following data structures are defined as [SimpleSerialize (SSZ)](https://git } ``` -##### `Deposit` - -```python -{ - # Branch in the deposit tree - 'proof': ['bytes32', DEPOSIT_CONTRACT_TREE_DEPTH], - # Index in the deposit tree - 'index': 'uint64', - # Data - 'deposit_data': DepositData, -} -``` - -#### Voluntary exits - -##### `VoluntaryExit` +#### `BeaconBlockHeader` ```python { - # Minimum epoch for processing exit - 'epoch': 'uint64', - # Index of the exiting validator - 'validator_index': 'uint64', - # Validator signature + 'slot': 'uint64', + 'previous_block_root': 'bytes32', + 'state_root': 'bytes32', + 'block_body_root': 'bytes32', 'signature': 'bytes96', } ``` -#### Transfers - -##### `Transfer` +#### `Validator` ```python { - # Sender index - 'sender': 'uint64', - # Recipient index - 'recipient': 'uint64', - # Amount in Gwei - 'amount': 'uint64', - # Fee in Gwei for block proposer - 'fee': 'uint64', - # Inclusion slot - 'slot': 'uint64', - # Sender withdrawal pubkey + # BLS public key 'pubkey': 'bytes48', - # Sender signature - 'signature': 'bytes96', + # Withdrawal credentials + 'withdrawal_credentials': 'bytes32', + # Epoch when validator activated + 'activation_epoch': 'uint64', + # Epoch when validator exited + 'exit_epoch': 'uint64', + # Epoch when validator is eligible to withdraw + 'withdrawable_epoch': 'uint64', + # Did the validator initiate an exit + 'initiated_exit': 'bool', + # Was the validator slashed + 'slashed': 'bool', } ``` -### Beacon chain blocks - -#### `BeaconBlockHeader` +#### `PendingAttestation` ```python { - 'slot': 'uint64', - 'previous_block_root': 'bytes32', - 'state_root': 'bytes32', - 'block_body_root': 'bytes32', - 'signature': 'bytes96', + # Attester aggregation bitfield + 'aggregation_bitfield': 'bytes', + # Attestation data + 'data': AttestationData, + # Custody bitfield + 'custody_bitfield': 'bytes', + # Inclusion slot + 'inclusion_slot': 'uint64', } ``` -#### Proposer slashings +### Beacon transactions -##### `ProposerSlashing` +#### `ProposerSlashing` ```python { @@ -491,34 +467,80 @@ The following data structures are defined as [SimpleSerialize (SSZ)](https://git } ``` -#### Attester slashings +#### `AttesterSlashing` -##### `SlashableAttestation` +```python +{ + # First slashable attestation + 'slashable_attestation_1': SlashableAttestation, + # Second slashable attestation + 'slashable_attestation_2': SlashableAttestation, +} +``` + +#### `Attestation` ```python { - # Validator indices - 'validator_indices': ['uint64'], + # Attester aggregation bitfield + 'aggregation_bitfield': 'bytes', # Attestation data 'data': AttestationData, # Custody bitfield 'custody_bitfield': 'bytes', - # Aggregate signature + # BLS aggregate signature 'aggregate_signature': 'bytes96', } ``` -##### `AttesterSlashing` +#### `Deposit` ```python { - # First slashable attestation - 'slashable_attestation_1': SlashableAttestation, - # Second slashable attestation - 'slashable_attestation_2': SlashableAttestation, + # Branch in the deposit tree + 'proof': ['bytes32', DEPOSIT_CONTRACT_TREE_DEPTH], + # Index in the deposit tree + 'index': 'uint64', + # Data + 'deposit_data': DepositData, +} +``` + +#### `VoluntaryExit` + +```python +{ + # Minimum epoch for processing exit + 'epoch': 'uint64', + # Index of the exiting validator + 'validator_index': 'uint64', + # Validator signature + 'signature': 'bytes96', } ``` +#### `Transfer` + +```python +{ + # Sender index + 'sender': 'uint64', + # Recipient index + 'recipient': 'uint64', + # Amount in Gwei + 'amount': 'uint64', + # Fee in Gwei for block proposer + 'fee': 'uint64', + # Inclusion slot + 'slot': 'uint64', + # Sender withdrawal pubkey + 'pubkey': 'bytes48', + # Sender signature + 'signature': 'bytes96', +} +``` + +### Beacon blocks #### `BeaconBlockBody` @@ -548,43 +570,7 @@ The following data structures are defined as [SimpleSerialize (SSZ)](https://git } ``` -### Beacon chain state - -#### `Validator` - -```python -{ - # BLS public key - 'pubkey': 'bytes48', - # Withdrawal credentials - 'withdrawal_credentials': 'bytes32', - # Epoch when validator activated - 'activation_epoch': 'uint64', - # Epoch when validator exited - 'exit_epoch': 'uint64', - # Epoch when validator is eligible to withdraw - 'withdrawable_epoch': 'uint64', - # Did the validator initiate an exit - 'initiated_exit': 'bool', - # Was the validator slashed - 'slashed': 'bool', -} -``` - -#### `PendingAttestation` - -```python -{ - # Attester aggregation bitfield - 'aggregation_bitfield': 'bytes', - # Attestation data - 'data': AttestationData, - # Custody bitfield - 'custody_bitfield': 'bytes', - # Inclusion slot - 'inclusion_slot': 'uint64', -} -``` +### Beacon state #### `BeaconState`