From 04710fdf01dedacce9a0cf293454e8b558b705f8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 13:55:33 -1100 Subject: [PATCH 01/11] -const in CBlockIndexWorkComparator https://github.com/jl777/komodo/issues/1606 --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index e01cba61f..a8f333aa8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -147,7 +147,7 @@ namespace { struct CBlockIndexWorkComparator { - bool operator()(const CBlockIndex *pa, const CBlockIndex *pb) const { + bool operator()(CBlockIndex *pa, const CBlockIndex *pb) const { // First sort by most total work, ... if (ASSETCHAINS_LWMAPOS) { From eb1bc0cc0ce2da863ce51917200fc9b3ed5b612a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 05:21:05 -1100 Subject: [PATCH 02/11] Test ASSETCHAINS_MAX_ERAS+1 --- src/komodo_defs.h | 2 +- src/komodo_globals.h | 2 +- src/main.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 5074b4303..748f9ee7a 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -274,7 +274,7 @@ extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH,ASSETCHAINS_EQUIHASH,KOM extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,KOMODO_ON_DEMAND,KOMODO_PASSPORT_INITDONE,ASSETCHAINS_STAKED; extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_LASTERA,ASSETCHAINS_CBOPRET; extern bool VERUS_MINTBLOCKS; -extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[],ASSETCHAINS_NK[2]; +extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[],ASSETCHAINS_NK[2]; extern const char *ASSETCHAINS_ALGORITHMS[]; extern int32_t VERUS_MIN_STAKEAGE; extern uint32_t ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV1_1, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[]; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 9ffa147ea..c350020b6 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -74,7 +74,7 @@ uint64_t ASSETCHAINS_TIMELOCKGTE = _ASSETCHAINS_TIMELOCKOFF; uint64_t ASSETCHAINS_TIMEUNLOCKFROM = 0, ASSETCHAINS_TIMEUNLOCKTO = 0,ASSETCHAINS_CBOPRET=0; uint64_t ASSETCHAINS_LASTERA = 1; -uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS]; +uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS+1]; uint8_t ASSETCHAINS_CCDISABLES[256]; std::vector ASSETCHAINS_PRICES,ASSETCHAINS_STOCKS; diff --git a/src/main.cpp b/src/main.cpp index a8f333aa8..34708bef7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2407,7 +2407,7 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW) //uint64_t komodo_moneysupply(int32_t height); extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; -extern uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS]; +extern uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS+1]; extern uint32_t ASSETCHAINS_MAGIC; extern uint64_t ASSETCHAINS_LINEAR,ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY; extern uint8_t ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; From 6024c775ac435c194e86c17c9d4d23e55f83f4b3 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Thu, 11 Jul 2019 11:42:52 -0700 Subject: [PATCH 03/11] Initial port of Hush supply curve to KMD --- src/komodo_bitcoind.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 48962b015..9882ef33c 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1266,6 +1266,37 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) nSubsidy = GetBlockSubsidy(height,Params().GetConsensus()); //fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); + + if ((strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) != 0)) { + int32_t starting_commission = 125000000, HALVING1 = 340000, INTERVAL = 840000, TRANSITION = 129, BR_END = 5422111; + // 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 + // 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 + if (height < TRANSITION) { + commission = 0; + } else if (height < HALVING1) { + commission = starting_commission; + } else if (height < HALVING1+1*INTERVAL) { + commission = starting_commission / 2; + } else if (height < HALVING1+2*INTERVAL) { + commission = starting_commission / 4; + } else if (height < HALVING1+3*INTERVAL) { + commission = starting_commission / 8; + } else if (height < HALVING1+4*INTERVAL) { + commission = starting_commission / 16; + } else if (height < HALVING1+5*INTERVAL) { + commission = starting_commission / 32; + } else if (height < HALVING1+6*INTERVAL) { // Block 5380000 + // Block reward will go to zero between 7th+8th halvings, ac_end may need adjusting + commission = starting_commission / 64; + } else if (height < HALVING1+7*INTERVAL) { + // Block reward will be zero before this is ever reached + commission = starting_commission / 128; // Block 6220000 + } + } + if ( ASSETCHAINS_FOUNDERS > 1 ) { if ( (height % ASSETCHAINS_FOUNDERS) == 0 ) From 7d8928c5e9234af6102d291faf1a4b3c62574f4d Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 12 Jul 2019 05:43:49 -0400 Subject: [PATCH 04/11] Use strncmp correctly --- 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 9882ef33c..312e2eda1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1267,7 +1267,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) //fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); - if ((strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) != 0)) { + if ((strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0)) { int32_t starting_commission = 125000000, HALVING1 = 340000, INTERVAL = 840000, TRANSITION = 129, BR_END = 5422111; // 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 From 38064092949b722a0629653973a5576809335bee Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 12 Jul 2019 11:37:01 -0400 Subject: [PATCH 05/11] Optimize check for HUSH3 in komodo_commission --- src/komodo_bitcoind.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 312e2eda1..20e0f3b90 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1256,10 +1256,16 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); uint64_t komodo_commission(const CBlock *pblock,int32_t height) { + static bool didinit = false,ishush3 = false; // LABS fungible chains, cannot have any block reward! if ( is_STAKED(ASSETCHAINS_SYMBOL) == 2 ) return(0); + if (!didinit) { + ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; + didinit = true; + } + int32_t i,j,n=0,txn_count; int64_t nSubsidy; uint64_t commission,total = 0; if ( ASSETCHAINS_FOUNDERS != 0 ) { @@ -1267,7 +1273,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) //fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); - if ((strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0)) { + if (ishush3) { int32_t starting_commission = 125000000, HALVING1 = 340000, INTERVAL = 840000, TRANSITION = 129, BR_END = 5422111; // 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 From f0398720dd51b271286226d5f73b59b81a321870 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Fri, 12 Jul 2019 10:28:01 -0700 Subject: [PATCH 06/11] Add hush convenience scripts --- src/hush-cli | 11 +++++++++++ src/hushd | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100755 src/hush-cli create mode 100755 src/hushd diff --git a/src/hush-cli b/src/hush-cli new file mode 100755 index 000000000..efa1840a6 --- /dev/null +++ b/src/hush-cli @@ -0,0 +1,11 @@ +#!/bin/bash +# Copyright (c) 2019 Hush developers + +# set working directory to the location of this script +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd $DIR + +NAME=HUSH3 + +CLI=${KOMODOCLI:-./komodo-cli} +$CLI -ac_name=$NAME "$@" diff --git a/src/hushd b/src/hushd new file mode 100755 index 000000000..949779a90 --- /dev/null +++ b/src/hushd @@ -0,0 +1,52 @@ +#!/bin/bash +# Copyright (c) 2019 Hush developers + +# set working directory to the location of this script +DIR="$( cd "$( dirname "$( readlink -f "${BASH_SOURCE[0]}" )" )" && pwd )" +cd $DIR + +NAME=HUSH3 +# this corresponds to FR address RHushEyeDm7XwtaTWtyCbjGQumYyV8vMjn +SCRIPT=76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac + +# Chain parameters +ERAS=3 +BLOCKTIME=150 +# 6250000 - (sprout pool at block 500,000) +SUPPLY=6178674 +FOUNDERS=1 +REWARD=0,1125000000,562500000 +PERC=11111111 +HALVING=129,340000,840000 +# NOTE: keep in sync with komodo_bitcoind.h +END=128,340000,5422111 +CLIENTNAME=GoldenSandtrout +SEEDNODE1=188.165.212.101 +SEEDNODE2=136.243.227.142 +SEEDNODE3=5.9.224.250 +CCLIB=hush3 + +# CryptoConditions/Custom Consensus params +FAUCET=228 +HEIR=234 +CHANNEL=235 +ORACLE=236 +GATEWAY=241 +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 \ + -addnode=$SEEDNODE1 \ + -addnode=$SEEDNODE2 \ + -addnode=$SEEDNODE3 \ + -ac_cclib=$CCLIB \ + -ac_script=$SCRIPT "$@" From 9b474d444756e2a84b958b3f4b0f29b9e9b0c320 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Fri, 12 Jul 2019 10:38:27 -0700 Subject: [PATCH 07/11] Add HUSH3 to assetchains.(old|json) --- src/assetchains.json | 22 ++++++++++++++++++++++ src/assetchains.old | 1 + 2 files changed, 23 insertions(+) diff --git a/src/assetchains.json b/src/assetchains.json index 86dc77565..910f19dd3 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -268,5 +268,27 @@ "ac_supply": "64000777", "ac_staked": "10", "addnode": ["18.197.20.21"] + }, + { + "ac_name": "HUSH3", + "ac_founders": "1", + "ac_reward": "0,1125000000,562500000" + "ac_end": "128,340000,5422111", + "ac_blocktime": "150", + "ac_supply": "6178674", + "ac_halving": "129,340000,840000", + "ac_cc": "2", + "ac_cclib": "hush3", + "ac_ccenable": "228,234,235,236,241", + "ac_supply": "100000000", + "ac_eras": "3", + "ac_script": "76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac", + "ac_sapling": "1", + "clientname": "GoldenSandtrout", + "addnode": [ + "188.165.212.101", + "136.243.227.142", + "5.9.224.250" + ] } ] diff --git a/src/assetchains.old b/src/assetchains.old index 1784bf2e1..8ee0b7daa 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -52,3 +52,4 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=KOIN -ac_supply=125000000 -addnode=3.0.32.10 & ./komodod -pubkey=$pubkey -ac_name=ZEXO -ac_supply=100000000 -ac_reward=1478310502 -ac_halving=525600 -ac_cc=42 -ac_ccenable=236 -ac_perc=77700 -ac_staked=93 -ac_pubkey=02713bd85e054db923694b6b7a85306264edf4d6bd6d331814f2b40af444b3ebbc -ac_public=1 -addnode=80.240.17.222 & ./komodod -pubkey=$pubkey -ac_name=K64 -ac_supply=64000777 -ac_reward=0 -ac_staked=10 -addnode=18.197.20.211 & +./komodod -pubkey=$pubkey -ac_name=HUSH3 -ac_sapling=1 -ac_reward=0,1125000000,562500000 -ac_halving=129,340000,840000 -ac_end=128,340000,5422111 -ac_eras=3 -ac_blocktime=150 -ac_cc=2 -ac_ccenable=228,234,235,236,241 -ac_founders=1 -ac_supply=6178674 -ac_perc=11111111 -clientname=GoldenSandtrout -addnode=188.165.212.101 -addnode=136.243.227.142 -addnode=5.9.224.250 -ac_cclib=hush3 -ac_script=76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac & From 8f5cbc8af21d0e1b8c04ad8405088d3fa8953ff5 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Fri, 12 Jul 2019 10:55:31 -0700 Subject: [PATCH 08/11] Missing comma --- src/assetchains.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assetchains.json b/src/assetchains.json index 910f19dd3..0b4b1644e 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -272,7 +272,7 @@ { "ac_name": "HUSH3", "ac_founders": "1", - "ac_reward": "0,1125000000,562500000" + "ac_reward": "0,1125000000,562500000", "ac_end": "128,340000,5422111", "ac_blocktime": "150", "ac_supply": "6178674", From 7d5af489141d79879710d65715137bdefe4f6eca Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Fri, 12 Jul 2019 10:59:36 -0700 Subject: [PATCH 09/11] Remove duplicate ac_supply and add ac_perc --- src/assetchains.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/assetchains.json b/src/assetchains.json index 0b4b1644e..20dd04ee2 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -271,6 +271,7 @@ }, { "ac_name": "HUSH3", + "ac_sapling": "1", "ac_founders": "1", "ac_reward": "0,1125000000,562500000", "ac_end": "128,340000,5422111", @@ -280,10 +281,9 @@ "ac_cc": "2", "ac_cclib": "hush3", "ac_ccenable": "228,234,235,236,241", - "ac_supply": "100000000", + "ac_perc": "11111111", "ac_eras": "3", "ac_script": "76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac", - "ac_sapling": "1", "clientname": "GoldenSandtrout", "addnode": [ "188.165.212.101", From d9617c68fd51617d3cb005d94f6b2ea49c8fbdd9 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Fri, 12 Jul 2019 11:05:56 -0700 Subject: [PATCH 10/11] Add fiat script --- src/fiat/hush | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 src/fiat/hush diff --git a/src/fiat/hush b/src/fiat/hush new file mode 100755 index 000000000..3d7a3425d --- /dev/null +++ b/src/fiat/hush @@ -0,0 +1,7 @@ +#!/bin/bash + +#set working directory to the location of this script +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd $DIR + +../komodo-cli -ac_name=HUSH3 "$@" From 152c86ce849b349b3e905a4e4e1832c80ca7a66f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 16:39:33 -1100 Subject: [PATCH 11/11] Fix MAXERAS crash (split array overflow) --- src/komodo_defs.h | 2 +- src/komodo_globals.h | 2 +- src/komodo_utils.h | 16 ++++++++-------- src/main.cpp | 2 +- src/util.cpp | 4 ++-- src/util.h | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 748f9ee7a..5074b4303 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -274,7 +274,7 @@ extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH,ASSETCHAINS_EQUIHASH,KOM extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,KOMODO_ON_DEMAND,KOMODO_PASSPORT_INITDONE,ASSETCHAINS_STAKED; extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_LASTERA,ASSETCHAINS_CBOPRET; extern bool VERUS_MINTBLOCKS; -extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[],ASSETCHAINS_NK[2]; +extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[],ASSETCHAINS_NK[2]; extern const char *ASSETCHAINS_ALGORITHMS[]; extern int32_t VERUS_MIN_STAKEAGE; extern uint32_t ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV1_1, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[]; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index c350020b6..9ffa147ea 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -74,7 +74,7 @@ uint64_t ASSETCHAINS_TIMELOCKGTE = _ASSETCHAINS_TIMELOCKOFF; uint64_t ASSETCHAINS_TIMEUNLOCKFROM = 0, ASSETCHAINS_TIMEUNLOCKTO = 0,ASSETCHAINS_CBOPRET=0; uint64_t ASSETCHAINS_LASTERA = 1; -uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS+1]; +uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS]; uint8_t ASSETCHAINS_CCDISABLES[256]; std::vector ASSETCHAINS_PRICES,ASSETCHAINS_STOCKS; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 57d652309..ab58326af 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1758,10 +1758,10 @@ void komodo_args(char *argv0) ASSETCHAINS_PUBLIC = GetArg("-ac_public",0); ASSETCHAINS_PRIVATE = GetArg("-ac_private",0); KOMODO_SNAPSHOT_INTERVAL = GetArg("-ac_snapshot",0); - Split(GetArg("-ac_nk",""), ASSETCHAINS_NK, 0); + Split(GetArg("-ac_nk",""), sizeof(ASSETCHAINS_NK)/sizeof(*ASSETCHAINS_NK), ASSETCHAINS_NK, 0); // -ac_ccactivateht=evalcode,height,evalcode,height,evalcode,height.... - Split(GetArg("-ac_ccactivateht",""), ccEnablesHeight, 0); + Split(GetArg("-ac_ccactivateht",""), sizeof(ccEnablesHeight)/sizeof(*ccEnablesHeight), ccEnablesHeight, 0); // fill map with all eval codes and activation height of 0. for ( int i = 0; i < 256; i++ ) mapHeightEvalActivate[i] = 0; @@ -1833,11 +1833,11 @@ void komodo_args(char *argv0) ASSETCHAINS_TIMEUNLOCKFROM = ASSETCHAINS_TIMEUNLOCKTO = 0; } - Split(GetArg("-ac_end",""), ASSETCHAINS_ENDSUBSIDY, 0); - Split(GetArg("-ac_reward",""), ASSETCHAINS_REWARD, 0); - Split(GetArg("-ac_halving",""), ASSETCHAINS_HALVING, 0); - Split(GetArg("-ac_decay",""), ASSETCHAINS_DECAY, 0); - Split(GetArg("-ac_notarypay",""), ASSETCHAINS_NOTARY_PAY, 0); + Split(GetArg("-ac_end",""), sizeof(ASSETCHAINS_ENDSUBSIDY)/sizeof(*ASSETCHAINS_ENDSUBSIDY), ASSETCHAINS_ENDSUBSIDY, 0); + Split(GetArg("-ac_reward",""), sizeof(ASSETCHAINS_REWARD)/sizeof(*ASSETCHAINS_REWARD), ASSETCHAINS_REWARD, 0); + Split(GetArg("-ac_halving",""), sizeof(ASSETCHAINS_HALVING)/sizeof(*ASSETCHAINS_HALVING), ASSETCHAINS_HALVING, 0); + Split(GetArg("-ac_decay",""), sizeof(ASSETCHAINS_DECAY)/sizeof(*ASSETCHAINS_DECAY), ASSETCHAINS_DECAY, 0); + Split(GetArg("-ac_notarypay",""), sizeof(ASSETCHAINS_NOTARY_PAY)/sizeof(*ASSETCHAINS_NOTARY_PAY), ASSETCHAINS_NOTARY_PAY, 0); for ( int i = 0; i < ASSETCHAINS_MAX_ERAS; i++ ) { @@ -1906,7 +1906,7 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_CC != 0 ) { ASSETCHAINS_CCLIB = GetArg("-ac_cclib",""); - Split(GetArg("-ac_ccenable",""), ccenables, 0); + Split(GetArg("-ac_ccenable",""), sizeof(ccenables)/sizeof(*ccenables), ccenables, 0); for (i=nonz=0; i<0x100; i++) { if ( ccenables[i] != 0 ) diff --git a/src/main.cpp b/src/main.cpp index 34708bef7..a8f333aa8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2407,7 +2407,7 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW) //uint64_t komodo_moneysupply(int32_t height); extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; -extern uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS+1]; +extern uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS]; extern uint32_t ASSETCHAINS_MAGIC; extern uint64_t ASSETCHAINS_LINEAR,ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY; extern uint8_t ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; diff --git a/src/util.cpp b/src/util.cpp index 1aa079085..9daecb63e 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -414,7 +414,7 @@ void SplitStr(const std::string& strVal, std::vector &outVals) } } -void Split(const std::string& strVal, uint64_t *outVals, const uint64_t nDefault) +void Split(const std::string& strVal, int32_t outsize, uint64_t *outVals, const uint64_t nDefault) { stringstream ss(strVal); vector vec; @@ -442,7 +442,7 @@ void Split(const std::string& strVal, uint64_t *outVals, const uint64_t nDefault else nLast = nDefault; - for ( i = numVals; i < ASSETCHAINS_MAX_ERAS; i++ ) + for ( i = numVals; i < outsize; i++ ) { outVals[i] = nLast; } diff --git a/src/util.h b/src/util.h index 617faaf36..17bf19952 100644 --- a/src/util.h +++ b/src/util.h @@ -185,7 +185,7 @@ inline bool IsSwitchChar(char c) * else if the string has fewer than _MAX_ERAS entries, then the last * entry fills remaining entries */ -void Split(const std::string& strVal, uint64_t *outVals, uint64_t nDefault); +void Split(const std::string& strVal, int32_t outsize, uint64_t *outVals, uint64_t nDefault); /** * Return string argument or default value