randao reveal is signed epoch number (#498)

This commit is contained in:
Danny Ryan 2019-01-26 12:13:12 -07:00 committed by Justin
parent 1a5424591e
commit 1a41078768
2 changed files with 5 additions and 9 deletions

View File

@ -514,8 +514,6 @@ The following data structures are defined as [SimpleSerialize (SSZ)](https://git
'pubkey': 'bytes48', 'pubkey': 'bytes48',
# Withdrawal credentials # Withdrawal credentials
'withdrawal_credentials': 'bytes32', 'withdrawal_credentials': 'bytes32',
# Number of proposer slots since genesis
'proposer_slots': 'uint64',
# Slot when validator activated # Slot when validator activated
'activation_slot': 'uint64', 'activation_slot': 'uint64',
# Slot when validator exited # Slot when validator exited
@ -1368,7 +1366,6 @@ def process_deposit(state: BeaconState,
validator = Validator( validator = Validator(
pubkey=pubkey, pubkey=pubkey,
withdrawal_credentials=withdrawal_credentials, withdrawal_credentials=withdrawal_credentials,
proposer_slots=0,
activation_slot=FAR_FUTURE_SLOT, activation_slot=FAR_FUTURE_SLOT,
exit_slot=FAR_FUTURE_SLOT, exit_slot=FAR_FUTURE_SLOT,
withdrawal_slot=FAR_FUTURE_SLOT, withdrawal_slot=FAR_FUTURE_SLOT,
@ -1447,7 +1444,6 @@ Below are the processing steps that happen at every slot.
### Misc counters ### Misc counters
* Set `state.slot += 1`. * Set `state.slot += 1`.
* Set `state.validator_registry[get_beacon_proposer_index(state, state.slot)].proposer_slots += 1`.
* Set `state.latest_randao_mixes[state.slot % LATEST_RANDAO_MIXES_LENGTH] = state.latest_randao_mixes[(state.slot - 1) % LATEST_RANDAO_MIXES_LENGTH]` * Set `state.latest_randao_mixes[state.slot % LATEST_RANDAO_MIXES_LENGTH] = state.latest_randao_mixes[(state.slot - 1) % LATEST_RANDAO_MIXES_LENGTH]`
### Block roots ### Block roots
@ -1473,8 +1469,8 @@ Below are the processing steps that happen at every `block`.
### RANDAO ### RANDAO
* 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 `bls_verify(pubkey=proposer.pubkey, message=int_to_bytes32(proposer.proposer_slots), signature=block.randao_reveal, domain=get_domain(state.fork, state.slot, DOMAIN_RANDAO))`. * Verify that `bls_verify(pubkey=proposer.pubkey, message=int_to_bytes32(state.slot // EPOCH_LENGTH), signature=block.randao_reveal, domain=get_domain(state.fork, state.slot, DOMAIN_RANDAO))`.
* Set `state.latest_randao_mixes[state.slot % LATEST_RANDAO_MIXES_LENGTH] = hash(state.latest_randao_mixes[state.slot % LATEST_RANDAO_MIXES_LENGTH] + block.randao_reveal)`. * Set `state.latest_randao_mixes[state.slot % LATEST_RANDAO_MIXES_LENGTH] = xor(state.latest_randao_mixes[state.slot % LATEST_RANDAO_MIXES_LENGTH], hash(block.randao_reveal))`.
### Eth1 data ### Eth1 data

View File

@ -158,12 +158,12 @@ _Note_: To calculate `state_root`, the validator should first run the state tran
##### Randao reveal ##### Randao reveal
Set `block.randao_reveal = reveal_signature` where `reveal_signature` is defined as: Set `block.randao_reveal = epoch_signature` where `epoch_signature` is defined as:
```python ```python
reveal_signature = bls_sign( epoch_signature = bls_sign(
privkey=validator.privkey, # privkey store locally, not in state privkey=validator.privkey, # privkey store locally, not in state
message=int_to_bytes32(validator.proposer_slots + 1), message=int_to_bytes32(block.slot // EPOCH_LENGTH),
domain=get_domain( domain=get_domain(
fork_data, # `fork_data` is the fork_data at the slot `block.slot` fork_data, # `fork_data` is the fork_data at the slot `block.slot`
block.slot, block.slot,