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

Commit

Permalink
dynamically calculate HB key proposal count, rather than fixed count
Browse files Browse the repository at this point in the history
  • Loading branch information
andymck committed Mar 14, 2022
1 parent 5345b69 commit 9864b84
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion rebar.lock
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
3},
{<<"sibyl">>,
{git,"https://github.com/helium/sibyl.git",
{ref,"7cfcc1f73784578a4fe18ead1264652b87c4571d"}},
{ref,"f1a49b2908efa4aa217165e0aebd6d31ab7ad9b2"}},
0},
{<<"sidejob">>,{pkg,<<"sidejob">>,<<"2.1.0">>},2},
{<<"small_ints">>,{pkg,<<"small_ints">>,<<"0.1.0">>},4},
Expand Down
21 changes: 17 additions & 4 deletions src/miner_val_heartbeat.erl
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,25 @@ generate_poc_keys(Ledger) ->
case not lists:member(SelfPubKeyBin, IgnoreVals) of
true ->
%% generate a set of ephemeral keys for POC usage
%% count is based on the num of active validators and the
%% target challenge rate
%% we also have to consider that key proposals are
%% submitted by validators as part of their heartbeats
%% which are only submitted periodically
%% so we need to ensure we have sufficient count of
%% key proposals submitted per HB
%% to help with this we reduce the number of val count
%% by 20% so that we have surplus keys being submitted
EphemeralKeyCount =
case blockchain:config(?poc_validator_ephemeral_key_count, Ledger) of
{ok, N} -> N;
_ -> 1
case sibyl_mgr:validator_count() of
NumVals when NumVals > 0 ->
{ok, ChallengeRate} = blockchain_ledger_v1:config(?poc_challenge_rate, Ledger),
{ok, HBInterval} = blockchain_ledger_v1:config(?validator_liveness_interval, Ledger),
round((ChallengeRate / (NumVals * 0.8 )) * HBInterval);
_ ->
0
end,
lager:debug("heartbeat ephemeral key count ~p", [EphemeralKeyCount]),
lager:info("heartbeat ephemeral key count ~p", [EphemeralKeyCount]),
generate_ephemeral_keys(EphemeralKeyCount);
false ->
{[], []}
Expand Down

0 comments on commit 9864b84

Please sign in to comment.