Skip to content

Commit ea34fb5

Browse files
dependabot[bot]avilagaston9
authored andcommitted
# This is a combination of 19 commits.
# This is the 1st commit message: chore(deps): bump jason from 1.4.3 to 1.4.4 (#1243) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> # This is the commit message #2: feat: add keystore API phoenix endpoint # This is the commit message #3: feat: add GET /keystores endpoint # This is the commit message #4: fix: update port flag # This is the commit message #5: feat: add post method # This is the commit message #6: refactor: validator manager genserver removal (#1244) # This is the commit message #7: refactor: save keystores into validators # This is the commit message #8: feat: add delete endpoint # This is the commit message #9: fix: delete/add endpoints # This is the commit message #10: fix: try fix ci # This is the commit message #11: fix: test # This is the commit message #12: refactor: enhace readability # This is the commit message #13: perf: compute all committees at once at the beginning of an epoch. (#1245) # This is the commit message #14: fix: use other validators slot when adding a new validator # This is the commit message #15: refactor: restore pruning # This is the commit message #16: Update README.md # This is the commit message #17: refactor: nit changes # This is the commit message #18: chore(deps): bump open_api_spex from 3.20.0 to 3.20.1 (#1252) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> # This is the commit message #19: chore(deps-dev): bump recode from 0.7.2 to 0.7.3 (#1251) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 6c6f9fb commit ea34fb5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2493
-430
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/

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ lint:
266266
mix recode --no-autocorrect
267267
mix format --check-formatted
268268
mix credo --strict
269+
mix dialyzer --no-check
269270

270271
#✅ fmt: @ Format all code (Go, rust and elixir).
271272
fmt:

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: 15 additions & 1 deletion
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
@@ -171,7 +185,7 @@ if keystore_pass_dir != nil and not File.dir?(keystore_pass_dir) do
171185
System.halt(2)
172186
end
173187

174-
config :lambda_ethereum_consensus, LambdaEthereumConsensus.Validator.ValidatorManager,
188+
config :lambda_ethereum_consensus, LambdaEthereumConsensus.Validator.Setup,
175189
keystore_dir: keystore_dir,
176190
keystore_pass_dir: keystore_pass_dir
177191

0 commit comments

Comments
 (0)