From 30643f4994d8d74db576b46072d903d6a08bc379 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Fri, 12 Apr 2019 20:23:04 -0700 Subject: [PATCH] Stop using eras and hardcode HUSH subsidy/FR --- src/hushd-testnet | 15 ++---- src/komodo_bitcoind.h | 19 +++---- src/komodo_utils.h | 117 +++++++++++------------------------------- 3 files changed, 41 insertions(+), 110 deletions(-) diff --git a/src/hushd-testnet b/src/hushd-testnet index a68c4b04b..954001363 100755 --- a/src/hushd-testnet +++ b/src/hushd-testnet @@ -6,19 +6,14 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $DIR # TESTING VALUES, DO NOT USE EXCEPT FOR DEVELOPMENT -NAME=HUSHT4 +NAME=HUSHT5 # this corresponds to FR address RHushEyeDm7XwtaTWtyCbjGQumYyV8vMjn SCRIPT=76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac # Chain parameters -ERAS=3 -BLOCKTIME=150 +BLOCKTIME=10 SUPPLY=6250000 FOUNDERS=1 -REWARD=0,1125000000,562500000 -PERC=11111111 -HALVING=29,34,84 -END=28,34,500 CLIENTNAME=GoldenSandtrout # CryptoConditions/Custom Consensus params @@ -27,17 +22,13 @@ HEIR=234 CHANNEL=235 ORACLE=236 GATEWAY=241 +DILITHIUM= CCENABLE=$FAUCET,$HEIR,$CHANNEL,$ORACLE,$GATEWAY KMD=${KOMODOD:-./komodod} $KMD -ac_name=$NAME -ac_sapling=1 \ - -ac_reward=$REWARD \ - -ac_halving=$HALVING \ - -ac_end=$END \ - -ac_eras=$ERAS \ -ac_blocktime=$BLOCKTIME \ -ac_cc=2 -ac_ccenable=$CCENABLE \ -ac_founders=$FOUNDERS -ac_supply=$SUPPLY \ - -ac_perc=$PERC \ -clientname=$CLIENTNAME \ -ac_script=$SCRIPT "$@" diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 29caa6a85..5bde4a773 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1215,15 +1215,14 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) // prod values //int32_t starting_commission = 125000000, HALVING1 = 340000, INTERVAL = 840000, TRANSITION = 129, BR_END = 5422111; // testnet values - int64_t starting_commission = 125000000, HALVING1 = 142, INTERVAL = 84, TRANSITION = 29, BR_END = 500; + int64_t starting_commission = 125000000, HALVING1 = 34, INTERVAL = 84, TRANSITION = 29, BR_END = 500; nSubsidy = GetBlockSubsidy(height,Params().GetConsensus()); commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); fprintf(stderr,"ORIG ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); - if ((strcmp(ASSETCHAINS_SYMBOL, "HUSH") != 0) || (strcmp(ASSETCHAINS_SYMBOL, "HUSHT4") != 0)) { - // HUSH supply curve cannot be exactly represented via KMD AC CLI args, so we do it ourselves. - // 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 + if ((strcmp(ASSETCHAINS_SYMBOL, "HUSH") != 0) || (strcmp(ASSETCHAINS_SYMBOL, "HUSHT5") != 0)) { + // HUSH supply curve cannot be exactly represented via KMD AC CLI args, so we do it manually + // 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 // Transition period of 128 blocks has BR=FR=0 @@ -1241,15 +1240,13 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) commission = starting_commission / 16; } else if (height < HALVING1+5*INTERVAL) { commission = starting_commission / 32; - } else if (height < HALVING1+6*INTERVAL) { + } else if (height < HALVING1+6*INTERVAL) { // Block 5380000 + // Block reward will go to zero between 7th+8th halvings commission = starting_commission / 64; - } else if (height < HALVING1+7*INTERVAL) { + } else if (height < HALVING1+7*INTERVAL) { // Block 6220000 commission = starting_commission / 128; - } else if (height < HALVING1+8*INTERVAL) { + } else if (height < HALVING1+8*INTERVAL) { // Block 7060000 commission = starting_commission / 256; - } else if (height < HALVING1+9*INTERVAL) { - // HUSH should never hit the 9th halving, but yolo - commission = starting_commission / 512; } // enforce the end of FR when BR ends diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 079ce1eea..b014afa32 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1570,96 +1570,39 @@ uint64_t komodo_max_money() uint64_t komodo_ac_block_subsidy(int nHeight) { - // we have to find our 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; - static uint64_t cached_subsidy; static int32_t cached_numhalvings; static int cached_era; - - // check for backwards compat, older chains with no explicit rewards had 0.0001 block reward - if ( ASSETCHAINS_ENDSUBSIDY[0] == 0 && ASSETCHAINS_REWARD[0] == 0 ) - subsidy = 10000; - else if ( (ASSETCHAINS_ENDSUBSIDY[0] == 0 && ASSETCHAINS_REWARD[0] != 0) || ASSETCHAINS_ENDSUBSIDY[0] != 0 ) - { - // if we have an end block in the first era, find our current era - if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 ) - { - for ( curEra = 0; curEra <= ASSETCHAINS_LASTERA; curEra++ ) - { - if ( ASSETCHAINS_ENDSUBSIDY[curEra] > nHeight || ASSETCHAINS_ENDSUBSIDY[curEra] == 0 ) - break; - } - } - if ( curEra <= ASSETCHAINS_LASTERA ) - { - int64_t nStart = curEra ? ASSETCHAINS_ENDSUBSIDY[curEra - 1] : 0; - subsidy = (int64_t)ASSETCHAINS_REWARD[curEra]; - if ( subsidy || (curEra != ASSETCHAINS_LASTERA && ASSETCHAINS_REWARD[curEra + 1] != 0) ) - { - if ( ASSETCHAINS_HALVING[curEra] != 0 ) - { - if ( (numhalvings = ((nHeight - nStart) / ASSETCHAINS_HALVING[curEra])) > 0 ) - { - if ( ASSETCHAINS_DECAY[curEra] == 0 ) - subsidy >>= numhalvings; - else if ( ASSETCHAINS_DECAY[curEra] == 100000000 && ASSETCHAINS_ENDSUBSIDY[curEra] != 0 ) - { - if ( curEra == ASSETCHAINS_LASTERA ) - { - subsidyDifference = subsidy; - } - else - { - // Ex: -ac_eras=3 -ac_reward=0,384,24 -ac_end=1440,260640,0 -ac_halving=1,1440,2103840 -ac_decay 100000000,97750000,0 - subsidyDifference = subsidy - ASSETCHAINS_REWARD[curEra + 1]; - if (subsidyDifference < 0) - { - sign = -1; - subsidyDifference *= sign; - } - } - denominator = ASSETCHAINS_ENDSUBSIDY[curEra] - nStart; - numerator = denominator - ((ASSETCHAINS_ENDSUBSIDY[curEra] - nHeight) + ((nHeight - nStart) % ASSETCHAINS_HALVING[curEra])); - subsidy = subsidy - sign * ((subsidyDifference * numerator) / denominator); - } - else - { - if ( cached_subsidy > 0 && cached_era == curEra && cached_numhalvings == numhalvings ) - subsidy = cached_subsidy; - else - { - for (int i=0; i < numhalvings && subsidy != 0; i++) - subsidy = (subsidy * ASSETCHAINS_DECAY[curEra]) / 100000000; - cached_subsidy = subsidy; - cached_numhalvings = numhalvings; - cached_era = curEra; - } - } - } - } - } - } - } uint32_t magicExtra = ASSETCHAINS_STAKED ? ASSETCHAINS_MAGIC : (ASSETCHAINS_MAGIC & 0xffffff); - if ( ASSETCHAINS_SUPPLY > 10000000000 ) // over 10 billion? - { - if ( nHeight <= ASSETCHAINS_SUPPLY/1000000000 ) - { - subsidy += (uint64_t)1000000000 * COIN; - if ( nHeight == 1 ) - subsidy += (ASSETCHAINS_SUPPLY % 1000000000)*COIN + magicExtra; - } + //TODO: unify with values in komodo_bitcoind.h + int64_t subsidy = 0, starting_subsidy = 1125000000, HALVING1 = 34, INTERVAL = 84, TRANSITION = 29, BR_END = 500; + + if ( nHeight == 1 ) { + subsidy = ASSETCHAINS_SUPPLY * SATOSHIDEN + magicExtra; + } else if (nHeight < TRANSITION) { + subsidy = 0; + } else if (nHeight < HALVING1) { + subsidy = starting_subsidy; + } else if (nHeight < HALVING1+1*INTERVAL) { + subsidy = starting_subsidy / 2; + } else if (nHeight < HALVING1+2*INTERVAL) { + subsidy = starting_subsidy / 4; + } else if (nHeight < HALVING1+3*INTERVAL) { + subsidy = starting_subsidy / 8; + } else if (nHeight < HALVING1+4*INTERVAL) { + subsidy = starting_subsidy / 16; + } else if (nHeight < HALVING1+5*INTERVAL) { + subsidy = starting_subsidy / 32; + } else if (nHeight < HALVING1+6*INTERVAL) { + subsidy = starting_subsidy / 64; + } else if (nHeight < HALVING1+7*INTERVAL) { + subsidy = starting_subsidy / 128; + } else if (nHeight < HALVING1+8*INTERVAL) { + subsidy = starting_subsidy / 256; } - else if ( nHeight == 1 ) - { - if ( ASSETCHAINS_LASTERA == 0 ) - subsidy = ASSETCHAINS_SUPPLY * SATOSHIDEN + magicExtra; - else - subsidy += ASSETCHAINS_SUPPLY * SATOSHIDEN + magicExtra; + + // enforce the end of subsidy + if (nHeight > BR_END) { + subsidy = 0; } - else if ( is_STAKED(ASSETCHAINS_SYMBOL) == 2 ) - return(0); - // LABS fungible chains, cannot have any block reward! + return(subsidy); }