From 707451ae1d4c574c555305e43017f5ac22350002 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 20 May 2017 17:50:03 +0300 Subject: [PATCH 01/15] 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 d9fe722a4..37acf0d24 100644 --- a/src/komodo_kv.h +++ b/src/komodo_kv.h @@ -136,7 +136,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); + printf("komodo_kvsigverify error [%d]\n",coresize-13); return; } } @@ -165,6 +165,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); } if ( newflag != 0 || (ptr->flags & KOMODO_KVPROTECTED) == 0 ) { From bfa5cb42bdcb43d02027ad9c23e242a99d564891 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 20 May 2017 18:01:11 +0300 Subject: [PATCH 02/15] Test --- 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 37acf0d24..e121a793e 100644 --- a/src/komodo_kv.h +++ b/src/komodo_kv.h @@ -165,7 +165,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 e8533655a72ef8dc6ad8bc350410abd974b9aed9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 21 May 2017 16:57:49 +0300 Subject: [PATCH 03/15] Protect first block --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 05968b2ee..3585cd369 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3329,7 +3329,7 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta // Don't accept any forks from the main chain prior to last checkpoint CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(chainParams.Checkpoints()); int32_t notarized_height; - if (pcheckpoint && nHeight < pcheckpoint->nHeight) + if (pcheckpoint && (nHeight < pcheckpoint->nHeight || nHeight == 1 && chainActive().Tip->nHeight > 1) ) return state.DoS(100, error("%s: forked chain older than last checkpoint (height %d) vs %d", __func__, nHeight,pcheckpoint->nHeight)); else if ( komodo_checkpoint(¬arized_height,nHeight,hash) < 0 ) return state.DoS(100, error("%s: forked chain %d older than last notarized (height %d) vs %d", __func__,nHeight, notarized_height)); From b9910288e5c8f8d75b4035d3b3532f08bc332818 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 23 May 2017 10:28:03 +0300 Subject: [PATCH 04/15] MESH supply change --- src/assetchains | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assetchains b/src/assetchains index 7f278ba4e..a85cdbe38 100755 --- a/src/assetchains +++ b/src/assetchains @@ -19,7 +19,7 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=WLC -ac_supply=210000000 -addnode=148.251.190.89 $1 -gen & ./komodod -pubkey=$pubkey -ac_name=KV -ac_supply=1000000 -addnode=78.47.196.146 $1 -gen & ./komodod -pubkey=$pubkey -ac_name=CEAL -ac_supply=366666666 -addnode=78.47.196.146 $1 -gen & -./komodod -pubkey=$pubkey -ac_name=MESH -ac_supply=1000006 -addnode=78.47.196.146 $1 -gen & +./komodod -pubkey=$pubkey -ac_name=MESH -ac_supply=1000007 -addnode=78.47.196.146 $1 -gen & sleep $delay ./komodod -pubkey=$pubkey -ac_name=USD -addnode=78.47.196.146 $1 & From f15e560cafe78335f608691a163411b388193a3f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 23 May 2017 10:37:28 +0300 Subject: [PATCH 05/15] test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 3585cd369..d53d70673 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3329,7 +3329,7 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta // Don't accept any forks from the main chain prior to last checkpoint CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(chainParams.Checkpoints()); int32_t notarized_height; - if (pcheckpoint && (nHeight < pcheckpoint->nHeight || nHeight == 1 && chainActive().Tip->nHeight > 1) ) + if (pcheckpoint && (nHeight < pcheckpoint->nHeight || nHeight == 1 && chainActive().Height() > 1) ) return state.DoS(100, error("%s: forked chain older than last checkpoint (height %d) vs %d", __func__, nHeight,pcheckpoint->nHeight)); else if ( komodo_checkpoint(¬arized_height,nHeight,hash) < 0 ) return state.DoS(100, error("%s: forked chain %d older than last notarized (height %d) vs %d", __func__,nHeight, notarized_height)); From d1659192fd4baa8ee8c7933c1682e15eb3943728 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 23 May 2017 10:38:52 +0300 Subject: [PATCH 06/15] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index d53d70673..6473a3737 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3329,7 +3329,7 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta // Don't accept any forks from the main chain prior to last checkpoint CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(chainParams.Checkpoints()); int32_t notarized_height; - if (pcheckpoint && (nHeight < pcheckpoint->nHeight || nHeight == 1 && chainActive().Height() > 1) ) + if (pcheckpoint && (nHeight < pcheckpoint->nHeight || nHeight == 1 && chainActive().Tip() != 0 && chainActive().Tip()->nHeight > 1) ) return state.DoS(100, error("%s: forked chain older than last checkpoint (height %d) vs %d", __func__, nHeight,pcheckpoint->nHeight)); else if ( komodo_checkpoint(¬arized_height,nHeight,hash) < 0 ) return state.DoS(100, error("%s: forked chain %d older than last notarized (height %d) vs %d", __func__,nHeight, notarized_height)); From c3803140cc89c8678c026ba490b7636b4d11fdca Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 23 May 2017 10:40:46 +0300 Subject: [PATCH 07/15] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 6473a3737..e46033e09 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3329,7 +3329,7 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta // Don't accept any forks from the main chain prior to last checkpoint CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(chainParams.Checkpoints()); int32_t notarized_height; - if (pcheckpoint && (nHeight < pcheckpoint->nHeight || nHeight == 1 && chainActive().Tip() != 0 && chainActive().Tip()->nHeight > 1) ) + if (pcheckpoint && (nHeight < pcheckpoint->nHeight || nHeight == 1 && chainActive.Tip() != 0 && chainActive.Tip()->nHeight > 1) ) return state.DoS(100, error("%s: forked chain older than last checkpoint (height %d) vs %d", __func__, nHeight,pcheckpoint->nHeight)); else if ( komodo_checkpoint(¬arized_height,nHeight,hash) < 0 ) return state.DoS(100, error("%s: forked chain %d older than last notarized (height %d) vs %d", __func__,nHeight, notarized_height)); From b2c00e543495e38500cb799d0714cb56071002db Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 23 May 2017 11:53:04 +0300 Subject: [PATCH 08/15] Default txindex true --- src/init.cpp | 6 +++--- src/main.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index d17f0a16e..7905b268e 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -856,7 +856,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // if using block pruning, then disable txindex // also disable the wallet (for now, until SPV support is implemented in wallet) if (GetArg("-prune", 0)) { - if (GetBoolArg("-txindex", false)) + if (GetBoolArg("-txindex", true)) return InitError(_("Prune mode is incompatible with -txindex.")); #ifdef ENABLE_WALLET if (!GetBoolArg("-disablewallet", false)) { @@ -1281,7 +1281,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) nTotalCache = std::max(nTotalCache, nMinDbCache << 20); // total cache cannot be less than nMinDbCache nTotalCache = std::min(nTotalCache, nMaxDbCache << 20); // total cache cannot be greated than nMaxDbcache int64_t nBlockTreeDBCache = nTotalCache / 8; - if (nBlockTreeDBCache > (1 << 21) && !GetBoolArg("-txindex", false)) + if (nBlockTreeDBCache > (1 << 21) && !GetBoolArg("-txindex", true)) nBlockTreeDBCache = (1 << 21); // block tree db cache shouldn't be larger than 2 MiB nTotalCache -= nBlockTreeDBCache; int64_t nCoinDBCache = std::min(nTotalCache / 2, (nTotalCache / 4) + (1 << 23)); // use 25%-50% of the remainder for disk cache @@ -1337,7 +1337,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } // Check for changed -txindex state - if (fTxIndex != GetBoolArg("-txindex", false)) { + if (fTxIndex != GetBoolArg("-txindex", true)) { strLoadError = _("You need to rebuild the database using -reindex to change -txindex"); break; } diff --git a/src/main.cpp b/src/main.cpp index e46033e09..0fa600f01 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4020,7 +4020,7 @@ bool InitBlockIndex() { return true; // Use the provided setting for -txindex in the new database - fTxIndex = GetBoolArg("-txindex", false); + fTxIndex = GetBoolArg("-txindex", true); pblocktree->WriteFlag("txindex", fTxIndex); LogPrintf("Initializing databases...\n"); From 3a00ec3f235b785e68ff25d4bbf7dedbc6cd9d25 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 2 Jun 2017 09:27:52 +0300 Subject: [PATCH 09/15] test --- src/komodo_gateway.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a6ccf8207..7d4923608 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -964,9 +964,12 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above else //if ( kmdheights[i-1] > 0 && otherheights[i-1] > 0 ) { hash = block.GetHash(); + for (j=0; j= activation ) return(-1); } From 370fb42f6f53de4b58bf87f33d4c03dd513d6660 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 4 Jun 2017 18:43:15 +0300 Subject: [PATCH 10/15] Bucket print --- src/policy/fees.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp index 9aca615f0..a2ae19172 100644 --- a/src/policy/fees.cpp +++ b/src/policy/fees.cpp @@ -56,7 +56,11 @@ void TxConfirmStats::ClearCurrent(unsigned int nBlockHeight) unsigned int TxConfirmStats::FindBucketIndex(double val) { auto it = bucketMap.lower_bound(val); - assert(it != bucketMap.end()); + //assert(it != bucketMap.end()); + if ( it != bucketMap.end() ) + { + printf("FindBucketIndex violation: %p != %p from val %f\n",it,bucketMap.end(),val); + } return it->second; } From 3f7c82e3af27da5ba65aecc93c9796060ab7755c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 4 Jun 2017 19:18:13 +0300 Subject: [PATCH 11/15] Test --- src/main.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 0fa600f01..b30c7806d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1803,15 +1803,14 @@ bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoins // Check for negative or overflow input values nValueIn += coins->vout[prevout.n].nValue; #ifdef KOMODO_ENABLE_INTEREST - if ( ASSETCHAINS_SYMBOL[0] == 0 && chainActive.Tip() != 0 && chainActive.Tip()->nHeight >= 60000 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 && chainActive.Tip() != 0 && chainActive.Tip()->nHeight >= 60000 && chainActive.Tip()->nHeight < 350000 ) { if ( coins->vout[prevout.n].nValue >= 10*COIN ) { int64_t interest; int32_t txheight; uint32_t locktime; if ( (interest= komodo_accrued_interest(&txheight,&locktime,prevout.hash,prevout.n,0,coins->vout[prevout.n].nValue)) != 0 ) { - //printf("checkResult %.8f += val %.8f interest %.8f ht.%d lock.%u tip.%u\n",(double)nValueIn/COIN,(double)coins->vout[prevout.n].nValue/COIN,(double)interest/COIN,txheight,locktime,chainActive.Tip()->nTime); - //fprintf(stderr,"checkResult %.8f += val %.8f interest %.8f ht.%d lock.%u tip.%u\n",(double)nValueIn/COIN,(double)coins->vout[prevout.n].nValue/COIN,(double)interest/COIN,txheight,locktime,chainActive.Tip()->nTime); + fprintf(stderr,"checkResult %.8f += val %.8f interest %.8f ht.%d lock.%u tip.%u\n",(double)nValueIn/COIN,(double)coins->vout[prevout.n].nValue/COIN,(double)interest/COIN,txheight,locktime,chainActive.Tip()->nTime); nValueIn += interest; } } From 4ec48ddab7a059e82ccbdd25effab8064814f54f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 4 Jun 2017 19:20:53 +0300 Subject: [PATCH 12/15] Test --- src/policy/fees.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp index a2ae19172..17cac1ce6 100644 --- a/src/policy/fees.cpp +++ b/src/policy/fees.cpp @@ -59,7 +59,7 @@ unsigned int TxConfirmStats::FindBucketIndex(double val) //assert(it != bucketMap.end()); if ( it != bucketMap.end() ) { - printf("FindBucketIndex violation: %p != %p from val %f\n",it,bucketMap.end(),val); + fprintf(stderr,"FindBucketIndex violation: from val %f\n",val); } return it->second; } From 5d2f557e4412ba37581ca5c397d1f3c767ef7483 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 4 Jun 2017 19:39:48 +0300 Subject: [PATCH 13/15] Disable mining unclaimed interest --- src/coins.cpp | 5 +++-- src/miner.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/coins.cpp b/src/coins.cpp index c97ba0790..9ac4358cd 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -391,7 +391,8 @@ extern char ASSETCHAINS_SYMBOL[16]; CAmount CCoinsViewCache::GetValueIn(int32_t nHeight,int64_t *interestp,const CTransaction& tx,uint32_t tiptime) const { - *interestp = 0; + if ( interestp != 0 ) + *interestp = 0; if ( tx.IsCoinBase() != 0 ) return 0; CAmount value,nResult = 0; @@ -400,7 +401,7 @@ CAmount CCoinsViewCache::GetValueIn(int32_t nHeight,int64_t *interestp,const CTr value = GetOutputFor(tx.vin[i]).nValue; nResult += value; #ifdef KOMODO_ENABLE_INTEREST - if ( ASSETCHAINS_SYMBOL[0] == 0 && nHeight >= 60000 ) + if ( interestp != 0 && ASSETCHAINS_SYMBOL[0] == 0 && nHeight >= 60000 ) { if ( value >= 10*COIN ) { diff --git a/src/miner.cpp b/src/miner.cpp index 3de85e5cf..8cee2e5d0 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -335,7 +335,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if (!view.HaveInputs(tx)) continue; - CAmount nTxFees = view.GetValueIn(chainActive.Tip()->nHeight,&interest,tx,chainActive.Tip()->nTime)-tx.GetValueOut(); + CAmount nTxFees = view.GetValueIn(chainActive.Tip()->nHeight,0,tx,chainActive.Tip()->nTime)-tx.GetValueOut(); nTxSigOps += GetP2SHSigOpCount(tx, view); if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS) From 1141b678212224ff216d107a35b13d36b6d52354 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 4 Jun 2017 20:09:30 +0300 Subject: [PATCH 14/15] Revert interest changes --- src/coins.cpp | 2 +- src/main.cpp | 2 +- src/miner.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coins.cpp b/src/coins.cpp index 9ac4358cd..27cac5a6f 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -401,7 +401,7 @@ CAmount CCoinsViewCache::GetValueIn(int32_t nHeight,int64_t *interestp,const CTr value = GetOutputFor(tx.vin[i]).nValue; nResult += value; #ifdef KOMODO_ENABLE_INTEREST - if ( interestp != 0 && ASSETCHAINS_SYMBOL[0] == 0 && nHeight >= 60000 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 && nHeight >= 60000 ) { if ( value >= 10*COIN ) { diff --git a/src/main.cpp b/src/main.cpp index b30c7806d..32fa42e03 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1803,7 +1803,7 @@ bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoins // Check for negative or overflow input values nValueIn += coins->vout[prevout.n].nValue; #ifdef KOMODO_ENABLE_INTEREST - if ( ASSETCHAINS_SYMBOL[0] == 0 && chainActive.Tip() != 0 && chainActive.Tip()->nHeight >= 60000 && chainActive.Tip()->nHeight < 350000 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 && chainActive.Tip() != 0 && chainActive.Tip()->nHeight >= 60000 ) { if ( coins->vout[prevout.n].nValue >= 10*COIN ) { diff --git a/src/miner.cpp b/src/miner.cpp index 8cee2e5d0..3de85e5cf 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -335,7 +335,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if (!view.HaveInputs(tx)) continue; - CAmount nTxFees = view.GetValueIn(chainActive.Tip()->nHeight,0,tx,chainActive.Tip()->nTime)-tx.GetValueOut(); + CAmount nTxFees = view.GetValueIn(chainActive.Tip()->nHeight,&interest,tx,chainActive.Tip()->nTime)-tx.GetValueOut(); nTxSigOps += GetP2SHSigOpCount(tx, view); if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS) From 0b2c3fe620c8ca80ce4a97ae7bdbb1c7866e3f9a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 4 Jun 2017 20:11:13 +0300 Subject: [PATCH 15/15] Remove print --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 32fa42e03..b2a4317df 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1810,7 +1810,7 @@ bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoins int64_t interest; int32_t txheight; uint32_t locktime; if ( (interest= komodo_accrued_interest(&txheight,&locktime,prevout.hash,prevout.n,0,coins->vout[prevout.n].nValue)) != 0 ) { - fprintf(stderr,"checkResult %.8f += val %.8f interest %.8f ht.%d lock.%u tip.%u\n",(double)nValueIn/COIN,(double)coins->vout[prevout.n].nValue/COIN,(double)interest/COIN,txheight,locktime,chainActive.Tip()->nTime); + //fprintf(stderr,"checkResult %.8f += val %.8f interest %.8f ht.%d lock.%u tip.%u\n",(double)nValueIn/COIN,(double)coins->vout[prevout.n].nValue/COIN,(double)interest/COIN,txheight,locktime,chainActive.Tip()->nTime); nValueIn += interest; } }