Merge pull request #731 from ethereum/top-order
reorder ssz types topologically
This commit is contained in:
commit
8e08e742dc
|
@ -21,36 +21,31 @@
|
||||||
- [Max transactions per block](#max-transactions-per-block)
|
- [Max transactions per block](#max-transactions-per-block)
|
||||||
- [Signature domains](#signature-domains)
|
- [Signature domains](#signature-domains)
|
||||||
- [Data structures](#data-structures)
|
- [Data structures](#data-structures)
|
||||||
- [Beacon chain transactions](#beacon-chain-transactions)
|
- [Misc dependencies](#misc-dependencies)
|
||||||
- [Proposer slashings](#proposer-slashings)
|
|
||||||
- [`ProposerSlashing`](#proposerslashing)
|
|
||||||
- [Attester slashings](#attester-slashings)
|
|
||||||
- [`AttesterSlashing`](#attesterslashing)
|
|
||||||
- [`SlashableAttestation`](#slashableattestation)
|
|
||||||
- [Attestations](#attestations)
|
|
||||||
- [`Attestation`](#attestation)
|
|
||||||
- [`AttestationData`](#attestationdata)
|
|
||||||
- [`AttestationDataAndCustodyBit`](#attestationdataandcustodybit)
|
|
||||||
- [Deposits](#deposits)
|
|
||||||
- [`Deposit`](#deposit)
|
|
||||||
- [`DepositData`](#depositdata)
|
|
||||||
- [`DepositInput`](#depositinput)
|
|
||||||
- [Voluntary exits](#voluntary-exits)
|
|
||||||
- [`VoluntaryExit`](#voluntaryexit)
|
|
||||||
- [Transfers](#transfers)
|
|
||||||
- [`Transfer`](#transfer)
|
|
||||||
- [Beacon chain blocks](#beacon-chain-blocks)
|
|
||||||
- [`BeaconBlock`](#beaconblock)
|
|
||||||
- [`BeaconBlockHeader`](#beaconblockheader)
|
|
||||||
- [`BeaconBlockBody`](#beaconblockbody)
|
|
||||||
- [Beacon chain state](#beacon-chain-state)
|
|
||||||
- [`BeaconState`](#beaconstate)
|
|
||||||
- [`Validator`](#validator)
|
|
||||||
- [`Crosslink`](#crosslink)
|
|
||||||
- [`PendingAttestation`](#pendingattestation)
|
|
||||||
- [`Fork`](#fork)
|
- [`Fork`](#fork)
|
||||||
|
- [`Crosslink`](#crosslink)
|
||||||
- [`Eth1Data`](#eth1data)
|
- [`Eth1Data`](#eth1data)
|
||||||
- [`Eth1DataVote`](#eth1datavote)
|
- [`Eth1DataVote`](#eth1datavote)
|
||||||
|
- [`AttestationData`](#attestationdata)
|
||||||
|
- [`AttestationDataAndCustodyBit`](#attestationdataandcustodybit)
|
||||||
|
- [`SlashableAttestation`](#slashableattestation)
|
||||||
|
- [`DepositInput`](#depositinput)
|
||||||
|
- [`DepositData`](#depositdata)
|
||||||
|
- [`BeaconBlockHeader`](#beaconblockheader)
|
||||||
|
- [`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)
|
- [Custom Types](#custom-types)
|
||||||
- [Helper functions](#helper-functions)
|
- [Helper functions](#helper-functions)
|
||||||
- [`xor`](#xor)
|
- [`xor`](#xor)
|
||||||
|
@ -116,8 +111,6 @@
|
||||||
- [Beacon chain fork choice rule](#beacon-chain-fork-choice-rule)
|
- [Beacon chain fork choice rule](#beacon-chain-fork-choice-rule)
|
||||||
- [Beacon chain state transition function](#beacon-chain-state-transition-function)
|
- [Beacon chain state transition function](#beacon-chain-state-transition-function)
|
||||||
- [Per-slot processing](#per-slot-processing)
|
- [Per-slot processing](#per-slot-processing)
|
||||||
- [Slot](#slot)
|
|
||||||
- [Block roots](#block-roots)
|
|
||||||
- [Per-block processing](#per-block-processing)
|
- [Per-block processing](#per-block-processing)
|
||||||
- [Block header](#block-header)
|
- [Block header](#block-header)
|
||||||
- [RANDAO](#randao)
|
- [RANDAO](#randao)
|
||||||
|
@ -136,8 +129,8 @@
|
||||||
- [Eth1 data](#eth1-data-1)
|
- [Eth1 data](#eth1-data-1)
|
||||||
- [Rewards and penalties](#rewards-and-penalties)
|
- [Rewards and penalties](#rewards-and-penalties)
|
||||||
- [Justification and finalization](#justification-and-finalization)
|
- [Justification and finalization](#justification-and-finalization)
|
||||||
- [Attestation inclusion](#attestation-inclusion)
|
|
||||||
- [Crosslinks](#crosslinks-1)
|
- [Crosslinks](#crosslinks-1)
|
||||||
|
- [Apply rewards](#apply-rewards)
|
||||||
- [Ejections](#ejections)
|
- [Ejections](#ejections)
|
||||||
- [Validator registry and shuffling seed data](#validator-registry-and-shuffling-seed-data)
|
- [Validator registry and shuffling seed data](#validator-registry-and-shuffling-seed-data)
|
||||||
- [Slashings and exit queue](#slashings-and-exit-queue)
|
- [Slashings and exit queue](#slashings-and-exit-queue)
|
||||||
|
@ -286,69 +279,57 @@ 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 following data structures are defined as [SimpleSerialize (SSZ)](https://github.com/ethereum/eth2.0-specs/blob/master/specs/simple-serialize.md) objects.
|
||||||
|
|
||||||
### Beacon chain transactions
|
The types are defined topologically to aid in facilitating an executable version of the spec.
|
||||||
|
|
||||||
#### Proposer slashings
|
### Misc dependencies
|
||||||
|
|
||||||
##### `ProposerSlashing`
|
#### `Fork`
|
||||||
|
|
||||||
```python
|
```python
|
||||||
{
|
{
|
||||||
# Proposer index
|
# Previous fork version
|
||||||
'proposer_index': 'uint64',
|
'previous_version': 'uint64',
|
||||||
# First block header
|
# Current fork version
|
||||||
'header_1': BeaconBlockHeader,
|
'current_version': 'uint64',
|
||||||
# Second block header
|
# Fork epoch number
|
||||||
'header_2': BeaconBlockHeader,
|
'epoch': 'uint64',
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Attester slashings
|
#### `Crosslink`
|
||||||
|
|
||||||
##### `AttesterSlashing`
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
{
|
{
|
||||||
# First slashable attestation
|
# Epoch number
|
||||||
'slashable_attestation_1': SlashableAttestation,
|
'epoch': 'uint64',
|
||||||
# Second slashable attestation
|
# Shard data since the previous crosslink
|
||||||
'slashable_attestation_2': SlashableAttestation,
|
'crosslink_data_root': 'bytes32',
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
##### `SlashableAttestation`
|
#### `Eth1Data`
|
||||||
|
|
||||||
```python
|
```python
|
||||||
{
|
{
|
||||||
# Validator indices
|
# Root of the deposit tree
|
||||||
'validator_indices': ['uint64'],
|
'deposit_root': 'bytes32',
|
||||||
# Attestation data
|
# Block hash
|
||||||
'data': AttestationData,
|
'block_hash': 'bytes32',
|
||||||
# Custody bitfield
|
|
||||||
'custody_bitfield': 'bytes',
|
|
||||||
# Aggregate signature
|
|
||||||
'aggregate_signature': 'bytes96',
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Attestations
|
#### `Eth1DataVote`
|
||||||
|
|
||||||
##### `Attestation`
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
{
|
{
|
||||||
# Attester aggregation bitfield
|
# Data being voted for
|
||||||
'aggregation_bitfield': 'bytes',
|
'eth1_data': Eth1Data,
|
||||||
# Attestation data
|
# Vote count
|
||||||
'data': AttestationData,
|
'vote_count': 'uint64',
|
||||||
# Custody bitfield
|
|
||||||
'custody_bitfield': 'bytes',
|
|
||||||
# BLS aggregate signature
|
|
||||||
'aggregate_signature': 'bytes96',
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
##### `AttestationData`
|
#### `AttestationData`
|
||||||
|
|
||||||
```python
|
```python
|
||||||
{
|
{
|
||||||
|
@ -371,7 +352,7 @@ The following data structures are defined as [SimpleSerialize (SSZ)](https://git
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
##### `AttestationDataAndCustodyBit`
|
#### `AttestationDataAndCustodyBit`
|
||||||
|
|
||||||
```python
|
```python
|
||||||
{
|
{
|
||||||
|
@ -382,35 +363,22 @@ The following data structures are defined as [SimpleSerialize (SSZ)](https://git
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Deposits
|
#### `SlashableAttestation`
|
||||||
|
|
||||||
##### `Deposit`
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
{
|
{
|
||||||
# Branch in the deposit tree
|
# Validator indices
|
||||||
'proof': ['bytes32', DEPOSIT_CONTRACT_TREE_DEPTH],
|
'validator_indices': ['uint64'],
|
||||||
# Index in the deposit tree
|
# Attestation data
|
||||||
'index': 'uint64',
|
'data': AttestationData,
|
||||||
# Data
|
# Custody bitfield
|
||||||
'deposit_data': DepositData,
|
'custody_bitfield': 'bytes',
|
||||||
|
# Aggregate signature
|
||||||
|
'aggregate_signature': 'bytes96',
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
##### `DepositData`
|
#### `DepositInput`
|
||||||
|
|
||||||
```python
|
|
||||||
{
|
|
||||||
# Amount in Gwei
|
|
||||||
'amount': 'uint64',
|
|
||||||
# Timestamp from deposit contract
|
|
||||||
'timestamp': 'uint64',
|
|
||||||
# Deposit input
|
|
||||||
'deposit_input': DepositInput,
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
##### `DepositInput`
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
{
|
{
|
||||||
|
@ -423,9 +391,122 @@ The following data structures are defined as [SimpleSerialize (SSZ)](https://git
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Voluntary exits
|
#### `DepositData`
|
||||||
|
|
||||||
##### `VoluntaryExit`
|
```python
|
||||||
|
{
|
||||||
|
# Amount in Gwei
|
||||||
|
'amount': 'uint64',
|
||||||
|
# Timestamp from deposit contract
|
||||||
|
'timestamp': 'uint64',
|
||||||
|
# Deposit input
|
||||||
|
'deposit_input': DepositInput,
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `BeaconBlockHeader`
|
||||||
|
|
||||||
|
```python
|
||||||
|
{
|
||||||
|
'slot': 'uint64',
|
||||||
|
'previous_block_root': 'bytes32',
|
||||||
|
'state_root': 'bytes32',
|
||||||
|
'block_body_root': 'bytes32',
|
||||||
|
'signature': 'bytes96',
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `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 transactions
|
||||||
|
|
||||||
|
#### `ProposerSlashing`
|
||||||
|
|
||||||
|
```python
|
||||||
|
{
|
||||||
|
# Proposer index
|
||||||
|
'proposer_index': 'uint64',
|
||||||
|
# First block header
|
||||||
|
'header_1': BeaconBlockHeader,
|
||||||
|
# Second block header
|
||||||
|
'header_2': BeaconBlockHeader,
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `AttesterSlashing`
|
||||||
|
|
||||||
|
```python
|
||||||
|
{
|
||||||
|
# First slashable attestation
|
||||||
|
'slashable_attestation_1': SlashableAttestation,
|
||||||
|
# Second slashable attestation
|
||||||
|
'slashable_attestation_2': SlashableAttestation,
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `Attestation`
|
||||||
|
|
||||||
|
```python
|
||||||
|
{
|
||||||
|
# Attester aggregation bitfield
|
||||||
|
'aggregation_bitfield': 'bytes',
|
||||||
|
# Attestation data
|
||||||
|
'data': AttestationData,
|
||||||
|
# Custody bitfield
|
||||||
|
'custody_bitfield': 'bytes',
|
||||||
|
# BLS aggregate signature
|
||||||
|
'aggregate_signature': 'bytes96',
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `Deposit`
|
||||||
|
|
||||||
|
```python
|
||||||
|
{
|
||||||
|
# Branch in the deposit tree
|
||||||
|
'proof': ['bytes32', DEPOSIT_CONTRACT_TREE_DEPTH],
|
||||||
|
# Index in the deposit tree
|
||||||
|
'index': 'uint64',
|
||||||
|
# Data
|
||||||
|
'deposit_data': DepositData,
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `VoluntaryExit`
|
||||||
|
|
||||||
```python
|
```python
|
||||||
{
|
{
|
||||||
|
@ -438,9 +519,7 @@ The following data structures are defined as [SimpleSerialize (SSZ)](https://git
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Transfers
|
#### `Transfer`
|
||||||
|
|
||||||
##### `Transfer`
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
{
|
{
|
||||||
|
@ -461,32 +540,7 @@ The following data structures are defined as [SimpleSerialize (SSZ)](https://git
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Beacon chain blocks
|
### Beacon blocks
|
||||||
|
|
||||||
#### `BeaconBlock`
|
|
||||||
|
|
||||||
```python
|
|
||||||
{
|
|
||||||
# Header
|
|
||||||
'slot': 'uint64',
|
|
||||||
'previous_block_root': 'bytes32',
|
|
||||||
'state_root': 'bytes32',
|
|
||||||
'body': BeaconBlockBody,
|
|
||||||
'signature': 'bytes96',
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `BeaconBlockHeader`
|
|
||||||
|
|
||||||
```python
|
|
||||||
{
|
|
||||||
'slot': 'uint64',
|
|
||||||
'previous_block_root': 'bytes32',
|
|
||||||
'state_root': 'bytes32',
|
|
||||||
'block_body_root': 'bytes32',
|
|
||||||
'signature': 'bytes96',
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `BeaconBlockBody`
|
#### `BeaconBlockBody`
|
||||||
|
|
||||||
|
@ -503,7 +557,20 @@ The following data structures are defined as [SimpleSerialize (SSZ)](https://git
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Beacon chain state
|
#### `BeaconBlock`
|
||||||
|
|
||||||
|
```python
|
||||||
|
{
|
||||||
|
# Header
|
||||||
|
'slot': 'uint64',
|
||||||
|
'previous_block_root': 'bytes32',
|
||||||
|
'state_root': 'bytes32',
|
||||||
|
'body': BeaconBlockBody,
|
||||||
|
'signature': 'bytes96',
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Beacon state
|
||||||
|
|
||||||
#### `BeaconState`
|
#### `BeaconState`
|
||||||
|
|
||||||
|
@ -552,88 +619,6 @@ The following data structures are defined as [SimpleSerialize (SSZ)](https://git
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `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',
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `Crosslink`
|
|
||||||
|
|
||||||
```python
|
|
||||||
{
|
|
||||||
# Epoch number
|
|
||||||
'epoch': 'uint64',
|
|
||||||
# Shard data since the previous crosslink
|
|
||||||
'crosslink_data_root': 'bytes32',
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `PendingAttestation`
|
|
||||||
|
|
||||||
```python
|
|
||||||
{
|
|
||||||
# Attester aggregation bitfield
|
|
||||||
'aggregation_bitfield': 'bytes',
|
|
||||||
# Attestation data
|
|
||||||
'data': AttestationData,
|
|
||||||
# Custody bitfield
|
|
||||||
'custody_bitfield': 'bytes',
|
|
||||||
# Inclusion slot
|
|
||||||
'inclusion_slot': 'uint64',
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `Fork`
|
|
||||||
|
|
||||||
```python
|
|
||||||
{
|
|
||||||
# Previous fork version
|
|
||||||
'previous_version': 'uint64',
|
|
||||||
# Current fork version
|
|
||||||
'current_version': 'uint64',
|
|
||||||
# Fork epoch number
|
|
||||||
'epoch': 'uint64',
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `Eth1Data`
|
|
||||||
|
|
||||||
```python
|
|
||||||
{
|
|
||||||
# Root of the deposit tree
|
|
||||||
'deposit_root': 'bytes32',
|
|
||||||
# Block hash
|
|
||||||
'block_hash': 'bytes32',
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `Eth1DataVote`
|
|
||||||
|
|
||||||
```python
|
|
||||||
{
|
|
||||||
# Data being voted for
|
|
||||||
'eth1_data': Eth1Data,
|
|
||||||
# Vote count
|
|
||||||
'vote_count': 'uint64',
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Custom Types
|
## Custom Types
|
||||||
|
|
||||||
We define the following Python custom types for type hinting and readability:
|
We define the following Python custom types for type hinting and readability:
|
||||||
|
|
Loading…
Reference in New Issue