From f28857181f51cb39529821c80fe18e41350274be Mon Sep 17 00:00:00 2001 From: Martin Paulucci Date: Thu, 4 Jan 2024 16:50:53 +0100 Subject: [PATCH] refactor: add beacon node supervisor. (#566) Co-authored-by: Martin Paulucci --- lib/lambda_ethereum_consensus/application.ex | 6 +----- .../{fork_choice/supervisor.ex => beacon/beacon_node.ex} | 9 ++++++--- .../{fork_choice => beacon}/checkpoint_sync.ex | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) rename lib/lambda_ethereum_consensus/{fork_choice/supervisor.ex => beacon/beacon_node.ex} (87%) rename lib/lambda_ethereum_consensus/{fork_choice => beacon}/checkpoint_sync.ex (96%) diff --git a/lib/lambda_ethereum_consensus/application.ex b/lib/lambda_ethereum_consensus/application.ex index 335e5a96a..e8503dee3 100644 --- a/lib/lambda_ethereum_consensus/application.ex +++ b/lib/lambda_ethereum_consensus/application.ex @@ -29,11 +29,7 @@ defmodule LambdaEthereumConsensus.Application do {LambdaEthereumConsensus.Libp2pPort, libp2p_opts}, {LambdaEthereumConsensus.Store.Db, []}, {LambdaEthereumConsensus.P2P.Peerbook, []}, - {LambdaEthereumConsensus.ForkChoice, [checkpoint_sync]}, - {LambdaEthereumConsensus.P2P.IncomingRequests, []}, - {LambdaEthereumConsensus.Beacon.PendingBlocks, []}, - {LambdaEthereumConsensus.Beacon.SyncBlocks, []}, - {LambdaEthereumConsensus.P2P.GossipSub, []}, + {LambdaEthereumConsensus.Beacon.BeaconNode, [checkpoint_sync]}, {BeaconApi.Endpoint, []} ] diff --git a/lib/lambda_ethereum_consensus/fork_choice/supervisor.ex b/lib/lambda_ethereum_consensus/beacon/beacon_node.ex similarity index 87% rename from lib/lambda_ethereum_consensus/fork_choice/supervisor.ex rename to lib/lambda_ethereum_consensus/beacon/beacon_node.ex index 5c1fc6581..18b1bc28d 100644 --- a/lib/lambda_ethereum_consensus/fork_choice/supervisor.ex +++ b/lib/lambda_ethereum_consensus/beacon/beacon_node.ex @@ -1,10 +1,10 @@ -defmodule LambdaEthereumConsensus.ForkChoice do +defmodule LambdaEthereumConsensus.Beacon.BeaconNode do @moduledoc false use Supervisor require Logger - alias LambdaEthereumConsensus.ForkChoice.CheckpointSync + alias LambdaEthereumConsensus.Beacon.CheckpointSync alias LambdaEthereumConsensus.StateTransition.Cache alias LambdaEthereumConsensus.Store.{BlockStore, StateStore} @@ -60,7 +60,10 @@ defmodule LambdaEthereumConsensus.ForkChoice do children = [ {LambdaEthereumConsensus.ForkChoice.Store, {anchor_state, anchor_block}}, - {LambdaEthereumConsensus.ForkChoice.Tree, []} + {LambdaEthereumConsensus.Beacon.PendingBlocks, []}, + {LambdaEthereumConsensus.Beacon.SyncBlocks, []}, + {LambdaEthereumConsensus.P2P.IncomingRequests, []}, + {LambdaEthereumConsensus.P2P.GossipSub, []} ] Supervisor.init(children, strategy: :one_for_all) diff --git a/lib/lambda_ethereum_consensus/fork_choice/checkpoint_sync.ex b/lib/lambda_ethereum_consensus/beacon/checkpoint_sync.ex similarity index 96% rename from lib/lambda_ethereum_consensus/fork_choice/checkpoint_sync.ex rename to lib/lambda_ethereum_consensus/beacon/checkpoint_sync.ex index b59123717..d0c2f52a6 100644 --- a/lib/lambda_ethereum_consensus/fork_choice/checkpoint_sync.ex +++ b/lib/lambda_ethereum_consensus/beacon/checkpoint_sync.ex @@ -1,4 +1,4 @@ -defmodule LambdaEthereumConsensus.ForkChoice.CheckpointSync do +defmodule LambdaEthereumConsensus.Beacon.CheckpointSync do @moduledoc """ Functions related to checkpoint-sync. """