From f328f77e653ad95b552e59517fa7990106044677 Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Tue, 11 May 2021 10:58:45 -0700 Subject: [PATCH 1/2] clarify fork upgrade conditions --- specs/altair/fork.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/specs/altair/fork.md b/specs/altair/fork.md index be562b82b..d789e7a8e 100644 --- a/specs/altair/fork.md +++ b/specs/altair/fork.md @@ -38,7 +38,11 @@ Note that for the pure Altair networks, we don't apply `upgrade_to_altair` since ### Upgrading the state -After `process_slots` of Phase 0 finishes, if `state.slot % SLOTS_PER_EPOCH == 0` and `compute_epoch_at_slot(state.slot) == ALTAIR_FORK_EPOCH`, an irregular state change is made to upgrade to Altair. +If `state.slot % SLOTS_PER_EPOCH == 0` and `compute_epoch_at_slot(state.slot) == ALTAIR_FORK_EPOCH`, an irregular state change is made to upgrade to Altair. + +The upgrade occurs after the inner loop of `process_slots` that sets `state.slot` equal to `ALTAIR_FORK_EPOCH * SLOTS_PER_EPOCH` finishes. +Care must be taken when transitioning through the fork boundary as implementations will need a modified state transition function that deviates from the Phase 0 spec. +In particular, the `state_transition` function defined in the Phase 0 spec will not expose the correct time to execute the upgrade in the presence of skipped slots at the fork boundary. ```python def upgrade_to_altair(pre: phase0.BeaconState) -> BeaconState: From 43ba615b7579ff1ac2e616ed1dd12cccec14118f Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Tue, 11 May 2021 14:13:22 -0600 Subject: [PATCH 2/2] Apply suggestions from code review --- specs/altair/fork.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specs/altair/fork.md b/specs/altair/fork.md index d789e7a8e..ac2258def 100644 --- a/specs/altair/fork.md +++ b/specs/altair/fork.md @@ -40,9 +40,9 @@ Note that for the pure Altair networks, we don't apply `upgrade_to_altair` since If `state.slot % SLOTS_PER_EPOCH == 0` and `compute_epoch_at_slot(state.slot) == ALTAIR_FORK_EPOCH`, an irregular state change is made to upgrade to Altair. -The upgrade occurs after the inner loop of `process_slots` that sets `state.slot` equal to `ALTAIR_FORK_EPOCH * SLOTS_PER_EPOCH` finishes. +The upgrade occurs after the completion of the inner loop of `process_slots` that sets `state.slot` equal to `ALTAIR_FORK_EPOCH * SLOTS_PER_EPOCH`. Care must be taken when transitioning through the fork boundary as implementations will need a modified state transition function that deviates from the Phase 0 spec. -In particular, the `state_transition` function defined in the Phase 0 spec will not expose the correct time to execute the upgrade in the presence of skipped slots at the fork boundary. +In particular, the outer `state_transition` function defined in the Phase 0 spec will not expose the precise fork slot to execute the upgrade in the presence of skipped slots at the fork boundary. Instead the logic must be within `process_slots`. ```python def upgrade_to_altair(pre: phase0.BeaconState) -> BeaconState: