Skip to content

Commit c85151e

Browse files
committed
Moved notify_tick to libp2p to be sure the issues is just with new blocks and not with libp2p calling the ValidatorManager
1 parent b6c2bed commit c85151e

File tree

5 files changed

+22
-11
lines changed

5 files changed

+22
-11
lines changed

lib/lambda_ethereum_consensus/beacon/clock.ex

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,12 @@ defmodule LambdaEthereumConsensus.Beacon.Clock do
4242
new_state = %{state | time: time}
4343

4444
if time >= state.genesis_time do
45-
Libp2pPort.on_tick(time)
45+
4646
# TODO: reduce time between ticks to account for gnosis' 5s slot time.
4747
old_logical_time = compute_logical_time(state)
4848
new_logical_time = compute_logical_time(new_state)
4949

50-
if old_logical_time != new_logical_time do
51-
log_new_slot(new_logical_time)
52-
ValidatorManager.notify_tick(new_logical_time)
53-
end
50+
Libp2pPort.on_tick({time, new_logical_time, new_logical_time != old_logical_time})
5451
end
5552

5653
{:noreply, new_state}

lib/lambda_ethereum_consensus/fork_choice/fork_choice.ex

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defmodule LambdaEthereumConsensus.ForkChoice do
55

66
require Logger
77

8-
alias LambdaEthereumConsensus.Beacon.Clock
8+
# alias LambdaEthereumConsensus.Beacon.Clock
99
alias LambdaEthereumConsensus.Execution.ExecutionChain
1010
alias LambdaEthereumConsensus.ForkChoice.Handlers
1111
alias LambdaEthereumConsensus.ForkChoice.Head
@@ -232,7 +232,7 @@ defmodule LambdaEthereumConsensus.ForkChoice do
232232
%{slot: slot, body: body} = head_block
233233

234234
OperationsCollector.notify_new_block(head_block)
235-
ValidatorManager.notify_new_block(slot, head_root)
235+
236236
ExecutionChain.notify_new_block(slot, body.eth1_data, body.execution_payload)
237237

238238
update_fork_choice_data(
@@ -242,7 +242,9 @@ defmodule LambdaEthereumConsensus.ForkChoice do
242242
store.finalized_checkpoint
243243
)
244244

245-
Logger.debug("[Fork choice] Updated fork choice cache", slot: slot)
245+
ValidatorManager.notify_new_block(slot, head_root)
246+
247+
Logger.info("[Fork choice] Updated fork choice cache", slot: slot)
246248

247249
:ok
248250
end

lib/lambda_ethereum_consensus/validator/validator_manager.ex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,15 @@ defmodule LambdaEthereumConsensus.Validator.ValidatorManager do
4949

5050
@spec notify_new_block(Types.slot(), Types.root()) :: :ok
5151
def notify_new_block(slot, head_root) do
52-
notify_validators({:new_block, slot, head_root})
52+
# Making this alone a cast solves the issue
53+
GenServer.cast(__MODULE__, {:notify_all, {:new_block, slot, head_root}})
54+
# notify_validators({:new_block, slot, head_root})
5355
end
5456

5557
@spec notify_tick(Clock.logical_time()) :: :ok
5658
def notify_tick(logical_time) do
59+
# Making this a cast alone doesn't solve the issue
60+
# GenServer.cast(__MODULE__, {:notify_all, {:on_tick, logical_time}})
5761
notify_validators({:on_tick, logical_time})
5862
end
5963

lib/libp2p_port.ex

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ defmodule LambdaEthereumConsensus.Libp2pPort do
99

1010
use GenServer
1111

12+
alias LambdaEthereumConsensus.Validator.ValidatorManager
1213
alias LambdaEthereumConsensus.Beacon.PendingBlocks
1314
alias LambdaEthereumConsensus.Beacon.SyncBlocks
1415
alias LambdaEthereumConsensus.ForkChoice
@@ -392,10 +393,17 @@ defmodule LambdaEthereumConsensus.Libp2pPort do
392393
end
393394

394395
@impl GenServer
395-
def handle_cast({:on_tick, time}, state) do
396+
def handle_cast({:on_tick, {time, slot_data, changed_slot_data}}, state) do
396397
# TODO: we probably want to remove this from here, but we keep it here to have this serialized
397398
# with respect to the other fork choice store modifications.
398399
ForkChoice.on_tick(time)
400+
401+
# For testing that calling it from the libp2p works, and its just a matter of the notify new block,
402+
# not the clock being the one who calls the notify tick.
403+
if changed_slot_data do
404+
ValidatorManager.notify_tick(slot_data)
405+
end
406+
399407
{:noreply, state}
400408
end
401409

network_params.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ participants:
88
cl_image: lambda_ethereum_consensus:latest
99
use_separate_vc: false
1010
count: 1
11-
validator_count: 10
11+
validator_count: 20
1212
cl_max_mem: 4096

0 commit comments

Comments
 (0)