Skip to content

Commit e3d47ab

Browse files
authored
Merge branch 'main' into initial-assertoor-implementation
2 parents 147200e + 988b261 commit e3d47ab

File tree

5 files changed

+43
-20
lines changed

5 files changed

+43
-20
lines changed

Makefile

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -164,39 +164,43 @@ test-iex:
164164

165165
##################
166166
# NODE RUNNERS
167-
DYSCOVERY_PORT ?= 30303
167+
DISCOVERY_PORT ?= 9009
168+
METRICS_PORT ?= 9568
168169

169-
#▶️ checkpoint-sync: @ Run an interactive terminal using checkpoint sync.
170-
checkpoint-sync: compile-all
171-
iex -S mix run -- --checkpoint-sync-url https://mainnet-checkpoint-sync.stakely.io/ --metrics --discovery-port $(DYSCOVERY_PORT)
170+
#▶️ mainnet: @ Run an interactive terminal using checkpoint sync for mainnet.
171+
mainnet: compile-all
172+
iex -S mix run -- --checkpoint-sync-url https://mainnet-checkpoint-sync.stakely.io/ --metrics --metrics-port $(METRICS_PORT) --discovery-port $(DISCOVERY_PORT)
172173

173-
#▶️ checkpoint-sync.logfile: @ Run an interactive terminal using checkpoint sync with a log file.
174-
checkpoint-sync.logfile: compile-all
175-
iex -S mix run -- --checkpoint-sync-url https://mainnet-checkpoint-sync.stakely.io/ --metrics --log-file ./logs/mainnet.log --discovery-port $(DYSCOVERY_PORT)
174+
#▶️ mainnet.logfile: @ Run an interactive terminal using checkpoint sync for mainnet with a log file.
175+
mainnet.logfile: compile-all
176+
iex -S mix run -- --checkpoint-sync-url https://mainnet-checkpoint-sync.stakely.io/ --metrics --metrics-port $(METRICS_PORT) --log-file ./logs/mainnet.log --discovery-port $(DISCOVERY_PORT)
176177

177178
#▶️ sepolia: @ Run an interactive terminal using sepolia network
178179
sepolia: compile-all
179-
iex -S mix run -- --checkpoint-sync-url https://sepolia.beaconstate.info --network sepolia --metrics --discovery-port $(DYSCOVERY_PORT)
180+
iex -S mix run -- --checkpoint-sync-url https://sepolia.beaconstate.info --network sepolia --metrics --metrics-port $(METRICS_PORT) --discovery-port $(DISCOVERY_PORT)
180181

181182
#▶️ sepolia.logfile: @ Run an interactive terminal using sepolia network with a log file
182183
sepolia.logfile: compile-all
183-
iex -S mix run -- --checkpoint-sync-url https://sepolia.beaconstate.info --network sepolia --metrics --log-file ./logs/sepolia.log --discovery-port $(DYSCOVERY_PORT)
184+
iex -S mix run -- --checkpoint-sync-url https://sepolia.beaconstate.info --network sepolia --metrics --metrics-port $(METRICS_PORT) --log-file ./logs/sepolia.log --discovery-port $(DISCOVERY_PORT)
184185

185186
#▶️ holesky: @ Run an interactive terminal using holesky network
186187
holesky: compile-all
187-
iex -S mix run -- --checkpoint-sync-url https://checkpoint-sync.holesky.ethpandaops.io --network holesky --discovery-port $(DYSCOVERY_PORT)
188+
iex -S mix run -- --checkpoint-sync-url https://checkpoint-sync.holesky.ethpandaops.io --network holesky --metrics --metrics-port $(METRICS_PORT) --discovery-port $(DISCOVERY_PORT)
188189

189190
#▶️ holesky.logfile: @ Run an interactive terminal using holesky network with a log file
190191
holesky.logfile: compile-all
191-
iex -S mix run -- --checkpoint-sync-url https://checkpoint-sync.holesky.ethpandaops.io --network holesky --log-file ./logs/holesky.log --discovery-port $(DYSCOVERY_PORT)
192+
iex -S mix run -- --checkpoint-sync-url https://checkpoint-sync.holesky.ethpandaops.io --network holesky --log-file ./logs/holesky.log --metrics --metrics-port $(METRICS_PORT) --discovery-port $(DISCOVERY_PORT)
192193

193194
#▶️ gnosis: @ Run an interactive terminal using gnosis network
194195
gnosis: compile-all
195-
iex -S mix run -- --checkpoint-sync-url https://checkpoint.gnosischain.com --network gnosis --discovery-port $(DYSCOVERY_PORT)
196+
iex -S mix run -- --checkpoint-sync-url https://checkpoint.gnosischain.com --network gnosis --metrics --metrics-port $(METRICS_PORT) --discovery-port $(DISCOVERY_PORT)
196197

197198
#▶️ gnosis.logfile: @ Run an interactive terminal using gnosis network with a log file
198199
gnosis.logfile: compile-all
199-
iex -S mix run -- --checkpoint-sync-url https://checkpoint.gnosischain.com --network gnosis --log-file ./logs/gnosis.log --discovery-port $(DYSCOVERY_PORT)
200+
iex -S mix run -- --checkpoint-sync-url https://checkpoint.gnosischain.com --network gnosis --metrics --metrics-port $(METRICS_PORT) --log-file ./logs/gnosis.log --discovery-port $(DISCOVERY_PORT)
201+
202+
#▶️ checkpoint-sync: @ Run an interactive terminal using checkpoint sync for mainnet.
203+
checkpoint-sync: mainnet
200204

201205
#🔴 test: @ Run tests
202206
test: compile-all

config/runtime.exs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,15 @@ if dsn do
259259

260260
config :sentry, dsn: dsn, release: String.trim(git_sha)
261261
end
262+
263+
# Peerbook penalization
264+
265+
penalizing_score =
266+
case network do
267+
"sepolia" -> 20
268+
"mainnet" -> 50
269+
_ -> 30
270+
end
271+
272+
config :lambda_ethereum_consensus, LambdaEthereumConsensus.P2P.Peerbook,
273+
penalizing_score: penalizing_score

lib/lambda_ethereum_consensus/beacon/checkpoint_sync.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ defmodule LambdaEthereumConsensus.Beacon.CheckpointSync do
1919
def get_finalized_block_and_state(url, genesis_validators_root) do
2020
tasks = [Task.async(__MODULE__, :get_state, [url]), Task.async(__MODULE__, :get_block, [url])]
2121

22-
case Task.await_many(tasks, 60_000) do
22+
case Task.await_many(tasks, 90_000) do
2323
[{:ok, state}, {:ok, block}] ->
2424
if state.genesis_validators_root == genesis_validators_root do
2525
check_match(url, state, block)
@@ -92,8 +92,8 @@ defmodule LambdaEthereumConsensus.Beacon.CheckpointSync do
9292
defp get_json_from_url(base_url, path) do
9393
full_url = concat_url(base_url, path)
9494

95-
with {:ok, response} <- get(full_url) do
96-
{:ok, response.body |> Map.fetch!("data") |> parse_json()}
95+
with {:ok, %{body: %{"data" => data}}} <- get(full_url) do
96+
{:ok, parse_json(data)}
9797
end
9898
end
9999

lib/lambda_ethereum_consensus/p2p/peerbook.ex

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,13 @@ defmodule LambdaEthereumConsensus.P2P.Peerbook do
6363
Logger.debug("[Peerbook] Penalizing peer: #{inspect(Utils.format_shorten_binary(peer_id))}")
6464

6565
peer_score = fetch_peerbook!() |> Map.get(peer_id)
66+
penalizing_score = penalazing_score()
6667

6768
case peer_score do
6869
nil ->
6970
:ok
7071

71-
score when score - @penalizing_score <= 0 ->
72+
score when score - penalizing_score <= 0 ->
7273
Logger.debug("[Peerbook] Removing peer: #{inspect(Utils.format_shorten_binary(peer_id))}")
7374

7475
fetch_peerbook!()
@@ -77,7 +78,7 @@ defmodule LambdaEthereumConsensus.P2P.Peerbook do
7778

7879
score ->
7980
fetch_peerbook!()
80-
|> Map.put(peer_id, score - @penalizing_score)
81+
|> Map.put(peer_id, score - penalizing_score)
8182
|> store_peerbook()
8283
end
8384
end
@@ -142,4 +143,10 @@ defmodule LambdaEthereumConsensus.P2P.Peerbook do
142143
{:ok, peerbook} = fetch_peerbook()
143144
peerbook
144145
end
146+
147+
defp penalazing_score() do
148+
:lambda_ethereum_consensus
149+
|> Application.get_env(__MODULE__)
150+
|> Keyword.get(:penalizing_score, @penalizing_score)
151+
end
145152
end

mix.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%{
22
"accept": {:hex, :accept, "0.3.5", "b33b127abca7cc948bbe6caa4c263369abf1347cfa9d8e699c6d214660f10cd1", [:rebar3], [], "hexpm", "11b18c220bcc2eab63b5470c038ef10eb6783bcb1fcdb11aa4137defa5ac1bb8"},
3-
"aja": {:hex, :aja, "0.7.0", "2ba5d752675bd77f8e20bcf8d6cee354913244c371ebecef70fcd18a1be1df45", [:mix], [{:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "85f966db2b703ca9ec4580c244699fa4915d97f946803ff2130ed74eb3721326"},
3+
"aja": {:hex, :aja, "0.7.1", "13afc7b9cf16ff0dc1e71fd1681ec50f60265ff34f07dd9bd53c1e7027d4cf53", [:mix], [{:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "2a50a94b47109e620803c097b670a703c8321ca095372282990619742104d5e9"},
44
"benchee": {:hex, :benchee, "1.3.1", "c786e6a76321121a44229dde3988fc772bca73ea75170a73fd5f4ddf1af95ccf", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}, {:statistex, "~> 1.0", [hex: :statistex, repo: "hexpm", optional: false]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "76224c58ea1d0391c8309a8ecbfe27d71062878f59bd41a390266bf4ac1cc56d"},
55
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
66
"castore": {:hex, :castore, "1.0.8", "dedcf20ea746694647f883590b82d9e96014057aff1d44d03ec90f36a5c0dc6e", [:mix], [], "hexpm", "0b2b66d2ee742cb1d9cb8c8be3b43c3a70ee8651f37b75a8b982e036752983f1"},
@@ -66,7 +66,7 @@
6666
"rustler": {:hex, :rustler, "0.34.0", "e9a73ee419fc296a10e49b415a2eb87a88c9217aa0275ec9f383d37eed290c1c", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:req, "~> 0.5", [hex: :req, repo: "hexpm", optional: false]}, {:toml, "~> 0.6", [hex: :toml, repo: "hexpm", optional: false]}], "hexpm", "1d0c7449482b459513003230c0e2422b0252245776fe6fd6e41cb2b11bd8e628"},
6767
"scrypt_elixir": {:hex, :scrypt_elixir_copy, "0.1.1", "2b23573e8d9e6c93c8116cd17f9b453b6ebf0725b5317ecaeacaf73353a4dbd3", [:make, :mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "1eb5768b6b6c657770cbc00a9724f47bad4e9d664a2da3916030d591223561e7"},
6868
"sentry": {:hex, :sentry, "10.7.1", "33392222d80ccff99c503f972998d2858b4c1e5aca2219a34269b68dacba8e7d", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: true]}, {:nimble_options, "~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_ownership, "~> 0.3.0 or ~> 1.0", [hex: :nimble_ownership, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.6", [hex: :phoenix, repo: "hexpm", optional: true]}, {:phoenix_live_view, "~> 0.20", [hex: :phoenix_live_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.6", [hex: :plug, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "56291312397bf2b6afab6cf4f7aa1f27413b0eb2ceeb63b8aab2d7658aaea882"},
69-
"snappyer": {:hex, :snappyer, "1.2.9", "9cc58470798648ce34c662ca0aa6daae31367667714c9a543384430a3586e5d3", [:rebar3], [], "hexpm", "18d00ca218ae613416e6eecafe1078db86342a66f86277bd45c95f05bf1c8b29"},
69+
"snappyer": {:hex, :snappyer, "1.2.10", "023e9ae00e969b0997208b5de7d3b12bb46ec6bc5411e8dc53e7b3f435b8f0fd", [:rebar3], [], "hexpm", "f55bd9ed147e7163cb3acd1e431a7ff2c9e31ceacbb8308786094fb64551c284"},
7070
"sourceror": {:hex, :sourceror, "1.5.0", "3e65d5fbb1a8e2864ad6411262c8018fee73474f5789dda12285c82999253d5d", [:mix], [], "hexpm", "4a32b5d189d8453f73278c15712f8731b89e9211e50726b798214b303b51bfc7"},
7171
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"},
7272
"statistex": {:hex, :statistex, "1.0.0", "f3dc93f3c0c6c92e5f291704cf62b99b553253d7969e9a5fa713e5481cd858a5", [:mix], [], "hexpm", "ff9d8bee7035028ab4742ff52fc80a2aa35cece833cf5319009b52f1b5a86c27"},

0 commit comments

Comments
 (0)