Eth2.0-specs: Randao_update object for active state

Created on 9 Oct 2018  路  7Comments  路  Source: ethereum/eth2.0-specs

We are currently modifying crystallized_state during block processing at the last step:
crystallized_state.validators[proposer_index].randao_commitment = block.randao_reveal

The correct way is to maintain a RandaoUpdate object in active_state, and during state recalculations update each validator's randao_commitment

enhancement

Most helpful comment

Sorry accidentally fat fingered as a commit instead of a PR, but here's a simple solution: https://github.com/ethereum/eth2.0-specs/commit/fe74c7e299ff90d56f4099733754c0e94e645ccc

All 7 comments

Proposed implementation --

  • move randao_mix to CrystallizedState
  • store array of size CYCLE_LENGTH in active_state. These values are each initialized to 0x00 * 32 . Call it pending_randao_reveals
  • when processing a block, check the validity of the reveal.
  • during state recalc, for each slot in (last_state_recalc, last_state_recalc + CYCLE_LENGTH - 1)

    • if active_state.pending_randao_reveals[slot] != 0x00 *32



      • let proposer_index be the proposer index from the shuffling related to the slot


      • `crystallized_state.randao_mix = xor(crystallized_state.randao_mix, active_state.pending_randao_reveals[slot])


      • crystallized_state.validators[proposer_index].randao_commitment = active_state.pending_randao_reveals[slot]



  • after a state recalc, set active_state.pending_randao_reveals to be CYCLE_LENGTH 0x00 hashes
  • _after_ doing all state recalcs, set active_state.pending_randao_reveals[block.slot % CYCLE_LENGTH] = block.randao_reveal

Note that setting the pending_randao_reveals for the current block happens _after_ state recalcs. This is to handle the case when a block is at (or after) the slot that triggers a state recalc. If we want too keep the size of pending_randao_reveals fix, then we have to do this trick.

There is an alternative method that would do appends and truncates like recent_block_hashes where we fill in missing slots with 0x00 whenever slots are skipped. Need to consider which I prefer..

cc: @JustinDrake

Do we need randao_mix? or can we just use dynasty_seed?

Also during dynasty transition, we should do the following:
crystallized_state.dynasty_seed = crystallized_state.randao_mix
shard_and_committee_for_slots[CYCLE_LENGTH:] = get_new_shuffling(crystallized_state.randao_mix, validators, next_start_shard)

I'd say use the term randao_mix instead of dynasty_seed. https://github.com/ethereum/eth2.0-specs/pull/61 removes all references of the word "dynasty" entirely.

Sorry accidentally fat fingered as a commit instead of a PR, but here's a simple solution: https://github.com/ethereum/eth2.0-specs/commit/fe74c7e299ff90d56f4099733754c0e94e645ccc

Sgtm!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

econoar picture econoar  路  41Comments

JustinDrake picture JustinDrake  路  12Comments

JustinDrake picture JustinDrake  路  15Comments

Swader picture Swader  路  28Comments

paulhauner picture paulhauner  路  15Comments