Skip to content

Commit 605bfe0

Browse files
authored
fix: bug when proposing on slot 1 (#1106)
1 parent 2789b16 commit 605bfe0

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/lambda_ethereum_consensus/validator/block_builder.ex

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,17 @@ defmodule LambdaEthereumConsensus.Validator.BlockBuilder do
101101
# PERF: the state can be cached for the later build_block call
102102
head_block = Blocks.get_block!(head_root)
103103
pre_state = BlockStates.get_state!(head_root)
104-
head_payload_hash = head_block.body.execution_payload.block_hash
105104

106-
with {:ok, mid_state} <- StateTransition.process_slots(pre_state, proposed_slot),
105+
head_payload_data =
106+
if proposed_slot == 1 do
107+
# If the head is the genesis block, fetches the payload_block_data.
108+
ExecutionClient.get_block_metadata(0)
109+
else
110+
{:ok, head_block.body.execution_payload}
111+
end
112+
113+
with {:ok, %{block_hash: head_payload_hash}} <- head_payload_data,
114+
{:ok, mid_state} <- StateTransition.process_slots(pre_state, proposed_slot),
107115
{:ok, finalized_payload_hash} <- get_finalized_block_hash(mid_state) do
108116
forkchoice_state = %{
109117
finalized_block_hash: finalized_payload_hash,

0 commit comments

Comments
 (0)