From 5fc4b4c7701f7efe453bae8145d15c12a83dbc70 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 14 Sep 2020 15:14:47 -0400 Subject: [PATCH 01/24] Use the correct interval at z2zheight --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index ff37a4847..4975d24b4 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1258,7 +1258,7 @@ uint64_t hush_commission(int height) }; uint64_t commission = 0; - if( height > HALVING1) { + if( height >= HALVING1) { // Block time going from 150s to 75s (half) means the interval between halvings // must be twice as often, i.e. 840000*2=1680000 // With 150s blocks, we have 210,000 blocks per year From b83f38c615ae43e8469de76c452cb4a0a06101d6 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 14 Sep 2020 15:27:26 -0400 Subject: [PATCH 02/24] komodo_commission logspam --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 4975d24b4..b1870b7c1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1362,7 +1362,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) } if ( commission < 10000 ) commission = 0; - //fprintf(stderr,"-> %.8f\n",(double)commission/COIN); + fprintf(stderr,"%s: commission=%.8f at height=%d\n",__func__, (double)commission/COIN, height); return(commission); } From 1ae419b54c7220f5aa5028a48860794760034ac3 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 14 Sep 2020 15:34:09 -0400 Subject: [PATCH 03/24] cleanup --- src/main.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c4fb5a26f..2b332593c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2402,13 +2402,8 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW) return true; } -//uint64_t komodo_moneysupply(int32_t height); - CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) { - fprintf(stderr,"%s: ht.%d\n", __func__, nHeight); - int32_t numhalvings,i; uint64_t numerator; CAmount nSubsidy = 3 * COIN; - return komodo_ac_block_subsidy(nHeight); } From 65b45d9f8824b12566afd03f8ec08c1e9c31656c Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 14 Sep 2020 15:53:34 -0400 Subject: [PATCH 04/24] mining logspam --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 4ab19638b..edd3a04f4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -610,7 +610,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 int32_t stakeHeight = chainActive.Height() + 1; - //LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x stake.%i\n", nBlockSize,blocktime,pblock->nBits,isStake); + LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x stake.%i\n", nBlockSize,blocktime,pblock->nBits,isStake); // Create coinbase tx CMutableTransaction txNew = CreateNewContextualCMutableTransaction(consensusParams, nHeight); @@ -621,7 +621,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout.resize(1); txNew.vout[0].scriptPubKey = scriptPubKeyIn; txNew.vout[0].nValue = GetBlockSubsidy(nHeight,consensusParams) + nFees; - //fprintf(stderr,"mine ht.%d with %.8f\n",nHeight,(double)txNew.vout[0].nValue/COIN); + fprintf(stderr,"mine ht.%d with %.8f\n",nHeight,(double)txNew.vout[0].nValue/COIN); txNew.nExpiryHeight = 0; if ( ASSETCHAINS_ADAPTIVEPOW <= 0 ) txNew.nLockTime = std::max(pindexPrev->GetMedianTimePast()+1, GetTime()); From 0920f264be4954fce24986e292a253b15131c3f1 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 14 Sep 2020 15:56:25 -0400 Subject: [PATCH 05/24] cleanup --- src/rpc/mining.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index ab64e8d49..80284108f 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -681,9 +681,6 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp, const CPubKey& myp throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Cannot get a block template while no peers are connected or chain not in sync!"); } - //if (IsInitialBlockDownload()) - // throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Zcash is downloading blocks..."); - static unsigned int nTransactionsUpdatedLast; if (!lpval.isNull()) From c422ec37b7bbe77377ae1366a2d1cb019a14f022 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 15 Sep 2020 10:15:03 -0400 Subject: [PATCH 06/24] Initialize numhalvings and do not print for now, since we dont calculate it here --- src/komodo_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index f81aaf34e..4f4f45229 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1567,7 +1567,7 @@ uint64_t komodo_ac_block_subsidy(int nHeight) // Find current era, start from beginning reward, and determine current subsidy int64_t numerator, denominator, subsidy = 0; int64_t subsidyDifference; - int32_t numhalvings, curEra = 0, sign = 1; + int32_t numhalvings = 0, curEra = 0, sign = 1; static uint64_t cached_subsidy; static int32_t cached_numhalvings; static int cached_era; bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; @@ -1654,7 +1654,7 @@ uint64_t komodo_ac_block_subsidy(int nHeight) else subsidy += ASSETCHAINS_SUPPLY * SATOSHIDEN + magicExtra; } - fprintf(stderr,"%s: ht.%d curEra.%d lastEra.%lu subsidy.%ld numhalvings.%d magicExtra.%u\n",__func__,nHeight,curEra,ASSETCHAINS_LASTERA,subsidy,numhalvings,magicExtra); + fprintf(stderr,"%s: ht.%d curEra.%d lastEra.%lu subsidy.%ld magicExtra.%u\n",__func__,nHeight,curEra,ASSETCHAINS_LASTERA,subsidy,magicExtra); return(subsidy); } From 396488306b68344f11015e940151eb7ae5bc8c73 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 15 Sep 2020 13:09:36 -0400 Subject: [PATCH 07/24] Optional logspam is best logspam --- src/komodo_bitcoind.h | 25 ++++++++++++++++--------- src/komodo_utils.h | 16 ++++++++++------ src/main.cpp | 2 +- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b1870b7c1..2ee07b6cd 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1298,13 +1298,14 @@ uint64_t hush_commission(int height) fprintf(stderr,"%s: HUSH block reward has gone to zero at height %d!!! It was a good run folks\n", __func__, height); commission = 0; } - fprintf(stderr,"%s: commission=%lu,interval=%d at height %d\n", __func__, commission, INTERVAL, height); + if(fDebug) + fprintf(stderr,"%s: commission=%lu,interval=%d at height %d\n", __func__, commission, INTERVAL, height); return commission; } uint64_t komodo_commission(const CBlock *pblock,int32_t height) { - fprintf(stderr,"%s at height=%d\n",__func__,height); + //fprintf(stderr,"%s at height=%d\n",__func__,height); static bool didinit = false, ishush3 = false; if (!didinit) { @@ -1317,7 +1318,8 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) if ( ASSETCHAINS_FOUNDERS != 0 ) { nSubsidy = GetBlockSubsidy(height,Params().GetConsensus()); - fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); + if(fDebug) + fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); if (ishush3) { @@ -1333,7 +1335,8 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) } else { commission = ASSETCHAINS_FOUNDERS_REWARD; } - fprintf(stderr,"%s: set commission=%lu at height %d with\n",__func__,commission, height); + if(fDebug) + fprintf(stderr,"%s: set commission=%lu at height %d with\n",__func__,commission, height); } else { commission = 0; } @@ -1362,7 +1365,8 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) } if ( commission < 10000 ) commission = 0; - fprintf(stderr,"%s: commission=%.8f at height=%d\n",__func__, (double)commission/COIN, height); + if(fDebug) + fprintf(stderr,"%s: commission=%.8f at height=%d\n",__func__, (double)commission/COIN, height); return(commission); } @@ -2010,21 +2014,22 @@ void GetKomodoEarlytxidScriptPub() int64_t komodo_checkcommission(CBlock *pblock,int32_t height) { - fprintf(stderr,"%s at height=%d\n",__func__,height); + if(fDebug) + fprintf(stderr,"%s at height=%d\n",__func__,height); int64_t checktoshis=0; uint8_t *script,scripthex[8192]; int32_t scriptlen,matched = 0; static bool didinit = false; if ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 ) { checktoshis = komodo_commission(pblock,height); if ( checktoshis >= 10000 && pblock->vtx[0].vout.size() < 2 ) { - fprintf(stderr,"komodo_checkcommission vsize.%d height.%d commission %.8f\n",(int32_t)pblock->vtx[0].vout.size(),height,(double)checktoshis/COIN); + fprintf(stderr,"ERROR: komodo_checkcommission vsize.%d height.%d commission %.8f has checktoshis <10000 or not enough vouts\n",(int32_t)pblock->vtx[0].vout.size(),height,(double)checktoshis/COIN); return(-1); } else if ( checktoshis != 0 ) { script = (uint8_t *)&pblock->vtx[0].vout[1].scriptPubKey[0]; scriptlen = (int32_t)pblock->vtx[0].vout[1].scriptPubKey.size(); - if ( 1 ) + if ( fDebug ) { int32_t i; for (i=0; ivtx[0].vout[1].nValue != checktoshis ) { - fprintf(stderr,"ht.%d checktoshis %.8f vs actual vout[1] %.8f\n",height,dstr(checktoshis),dstr(pblock->vtx[0].vout[1].nValue)); + fprintf(stderr,"ERROR: ht.%d checktoshis %.8f vs actual vout[1] %.8f !!!\n",height,dstr(checktoshis),dstr(pblock->vtx[0].vout[1].nValue)); return(-1); } } } + if(fDebug) + fprintf(stderr,"%s checktoshis=%li at height=%d\n",__func__,checktoshis, height); return(checktoshis); } diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 4f4f45229..e1449c170 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1563,7 +1563,7 @@ uint64_t hush_block_subsidy(int nHeight) // wrapper for more general supply curves of Hush Smart Chains uint64_t komodo_ac_block_subsidy(int nHeight) { - fprintf(stderr,"%s: ht.%d\n", __func__, nHeight); + //fprintf(stderr,"%s: ht.%d\n", __func__, nHeight); // Find current era, start from beginning reward, and determine current subsidy int64_t numerator, denominator, subsidy = 0; int64_t subsidyDifference; @@ -1590,7 +1590,8 @@ uint64_t komodo_ac_block_subsidy(int nHeight) { int64_t nStart = curEra ? ASSETCHAINS_ENDSUBSIDY[curEra - 1] : 0; subsidy = (int64_t)ASSETCHAINS_REWARD[curEra]; - fprintf(stderr,"%s: nStart.%ld subsidy.%ld curEra.%d\n",__func__,nStart,subsidy,curEra); + if(fDebug) + fprintf(stderr,"%s: nStart.%ld subsidy.%ld curEra.%d\n",__func__,nStart,subsidy,curEra); if ( subsidy || (curEra != ASSETCHAINS_LASTERA && ASSETCHAINS_REWARD[curEra + 1] != 0) ) { @@ -1598,7 +1599,8 @@ uint64_t komodo_ac_block_subsidy(int nHeight) { if (ishush3) { subsidy = hush_block_subsidy(nHeight); - fprintf(stderr,"%s: HUSH3 subsidy=%ld at height=%d\n",__func__,subsidy,nHeight); + if(fDebug) + fprintf(stderr,"%s: HUSH3 subsidy=%ld at height=%d\n",__func__,subsidy,nHeight); } else if ( (numhalvings = ((nHeight - nStart) / ASSETCHAINS_HALVING[curEra])) > 0 ) { // The code below is not compatible with HUSH3 mainnet if ( ASSETCHAINS_DECAY[curEra] == 0 ) { @@ -1654,7 +1656,8 @@ uint64_t komodo_ac_block_subsidy(int nHeight) else subsidy += ASSETCHAINS_SUPPLY * SATOSHIDEN + magicExtra; } - fprintf(stderr,"%s: ht.%d curEra.%d lastEra.%lu subsidy.%ld magicExtra.%u\n",__func__,nHeight,curEra,ASSETCHAINS_LASTERA,subsidy,magicExtra); + if(fDebug) + fprintf(stderr,"%s: ht.%d curEra.%d lastEra.%lu subsidy.%ld magicExtra.%u\n",__func__,nHeight,curEra,ASSETCHAINS_LASTERA,subsidy,magicExtra); return(subsidy); } @@ -1822,7 +1825,8 @@ void komodo_args(char *argv0) printf("ASSETCHAINS_LASTERA, if specified, must be between 1 and %u. ASSETCHAINS_LASTERA set to %lu\n", ASSETCHAINS_MAX_ERAS, ASSETCHAINS_LASTERA); } ASSETCHAINS_LASTERA -= 1; - fprintf(stderr,"%s: lastEra=%lu maxEras=%d\n", __func__, ASSETCHAINS_LASTERA, ASSETCHAINS_MAX_ERAS); + if(fDebug) + fprintf(stderr,"%s: lastEra=%lu maxEras=%d\n", __func__, ASSETCHAINS_LASTERA, ASSETCHAINS_MAX_ERAS); ASSETCHAINS_TIMELOCKGTE = (uint64_t)GetArg("-ac_timelockgte", _ASSETCHAINS_TIMELOCKOFF); ASSETCHAINS_TIMEUNLOCKFROM = GetArg("-ac_timeunlockfrom", 0); @@ -1841,7 +1845,7 @@ void komodo_args(char *argv0) bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; if(ishush3) { - fprintf(stderr,"Setting custom HUSH3 chain values...\n"); + fprintf(stderr,"%s: Setting custom HUSH3 reward,halving,subsidy chain values...\n",__func__); // Over-ride HUSH3 values from CLI params. Changing our blocktime to 75s changes things ASSETCHAINS_REWARD[0] = 0; ASSETCHAINS_REWARD[1] = 1125000000; diff --git a/src/main.cpp b/src/main.cpp index 2b332593c..1e13c8ff1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1750,7 +1750,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa // and edge cases. This empty mempool assures there will be no transactions involving taddrs // stuck in the mempool, when the z2z rule takes effect. // Thanks to jl777 for helping design this - fprintf(stderr,"%s: rejecting all tx's during z2z transition window at height=%d\n", __func__,nHeight); + fprintf(stderr,"%s: rejecting all tx's during z2z transition window. Please retry after Block %d !!!\n", __func__,nHeight); return false; } } From 909285b981f88644e8e26777bb1499f1190e644c Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 15 Sep 2020 13:15:11 -0400 Subject: [PATCH 08/24] Where Would I Be Without @DenioD --- src/komodo_bitcoind.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 2ee07b6cd..8aa34e268 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1258,7 +1258,9 @@ uint64_t hush_commission(int height) }; uint64_t commission = 0; - if( height >= HALVING1) { + //TODO: Likely a bug hiding here or at the next halving :) + //if( height >= HALVING1) { + if( height > HALVING1) { // Block time going from 150s to 75s (half) means the interval between halvings // must be twice as often, i.e. 840000*2=1680000 // With 150s blocks, we have 210,000 blocks per year From c5189df0348f3090107d405ec37e18e26039274a Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 15 Sep 2020 13:18:01 -0400 Subject: [PATCH 09/24] A few useful comments in hush_commission() --- src/komodo_bitcoind.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 8aa34e268..e5a5fa06e 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1263,9 +1263,10 @@ uint64_t hush_commission(int height) if( height > HALVING1) { // Block time going from 150s to 75s (half) means the interval between halvings // must be twice as often, i.e. 840000*2=1680000 + // 840000 is 4 years worth of 150s blocks // With 150s blocks, we have 210,000 blocks per year // With 75s blocks, we have 420,000 blocks per year - INTERVAL = GetArg("-ac_halving2",1680000); + INTERVAL = GetArg("-ac_halving2",1680000); // 4 years worth of 75s blocks fprintf(stderr,"%s: height=%d increasing interval to %d\n", __func__, height, INTERVAL); } From 62fc6af52c70710a4d34dc98126d9b62dbdb5462 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 18 Sep 2020 11:47:06 -0400 Subject: [PATCH 10/24] cleanup --- src/komodo_bitcoind.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index e5a5fa06e..cb28cb1df 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -15,12 +15,11 @@ * * ******************************************************************************/ -// komodo functions that interact with bitcoind C++ +// Hush + Komodo functions that interact with bitcoind C++ #include #include #include "consensus/params.h" -//#include "primitives/nonce.h" #include "komodo_defs.h" #include "script/standard.h" #include "cc/CCinclude.h" From 6746d1a46aa26fd02552311ca63ed60345abe4f4 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 18 Sep 2020 12:56:01 -0400 Subject: [PATCH 11/24] Nothing is simple when floats are involved and this is a great example --- contrib/hush_supply | 152 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 125 insertions(+), 27 deletions(-) diff --git a/contrib/hush_supply b/contrib/hush_supply index f7813c64d..8584da0d4 100755 --- a/contrib/hush_supply +++ b/contrib/hush_supply @@ -8,49 +8,147 @@ use strict; # Todo: track FR # Todo: verify FR off-by-one +# Block Reward: Total Coinbase In Block +# Subsidy : Coinbase Earned by Miner +# FR : Founders Reward (10%) +# Block Reward = Subsidy + FR + my $supply = 0.0; my $block = 0; # Block 0 in Hush Smart chains is the BTC genesis block my $puposhis = 100_000_000; -my $reward0 = 1_250_000_000; +my $subsidy0 = 1_250_000_000; my $halvings = 0; my $initial = 6178674 * $puposhis; -my $interval = 1_640_000; # 4 years of 75s blocks +my $interval = 1_680_000; # ~4 years of 75s blocks my $stop = shift || -1; my $totalfr = 0; # total paid out to FR address -my $reward = $reward0; +my $subsidy = [$subsidy0, 31250000, 15625000, 78125000, 39062500, 19531250, 9765625, # these are exact + 4882812, 2441406, 1220703, 610351 ]; # these have deviation from ideal BR # Usage: ./hush_supply &> supply.csv # ./hush_supply HEIGHT &> supply.csv # stop at HEIGHT -printf "# block, supply, reward, fr, totalfr, halvings\n"; +printf "# block, supply, reward, subsidy, fr, totalfr, halvings\n"; + +# Block Reward Amounts in puposhis +# The non-integral amounts cannot be represented exactly +# 12.5 * 100000000 = 1250000000 +# 12.5 * 100000000 / 2 = 625000000 +# 12.5 * 100000000 / 4 = 312500000 +# 12.5 * 100000000 / 8 = 156250000 +# 12.5 * 100000000 / 16 = 78125000 +# 12.5 * 100000000 / 32 = 39062500 +# 12.5 * 100000000 / 64 = 19531250 +# 12.5 * 100000000 / 128 = 9765625 +# 12.5 * 100000000 / 256 = 4882812.5 +# 12.5 * 100000000 / 512 = 2441406.25 +# 12.5 * 100000000 / 1024 = 1220703.125 +# 12.5 * 100000000 / 2048 = 610351.5625 +# 12.5 * 100000000 / 4096 = 305175.78125 +# 12.5 * 100000000 / 8192 = 152587.890625 +# 12.5 * 100000000 / 16384 = 76293.9453125 +# 12.5 * 100000000 / 32768 = 38146.97265625 +# 12.5 * 100000000 / 65536 = 19073.486328125 + + + +# Halving Block Heights +# 340000 + 1680000 = 2020000 +# 340000 + 1680000*2 = 3700000 +# 340000 + 1680000*3 = 5380000 +# 340000 + 1680000*4 = 7060000 +# 340000 + 1680000*5 = 8740000 +# 340000 + 1680000*6 = 10420000 +# 340000 + 1680000*7 = 12100000 +# 340000 + 1680000*8 = 13780000 +# 340000 + 1680000*9 = 15460000 +# 340000 + 1680000*10 = 17140000 +# 340000 + 1680000*11 = 18820000 +# 340000 + 1680000*12 = 20500000 +# 340000 + 1680000*13 = 22180000 +# 340000 + 1680000*14 = 23860000 +# 340000 + 1680000*15 = 25540000 + + +sub hush_block_reward +{ + my $reward = 0; + my $height = shift; + my $halvings = 0; + + # TODO: Cover all halvings until BR=0 + if ($height >= 23860000) { + $reward = 19073; # 0.486328125 deviation + $halvings = 15; + } elsif ($height >= 22180000) { + $reward = 38146; # 0.97265625 deviation + $halvings = 14; + } elsif ($height >= 20500000) { + $reward = 152587; # 0.890625sat deviation + $halvings = 13; + } elsif ($height >= 18820000) { + $reward = 305175; # 0.78125sat deviation + $halvings = 12; + } elsif ($height >= 17140000) { + $reward = 305175; # 0.78125sat deviation + $halvings = 11; + } elsif ($height >= 15460000) { + $reward = 610351; # 0.5625sat deviation + $halvings = 10; + } elsif ($height >= 13780000) { + $reward = 1220703; # 0.125sat deviation + $halvings = 9 + } elsif ($height >= 12100000) { + $reward = 2441406; # 0.25sat deviation + $halvings = 8 + } elsif ($height >= 10420000) { + $reward = 4882812; # 0.5sat deviation + $halvings = 7; + } elsif ($height >= 8740000) { + $reward = 9765625; # last exact reward + $halvings = 6; + } elsif ($height >= 7060000) { + $reward = 19531250; # 0.1953125 HUSH + $halvings = 5; + } elsif ($height >= 5380000) { + $reward = 39062500; # 0.390625 HUSH + $halvings = 4; + } elsif ($height >= 3700000) { + $reward = 78125000; # 0.78125 HUSH + $halvings = 3; + } elsif ($height >= 2020000) { + $reward = 156250000; # 1.5625 HUSH + $halvings = 2; + } elsif ($height >= 340000) { + $reward = 312500000; # 3.125 HUSH + $halvings = 1; + } elsif ($height >= 128) { + $reward = 1250000000; # 12.5 HUSH + } + + return ($reward,$halvings); +} # We know BR will go to zero between 7 and 8th halvings while ($halvings <= 10) { $block++; - my $fr = 0; - # blocks 2-127 of Hush v3 had BR=0 - if ($block == 1) { - $reward = $initial; # airdropped funds from Hush v2 mainnet - } elsif ($block > 1 && $block < 128) { - $reward = 0; # blocks 2-127 have BR=0 - } else { - $fr = 125_000_000; - if ($block < 340_000) { - $reward = $reward0; - } else { - my $shifted = $block - 340_000; - # Past the first halving - $halvings = 1 + int ($shifted / $interval); - if ($shifted % 840_000 == 0) { - $reward >>= 2; - $fr >>= 2; - } - } + my ($reward,$halvings) = hush_block_reward($block); + my $fr = int($reward / 10); + my $subsidy = $reward - $fr; + + if($block == 1) { + # initial airdrop of funds from HUSH v2 network @ Block 500000 + $reward = $initial; + $subsidy= $reward; + $fr = 0; } - $supply += $reward; - $totalfr += $fr; + $supply += $reward; + $totalfr += $fr; - # block, current supply, block reward amount, number of halvings, all amounts are in puposhis - printf "%d,%d,%d,%d,%d,%d\n", $block, $supply, $reward, $fr, $totalfr, $halvings; + # all values in puposhis + # block, current supply, block reward amount, fr, totalfr, number of halvings + printf "%d,%d,%d,%d,%d,%d,%d\n", $block, $supply, $reward, $subsidy, $fr, $totalfr, $halvings; exit(0) if $block == $stop; + exit(0) if ($block > 128 && $reward == 0); + exit(-1) if ($supply >= 21_000_000*$puposhis); } From b277641ca114e153997e1018b3763221a5236d9d Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 18 Sep 2020 13:00:04 -0400 Subject: [PATCH 12/24] Cleanup and cli help --- contrib/hush_supply | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/contrib/hush_supply b/contrib/hush_supply index 8584da0d4..1b4ec43af 100755 --- a/contrib/hush_supply +++ b/contrib/hush_supply @@ -4,14 +4,6 @@ use warnings; use strict; -# Simulate the total supply on Hush v3 mainnet -# Todo: track FR -# Todo: verify FR off-by-one - -# Block Reward: Total Coinbase In Block -# Subsidy : Coinbase Earned by Miner -# FR : Founders Reward (10%) -# Block Reward = Subsidy + FR my $supply = 0.0; my $block = 0; # Block 0 in Hush Smart chains is the BTC genesis block @@ -22,11 +14,22 @@ my $initial = 6178674 * $puposhis; my $interval = 1_680_000; # ~4 years of 75s blocks my $stop = shift || -1; my $totalfr = 0; # total paid out to FR address -my $subsidy = [$subsidy0, 31250000, 15625000, 78125000, 39062500, 19531250, 9765625, # these are exact - 4882812, 2441406, 1220703, 610351 ]; # these have deviation from ideal BR -# Usage: ./hush_supply &> supply.csv -# ./hush_supply HEIGHT &> supply.csv # stop at HEIGHT + +if ($stop eq 'help' or $stop =~ m/-h/) { + die < supply.csv + ./hush_supply HEIGHT &> supply.csv # stop at HEIGHT +# This will generate CSV in the form of: +# block, supply, reward, subsidy, fr, totalfr, halvings +HELP +} + printf "# block, supply, reward, subsidy, fr, totalfr, halvings\n"; From 3e60d1187f1e66f97a8bb563bce613d2ac0d975a Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 18 Sep 2020 13:09:30 -0400 Subject: [PATCH 13/24] Fix logging bug where incorrect number of zins/zouts was shown (block vs tx counts) --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 1e13c8ff1..6bed1c0e4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4789,9 +4789,10 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl nShieldedOutputsInBlock += nShieldedOutputs; nShieldedSpendsInBlock += nShieldedSpends; if (fZdebug) { - fprintf(stderr,"%s: tx=%s has zspends=%d zouts=%d\n", __FUNCTION__, tx.GetHash().ToString().c_str(), nShieldedSpendsInBlock, nShieldedOutputsInBlock ); + fprintf(stderr,"%s: tx=%s has zspends=%d zouts=%d\n", __FUNCTION__, tx.GetHash().ToString().c_str(), nShieldedSpends, nShieldedOutputs ); } } + fprintf(stderr,"%s: block %s has total zspends=%d zouts=%d\n", __FUNCTION__, block.GetHash().ToString().c_str(), nShieldedSpendsInBlock, nShieldedOutputsInBlock ); pindexNew->nSproutValue = sproutValue; pindexNew->nChainSproutValue = boost::none; From 0a96fdc63f9313c7ea198aedad3419cac42db2b7 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 18 Sep 2020 16:19:34 -0400 Subject: [PATCH 14/24] Exactly simulate the Hush block reward until it hits zero at halving 31 --- contrib/hush_supply | 109 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 85 insertions(+), 24 deletions(-) diff --git a/contrib/hush_supply b/contrib/hush_supply index 1b4ec43af..fcf4460dc 100755 --- a/contrib/hush_supply +++ b/contrib/hush_supply @@ -53,24 +53,38 @@ printf "# block, supply, reward, subsidy, fr, totalfr, halvings\n"; # 12.5 * 100000000 / 32768 = 38146.97265625 # 12.5 * 100000000 / 65536 = 19073.486328125 - - -# Halving Block Heights -# 340000 + 1680000 = 2020000 -# 340000 + 1680000*2 = 3700000 -# 340000 + 1680000*3 = 5380000 -# 340000 + 1680000*4 = 7060000 -# 340000 + 1680000*5 = 8740000 -# 340000 + 1680000*6 = 10420000 -# 340000 + 1680000*7 = 12100000 -# 340000 + 1680000*8 = 13780000 -# 340000 + 1680000*9 = 15460000 -# 340000 + 1680000*10 = 17140000 -# 340000 + 1680000*11 = 18820000 -# 340000 + 1680000*12 = 20500000 -# 340000 + 1680000*13 = 22180000 -# 340000 + 1680000*14 = 23860000 -# 340000 + 1680000*15 = 25540000 +# Hush Halving Heights and Block Rewards +# 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 sub hush_block_reward @@ -79,18 +93,65 @@ sub hush_block_reward my $height = shift; my $halvings = 0; - # TODO: Cover all halvings until BR=0 - if ($height >= 23860000) { + if ($height >= 50740000) { + $reward = 0; + $halvings = 31; + } elsif ($height >= 49060000) { + $reward = 1; + $halvings = 30; + } elsif ($height >= 47380000) { + $reward = 1; + $halvings = 29; + } elsif ($height >= 45700000) { + $reward = 2; + $halvings = 28; + } elsif ($height >= 44020000) { + $reward = 4; + $halvings = 27; + } elsif ($height >= 42340000) { + $reward = 9; + $halvings = 26; + } elsif ($height >= 40660000) { + $reward = 18; + $halvings = 25; + } elsif ($height >= 38980000) { + $reward = 37; + $halvings = 24; + } elsif ($height >= 37380000) { + $reward = 74; + $halvings = 23; + } elsif ($height >= 35620000) { + $reward = 149; + $halvings = 22; + } elsif ($height >= 33940000) { + $reward = 298; + $halvings = 21; + } elsif ($height >= 32260001) { + $reward = 596; + $halvings = 20; + } elsif ($height >= 30580000) { + $reward = 1192; + $halvings = 19; + } elsif ($height >= 28900000) { + $reward = 2384; + $halvings = 18; + } elsif ($height >= 27220000) { + $reward = 4768; + $halvings = 17; + } elsif ($height >= 25540000) { + $reward = 9536; + $halvings = 16; + } elsif ($height >= 23860000) { $reward = 19073; # 0.486328125 deviation $halvings = 15; } elsif ($height >= 22180000) { $reward = 38146; # 0.97265625 deviation $halvings = 14; } elsif ($height >= 20500000) { - $reward = 152587; # 0.890625sat deviation + $reward = 76293; # 0.9453125 deviation $halvings = 13; } elsif ($height >= 18820000) { - $reward = 305175; # 0.78125sat deviation + $reward = 152587; # 0.890625 deviation $halvings = 12; } elsif ($height >= 17140000) { $reward = 305175; # 0.78125sat deviation @@ -132,8 +193,8 @@ sub hush_block_reward return ($reward,$halvings); } -# We know BR will go to zero between 7 and 8th halvings -while ($halvings <= 10) { +# Block reward is 0 at the 31st halving +while ($halvings <= 30) { $block++; my ($reward,$halvings) = hush_block_reward($block); my $fr = int($reward / 10); From d65fbabc778f1b4a51e0e04588c27e58e9c6b219 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 18 Sep 2020 16:34:36 -0400 Subject: [PATCH 15/24] Correctly specify the exact block height when Hush block reward goes to zero --- src/komodo_bitcoind.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index cb28cb1df..e8eadbd09 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1245,10 +1245,9 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); // Here Be Dragons! -- Duke Leto uint64_t hush_commission(int height) { - // TODO: Calculate new BR_END based on 75s block time!!! 2X old BR_END is a rough estimate, not exact! + // BR_END is the 31st halving int32_t starting_commission = 125000000, HALVING1 = GetArg("-z2zheight",340000), - INTERVAL = GetArg("-ac_halving1",840000), TRANSITION = 129, BR_END = 2*5422111; - // TODO: how many halvings will we have given new 75s blocktime? + INTERVAL = GetArg("-ac_halving1",840000), TRANSITION = 129, BR_END = 50740000; int32_t commisions[] = {starting_commission, 31250000, 15625000, 78125000, 39062500, 19531250, 9765625, // these are exact 4882812, 2441406, 1220703, 610351 // these have deviation from ideal BR // Just like BTC, BRs in the far future will be slightly less than @@ -1294,9 +1293,9 @@ uint64_t hush_commission(int height) commission = commisions[8]; } // Explicitly set the last block reward - // BR_END is the block with the last non-zero block reward, which overrides + // BR_END is the block with first zero block reward, which overrides // the -ac_end param on HUSH3 - if(height > BR_END) { + 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; } From 70455eb41e3f2fb5b62c06276b95879f84648290 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 18 Sep 2020 16:41:28 -0400 Subject: [PATCH 16/24] update version --- src/clientversion.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clientversion.h b/src/clientversion.h index fea7d0b05..ed24867a1 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -35,7 +35,7 @@ #define CLIENT_VERSION_MAJOR 3 #define CLIENT_VERSION_MINOR 5 #define CLIENT_VERSION_REVISION 0 -#define CLIENT_VERSION_BUILD 5 +#define CLIENT_VERSION_BUILD 50 //! Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE true From 5adfbf80ee6dbb77d4dce6f0ae0517ce29d5554d Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 18 Sep 2020 16:42:14 -0400 Subject: [PATCH 17/24] Bump protocol version since this is a mandatory consensus change, in the future we can make this a minimum protocol version --- src/version.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/version.h b/src/version.h index 4056f105d..5cf912492 100644 --- a/src/version.h +++ b/src/version.h @@ -1,6 +1,7 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -24,7 +25,7 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 170008; +static const int PROTOCOL_VERSION = 170009; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; From fab0f9494230e8b982445f3facb29601ee79da22 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 18 Sep 2020 16:49:42 -0400 Subject: [PATCH 18/24] Cleanup and update copyrights --- src/addressindex.h | 3 ++- src/alert.h | 1 + src/alertkeys.h | 3 ++- src/arith_uint256.h | 1 + src/asyncrpcoperation.h | 1 + src/asyncrpcqueue.h | 1 + src/coincontrol.h | 1 + src/init.h | 4 +--- src/komodo.h | 1 + src/miner.h | 1 + 10 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/addressindex.h b/src/addressindex.h index 643f06e13..d22426ed6 100644 --- a/src/addressindex.h +++ b/src/addressindex.h @@ -1,5 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2015 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -79,4 +80,4 @@ struct CMempoolAddressDeltaKeyCompare } }; -#endif // BITCOIN_ADDRESSINDEX_H \ No newline at end of file +#endif // BITCOIN_ADDRESSINDEX_H diff --git a/src/alert.h b/src/alert.h index 16204c9c5..d8d762b00 100644 --- a/src/alert.h +++ b/src/alert.h @@ -1,5 +1,6 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/alertkeys.h b/src/alertkeys.h index 106576add..1c4bcbc2c 100644 --- a/src/alertkeys.h +++ b/src/alertkeys.h @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * @@ -16,7 +17,7 @@ #ifndef BITCOIN_ALERTKEYS_H #define BITCOIN_ALERTKEYS_H -// REMINDER: DO NOT COMMIT YOUR PRIVATE KEYS TO THE GIT REPOSITORY! +// REMINDER: DO NOT COMMIT YOUR PRIVATE KEYS TO THE GIT REPOSITORY, lulz const char* pszPrivKey = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; const char* pszTestNetPrivKey = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; diff --git a/src/arith_uint256.h b/src/arith_uint256.h index b51f82f14..f7bc8a585 100644 --- a/src/arith_uint256.h +++ b/src/arith_uint256.h @@ -1,5 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/asyncrpcoperation.h b/src/asyncrpcoperation.h index 3fe966977..5dc102366 100644 --- a/src/asyncrpcoperation.h +++ b/src/asyncrpcoperation.h @@ -1,4 +1,5 @@ // Copyright (c) 2016 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/asyncrpcqueue.h b/src/asyncrpcqueue.h index 0d228564f..32e091aff 100644 --- a/src/asyncrpcqueue.h +++ b/src/asyncrpcqueue.h @@ -1,4 +1,5 @@ // Copyright (c) 2016 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/coincontrol.h b/src/coincontrol.h index 02d487a4c..2daa95919 100644 --- a/src/coincontrol.h +++ b/src/coincontrol.h @@ -1,4 +1,5 @@ // Copyright (c) 2011-2013 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/init.h b/src/init.h index c68d59419..0d8145a41 100644 --- a/src/init.h +++ b/src/init.h @@ -1,5 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -23,8 +24,6 @@ #include -//#include "zcash/JoinSplit.hpp" - class CScheduler; class CWallet; @@ -34,7 +33,6 @@ class thread_group; } // namespace boost extern CWallet* pwalletMain; -//extern ZCJoinSplit* pzcashParams; void StartShutdown(); bool ShutdownRequested(); diff --git a/src/komodo.h b/src/komodo.h index 9816eb20b..1cfbd283b 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * diff --git a/src/miner.h b/src/miner.h index a3bedd292..c42c2ad54 100644 --- a/src/miner.h +++ b/src/miner.h @@ -1,5 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. From 794c32143c54a681386db17f717197600cd58245 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 18 Sep 2020 16:59:15 -0400 Subject: [PATCH 19/24] Staked notaries are not supported on Hush smart chains --- src/notaries_staked.cpp | 97 +---------------------------------------- 1 file changed, 1 insertion(+), 96 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index db1696ed5..6bc458078 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -9,125 +9,30 @@ extern pthread_mutex_t staked_mutex; int8_t is_STAKED(const char *chain_name) { - static int8_t STAKED,doneinit; - if ( chain_name[0] == 0 ) - return(0); - if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) - return(STAKED); - else STAKED = 0; - if ( (strcmp(chain_name, "LABS") == 0) ) - STAKED = 1; // These chains are allowed coin emissions. - else if ( (strncmp(chain_name, "LABS", 4) == 0) ) - STAKED = 2; // These chains have no coin emission, block subsidy is always 0, and comission is 0. Notary pay is allowed. - else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) - STAKED = 3; // These chains have no speical rules at all. - else if ( (strcmp(chain_name, "TEST") == 0) || (strncmp(chain_name, "TEST", 4) == 0) ) - STAKED = 4; // These chains are for testing consensus to create a chain etc. Not meant to be actually used for anything important. - else if ( (strcmp(chain_name, "THIS_CHAIN_IS_BANNED") == 0) ) - STAKED = 255; // Any chain added to this group is banned, no notarisations are valid, as a consensus rule. Can be used to remove a chain from cluster if needed. - doneinit = 1; + static int8_t STAKED=0; return(STAKED); }; int32_t STAKED_era(int timestamp) { - int8_t era = 0; - if (timestamp <= STAKED_NOTARIES_TIMESTAMP[0]) - return(1); - for (int32_t i = 1; i < NUM_STAKED_ERAS; i++) - { - if (timestamp <= STAKED_NOTARIES_TIMESTAMP[i] && timestamp >= (STAKED_NOTARIES_TIMESTAMP[i-1] + STAKED_ERA_GAP)) - return(i+1); - } - // if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP. return(0); }; int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { - if ( STAKED_ERA != 0 ) - { - for (int8_t i = 0; i < num_notaries_STAKED[STAKED_ERA-1]; i++) { - if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { - notaryname.assign(notaries_STAKED[STAKED_ERA-1][i][0]); - return(i); - } - } - } return(-1); } int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { int i; int8_t retval = 0; - static uint8_t staked_pubkeys[NUM_STAKED_ERAS][64][33],didinit[NUM_STAKED_ERAS]; - static char ChainName[65]; - - if ( ChainName[0] == 0 ) - { - if ( ASSETCHAINS_SYMBOL[0] == 0 ) - strcpy(ChainName,"KMD"); - else - strcpy(ChainName,ASSETCHAINS_SYMBOL); - } - - if ( era == 0 ) - { - // era is zero so we need to null out the pubkeys. - memset(pubkeys,0,64 * 33); - printf("%s is a STAKED chain and is in an ERA GAP.\n",ChainName); - return(64); - } - else - { - if ( didinit[era-1] == 0 ) - { - for (i=0; i Date: Fri, 18 Sep 2020 17:01:15 -0400 Subject: [PATCH 20/24] Update manpages --- doc/man/hush-cli.1 | 6 +++--- doc/man/hush-tx.1 | 6 +++--- doc/man/hushd.1 | 14 ++++++++++---- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/doc/man/hush-cli.1 b/doc/man/hush-cli.1 index 3e1ca3616..d091ac49f 100644 --- a/doc/man/hush-cli.1 +++ b/doc/man/hush-cli.1 @@ -1,9 +1,9 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10. -.TH HUSH-CLI "1" "July 2020" "hush-cli v3.5.0" "User Commands" +.TH HUSH-CLI "1" "September 2020" "hush-cli v3.5.0" "User Commands" .SH NAME hush-cli \- manual page for hush-cli v3.5.0 .SH DESCRIPTION -Komodo RPC client version v3.5.0\-beta6\-a59803c32\-dirty +Komodo RPC client version v3.5.0\-beta6\-fab0f9494\-dirty .PP In order to ensure you are adequately protecting your privacy when using Hush, please see . @@ -71,7 +71,7 @@ Timeout in seconds during HTTP requests, or 0 for no timeout. (default: Read extra arguments from standard input, one per line until EOF/Ctrl\-D (recommended for sensitive information such as passphrases) .SH COPYRIGHT -Hush Daemon version v3.5.0-beta6-a59803c32-dirty +Hush Daemon version v3.5.0-beta6-fab0f9494-dirty In order to ensure you are adequately protecting your privacy when using Hush, please see . diff --git a/doc/man/hush-tx.1 b/doc/man/hush-tx.1 index fa3162fda..99212c29b 100644 --- a/doc/man/hush-tx.1 +++ b/doc/man/hush-tx.1 @@ -1,9 +1,9 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10. -.TH HUSH-TX "1" "July 2020" "hush-tx v3.5.0" "User Commands" +.TH HUSH-TX "1" "September 2020" "hush-tx v3.5.0" "User Commands" .SH NAME hush-tx \- manual page for hush-tx v3.5.0 .SH DESCRIPTION -Hush komodo\-tx utility version v3.5.0\-beta6\-a59803c32\-dirty +Hush komodo\-tx utility version v3.5.0\-beta6\-fab0f9494\-dirty .SS "Usage:" .TP komodo\-tx [options] [commands] @@ -84,7 +84,7 @@ set=NAME:JSON\-STRING .IP Set register NAME to given JSON\-STRING .SH COPYRIGHT -Hush Daemon version v3.5.0-beta6-a59803c32-dirty +Hush Daemon version v3.5.0-beta6-fab0f9494-dirty In order to ensure you are adequately protecting your privacy when using Hush, please see . diff --git a/doc/man/hushd.1 b/doc/man/hushd.1 index 370986f0f..1d4d70cc3 100644 --- a/doc/man/hushd.1 +++ b/doc/man/hushd.1 @@ -1,10 +1,10 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10. -.TH HUSHD "1" "July 2020" "hushd v3.5.0" "User Commands" +.TH HUSHD "1" "September 2020" "hushd v3.5.0" "User Commands" .SH NAME hushd \- manual page for hushd v3.5.0 .SH DESCRIPTION Found binary: ./komodod -Hush Daemon version v3.5.0\-beta6\-a59803c32\-dirty +Hush Daemon version v3.5.0\-beta6\-fab0f9494\-dirty .PP In order to ensure you are adequately protecting your privacy when using Hush, please see . @@ -114,6 +114,11 @@ Create new files with system default permissions, instead of umask 077 Maintain a full transaction index, used by the getrawtransaction rpc call (default: 0) .HP +\fB\-txsend=\fR +.IP +Execute command to send a transaction instead of broadcasting (%s in cmd +is replaced by transaction hex) +.HP \fB\-addressindex\fR .IP Maintain a full address index, used to query for the balance, txids and @@ -346,7 +351,8 @@ Upgrade wallet to latest format on startup .HP \fB\-wallet=\fR .IP -Specify wallet file (within data directory) (default: wallet.dat) +Specify wallet file absolute path or a path relative to the data +directory (default: wallet.dat) .HP \fB\-walletbroadcast\fR .IP @@ -639,7 +645,7 @@ Starting supply, default is 0 .IP Enforce transaction\-rate limit, default 0 .SH COPYRIGHT -Hush Daemon version v3.5.0-beta6-a59803c32-dirty +Hush Daemon version v3.5.0-beta6-fab0f9494-dirty In order to ensure you are adequately protecting your privacy when using Hush, please see . From 2ea974a402cdd80357145ccecaf1197faeba7825 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 18 Sep 2020 17:15:51 -0400 Subject: [PATCH 21/24] Update comments --- src/komodo_bitcoind.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index e8eadbd09..69d4859af 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1261,10 +1261,10 @@ uint64_t hush_commission(int height) if( height > HALVING1) { // Block time going from 150s to 75s (half) means the interval between halvings // must be twice as often, i.e. 840000*2=1680000 - // 840000 is 4 years worth of 150s blocks + // 840000 is ~4 years worth of 150s blocks // With 150s blocks, we have 210,000 blocks per year // With 75s blocks, we have 420,000 blocks per year - 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); } @@ -1286,10 +1286,8 @@ uint64_t hush_commission(int height) } else if (height < HALVING1+6*INTERVAL) { // before 7th Halving @ Block 10420000 commission = commisions[6]; } else if (height < HALVING1+7*INTERVAL) { // before 8th Halving @ Block 12100000 - // TODO: Still true??? Block reward will go to zero between 7th+8th halvings, ac_end may need adjusting commission = commisions[7]; } else if (height < HALVING1+8*INTERVAL) { // before 9th Halving @ Block 13780000 - // BR should be zero before this halving happens commission = commisions[8]; } // Explicitly set the last block reward From 599c8420965f5f9e7f2fe2235baeddc16f714562 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 18 Sep 2020 17:50:04 -0400 Subject: [PATCH 22/24] WIP full supply curve --- src/komodo_bitcoind.h | 122 +++++++++++++++++++++++++++++++++--------- src/komodo_utils.h | 13 +++-- 2 files changed, 103 insertions(+), 32 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 69d4859af..c7aad1778 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1248,12 +1248,6 @@ uint64_t hush_commission(int height) // BR_END is the 31st halving int32_t starting_commission = 125000000, HALVING1 = GetArg("-z2zheight",340000), INTERVAL = GetArg("-ac_halving1",840000), TRANSITION = 129, BR_END = 50740000; - int32_t commisions[] = {starting_commission, 31250000, 15625000, 78125000, 39062500, 19531250, 9765625, // these are exact - 4882812, 2441406, 1220703, 610351 // these have deviation from ideal BR - // Just like BTC, BRs in the far future will be slightly less than - // they should be because exact values are not integers, causing - // slightly less coins to be actually mined - }; uint64_t commission = 0; //TODO: Likely a bug hiding here or at the next halving :) @@ -1267,29 +1261,107 @@ uint64_t hush_commission(int height) INTERVAL = GetArg("-ac_halving2",1680000); // ~4 years worth of 75s blocks 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 +*/ + - // Transition period of 128 blocks has BR=FR=0 if (height < TRANSITION) { commission = 0; - } else if (height < HALVING1) { // before 1st Halving @ Block 340000 (Nov 2020) - commission = commisions[0]; - } else if (height < HALVING1+1*INTERVAL) { // before 2nd Halving @ Block 2020000 - commission = commisions[1]; - } else if (height < HALVING1+2*INTERVAL) { // before 3rd Halving @ Block 3700000 - commission = commisions[2]; - } else if (height < HALVING1+3*INTERVAL) { // before 4th Halving @ Block 5380000 - commission = commisions[3]; - } else if (height < HALVING1+4*INTERVAL) { // before 5th Halving @ Block 7060000 - commission = commisions[4]; - } else if (height < HALVING1+5*INTERVAL) { // before 6th Halving @ Block 8740000 - commission = commisions[5]; - } else if (height < HALVING1+6*INTERVAL) { // before 7th Halving @ Block 10420000 - commission = commisions[6]; - } else if (height < HALVING1+7*INTERVAL) { // before 8th Halving @ Block 12100000 - commission = commisions[7]; - } else if (height < HALVING1+8*INTERVAL) { // before 9th Halving @ Block 13780000 - commission = commisions[8]; + } else { + // Just like BTC, BRs in the far future will be slightly less than + // they should be because exact values are not integers, causing + // slightly less coins to be actually mined + if (height < HALVING1) { // before 1st Halving @ Block 340000 (Nov 2020) + commission = starting_commission; + } else if (height < 2020000 ) { + commission = 312500000; + } else if (height < 3700000 ) { + commission = 156250000; + } else if (height < 5380000 ) { + commission = 78125000; + } else if (height < 7060000 ) { + commission = 39062500; + } else if (height < 8740000 ) { + commission = 19531250; + } else if (height < 10420000) { + commission = 9765625; + } else if (height < 12100000) { + commission = 488281; + } else if (height < 15460000) { + commission = 244140; + } else if (height < 17140000) { + commission = 122070; + } else if (height < 18820000) { + commission = 61035; + } else if (height < 23860000) { + commission = 30517; + } else if (height < 23860000) { + commission = 15258; + } else if (height < 25540000) { + commission = 7629; + } else if (height < 27220000) { + commission = 3814; + } else if (height < 27220000) { + commission = 1907; + } else if (height < 28900000) { + commission = 953; + } else if (height < 30580000) { + commission = 476; + } else if (height < 32260000) { + commission = 238; + } else if (height < 33940000) { + commission = 119; + } else if (height < 35620000) { + commission = 59; + } else if (height < 37300000) { + commission = 29; + } else if (height < 38980000) { + commission = 14; + } else if (height < 40660000) { + commission = 7; + } else if (height < 42340000) { + commission = 3; + } else if (height < 44020000) { + commission = 1; + } else if (height < 45700000) { + commission = 0; + } else if (height < 47380000) { + commission = 0; + } else if (height < 49060000) { + commission = 0; + } else if (height < 50740000) { + commission = 0; + } else { + 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 diff --git a/src/komodo_utils.h b/src/komodo_utils.h index e1449c170..392875dbc 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1543,18 +1543,17 @@ uint64_t komodo_max_money() // This implements the Hush Emission Curve -uint64_t hush_block_subsidy(int nHeight) +uint64_t hush_block_subsidy(int height) { uint64_t subsidy=0; //TODO: Cover all halvings until BR=0 - //if (nHeight >= 3700000) { - // subsidy = ASSETCHAINS_REWARD[4]; - //} else - if (nHeight >= 2020000) { + if (nHeight >= 3700000) { + subsidy = -1; + } else if (height >= 2020000) { subsidy = 140625000; - } else if (nHeight >= GetArg("-z2zheight",340000)) { + } else if (height >= GetArg("-z2zheight",340000)) { subsidy = 281250000; - } else if (nHeight >= 128) { + } else if (height >= 128) { subsidy = 1125000000; } return subsidy; From 65da80de5860ef56f18ba2a8b7e47e1357114e01 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 19 Sep 2020 11:03:35 -0400 Subject: [PATCH 23/24] 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. --- contrib/hush_block_subsidy_per_halving | 17 +++++ contrib/hush_halvings | 22 ++++++ src/komodo_bitcoind.h | 60 +++++----------- src/komodo_utils.h | 94 +++++++++++++++++++++++--- 4 files changed, 138 insertions(+), 55 deletions(-) create mode 100755 contrib/hush_block_subsidy_per_halving create mode 100755 contrib/hush_halvings diff --git a/contrib/hush_block_subsidy_per_halving b/contrib/hush_block_subsidy_per_halving new file mode 100755 index 000000000..7e7b05b4b --- /dev/null +++ b/contrib/hush_block_subsidy_per_halving @@ -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); +} + diff --git a/contrib/hush_halvings b/contrib/hush_halvings new file mode 100755 index 000000000..67246bb13 --- /dev/null +++ b/contrib/hush_halvings @@ -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++; +} + diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index c7aad1778..76e075bd6 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -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 // 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 -// 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 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 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) { commission = 0; } else { // Just like BTC, BRs in the far future will be slightly less than // 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) commission = starting_commission; } else if (height < 2020000 ) { - commission = 312500000; + commission = 31250000; } else if (height < 3700000 ) { - commission = 156250000; + commission = 15625000; } else if (height < 5380000 ) { - commission = 78125000; + commission = 7812500; } else if (height < 7060000 ) { - commission = 39062500; + commission = 3906250; } else if (height < 8740000 ) { - commission = 19531250; + commission = 1953125; } else if (height < 10420000) { - commission = 9765625; + commission = 976562; // 0.5 puposhi deviation, all further BRs have deviation from ideal } else if (height < 12100000) { commission = 488281; } else if (height < 15460000) { @@ -1350,25 +1323,24 @@ uint64_t hush_commission(int height) } else if (height < 44020000) { commission = 1; } else if (height < 45700000) { + // FR goes to zero at Halving 26 commission = 0; } else if (height < 47380000) { + // FR still zero at Halving 27 commission = 0; } else if (height < 49060000) { + // FR still zero at Halving 28 commission = 0; } else if (height < 50740000) { + // FR still zero at Halving 29 commission = 0; } else { + // enforce FR=0 for all other heights + // This over-rides the -ac_end param via HUSH3 cli args 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) fprintf(stderr,"%s: commission=%lu,interval=%d at height %d\n", __func__, commission, INTERVAL, height); return commission; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 392875dbc..f134e9957 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -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 subsidy=0; - //TODO: Cover all halvings until BR=0 - if (nHeight >= 3700000) { - subsidy = -1; - } else if (height >= 2020000) { - subsidy = 140625000; - } else if (height >= GetArg("-z2zheight",340000)) { - subsidy = 281250000; - } else if (height >= 128) { - subsidy = 1125000000; + uint64_t subsidy = 0; + int32_t HALVING1 = GetArg("-z2zheight",340000), + + if (height < TRANSITION) { + if(fDebug) + fprintf(stderr,"%s: setting subsidy=0 during transition at height=%d\n",__func__, height); + subsidy = 0; + } else { + // Just like BTC, BRs in the far future will be slightly less than + // 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; } From 9e288d185b069b3a0cac13c9850a4f9613772860 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 19 Sep 2020 12:17:26 -0400 Subject: [PATCH 24/24] Define the halving interval, initial transition period and fix format string bug --- src/komodo_utils.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index f134e9957..9cf26d6ba 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1549,7 +1549,10 @@ uint64_t komodo_max_money() uint64_t hush_block_subsidy(int height) { uint64_t subsidy = 0; - int32_t HALVING1 = GetArg("-z2zheight",340000), + int32_t HALVING1 = GetArg("-z2zheight",340000); + //TODO: support INTERVAL :( + //int32_t INTERVAL = GetArg("-ac_halving1",840000); + int32_t TRANSITION = 129; if (height < TRANSITION) { if(fDebug) @@ -1627,7 +1630,7 @@ uint64_t hush_block_subsidy(int height) } } if(fDebug) - fprintf(stderr,"%s: subsidy=%ul at height=%d\n",__func__,subsidy,height); + fprintf(stderr,"%s: subsidy=%lu at height=%d\n",__func__,subsidy,height); return subsidy; }