@@ -8,33 +8,11 @@ defmodule LambdaEthereumConsensus.Application do
8
8
9
9
@ impl true
10
10
def start ( _type , _args ) do
11
- checkpoint_sync =
12
- Application . fetch_env! ( :lambda_ethereum_consensus , LambdaEthereumConsensus.ForkChoice ) [
13
- :checkpoint_sync
14
- ]
15
-
16
- jwt_secret =
17
- Application . fetch_env! (
18
- :lambda_ethereum_consensus ,
19
- LambdaEthereumConsensus.Execution.EngineApi
20
- ) [ :jwt_secret ]
11
+ mode = get_operation_mode ( )
21
12
22
- if is_nil ( jwt_secret ) do
23
- Logger . warning (
24
- "[EngineAPI] A JWT secret is needed for communication with the execution engine. " <>
25
- "Please specify the file to load it from with the --execution-jwt flag."
26
- )
27
- end
13
+ check_jwt_secret ( mode )
28
14
29
- children = [
30
- LambdaEthereumConsensus.Telemetry ,
31
- LambdaEthereumConsensus.Store.Db ,
32
- LambdaEthereumConsensus.Store.Blocks ,
33
- LambdaEthereumConsensus.Store.BlockStates ,
34
- { LambdaEthereumConsensus.Beacon.BeaconNode , [ checkpoint_sync ] } ,
35
- LambdaEthereumConsensus.P2P.Metadata ,
36
- BeaconApi.Endpoint
37
- ]
15
+ children = get_children ( mode )
38
16
39
17
# See https://hexdocs.pm/elixir/Supervisor.html
40
18
# for other strategies and supported options
@@ -50,4 +28,50 @@ defmodule LambdaEthereumConsensus.Application do
50
28
BeaconApi.Endpoint . config_change ( changed , removed )
51
29
:ok
52
30
end
31
+
32
+ defp get_children ( :db ) do
33
+ [
34
+ LambdaEthereumConsensus.Telemetry ,
35
+ LambdaEthereumConsensus.Store.Db ,
36
+ LambdaEthereumConsensus.Store.Blocks ,
37
+ LambdaEthereumConsensus.Store.BlockStates
38
+ ]
39
+ end
40
+
41
+ defp get_children ( :full ) do
42
+ get_children ( :db ) ++
43
+ [
44
+ { LambdaEthereumConsensus.Beacon.BeaconNode , [ checkpoint_sync_url ( ) ] } ,
45
+ LambdaEthereumConsensus.P2P.Metadata ,
46
+ BeaconApi.Endpoint
47
+ ]
48
+ end
49
+
50
+ def checkpoint_sync_url do
51
+ Application . fetch_env! ( :lambda_ethereum_consensus , LambdaEthereumConsensus.ForkChoice )
52
+ |> Keyword . fetch! ( :checkpoint_sync )
53
+ end
54
+
55
+ defp get_operation_mode do
56
+ Application . fetch_env! ( :lambda_ethereum_consensus , LambdaEthereumConsensus )
57
+ |> Keyword . fetch! ( :mode )
58
+ end
59
+
60
+ defp check_jwt_secret ( :db ) , do: nil
61
+
62
+ defp check_jwt_secret ( :full ) do
63
+ jwt_secret =
64
+ Application . fetch_env! (
65
+ :lambda_ethereum_consensus ,
66
+ LambdaEthereumConsensus.Execution.EngineApi
67
+ )
68
+ |> Keyword . fetch! ( :jwt_secret )
69
+
70
+ if is_nil ( jwt_secret ) do
71
+ Logger . warning (
72
+ "[EngineAPI] A JWT secret is needed for communication with the execution engine. " <>
73
+ "Please specify the file to load it from with the --execution-jwt flag."
74
+ )
75
+ end
76
+ end
53
77
end
0 commit comments