From 6cfd38e8007e7dadb68c6c2ebcd8b2630964bc26 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Thu, 11 Nov 2021 11:47:01 +1100 Subject: [PATCH 1/2] Patch for genesis blocks --- specs/merge/validator.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/specs/merge/validator.md b/specs/merge/validator.md index d36397353..6ca7c9c12 100644 --- a/specs/merge/validator.md +++ b/specs/merge/validator.md @@ -44,8 +44,10 @@ Please see related Beacon Chain doc before continuing and use them as a referenc def get_pow_block_at_terminal_total_difficulty(pow_chain: Dict[Hash32, PowBlock]) -> Optional[PowBlock]: # `pow_chain` abstractly represents all blocks in the PoW chain for block in pow_chain: - parent = pow_chain[block.parent_hash] block_reached_ttd = block.total_difficulty >= TERMINAL_TOTAL_DIFFICULTY + if block_reached_ttd and block.parent_hash == Hash32(): + return block + parent = pow_chain[block.parent_hash] parent_reached_ttd = parent.total_difficulty >= TERMINAL_TOTAL_DIFFICULTY if block_reached_ttd and not parent_reached_ttd: return block From 61207c5b6155243c3dec6529ecc214d5e23cfb58 Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Thu, 11 Nov 2021 07:29:38 -0700 Subject: [PATCH 2/2] Apply suggestions from code review --- specs/merge/validator.md | 1 + 1 file changed, 1 insertion(+) diff --git a/specs/merge/validator.md b/specs/merge/validator.md index 6ca7c9c12..22fc3eb13 100644 --- a/specs/merge/validator.md +++ b/specs/merge/validator.md @@ -45,6 +45,7 @@ def get_pow_block_at_terminal_total_difficulty(pow_chain: Dict[Hash32, PowBlock] # `pow_chain` abstractly represents all blocks in the PoW chain for block in pow_chain: block_reached_ttd = block.total_difficulty >= TERMINAL_TOTAL_DIFFICULTY + # If genesis block, no parent exists so reaching TTD alone qualifies as valid terminal block if block_reached_ttd and block.parent_hash == Hash32(): return block parent = pow_chain[block.parent_hash]