From 03e956f9c95fc59094a9d199e90e5796dabab650 Mon Sep 17 00:00:00 2001 From: protolambda Date: Sat, 16 Nov 2019 12:33:24 +0100 Subject: [PATCH] validator init adjustments --- specs/core/1_custody-game.md | 10 +++++----- specs/core/1_phase1_fork.md | 11 ++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/specs/core/1_custody-game.md b/specs/core/1_custody-game.md index 0e804f628..e4e752763 100644 --- a/specs/core/1_custody-game.md +++ b/specs/core/1_custody-game.md @@ -320,11 +320,11 @@ def get_randao_epoch_for_custody_period(period: uint64, validator_index: Validat ### `get_custody_period_for_validator` ```python -def get_custody_period_for_validator(state: BeaconState, validator_index: ValidatorIndex, epoch: Epoch=None) -> int: +def get_custody_period_for_validator(validator_index: ValidatorIndex, epoch: Epoch=None) -> int: ''' Return the reveal period for a given validator. ''' - epoch = get_current_epoch(state) if epoch is None else epoch + epoch = if epoch is None else epoch return (epoch + validator_index % EPOCHS_PER_CUSTODY_PERIOD) // EPOCHS_PER_CUSTODY_PERIOD ``` @@ -367,7 +367,7 @@ def process_custody_key_reveal(state: BeaconState, reveal: CustodyKeyReveal) -> revealer = state.validators[reveal.revealer_index] epoch_to_sign = get_randao_epoch_for_custody_period(revealer.next_custody_secret_to_reveal, reveal.revealer_index) - assert revealer.next_custody_secret_to_reveal < get_custody_period_for_validator(state, reveal.revealer_index) + assert revealer.next_custody_secret_to_reveal < get_custody_period_for_validator(reveal.revealer_index, get_current_epoch(state)) # Revealed validator is active or exited, but not withdrawn assert is_slashable_validator(revealer, get_current_epoch(state)) @@ -566,7 +566,7 @@ def process_bit_challenge(state: BeaconState, challenge: CustodyBitChallenge) -> # Verify attestation is eligible for challenging responder = state.validators[challenge.responder_index] assert get_current_epoch(state) <= get_randao_epoch_for_custody_period( - get_custody_period_for_validator(state, challenge.responder_index, epoch), + get_custody_period_for_validator(challenge.responder_index, epoch), challenge.responder_index ) + 2 * EPOCHS_PER_CUSTODY_PERIOD + responder.max_reveal_lateness @@ -578,7 +578,7 @@ def process_bit_challenge(state: BeaconState, challenge: CustodyBitChallenge) -> assert record.challenger_index != challenge.challenger_index # Verify the responder custody key epoch_to_sign = get_randao_epoch_for_custody_period( - get_custody_period_for_validator(state, challenge.responder_index, epoch), + get_custody_period_for_validator(challenge.responder_index, epoch), challenge.responder_index, ) domain = get_domain(state, DOMAIN_RANDAO, epoch_to_sign) diff --git a/specs/core/1_phase1_fork.md b/specs/core/1_phase1_fork.md index f5ab658f5..e257d6eb1 100644 --- a/specs/core/1_phase1_fork.md +++ b/specs/core/1_phase1_fork.md @@ -35,13 +35,14 @@ After `process_slots` of Phase 0 finishes, but before the first Phase 1 block is ```python def upgrade_to_phase1(pre: phase0.BeaconState) -> BeaconState: + epoch = get_current_epoch(pre) post = BeaconState( genesis_time=pre.genesis_time, slot=pre.slot, fork=Fork( previous_version=pre.current_version, current_version=PHASE_1_FORK_VERSION, - epoch=get_current_epoch(pre), + epoch=epoch, ), # History latest_block_header=pre.latest_block_header, @@ -58,14 +59,14 @@ def upgrade_to_phase1(pre: phase0.BeaconState) -> BeaconState: pubkey=phase0_validator.pubkey, withdrawal_credentials=phase0_validator.withdrawal_credentials, effective_balance=phase0_validator.effective_balance, - slashed=phase0.slashed, + slashed=phase0_validator.slashed, activation_eligibility_epoch=phase0_validator.activation_eligibility_epoch, activation_epoch=phase0_validator.activation_eligibility_epoch, exit_epoch=phase0_validator.exit_epoch, withdrawable_epoch=phase0_validator.withdrawable_epoch, - next_custody_secret_to_reveal=, - max_reveal_lateness=, - ) for phase0_validator in pre.validators + next_custody_secret_to_reveal=get_custody_period_for_validator(validator_index, epoch), + max_reveal_lateness=0, # TODO custody refactor. Outdated? + ) for validator_index, phase0_validator in enumerate(pre.validators) ), balances=pre.balances, # Randomness