def upgrade_lc_header_to_gloas(pre: electra.LightClientHeader) -> LightClientHeader:
if pre == electra.LightClientHeader.empty():
return LightClientHeader.empty()
epoch = compute_epoch_at_slot(pre.beacon.slot)
if epoch >= DENEB_FORK_EPOCH:
BLOCK_HASH_GINDEX = get_generalized_index(deneb.ExecutionPayloadHeader, "block_hash")
return LightClientHeader(
beacon=pre.beacon,
execution_block_hash=pre.execution.block_hash,
execution_branch=ExecutionBranch(
data=normalize_merkle_branch(
list(compute_merkle_proof(pre.execution, BLOCK_HASH_GINDEX))
+ list(pre.execution_branch),
EXECUTION_BLOCK_HASH_GINDEX_GLOAS,
)
),
)
if epoch >= CAPELLA_FORK_EPOCH:
execution_header = capella.ExecutionPayloadHeader(
parent_hash=pre.execution.parent_hash,
fee_recipient=pre.execution.fee_recipient,
state_root=pre.execution.state_root,
receipts_root=pre.execution.receipts_root,
logs_bloom=pre.execution.logs_bloom,
prev_randao=pre.execution.prev_randao,
block_number=pre.execution.block_number,
gas_limit=pre.execution.gas_limit,
gas_used=pre.execution.gas_used,
timestamp=pre.execution.timestamp,
extra_data=pre.execution.extra_data,
base_fee_per_gas=pre.execution.base_fee_per_gas,
block_hash=pre.execution.block_hash,
transactions_root=pre.execution.transactions_root,
withdrawals_root=pre.execution.withdrawals_root,
)
BLOCK_HASH_GINDEX = get_generalized_index(capella.ExecutionPayloadHeader, "block_hash")
return LightClientHeader(
beacon=pre.beacon,
execution_block_hash=pre.execution.block_hash,
execution_branch=ExecutionBranch(
data=normalize_merkle_branch(
list(compute_merkle_proof(execution_header, BLOCK_HASH_GINDEX))
+ list(pre.execution_branch),
EXECUTION_BLOCK_HASH_GINDEX_GLOAS,
)
),
)
return LightClientHeader(
beacon=pre.beacon,
execution_block_hash=Hash32(),
execution_branch=ExecutionBranch(),
)