This repository was archived by the owner on Mar 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 83
Add support for hip17 #677
Merged
Merged
Changes from 14 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
19a7424
Add chain var proposal for hip17
vihu 6b0335d
Add h3dex
c38ed19
Several improvements overall
Vagabond 9fd9ebc
Refactor hex API and add more tests
vihu 85123a0
Fixes to hex API and related chain vars
52cb761
Use challengee scale for witness rewards
vihu af7c0c9
Add filtering for interactive gateways
9ac1634
Optimize scaling by using density at outermost hex
vihu 46d7b90
Memoize density calculations
797e5cd
Add more cross checking for rewards
vihu 0c87807
More cross verification
vihu 046e9cc
Add a marker to BC_UPGRADE_NAMES
6ec1270
add v5 snapshots with h3dex
evanmcc 02ab6bc
Merge pull request #693 from helium/pevm/snap-h3dex
evanmcc 21c6088
Enhance tests for hip17 rewards
vihu ca48d76
Merge pull request #694 from helium/rg/hip0017-reward-test-rework
vihu db4ef8c
fix dialyzer
evanmcc 3f5d9c8
Review comment
vihu 6e53fd9
Dont do unnecessary calc on old reward version
vihu 9032342
Review comment, cleanup
vihu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| -module(h3dex_eqc). | ||
|
|
||
| -include_lib("eqc/include/eqc.hrl"). | ||
| -include_lib("eunit/include/eunit.hrl"). | ||
|
|
||
| -define(INDICES, lists:flatten([ h3:children(I, 5) || I <- h3:get_res0_indexes()])). | ||
|
|
||
| -export([prop_h3dex_check/0]). | ||
|
|
||
| prop_h3dex_check() -> | ||
| ?FORALL({Hex1, Hex2, Resolution}, ?SUCHTHAT({X1, X2, _}, {gen_h3(), gen_h3(), choose(6, 6)}, X1 /= 0 andalso X2 /= 0 andalso X1 /= X2), | ||
| begin | ||
| Children1 = h3:children(Hex1, Resolution) -- [0], | ||
| Children2 = h3:children(Hex2, Resolution) -- [0], | ||
|
|
||
| End = h3_to_key(Hex1), | ||
| Start = find_lower_bound_hex(Hex1), | ||
| ?WHENFAIL(begin | ||
| io:format("Hex 1: ~p (~w -> ~w), Hex 2: ~p (~w -> ~w), Resolution ~p~n", [Hex1, find_lower_bound_hex(Hex1), h3_to_key(Hex1), Hex2, find_lower_bound_hex(Hex2), h3_to_key(Hex2), Resolution]) | ||
| end, | ||
| noshrink(conjunction( | ||
| [{all_children_in_range, eqc:equals([], lists:filter(fun(X) -> X < Start orelse X > End end, lists:sort(lists:map(fun h3_to_key/1, Children1)))) }, | ||
| {all_non_children_out_of_range, eqc:equals([], lists:filter(fun(E) -> X = h3_to_key(E), X > Start andalso X =< End end, Children2)) }, | ||
| {unparse_works, eqc:equals(Hex1, key_to_h3(h3_to_key(Hex1)))} | ||
| ] | ||
| ) | ||
| ) | ||
| ) | ||
| end). | ||
|
|
||
| gen_h3() -> | ||
| elements(?INDICES). | ||
|
|
||
| h3_to_key(H3) -> | ||
| %% both reserved fields must be 0 and Mode must be 1 for this to be a h3 cell | ||
| <<0:1/integer-unsigned-big, 1:4/integer-unsigned-big, 0:3/integer-unsigned-big, Resolution:4/integer-unsigned-big, BaseCell:7/integer-unsigned-big, Digits:45/integer-unsigned-big>> = <<H3:64/integer-unsigned-big>>, | ||
| %% store the resolution inverted (15 - Resolution) so it sorts later | ||
| <<BaseCell:7/integer-unsigned-big, Digits:45/integer-unsigned-big, (15 - Resolution):4/integer-unsigned-big>>. | ||
|
|
||
| key_to_h3(Key) -> | ||
| <<BaseCell:7/integer-unsigned-big, Digits:45/integer-unsigned-big, InverseResolution:4/integer-unsigned-big>> = Key, | ||
| <<H3:64/integer-unsigned-big>> = <<0:1, 1:4/integer-unsigned-big, 0:3, (15 - InverseResolution):4/integer-unsigned-big, BaseCell:7/integer-unsigned-big, Digits:45/integer-unsigned-big>>, | ||
| H3. | ||
|
|
||
| find_lower_bound_hex(Hex) -> | ||
| %% both reserved fields must be 0 and Mode must be 1 for this to be a h3 cell | ||
| <<0:1, 1:4/integer-unsigned-big, 0:3, Resolution:4/integer-unsigned-big, BaseCell:7/integer-unsigned-big, Digits/bitstring>> = <<Hex:64/integer-unsigned-big>>, | ||
| ActualDigitCount = Resolution * 3, | ||
| %% pull out the actual digits used and dump the rest | ||
| <<ActualDigits:ActualDigitCount/integer-unsigned-big, _/bitstring>> = Digits, | ||
| Padding = 45 - ActualDigitCount, | ||
| %% store the resolution inverted (15 - 15) = 0 so it sorts earlier | ||
| %% pad the actual digits used with 0s on the end | ||
| <<BaseCell:7/integer-unsigned-big, ActualDigits:ActualDigitCount/integer-unsigned-big, 0:Padding, 0:4/integer-unsigned-big>>. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.