From 992ae6c58e0990f9fa4118502cb8c59c5d8461e0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 09:05:10 -1100 Subject: [PATCH 01/49] -print --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 12433f1e8..2100b59ed 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3779,7 +3779,7 @@ bool CheckBlockHeader(int32_t *futureblockp,int32_t height,CBlockIndex *pindex, { if (blockhdr.GetBlockTime() < GetAdjustedTime() + 600) *futureblockp = 1; - LogPrintf("CheckBlockHeader block from future %d error",blockhdr.GetBlockTime() - GetAdjustedTime()); + //LogPrintf("CheckBlockHeader block from future %d error",blockhdr.GetBlockTime() - GetAdjustedTime()); return false; //state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"),REJECT_INVALID, "time-too-new"); } } From 97d48e24058dbba791c3c80f89ac804575ed9f6b Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sat, 2 Jun 2018 22:17:18 -0700 Subject: [PATCH 02/49] Add missing ZCVIEWING_KEY to base58Prefixes --- src/chainparams.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index d78e1351b..e90fc23f0 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -173,6 +173,8 @@ public: base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x88)(0xAD)(0xE4).convert_to_container >(); // guarantees the first two characters, when base58 encoded, are "zc" base58Prefixes[ZCPAYMENT_ADDRRESS] = {22,154}; + // guarantees the first 4 characters, when base58 encoded, are "ZiVK" + base58Prefixes[ZCVIEWING_KEY] = {0xA8,0xAB,0xD3}; // guarantees the first two characters, when base58 encoded, are "SK" base58Prefixes[ZCSPENDING_KEY] = {171,54}; @@ -467,6 +469,8 @@ public: base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x35)(0x87)(0xCF).convert_to_container >(); base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x35)(0x83)(0x94).convert_to_container >(); base58Prefixes[ZCPAYMENT_ADDRRESS] = {20,81}; + // guarantees the first 4 characters, when base58 encoded, are "ZiVt" + base58Prefixes[ZCVIEWING_KEY] = {0xA8,0xAC,0x0C}; base58Prefixes[ZCSPENDING_KEY] = {177,235}; vFixedSeeds = std::vector(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test)); From 30999b9c129b4af030cb3fa0afb1414da9d7ca24 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 3 Jun 2018 00:52:55 -1100 Subject: [PATCH 03/49] Test --- src/komodo_gateway.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3b2922a7b..1ab58b04a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -747,17 +747,18 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim if ( ASSETCHAINS_COMMISSION != 0 && height > 1 ) { if ( (checktoshis= komodo_checkcommission((CBlock *)&block,height)) < 0 ) - return(-1); - } - else - { - if ( overflow != 0 || total > checktoshis || strangeout != 0 ) { - if ( strangeout != 0 ) - fprintf(stderr,">>>>>>>>>>>>> %s DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",ASSETCHAINS_SYMBOL,height,strangeout,notmatched); + fprintf(stderr,"ht.%d checktoshis %.8f overflow.%d total %.8f strangeout.%d\n",height,dstr(checktoshis),overflow,dstr(total),strangeout); return(-1); } } + if ( overflow != 0 || total > checktoshis || strangeout != 0 ) + { + fprintf(stderr,"checkdeposit: ht.%d checktoshis %.8f overflow.%d total %.8f strangeout.%d\n",height,dstr(checktoshis),overflow,dstr(total),strangeout); + if ( strangeout != 0 ) + fprintf(stderr,">>>>>>>>>>>>> %s DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",ASSETCHAINS_SYMBOL,height,strangeout,notmatched); + return(-1); + } } return(0); } From d630af57fbfe083c16bc6b7d70ae13b1e920c43d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 3 Jun 2018 00:55:40 -1100 Subject: [PATCH 04/49] Test --- src/komodo_gateway.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1ab58b04a..9f008e3a0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -751,6 +751,8 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim fprintf(stderr,"ht.%d checktoshis %.8f overflow.%d total %.8f strangeout.%d\n",height,dstr(checktoshis),overflow,dstr(total),strangeout); return(-1); } + if ( height < 2 ) + return(0); } if ( overflow != 0 || total > checktoshis || strangeout != 0 ) { From b7aeaa2deb850c60d6a6bac60884d5b0debc589d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 3 Jun 2018 00:58:51 -1100 Subject: [PATCH 05/49] Test --- src/komodo_gateway.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9f008e3a0..5717a2586 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -751,10 +751,8 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim fprintf(stderr,"ht.%d checktoshis %.8f overflow.%d total %.8f strangeout.%d\n",height,dstr(checktoshis),overflow,dstr(total),strangeout); return(-1); } - if ( height < 2 ) - return(0); } - if ( overflow != 0 || total > checktoshis || strangeout != 0 ) + if ( height >= 2 && (overflow != 0 || total > checktoshis || strangeout != 0) ) { fprintf(stderr,"checkdeposit: ht.%d checktoshis %.8f overflow.%d total %.8f strangeout.%d\n",height,dstr(checktoshis),overflow,dstr(total),strangeout); if ( strangeout != 0 ) From 93b144ac35cefccf31e3ec558365ed54b545814a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 3 Jun 2018 02:54:03 -1100 Subject: [PATCH 06/49] KV fix --- src/komodo.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index d69768e8f..690e91248 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -598,14 +598,15 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } else { + if ( scriptbuf[len] == 'K' ) + { + fprintf(stderr,"i.%d j.%d KV OPRET len.%d %.8f\n",i,j,opretlen,dstr(value)); + komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen,j,zero,0); + return(-1); + } if ( strcmp(ASSETCHAINS_SYMBOL,(char *)&scriptbuf[len+32*2+4]) == 0 ) matched = 1; } - if ( scriptbuf[len] == 'K' ) - { - fprintf(stderr,"i.%d j.%d KV OPRET len.%d %.8f\n",i,j,opretlen,dstr(value)); - return(-1); - } offset = 32 * (1 + matched) + 4; nameoffset = (int32_t)strlen((char *)&scriptbuf[len+offset]); nameoffset++; From ceb6321c7ca18e9daf65d4ad2a7f0e781dfb0c5e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 3 Jun 2018 05:46:46 -1100 Subject: [PATCH 07/49] -print --- src/komodo_kv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_kv.h b/src/komodo_kv.h index 80fac5ff8..ee0496aae 100644 --- a/src/komodo_kv.h +++ b/src/komodo_kv.h @@ -111,7 +111,7 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value) if ( keylen+13 > opretlen ) { static uint32_t counter; - if ( ++counter < 100 ) + if ( ++counter < 1 ) fprintf(stderr,"komodo_kvupdate: keylen.%d + 13 > opretlen.%d, this can be ignored\n",keylen,opretlen); return; } From 181e67c617e7913f6c3ef728a6efa5a48f0389fe Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Jun 2018 03:35:21 -1100 Subject: [PATCH 08/49] Increase conversion rate for PoW high diff, breaking change for existing testchains --- 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 a5ef1ccab..12ba756fe 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1197,7 +1197,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he } else return(target); if ( percPoS < goalperc ) // increase PoW diff -> lower bnTarget { - bnTarget = (ave * arith_uint256(percPoS * percPoS)) / arith_uint256((goalperc) * (goalperc)); + bnTarget = (ave * arith_uint256(percPoS * percPoS)) / arith_uint256(goalperc * goalperc * goalperc); if ( 1 ) { for (i=31; i>=24; i--) From 5f20a85d14040ab92a0c368e9ee265d4607d7380 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Jun 2018 02:52:58 -1100 Subject: [PATCH 09/49] -genjson for komodo_port.c --- src/komodo_port.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/komodo_port.c b/src/komodo_port.c index 991be2013..14a97e159 100644 --- a/src/komodo_port.c +++ b/src/komodo_port.c @@ -826,7 +826,7 @@ uint16_t komodo_calcport(char *name,uint64_t supply,uint64_t endsubsidy,uint64_t int main(int argc, char * argv[]) { - uint16_t rpcport; int32_t i,j,offset=0,num = 1; uint64_t supply=10,commission=0,endsubsidy,reward,halving,decay; uint8_t *allocated=0,staked=0; uint32_t cc = 1; + uint16_t rpcport; int32_t i,j,offset=0,jsonflag=0,num = 1; uint64_t supply=10,commission=0,endsubsidy,reward,halving,decay; uint8_t *allocated=0,staked=0; uint32_t cc = 3; endsubsidy = reward = halving = decay = 0; if ( argc < 2 ) { @@ -835,9 +835,11 @@ int main(int argc, char * argv[]) printf("%s -gen num name supply endsubsidy reward halving decay\n",argv[0]); return(-1); } - if ( strcmp(argv[1],"-gen") == 0 ) + if ( strncmp(argv[1],"-gen",3) == 0 ) { num = atoi(argv[2]); + if ( strcmp(argv[1],"-genjson") == 0 ) + jsonflag = 1; offset = 2; allocated = calloc(1,1 << 16); } @@ -852,7 +854,7 @@ int main(int argc, char * argv[]) if ( argc > offset + 6 ) decay = (long long)atof(argv[offset + 6]); rpcport = 1 + komodo_calcport(argv[offset + 1],supply,endsubsidy,reward,halving,decay,commission,staked,cc); - printf("./komodod -ac_name=%s -ac_cc=%u -ac_supply=%llu -ac_end=%llu -ac_reward=%llu -ac_halving=%llu -ac_decay=%llu & # rpcport %u\n",argv[offset + 1],cc,(long long)supply,(long long)endsubsidy,(long long)reward,(long long)halving,(long long)decay,rpcport); + printf("./komodod -ac_name=%s -ac_cc=%u -ac_supply=%llu -ac_end=%llu -ac_reward=%llu -ac_halving=%llu -ac_decay=%llu & # rpcport %u\n[",argv[offset + 1],cc,(long long)supply,(long long)endsubsidy,(long long)reward,(long long)halving,(long long)decay,rpcport); if ( allocated != 0 ) { char name[64],newname[64]; @@ -868,7 +870,14 @@ int main(int argc, char * argv[]) rpcport = 1 + komodo_calcport(newname,supply+j,endsubsidy,reward,halving,decay,commission,staked,cc); if ( allocated[rpcport] == 0 && allocated[rpcport-1] == 0 ) { - printf("./komodod -ac_name=%s -ac_cc=%u -ac_supply=%llu -ac_end=%llu -ac_reward=%llu -ac_halving=%llu -ac_decay=%llu & # rpcport %u\n",newname,cc,(long long)supply+j,(long long)endsubsidy,(long long)reward,(long long)halving,(long long)decay,rpcport); + if ( jsonflag == 0 ) + { + printf("./komodod -ac_name=%s -ac_cc=%u -ac_supply=%llu -ac_end=%llu -ac_reward=%llu -ac_halving=%llu -ac_decay=%llu & # rpcport %u\n",newname,cc,(long long)supply+j,(long long)endsubsidy,(long long)reward,(long long)halving,(long long)decay,rpcport); + } + else + { + printf("{ \"assetname\": \"%s\", \"p2p\": %u, \"rpc\": %u, \"supply\": %llu, \"ac_cc\": %u, \"ac_reward\": %llu, \"notarize\": %s }%s ",newname,rpcport-1,rpcport,(long long)supply+j,cc,(long long)reward,i<64?"true":"false",i Date: Wed, 6 Jun 2018 03:22:13 -1100 Subject: [PATCH 10/49] Fix coinbasevalue --- src/rpcmining.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index e3341144a..f7c99b1c0 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -692,7 +692,8 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) // Correct this if GetBlockTemplate changes the order // entry.push_back(Pair("foundersreward", (int64_t)tx.vout[1].nValue)); //} - entry.push_back(Pair("coinbasevalue", 3*COIN)); + CAmount nReward = GetBlockSubsidy(chainActive.Tip()->nHeight+1, Params().GetConsensus()); + entry.push_back(Pair("coinbasevalue", nReward)); entry.push_back(Pair("required", true)); txCoinbase = entry; } else From 15d17928f89e83cbfcde77d408a91cfd74f05a56 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Jun 2018 07:06:40 -1100 Subject: [PATCH 11/49] Allow asset chains to have more coinbase vouts --- src/komodo_gateway.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5717a2586..9de6b4fc9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -752,6 +752,10 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim return(-1); } } + if ( height > 1 && checktoshis == 0 ) + { + checktoshis = ((uint64_t)GetBlockSubsidy(height, Params().GetConsensus()) - block.vtx[0].vout[0].nValue); + } if ( height >= 2 && (overflow != 0 || total > checktoshis || strangeout != 0) ) { fprintf(stderr,"checkdeposit: ht.%d checktoshis %.8f overflow.%d total %.8f strangeout.%d\n",height,dstr(checktoshis),overflow,dstr(total),strangeout); From acbc7a942a604af3c2ce84e5cb25ec04f926de17 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 7 Jun 2018 06:31:20 -1100 Subject: [PATCH 12/49] Segid to validate address --- src/komodo_bitcoind.h | 7 +++++++ src/rpcmisc.cpp | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 12ba756fe..32d34c700 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1080,6 +1080,13 @@ uint64_t komodo_commission(const CBlock *pblock) return(commission); } +uint32_t komodo_segid32(char *coinaddr) +{ + bits256 addrhash; + vcalc_sha256(0,(uint8_t *)&addrhash,(uint8_t *)address,(int32_t)strlen(address)); + return(addrhash.uints[0]); +} + uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeight,uint256 txid,int32_t vout,uint32_t blocktime,uint32_t prevtime,char *destaddr) { CBlockIndex *pindex; uint8_t hashbuf[128]; char address[64]; bits256 addrhash; arith_uint256 hashval; uint256 hash,pasthash; int64_t diff=0; int32_t segid,minage,i,iter=0; uint32_t txtime,winner = 0; uint64_t value,coinage,supply = ASSETCHAINS_SUPPLY + nHeight*ASSETCHAINS_REWARD/SATOSHIDEN; diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index c356ef994..95285b580 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -52,6 +52,7 @@ int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; +uint32_t komodo_segid32(char *coinaddr); int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp); #define KOMODO_VERSION "0.1.1" extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; @@ -326,7 +327,7 @@ UniValue validateaddress(const UniValue& params, bool fHelp) CScript scriptPubKey = GetScriptForDestination(dest); ret.push_back(Pair("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end()))); - + ret.push_back(Pair("segid", komodo_segid(address.c_str()) & 3f)); #ifdef ENABLE_WALLET isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); From 3001f999ecc5bfc29f733e144f82e51527ad1a6d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 7 Jun 2018 09:12:26 -1100 Subject: [PATCH 13/49] Syntax --- 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 32d34c700..44c3db942 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1083,7 +1083,7 @@ uint64_t komodo_commission(const CBlock *pblock) uint32_t komodo_segid32(char *coinaddr) { bits256 addrhash; - vcalc_sha256(0,(uint8_t *)&addrhash,(uint8_t *)address,(int32_t)strlen(address)); + vcalc_sha256(0,(uint8_t *)&addrhash,(uint8_t *)coinaddr,(int32_t)strlen(coinaddr)); return(addrhash.uints[0]); } From 584b784c57d80a8e3f41f6bb2a1756b0004bf485 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 7 Jun 2018 09:13:38 -1100 Subject: [PATCH 14/49] Fix --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 95285b580..ae3f48874 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -327,7 +327,7 @@ UniValue validateaddress(const UniValue& params, bool fHelp) CScript scriptPubKey = GetScriptForDestination(dest); ret.push_back(Pair("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end()))); - ret.push_back(Pair("segid", komodo_segid(address.c_str()) & 3f)); + ret.push_back(Pair("segid", komodo_segid(address.c_str()) & 0x3f)); #ifdef ENABLE_WALLET isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); From d23c6a06e7dbd3b3666bc3000d541aa3bcd327b4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 7 Jun 2018 09:15:13 -1100 Subject: [PATCH 15/49] c++ --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index ae3f48874..a09a4368b 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -327,7 +327,7 @@ UniValue validateaddress(const UniValue& params, bool fHelp) CScript scriptPubKey = GetScriptForDestination(dest); ret.push_back(Pair("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end()))); - ret.push_back(Pair("segid", komodo_segid(address.c_str()) & 0x3f)); + ret.push_back(Pair("segid", komodo_segid(params[0].get_str().c_str()) & 0x3f)); #ifdef ENABLE_WALLET isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); From cf266927980fcf07a3c5b2965fccd0fd1deb5d41 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 7 Jun 2018 09:15:52 -1100 Subject: [PATCH 16/49] Syntax --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index a09a4368b..27b72dd0c 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -327,7 +327,7 @@ UniValue validateaddress(const UniValue& params, bool fHelp) CScript scriptPubKey = GetScriptForDestination(dest); ret.push_back(Pair("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end()))); - ret.push_back(Pair("segid", komodo_segid(params[0].get_str().c_str()) & 0x3f)); + ret.push_back(Pair("segid", komodo_segid32(params[0].get_str().c_str()) & 0x3f)); #ifdef ENABLE_WALLET isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); From 1eb7f6169f85bfceb3808c3507439bec5994400c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 7 Jun 2018 09:17:08 -1100 Subject: [PATCH 17/49] c++ --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 27b72dd0c..bd22385d6 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -327,7 +327,7 @@ UniValue validateaddress(const UniValue& params, bool fHelp) CScript scriptPubKey = GetScriptForDestination(dest); ret.push_back(Pair("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end()))); - ret.push_back(Pair("segid", komodo_segid32(params[0].get_str().c_str()) & 0x3f)); + ret.push_back(Pair("segid", (int32_t)komodo_segid32(params[0].get_str().c_str()) & 0x3f)); #ifdef ENABLE_WALLET isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); From 7cf23c98155c2525eb1e6090f1a3141ede1937ba Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 7 Jun 2018 09:18:48 -1100 Subject: [PATCH 18/49] c++ --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index bd22385d6..278fb8866 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -327,7 +327,7 @@ UniValue validateaddress(const UniValue& params, bool fHelp) CScript scriptPubKey = GetScriptForDestination(dest); ret.push_back(Pair("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end()))); - ret.push_back(Pair("segid", (int32_t)komodo_segid32(params[0].get_str().c_str()) & 0x3f)); + ret.push_back(Pair("segid", (int32_t)komodo_segid32((char *)params[0].get_str().c_str()) & 0x3f)); #ifdef ENABLE_WALLET isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); From 16593898016ed2e020e6f9fda7e8f5d433b9bb84 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 7 Jun 2018 21:01:41 -1100 Subject: [PATCH 19/49] Prevent very long gap in blocks --- src/miner.cpp | 33 +++++++++++---------------------- src/miner.h | 5 +++-- src/rpcmining.cpp | 5 +++-- src/test/miner_tests.cpp | 26 +++++++++++++------------- 4 files changed, 30 insertions(+), 39 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index ef943b3aa..08fac7e22 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -124,10 +124,12 @@ uint64_t komodo_commission(const CBlock *block); int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig); int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33); -CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) +CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) { uint64_t deposits; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params(); // Create new block + if ( gpucount < 0 ) + gpucount = KOMODO_MAXGPUCOUNT; std::unique_ptr pblocktemplate(new CBlockTemplate()); if(!pblocktemplate.get()) { @@ -475,6 +477,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); if ( pblock->nTime < pindexPrev->nTime+65 ) pblock->nTime = pindexPrev->nTime + 65; + if ( gpucount < 33 ) + pblock->nTime += (rand() % (33 - gpucount)*(33 - gpucount)); if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33) > 0 ) { CAmount txfees = 5000; @@ -583,7 +587,7 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& // Internal miner // -CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight) +CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,int32_t gpucount) { CPubKey pubkey; CScript scriptPubKey; uint8_t *script,*ptr; int32_t i; if ( nHeight == 1 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) @@ -610,7 +614,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight) script[34] = OP_CHECKSIG; //scriptPubKey = CScript() << ToByteVector(pubkey) << OP_CHECKSIG; } - return CreateNewBlock(scriptPubKey); + return CreateNewBlock(scriptPubKey,gpucount); } void komodo_broadcast(CBlock *pblock,int32_t limit) @@ -717,7 +721,7 @@ void static BitcoinMiner() unsigned int n = chainparams.EquihashN(); unsigned int k = chainparams.EquihashK(); - uint8_t *script; uint64_t total,checktoshis; int32_t i,j,notaryid = -1; + uint8_t *script; uint64_t total,checktoshis; int32_t i,j,gpucount=KOMODO_MAXGPUCOUNT,notaryid = -1; while ( (ASSETCHAIN_INIT == 0 || KOMODO_INITDONE == 0) ) //chainActive.Tip()->nHeight != 235300 && { sleep(1); @@ -771,11 +775,6 @@ void static BitcoinMiner() //fprintf(stderr,"%s Found peers\n",ASSETCHAINS_SYMBOL); miningTimer.start(); } - /*while ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight < ASSETCHAINS_MINHEIGHT ) - { - fprintf(stderr,"%s waiting for block 100, ht.%d\n",ASSETCHAINS_SYMBOL,chainActive.Tip()->nHeight); - sleep(3); - }*/ // // Create new block // @@ -792,7 +791,7 @@ void static BitcoinMiner() sleep(3); } #ifdef ENABLE_WALLET - CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey,pindexPrev->nHeight+1); + CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey,pindexPrev->nHeight+1,gpucount); #else CBlockTemplate *ptr = CreateNewBlockWithKey(); #endif @@ -835,7 +834,7 @@ void static BitcoinMiner() // // Search // - uint8_t pubkeys[66][33]; uint32_t blocktimes[66]; int mids[256],gpucount,nonzpkeys,i,j,externalflag; uint32_t savebits; int64_t nStart = GetTime(); + uint8_t pubkeys[66][33]; uint32_t blocktimes[66]; int mids[256],nonzpkeys,i,j,externalflag; uint32_t savebits; int64_t nStart = GetTime(); savebits = pblock->nBits; HASHTarget = arith_uint256().SetCompact(pblock->nBits); roundrobin_delay = ROUNDROBIN_DELAY; @@ -874,18 +873,8 @@ void static BitcoinMiner() if ( mids[j] == -1 ) gpucount++; } - if ( gpucount > j/2 ) - { - double delta; - if ( notaryid < 0 ) - i = (rand() % 64); - else i = ((Mining_height + notaryid) % 64); - delta = sqrt((double)gpucount - j/2) / 2.; - roundrobin_delay += ((delta * i) / 64) - delta; - //fprintf(stderr,"delta.%f %f %f\n",delta,(double)(gpucount - j/3) / 2,(delta * i) / 64); - } if ( dispflag != 0 ) - fprintf(stderr," <- prev minerids from ht.%d notary.%d gpucount.%d %.2f%% t.%u %d\n",pindexPrev->nHeight,notaryid,gpucount,100.*(double)gpucount/j,(uint32_t)time(NULL),roundrobin_delay); + fprintf(stderr," <- prev minerids from ht.%d notary.%d gpucount.%d %.2f%% t.%u\n",pindexPrev->nHeight,notaryid,gpucount,100.*(double)gpucount/j,(uint32_t)time(NULL)); } for (j=0; j<65; j++) if ( mids[j] == notaryid ) diff --git a/src/miner.h b/src/miner.h index 684b10187..5486f2d5e 100644 --- a/src/miner.h +++ b/src/miner.h @@ -25,12 +25,13 @@ struct CBlockTemplate std::vector vTxFees; std::vector vTxSigOps; }; +#define KOMODO_MAXGPUCOUNT 65 /** Generate a new block, without valid proof-of-work */ -CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn); +CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount); #ifdef ENABLE_WALLET boost::optional GetMinerScriptPubKey(CReserveKey& reservekey); -CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight); +CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,int32_t gpucount); #else boost::optional GetMinerScriptPubKey(); CBlockTemplate* CreateNewBlockWithKey(); diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index f7c99b1c0..7f66f23f6 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -32,6 +32,7 @@ using namespace std; + /** * Return average network hashes per second based on the last 'lookup' blocks, * or over the difficulty averaging window if 'lookup' is nonpositive. @@ -214,7 +215,7 @@ UniValue generate(const UniValue& params, bool fHelp) lastTime = GetTime(); #ifdef ENABLE_WALLET - std::unique_ptr pblocktemplate(CreateNewBlockWithKey(reservekey,nHeight)); + std::unique_ptr pblocktemplate(CreateNewBlockWithKey(reservekey,nHeight,KOMODO_MAXGPUCOUNT)); #else std::unique_ptr pblocktemplate(CreateNewBlockWithKey()); #endif @@ -639,7 +640,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) } #ifdef ENABLE_WALLET CReserveKey reservekey(pwalletMain); - pblocktemplate = CreateNewBlockWithKey(reservekey,chainActive.Tip()->nHeight+1); + pblocktemplate = CreateNewBlockWithKey(reservekey,chainActive.Tip()->nHeight+1,KOMODO_MAXGPUCOUNT); #else pblocktemplate = CreateNewBlockWithKey(); #endif diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp index 7866d3ac1..3822a271d 100644 --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -158,7 +158,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) for (unsigned int i = 0; i < sizeof(blockinfo)/sizeof(*blockinfo); ++i) { // Simple block creation, nothing special yet: - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); CBlock *pblock = &pblocktemplate->block; // pointer for convenience pblock->nVersion = 4; @@ -270,7 +270,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) } // Just to make sure we can still make simple blocks - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); delete pblocktemplate; // block sigops > limit: 1000 CHECKMULTISIG + 1 @@ -289,7 +289,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx)); tx.vin[0].prevout.hash = hash; } - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); delete pblocktemplate; mempool.clear(); @@ -310,14 +310,14 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx)); tx.vin[0].prevout.hash = hash; } - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); delete pblocktemplate; mempool.clear(); // orphan in mempool hash = tx.GetHash(); mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx)); - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); delete pblocktemplate; mempool.clear(); @@ -335,7 +335,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) tx.vout[0].nValue = 49000LL; hash = tx.GetHash(); mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(true).FromTx(tx)); - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); delete pblocktemplate; mempool.clear(); @@ -346,7 +346,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) tx.vout[0].nValue = 0; hash = tx.GetHash(); mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(false).FromTx(tx)); - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); delete pblocktemplate; mempool.clear(); @@ -364,7 +364,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) tx.vout[0].nValue -= 10000; hash = tx.GetHash(); mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(false).FromTx(tx)); - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); delete pblocktemplate; mempool.clear(); @@ -378,17 +378,17 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) tx.vout[0].scriptPubKey = CScript() << OP_2; hash = tx.GetHash(); mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(true).FromTx(tx)); - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); delete pblocktemplate; mempool.clear(); // subsidy changing int nHeight = chainActive.Height(); chainActive.Tip()->nHeight = 209999; - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); delete pblocktemplate; chainActive.Tip()->nHeight = 210000; - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); delete pblocktemplate; chainActive.Tip()->nHeight = nHeight; @@ -420,7 +420,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(true).FromTx(tx2)); BOOST_CHECK(!CheckFinalTx(tx2, LOCKTIME_MEDIAN_TIME_PAST)); - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); // Neither tx should have made it into the template. BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 1); @@ -435,7 +435,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) //BOOST_CHECK(CheckFinalTx(tx)); //BOOST_CHECK(CheckFinalTx(tx2)); - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 2); delete pblocktemplate; From 7714b7f1430b6aa18941117a8363ce9c1a718a04 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 8 Jun 2018 02:15:46 -1100 Subject: [PATCH 20/49] Handle -disablewallet=1 --- src/wallet/rpcwallet.cpp | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 65dd0e22b..7187b8fe8 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2697,32 +2697,34 @@ UniValue listunspent(const UniValue& params, bool fHelp) uint64_t komodo_interestsum() { #ifdef ENABLE_WALLET - uint64_t interest,sum = 0; int32_t txheight; uint32_t locktime; - vector vecOutputs; - assert(pwalletMain != NULL); - LOCK2(cs_main, pwalletMain->cs_wallet); - pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); - BOOST_FOREACH(const COutput& out,vecOutputs) + if ( GetBoolArg("-disablewallet", false) == 0 ) { - CAmount nValue = out.tx->vout[out.i].nValue; - if ( out.tx->nLockTime != 0 && out.fSpendable != 0 ) + uint64_t interest,sum = 0; int32_t txheight; uint32_t locktime; + vector vecOutputs; + assert(pwalletMain != NULL); + LOCK2(cs_main, pwalletMain->cs_wallet); + pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); + BOOST_FOREACH(const COutput& out,vecOutputs) { - BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock()); - CBlockIndex *tipindex,*pindex = it->second; - if ( pindex != 0 && (tipindex= chainActive.Tip()) != 0 ) + CAmount nValue = out.tx->vout[out.i].nValue; + if ( out.tx->nLockTime != 0 && out.fSpendable != 0 ) { - interest = komodo_accrued_interest(&txheight,&locktime,out.tx->GetHash(),out.i,0,nValue,(int32_t)tipindex->nHeight); - //interest = komodo_interest(pindex->nHeight,nValue,out.tx->nLockTime,tipindex->nTime); - sum += interest; + BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock()); + CBlockIndex *tipindex,*pindex = it->second; + if ( pindex != 0 && (tipindex= chainActive.Tip()) != 0 ) + { + interest = komodo_accrued_interest(&txheight,&locktime,out.tx->GetHash(),out.i,0,nValue,(int32_t)tipindex->nHeight); + //interest = komodo_interest(pindex->nHeight,nValue,out.tx->nLockTime,tipindex->nTime); + sum += interest; + } } } + KOMODO_INTERESTSUM = sum; + KOMODO_WALLETBALANCE = pwalletMain->GetBalance(); + return(sum); } - KOMODO_INTERESTSUM = sum; - KOMODO_WALLETBALANCE = pwalletMain->GetBalance(); - return(sum); -#else - return(0); #endif + return(0); } UniValue fundrawtransaction(const UniValue& params, bool fHelp) From fa04bcf38c6cedabe80414c10e20ccf8189ba80d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 8 Jun 2018 05:17:25 -1100 Subject: [PATCH 21/49] 65 seconds to 60 --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 08fac7e22..35eb8e4d3 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -475,8 +475,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 ) { CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); - if ( pblock->nTime < pindexPrev->nTime+65 ) - pblock->nTime = pindexPrev->nTime + 65; + if ( pblock->nTime < pindexPrev->nTime+60 ) + pblock->nTime = pindexPrev->nTime + 60; if ( gpucount < 33 ) pblock->nTime += (rand() % (33 - gpucount)*(33 - gpucount)); if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33) > 0 ) From 99d7ed2567868d790e5ceac0d5afa6aa612aa873 Mon Sep 17 00:00:00 2001 From: l0rb Date: Fri, 8 Jun 2018 21:16:24 +0200 Subject: [PATCH 22/49] remove unused variable minor code 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 44c3db942..be0f07c5a 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1024,9 +1024,8 @@ int32_t komodo_isrealtime(int32_t *kmdheightp) else return(0); } -int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t nTime,int32_t dispflag) +int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t cmptime,int32_t dispflag) { - uint32_t cmptime = nTime; if ( KOMODO_REWIND == 0 && ASSETCHAINS_SYMBOL[0] == 0 && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD ) //1473793441 ) { if ( txheight > 246748 ) From 936078888db0780f880828b0a5336a3332b1b824 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Jun 2018 00:04:00 -1100 Subject: [PATCH 23/49] int32_t CBlockTreeDB::SnapShot() --- src/txdb.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/txdb.cpp b/src/txdb.cpp index c856947ad..0d802345a 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -396,6 +396,43 @@ bool CBlockTreeDB::ReadAddressIndex(uint160 addressHash, int type, return true; } +int32_t CBlockTreeDB::SnapShot() +{ + char chType; int32_t num = 0; std::string address; + boost::scoped_ptr pcursor(NewIterator()); + while (pcursor->Valid()) + { + boost::this_thread::interruption_point(); + try + { + leveldb::Slice slKey = pcursor->key(); + CDataStream ssKey(slKey.data(), slKey.data()+slKey.size(), SER_DISK, CLIENT_VERSION); + CAddressIndexKey indexKey; + ssKey >> chType; + ssKey >> indexKey; + if ( chType == DB_ADDRESSINDEX ) + { + try { + leveldb::Slice slValue = pcursor->value(); + CDataStream ssValue(slValue.data(), slValue.data()+slValue.size(), SER_DISK, CLIENT_VERSION); + CAmount nValue; + ssValue >> nValue; + getAddressFromIndex(indexKey.type, indexKey.addressBytes, address); + fprintf(stderr,"{\"%s\", %.8f},\n",address.c_str(),(double)nValue/COIN); + num++; + //addressIndex.push_back(make_pair(indexKey, nValue)); + pcursor->Next(); + } catch (const std::exception& e) { + return error("failed to get address index value"); + } + } else break; + } catch (const std::exception& e) { + break; + } + } + return(num); +} + bool CBlockTreeDB::WriteTimestampIndex(const CTimestampIndexKey ×tampIndex) { CLevelDBBatch batch; batch.Write(make_pair(DB_TIMESTAMPINDEX, timestampIndex), 0); From b4b4c499853d308c9ae2bc67ce2131576cddaa16 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Jun 2018 00:07:51 -1100 Subject: [PATCH 24/49] Syntax --- src/txdb.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/txdb.h b/src/txdb.h index 401f92144..14728d748 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -94,6 +94,7 @@ public: bool ReadFlag(const std::string &name, bool &fValue); bool LoadBlockIndexGuts(); bool blockOnchainActive(const uint256 &hash); + int32_t SnapShot(); }; #endif // BITCOIN_TXDB_H From bd1469982428160c89e4c0a0ff520a5bbf2d3cda Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Jun 2018 00:10:37 -1100 Subject: [PATCH 25/49] Syntax --- src/txdb.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index 0d802345a..67f403c64 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -396,6 +396,8 @@ bool CBlockTreeDB::ReadAddressIndex(uint160 addressHash, int type, return true; } +bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &address); + int32_t CBlockTreeDB::SnapShot() { char chType; int32_t num = 0; std::string address; @@ -417,7 +419,7 @@ int32_t CBlockTreeDB::SnapShot() CDataStream ssValue(slValue.data(), slValue.data()+slValue.size(), SER_DISK, CLIENT_VERSION); CAmount nValue; ssValue >> nValue; - getAddressFromIndex(indexKey.type, indexKey.addressBytes, address); + getAddressFromIndex(indexKey.type, indexKey.hashBytes, address); fprintf(stderr,"{\"%s\", %.8f},\n",address.c_str(),(double)nValue/COIN); num++; //addressIndex.push_back(make_pair(indexKey, nValue)); From 2200781907408b07f0de4988b07728680e89e7b4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Jun 2018 00:26:46 -1100 Subject: [PATCH 26/49] Snapshot roc --- src/rpcmisc.cpp | 17 +++++++++++++++++ src/rpcserver.cpp | 1 + src/rpcserver.h | 3 ++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 278fb8866..b348a893f 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -993,6 +993,23 @@ UniValue getaddressbalance(const UniValue& params, bool fHelp) } +UniValue getsnapshot(const UniValue& params, bool fHelp) +{ + UniValue result(UniValue::VOBJ); int32_t num; + if ( fHelp || params.size() > 0 ) + { + throw runtime_error( + "getsnapshot\n" + ); + } + if ( pblocktree != 0 ) + { + num = pblocktree->Snapshot(); + result.push_back(Pair("numaddresses", num)); + } else result.push_back(Pair("error", "no addressindex")); + return(result); +} + UniValue getaddresstxids(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 1) diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 86a7aed86..8e9a2c634 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -345,6 +345,7 @@ static const CRPCCommand vRPCCommands[] = { "addressindex", "getaddressdeltas", &getaddressdeltas, false }, { "addressindex", "getaddresstxids", &getaddresstxids, false }, { "addressindex", "getaddressbalance", &getaddressbalance, false }, + { "addressindex", "getsnapshot", &getsnapshot, false }, /* Utility functions */ { "util", "createmultisig", &createmultisig, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index ce412cdb9..1fbcca794 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -177,7 +177,8 @@ extern UniValue getaddressmempool(const UniValue& params, bool fHelp); extern UniValue getaddressutxos(const UniValue& params, bool fHelp); extern UniValue getaddressdeltas(const UniValue& params, bool fHelp); extern UniValue getaddresstxids(const UniValue& params, bool fHelp); -extern UniValue getaddressbalance(const UniValue& params, bool fHelp); +extern UniValue getaddresstxids(const UniValue& params, bool fHelp); +extern UniValue getsnapshot(const UniValue& params, bool fHelp); extern UniValue getpeerinfo(const UniValue& params, bool fHelp); extern UniValue ping(const UniValue& params, bool fHelp); extern UniValue addnode(const UniValue& params, bool fHelp); From 329d80d2c1b8ecbfea30b0d78f7252bc4da94bf7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Jun 2018 00:34:28 -1100 Subject: [PATCH 27/49] Move code --- src/main.cpp | 8 ++++++++ src/rpcmisc.cpp | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 2100b59ed..d15ff62c0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -585,6 +585,14 @@ CBlockTreeDB *pblocktree = NULL; #define KOMODO_ZCASH #include "komodo.h" +int32_t komodo_snapshot() +{ + int32_t num = -1; + if ( pblocktree != 0 ) + num = pblocktree->Snapshot(); + return(num); +} + ////////////////////////////////////////////////////////////////////////////// // // mapOrphanTransactions diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index b348a893f..4c4d1958b 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -993,6 +993,8 @@ UniValue getaddressbalance(const UniValue& params, bool fHelp) } +int32_t komodo_snapshot(); + UniValue getsnapshot(const UniValue& params, bool fHelp) { UniValue result(UniValue::VOBJ); int32_t num; @@ -1002,11 +1004,9 @@ UniValue getsnapshot(const UniValue& params, bool fHelp) "getsnapshot\n" ); } - if ( pblocktree != 0 ) - { - num = pblocktree->Snapshot(); + if ( (num= komodo_snapshot()) >= 0 ) result.push_back(Pair("numaddresses", num)); - } else result.push_back(Pair("error", "no addressindex")); + else result.push_back(Pair("error", "no addressindex")); return(result); } From bf91fda6825132f6f6b470eb458cef17a71cfaa6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Jun 2018 00:35:59 -1100 Subject: [PATCH 28/49] SnapShot -> snapshot --- src/txdb.cpp | 2 +- src/txdb.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index 67f403c64..d2ffb0b21 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -398,7 +398,7 @@ bool CBlockTreeDB::ReadAddressIndex(uint160 addressHash, int type, bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &address); -int32_t CBlockTreeDB::SnapShot() +int32_t CBlockTreeDB::Snapshot() { char chType; int32_t num = 0; std::string address; boost::scoped_ptr pcursor(NewIterator()); diff --git a/src/txdb.h b/src/txdb.h index 14728d748..a93e50f19 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -94,7 +94,7 @@ public: bool ReadFlag(const std::string &name, bool &fValue); bool LoadBlockIndexGuts(); bool blockOnchainActive(const uint256 &hash); - int32_t SnapShot(); + int32_t Snapshot(); }; #endif // BITCOIN_TXDB_H From 50b11c4a55c76f7fc6a9259212f623ed05e5f910 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Jun 2018 00:38:15 -1100 Subject: [PATCH 29/49] Fix --- src/rpcserver.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcserver.h b/src/rpcserver.h index 1fbcca794..b122e307a 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -177,8 +177,8 @@ extern UniValue getaddressmempool(const UniValue& params, bool fHelp); extern UniValue getaddressutxos(const UniValue& params, bool fHelp); extern UniValue getaddressdeltas(const UniValue& params, bool fHelp); extern UniValue getaddresstxids(const UniValue& params, bool fHelp); -extern UniValue getaddresstxids(const UniValue& params, bool fHelp); extern UniValue getsnapshot(const UniValue& params, bool fHelp); +extern UniValue getaddressbalance(const UniValue& params, bool fHelp); extern UniValue getpeerinfo(const UniValue& params, bool fHelp); extern UniValue ping(const UniValue& params, bool fHelp); extern UniValue addnode(const UniValue& params, bool fHelp); From 67d2e41b3f0332767eefb698f53c82b1a4b7eba3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Jun 2018 00:41:46 -1100 Subject: [PATCH 30/49] Test --- src/main.cpp | 8 ++++---- src/rpcmisc.cpp | 6 +++--- src/txdb.cpp | 10 ++++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index d15ff62c0..8dee9bfea 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -585,12 +585,12 @@ CBlockTreeDB *pblocktree = NULL; #define KOMODO_ZCASH #include "komodo.h" -int32_t komodo_snapshot() +int64_t komodo_snapshot() { - int32_t num = -1; + int64_t total = -1; if ( pblocktree != 0 ) - num = pblocktree->Snapshot(); - return(num); + total = pblocktree->Snapshot(); + return(total); } ////////////////////////////////////////////////////////////////////////////// diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 4c4d1958b..b873dc495 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -997,15 +997,15 @@ int32_t komodo_snapshot(); UniValue getsnapshot(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); int32_t num; + UniValue result(UniValue::VOBJ); int64_t total; if ( fHelp || params.size() > 0 ) { throw runtime_error( "getsnapshot\n" ); } - if ( (num= komodo_snapshot()) >= 0 ) - result.push_back(Pair("numaddresses", num)); + if ( (total= komodo_snapshot()) >= 0 ) + result.push_back(Pair("total", (double)total/COIN)); else result.push_back(Pair("error", "no addressindex")); return(result); } diff --git a/src/txdb.cpp b/src/txdb.cpp index d2ffb0b21..72ff85937 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -398,9 +398,9 @@ bool CBlockTreeDB::ReadAddressIndex(uint160 addressHash, int type, bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &address); -int32_t CBlockTreeDB::Snapshot() +int64_t CBlockTreeDB::Snapshot() { - char chType; int32_t num = 0; std::string address; + char chType; int64_t total = -1; std::string address; boost::scoped_ptr pcursor(NewIterator()); while (pcursor->Valid()) { @@ -421,7 +421,9 @@ int32_t CBlockTreeDB::Snapshot() ssValue >> nValue; getAddressFromIndex(indexKey.type, indexKey.hashBytes, address); fprintf(stderr,"{\"%s\", %.8f},\n",address.c_str(),(double)nValue/COIN); - num++; + if ( total < 0 ) + total = (int64_t)nValue; + else total += (int64_t)nValue; //addressIndex.push_back(make_pair(indexKey, nValue)); pcursor->Next(); } catch (const std::exception& e) { @@ -432,7 +434,7 @@ int32_t CBlockTreeDB::Snapshot() break; } } - return(num); + return(total); } bool CBlockTreeDB::WriteTimestampIndex(const CTimestampIndexKey ×tampIndex) { From 78a6f7041ec4d43fc29539b24d390c073ddc70d5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Jun 2018 00:43:46 -1100 Subject: [PATCH 31/49] int64_t --- src/txdb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/txdb.h b/src/txdb.h index a93e50f19..cb4d6d19e 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -94,7 +94,7 @@ public: bool ReadFlag(const std::string &name, bool &fValue); bool LoadBlockIndexGuts(); bool blockOnchainActive(const uint256 &hash); - int32_t Snapshot(); + int64_t Snapshot(); }; #endif // BITCOIN_TXDB_H From 74db3cd02768174b4e4c37322d30a3ece8dca062 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Jun 2018 02:01:14 -1100 Subject: [PATCH 32/49] SeekToFirst --- src/main.cpp | 1 + src/txdb.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 8dee9bfea..c9a798e4d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -590,6 +590,7 @@ int64_t komodo_snapshot() int64_t total = -1; if ( pblocktree != 0 ) total = pblocktree->Snapshot(); + else fprintf(stderr,"null pblocktree start with -addressindex=true\n"); return(total); } diff --git a/src/txdb.cpp b/src/txdb.cpp index 72ff85937..d061d7792 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -402,6 +402,8 @@ int64_t CBlockTreeDB::Snapshot() { char chType; int64_t total = -1; std::string address; boost::scoped_ptr pcursor(NewIterator()); + pcursor->SeekToFirst(); + fprintf(stderr,"pcursor iterate\n"); while (pcursor->Valid()) { boost::this_thread::interruption_point(); From de84abc1b04c80b1be561fdd453c02bb95d959bd Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Jun 2018 02:06:11 -1100 Subject: [PATCH 33/49] Prints --- src/txdb.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index d061d7792..a0f764962 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -414,6 +414,7 @@ int64_t CBlockTreeDB::Snapshot() CAddressIndexKey indexKey; ssKey >> chType; ssKey >> indexKey; + fprintf(stderr,"chType.%d\n",chType); if ( chType == DB_ADDRESSINDEX ) { try { @@ -431,7 +432,7 @@ int64_t CBlockTreeDB::Snapshot() } catch (const std::exception& e) { return error("failed to get address index value"); } - } else break; + } else { break; } } catch (const std::exception& e) { break; } From 67d4c3beef517ad54efc56ac5c24243a65322f4c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Jun 2018 03:13:45 -1100 Subject: [PATCH 34/49] Test --- src/rpcmisc.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index b873dc495..3cc18c6a6 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -634,12 +634,12 @@ bool getAddressesFromParams(const UniValue& params, std::vector > addresses; @@ -753,8 +753,8 @@ UniValue getaddressutxos(const UniValue& params, bool fHelp) " }\n" "]\n" "\nExamples:\n" - + HelpExampleCli("getaddressutxos", "'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'") - + HelpExampleRpc("getaddressutxos", "{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}") + + HelpExampleCli("getaddressutxos", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") + + HelpExampleRpc("getaddressutxos", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") ); bool includeChainInfo = false; @@ -840,8 +840,8 @@ UniValue getaddressdeltas(const UniValue& params, bool fHelp) " }\n" "]\n" "\nExamples:\n" - + HelpExampleCli("getaddressdeltas", "'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'") - + HelpExampleRpc("getaddressdeltas", "{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}") + + HelpExampleCli("getaddressdeltas", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") + + HelpExampleRpc("getaddressdeltas", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") ); @@ -957,8 +957,8 @@ UniValue getaddressbalance(const UniValue& params, bool fHelp) " \"received\" (string) The total number of satoshis received (including change)\n" "}\n" "\nExamples:\n" - + HelpExampleCli("getaddressbalance", "'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'") - + HelpExampleRpc("getaddressbalance", "{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}") + + HelpExampleCli("getaddressbalance", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") + + HelpExampleRpc("getaddressbalance", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") ); std::vector > addresses; @@ -1032,8 +1032,8 @@ UniValue getaddresstxids(const UniValue& params, bool fHelp) " ,...\n" "]\n" "\nExamples:\n" - + HelpExampleCli("getaddresstxids", "'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'") - + HelpExampleRpc("getaddresstxids", "{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}") + + HelpExampleCli("getaddresstxids", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") + + HelpExampleRpc("getaddresstxids", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") ); std::vector > addresses; From 32748f525e9db520b6def11a8c73b50268d92ce9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Jun 2018 03:38:36 -1100 Subject: [PATCH 35/49] New iterator --- src/txdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index a0f764962..151acdb68 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -401,7 +401,7 @@ bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &addr int64_t CBlockTreeDB::Snapshot() { char chType; int64_t total = -1; std::string address; - boost::scoped_ptr pcursor(NewIterator()); + boost::scoped_ptr pcursor(const_cast(&db)->NewIterator()); pcursor->SeekToFirst(); fprintf(stderr,"pcursor iterate\n"); while (pcursor->Valid()) From afd86eb21ef844cabf3e21babf1ad6eb979d8e8a Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Jun 2018 03:46:42 -1100 Subject: [PATCH 36/49] Undo --- src/txdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index 151acdb68..a0f764962 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -401,7 +401,7 @@ bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &addr int64_t CBlockTreeDB::Snapshot() { char chType; int64_t total = -1; std::string address; - boost::scoped_ptr pcursor(const_cast(&db)->NewIterator()); + boost::scoped_ptr pcursor(NewIterator()); pcursor->SeekToFirst(); fprintf(stderr,"pcursor iterate\n"); while (pcursor->Valid()) From 28a62b60df3f57eaad1d946b75a1af6f3f7b15e7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Jun 2018 05:46:21 -1100 Subject: [PATCH 37/49] Deterministic RNG for notary mining --- src/miner.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 35eb8e4d3..07e4a7a16 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -112,6 +112,7 @@ extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY; extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33]; uint32_t Mining_start,Mining_height; +int32_t My_notaryid = -1; int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp); int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize); //uint64_t komodo_paxtotal(); @@ -472,13 +473,21 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) } pblock->nSolution.clear(); pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]); - if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 && My_notaryid >= 0 ) { + uint32_t r; CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); if ( pblock->nTime < pindexPrev->nTime+60 ) pblock->nTime = pindexPrev->nTime + 60; if ( gpucount < 33 ) - pblock->nTime += (rand() % (33 - gpucount)*(33 - gpucount)); + { + uint8_t tmpbuffer[40]; int32_t n=0; bits256 randvals; + memcpy(&tmpbuffer[n],&My_notaryid,sizeof(My_notaryid)), n += sizeof(My_notaryid); + memcpy(&tmpbuffer[n],&Mining_height,sizeof(Mining_height)), n += sizeof(Mining_height); + memcpy(&tmpbuffer[n],&pblock->hashPrevBlock,sizeof(pblock->hashPrevBlock)), n += sizeof(pblock->hashPrevBlock); + vcalc_sha256(0,randvals.bytes,tmpbuffer,n); + pblock->nTime += (randvals.uints[0] % (33 - gpucount)*(33 - gpucount)); + } if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33) > 0 ) { CAmount txfees = 5000; @@ -729,7 +738,8 @@ void static BitcoinMiner() break; } komodo_chosennotary(¬aryid,chainActive.Tip()->nHeight,NOTARY_PUBKEY33,(uint32_t)chainActive.Tip()->GetBlockTime()); - + if ( notaryid != My_notaryid ) + My_notaryid = notaryid; std::string solver; //if ( notaryid >= 0 || ASSETCHAINS_SYMBOL[0] != 0 ) solver = "tromp"; From 55566f16bd2cb405d93e896ed2b687beaa1c7853 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Jun 2018 05:50:20 -1100 Subject: [PATCH 38/49] Fix --- src/miner.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 07e4a7a16..45b70040f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -481,12 +481,13 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) pblock->nTime = pindexPrev->nTime + 60; if ( gpucount < 33 ) { - uint8_t tmpbuffer[40]; int32_t n=0; bits256 randvals; + uint8_t tmpbuffer[40]; uint32_t r; int32_t n=0; uint256 randvals; memcpy(&tmpbuffer[n],&My_notaryid,sizeof(My_notaryid)), n += sizeof(My_notaryid); memcpy(&tmpbuffer[n],&Mining_height,sizeof(Mining_height)), n += sizeof(Mining_height); memcpy(&tmpbuffer[n],&pblock->hashPrevBlock,sizeof(pblock->hashPrevBlock)), n += sizeof(pblock->hashPrevBlock); - vcalc_sha256(0,randvals.bytes,tmpbuffer,n); - pblock->nTime += (randvals.uints[0] % (33 - gpucount)*(33 - gpucount)); + vcalc_sha256(0,(void *)&randvals,tmpbuffer,n); + memcpy(&r,&randvals,sizeof(r)); + pblock->nTime += (r % (33 - gpucount)*(33 - gpucount)); } if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33) > 0 ) { From 292809f76cc838ca0d2f4996df46c3016eac291b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Jun 2018 05:51:17 -1100 Subject: [PATCH 39/49] Fix --- src/miner.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/miner.cpp b/src/miner.cpp index 45b70040f..327382089 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -109,6 +109,7 @@ extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOS extern uint64_t ASSETCHAINS_REWARD,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY; +void vcalc_sha256(char deprecated[(256 >> 3) * 2 + 1],uint8_t hash[256 >> 3],uint8_t *src,int32_t len); extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33]; uint32_t Mining_start,Mining_height; From 9a146fef7685b8b84d0b6c490f6996e0e5b17068 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Jun 2018 05:52:44 -1100 Subject: [PATCH 40/49] Fix --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 327382089..5f753f267 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -486,7 +486,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) memcpy(&tmpbuffer[n],&My_notaryid,sizeof(My_notaryid)), n += sizeof(My_notaryid); memcpy(&tmpbuffer[n],&Mining_height,sizeof(Mining_height)), n += sizeof(Mining_height); memcpy(&tmpbuffer[n],&pblock->hashPrevBlock,sizeof(pblock->hashPrevBlock)), n += sizeof(pblock->hashPrevBlock); - vcalc_sha256(0,(void *)&randvals,tmpbuffer,n); + vcalc_sha256(0,(uint8_t *)&randvals,tmpbuffer,n); memcpy(&r,&randvals,sizeof(r)); pblock->nTime += (r % (33 - gpucount)*(33 - gpucount)); } From 2c6d812dff58c67e91e2030a2031a70474afb1b1 Mon Sep 17 00:00:00 2001 From: St3rling0x <38841176+St3rling0x@users.noreply.github.com> Date: Wed, 13 Jun 2018 20:55:06 +0200 Subject: [PATCH 41/49] Added ZILLA --- src/assetchains | 1 + 1 file changed, 1 insertion(+) diff --git a/src/assetchains b/src/assetchains index ec77fba28..6697c1735 100755 --- a/src/assetchains +++ b/src/assetchains @@ -57,3 +57,4 @@ komodo_asset PRLPAY 500000000 komodo_asset DSEC 7000000 komodo_asset GLXT 100000000 komodo_asset EQL 500000000 +komodo_asset ZILLA 11000000 From a358386ba67592f84c75b9219f2a59b7688b9cb5 Mon Sep 17 00:00:00 2001 From: St3rling0x <38841176+St3rling0x@users.noreply.github.com> Date: Wed, 13 Jun 2018 20:56:09 +0200 Subject: [PATCH 42/49] added Zilla --- src/assetchains.old | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/assetchains.old b/src/assetchains.old index af9361746..44b494647 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -35,4 +35,6 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=GLXT -ac_supply=100000000 -addnode=13.230.224.15 & ./komodod -pubkey=$pubkey -ac_name=EQL -ac_supply=500000000 -addnode=46.101.124.153 & ~/VerusCoin/src/komodod -ac_name=VRSC -ac_algo=verushash -ac_cc=1 -ac_veruspos=50 -ac_supply=0 -ac_eras=3 -ac_reward=0,38400000000,2400000000 -ac_halving=1,43200,1051920 -ac_decay=100000000,0,0 -ac_end=10080,226080,0 -ac_timelockgte=19200000000 -ac_timeunlockfrom=129600 -ac_timeunlockto=1180800 -addnode=185.25.48.236 -addnode=185.64.105.111 & +./komodod -pubkey=$pubkey -ac_name=ZILLA -ac_supply=11000000 -addnode=54.39.23.248 & + From cccc5ac04e95a5573f7982ca7488f1a8ab736f33 Mon Sep 17 00:00:00 2001 From: St3rling0x <38841176+St3rling0x@users.noreply.github.com> Date: Wed, 13 Jun 2018 20:56:34 +0200 Subject: [PATCH 43/49] Added Zilla --- src/assetchains.old | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assetchains.old b/src/assetchains.old index 44b494647..3f42fef13 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -34,7 +34,7 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=DSEC -ac_supply=7000000 -addnode=185.148.147.30 & ./komodod -pubkey=$pubkey -ac_name=GLXT -ac_supply=100000000 -addnode=13.230.224.15 & ./komodod -pubkey=$pubkey -ac_name=EQL -ac_supply=500000000 -addnode=46.101.124.153 & -~/VerusCoin/src/komodod -ac_name=VRSC -ac_algo=verushash -ac_cc=1 -ac_veruspos=50 -ac_supply=0 -ac_eras=3 -ac_reward=0,38400000000,2400000000 -ac_halving=1,43200,1051920 -ac_decay=100000000,0,0 -ac_end=10080,226080,0 -ac_timelockgte=19200000000 -ac_timeunlockfrom=129600 -ac_timeunlockto=1180800 -addnode=185.25.48.236 -addnode=185.64.105.111 & ./komodod -pubkey=$pubkey -ac_name=ZILLA -ac_supply=11000000 -addnode=54.39.23.248 & +~/VerusCoin/src/komodod -ac_name=VRSC -ac_algo=verushash -ac_cc=1 -ac_veruspos=50 -ac_supply=0 -ac_eras=3 -ac_reward=0,38400000000,2400000000 -ac_halving=1,43200,1051920 -ac_decay=100000000,0,0 -ac_end=10080,226080,0 -ac_timelockgte=19200000000 -ac_timeunlockfrom=129600 -ac_timeunlockto=1180800 -addnode=185.25.48.236 -addnode=185.64.105.111 & From 784e0917cfdfb3c6e53153bd6ee94e45d183ee06 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Jun 2018 08:48:47 -1100 Subject: [PATCH 44/49] Prevent skipping even old notarizations --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 690e91248..18a97ab00 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -694,7 +694,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 ) komodo_rwccdata((char *)"KMD",1,&ccdata,0); - if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) + if ( matched != 0 )//&& *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { sp->NOTARIZED_HEIGHT = *notarizedheightp; sp->NOTARIZED_HASH = srchash; From 77dbf244b8bab1a204afc20a9dd3c119f238c3b4 Mon Sep 17 00:00:00 2001 From: PTYX11 <32718517+ptyx11@users.noreply.github.com> Date: Wed, 13 Jun 2018 23:02:53 +0200 Subject: [PATCH 45/49] Added Zilla --- src/dpowassets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dpowassets b/src/dpowassets index dbf928d79..b15bdbbd3 100755 --- a/src/dpowassets +++ b/src/dpowassets @@ -33,6 +33,6 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"DSEC\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"GLXT\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"EQL\",\"pubkey\":\"$pubkey\"}" - +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"ZILLA\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CHIPS\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"GAME\",\"freq\":5,\"pubkey\":\"$pubkey\"}" From cc175ed24d76527ef2ec4e5b0b1916a95fb1a1eb Mon Sep 17 00:00:00 2001 From: PTYX11 <32718517+ptyx11@users.noreply.github.com> Date: Wed, 13 Jun 2018 23:03:26 +0200 Subject: [PATCH 46/49] Added Zilla --- src/fiat-cli | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fiat-cli b/src/fiat-cli index 6183f35d1..1362833d9 100755 --- a/src/fiat-cli +++ b/src/fiat-cli @@ -30,3 +30,4 @@ echo prlpay; fiat/prlpay $1 $2 $3 $4 echo dsec; fiat/dsec $1 $2 $3 $4 echo glxt; fiat/glxt $1 $2 $3 $4 echo eql; fiat/eql $1 $2 $3 $4 +echo zilla; fiat/eql $1 $2 $3 $4 From 656133e978061028b3cc7b4c88408da9bb28025e Mon Sep 17 00:00:00 2001 From: PTYX11 <32718517+ptyx11@users.noreply.github.com> Date: Wed, 13 Jun 2018 23:03:51 +0200 Subject: [PATCH 47/49] changed to zilla --- src/fiat-cli | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fiat-cli b/src/fiat-cli index 1362833d9..4e1c61675 100755 --- a/src/fiat-cli +++ b/src/fiat-cli @@ -30,4 +30,4 @@ echo prlpay; fiat/prlpay $1 $2 $3 $4 echo dsec; fiat/dsec $1 $2 $3 $4 echo glxt; fiat/glxt $1 $2 $3 $4 echo eql; fiat/eql $1 $2 $3 $4 -echo zilla; fiat/eql $1 $2 $3 $4 +echo zilla; fiat/zilla $1 $2 $3 $4 From 62c218de74f2d5998248ca0a733e9bb178cd9b8e Mon Sep 17 00:00:00 2001 From: PTYX11 <32718517+ptyx11@users.noreply.github.com> Date: Wed, 13 Jun 2018 23:05:15 +0200 Subject: [PATCH 48/49] created zilla file --- src/fiat/zilla | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 src/fiat/zilla diff --git a/src/fiat/zilla b/src/fiat/zilla new file mode 100644 index 000000000..d8c713369 --- /dev/null +++ b/src/fiat/zilla @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=ZILLA $1 $2 $3 $4 $5 $6 From 68e359a462e4e29705218b6ce62338a23227a818 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Jun 2018 21:01:32 -1100 Subject: [PATCH 49/49] Revert unfiltered notarizations --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 18a97ab00..690e91248 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -694,7 +694,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 ) komodo_rwccdata((char *)"KMD",1,&ccdata,0); - if ( matched != 0 )//&& *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) + if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { sp->NOTARIZED_HEIGHT = *notarizedheightp; sp->NOTARIZED_HASH = srchash;