This commit is contained in:
Danny Ryan 2018-12-10 16:14:08 -06:00
parent 9cff4ae653
commit 03901ffe65
No known key found for this signature in database
GPG Key ID: 2765A792E42CE07A
1 changed files with 21 additions and 12 deletions

View File

@ -71,9 +71,11 @@
- [`bytes1`, `bytes2`, ...](#bytes1-bytes2-)
- [`get_effective_balance`](#get_effective_balance)
- [`get_new_validator_registry_delta_chain_tip`](#get_new_validator_registry_delta_chain_tip)
- [`get_fork_version`](#get_fork_version)
- [`get_domain`](#get_domain)
- [`verify_casper_votes`](#verify_casper_votes)
- [`integer_squareroot`](#integer_squareroot)
- [`BLSVerify`](#blsverify)
- [On startup](#on-startup)
- [Routine for activating a validator](#routine-for-activating-a-validator)
- [Routine for exiting a validator](#routine-for-exiting-a-validator)
@ -959,6 +961,17 @@ def get_new_validator_registry_delta_chain_tip(current_validator_registry_delta_
)
```
#### `get_fork_version`
```python
def get_fork_version(fork_data: ForkData,
slot: int) -> int:
if slot < fork_data.fork_slot:
return fork_data.pre_fork_version
else:
return fork_data.post_fork_version
```
#### `get_domain`
```python
@ -998,6 +1011,10 @@ def integer_squareroot(n: int) -> int:
return x
```
#### `BLSVerify`
`BLSVerify` is a function for verifying a BLS12-381 signature, defined in the [BLS12-381 spec](https://github.com/ethereum/eth2.0-specs/blob/master/specs/bls_verify.md).
### On startup
A valid block with slot `INITIAL_SLOT_NUMBER` (a "genesis block") has the following values. Other validity rules (e.g. requiring a signature) do not apply.
@ -1094,9 +1111,7 @@ def on_startup(initial_validator_entries: List[Any],
### Routine for processing deposits
These logs should be processed in the order in which they are emitted by Ethereum 1.0.
First, some helper functions:
First, a helper function:
```python
def min_empty_validator_index(validators: List[ValidatorRecord], current_slot: int) -> int:
@ -1104,17 +1119,9 @@ def min_empty_validator_index(validators: List[ValidatorRecord], current_slot: i
if v.balance == 0 and v.latest_status_change_slot + ZERO_BALANCE_VALIDATOR_TTL <= current_slot:
return i
return None
def get_fork_version(fork_data: ForkData,
slot: int) -> int:
if slot < fork_data.fork_slot:
return fork_data.pre_fork_version
else:
return fork_data.post_fork_version
```
`BLSVerify` is a function for verifying a BLS12-381 signature, defined in the [BLS12-381 spec](https://github.com/ethereum/eth2.0-specs/blob/master/specs/bls_verify.md).
Now, to add a [validator](#dfn-validator) or top up an existing [validator](#dfn-validator)'s balance:
Now, to add a [validator](#dfn-validator) or top up an existing [validator](#dfn-validator)'s balance by some `deposit` amount:
```python
def process_deposit(state: BeaconState,
@ -1353,6 +1360,8 @@ For each `attestation` in `block.body.attestations`:
Verify that `len(block.body.deposits) <= MAX_DEPOSITS`.
[TODO: add logic to ensure that deposits from 1.0 chain are processed in order:]
For each `deposit` in `block.body.deposits`:
* Let `serialized_deposit_data` be the serialized form of `deposit.deposit_data`. It should be the `DepositParameters` followed by 8 bytes for `deposit_data.value` and 8 bytes for `deposit_data.timestamp`. That is, it should match `deposit_data` in the [Ethereum 1.0 deposit contract](#ethereum-10-chain-deposit-contract) of which the hash was placed into the Merkle tree.