Skip to content
This repository has been archived by the owner on Nov 5, 2023. It is now read-only.

Commit

Permalink
Bump core, blessed snapshot
Browse files Browse the repository at this point in the history
Also uses a validator predicate to prefer validators for block sync
  • Loading branch information
madninja committed Aug 30, 2021
1 parent d5d456f commit 67b7847
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
22 changes: 13 additions & 9 deletions config/sys.config
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,34 @@
{lager_file_backend, [{file, "error.log"}, {level, error}]}
]}
]},
{libp2p, [
{use_dns_for_seeds, true},
{seed_dns_cname, "seed.helium.io"},
{similarity_time_diff_mins, 30},
{random_peer_pred, fun bn_sup:random_val_predicate/1}
]},
{blockchain, [
{s3_base_url, "https://snapshots.helium.wtf/mainnet"},
%% set to number of cores -1
{validation_width, 3},
{block_sync_batch_size, 10},
{block_sync_batch_limit, 100},

{honor_quick_sync, true},
{quick_sync_mode, blessed_snapshot},
{blessed_snapshot_block_height, 959041},
{blessed_snapshot_block_height, 983521},
{blessed_snapshot_block_hash,
<<34, 206, 154, 249, 18, 46, 227, 229, 192, 100, 101, 102, 243, 107, 119, 207, 57, 219,
106, 30, 231, 29, 82, 221, 234, 116, 189, 64, 1, 70, 55, 143>>},
{port, 44158},
<<97, 208, 157, 201, 5, 40, 83, 139, 102, 73, 148, 246, 147, 130, 211, 30, 45, 143, 70,
112, 163, 70, 105, 238, 101, 244, 197, 179, 72, 14, 100, 15>>},
{listen_addresses, ["/ip4/0.0.0.0/tcp/44158"]},
{key, undefined},
{base_dir, "data"},
{autoload, false},
{num_consensus_members, 16},
{seed_nodes, "/ip4/35.166.211.46/tcp/2154,/ip4/44.236.95.167/tcp/2154"},
{seed_node_dns, "seed.helium.foundation"},
{seed_nodes,
"/ip4/18.217.27.26/tcp/2154,/ip4/35.161.222.43/tcp/443,/ip4/99.80.158.114/tcp/2154"},
{disable_gateway_cache, true},
{sync_timeout_mins, 5},
{max_inbound_connections, 32},
{snapshot_memory_limit, 300},
{snapshot_memory_limit, 2048},
{outbound_gossip_connections, 4},
{peerbook_update_interval, 180000},
{peerbook_allow_rfc1918, false},
Expand Down
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
{elli, "3.2.0"},
{jsonrpc2, {git, "https://github.com/zuiderkwast/jsonrpc2-erlang.git", {branch, "master"}}},
{clique, {git, "https://github.com/helium/clique.git", {branch, "develop"}}},
{blockchain, {git, "https://github.com/helium/blockchain-core.git", {tag, "2021.08.05.0"}}}
{blockchain, {git, "https://github.com/helium/blockchain-core.git", {tag, "2021.08.27.0"}}}
]}.

{xref_checks, [
Expand Down
4 changes: 2 additions & 2 deletions rebar.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{<<"base64url">>,{pkg,<<"base64url">>,<<"1.0.1">>},0},
{<<"blockchain">>,
{git,"https://github.com/helium/blockchain-core.git",
{ref,"6247badfcdc0409869a08af230fdba0d634a77f3"}},
{ref,"b4bacdaa62f12f4c109f8349d74efce4cc6c5a5d"}},
0},
{<<"clique">>,
{git,"https://github.com/helium/clique.git",
Expand Down Expand Up @@ -63,7 +63,7 @@
{<<"lager">>,{pkg,<<"lager">>,<<"3.9.2">>},0},
{<<"libp2p">>,
{git,"https://github.com/helium/erlang-libp2p.git",
{ref,"d706184618c4dd535f217fcfea40d7f110c5780a"}},
{ref,"d1963fb4bac6c872841261fb14fd6379172b4078"}},
1},
{<<"libp2p_crypto">>,{pkg,<<"libp2p_crypto">>,<<"1.4.0">>},2},
{<<"merkerl">>,
Expand Down
16 changes: 9 additions & 7 deletions src/bn_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
-behaviour(supervisor).

%% API
-export([start_link/0]).
-export([start_link/0, random_val_predicate/1]).
%% Supervisor callbacks
-export([init/1]).

Expand Down Expand Up @@ -49,23 +49,21 @@ init([]) ->
{PublicKey, ECDHFun, SigFun} =
case libp2p_crypto:load_keys(SwarmKey) of
{ok, #{secret := PrivKey0, public := PubKey}} ->
{PubKey, libp2p_crypto:mk_ecdh_fun(PrivKey0),
libp2p_crypto:mk_sig_fun(PrivKey0)};
{PubKey, libp2p_crypto:mk_ecdh_fun(PrivKey0), libp2p_crypto:mk_sig_fun(PrivKey0)};
{error, enoent} ->
KeyMap =
#{secret := PrivKey0, public := PubKey} = libp2p_crypto:generate_keys(
ecc_compact
),
ok = libp2p_crypto:save_keys(KeyMap, SwarmKey),
{PubKey, libp2p_crypto:mk_ecdh_fun(PrivKey0),
libp2p_crypto:mk_sig_fun(PrivKey0)}
{PubKey, libp2p_crypto:mk_ecdh_fun(PrivKey0), libp2p_crypto:mk_sig_fun(PrivKey0)}
end,
SeedNodeDNS = application:get_env(blockchain, seed_node_dns, []),
SeedAddresses = string:tokens(
lists:flatten([
string:prefix(X, "blockchain-seed-nodes=")
|| [X] <- inet_res:lookup(SeedNodeDNS, in, txt),
string:prefix(X, "blockchain-seed-nodes=") /= nomatch
|| [X] <- inet_res:lookup(SeedNodeDNS, in, txt),
string:prefix(X, "blockchain-seed-nodes=") /= nomatch
]),
","
),
Expand Down Expand Up @@ -97,3 +95,7 @@ init([]) ->
?WORKER(bn_wallets, [[{base_dir, BaseDir}]]),
?WORKER(elli, [[{callback, bn_jsonrpc_handler}, {port, NodePort}]])
]}}.

random_val_predicate(Peer) ->
not libp2p_peer:is_stale(Peer, timer:minutes(360)) andalso
maps:get(<<"release_version">>, libp2p_peer:signed_metadata(Peer), undefined) /= undefined.

0 comments on commit 67b7847

Please sign in to comment.