From ddb56b6046c020da9ed32fd9a1df73b2f598161b Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 13 Mar 2017 20:43:27 +0200 Subject: [PATCH 1/8] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 376c12c63..f5543b9e4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -605,7 +605,7 @@ void static BitcoinMiner(CWallet *pwallet) Mining_height = pindexPrev->nHeight+1; Mining_start = (uint32_t)time(NULL); } - //if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"%s create new block ht.%d\n",ASSETCHAINS_SYMBOL,Mining_height); CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey); if ( ptr == 0 ) From 1b5b89ba204ec5b0f0da045900f22618ae6f231e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 13 Mar 2017 22:38:12 +0200 Subject: [PATCH 2/8] Test --- src/komodo_bitcoind.h | 2 +- src/miner.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 2a29b1dc9..d575b02b1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -781,7 +781,7 @@ int32_t komodo_isrealtime(int32_t *kmdheightp) if ( (sp= komodo_stateptrget((char *)"KMD")) != 0 ) *kmdheightp = sp->CURRENT_HEIGHT; else *kmdheightp = 0; - if ( (pindex= chainActive.Tip()) != 0 && pindex->nHeight == (int32_t)komodo_longestchain() ) + if ( (pindex= chainActive.Tip()) != 0 && pindex->nHeight >= (int32_t)komodo_longestchain() ) return(1); else return(0); } diff --git a/src/miner.cpp b/src/miner.cpp index f5543b9e4..c3e14b343 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -121,7 +121,10 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) // Create new block unique_ptr pblocktemplate(new CBlockTemplate()); if(!pblocktemplate.get()) + { + fprintf(stderr,"pblocktemplate.get() failure\n"); return NULL; + } CBlock *pblock = &pblocktemplate->block; // pointer for convenience if ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight >= ASSETCHAINS_MINHEIGHT ) { @@ -469,7 +472,9 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey) else { if (!reservekey.GetReservedKey(pubkey)) + { return NULL; + } scriptPubKey.resize(35); ptr = (uint8_t *)pubkey.begin(); script = (uint8_t *)scriptPubKey.data(); @@ -610,7 +615,9 @@ void static BitcoinMiner(CWallet *pwallet) CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey); if ( ptr == 0 ) { - fprintf(stderr,"created illegal block, retry\n"); + static int32_t counter; + if ( counter++ < 100 ) + fprintf(stderr,"created illegal block, retry\n"); continue; } unique_ptr pblocktemplate(ptr); From d4190a2acee3ae613ee3d1131b8a9dfc5e9ec67e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 13 Mar 2017 23:03:45 +0200 Subject: [PATCH 3/8] Test --- src/main.cpp | 12 ++++++++++++ src/miner.cpp | 6 ++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 307d1d460..0c03f4f40 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3448,13 +3448,25 @@ bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex // NOTE: CheckBlockHeader is called by CheckBlock if (!ContextualCheckBlockHeader(block, state, pindexPrev)) + { + fprintf(stderr,"TestBlockValidity failure A\n"); return false; + } if (!CheckBlock(indexDummy.nHeight,0,block, state, verifier, fCheckPOW, fCheckMerkleRoot)) + { + fprintf(stderr,"TestBlockValidity failure B\n"); return false; + } if (!ContextualCheckBlock(block, state, pindexPrev)) + { + fprintf(stderr,"TestBlockValidity failure C\n"); return false; + } if (!ConnectBlock(block, state, &indexDummy, viewNew, true)) + { + fprintf(stderr,"TestBlockValidity failure D\n"); return false; + } assert(state.IsValid()); return true; diff --git a/src/miner.cpp b/src/miner.cpp index c3e14b343..597b5e400 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -426,7 +426,9 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) CValidationState state; if ( !TestBlockValidity(state, *pblock, pindexPrev, false, false)) { - fprintf(stderr,"warning: testblockvalidity failed\n"); + static uint32_t counter; + if ( counter++ < 100 ) + fprintf(stderr,"warning: testblockvalidity failed\n"); return(0); //throw std::runtime_error("CreateNewBlock(): TestBlockValidity failed"); } @@ -615,7 +617,7 @@ void static BitcoinMiner(CWallet *pwallet) CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey); if ( ptr == 0 ) { - static int32_t counter; + static uint32_t counter; if ( counter++ < 100 ) fprintf(stderr,"created illegal block, retry\n"); continue; From 22c10675333096cc542ae8c2d3f11d468451f4f0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 13 Mar 2017 23:10:50 +0200 Subject: [PATCH 4/8] Test --- src/komodo_gateway.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5df0e1393..2a2ac2baf 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -651,7 +651,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { if ( n == 2 && block.vtx[0].vout[1].nValue > COIN/10 ) { - //fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); + fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); if ( height >= 235300 ) return(-1); } @@ -757,8 +757,18 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } } } + else + { + printf("no opreturn entries to check\n"); + return(-1); + } //printf("opretlen.%d num.%d\n",opretlen,num); - } else return(-1); + } + else + { + printf("not proper vout with opreturn format\n"); + return(-1); + } return(0); } From e699e13dfb1ea90c6e694a62a8aac0ace361c8de Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 13 Mar 2017 23:26:14 +0200 Subject: [PATCH 5/8] Test --- src/komodo_gateway.h | 2 +- src/main.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2a2ac2baf..4fafbaf5c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -639,7 +639,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { if ( block.vtx[i].vin[j].prevout.hash == array[k] && block.vtx[i].vin[j].prevout.n == 1 ) { - //printf("banned tx.%d being used at ht.%d txi.%d vini.%d\n",k,height,i,j); + printf("banned tx.%d being used at ht.%d txi.%d vini.%d\n",k,height,i,j); return(-1); } } diff --git a/src/main.cpp b/src/main.cpp index 0c03f4f40..0dfaf2312 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3189,7 +3189,10 @@ bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidat return state.DoS(100, error("CheckBlock(): out-of-bounds SigOpCount"), REJECT_INVALID, "bad-blk-sigops", true); if ( komodo_check_deposit(height,block) < 0 ) + { + fprintf(stderr,"check deposit rejection\n"); return(false); + } return true; } From 782e1a56ae9af0d9a51bc6816ee5e7f36b72015f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 13 Mar 2017 23:42:12 +0200 Subject: [PATCH 6/8] Test --- src/komodo_globals.h | 1 + src/main.cpp | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 55b54ddf8..9af4d0b36 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -24,6 +24,7 @@ int32_t komodo_isrealtime(int32_t *kmdheightp); uint64_t komodo_paxtotal(); int32_t komodo_longestchain(); uint64_t komodo_maxallowed(int32_t baseid); +void komodo_bannedset(uint256 *array,int32_t max); pthread_mutex_t komodo_mutex; diff --git a/src/main.cpp b/src/main.cpp index 0dfaf2312..d31e4e446 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -863,7 +863,22 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in bool CheckTransaction(const CTransaction& tx, CValidationState &state, libzcash::ProofVerifier& verifier) { - // Don't count coinbase transactions because mining skews the count + static uint256 array[15]; int32_t j,k,n; + if ( *(int32_t *)&array[0] == 0 ) + komodo_bannedset(array,(int32_t)(sizeof(array)/sizeof(*array))); + n = tx[i].vin.size(); + for (j=0; jnHeight,i,j); + return(false); + } + } + } + // Don't count coinbase transactions because mining skews the count if (!tx.IsCoinBase()) { transactionsValidated.increment(); } From 6d1d0330fe176b9a008885f56c0dbd8ab930c814 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 13 Mar 2017 23:47:03 +0200 Subject: [PATCH 7/8] Test --- src/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index d31e4e446..8b5278720 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -866,14 +866,14 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, static uint256 array[15]; int32_t j,k,n; if ( *(int32_t *)&array[0] == 0 ) komodo_bannedset(array,(int32_t)(sizeof(array)/sizeof(*array))); - n = tx[i].vin.size(); + n = tx.vin.size(); for (j=0; jnHeight,i,j); + printf("MEMPOOL: banned tx.%d being used at ht.%d vini.%d\n",k,(int32_t)chainActive.Tip()->nHeight,j); return(false); } } From 541f90199df665493c73abb915338f540bbd4328 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 13 Mar 2017 23:55:00 +0200 Subject: [PATCH 8/8] Make mempool reject banned undo --- src/komodo_gateway.h | 2 +- src/main.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 4fafbaf5c..a1480f83b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -651,7 +651,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { if ( n == 2 && block.vtx[0].vout[1].nValue > COIN/10 ) { - fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); + //fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); if ( height >= 235300 ) return(-1); } diff --git a/src/main.cpp b/src/main.cpp index 8b5278720..8552aff8a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3205,7 +3205,9 @@ bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidat REJECT_INVALID, "bad-blk-sigops", true); if ( komodo_check_deposit(height,block) < 0 ) { - fprintf(stderr,"check deposit rejection\n"); + static uint32_t counter; + if ( counter++ < 100 ) + fprintf(stderr,"check deposit rejection\n"); return(false); } return true;