Browse Source

WIP hush_supply

pull/136/head
Duke Leto 4 years ago
parent
commit
1c4a2ee13c
  1. 40
      contrib/hush_supply

40
contrib/hush_supply

@ -5,42 +5,52 @@ use warnings;
use strict; use strict;
# Simulate the total supply on Hush v3 mainnet # Simulate the total supply on Hush v3 mainnet
# Todo: track FR
# Todo: verify FR off-by-one
my $supply = 0.0; my $supply = 0.0;
my $block = 0; my $block = 0; # Block 0 in Hush Smart chains is the BTC genesis block
my $satoshis = 100_000_000; my $puposhis = 100_000_000;
my $reward0 = int(12.5*$satoshis); my $reward0 = 1_250_000_000;
my $halvings = 0; my $halvings = 0;
my $initial = 6178674 * $satoshis; my $initial = 6178674 * $puposhis;
my $interval = 1_640_000; # 4 years of 75s blocks my $interval = 1_640_000; # 4 years of 75s blocks
my $height = shift || -1; my $stop = shift || -1;
my $totalfr = 0; # total paid out to FR address
my $reward = $reward0;
# Usage: ./hush_supply &> supply.csv # Usage: ./hush_supply &> supply.csv
# ./hush_supply HEIGHT &> supply.csv # stop at HEIGHT # ./hush_supply HEIGHT &> supply.csv # stop at HEIGHT
my $reward = $reward0; printf "# block, supply, reward, fr, totalfr, halvings\n";
# We know BR will go to zero between 7 and 8th halvings # We know BR will go to zero between 7 and 8th halvings
while ($halvings <= 10) { while ($halvings <= 10) {
$block++; $block++;
my $fr = 0;
# blocks 2-127 of Hush v3 had BR=0 # blocks 2-127 of Hush v3 had BR=0
if ($block == 1) { if ($block == 1) {
$reward = $initial; # airdropped funds from Hush v2 mainnet $reward = $initial; # airdropped funds from Hush v2 mainnet
} elsif ($block > 1 && $block < 128) { } elsif ($block > 1 && $block < 128) {
$reward = 0; # blocks 2-127 have BR=0 $reward = 0; # blocks 2-127 have BR=0
} else { } else {
$fr = 125_000_000;
if ($block < 340_000) { if ($block < 340_000) {
$reward = $reward0; $reward = $reward0;
} else { } else {
my $shifted = $block - 340_000;
# Past the first halving # Past the first halving
$block -= 340_000; $halvings = 1 + int ($shifted / $interval);
$halvings = 1 + ($block % $interval); if ($shifted % 840_000 == 0) {
$reward <<= $halvings; $reward >>= 2;
$fr >>= 2;
}
} }
} }
$supply += $reward; $supply += $reward;
# block, current supply, block reward amount, number of halvings $totalfr += $fr;
# all amounts are in satoshis
printf "%s,%s,%s,%s\n",$block, $supply, $reward, $halvings; # block, current supply, block reward amount, number of halvings, all amounts are in puposhis
#exit(0) if ($block > 200); printf "%d,%d,%d,%d,%d,%d\n", $block, $supply, $reward, $fr, $totalfr, $halvings;
exit(0) if $block == $height; exit(0) if $block == $stop;
} }

Loading…
Cancel
Save