Merge pull request #2719 from paulhauner/patch-33
Genesis execution block handling
This commit is contained in:
commit
fb34e162ef
|
@ -44,8 +44,11 @@ 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]:
|
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
|
# `pow_chain` abstractly represents all blocks in the PoW chain
|
||||||
for block in pow_chain:
|
for block in pow_chain:
|
||||||
parent = pow_chain[block.parent_hash]
|
|
||||||
block_reached_ttd = block.total_difficulty >= TERMINAL_TOTAL_DIFFICULTY
|
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]
|
||||||
parent_reached_ttd = parent.total_difficulty >= TERMINAL_TOTAL_DIFFICULTY
|
parent_reached_ttd = parent.total_difficulty >= TERMINAL_TOTAL_DIFFICULTY
|
||||||
if block_reached_ttd and not parent_reached_ttd:
|
if block_reached_ttd and not parent_reached_ttd:
|
||||||
return block
|
return block
|
||||||
|
|
Loading…
Reference in New Issue