Skip to content

Commit 0c85ce1

Browse files
committed
Merge branch 'main' into validator-state-management-refactor
2 parents 616f892 + f38288c commit 0c85ce1

35 files changed

+2268
-162
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,4 @@ callgrind.out.*
6565

6666
# beacon node oapi json file
6767
beacon-node-oapi.json
68+
flamegraphs/

README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ Some public endpoints can be found in [eth-clients.github.io/checkpoint-sync-end
9090
> The data retrieved from the URL is stored in the DB once the node is initiated (i.e. the iex prompt shows).
9191
> Once this happens, following runs of `make iex` will start the node using that data.
9292
93-
### Beacon API
93+
### APIs
94+
#### Beacon API
9495

9596
You can start the application with the Beacon API on the default port `4000` running:
9697
```shell
@@ -100,7 +101,27 @@ make start
100101
You can also specify a port with the "--beacon-api-port" flag:
101102

102103
```shell
103-
iex -S mix run -- --beacon-api --beacon-api-port <your_port_here>
104+
iex -S mix run -- --beacon-api-port <your_port_here>
105+
```
106+
> [!WARNING]
107+
> In case checkpoint-sync is needed, following the instructions above will end immediately with an error (see [Checkpoint Sync](#checkpoint-sync)).
108+
>
109+
110+
#### Key-Manager API
111+
112+
Implemented following the [Ethereum specification](https://ethereum.github.io/keymanager-APIs/#/).
113+
114+
You can start the application with the key manager API on the default port `5000` running:
115+
116+
```shell
117+
iex -S mix run -- --validator-api
118+
```
119+
120+
121+
You can also specify a port with the "--validator-api-port" flag:
122+
123+
```shell
124+
iex -S mix run -- --validator-api-port <your_port_here>
104125
```
105126
> [!WARNING]
106127
> In case checkpoint-sync is needed, following the instructions above will end immediately with an error (see [Checkpoint Sync](#checkpoint-sync)).
@@ -250,6 +271,7 @@ participants:
250271
use_separate_vc: false
251272
count: 1
252273
cl_max_mem: 4096
274+
keymanager_enabled: true
253275
```
254276
255277
### Kurtosis Execution and Make tasks

bench/block_processing.exs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
11
alias LambdaEthereumConsensus.ForkChoice
22
alias LambdaEthereumConsensus.ForkChoice.Handlers
33
alias LambdaEthereumConsensus.StateTransition.Cache
4-
alias LambdaEthereumConsensus.Store
5-
alias LambdaEthereumConsensus.Store.BlockBySlot
64
alias LambdaEthereumConsensus.Store.BlockDb
75
alias LambdaEthereumConsensus.Store.StateDb
8-
alias Types.BeaconState
96
alias Types.BlockInfo
10-
alias Types.SignedBeaconBlock
117
alias Types.StateInfo
8+
alias Utils.Date
129

1310
Logger.configure(level: :warning)
1411
Cache.initialize_cache()
1512

1613
# NOTE: this slot must be at the beginning of an epoch (i.e. a multiple of 32)
17-
slot = 9_591_424
14+
slot = 9_649_056
1815

19-
IO.puts("fetching blocks...")
16+
IO.puts("Fetching state and blocks...")
2017
{:ok, %StateInfo{beacon_state: state}} = StateDb.get_state_by_slot(slot)
2118
{:ok, %BlockInfo{signed_block: block}} = BlockDb.get_block_info_by_slot(slot)
22-
{:ok, %BlockInfo{signed_block: new_block} = block_info} = BlockDb.get_block_info_by_slot(slot + 1)
19+
{:ok, %BlockInfo{} = block_info} = BlockDb.get_block_info_by_slot(slot + 1)
20+
{:ok, %BlockInfo{} = block_info_2} = BlockDb.get_block_info_by_slot(slot + 2)
2321

24-
IO.puts("initializing store...")
22+
IO.puts("Initializing store...")
2523
{:ok, store} = Types.Store.get_forkchoice_store(state, block)
2624
store = Handlers.on_tick(store, store.time + 30)
2725

28-
{:ok, root} = BlockBySlot.get(slot)
26+
IO.puts("Processing the block 1...")
2927

30-
IO.puts("about to process block: #{slot + 1}, with root: #{Base.encode16(root)}...")
31-
IO.puts("#{length(attestations)} attestations ; #{length(attester_slashings)} attester slashings")
32-
IO.puts("")
28+
{:ok, new_store} = ForkChoice.process_block(block_info, store)
29+
IO.puts("Processing the block 2...")
3330

3431
if System.get_env("FLAMA") do
35-
Flama.run({ForkChoice, :process_block, [block_info, store]})
32+
filename = "flamegraphs/stacks.#{Date.now_str()}.out"
33+
Flama.run({ForkChoice, :process_block, [block_info_2, new_store]}, output_file: filename)
34+
IO.puts("Flamegraph saved to #{filename}")
3635
else
3736
Benchee.run(
3837
%{
3938
"block (full cache)" => fn ->
40-
ForkChoice.process_block(block_info, store)
39+
ForkChoice.process_block(block_info_2, new_store)
4140
end
4241
},
4342
time: 30
@@ -46,7 +45,7 @@ else
4645
Benchee.run(
4746
%{
4847
"block (empty cache)" => fn _ ->
49-
ForkChoice.process_block(block_info, store)
48+
ForkChoice.process_block(block_info_2, new_store)
5049
end
5150
},
5251
time: 30,

config/runtime.exs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ switches = [
1818
log_file: :string,
1919
beacon_api: :boolean,
2020
beacon_api_port: :integer,
21+
validator_api: :boolean,
22+
validator_api_port: :integer,
2123
listen_address: [:string, :keep],
2224
discovery_port: :integer,
2325
boot_nodes: :string,
@@ -47,6 +49,8 @@ metrics_port = Keyword.get(args, :metrics_port, nil)
4749
enable_metrics = Keyword.get(args, :metrics, not is_nil(metrics_port))
4850
beacon_api_port = Keyword.get(args, :beacon_api_port, nil)
4951
enable_beacon_api = Keyword.get(args, :beacon_api, not is_nil(beacon_api_port))
52+
validator_api_port = Keyword.get(args, :validator_api_port, nil)
53+
enable_validator_api = Keyword.get(args, :validator_api, not is_nil(validator_api_port))
5054
listen_addresses = Keyword.get_values(args, :listen_address)
5155
discovery_port = Keyword.get(args, :discovery_port, 9000)
5256
cli_bootnodes = Keyword.get(args, :boot_nodes, "")
@@ -153,6 +157,16 @@ config :lambda_ethereum_consensus, BeaconApi.Endpoint,
153157
layout: false
154158
]
155159

160+
# KeyStore API
161+
config :lambda_ethereum_consensus, KeyStoreApi.Endpoint,
162+
server: enable_validator_api,
163+
http: [port: validator_api_port || 5000],
164+
url: [host: "localhost"],
165+
render_errors: [
166+
formats: [json: KeyStoreApi.ErrorJSON],
167+
layout: false
168+
]
169+
156170
# Validator setup
157171

158172
if (keystore_dir != nil and keystore_pass_dir == nil) or

0 commit comments

Comments
 (0)