Skip to content

Commit 55c5d90

Browse files
committed
Simplify a diff
1 parent 46efa3a commit 55c5d90

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

lib/lambda_ethereum_consensus/fork_choice/fork_choice.ex

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ defmodule LambdaEthereumConsensus.ForkChoice do
259259
%{slot: slot, body: body} = head_block
260260

261261
OperationsCollector.notify_new_block(head_block)
262+
Libp2pPort.notify_new_block(slot, head_root)
262263
ExecutionChain.notify_new_block(slot, body.eth1_data, body.execution_payload)
263264

264265
update_fork_choice_data(
@@ -268,8 +269,6 @@ defmodule LambdaEthereumConsensus.ForkChoice do
268269
store.finalized_checkpoint
269270
)
270271

271-
Libp2pPort.notify_new_block({slot, head_root})
272-
273272
Logger.debug("[Fork choice] Updated fork choice cache", slot: slot)
274273

275274
:ok

lib/libp2p_port.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ defmodule LambdaEthereumConsensus.Libp2pPort do
114114
GenServer.cast(__MODULE__, {:on_tick, time})
115115
end
116116

117-
@spec notify_new_block({Types.slot(), Types.root()}) :: :ok
118-
def notify_new_block(data) do
117+
@spec notify_new_block(Types.slot(), Types.root()) :: :ok
118+
def notify_new_block(slot, head_root) do
119119
# TODO: This is quick workarround to notify the libp2p port about new blocks from within
120120
# the ForkChoice.recompute_head/1 without moving the validators to the store this
121121
# allows to deferr that move until we simplify the state and remove duplicates.
122-
send(self(), {:new_block, data})
122+
send(self(), {:new_block, slot, head_root})
123123
end
124124

125125
@doc """
@@ -499,8 +499,8 @@ defmodule LambdaEthereumConsensus.Libp2pPort do
499499
end
500500

501501
@impl GenServer
502-
def handle_info({:new_block, data}, %{validators: validators} = state) do
503-
updated_validators = notify_validators(validators, {:new_block, data})
502+
def handle_info({:new_block, slot, head_root}, %{validators: validators} = state) do
503+
updated_validators = notify_validators(validators, {:new_block, slot, head_root})
504504

505505
{:noreply, %{state | validators: updated_validators}}
506506
end
@@ -755,7 +755,7 @@ defmodule LambdaEthereumConsensus.Libp2pPort do
755755
defp notify_validator({pubkey, validator}, {:on_tick, slot_data}),
756756
do: {pubkey, Validator.handle_tick(slot_data, validator)}
757757

758-
defp notify_validator({pubkey, validator}, {:new_block, {slot, head_root}}),
758+
defp notify_validator({pubkey, validator}, {:new_block, slot, head_root}),
759759
do: {pubkey, Validator.handle_new_block(slot, head_root, validator)}
760760

761761
@spec compute_slot(Types.uint64(), Types.uint64()) :: slot_data()

0 commit comments

Comments
 (0)