remove 'slot_hash_block'

This commit is contained in:
Danny Ryan 2018-12-06 10:41:50 -06:00
parent 464ad63464
commit 5e058a15b8
No known key found for this signature in database
GPG Key ID: 2765A792E42CE07A
1 changed files with 14 additions and 30 deletions

View File

@ -872,12 +872,12 @@ def get_beacon_proposer_index(state: BeaconState,
#### `get_updated_ancestor_hashes` #### `get_updated_ancestor_hashes`
```python ```python
def get_updated_ancestor_hashes(parent: BeaconBlock, def get_updated_ancestor_hashes(latest_block: BeaconBlock,
parent_hash: Hash32) -> List[Hash32]: latest_hash: Hash32) -> List[Hash32]:
new_ancestor_hashes = copy.deepcopy(parent.ancestor_hashes) new_ancestor_hashes = copy.deepcopy(latest_block.ancestor_hashes)
for i in range(32): for i in range(32):
if parent.slot % 2**i == 0: if latest_block.slot % 2**i == 0:
new_ancestor_hashes[i] = parent_hash new_ancestor_hashes[i] = latest_hash
return new_ancestor_hashes return new_ancestor_hashes
``` ```
@ -1205,31 +1205,28 @@ def exit_validator(index: int,
Below are the processing steps that happen at every slot. Below are the processing steps that happen at every slot.
* Let `parent_hash` be the hash of the latest beacon block that was processed in the chain. * Let `latest_hash` be the hash of the latest beacon block that was processed in the chain.
* Let `parent` be the `BeaconBlock` with the hash `parent_hash`. * Let `latest_block` be the `BeaconBlock` with the hash `latest_hash`.
* Set `state.slot += 1` * Set `state.slot += 1`
* Set `state.latest_block_hashes = state.latest_block_hashes + [parent_hash]`. (The output of `get_block_hash` should not change, except that it will no longer throw for `state.slot - 1`). * Set `state.latest_block_hashes = state.latest_block_hashes + [latest_hash]`. (The output of `get_block_hash` should not change, except that it will no longer throw for `state.slot - 1`).
If there is a block from the proposer for `state.slot`, we process that incoming block: If there is a block from the proposer for `state.slot`, we process that incoming block:
* Let `slot_has_block = True`
* Let `block` be that associated incoming block. * Let `block` be that associated incoming block.
* Verify that `block.ancestor_hashes` equals `get_updated_ancestor_hashes(parent, parent_hash)`. * Verify that `block.slot == state.slot`
* Verify that `block.ancestor_hashes` equals `get_updated_ancestor_hashes(latest_block, latest_hash)`.
If there is not a block from the proposer for `state.slot`, the slot is processed without a block: If there is not a block from the proposer for `state.slot`, the slot is processed without a block:
* Let `slot_has_block = False` * Let `state.validator_registry[get_beacon_proposer_index(state, state.slot)].randao_skips += 1`.
* Skip all other per-slot processing. Move directly to [per-epoch processing](#per-epoch-processing).
### Proposer signature ### Proposer signature
If `slot_has_block`:
* Let `block_hash_without_sig` be the hash of `block` where `proposer_signature` is set to `[0, 0]`. * Let `block_hash_without_sig` be the hash of `block` where `proposer_signature` is set to `[0, 0]`.
* Let `proposal_hash = hash(ProposalSignedData(state.slot, BEACON_CHAIN_SHARD_NUMBER, block_hash_without_sig))`. * Let `proposal_hash = hash(ProposalSignedData(state.slot, BEACON_CHAIN_SHARD_NUMBER, block_hash_without_sig))`.
* Verify that `BLSVerify(pubkey=state.validator_registry[get_beacon_proposer_index(state, state.slot)].pubkey, data=proposal_hash, sig=block.proposer_signature, domain=get_domain(state.fork_data, state.slot, DOMAIN_PROPOSAL))`. * Verify that `BLSVerify(pubkey=state.validator_registry[get_beacon_proposer_index(state, state.slot)].pubkey, data=proposal_hash, sig=block.proposer_signature, domain=get_domain(state.fork_data, state.slot, DOMAIN_PROPOSAL))`.
### Attestations ### Attestations
*If not `slot_has_block`, do not process attestations. Move to next section.*
* Verify that `len(block.attestations) <= MAX_ATTESTATIONS_PER_BLOCK`. * Verify that `len(block.attestations) <= MAX_ATTESTATIONS_PER_BLOCK`.
For each `attestation` in `block.attestations`: For each `attestation` in `block.attestations`:
@ -1248,8 +1245,6 @@ For each `attestation` in `block.attestations`:
### RANDAO ### RANDAO
If `slot_has_block`:
* Let `repeat_hash(x, n) = x if n == 0 else repeat_hash(hash(x), n-1)`. * Let `repeat_hash(x, n) = x if n == 0 else repeat_hash(hash(x), n-1)`.
* Let `proposer = state.validator_registry[get_beacon_proposer_index(state, state.slot)]`. * Let `proposer = state.validator_registry[get_beacon_proposer_index(state, state.slot)]`.
* Verify that `repeat_hash(block.randao_reveal, proposer.randao_skips + 1) == proposer.randao_commitment`. * Verify that `repeat_hash(block.randao_reveal, proposer.randao_skips + 1) == proposer.randao_commitment`.
@ -1257,23 +1252,13 @@ If `slot_has_block`:
* Set `proposer.randao_commitment = block.randao_reveal`. * Set `proposer.randao_commitment = block.randao_reveal`.
* Set `proposer.randao_skips = 0`. * Set `proposer.randao_skips = 0`.
If not `slot_has_block`:
* Let `state.validator_registry[get_beacon_proposer_index(state, state.slot)].randao_skips += 1`.
### PoW receipt root ### PoW receipt root
*If not `slot_has_block`, do not process PoW receipt root. Move to next section.*
* 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`. * 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)`. * Otherwise, append to `state.candidate_pow_receipt_roots` a new `CandidatePoWReceiptRootRecord(candidate_pow_receipt_root=block.candidate_pow_receipt_root, votes=1)`.
### Special objects ### Special objects
*If not `slot_has_block`, do not process special objects. Move to next section.*
* Verify that the quantity of each type of object in `block.specials` is less than or equal to its maximum (see table at the top). * Verify that the quantity of each type of object in `block.specials` is less than or equal to its maximum (see table at the top).
* Verify that objects are sorted in order of `kind`. That is, `block.specials[i+1].kind >= block.specials[i].kind` for `0 <= i < len(block.specials-1)`. * Verify that objects are sorted in order of `kind`. That is, `block.specials[i+1].kind >= block.specials[i].kind` for `0 <= i < len(block.specials-1)`.
@ -1607,9 +1592,8 @@ while len(state.persistent_committee_reassignments) > 0 and state.persistent_com
## State root processing ## State root processing
*If not `slot_has_block`, do not process state root. Move to next section.* If there exists a `block` for the slot being processed:
* Verify `block.state_root == hash(state)`
Verify `block.state_root == hash(state)`
# Appendix # Appendix
## Appendix A - Hash function ## Appendix A - Hash function