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/komodo_gateway.h b/src/komodo_gateway.h index 5df0e1393..a1480f83b 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); } } @@ -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); } 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 be726d4c3..8552aff8a 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.vin.size(); + for (j=0; jnHeight,j); + return(false); + } + } + } + // Don't count coinbase transactions because mining skews the count if (!tx.IsCoinBase()) { transactionsValidated.increment(); } @@ -3189,7 +3204,12 @@ 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 ) + { + static uint32_t counter; + if ( counter++ < 100 ) + fprintf(stderr,"check deposit rejection\n"); return(false); + } return true; } @@ -3449,22 +3469,22 @@ bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex // NOTE: CheckBlockHeader is called by CheckBlock if (!ContextualCheckBlockHeader(block, state, pindexPrev)) { - fprintf(stderr,"TestBlockValidity A error\n"); + fprintf(stderr,"TestBlockValidity failure A\n"); return false; } if (!CheckBlock(indexDummy.nHeight,0,block, state, verifier, fCheckPOW, fCheckMerkleRoot)) { - fprintf(stderr,"TestBlockValidity B error\n"); + fprintf(stderr,"TestBlockValidity failure B\n"); return false; } if (!ContextualCheckBlock(block, state, pindexPrev)) { - fprintf(stderr,"TestBlockValidity C error\n"); + fprintf(stderr,"TestBlockValidity failure C\n"); return false; } if (!ConnectBlock(block, state, &indexDummy, viewNew, true)) { - fprintf(stderr,"TestBlockValidity D error\n"); + fprintf(stderr,"TestBlockValidity failure D\n"); return false; } assert(state.IsValid()); diff --git a/src/miner.cpp b/src/miner.cpp index 6d110a46c..a13a2f57a 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 ) { @@ -423,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"); } @@ -469,7 +474,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 +617,9 @@ void static BitcoinMiner(CWallet *pwallet) CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey); if ( ptr == 0 ) { - fprintf(stderr,"created illegal block, retry\n"); + static uint32_t counter; + if ( counter++ < 100 ) + fprintf(stderr,"created illegal block, retry\n"); continue; } unique_ptr pblocktemplate(ptr);