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

Add support for HIP15 #662

Merged
merged 4 commits into from
Nov 17, 2020
Merged

Add support for HIP15 #662

merged 4 commits into from
Nov 17, 2020

Conversation

vihu
Copy link
Member

@vihu vihu commented Oct 22, 2020

Refer: https://github.com/helium/HIP/blob/master/0015-beaconing-rewards.md

  • Introduce two new chain variables poc_reward_decay_rate (r) and witness_redundancy (n)
  • The reward formula for transmitter (from hip15) is essentially the poc_challengee_reward unit and the formula for receiver is the poc_witness_reward unit
  • There are no defaults here for either of the new chain variables, so we must set both in order for the change to trigger

TODO:

  • Fix eunits
  • Add more tests

@codecov
Copy link

codecov bot commented Oct 22, 2020

Codecov Report

Merging #662 (5f87842) into master (4fcd506) will increase coverage by 0.28%.
The diff coverage is 82.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #662      +/-   ##
==========================================
+ Coverage   68.40%   68.68%   +0.28%     
==========================================
  Files          94       94              
  Lines       12311    12362      +51     
==========================================
+ Hits         8421     8491      +70     
+ Misses       3890     3871      -19     
Impacted Files Coverage Δ
...transactions/v1/blockchain_txn_poc_receipts_v1.erl 29.62% <0.00%> (+0.17%) ⬆️
src/transactions/v1/blockchain_txn_rewards_v1.erl 92.06% <83.33%> (+3.69%) ⬆️
src/transactions/v1/blockchain_txn_vars_v1.erl 62.03% <100.00%> (+0.17%) ⬆️
src/handlers/blockchain_gossip_handler.erl 68.18% <0.00%> (-9.10%) ⬇️
src/blockchain_worker.erl 38.99% <0.00%> (-0.27%) ⬇️
src/blockchain.erl 63.42% <0.00%> (+0.09%) ⬆️
src/blockchain_utils.erl 75.44% <0.00%> (+1.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4fcd506...5f87842. Read the comment docs.

@Vagabond
Copy link
Contributor

Vagabond commented Nov 4, 2020

Here are the scaling factors from HIP 15 in erlang code:

(N - (1 - math:pow(R, W-N)))/W.

1 + (1 - math:pow(R, W-N))

@abhay
Copy link
Contributor

abhay commented Nov 4, 2020

relevant GH Issue #673

@vihu vihu force-pushed the rg/hip0015 branch 3 times, most recently from ea3a6d9 to 8da40c3 Compare November 7, 2020 20:07
@vihu vihu marked this pull request as ready for review November 10, 2020 00:50
ct:pal("Txn: ~p", [Txn]),

%% Construct a block for the poc receipt txn WITHOUT validation
{ok, Block2} = test_utils:create_block(ConsensusMembers, [Txn], #{}, false),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we disable validation so we don't need to deal with pathing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, pretty much. Also didn't really see any need to do a poc request then receipt cycle since we only care about the rewards here. lmk if that's acceptable...

Copy link
Contributor

@Vagabond Vagabond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial impression of this looks very good. I will try to go through it more deeply soon.

@@ -604,11 +677,21 @@ poc_witnesses_rewards(Transactions,
[] ->
Acc1;
ValidWitnesses ->
ToAdd = case {WitnessRedundancy, DecayRate} of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we inline some of the documentation here? it's clear enough what it's doing, but I'm at sea wrt why

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, added 5f87842

[[blockchain_utils:addr2name(blockchain_poc_witness_v1:gateway(W)) || W <- ValidWitnesses]]),
ValidWitnesses
catch What:Why:ST ->
lager:error("failed to calculate poc_challengees_rewards, error ~p:~p:~p", [What, Why, ST]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to do this differently depending on how many blocks back you have? in which case we might want to determine if we need more snap history to avoid drift

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this isn't new code, I simply moved this piece out in order to meck it in the test. I will however run a resync with revalidation with this just to be certain.

@evanmcc evanmcc merged commit 79a749e into master Nov 17, 2020
@evanmcc evanmcc deleted the rg/hip0015 branch November 17, 2020 22:43
@wavyog
Copy link

wavyog commented Oct 14, 2021

I know it's going to work

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants