Skip to content

Commit

Permalink
Merge pull request #6 from jl777/beta
Browse files Browse the repository at this point in the history
beta update
  • Loading branch information
radix42 authored Mar 13, 2017
2 parents 1fe80f4 + e39811d commit a0092ef
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#define CLIENT_VERSION_MAJOR 1
#define CLIENT_VERSION_MINOR 0
#define CLIENT_VERSION_REVISION 5
#define CLIENT_VERSION_BUILD 50
#define CLIENT_VERSION_BUILD 51

//! Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE true
Expand Down
12 changes: 8 additions & 4 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1244,10 +1244,14 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
LogPrintf("Prune: pruned datadir may not have more than %d blocks; -checkblocks=%d may fail\n",
MIN_BLOCKS_TO_KEEP, GetArg("-checkblocks", 288));
}
if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3),
GetArg("-checkblocks", 288))) {
strLoadError = _("Corrupted block database detected");
break;
extern int32_t KOMODO_REWIND;
if ( KOMODO_REWIND == 0 )
{
if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3),
GetArg("-checkblocks", 288))) {
strLoadError = _("Corrupted block database detected");
break;
}
}
} catch (const std::exception& e) {
if (fDebug) LogPrintf("%s\n", e.what());
Expand Down
20 changes: 17 additions & 3 deletions src/komodo.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,9 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
}
if ( opretlen > len && scriptbuf[len] == 'A' )
{
for (i=0; i<opretlen-len; i++)
printf("%02x",scriptbuf[len+i]);
printf(" Found extradata.[%d] %d - %d\n",opretlen-len,opretlen,len);
//for (i=0; i<opretlen-len; i++)
// printf("%02x",scriptbuf[len+i]);
//printf(" Found extradata.[%d] %d - %d\n",opretlen-len,opretlen,len);
komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len+4+3+(scriptbuf[1] == 0x4d),j);
}
}
Expand Down Expand Up @@ -546,6 +546,20 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
}
for (j=0; j<numvouts; j++)
{
/*if ( i == 0 && j == 0 )
{
uint8_t *script = (uint8_t *)block.vtx[0].vout[numvouts-1].scriptPubKey.data();
if ( numvouts <= 2 || script[0] != 0x6a )
{
if ( numvouts == 2 && block.vtx[0].vout[1].nValue != 0 )
{
fprintf(stderr,"ht.%d numvouts.%d value %.8f\n",height,numvouts,dstr(block.vtx[0].vout[1].nValue));
if ( height >= 235300 && block.vtx[0].vout[1].nValue >= 100000*COIN )
block.vtx[0].vout[1].nValue = 0;
break;
}
}
}*/
len = block.vtx[i].vout[j].scriptPubKey.size();
if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) )
{
Expand Down
65 changes: 61 additions & 4 deletions src/komodo_gateway.h
Original file line number Diff line number Diff line change
Expand Up @@ -588,20 +588,77 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
return(0);
}

const char *banned_txids[] =
{
"78cb4e21245c26b015b888b14c4f5096e18137d2741a6de9734d62b07014dfca", //233559
"00697be658e05561febdee1aafe368b821ca33fbb89b7027365e3d77b5dfede5", //234172
"e909465788b32047c472d73e882d79a92b0d550f90be008f76e1edaee6d742ea", //234187
"f56c6873748a327d0b92b8108f8ec8505a2843a541b1926022883678fb24f9dc", //234188
"abf08be07d8f5b3a433ddcca7ef539e79a3571632efd6d0294ec0492442a0204", //234213
"3b854b996cc982fba8c06e76cf507ae7eed52ab92663f4c0d7d10b3ed879c3b0", //234367
"fa9e474c2cda3cb4127881a40eb3f682feaba3f3328307d518589024a6032cc4", //234635
"ca746fa13e0113c4c0969937ea2c66de036d20274efad4ce114f6b699f1bc0f3", //234662
"43ce88438de4973f21b1388ffe66e68fda592da38c6ef939be10bb1b86387041", //234697
"0aeb748de82f209cd5ff7d3a06f65543904c4c17387c9d87c65fd44b14ad8f8c", //234899
"bbd3a3d9b14730991e1066bd7c626ca270acac4127131afe25f877a5a886eb25", //235252
"fa9943525f2e6c32cbc243294b08187e314d83a2870830180380c3c12a9fd33c", //235253
"a01671c8775328a41304e31a6693bbd35e9acbab28ab117f729eaba9cb769461", //235265
"2ef49d2d27946ad7c5d5e4ab5c089696762ff04e855f8ab48e83bdf0cc68726d", //235295
"c85dcffb16d5a45bd239021ad33443414d60224760f11d535ae2063e5709efee", //235296
};

void komodo_bannedset(uint256 *array,int32_t max)
{
int32_t i;
for (i=0; i<sizeof(banned_txids)/sizeof(*banned_txids); i++)
array[i] = uint256S(banned_txids[i]);
if ( i != max )
printf("banned txid array error i.%d != max.%d\n",i,max);
//else printf("set %d banned txids\n",max);
}

int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing
{
int32_t i,j,n,ht,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; uint64_t available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp;
if ( KOMODO_PAX == 0 || komodo_isrealtime(&ht) == 0 || KOMODO_PASSPORT_INITDONE == 0 )
return(0);
static uint256 array[15];
int32_t i,j,k,n,ht,txn_count,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; uint64_t available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp;
if ( *(int32_t *)&array[0] == 0 )
komodo_bannedset(array,(int32_t)(sizeof(array)/sizeof(*array)));
memset(baseids,0xff,sizeof(baseids));
memset(values,0,sizeof(values));
memset(srcvalues,0,sizeof(srcvalues));
memset(rmd160s,0,sizeof(rmd160s));
memset(kmdheights,0,sizeof(kmdheights));
memset(otherheights,0,sizeof(otherheights));
txn_count = block.vtx.size();
for (i=0; i<txn_count; i++)
{
n = block.vtx[i].vin.size();
for (j=0; j<n; j++)
{
for (k=0; k<sizeof(array)/sizeof(*array); k++)
{
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);
return(-1);
}
}
}
}
n = block.vtx[0].vout.size();
script = (uint8_t *)block.vtx[0].vout[n-1].scriptPubKey.data();
if ( n <= 2 || script[0] != 0x6a )
{
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);
if ( height >= 235300 )
return(-1);
}
return(0);
}
//fprintf(stderr,"ht.%d n.%d nValue %.8f (%d %d %d)\n",height,n,dstr(block.vtx[0].vout[1].nValue),KOMODO_PAX,komodo_isrealtime(&ht),KOMODO_PASSPORT_INITDONE);
if ( komodo_isrealtime(&ht) == 0 || KOMODO_PASSPORT_INITDONE == 0 ) //KOMODO_PAX == 0 ||
return(0);
offset += komodo_scriptitemlen(&opretlen,&script[offset]);
if ( ASSETCHAINS_SYMBOL[0] == 0 )
Expand Down Expand Up @@ -701,7 +758,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
}
}
//printf("opretlen.%d num.%d\n",opretlen,num);
}
} else return(-1);
return(0);
}

Expand Down
22 changes: 19 additions & 3 deletions src/komodo_notary.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const char *Notaries_elected[][2] =

int32_t komodo_electednotary(uint8_t *pubkey33,int32_t height)
{
char pubkeystr[67]; int32_t i;
char pubkeystr[67]; int32_t i; uint8_t legacy33[33];
for (i=0; i<33; i++)
sprintf(&pubkeystr[i*2],"%02x",pubkey33[i]);
pubkeystr[66] = 0;
Expand All @@ -137,6 +137,20 @@ int32_t komodo_electednotary(uint8_t *pubkey33,int32_t height)
return(i);
}
}
/*if ( height < 300000 )
{
for (i=0; i<sizeof(Notaries_genesis)/sizeof(*Notaries_genesis); i++)
{
if ( strcmp(pubkeystr,(char *)Notaries_genesis[i][1]) == 0 )
{
//printf("i.%d -> elected %s\n",i,(char *)Notaries_elected[i][1]);
return(i+64);
}
}
decode_hex(legacy33,33,(char *)"0252b6185bf8ea7efe8bbc345ddc8da87329149f30233088387abd716d4aa9e974");
if ( memcmp(pubkey33,legacy33,33) == 0 )
return(128);
}*/
return(-1);
}

Expand Down Expand Up @@ -246,6 +260,8 @@ int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33)
return(modval);
}
}
if ( height >= 300000 )
return(-1);
htind = height / KOMODO_ELECTION_GAP;
pthread_mutex_lock(&komodo_mutex);
HASH_FIND(hh,Pubkeys[htind].Notaries,pubkey33,33,kp);
Expand All @@ -258,7 +274,7 @@ int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33)
modval = ((height % numnotaries) == kp->notaryid);
//printf("found notary.%d ht.%d modval.%d\n",kp->notaryid,height,modval);
} else printf("unexpected zero notaries at height.%d\n",height);
}
} //else printf("cant find kp at htind.%d ht.%d\n",htind,height);
//int32_t i; for (i=0; i<33; i++)
// printf("%02x",pubkey33[i]);
//printf(" ht.%d notary.%d special.%d htind.%d num.%d\n",height,*notaryidp,modval,htind,numnotaries);
Expand Down Expand Up @@ -352,7 +368,7 @@ void komodo_init(int32_t height)
// Minerids[i] = -2;
didinit = 1;
}
else if ( height == KOMODO_MAINNET_START )
else if ( 0 && height == KOMODO_MAINNET_START )
{
n = (int32_t)(sizeof(Notaries_elected)/sizeof(*Notaries_elected));
for (k=0; k<n; k++)
Expand Down
7 changes: 5 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,7 @@ bool IsInitialBlockDownload()
}
bool state;
if ( ASSETCHAINS_SYMBOL[0] == 0 )
state = (chainActive.Height() < pindexBestHeader->nHeight - 24*6) ||
state = (chainActive.Height() > 236000 && chainActive.Height() < pindexBestHeader->nHeight - 24*6) ||
pindexBestHeader->GetBlockTime() < (GetTime() - chainParams.MaxTipAge());
else state = (chainActive.Height() < pindexBestHeader->nHeight - 100);
if (!state)
Expand Down Expand Up @@ -3206,7 +3206,7 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
int nHeight = pindexPrev->nHeight+1;

// Check proof of work
if (block.nBits != GetNextWorkRequired(pindexPrev, &block, consensusParams))
if ( (nHeight < 235300 || nHeight > 236000) && block.nBits != GetNextWorkRequired(pindexPrev, &block, consensusParams))
{
cout << block.nBits << " block.nBits vs. calc " << GetNextWorkRequired(pindexPrev, &block, consensusParams) << endl;
return state.DoS(100, error("%s: incorrect proof of work", __func__),
Expand Down Expand Up @@ -3412,6 +3412,8 @@ bool ProcessNewBlock(int32_t height,CValidationState &state, CNode* pfrom, CBloc
bool fRequested = MarkBlockAsReceived(pblock->GetHash());
fRequested |= fForceProcessing;
if (!checked) {
if ( pfrom != 0 )
Misbehaving(pfrom->GetId(), 1);
return error("%s: CheckBlock FAILED", __func__);
}

Expand Down Expand Up @@ -3872,6 +3874,7 @@ bool LoadBlockIndex()
return false;
}
KOMODO_LOADINGBLOCKS = 0;
fprintf(stderr,"finished loading blocks\n");
return true;
}

Expand Down
18 changes: 9 additions & 9 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ void static BitcoinMiner(CWallet *pwallet)
unsigned int n = chainparams.EquihashN();
unsigned int k = chainparams.EquihashK();
int32_t notaryid = -1;
while ( ASSETCHAIN_INIT == 0 || KOMODO_INITDONE == 0 )
while ( (ASSETCHAIN_INIT == 0 || KOMODO_INITDONE == 0) ) //chainActive.Tip()->nHeight != 235300 &&
{
sleep(1);
if ( komodo_baseid(ASSETCHAINS_SYMBOL) < 0 )
Expand All @@ -554,7 +554,7 @@ void static BitcoinMiner(CWallet *pwallet)
assert(solver == "tromp" || solver == "default");
LogPrint("pow", "Using Equihash solver \"%s\" with n = %u, k = %u\n", solver, n, k);
if ( ASSETCHAINS_SYMBOL[0] != 0 )
fprintf(stderr,"Mining with %s\n",solver.c_str());
fprintf(stderr,"notaryid.%d Mining with %s\n",notaryid,solver.c_str());
std::mutex m_cs;
bool cancelSolver = false;
boost::signals2::connection c = uiInterface.NotifyBlockTip.connect(
Expand All @@ -569,7 +569,7 @@ void static BitcoinMiner(CWallet *pwallet)
fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str());
while (true)
{
if (chainparams.MiningRequiresPeers())
if (chainparams.MiningRequiresPeers()) //chainActive.Tip()->nHeight != 235300 &&
{
//if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 )
// break;
Expand Down Expand Up @@ -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 )
Expand All @@ -631,7 +631,7 @@ void static BitcoinMiner(CWallet *pwallet)
if ( ASSETCHAINS_SYMBOL[0] == 0 && notaryid >= 0 )//komodo_is_special(pindexPrev->nHeight+1,NOTARY_PUBKEY33) > 0 )
{
j = 65;
if ( (Mining_height % KOMODO_ELECTION_GAP) > 64 || (Mining_height % KOMODO_ELECTION_GAP) == 0 )
if ( (Mining_height >= 235300 && Mining_height < 236000) || (Mining_height % KOMODO_ELECTION_GAP) > 64 || (Mining_height % KOMODO_ELECTION_GAP) == 0 )
{
komodo_eligiblenotary(pubkeys,mids,&nonzpkeys,pindexPrev->nHeight);
if ( nonzpkeys > 0 )
Expand Down Expand Up @@ -667,7 +667,7 @@ void static BitcoinMiner(CWallet *pwallet)
if ( mids[j] == notaryid )
break;
} else fprintf(stderr,"no nonz pubkeys\n");
if ( j == 65 && Mining_height > KOMODO_MAYBEMINED+3 && Mining_height > KOMODO_LASTMINED+64 )
if ( (Mining_height >= 235300 && Mining_height < 236000) || (j == 65 && Mining_height > KOMODO_MAYBEMINED+3 && Mining_height > KOMODO_LASTMINED+64) )
{
hashTarget = arith_uint256().SetCompact(KOMODO_MINDIFF_NBITS);
fprintf(stderr,"I am the chosen one for %s ht.%d\n",ASSETCHAINS_SYMBOL,pindexPrev->nHeight+1);
Expand Down Expand Up @@ -709,8 +709,8 @@ void static BitcoinMiner(CWallet *pwallet)
solutionTargetChecks.increment();
if ( UintToArith256(pblock->GetHash()) > hashTarget )
{
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
fprintf(stderr,"missed target\n");
//if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
// fprintf(stderr," missed target\n");
return false;
}
if ( ASSETCHAINS_SYMBOL[0] == 0 && Mining_start != 0 && time(NULL) < Mining_start+ROUNDROBIN_DELAY )
Expand Down Expand Up @@ -815,7 +815,7 @@ void static BitcoinMiner(CWallet *pwallet)
{
if ( ASSETCHAINS_SYMBOL[0] == 0 || Mining_height > ASSETCHAINS_MINHEIGHT )
{
//fprintf(stderr,"no nodes, break\n");
fprintf(stderr,"no nodes, break\n");
break;
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/pow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params)
{
unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact();

// Genesis block
if (pindexLast == NULL )
return nProofOfWorkLimit;
Expand Down Expand Up @@ -156,7 +155,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
// Check proof of work matches claimed amount
if ( UintToArith256(hash) > bnTarget )
{
if ( KOMODO_LOADINGBLOCKS == 0 && height > 188000 && KOMODO_REWIND == 0 )//186269, 182507&& komodo_chainactive(height) != 0 && nonzpkeys > 0
if ( (height < 235300 || height >= 236000) && KOMODO_LOADINGBLOCKS == 0 && height > 188000 && KOMODO_REWIND == 0 )//186269, 182507&& komodo_chainactive(height) != 0 && nonzpkeys > 0
{
int32_t i;
for (i=31; i>=0; i--)
Expand Down
6 changes: 3 additions & 3 deletions src/rpcblockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ Value kvsearch(const Array& params, bool fHelp)

Value minerids(const Array& params, bool fHelp)
{
Object ret; Array a; uint8_t minerids[2000],pubkeys[64][33]; int32_t i,j,n,numnotaries,tally[65];
Object ret; Array a; uint8_t minerids[2000],pubkeys[65][33]; int32_t i,j,n,numnotaries,tally[129];
if ( fHelp || params.size() != 1 )
throw runtime_error("minerids needs height\n");
LOCK(cs_main);
Expand All @@ -463,7 +463,7 @@ Value minerids(const Array& params, bool fHelp)
for (i=0; i<n; i++)
{
if ( minerids[i] >= numnotaries )
tally[64]++;
tally[128]++;
else tally[minerids[i]]++;
}
for (i=0; i<64; i++)
Expand All @@ -488,7 +488,7 @@ Value minerids(const Array& params, bool fHelp)
}
Object item;
item.push_back(Pair("pubkey", (char *)"external miners"));
item.push_back(Pair("blocks", tally[64]));
item.push_back(Pair("blocks", tally[128]));
a.push_back(item);
}
ret.push_back(Pair("mined", a));
Expand Down
1 change: 1 addition & 0 deletions src/rpcmining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ Value getblocktemplate(const Array& params, bool fHelp)
result.push_back(Pair("bits", strprintf("%08x", pblock->nBits)));
result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight+1)));

//fprintf(stderr,"return complete template\n");
return result;
}
#endif
Expand Down

0 comments on commit a0092ef

Please sign in to comment.