From e7ff5ad5e7abc949f0854ef6f975dfb68128b64d Mon Sep 17 00:00:00 2001 From: Vitalik Buterin Date: Wed, 3 Oct 2018 10:29:00 -0400 Subject: [PATCH] Added RANDAO support (without multi-skip mechanism) --- specs/casper_sharding_v2.1.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/specs/casper_sharding_v2.1.md b/specs/casper_sharding_v2.1.md index c0d2c231c..ec590d361 100644 --- a/specs/casper_sharding_v2.1.md +++ b/specs/casper_sharding_v2.1.md @@ -90,7 +90,7 @@ fields = { # Hash of the crystallized state 'crystallized_state_root': 'hash32', # Logouts, penalties, etc etc - 'specials': [SpecialObject] + 'specials': [SpecialObject], } ``` @@ -139,7 +139,9 @@ fields = { # Special objects that have not yet been processed 'pending_specials': [SpecialObject], # Most recent 2 * CYCLE_LENGTH block hashes, older to newer - 'recent_block_hashes': ['hash32'] + 'recent_block_hashes': ['hash32'], + # RANDAO state + 'randao_mix': 'hash32' } ``` @@ -459,7 +461,9 @@ For each one of these attestations: Extend the list of `AttestationRecord` objects in the `active_state` with those included in the block, ordering the new additions in the same order as they came in the block. Similarly extend the list of `SpecialObject` objects in the `active_state` with those included in the block. -Verify that the `parent.slot % len(get_shards_and_committees_for_slot(crystallized_state, parent.slot)[0].committee)`'th attester in `get_shards_and_committees_for_slot(crystallized_state, parent.slot)[0]` is part of the first (ie. item 0 in the array) `AttestationRecord` object; this attester can be considered to be the proposer of the parent block. In general, when a block is produced, it is broadcasted at the network layer along with the attestation from its proposer. +Let `proposer_index` be the validator index of the `parent.slot % len(get_shards_and_committees_for_slot(crystallized_state, parent.slot)[0].committee)`'th attester in `get_shards_and_committees_for_slot(crystallized_state, parent.slot)[0]`. Verify that an attestation from this validator is part of the first (ie. item 0 in the array) `AttestationRecord` object; this attester can be considered to be the proposer of the parent block. In general, when a block is produced, it is broadcasted at the network layer along with the attestation from its proposer. + +Additionally, verify that `hash(block.randao_reveal) == crystallized_state.validators[proposer_index].randao_commitment`, and set `active_state.randao_mix = xor(active_state.randao_mix, block.randao_reveal)` and `crystallized_state.validators[proposer_index].randao_commitment = block.randao_reveal`. ### State recalculations (every `CYCLE_LENGTH` slots) @@ -579,7 +583,7 @@ Finally: * Set `last_dynasty_start = crystallized_state.last_state_recalculation` * Set `crystallized_state.current_dynasty += 1` * Let `next_start_shard = (shard_and_committee_for_slots[-1][-1].shard_id + 1) % SHARD_COUNT` -* Set `shard_and_committee_for_slots[CYCLE_LENGTH:] = get_new_shuffling(block.ancestor_hashes[0], validators, next_start_shard)` +* Set `shard_and_committee_for_slots[CYCLE_LENGTH:] = get_new_shuffling(active_state.randao_mix, validators, next_start_shard)` -------