Merge pull request #253 from jl777/beta

Beta
This commit is contained in:
jl777
2017-03-14 00:00:13 +02:00
committed by GitHub
5 changed files with 50 additions and 10 deletions

View File

@@ -781,7 +781,7 @@ int32_t komodo_isrealtime(int32_t *kmdheightp)
if ( (sp= komodo_stateptrget((char *)"KMD")) != 0 ) if ( (sp= komodo_stateptrget((char *)"KMD")) != 0 )
*kmdheightp = sp->CURRENT_HEIGHT; *kmdheightp = sp->CURRENT_HEIGHT;
else *kmdheightp = 0; 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); return(1);
else return(0); else return(0);
} }

View File

@@ -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 ) 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); 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); //printf("opretlen.%d num.%d\n",opretlen,num);
} else return(-1); }
else
{
printf("not proper vout with opreturn format\n");
return(-1);
}
return(0); return(0);
} }

View File

@@ -24,6 +24,7 @@ int32_t komodo_isrealtime(int32_t *kmdheightp);
uint64_t komodo_paxtotal(); uint64_t komodo_paxtotal();
int32_t komodo_longestchain(); int32_t komodo_longestchain();
uint64_t komodo_maxallowed(int32_t baseid); uint64_t komodo_maxallowed(int32_t baseid);
void komodo_bannedset(uint256 *array,int32_t max);
pthread_mutex_t komodo_mutex; pthread_mutex_t komodo_mutex;

View File

@@ -863,7 +863,22 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in
bool CheckTransaction(const CTransaction& tx, CValidationState &state, bool CheckTransaction(const CTransaction& tx, CValidationState &state,
libzcash::ProofVerifier& verifier) 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; j<n; j++)
{
for (k=0; k<sizeof(array)/sizeof(*array); k++)
{
if ( tx.vin[j].prevout.hash == array[k] && tx.vin[j].prevout.n == 1 )
{
printf("MEMPOOL: banned tx.%d being used at ht.%d vini.%d\n",k,(int32_t)chainActive.Tip()->nHeight,j);
return(false);
}
}
}
// Don't count coinbase transactions because mining skews the count
if (!tx.IsCoinBase()) { if (!tx.IsCoinBase()) {
transactionsValidated.increment(); 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"), return state.DoS(100, error("CheckBlock(): out-of-bounds SigOpCount"),
REJECT_INVALID, "bad-blk-sigops", true); REJECT_INVALID, "bad-blk-sigops", true);
if ( komodo_check_deposit(height,block) < 0 ) if ( komodo_check_deposit(height,block) < 0 )
{
static uint32_t counter;
if ( counter++ < 100 )
fprintf(stderr,"check deposit rejection\n");
return(false); return(false);
}
return true; return true;
} }
@@ -3449,22 +3469,22 @@ bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex
// NOTE: CheckBlockHeader is called by CheckBlock // NOTE: CheckBlockHeader is called by CheckBlock
if (!ContextualCheckBlockHeader(block, state, pindexPrev)) if (!ContextualCheckBlockHeader(block, state, pindexPrev))
{ {
fprintf(stderr,"TestBlockValidity A error\n"); fprintf(stderr,"TestBlockValidity failure A\n");
return false; return false;
} }
if (!CheckBlock(indexDummy.nHeight,0,block, state, verifier, fCheckPOW, fCheckMerkleRoot)) if (!CheckBlock(indexDummy.nHeight,0,block, state, verifier, fCheckPOW, fCheckMerkleRoot))
{ {
fprintf(stderr,"TestBlockValidity B error\n"); fprintf(stderr,"TestBlockValidity failure B\n");
return false; return false;
} }
if (!ContextualCheckBlock(block, state, pindexPrev)) if (!ContextualCheckBlock(block, state, pindexPrev))
{ {
fprintf(stderr,"TestBlockValidity C error\n"); fprintf(stderr,"TestBlockValidity failure C\n");
return false; return false;
} }
if (!ConnectBlock(block, state, &indexDummy, viewNew, true)) if (!ConnectBlock(block, state, &indexDummy, viewNew, true))
{ {
fprintf(stderr,"TestBlockValidity D error\n"); fprintf(stderr,"TestBlockValidity failure D\n");
return false; return false;
} }
assert(state.IsValid()); assert(state.IsValid());

View File

@@ -121,7 +121,10 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
// Create new block // Create new block
unique_ptr<CBlockTemplate> pblocktemplate(new CBlockTemplate()); unique_ptr<CBlockTemplate> pblocktemplate(new CBlockTemplate());
if(!pblocktemplate.get()) if(!pblocktemplate.get())
{
fprintf(stderr,"pblocktemplate.get() failure\n");
return NULL; return NULL;
}
CBlock *pblock = &pblocktemplate->block; // pointer for convenience CBlock *pblock = &pblocktemplate->block; // pointer for convenience
if ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight >= ASSETCHAINS_MINHEIGHT ) if ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight >= ASSETCHAINS_MINHEIGHT )
{ {
@@ -423,7 +426,9 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
CValidationState state; CValidationState state;
if ( !TestBlockValidity(state, *pblock, pindexPrev, false, false)) 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); return(0);
//throw std::runtime_error("CreateNewBlock(): TestBlockValidity failed"); //throw std::runtime_error("CreateNewBlock(): TestBlockValidity failed");
} }
@@ -469,7 +474,9 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey)
else else
{ {
if (!reservekey.GetReservedKey(pubkey)) if (!reservekey.GetReservedKey(pubkey))
{
return NULL; return NULL;
}
scriptPubKey.resize(35); scriptPubKey.resize(35);
ptr = (uint8_t *)pubkey.begin(); ptr = (uint8_t *)pubkey.begin();
script = (uint8_t *)scriptPubKey.data(); script = (uint8_t *)scriptPubKey.data();
@@ -610,7 +617,9 @@ void static BitcoinMiner(CWallet *pwallet)
CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey); CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey);
if ( ptr == 0 ) 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; continue;
} }
unique_ptr<CBlockTemplate> pblocktemplate(ptr); unique_ptr<CBlockTemplate> pblocktemplate(ptr);