From 2ad1557300b579b7d453bd32398e97d727b667c3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 May 2018 20:21:15 -1100 Subject: [PATCH 001/100] Fix ;; --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 70a5488f8..fce556d33 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4519,7 +4519,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) txNew.vin.resize(1); txNew.vout.resize(1); - txfee = utxovalue / 2;; + txfee = utxovalue / 2; //for (i=0; i<32; i++) // ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i]; txNew.vin[0].prevout.hash = utxotxid; //revtxid; From ab78e2413064fbcdd589efca5f2fbe2f0eb5031b Mon Sep 17 00:00:00 2001 From: Mihail Fedorov Date: Mon, 28 May 2018 14:19:11 +0300 Subject: [PATCH 002/100] 2 new chains --- src/assetchains | 2 ++ src/assetchains.old | 2 ++ src/dpowassets | 2 ++ src/fiat-cli | 2 ++ src/fiat/eql | 2 ++ src/fiat/glxt | 2 ++ 6 files changed, 12 insertions(+) create mode 100755 src/fiat/eql create mode 100755 src/fiat/glxt diff --git a/src/assetchains b/src/assetchains index a8ab28155..ec77fba28 100755 --- a/src/assetchains +++ b/src/assetchains @@ -55,3 +55,5 @@ komodo_asset BNTN 500000000 komodo_asset CHAIN 999999 komodo_asset PRLPAY 500000000 komodo_asset DSEC 7000000 +komodo_asset GLXT 100000000 +komodo_asset EQL 500000000 diff --git a/src/assetchains.old b/src/assetchains.old index 4e56fe639..cf46922de 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -32,6 +32,8 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=CHAIN -ac_supply=999999 -addnode=78.47.146.222 & ./komodod -pubkey=$pubkey -ac_name=PRLPAY -ac_supply=500000000 -addnode=13.250.226.125 & ./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 & #sleep $delay #./komodod -pubkey=$pubkey -ac_name=USD -addnode=78.47.196.146 $1 & diff --git a/src/dpowassets b/src/dpowassets index 40bb89cce..dbf928d79 100755 --- a/src/dpowassets +++ b/src/dpowassets @@ -31,6 +31,8 @@ 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\":\"BNTN\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PRLPAY\",\"pubkey\":\"$pubkey\"}" 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\":\"CHIPS\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"GAME\",\"freq\":5,\"pubkey\":\"$pubkey\"}" diff --git a/src/fiat-cli b/src/fiat-cli index 463906cf2..8e54aeeb6 100755 --- a/src/fiat-cli +++ b/src/fiat-cli @@ -28,3 +28,5 @@ echo bntn; fiat/bntn $1 $2 $3 $4 echo chain; fiat/chain $1 $2 $3 $4 echo prlpay; fiat/prlpay $1 $2 $3 $4 echo dsec; fiat/dsec $1 $2 $3 $4 +echo dsec; fiat/glxt $1 $2 $3 $4 +echo dsec; fiat/eql $1 $2 $3 $4 diff --git a/src/fiat/eql b/src/fiat/eql new file mode 100755 index 000000000..99cfa9a09 --- /dev/null +++ b/src/fiat/eql @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=EQL $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/glxt b/src/fiat/glxt new file mode 100755 index 000000000..6cedfbf87 --- /dev/null +++ b/src/fiat/glxt @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=GLXT $1 $2 $3 $4 $5 $6 From f3c9d7c7e9c4040cf285c06f7f0d124908bef167 Mon Sep 17 00:00:00 2001 From: Mihail Fedorov Date: Mon, 28 May 2018 14:22:02 +0300 Subject: [PATCH 003/100] 2 new chains --- src/ac/eql | 2 ++ src/ac/glxt | 2 ++ src/fiat-cli | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100755 src/ac/eql create mode 100755 src/ac/glxt diff --git a/src/ac/eql b/src/ac/eql new file mode 100755 index 000000000..99cfa9a09 --- /dev/null +++ b/src/ac/eql @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=EQL $1 $2 $3 $4 $5 $6 diff --git a/src/ac/glxt b/src/ac/glxt new file mode 100755 index 000000000..6cedfbf87 --- /dev/null +++ b/src/ac/glxt @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=GLXT $1 $2 $3 $4 $5 $6 diff --git a/src/fiat-cli b/src/fiat-cli index 8e54aeeb6..6183f35d1 100755 --- a/src/fiat-cli +++ b/src/fiat-cli @@ -28,5 +28,5 @@ echo bntn; fiat/bntn $1 $2 $3 $4 echo chain; fiat/chain $1 $2 $3 $4 echo prlpay; fiat/prlpay $1 $2 $3 $4 echo dsec; fiat/dsec $1 $2 $3 $4 -echo dsec; fiat/glxt $1 $2 $3 $4 -echo dsec; fiat/eql $1 $2 $3 $4 +echo glxt; fiat/glxt $1 $2 $3 $4 +echo eql; fiat/eql $1 $2 $3 $4 From 6fd79871df7933ec65b05362f26b84954471b32c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 May 2018 02:03:48 -1100 Subject: [PATCH 004/100] wallet/rpcwallet.cpp:2701: uint64_t komodo_interestsum(): Assertion` pwalletMain != NULL' failed.` --- src/wallet/rpcwallet.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index fce556d33..0b3b45a80 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2696,6 +2696,7 @@ 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); @@ -2719,6 +2720,9 @@ uint64_t komodo_interestsum() KOMODO_INTERESTSUM = sum; KOMODO_WALLETBALANCE = pwalletMain->GetBalance(); return(sum); +#else + return(0); +#endif } UniValue fundrawtransaction(const UniValue& params, bool fHelp) From d9f176ac7ef5abc7f8af299a7a69d015f50f0f8e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 May 2018 02:43:08 -1100 Subject: [PATCH 005/100] Support -ac_pubkey without -ac_perc If ac_pubkey is set, then height 1 out must go to that pub key --- src/komodo_bitcoind.h | 27 ++++++++++++++++++--------- src/komodo_port.c | 2 +- src/komodo_utils.h | 2 +- src/miner.cpp | 13 +++++++++---- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index c434e33a3..2ef99c5e3 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1333,20 +1333,29 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } else if ( is_PoSblock < 0 ) return(-1); } - if ( failed == 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 ) + if ( failed == 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) { - checktoshis = komodo_commission(pblock); - if ( checktoshis > 10000 && pblock->vtx[0].vout.size() != 2 ) - return(-1); - else if ( checktoshis != 0 ) + if ( height == 1 ) { - script = (uint8_t *)pblock->vtx[0].vout[1].scriptPubKey.data(); + script = (uint8_t *)pblock->vtx[0].vout[0].scriptPubKey.data(); if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) return(-1); - if ( pblock->vtx[0].vout[1].nValue != checktoshis ) - { - fprintf(stderr,"checktoshis %.8f vs actual vout[1] %.8f\n",dstr(checktoshis),dstr(pblock->vtx[0].vout[1].nValue)); + } + if ( ASSETCHAINS_COMMISSION != 0 ) + { + checktoshis = komodo_commission(pblock); + if ( checktoshis > 10000 && pblock->vtx[0].vout.size() != 2 ) return(-1); + else if ( checktoshis != 0 ) + { + script = (uint8_t *)pblock->vtx[0].vout[1].scriptPubKey.data(); + if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) + return(-1); + if ( pblock->vtx[0].vout[1].nValue != checktoshis ) + { + fprintf(stderr,"checktoshis %.8f vs actual vout[1] %.8f\n",dstr(checktoshis),dstr(pblock->vtx[0].vout[1].nValue)); + return(-1); + } } } } diff --git a/src/komodo_port.c b/src/komodo_port.c index e92da3af1..991be2013 100644 --- a/src/komodo_port.c +++ b/src/komodo_port.c @@ -809,7 +809,7 @@ uint16_t komodo_calcport(char *name,uint64_t supply,uint64_t endsubsidy,uint64_t decay = 0; printf("decay cant be more than 100000000\n"); } - if ( endsubsidy != 0 || reward != 0 || halving != 0 || decay != 0 || commission != 0 || cc != 0 || staked != 0 ) + if ( endsubsidy != 0 || reward != 0 || halving != 0 || decay != 0 || commission != 0 || cc != 0 || staked != 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) { //printf("end.%llu reward.%llu halving.%llu decay.%llu perc.%llu\n",(long long)endsubsidy,(long long)reward,(long long)halving,(long long)decay,(long long)commission); extraptr = extrabuf; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 36766a1f7..119c4d6f4 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1559,7 +1559,7 @@ void komodo_args(char *argv0) ASSETCHAINS_DECAY = 0; printf("ASSETCHAINS_DECAY cant be more than 100000000\n"); } - if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 && ASSETCHAINS_COMMISSION > 0 && ASSETCHAINS_COMMISSION <= 100000000 ) + if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 ) decode_hex(ASSETCHAINS_OVERRIDE_PUBKEY33,33,(char *)ASSETCHAINS_OVERRIDE_PUBKEY.c_str()); else if ( ASSETCHAINS_COMMISSION != 0 ) { diff --git a/src/miner.cpp b/src/miner.cpp index 264a6e2d4..ff93ca91c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -108,7 +108,8 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; extern uint64_t ASSETCHAINS_REWARD,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; -extern std::string NOTARY_PUBKEY; +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 komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp); @@ -582,10 +583,14 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& // Internal miner // -CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey) +CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight) { CPubKey pubkey; CScript scriptPubKey; uint8_t *script,*ptr; int32_t i; - if ( USE_EXTERNAL_PUBKEY != 0 ) + if ( nHeight == 1 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) + { + scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG; + } + else if ( USE_EXTERNAL_PUBKEY != 0 ) { //fprintf(stderr,"use notary pubkey\n"); scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; @@ -787,7 +792,7 @@ void static BitcoinMiner() sleep(3); } #ifdef ENABLE_WALLET - CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey); + CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey,pindexPrev->nHeight+1); #else CBlockTemplate *ptr = CreateNewBlockWithKey(); #endif From cf1b8419d426e7a7d1c65ce887249a167f6b5d4a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 May 2018 02:56:05 -1100 Subject: [PATCH 006/100] Add nHeight --- src/rpcmining.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index bd9c45f5d..e3341144a 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -214,7 +214,7 @@ UniValue generate(const UniValue& params, bool fHelp) lastTime = GetTime(); #ifdef ENABLE_WALLET - std::unique_ptr pblocktemplate(CreateNewBlockWithKey(reservekey)); + std::unique_ptr pblocktemplate(CreateNewBlockWithKey(reservekey,nHeight)); #else std::unique_ptr pblocktemplate(CreateNewBlockWithKey()); #endif @@ -639,7 +639,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) } #ifdef ENABLE_WALLET CReserveKey reservekey(pwalletMain); - pblocktemplate = CreateNewBlockWithKey(reservekey); + pblocktemplate = CreateNewBlockWithKey(reservekey,chainActive.Tip()->nHeight+1); #else pblocktemplate = CreateNewBlockWithKey(); #endif From 1afc2472d073a6e6907051f85a057fd912f8aa6a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 May 2018 02:56:49 -1100 Subject: [PATCH 007/100] Create block with nHeight --- src/miner.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.h b/src/miner.h index bf1a088f0..684b10187 100644 --- a/src/miner.h +++ b/src/miner.h @@ -30,7 +30,7 @@ struct CBlockTemplate CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn); #ifdef ENABLE_WALLET boost::optional GetMinerScriptPubKey(CReserveKey& reservekey); -CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey); +CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight); #else boost::optional GetMinerScriptPubKey(); CBlockTemplate* CreateNewBlockWithKey(); From 525c7b98a9c62d54b7f1c29e12be343eccd5df8c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 May 2018 03:01:05 -1100 Subject: [PATCH 008/100] Skip equihash test for regrets --- src/pow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pow.cpp b/src/pow.cpp index 817dcc1fe..e942883f2 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -86,6 +86,8 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams& param unsigned int n = params.EquihashN(); unsigned int k = params.EquihashK(); + if ( Params().NetworkIDString() == "regtest" ) + return(true); // Hash state crypto_generichash_blake2b_state state; EhInitialiseState(n, k, state); From e2c2eec41a29794dea0f65c9f1eb3f89b63cffd2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 May 2018 03:06:13 -1100 Subject: [PATCH 009/100] Guard null it->second --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 119967a46..fa402338a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5147,7 +5147,8 @@ void static CheckBlockIndex() // Build forward-pointing map of the entire block tree. std::multimap forward; for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); it++) { - forward.insert(std::make_pair(it->second->pprev, it->second)); + if ( it->second != 0 ) + forward.insert(std::make_pair(it->second->pprev, it->second)); } assert(forward.size() == mapBlockIndex.size()); From d916630e3a267452ab0a3700fe2e1bc5de8079a6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 May 2018 03:08:43 -1100 Subject: [PATCH 010/100] Bypass assert in regrets --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index fa402338a..34d939431 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5150,8 +5150,8 @@ void static CheckBlockIndex() if ( it->second != 0 ) forward.insert(std::make_pair(it->second->pprev, it->second)); } - - assert(forward.size() == mapBlockIndex.size()); + if ( Params().NetworkIDString() != "regtest" ) + assert(forward.size() == mapBlockIndex.size()); std::pair::iterator,std::multimap::iterator> rangeGenesis = forward.equal_range(NULL); CBlockIndex *pindex = rangeGenesis.first->second; From 528f340601cd6aca31341623a27d291b8ea6a0ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 May 2018 03:15:29 -1100 Subject: [PATCH 011/100] -print --- src/komodo.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 36c7c2ef3..d01de9553 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -201,8 +201,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char komodo_eventadd_pricefeed(sp,symbol,ht,pvals,numpvals); //printf("load pvals ht.%d numpvals.%d\n",ht,numpvals); } else printf("error loading pvals[%d]\n",numpvals); - } - else printf("[%s] %s illegal func.(%d %c)\n",ASSETCHAINS_SYMBOL,symbol,func,func); + } // else printf("[%s] %s illegal func.(%d %c)\n",ASSETCHAINS_SYMBOL,symbol,func,func); return(func); } else return(-1); } @@ -342,8 +341,7 @@ int32_t komodo_parsestatefiledata(struct komodo_state *sp,uint8_t *filedata,long komodo_eventadd_pricefeed(sp,symbol,ht,pvals,numpvals); //printf("load pvals ht.%d numpvals.%d\n",ht,numpvals); } else printf("error loading pvals[%d]\n",numpvals); - } - else printf("[%s] %s illegal func.(%d %c)\n",ASSETCHAINS_SYMBOL,symbol,func,func); + } // else printf("[%s] %s illegal func.(%d %c)\n",ASSETCHAINS_SYMBOL,symbol,func,func); *fposp = fpos; return(func); } From 2d79309f33ed4fdb819170f2db15e856de62d16d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 May 2018 03:25:26 -1100 Subject: [PATCH 012/100] unburn Notary vin txfee --- src/miner.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index ff93ca91c..e86902a92 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -479,11 +479,13 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblock->nTime = pindexPrev->nTime + 65; if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33) > 0 ) { - CAmount txfees = 0; + CAmount txfees = 5000; pblock->vtx.push_back(txNotary); pblocktemplate->vTxFees.push_back(txfees); pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txNotary)); nFees += txfees; + pblocktemplate->vTxFees[0] = -nFees; + pblock->vtx[0].vout[0].nValue += txfees; //fprintf(stderr,"added notaryvin\n"); } else From c255db29b37e1ac2d35e1e6477c7603b2f6f93d0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 May 2018 03:29:06 -1100 Subject: [PATCH 013/100] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index e86902a92..9863c8139 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -485,7 +485,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txNotary)); nFees += txfees; pblocktemplate->vTxFees[0] = -nFees; - pblock->vtx[0].vout[0].nValue += txfees; + *(uint64_t *)(&pblock->vtx[0].vout[0].nValue) += txfees; //fprintf(stderr,"added notaryvin\n"); } else From c881e52b6ef23c1dc0df6a95d13ebe5429270a91 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 May 2018 03:41:03 -1100 Subject: [PATCH 014/100] Revert --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 9863c8139..c789eb41d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -485,7 +485,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txNotary)); nFees += txfees; pblocktemplate->vTxFees[0] = -nFees; - *(uint64_t *)(&pblock->vtx[0].vout[0].nValue) += txfees; + //*(uint64_t *)(&pblock->vtx[0].vout[0].nValue) += txfees; //fprintf(stderr,"added notaryvin\n"); } else From fb6bb4e82ebbaee6cf1ebbbd3c9de6ff0bc68ecd Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 May 2018 04:18:31 -1100 Subject: [PATCH 015/100] fix -ac_perc --- src/komodo_bitcoind.h | 42 +++++++++++++++++++++++++----------------- src/komodo_gateway.h | 19 ++++++++++++++----- 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 2ef99c5e3..b48c40442 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1265,6 +1265,29 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ return(isPoS); } +int64_t komodo_checkcommission(CBlock *pblock,int32_t height) +{ + int64_t checktoshis=0; uint8_t *script; + if ( ASSETCHAINS_COMMISSION != 0 ) + { + checktoshis = komodo_commission(pblock); + if ( checktoshis > 10000 && pblock->vtx[0].vout.size() != 2 ) + return(-1); + else if ( checktoshis != 0 ) + { + script = (uint8_t *)pblock->vtx[0].vout[1].scriptPubKey.data(); + if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) + return(-1); + if ( pblock->vtx[0].vout[1].nValue != checktoshis ) + { + fprintf(stderr,"ht.%d checktoshis %.8f vs actual vout[1] %.8f\n",height,dstr(checktoshis),dstr(pblock->vtx[0].vout[1].nValue)); + return(-1); + } + } + } + return(checktoshis); +} + int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) { uint256 hash; arith_uint256 bnTarget,bhash; bool fNegative,fOverflow; uint8_t *script,pubkey33[33],pubkeys[64][33]; int32_t i,possible,PoSperc,is_PoSblock=0,n,failed = 0,notaryid = -1; int64_t checktoshis,value; CBlockIndex *pprev; @@ -1341,23 +1364,8 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) return(-1); } - if ( ASSETCHAINS_COMMISSION != 0 ) - { - checktoshis = komodo_commission(pblock); - if ( checktoshis > 10000 && pblock->vtx[0].vout.size() != 2 ) - return(-1); - else if ( checktoshis != 0 ) - { - script = (uint8_t *)pblock->vtx[0].vout[1].scriptPubKey.data(); - if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) - return(-1); - if ( pblock->vtx[0].vout[1].nValue != checktoshis ) - { - fprintf(stderr,"checktoshis %.8f vs actual vout[1] %.8f\n",dstr(checktoshis),dstr(pblock->vtx[0].vout[1].nValue)); - return(-1); - } - } - } + if ( komodo_checkcommission(pblock,height) < 0 ) + return(-1); } //fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed); if ( failed != 0 && possible == 0 && notaryid < 0 ) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 410e106ae..283c2ef0c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -653,7 +653,7 @@ void komodo_passport_iteration(); int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtime) // verify above block is valid pax pricing { static uint256 array[64]; static int32_t numbanned,indallvouts; - int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,notmatched=0,matched=0,kmdheights[256],otherheights[256]; uint256 hash,txids[256]; char symbol[KOMODO_ASSETCHAIN_MAXLEN],base[KOMODO_ASSETCHAIN_MAXLEN]; uint16_t vouts[256]; int8_t baseids[256]; uint8_t *script,opcode,rmd160s[256*20]; uint64_t total,subsidy,available,deposited,issued,withdrawn,approved,redeemed,checktoshis,seed; int64_t values[256],srcvalues[256]; struct pax_transaction *pax; struct komodo_state *sp; CTransaction tx; + int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,notmatched=0,matched=0,kmdheights[256],otherheights[256]; uint256 hash,txids[256]; char symbol[KOMODO_ASSETCHAIN_MAXLEN],base[KOMODO_ASSETCHAIN_MAXLEN]; uint16_t vouts[256]; int8_t baseids[256]; uint8_t *script,opcode,rmd160s[256*20]; uint64_t total,subsidy,available,deposited,issued,withdrawn,approved,redeemed,seed; int64_t checktoshis,values[256],srcvalues[256]; struct pax_transaction *pax; struct komodo_state *sp; CTransaction tx; activation = 235300; if ( *(int32_t *)&array[0] == 0 ) numbanned = komodo_bannedset(&indallvouts,array,(int32_t)(sizeof(array)/sizeof(*array))); @@ -743,11 +743,20 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim } else { - if ( overflow != 0 || total > 0 || strangeout != 0 ) + checktoshis = 0; + if ( ASSETCHAINS_COMMISSION != 0 ) { - if ( strangeout != 0 ) - fprintf(stderr,">>>>>>>>>>>>> %s DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",ASSETCHAINS_SYMBOL,height,strangeout,notmatched); - return(-1); + if ( (checktoshis= komodo_checkcommission(&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); + return(-1); + } } } return(0); From 44bbf01edf6b4f522132cfe4e52c973d901c93bd Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 May 2018 04:22:02 -1100 Subject: [PATCH 016/100] Fix --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 283c2ef0c..55ab8b477 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -746,7 +746,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim checktoshis = 0; if ( ASSETCHAINS_COMMISSION != 0 ) { - if ( (checktoshis= komodo_checkcommission(&block,height)) < 0 ) + if ( (checktoshis= komodo_checkcommission((CBlock *)&block,height)) < 0 ) return(-1); } else From dc241f13d0460b094f911d0f58d5b04325e72d7e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 May 2018 05:30:21 -1100 Subject: [PATCH 017/100] Special case ht.1 --- src/komodo_gateway.h | 2 +- src/miner.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 55ab8b477..3b2922a7b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -744,7 +744,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim else { checktoshis = 0; - if ( ASSETCHAINS_COMMISSION != 0 ) + if ( ASSETCHAINS_COMMISSION != 0 && height > 1 ) { if ( (checktoshis= komodo_checkcommission((CBlock *)&block,height)) < 0 ) return(-1); diff --git a/src/miner.cpp b/src/miner.cpp index c789eb41d..081796aaa 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -440,7 +440,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) txNew.vin[0].scriptSig = CScript() << nHeight << OP_0; pblock->vtx[0] = txNew; - if ( ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block)) != 0 ) + if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block)) != 0 ) { int32_t i; uint8_t *ptr; txNew.vout.resize(2); From c9855c14864df71b7cfc332c1af02b9941c67137 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 May 2018 08:34:47 -1100 Subject: [PATCH 018/100] Height 1 exclusion -ac_pubkey --- src/komodo_bitcoind.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b48c40442..5b19dfb6f 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1364,8 +1364,11 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) return(-1); } - if ( komodo_checkcommission(pblock,height) < 0 ) - return(-1); + else + { + if ( komodo_checkcommission(pblock,height) < 0 ) + return(-1); + } } //fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed); if ( failed != 0 && possible == 0 && notaryid < 0 ) From 44b541d92fd5f84a7c1470836d38e72e8b44b03f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 May 2018 10:52:43 -1100 Subject: [PATCH 019/100] Add VRSC to assetchains.old --- src/assetchains.old | 65 +-------------------------------------------- 1 file changed, 1 insertion(+), 64 deletions(-) diff --git a/src/assetchains.old b/src/assetchains.old index cf46922de..af9361746 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -34,68 +34,5 @@ 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 & -#sleep $delay +~/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=USD -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=EUR -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=JPY -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=GBP -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=AUD -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=CAD -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=CHF -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=NZD -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=CNY -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=RUB -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=MXN -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=BRL -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=INR -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=HKD -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=TRY -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=ZAR -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=PLN -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=NOK -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=SEK -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=DKK -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=CZK -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=HUF -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=ILS -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=KRW -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=MYR -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=PHP -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=RON -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=SGD -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=THB -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=BGN -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=IDR -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=HRK -addnode=78.47.196.146 $1 & From b6e71fe96c8bc1518ab58a8c48f488095de07e5b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 May 2018 12:30:16 -1100 Subject: [PATCH 020/100] Encode Ccid into upper MoMdepth --- src/komodo.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index d01de9553..efb59dee1 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -113,7 +113,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char if ( fread(&MoMdepth,1,sizeof(MoMdepth),fp) != sizeof(MoMdepth) ) errs++; if ( 1 && ASSETCHAINS_SYMBOL[0] != 0 && sp != 0 ) - printf("%s load[%s.%d -> %s] NOTARIZED %d %s MoM.%s %d\n",ASSETCHAINS_SYMBOL,symbol,sp->NUM_NPOINTS,dest,notarized_height,notarized_hash.ToString().c_str(),MoM.ToString().c_str(),MoMdepth); + printf("%s load[%s.%d -> %s] NOTARIZED %d %s MoM.%s %d CCid.%u\n",ASSETCHAINS_SYMBOL,symbol,sp->NUM_NPOINTS,dest,notarized_height,notarized_hash.ToString().c_str(),MoM.ToString().c_str(),MoMdepth&0xffff,(MoMdepth>>16)&0xffff); } else { @@ -258,7 +258,7 @@ int32_t komodo_parsestatefiledata(struct komodo_state *sp,uint8_t *filedata,long if ( memread(&MoMdepth,sizeof(MoMdepth),filedata,&fpos,datalen) != sizeof(MoMdepth) ) errs++; if ( 1 && ASSETCHAINS_SYMBOL[0] != 0 && sp != 0 ) - printf("%s load[%s.%d -> %s] NOTARIZED %d %s MoM.%s %d\n",ASSETCHAINS_SYMBOL,symbol,sp->NUM_NPOINTS,dest,notarized_height,notarized_hash.ToString().c_str(),MoM.ToString().c_str(),MoMdepth); + printf("%s load[%s.%d -> %s] NOTARIZED %d %s MoM.%s %d CCid.%u\n",ASSETCHAINS_SYMBOL,symbol,sp->NUM_NPOINTS,dest,notarized_height,notarized_hash.ToString().c_str(),MoM.ToString().c_str(),MoMdepth&0xffff,(MoMdepth>>16)&0xffff); } else { @@ -480,7 +480,7 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar //printf("ht.%d func N ht.%d errs.%d\n",height,NOTARIZED_HEIGHT,errs); if ( sp != 0 ) { - if ( sp->MoMdepth > 0 && sp->MoM != zero ) + if ( sp->MoMdepth != 0 && sp->MoM != zero ) fputc('M',fp); else fputc('N',fp); if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) ) @@ -491,7 +491,7 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar errs++; if ( fwrite(&sp->NOTARIZED_DESTTXID,1,sizeof(sp->NOTARIZED_DESTTXID),fp) != sizeof(sp->NOTARIZED_DESTTXID) ) errs++; - if ( sp->MoMdepth > 0 && sp->MoM != zero ) + if ( sp->MoMdepth != 0 && sp->MoM != zero ) { if ( fwrite(&sp->MoM,1,sizeof(sp->MoM),fp) != sizeof(sp->MoM) ) errs++; @@ -641,10 +641,12 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&MoM); len += iguana_rwnum(0,&scriptbuf[len],sizeof(MoMdepth),(uint8_t *)&MoMdepth); ccdata.MoMdata.MoM = MoM; - ccdata.MoMdata.MoMdepth = MoMdepth; + ccdata.MoMdata.MoMdepth = MoMdepth & 0xffff; if ( len+sizeof(ccdata.CCid)-opoffset <= opretlen ) { len += iguana_rwnum(0,&scriptbuf[len],sizeof(ccdata.CCid),(uint8_t *)&ccdata.CCid); + if ( ((MoMdepth>>16) & 0xffff) != (ccdata.CCid & 0xffff) ) + fprintf(stderr,"%s CCid mismatch %u != %u\n",ASSETCHAINS_SYMBOL,((MoMdepth>>16) & 0xffff),(ccdata.CCid & 0xffff)); ccdata.len = sizeof(ccdata.CCid); if ( ASSETCHAINS_SYMBOL[0] != 0 ) { @@ -670,7 +672,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } else ccdata.len = MoMoMdata.len = 0; } } - if ( MoM == zero || MoMdepth > *notarizedheightp || MoMdepth < 0 ) + if ( MoM == zero || (MoMdepth&0xffff) > *notarizedheightp || (MoMdepth&0xffff) < 0 ) { memset(&MoM,0,sizeof(MoM)); MoMdepth = 0; @@ -679,7 +681,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr { komodo_rwccdata(ASSETCHAINS_SYMBOL,1,&ccdata,&MoMoMdata); if ( matched != 0 ) - printf("[%s] matched.%d VALID (%s) MoM.%s [%d]\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth); + printf("[%s] matched.%d VALID (%s) MoM.%s [%d] CCid.%u\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth&0xffff,(MoMdepth>>16)&0xffff); } if ( MoMoMdata.pairs != 0 ) free(MoMoMdata.pairs); @@ -693,7 +695,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr sp->NOTARIZED_HEIGHT = *notarizedheightp; sp->NOTARIZED_HASH = srchash; sp->NOTARIZED_DESTTXID = desttxid; - if ( MoM != zero && MoMdepth > 0 ) + if ( MoM != zero && (MoMdepth&0xffff) > 0 ) { sp->MoM = MoM; sp->MoMdepth = MoMdepth; From 1b9f98cd1980493f995c5c1bef0f12d8b81c0397 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 May 2018 12:57:21 -1100 Subject: [PATCH 021/100] Truncate MoMdepth --- src/komodo_bitcoind.h | 2 +- src/komodo_ccdata.h | 1 + src/komodo_notary.h | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 5b19dfb6f..24f510b8b 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -932,7 +932,7 @@ int32_t komodo_MoM(int32_t *notarized_heightp,uint256 *MoMp,uint256 *kmdtxidp,in memset(MoMp,0,sizeof(*MoMp)); memset(kmdtxidp,0,sizeof(*kmdtxidp)); *notarized_heightp = 0; - if ( depth > 0 && notarized_ht > 0 && nHeight > notarized_ht-depth && nHeight <= notarized_ht ) + if ( depth != 0 && notarized_ht > 0 && nHeight > notarized_ht-depth && nHeight <= notarized_ht ) { *MoMp = MoM; *notarized_heightp = notarized_ht; diff --git a/src/komodo_ccdata.h b/src/komodo_ccdata.h index 058e38cee..6e7d0fabe 100644 --- a/src/komodo_ccdata.h +++ b/src/komodo_ccdata.h @@ -45,6 +45,7 @@ bits256 iguana_merkle(bits256 *tree,int32_t txn_count) uint256 komodo_calcMoM(int32_t height,int32_t MoMdepth) { static uint256 zero; bits256 MoM,*tree; CBlockIndex *pindex; int32_t i; + MoMdepth &= 0xffff; if ( MoMdepth >= height ) return(zero); tree = (bits256 *)calloc(MoMdepth * 3,sizeof(*tree)); diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 25a03f83b..f83f85afe 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -392,7 +392,7 @@ struct notarized_checkpoint *komodo_npptr(int32_t height) for (i=sp->NUM_NPOINTS-1; i>=0; i--) { np = &sp->NPOINTS[i]; - if ( np->MoMdepth > 0 && height > np->notarized_height-np->MoMdepth && height <= np->notarized_height ) + if ( np->MoMdepth != 0 && height > np->notarized_height-(np->MoMdepth&0xffff) && height <= np->notarized_height ) return(np); } } @@ -447,7 +447,7 @@ int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,in *MoMoMdepthp = np->MoMoMdepth; *kmdstartip = np->kmdstarti; *kmdendip = np->kmdendi; - return(np->MoMdepth); + return(np->MoMdepth & 0xffff); } *notarized_htp = *MoMoMoffsetp = *MoMoMdepthp = *kmdstartip = *kmdendip = 0; memset(MoMp,0,sizeof(*MoMp)); From 627aaf734b425f0bb608f17ed73576de3c295988 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 May 2018 05:07:18 -1100 Subject: [PATCH 022/100] Skip invalid Ccid compare --- src/komodo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index efb59dee1..248396812 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -645,8 +645,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr if ( len+sizeof(ccdata.CCid)-opoffset <= opretlen ) { len += iguana_rwnum(0,&scriptbuf[len],sizeof(ccdata.CCid),(uint8_t *)&ccdata.CCid); - if ( ((MoMdepth>>16) & 0xffff) != (ccdata.CCid & 0xffff) ) - fprintf(stderr,"%s CCid mismatch %u != %u\n",ASSETCHAINS_SYMBOL,((MoMdepth>>16) & 0xffff),(ccdata.CCid & 0xffff)); + //if ( ((MoMdepth>>16) & 0xffff) != (ccdata.CCid & 0xffff) ) + // fprintf(stderr,"%s CCid mismatch %u != %u\n",ASSETCHAINS_SYMBOL,((MoMdepth>>16) & 0xffff),(ccdata.CCid & 0xffff)); ccdata.len = sizeof(ccdata.CCid); if ( ASSETCHAINS_SYMBOL[0] != 0 ) { From fe98fc34b916c3f480df1ee65b4e9b56d363626d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 03:30:25 -1100 Subject: [PATCH 023/100] Nameoffset --- src/komodo.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 248396812..9b069624b 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -603,9 +603,12 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } offset = 32 * (1 + matched) + 4; nameoffset = (int32_t)strlen((char *)&scriptbuf[len+offset]); - if ( nameoffset == 2 ) + /*if ( nameoffset == 2 ) nameoffset += 2; - else nameoffset++; + else if ( nameoffset == 1 ) + nameoffset += 3; + else*/ + nameoffset++; memset(&ccdata,0,sizeof(ccdata)); strncpy(ccdata.symbol,(char *)&scriptbuf[len+offset],sizeof(ccdata.symbol)); if ( j == 1 && opretlen >= len+offset-opoffset ) @@ -635,7 +638,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr ccdata.MoMdata.notarized_height = *notarizedheightp; ccdata.MoMdata.height = height; ccdata.MoMdata.txi = i; - //printf("nameoffset.%d len.%d + 36 %d vs opretlen.%d\n",nameoffset,len,len+36,opretlen); + printf("nameoffset.%d len.%d + 36 %d opoffset.%d vs opretlen.%d\n",nameoffset,len,len+36,opoffset,opretlen); if ( len+36-opoffset <= opretlen ) { len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&MoM); From 4a15f78eada27e2a254b2621ae57e75c38fecc8e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 04:02:42 -1100 Subject: [PATCH 024/100] Kv test --- src/komodo.h | 9 ++------- src/komodo_kv.h | 4 ++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 9b069624b..c6c523683 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -603,12 +603,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } offset = 32 * (1 + matched) + 4; nameoffset = (int32_t)strlen((char *)&scriptbuf[len+offset]); - /*if ( nameoffset == 2 ) - nameoffset += 2; - else if ( nameoffset == 1 ) - nameoffset += 3; - else*/ - nameoffset++; + nameoffset++; memset(&ccdata,0,sizeof(ccdata)); strncpy(ccdata.symbol,(char *)&scriptbuf[len+offset],sizeof(ccdata.symbol)); if ( j == 1 && opretlen >= len+offset-opoffset ) @@ -638,7 +633,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr ccdata.MoMdata.notarized_height = *notarizedheightp; ccdata.MoMdata.height = height; ccdata.MoMdata.txi = i; - printf("nameoffset.%d len.%d + 36 %d opoffset.%d vs opretlen.%d\n",nameoffset,len,len+36,opoffset,opretlen); + //printf("nameoffset.%d len.%d + 36 %d opoffset.%d vs opretlen.%d\n",nameoffset,len,len+36,opoffset,opretlen); if ( len+36-opoffset <= opretlen ) { len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&MoM); diff --git a/src/komodo_kv.h b/src/komodo_kv.h index 58d550414..dbcf99f6c 100644 --- a/src/komodo_kv.h +++ b/src/komodo_kv.h @@ -64,7 +64,7 @@ int32_t komodo_kvsearch(uint256 *pubkeyp,int32_t current_height,uint32_t *flagsp if ( ptr != 0 ) { duration = komodo_kvduration(ptr->flags); - //printf("duration.%d flags.%d current.%d ht.%d keylen.%d valuesize.%d\n",duration,ptr->flags,current_height,ptr->height,ptr->keylen,ptr->valuesize); + printf("duration.%d flags.%d current.%d ht.%d keylen.%d valuesize.%d\n",duration,ptr->flags,current_height,ptr->height,ptr->keylen,ptr->valuesize); if ( current_height > (ptr->height + duration) ) { HASH_DELETE(hh,KOMODO_KV,ptr); @@ -171,7 +171,7 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value) memcpy(ptr->key,key,keylen); newflag = 1; HASH_ADD_KEYPTR(hh,KOMODO_KV,ptr->key,ptr->keylen,ptr); - //printf("KV add.(%s) (%s)\n",ptr->key,valueptr); + printf("KV add.(%s) (%s)\n",ptr->key,valueptr); } if ( newflag != 0 || (ptr->flags & KOMODO_KVPROTECTED) == 0 ) { From 29806831f29e0f3acfa009d03102df9f1dc6f529 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 04:08:08 -1100 Subject: [PATCH 025/100] Print --- src/komodo_kv.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_kv.h b/src/komodo_kv.h index dbcf99f6c..0b0b21161 100644 --- a/src/komodo_kv.h +++ b/src/komodo_kv.h @@ -64,7 +64,7 @@ int32_t komodo_kvsearch(uint256 *pubkeyp,int32_t current_height,uint32_t *flagsp if ( ptr != 0 ) { duration = komodo_kvduration(ptr->flags); - printf("duration.%d flags.%d current.%d ht.%d keylen.%d valuesize.%d\n",duration,ptr->flags,current_height,ptr->height,ptr->keylen,ptr->valuesize); + fprintf(stderr,"duration.%d flags.%d current.%d ht.%d keylen.%d valuesize.%d\n",duration,ptr->flags,current_height,ptr->height,ptr->keylen,ptr->valuesize); if ( current_height > (ptr->height + duration) ) { HASH_DELETE(hh,KOMODO_KV,ptr); @@ -171,7 +171,7 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value) memcpy(ptr->key,key,keylen); newflag = 1; HASH_ADD_KEYPTR(hh,KOMODO_KV,ptr->key,ptr->keylen,ptr); - printf("KV add.(%s) (%s)\n",ptr->key,valueptr); + fprintf(stderr,"KV add.(%s) (%s)\n",ptr->key,valueptr); } if ( newflag != 0 || (ptr->flags & KOMODO_KVPROTECTED) == 0 ) { From ebe5e09afe2cc5694ebecfb45ef60f6e40d8a839 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 04:10:52 -1100 Subject: [PATCH 026/100] Test --- src/komodo_kv.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_kv.h b/src/komodo_kv.h index 0b0b21161..116924b5a 100644 --- a/src/komodo_kv.h +++ b/src/komodo_kv.h @@ -88,7 +88,7 @@ int32_t komodo_kvsearch(uint256 *pubkeyp,int32_t current_height,uint32_t *flagsp if ( (retval= ptr->valuesize) > 0 ) memcpy(value,ptr->value,retval); } - } + } else fprintf(stderr,"couldnt find (%s)\n",(char *)key); portable_mutex_unlock(&KOMODO_KV_mutex); if ( retval < 0 ) { @@ -151,6 +151,7 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value) HASH_FIND(hh,KOMODO_KV,key,keylen,ptr); if ( ptr != 0 ) { + fprintf(stderr,"(%s) already there\n",(char *)key); //if ( (ptr->flags & KOMODO_KVPROTECTED) != 0 ) { tstr = (char *)"transfer:"; From 3f1012ff4c136b2e7d7630b4816a7e0621171ac2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 04:15:07 -1100 Subject: [PATCH 027/100] Test --- src/komodo_kv.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo_kv.h b/src/komodo_kv.h index 116924b5a..80fac5ff8 100644 --- a/src/komodo_kv.h +++ b/src/komodo_kv.h @@ -111,13 +111,13 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value) if ( keylen+13 > opretlen ) { static uint32_t counter; - if ( ++counter < 1 ) - printf("komodo_kvupdate: keylen.%d + 13 > opretlen.%d, this can be ignored\n",keylen,opretlen); + if ( ++counter < 100 ) + fprintf(stderr,"komodo_kvupdate: keylen.%d + 13 > opretlen.%d, this can be ignored\n",keylen,opretlen); return; } valueptr = &key[keylen]; fee = komodo_kvfee(flags,opretlen,keylen); - //printf("fee %.8f vs %.8f flags.%d keylen.%d valuesize.%d height.%d (%02x %02x %02x) (%02x %02x %02x)\n",(double)fee/COIN,(double)value/COIN,flags,keylen,valuesize,height,key[0],key[1],key[2],valueptr[0],valueptr[1],valueptr[2]); + printf("fee %.8f vs %.8f flags.%d keylen.%d valuesize.%d height.%d (%02x %02x %02x) (%02x %02x %02x)\n",(double)fee/COIN,(double)value/COIN,flags,keylen,valuesize,height,key[0],key[1],key[2],valueptr[0],valueptr[1],valueptr[2]); if ( value >= fee ) { coresize = (int32_t)(sizeof(flags)+sizeof(height)+sizeof(keylen)+sizeof(valuesize)+keylen+valuesize+1); @@ -142,7 +142,7 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value) { if ( komodo_kvsigverify(keyvalue,keylen+refvaluesize,refpubkey,sig) < 0 ) { - printf("komodo_kvsigverify error [%d]\n",coresize-13); + fprintf(stderr,"komodo_kvsigverify error [%d]\n",coresize-13); return; } } @@ -194,7 +194,7 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value) ptr->height = height; ptr->flags = flags; // jl777 used to or in KVPROTECTED portable_mutex_unlock(&KOMODO_KV_mutex); - } else fprintf(stderr,"size mismatch %d vs %d\n",opretlen,coresize); + } else fprintf(stderr,"KV update size mismatch %d vs %d\n",opretlen,coresize); } else fprintf(stderr,"not enough fee\n"); } From 4263c6935d12c93287b071f69a106199698656cc Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 04:19:53 -1100 Subject: [PATCH 028/100] Prints --- src/komodo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index c6c523683..79d511db2 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -311,7 +311,7 @@ int32_t komodo_parsestatefiledata(struct komodo_state *sp,uint8_t *filedata,long { if ( memread(opret,olen,filedata,&fpos,datalen) != olen ) errs++; - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 && matched != 0 ) + if ( 1 && ASSETCHAINS_SYMBOL[0] != 0 && matched != 0 ) { int32_t i; for (i=0; i Date: Fri, 1 Jun 2018 04:29:16 -1100 Subject: [PATCH 029/100] Fix state update --- src/komodo.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 79d511db2..c94dc0ece 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -717,13 +717,13 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr fwrite(&signedmask,1,sizeof(signedmask),signedfp); fflush(signedfp); } - if ( opretlen > len && scriptbuf[len] == 'A' ) - { - //for (i=0; i len && scriptbuf[len] == 'A' ) + { + for (i=0; i 600000 && matched != 0 ) From dd801e5d470238ae096b9875300e318d9b107e7d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 04:43:42 -1100 Subject: [PATCH 030/100] Test --- src/komodo.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index c94dc0ece..0a0fa2cd8 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -601,6 +601,11 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr if ( strcmp(ASSETCHAINS_SYMBOL,(char *)&scriptbuf[len+32*2+4]) == 0 ) matched = 1; } + if ( scriptbuf[len] == 'K' ) + { + fprintf(stderr,"KV OPRET len.%d\n",opretlen); + return(-1); + } offset = 32 * (1 + matched) + 4; nameoffset = (int32_t)strlen((char *)&scriptbuf[len+offset]); nameoffset++; @@ -717,13 +722,13 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr fwrite(&signedmask,1,sizeof(signedmask),signedfp); fflush(signedfp); } - } - if ( opretlen > len && scriptbuf[len] == 'A' ) - { - for (i=0; i len && scriptbuf[len] == 'A' ) + { + //for (i=0; i 600000 && matched != 0 ) From b8fef917d954595dafb583d7b13ed90ef825fcb8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 04:46:41 -1100 Subject: [PATCH 031/100] Test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 0a0fa2cd8..d69768e8f 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -603,7 +603,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } if ( scriptbuf[len] == 'K' ) { - fprintf(stderr,"KV OPRET len.%d\n",opretlen); + fprintf(stderr,"i.%d j.%d KV OPRET len.%d %.8f\n",i,j,opretlen,dstr(value)); return(-1); } offset = 32 * (1 + matched) + 4; From 265f4e9675a2c525396d925a1baf4da74e6f3608 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 05:44:42 -1100 Subject: [PATCH 032/100] Print --- src/miner.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 081796aaa..79e5d619c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -957,9 +957,7 @@ void static BitcoinMiner() solutionTargetChecks.increment(); B = *pblock; h = UintToArith256(B.GetHash()); - if ( h > hashTarget ) - return false; - /*for (z=31; z>=16; z--) + for (z=31; z>=16; z--) fprintf(stderr,"%02x",((uint8_t *)&h)[z]); fprintf(stderr," mined "); for (z=31; z>=16; z--) @@ -967,7 +965,9 @@ void static BitcoinMiner() fprintf(stderr," hashTarget "); for (z=31; z>=16; z--) fprintf(stderr,"%02x",((uint8_t *)&HASHTarget_POW)[z]); - fprintf(stderr," POW\n");*/ + fprintf(stderr," POW\n"); + if ( h > hashTarget ) + return false; if ( NOTARY_PUBKEY33[0] != 0 && B.nTime > GetAdjustedTime() ) { fprintf(stderr,"need to wait %d seconds to submit block\n",(int32_t)(B.nTime - GetAdjustedTime())); From 2515c9f22a161519a2f893a22bab172fb3885342 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 05:52:39 -1100 Subject: [PATCH 033/100] First 10 blocks as normal --- src/komodo_bitcoind.h | 2 +- src/miner.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 24f510b8b..5f96bf2b8 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1147,7 +1147,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he { CBlockIndex *pindex; arith_uint256 bnTarget,hashval,sum,ave; bool fNegative,fOverflow; int32_t i,n,ht,percPoS,diff,val; *percPoSp = percPoS = 0; - if ( height < 3 ) + if ( height < 10 ) return(target); sum = arith_uint256(0); ave = sum; diff --git a/src/miner.cpp b/src/miner.cpp index 79e5d619c..9dd800cdd 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -940,7 +940,7 @@ void static BitcoinMiner() // (x_1, x_2, ...) = A(I, V, n, k) LogPrint("pow", "Running Equihash solver \"%s\" with nNonce = %s\n",solver, pblock->nNonce.ToString()); arith_uint256 hashTarget; - if ( NOTARY_PUBKEY33[0] == 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 ) + if ( NOTARY_PUBKEY33[0] == 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 && Mining_height > 10 ) hashTarget = HASHTarget_POW; else hashTarget = HASHTarget; std::function)> validBlock = From e83bf6b3cbbc701dd0eae09a5ef0010625af8317 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 06:05:23 -1100 Subject: [PATCH 034/100] Fix PoS PoW diff --- src/komodo_bitcoind.h | 5 ++++- src/main.cpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 5f96bf2b8..5b605a4aa 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1154,6 +1154,8 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he for (i=n=0; i<100; i++) { ht = height - 100 + i; + if ( ht <= 1 ) + continue; if ( (pindex= komodo_chainactive(ht)) != 0 ) { bnTarget.SetCompact(pindex->nBits,&fNegative,&fOverflow); @@ -1341,7 +1343,8 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) { if ( slowflag != 0 ) bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); - else bnTarget = (bnTarget / arith_uint256(KOMODO_POWMINMULT)); // lower bound + else if ( height > 100 ) + bnTarget = (bnTarget / arith_uint256(KOMODO_POWMINMULT)); // lower bound if ( bhash > bnTarget ) { for (i=31; i>=16; i--) diff --git a/src/main.cpp b/src/main.cpp index 34d939431..12433f1e8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4273,7 +4273,7 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo if ( checked != 0 && komodo_checkPOW(from_miner && ASSETCHAINS_STAKED == 0,pblock,height) < 0 ) { checked = 0; - fprintf(stderr,"passed checkblock but failed checkPOW.%d\n",from_miner && ASSETCHAINS_STAKED == 0); + //fprintf(stderr,"passed checkblock but failed checkPOW.%d\n",from_miner && ASSETCHAINS_STAKED == 0); } if (!checked && futureblock == 0) { From 3753f56834d0baf9452098c962cd8a6249988a41 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 06:16:44 -1100 Subject: [PATCH 035/100] Test --- src/komodo_bitcoind.h | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 5b605a4aa..83f3bb518 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1147,7 +1147,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he { CBlockIndex *pindex; arith_uint256 bnTarget,hashval,sum,ave; bool fNegative,fOverflow; int32_t i,n,ht,percPoS,diff,val; *percPoSp = percPoS = 0; - if ( height < 10 ) + if ( height <= 10 ) return(target); sum = arith_uint256(0); ave = sum; @@ -1161,7 +1161,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he bnTarget.SetCompact(pindex->nBits,&fNegative,&fOverflow); bnTarget = (bnTarget / arith_uint256(KOMODO_POWMINMULT)); hashval = UintToArith256(pindex->GetBlockHash()); - if ( hashval <= bnTarget ) // PoW is never as easy as PoS/64, some PoS will be counted as PoW + if ( hashval <= bnTarget ) // PoW is never as easy as PoS/16, some PoS will be counted as PoW { fprintf(stderr,"1"); sum += hashval; @@ -1176,7 +1176,9 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he fprintf(stderr," %d, ",percPoS); } } - fprintf(stderr," -> %d%% percPoS ht.%d\n",percPoS,height); + if ( n < 100 ) + percPoS = ((percPoS * n) + (goalperc * (100-n))) / 100; + fprintf(stderr," -> %d%% percPoS vs goalperc.%d ht.%d\n",percPoS,goalperc,height); *percPoSp = percPoS; target = (target / arith_uint256(KOMODO_POWMINMULT)); if ( n > 0 ) @@ -1188,16 +1190,6 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he if ( percPoS < goalperc ) // increase PoW diff -> lower bnTarget { bnTarget = (ave * arith_uint256(percPoS * percPoS)) / arith_uint256((goalperc) * (goalperc)); - /*if ( height > 1165 ) - { - if ( height > 1180 ) - { - if ( height > 1230 ) - bnTarget = (ave * arith_uint256(percPoS * percPoS)) / arith_uint256((goalperc) * (goalperc)); - else bnTarget = (ave * arith_uint256(percPoS * percPoS)) / arith_uint256(goalperc * goalperc); - } - else bnTarget = (ave * arith_uint256(goalperc * goalperc)) / arith_uint256(2 * (percPoS + goalperc) * (percPoS + goalperc)); - } else bnTarget = (ave * arith_uint256(goalperc)) / arith_uint256(percPoS + goalperc);*/ if ( 1 ) { for (i=31; i>=24; i--) From a2ec2aaad257d27d787e9dd9656d2c56d10db28c Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 06:25:31 -1100 Subject: [PATCH 036/100] Stake best utxo --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 9dd800cdd..3c07fbb16 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -415,14 +415,14 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if ( (siglen= komodo_staked(txStaked,pblock->nBits,&blocktime,&txtime,&utxotxid,&utxovout,&utxovalue,utxosig)) > 0 ) { CAmount txfees = 0; - if ( GetAdjustedTime() < blocktime-13 ) + if ( (int32_t)chainActive.Tip()->nHeight+1 > 100 && GetAdjustedTime() < blocktime-13 ) return(0); pblock->vtx.push_back(txStaked); pblocktemplate->vTxFees.push_back(txfees); pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txStaked)); nFees += txfees; pblock->nTime = blocktime; - //printf("PoS ht.%d t%u\n",(int32_t)chainActive.Tip()->nHeight+1,blocktime); + printf("staking PoS ht.%d t%u lag.%u\n",(int32_t)chainActive.Tip()->nHeight+1,blocktime,GetAdjustedTime() - (blocktime-13)); } else return(0); //fprintf(stderr,"no utxos eligible for staking\n"); } From 535f0c1a2c31188f53c27c1eb75cf89771f737a5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 06:26:38 -1100 Subject: [PATCH 037/100] Syntax --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 3c07fbb16..08f3da2be 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -422,7 +422,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txStaked)); nFees += txfees; pblock->nTime = blocktime; - printf("staking PoS ht.%d t%u lag.%u\n",(int32_t)chainActive.Tip()->nHeight+1,blocktime,GetAdjustedTime() - (blocktime-13)); + printf("staking PoS ht.%d t%u lag.%u\n",(int32_t)chainActive.Tip()->nHeight+1,blocktime,(uint32_t)(GetAdjustedTime() - (blocktime-13))); } else return(0); //fprintf(stderr,"no utxos eligible for staking\n"); } From 7e679101e1a2afab6893e82d582945c81b0920a2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 06:33:50 -1100 Subject: [PATCH 038/100] Print --- src/komodo_bitcoind.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 83f3bb518..fd8b19a55 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1128,7 +1128,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh } } //fprintf(stderr,"iterated until i.%d winner.%d\n",i,winner); - if ( 0 ) + if ( 1 ) { for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); @@ -1138,7 +1138,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d t.%u %.8f diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,dstr(value),(int32_t)diff); } } - if ( nHeight < 2 ) + if ( nHeight < 10 ) return(blocktime); return(blocktime * winner); } From 2214fc14b8d44ce081566a7abd116641f648a2c6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 06:39:23 -1100 Subject: [PATCH 039/100] Prints --- src/miner.cpp | 2 -- src/wallet/rpcwallet.cpp | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 08f3da2be..dfad0f402 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -410,8 +410,6 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) { uint64_t txfees,utxovalue; uint32_t txtime; uint256 utxotxid,revtxid; int32_t i,siglen,numsigs,utxovout; uint8_t utxosig[128],*ptr; CMutableTransaction txStaked = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); - //if ( blocktime > pindexPrev->GetMedianTimePast()+60 ) - // blocktime = pindexPrev->GetMedianTimePast() + 60; if ( (siglen= komodo_staked(txStaked,pblock->nBits,&blocktime,&txtime,&utxotxid,&utxovout,&utxovalue,utxosig)) > 0 ) { CAmount txfees = 0; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 0b3b45a80..bac222f63 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4590,7 +4590,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt { if ( eligible != komodo_stake(1,bnTarget,(uint32_t)tipindex->nHeight+1,out.tx->GetHash(),out.i,eligible,(uint32_t)tipindex->nTime,(char *)CBitcoinAddress(address).ToString().c_str()) ) { - //fprintf(stderr,"tip.%d validation of winning blocktime failed %u -> eligible.%u\n",(uint32_t)tipindex->nHeight,*blocktimep,eligible); + fprintf(stderr,"tip.%d validation of winning blocktime failed %u -> eligible.%u\n",(uint32_t)tipindex->nHeight,*blocktimep,eligible); } else if ( earliest == 0 || eligible < earliest || (eligible == earliest && (*utxovaluep == 0 || nValue < *utxovaluep)) ) { @@ -4632,9 +4632,9 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt for (i=0; i Date: Fri, 1 Jun 2018 06:45:45 -1100 Subject: [PATCH 040/100] -print --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index dfad0f402..ef943b3aa 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -955,7 +955,7 @@ void static BitcoinMiner() solutionTargetChecks.increment(); B = *pblock; h = UintToArith256(B.GetHash()); - for (z=31; z>=16; z--) + /*for (z=31; z>=16; z--) fprintf(stderr,"%02x",((uint8_t *)&h)[z]); fprintf(stderr," mined "); for (z=31; z>=16; z--) @@ -963,7 +963,7 @@ void static BitcoinMiner() fprintf(stderr," hashTarget "); for (z=31; z>=16; z--) fprintf(stderr,"%02x",((uint8_t *)&HASHTarget_POW)[z]); - fprintf(stderr," POW\n"); + fprintf(stderr," POW\n");*/ if ( h > hashTarget ) return false; if ( NOTARY_PUBKEY33[0] != 0 && B.nTime > GetAdjustedTime() ) From 2e4cc2a27f65b18335190497036139cc9c2ece94 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 06:54:14 -1100 Subject: [PATCH 041/100] Test --- src/wallet/rpcwallet.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index bac222f63..b09e656b8 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4550,7 +4550,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) 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) { - set setAddress; int32_t i,siglen=0,nMinDepth = 1,nMaxDepth = 9999999; vector vecOutputs; uint32_t eligible,earliest = 0; CScript best_scriptPubKey; arith_uint256 bnTarget; bool fNegative,fOverflow; + set setAddress; int32_t i,siglen=0,nMinDepth = 1,nMaxDepth = 99999999; vector vecOutputs; uint32_t eligible,earliest = 0; CScript best_scriptPubKey; arith_uint256 bnTarget; bool fNegative,fOverflow; bnTarget.SetCompact(nBits, &fNegative, &fOverflow); assert(pwalletMain != NULL); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -4562,14 +4562,23 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt BOOST_FOREACH(const COutput& out, vecOutputs) { if ( out.nDepth < nMinDepth || out.nDepth > nMaxDepth ) + { + fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth); continue; + } if ( setAddress.size() ) { CTxDestination address; if (!ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) + { + fprintf(stderr,"komodo_staked ExtractDestination error\n"); continue; + } if (!setAddress.count(address)) + { + fprintf(stderr,"komodo_staked setAddress.count error\n"); continue; + } } CAmount nValue = out.tx->vout[out.i].nValue; const CScript& pk = out.tx->vout[out.i].scriptPubKey; @@ -4602,8 +4611,8 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt *txtimep = (uint32_t)out.tx->nLockTime; fprintf(stderr,"earliest.%u [%d] (%s) nValue %.8f locktime.%u\n",earliest,(int32_t)(earliest- *blocktimep),CBitcoinAddress(address).ToString().c_str(),(double)nValue/COIN,*txtimep); } - } - } + } else fprintf(stderr,"%s not eligible\n",out.tx->GetHash().c_str()); + } else fprintf(stderr,"no tipindex\n"); } if ( earliest != 0 ) { From 65777b40ab38cbea4b5d93969da99c4e85826b7a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 06:56:35 -1100 Subject: [PATCH 042/100] Syntax --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b09e656b8..5bb4a74aa 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4611,7 +4611,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt *txtimep = (uint32_t)out.tx->nLockTime; fprintf(stderr,"earliest.%u [%d] (%s) nValue %.8f locktime.%u\n",earliest,(int32_t)(earliest- *blocktimep),CBitcoinAddress(address).ToString().c_str(),(double)nValue/COIN,*txtimep); } - } else fprintf(stderr,"%s not eligible\n",out.tx->GetHash().c_str()); + } else fprintf(stderr,"%s not eligible\n",out.tx->GetHash()); } else fprintf(stderr,"no tipindex\n"); } if ( earliest != 0 ) From 3851fb86e406f552421a642ad0a22cb4678624d8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 06:58:50 -1100 Subject: [PATCH 043/100] Test --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 5bb4a74aa..0ea28b696 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4611,7 +4611,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt *txtimep = (uint32_t)out.tx->nLockTime; fprintf(stderr,"earliest.%u [%d] (%s) nValue %.8f locktime.%u\n",earliest,(int32_t)(earliest- *blocktimep),CBitcoinAddress(address).ToString().c_str(),(double)nValue/COIN,*txtimep); } - } else fprintf(stderr,"%s not eligible\n",out.tx->GetHash()); + } else fprintf(stderr,"utxo not eligible\n"); } else fprintf(stderr,"no tipindex\n"); } if ( earliest != 0 ) From 985990dded76c10254508b60a9236e1e7653c302 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 07:03:34 -1100 Subject: [PATCH 044/100] +print --- src/komodo_bitcoind.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index fd8b19a55..0ddcb7ffe 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1087,9 +1087,13 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh if ( blocktime < prevtime+57 ) blocktime = prevtime+57; if ( value == 0 || txtime == 0 || blocktime == 0 || prevtime == 0 ) + { + fprintf(stderr,"komodo_stake null %.8f %u %u %u\n",dstr(value),txtime,blocktime,prevtime); return(0); + } if ( (minage= nHeight*3) > 6000 ) minage = 6000; + pindex = 0; if ( blocktime > txtime+minage && (pindex= komodo_chainactive(nHeight>200?nHeight-200:1)) != 0 ) { vcalc_sha256(0,(uint8_t *)&addrhash,(uint8_t *)address,(int32_t)strlen(address)); @@ -1137,7 +1141,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d t.%u %.8f diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,dstr(value),(int32_t)diff); } - } + } else fprintf(stderr,"skip PoS scan: blocktime %u > %u txtime+minage %u\n",blocktime,txtime,minage); if ( nHeight < 10 ) return(blocktime); return(blocktime * winner); From 012026ed973161f14c50f4aa975ff16acbb81e09 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 07:03:52 -1100 Subject: [PATCH 045/100] -print --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 0ea28b696..6dddc5401 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4611,8 +4611,8 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt *txtimep = (uint32_t)out.tx->nLockTime; fprintf(stderr,"earliest.%u [%d] (%s) nValue %.8f locktime.%u\n",earliest,(int32_t)(earliest- *blocktimep),CBitcoinAddress(address).ToString().c_str(),(double)nValue/COIN,*txtimep); } - } else fprintf(stderr,"utxo not eligible\n"); - } else fprintf(stderr,"no tipindex\n"); + } //else fprintf(stderr,"utxo not eligible\n"); + } //else fprintf(stderr,"no tipindex\n"); } if ( earliest != 0 ) { From 3a9d2c4323d29809009c731dfafb39e25572dec7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 07:10:15 -1100 Subject: [PATCH 046/100] Test --- src/komodo_bitcoind.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 0ddcb7ffe..52678da39 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1094,7 +1094,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh if ( (minage= nHeight*3) > 6000 ) minage = 6000; pindex = 0; - if ( blocktime > txtime+minage && (pindex= komodo_chainactive(nHeight>200?nHeight-200:1)) != 0 ) + if ( blocktime >= txtime+minage && (pindex= komodo_chainactive(nHeight>200?nHeight-200:1)) != 0 ) { vcalc_sha256(0,(uint8_t *)&addrhash,(uint8_t *)address,(int32_t)strlen(address)); segid = ((nHeight + addrhash.uints[0]) & 0x3f); @@ -1141,7 +1141,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d t.%u %.8f diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,dstr(value),(int32_t)diff); } - } else fprintf(stderr,"skip PoS scan: blocktime %u > %u txtime+minage %u\n",blocktime,txtime,minage); + } else fprintf(stderr,"skip PoS scan: diff %d blocktime %u > %u txtime+minage %u pindex.%p\n",(int32_t)(blocktime - (txtime+minage)),blocktime,txtime,minage,pindex); if ( nHeight < 10 ) return(blocktime); return(blocktime * winner); From 26a2b5cd68cd713ba18019f46957f02e040575ec Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 07:13:08 -1100 Subject: [PATCH 047/100] Test --- src/komodo_bitcoind.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 52678da39..c9b1cf1c5 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1094,7 +1094,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh if ( (minage= nHeight*3) > 6000 ) minage = 6000; pindex = 0; - if ( blocktime >= txtime+minage && (pindex= komodo_chainactive(nHeight>200?nHeight-200:1)) != 0 ) + if ( (pindex= komodo_chainactive(nHeight>200?nHeight-200:1)) != 0 ) { vcalc_sha256(0,(uint8_t *)&addrhash,(uint8_t *)address,(int32_t)strlen(address)); segid = ((nHeight + addrhash.uints[0]) & 0x3f); @@ -1108,6 +1108,8 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh diff = (iter + blocktime - txtime - minage); if ( diff > 3600*24 ) break; + if ( blocktime+iter+segid*2 < txtime+minage ) + continue; coinage = (value * diff) * ((diff >> 16) + 1); hashval = arith_uint256(supply * 64) * (UintToArith256(hash) / arith_uint256(coinage+1)); if ( hashval <= bnTarget ) @@ -1141,7 +1143,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d t.%u %.8f diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,dstr(value),(int32_t)diff); } - } else fprintf(stderr,"skip PoS scan: diff %d blocktime %u > %u txtime+minage %u pindex.%p\n",(int32_t)(blocktime - (txtime+minage)),blocktime,txtime,minage,pindex); + } //else fprintf(stderr,"skip PoS scan: diff %d blocktime %u > %u txtime+minage %u pindex.%p\n",(int32_t)(blocktime - (txtime+minage)),blocktime,txtime,minage,pindex); if ( nHeight < 10 ) return(blocktime); return(blocktime * winner); From 9b79591bba1d45663902964d0a169ec6c642abee Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 07:20:47 -1100 Subject: [PATCH 048/100] Test --- src/komodo_bitcoind.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index c9b1cf1c5..5f9cbae8a 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1106,8 +1106,10 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh for (iter=0; iter<3600; iter++) { diff = (iter + blocktime - txtime - minage); - if ( diff > 3600*24 ) - break; + if ( iter > 0 ) + diff += iter + segid*2; + //if ( diff > 3600*24 ) + // break; if ( blocktime+iter+segid*2 < txtime+minage ) continue; coinage = (value * diff) * ((diff >> 16) + 1); From ad277ac6449ae51588f0c2c4b4b9a141eb5e80a3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 07:30:49 -1100 Subject: [PATCH 049/100] -print --- 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 5f9cbae8a..a5ef1ccab 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1136,7 +1136,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh } } //fprintf(stderr,"iterated until i.%d winner.%d\n",i,winner); - if ( 1 ) + if ( 0 ) { for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); From 34bcc3094f09d164981f76357a40cdf8d1fc0740 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jun 2018 07:37:41 -1100 Subject: [PATCH 050/100] -print --- src/wallet/rpcwallet.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 6dddc5401..65dd0e22b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4599,7 +4599,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt { if ( eligible != komodo_stake(1,bnTarget,(uint32_t)tipindex->nHeight+1,out.tx->GetHash(),out.i,eligible,(uint32_t)tipindex->nTime,(char *)CBitcoinAddress(address).ToString().c_str()) ) { - fprintf(stderr,"tip.%d validation of winning blocktime failed %u -> eligible.%u\n",(uint32_t)tipindex->nHeight,*blocktimep,eligible); + //fprintf(stderr,"tip.%d validation of winning blocktime failed %u -> eligible.%u\n",(uint32_t)tipindex->nHeight,*blocktimep,eligible); } else if ( earliest == 0 || eligible < earliest || (eligible == earliest && (*utxovaluep == 0 || nValue < *utxovaluep)) ) { @@ -4609,7 +4609,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt decode_hex((uint8_t *)utxotxidp,32,(char *)out.tx->GetHash().GetHex().c_str()); *utxovoutp = out.i; *txtimep = (uint32_t)out.tx->nLockTime; - fprintf(stderr,"earliest.%u [%d] (%s) nValue %.8f locktime.%u\n",earliest,(int32_t)(earliest- *blocktimep),CBitcoinAddress(address).ToString().c_str(),(double)nValue/COIN,*txtimep); + //fprintf(stderr,"earliest.%u [%d] (%s) nValue %.8f locktime.%u\n",earliest,(int32_t)(earliest- *blocktimep),CBitcoinAddress(address).ToString().c_str(),(double)nValue/COIN,*txtimep); } } //else fprintf(stderr,"utxo not eligible\n"); } //else fprintf(stderr,"no tipindex\n"); @@ -4641,7 +4641,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt for (i=0; i Date: Fri, 1 Jun 2018 09:05:10 -1100 Subject: [PATCH 051/100] -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 052/100] 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 053/100] 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 054/100] 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 055/100] 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 056/100] 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 057/100] -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 058/100] 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 059/100] -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 060/100] 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 061/100] 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 062/100] 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 063/100] 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 064/100] 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 065/100] 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 066/100] 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 067/100] 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 068/100] 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 069/100] 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 070/100] 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 071/100] 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 072/100] 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 073/100] 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 074/100] 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 075/100] 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 076/100] 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 077/100] 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 078/100] 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 079/100] 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 080/100] 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 081/100] 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 082/100] 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 083/100] 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 084/100] 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 085/100] 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 086/100] 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 087/100] 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 088/100] 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 089/100] 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 090/100] 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 091/100] 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 092/100] 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 093/100] 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 094/100] 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 095/100] 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 096/100] 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 097/100] 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 098/100] 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 099/100] 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; From 1c03ff0ecf8533958cdb8ecf73879b4b0d02d1c9 Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Mon, 18 Jun 2018 21:15:49 +0700 Subject: [PATCH 100/100] Make src/fiat/zilla executable --- src/fiat/zilla | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 src/fiat/zilla diff --git a/src/fiat/zilla b/src/fiat/zilla old mode 100644 new mode 100755