Implement entire Hush block subsidy schedule
We now have our halving schedule implemented until the BR goes to zero. The data was calculated via two new scripts which are in ./contrib : $ ./contrib/hush_halvings 1,12500000000,340000 2,312500000,2020000 3,156250000,3700000 4,78125000,5380000 5,39062500,7060000 6,19531250,8740000 7,9765625,10420000 8,4882812,12100000 9,2441406,13780000 10,1220703,15460000 11,610351,17140000 12,305175,18820000 13,152587,20500000 14,76293,22180000 15,38146,23860000 16,19073,25540000 17,9536,27220000 18,4768,28900000 19,2384,30580000 20,1192,32260000 21,596,33940000 22,298,35620000 23,149,37300000 24,74,38980000 25,37,40660000 26,18,42340000 27,9,44020000 28,4,45700000 29,2,47380000 30,1,49060000 31,0,50740000 32,0,52420000 33,0,54100000 $ ./contrib/hush_block_subsidy_per_halving 0,1250000000,1125000000,125000000 1,625000000,562500000,62500000 2,312500000,281250000,31250000 3,156250000,140625000,15625000 4,78125000,70312500,7812500 5,39062500,35156250,3906250 6,19531250,17578125,1953125 7,9765625,8789062,976562 8,4882812,4394531,488281 9,2441406,2197265,244140 10,1220703,1098632,122070 11,610351,549316,61035 12,305175,274658,30517 13,152587,137329,15258 14,76293,68664,7629 15,38146,34332,3814 16,19073,17166,1907 17,9536,8583,953 18,4768,4291,476 19,2384,2145,238 20,1192,1072,119 21,596,536,59 22,298,268,29 23,149,134,14 24,74,67,7 25,37,33,3 26,18,16,1 27,9,8,0 28,4,4,0 29,2,2,0 30,1,1,0 31,0,0,0 These show that the block subsidy for miners goes to 0 at the 31st halving and that the Founders Reward AKA Dev Tax goes to 0 at the 27th halving. There is also some current KMD internals code that we inherited that prevents the FR from being less than 10000, so that code would currently set our FR to 0 at the 14th halving and lead less HUSH being mined than the planned 21M and even a bit less than the amount under 21M that normally happens, such as in BTC. We have some time to deal with the bug, since halving 14 is in about 52 years.
This commit is contained in:
17
contrib/hush_block_subsidy_per_halving
Executable file
17
contrib/hush_block_subsidy_per_halving
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/env perl
|
||||||
|
# Copyright 2019-2020 The Hush developers
|
||||||
|
# Released under the GPLv3
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
my $x = 12.5 * 100000000;
|
||||||
|
my $n = 0;
|
||||||
|
while ($n<=31) {
|
||||||
|
#printf "$n,%.16g,%.16g,%.16g\n", $x, $x*0.90, $x*0.1;
|
||||||
|
printf "$n,%d,%d,%d\n", $x, $x*0.90, $x*0.1;
|
||||||
|
$x = $x / 2;
|
||||||
|
$n++;
|
||||||
|
exit if ($x <= 0);
|
||||||
|
}
|
||||||
|
|
||||||
22
contrib/hush_halvings
Executable file
22
contrib/hush_halvings
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env perl
|
||||||
|
# Copyright 2019-2020 The Hush developers
|
||||||
|
# Released under the GPLv3
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
my $x = 340_000;
|
||||||
|
my $n = 0;
|
||||||
|
my $r = 12_500_000_000;
|
||||||
|
while ($n<=32) {
|
||||||
|
printf "%d,%d,%d\n", $n+1, $r, $x + 1680000*$n;
|
||||||
|
# blocktime halving at block 340000
|
||||||
|
if ($n==0) {
|
||||||
|
$r = 3.125 * 100_000_000;
|
||||||
|
} else {
|
||||||
|
$r /= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
$n++;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1241,7 +1241,8 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
|
|||||||
// You specify the BR, and the FR % gets added so 10% of 12.5 is 1.25
|
// You specify the BR, and the FR % gets added so 10% of 12.5 is 1.25
|
||||||
// but to tell the AC params, I need to say "11% of 11.25" is 1.25
|
// but to tell the AC params, I need to say "11% of 11.25" is 1.25
|
||||||
// 11% ie. 1/9th cannot be exactly represented and so the FR has tiny amounts of error unless done manually
|
// 11% ie. 1/9th cannot be exactly represented and so the FR has tiny amounts of error unless done manually
|
||||||
// Do not change this code unless you really know what you are doing.
|
// This must be kept in sync with hush_block_subsidy() in komoto_utils.h!
|
||||||
|
// Changing these functions are consensus changes!
|
||||||
// Here Be Dragons! -- Duke Leto
|
// Here Be Dragons! -- Duke Leto
|
||||||
uint64_t hush_commission(int height)
|
uint64_t hush_commission(int height)
|
||||||
{
|
{
|
||||||
@@ -1261,56 +1262,28 @@ uint64_t hush_commission(int height)
|
|||||||
INTERVAL = GetArg("-ac_halving2",1680000); // ~4 years worth of 75s blocks
|
INTERVAL = GetArg("-ac_halving2",1680000); // ~4 years worth of 75s blocks
|
||||||
fprintf(stderr,"%s: height=%d increasing interval to %d\n", __func__, height, INTERVAL);
|
fprintf(stderr,"%s: height=%d increasing interval to %d\n", __func__, height, INTERVAL);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
0,1250000000,1125000000,125000000
|
|
||||||
1,312500000,281250000,31250000
|
|
||||||
2,156250000,140625000,15625000
|
|
||||||
3,78125000,70312500,7812500
|
|
||||||
4,39062500,35156250,3906250
|
|
||||||
5,19531250,17578125,1953125
|
|
||||||
6,9765625,8789062,976562
|
|
||||||
7,4882812,4394531,488281
|
|
||||||
8,2441406,2197265,244140
|
|
||||||
9,1220703,1098632,122070
|
|
||||||
10,610351,549316,61035
|
|
||||||
11,305175,274658,30517
|
|
||||||
12,152587,137329,15258
|
|
||||||
13,76293,68664,7629
|
|
||||||
14,38146,34332,3814
|
|
||||||
15,19073,17166,1907
|
|
||||||
16,9536,8583,953
|
|
||||||
17,4768,4291,476
|
|
||||||
18,2384,2145,238
|
|
||||||
19,1192,1072,119
|
|
||||||
20,596,536,59
|
|
||||||
21,298,268,29
|
|
||||||
22,149,134,14
|
|
||||||
23,74,67,7
|
|
||||||
24,37,33,3
|
|
||||||
25,18,16,1
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
if (height < TRANSITION) {
|
if (height < TRANSITION) {
|
||||||
commission = 0;
|
commission = 0;
|
||||||
} else {
|
} else {
|
||||||
// Just like BTC, BRs in the far future will be slightly less than
|
// Just like BTC, BRs in the far future will be slightly less than
|
||||||
// they should be because exact values are not integers, causing
|
// they should be because exact values are not integers, causing
|
||||||
// slightly less coins to be actually mined
|
// slightly less coins to be actually mined and small deviations
|
||||||
|
// to the ideal FR/devtax
|
||||||
if (height < HALVING1) { // before 1st Halving @ Block 340000 (Nov 2020)
|
if (height < HALVING1) { // before 1st Halving @ Block 340000 (Nov 2020)
|
||||||
commission = starting_commission;
|
commission = starting_commission;
|
||||||
} else if (height < 2020000 ) {
|
} else if (height < 2020000 ) {
|
||||||
commission = 312500000;
|
commission = 31250000;
|
||||||
} else if (height < 3700000 ) {
|
} else if (height < 3700000 ) {
|
||||||
commission = 156250000;
|
commission = 15625000;
|
||||||
} else if (height < 5380000 ) {
|
} else if (height < 5380000 ) {
|
||||||
commission = 78125000;
|
commission = 7812500;
|
||||||
} else if (height < 7060000 ) {
|
} else if (height < 7060000 ) {
|
||||||
commission = 39062500;
|
commission = 3906250;
|
||||||
} else if (height < 8740000 ) {
|
} else if (height < 8740000 ) {
|
||||||
commission = 19531250;
|
commission = 1953125;
|
||||||
} else if (height < 10420000) {
|
} else if (height < 10420000) {
|
||||||
commission = 9765625;
|
commission = 976562; // 0.5 puposhi deviation, all further BRs have deviation from ideal
|
||||||
} else if (height < 12100000) {
|
} else if (height < 12100000) {
|
||||||
commission = 488281;
|
commission = 488281;
|
||||||
} else if (height < 15460000) {
|
} else if (height < 15460000) {
|
||||||
@@ -1350,25 +1323,24 @@ uint64_t hush_commission(int height)
|
|||||||
} else if (height < 44020000) {
|
} else if (height < 44020000) {
|
||||||
commission = 1;
|
commission = 1;
|
||||||
} else if (height < 45700000) {
|
} else if (height < 45700000) {
|
||||||
|
// FR goes to zero at Halving 26
|
||||||
commission = 0;
|
commission = 0;
|
||||||
} else if (height < 47380000) {
|
} else if (height < 47380000) {
|
||||||
|
// FR still zero at Halving 27
|
||||||
commission = 0;
|
commission = 0;
|
||||||
} else if (height < 49060000) {
|
} else if (height < 49060000) {
|
||||||
|
// FR still zero at Halving 28
|
||||||
commission = 0;
|
commission = 0;
|
||||||
} else if (height < 50740000) {
|
} else if (height < 50740000) {
|
||||||
|
// FR still zero at Halving 29
|
||||||
commission = 0;
|
commission = 0;
|
||||||
} else {
|
} else {
|
||||||
|
// enforce FR=0 for all other heights
|
||||||
|
// This over-rides the -ac_end param via HUSH3 cli args
|
||||||
commission = 0;
|
commission = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Explicitly set the last block reward
|
|
||||||
// BR_END is the block with first zero block reward, which overrides
|
|
||||||
// the -ac_end param on HUSH3
|
|
||||||
if(height >= BR_END) {
|
|
||||||
fprintf(stderr,"%s: HUSH block reward has gone to zero at height %d!!! It was a good run folks\n", __func__, height);
|
|
||||||
commission = 0;
|
|
||||||
}
|
|
||||||
if(fDebug)
|
if(fDebug)
|
||||||
fprintf(stderr,"%s: commission=%lu,interval=%d at height %d\n", __func__, commission, INTERVAL, height);
|
fprintf(stderr,"%s: commission=%lu,interval=%d at height %d\n", __func__, commission, INTERVAL, height);
|
||||||
return commission;
|
return commission;
|
||||||
|
|||||||
@@ -1542,20 +1542,92 @@ uint64_t komodo_max_money()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This implements the Hush Emission Curve
|
// This implements the Hush Emission Curve, the miner subsidy part,
|
||||||
|
// and must be kept in sync with hush_commision() in komoto_bitcoind.h!
|
||||||
|
// Changing these functions are consensus changes!
|
||||||
|
// Here Be Dragons! -- Duke Leto
|
||||||
uint64_t hush_block_subsidy(int height)
|
uint64_t hush_block_subsidy(int height)
|
||||||
{
|
{
|
||||||
uint64_t subsidy=0;
|
uint64_t subsidy = 0;
|
||||||
//TODO: Cover all halvings until BR=0
|
int32_t HALVING1 = GetArg("-z2zheight",340000),
|
||||||
if (nHeight >= 3700000) {
|
|
||||||
subsidy = -1;
|
if (height < TRANSITION) {
|
||||||
} else if (height >= 2020000) {
|
if(fDebug)
|
||||||
subsidy = 140625000;
|
fprintf(stderr,"%s: setting subsidy=0 during transition at height=%d\n",__func__, height);
|
||||||
} else if (height >= GetArg("-z2zheight",340000)) {
|
subsidy = 0;
|
||||||
subsidy = 281250000;
|
} else {
|
||||||
} else if (height >= 128) {
|
// Just like BTC, BRs in the far future will be slightly less than
|
||||||
subsidy = 1125000000;
|
// they should be because exact values are not integers, causing
|
||||||
|
// slightly less coins to be actually mined and small deviations
|
||||||
|
// to the ideal FR/devtax
|
||||||
|
if (height < HALVING1) { // before 1st Halving @ Block 340000 (Nov 2020)
|
||||||
|
subsidy = 1125000000;
|
||||||
|
} else if (height < 2020000 ) {
|
||||||
|
subsidy = 281250000;
|
||||||
|
} else if (height < 3700000 ) {
|
||||||
|
subsidy = 140625000;
|
||||||
|
} else if (height < 5380000 ) {
|
||||||
|
subsidy = 70312500;
|
||||||
|
} else if (height < 7060000 ) {
|
||||||
|
subsidy = 35156250;
|
||||||
|
} else if (height < 8740000 ) {
|
||||||
|
subsidy = 17578125;
|
||||||
|
} else if (height < 10420000) {
|
||||||
|
subsidy = 8789062;
|
||||||
|
} else if (height < 12100000) {
|
||||||
|
subsidy = 4394531;
|
||||||
|
} else if (height < 15460000) {
|
||||||
|
subsidy = 2197265;
|
||||||
|
} else if (height < 17140000) {
|
||||||
|
subsidy = 1098632;
|
||||||
|
} else if (height < 18820000) {
|
||||||
|
subsidy = 549316;
|
||||||
|
} else if (height < 23860000) {
|
||||||
|
subsidy = 274658;
|
||||||
|
} else if (height < 23860000) {
|
||||||
|
subsidy = 137329;
|
||||||
|
} else if (height < 25540000) {
|
||||||
|
subsidy = 68664;
|
||||||
|
} else if (height < 27220000) {
|
||||||
|
subsidy = 34332;
|
||||||
|
} else if (height < 27220000) {
|
||||||
|
subsidy = 17166;
|
||||||
|
} else if (height < 28900000) {
|
||||||
|
subsidy = 8583;
|
||||||
|
} else if (height < 30580000) {
|
||||||
|
subsidy = 4291;
|
||||||
|
} else if (height < 32260000) {
|
||||||
|
subsidy = 2145;
|
||||||
|
} else if (height < 33940000) {
|
||||||
|
subsidy = 1072;
|
||||||
|
} else if (height < 35620000) {
|
||||||
|
subsidy = 536;
|
||||||
|
} else if (height < 37300000) {
|
||||||
|
subsidy = 268;
|
||||||
|
} else if (height < 38980000) {
|
||||||
|
subsidy = 134;
|
||||||
|
} else if (height < 40660000) {
|
||||||
|
subsidy = 67;
|
||||||
|
} else if (height < 42340000) {
|
||||||
|
subsidy = 33;
|
||||||
|
} else if (height < 44020000) {
|
||||||
|
subsidy = 16;
|
||||||
|
} else if (height < 45700000) {
|
||||||
|
subsidy = 8;
|
||||||
|
} else if (height < 47380000) {
|
||||||
|
subsidy = 4;
|
||||||
|
} else if (height < 49060000) {
|
||||||
|
subsidy = 2;
|
||||||
|
} else if (height < 50740000) {
|
||||||
|
subsidy = 1;
|
||||||
|
} else {
|
||||||
|
// HUSH Block Reward rounds down to 0 at Block 50740000 which is the 31st halving
|
||||||
|
// because Bitcoin/Zcash/Hush internals don't support 0.5 sat block reward yet ;)
|
||||||
|
subsidy = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if(fDebug)
|
||||||
|
fprintf(stderr,"%s: subsidy=%ul at height=%d\n",__func__,subsidy,height);
|
||||||
return subsidy;
|
return subsidy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user