Merge pull request #164 from ethereum/vbuterin-patch-12

Made candidate PoW receipt roots into a map
This commit is contained in:
Justin 2018-11-24 21:42:51 +00:00 committed by GitHub
commit 51f8ea16ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 12 deletions

View File

@ -238,8 +238,7 @@ The `BeaconState` has the following fields:
'genesis_time': 'uint64',
# PoW receipt root
'processed_pow_receipt_root': 'hash32',
'candidate_pow_receipt_root': 'hash32',
'candidate_pow_receipt_root_votes': 'uint64',
'candidate_pow_receipt_roots': [CandidatePoWReceiptRootRecord],
# Parameters relevant to hard forks / versioning.
# Should be updated only by hard forks.
'pre_fork_version': 'uint64',
@ -312,6 +311,17 @@ A `ShardReassignmentRecord` object has the following fields:
}
```
A `CandidatePoWReceiptRootRecord` object contains the following fields:
```python
{
# Candidate PoW receipt root
'candidate_pow_receipt_root': 'hash32',
# Vote count
'votes': 'uint64'
}
```
## Beacon chain processing
The beacon chain is the "main chain" of the PoS system. The beacon chain's main responsibilities are:
@ -610,7 +620,7 @@ If the user wishes to deposit more than `DEPOSIT_SIZE` ETH, they would need to m
* `initial_validator_entries` equal to the list of data records published as HashChainValue logs so far, in the order in which they were published (oldest to newest).
* `genesis_time` equal to the `time` value published in the log
* `pow_receipt_root` equal to the `receipt_root` value published in the log
* `processed_pow_receipt_root` equal to the `receipt_root` value published in the log
### On startup
@ -620,7 +630,7 @@ A valid block with slot `0` (the "genesis block") has the following values. Othe
{
'slot': 0,
'randao_reveal': bytes32(0),
'candidate_pow_receipt_root': bytes32(0),
'candidate_pow_receipt_roots': [],
'ancestor_hashes': [bytes32(0) for i in range(32)],
'state_root': STARTUP_STATE_ROOT,
'attestations': [],
@ -632,7 +642,7 @@ A valid block with slot `0` (the "genesis block") has the following values. Othe
`STARTUP_STATE_ROOT` is the root of the initial state, computed by running the following code:
```python
def on_startup(initial_validator_entries: List[Any], genesis_time: uint64, pow_receipt_root: Hash32) -> BeaconState:
def on_startup(initial_validator_entries: List[Any], genesis_time: uint64, processed_pow_receipt_root: Hash32) -> BeaconState:
# Induct validators
validators = []
for pubkey, proof_of_possession, withdrawal_credentials, \
@ -671,9 +681,8 @@ def on_startup(initial_validator_entries: List[Any], genesis_time: uint64, pow_r
validator_set_delta_hash_chain=bytes([0] * 32), # stub
current_exit_seq=0,
genesis_time=genesis_time,
processed_pow_receipt_root=pow_receipt_root,
candidate_pow_receipt_root=bytes([0] * 32),
candidate_pow_receipt_root_votes=0,
processed_pow_receipt_root=processed_pow_receipt_root,
candidate_pow_receipt_roots=[],
pre_fork_version=INITIAL_FORK_VERSION,
post_fork_version=INITIAL_FORK_VERSION,
fork_slot_number=0,
@ -822,7 +831,7 @@ Verify that `BLSVerify(pubkey=get_beacon_proposer(state, block.slot).pubkey, dat
### Process PoW receipt root
If `block.candidate_pow_receipt_root == state.candidate_pow_receipt_root` set `state.candidate_pow_receipt_root_votes += 1`.
If `block.candidate_pow_receipt_root` is `x.candidate_pow_receipt_root` for some `x` in `state.candidate_pow_receipt_roots`, set `x.votes += 1`. Otherwise, append to `state.candidate_pow_receipt_roots` a new `CandidatePoWReceiptRootRecord(candidate_pow_receipt_root=block.candidate_pow_receipt_root, votes=1)`.
### Process penalties, logouts and other special objects
@ -973,9 +982,8 @@ For every shard number `shard` for which a crosslink committee exists in the cyc
If `last_state_recalculation_slot % POW_RECEIPT_ROOT_VOTING_PERIOD == 0`, then:
* If `state.candidate_pow_receipt_root_votes * 2 >= POW_RECEIPT_ROOT_VOTING_PERIOD` set `state.processed_pow_receipt_root = state.candidate_pow_receipt_root`.
* Set `state.candidate_pow_receipt_root = block.candidate_pow_receipt_root`.
* Set `state.candidate_pow_receipt_root_votes = 0`.
* If for any `x` in `state.candidate_pow_receipt_root`, `x.votes * 2 >= POW_RECEIPT_ROOT_VOTING_PERIOD` set `state.processed_pow_receipt_root = x.receipt_root`.
* Set `state.candidate_pow_receipt_roots = []`.
### Validator set change