From e67ca3d3098c476139ee4149442f0dc0e6761af9 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Mon, 12 Dec 2022 13:09:18 +0100 Subject: [PATCH] Compute epoch only once for better readability --- specs/capella/light-client/full-node.md | 4 +++- specs/capella/light-client/sync-protocol.md | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/specs/capella/light-client/full-node.md b/specs/capella/light-client/full-node.md index 104853f8e..6a2104a38 100644 --- a/specs/capella/light-client/full-node.md +++ b/specs/capella/light-client/full-node.md @@ -34,7 +34,9 @@ def compute_merkle_proof_for_block_body(body: BeaconBlockBody, ```python def block_to_light_client_header(block: SignedBeaconBlock) -> LightClientHeader: - if compute_epoch_at_slot(block.message.slot) >= CAPELLA_FORK_EPOCH: + epoch = compute_epoch_at_slot(block.message.slot) + + if epoch >= CAPELLA_FORK_EPOCH: payload = block.message.body.execution_payload execution_header = ExecutionPayloadHeader( parent_hash=payload.parent_hash, diff --git a/specs/capella/light-client/sync-protocol.md b/specs/capella/light-client/sync-protocol.md index 515b53582..060dea1b9 100644 --- a/specs/capella/light-client/sync-protocol.md +++ b/specs/capella/light-client/sync-protocol.md @@ -152,7 +152,9 @@ def get_lc_beacon_root(header: LightClientHeader) -> Root: ```python def get_lc_execution_root(header: LightClientHeader) -> Root: - if compute_epoch_at_slot(get_lc_beacon_slot(header)) >= CAPELLA_FORK_EPOCH: + epoch = compute_epoch_at_slot(get_lc_beacon_slot(header)) + + if epoch >= CAPELLA_FORK_EPOCH: return hash_tree_root(header.execution) return Root() @@ -162,7 +164,9 @@ def get_lc_execution_root(header: LightClientHeader) -> Root: ```python def is_valid_light_client_header(header: LightClientHeader) -> bool: - if compute_epoch_at_slot(get_lc_beacon_slot(header)) < CAPELLA_FORK_EPOCH: + epoch = compute_epoch_at_slot(get_lc_beacon_slot(header)) + + if epoch < CAPELLA_FORK_EPOCH: if header.execution != ExecutionPayloadHeader(): return False