From bf78a711524e964dc616c10cbd3ca561d050b830 Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Thu, 7 Nov 2019 11:51:53 -0700 Subject: [PATCH] pr feedback --- specs/core/0_fork-choice.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/specs/core/0_fork-choice.md b/specs/core/0_fork-choice.md index ac1de0b3d..468d1e3d6 100644 --- a/specs/core/0_fork-choice.md +++ b/specs/core/0_fork-choice.md @@ -158,6 +158,13 @@ def get_head(store: Store) -> Hash: ```python def should_update_justified_checkpoint(store: Store, new_justified_checkpoint: Checkpoint) -> bool: + """ + To address the bouncing attack, only update conflicting justified + checkpoints in the fork choice if in the early slots of the epoch. + Otherwise, delay incorporation of new justified checkpoint until next epoch boundary. + + See https://ethresear.ch/t/prevention-of-bouncing-attack-on-ffg/6114 for more detailed analysis and discussion. + """ if compute_slots_since_epoch_start(get_current_slot(store)) < SAFE_SLOTS_TO_UPDATE_JUSTIFIED: return True @@ -186,9 +193,9 @@ def on_tick(store: Store, time: uint64) -> None: current_slot = get_current_slot(store) # Not a new epoch, return - if not (current_slot > previous_slot and current_slot % SLOTS_PER_EPOCH == 0): + if not (current_slot > previous_slot and compute_slots_since_epoch_start(current_slot) == 0): return - # Update store.justified_checkpoint if a better checkpoint is know + # Update store.justified_checkpoint if a better checkpoint is known if store.best_justified_checkpoint.epoch > store.justified_checkpoint.epoch: store.justified_checkpoint = store.best_justified_checkpoint ```