From 80db4aead0758455f8e1b11a87678e65c83872e1 Mon Sep 17 00:00:00 2001 From: Team ChainStrike Date: Thu, 27 Sep 2018 03:34:26 +1000 Subject: [PATCH 01/12] WIP with lots of debugging --- src/komodo_validation011.h | 108 +++++++++++++++++++++++-------------- 1 file changed, 67 insertions(+), 41 deletions(-) diff --git a/src/komodo_validation011.h b/src/komodo_validation011.h index 677f03c00..c7976f5a8 100644 --- a/src/komodo_validation011.h +++ b/src/komodo_validation011.h @@ -81,7 +81,6 @@ void ImportAddress(CWallet* const pwallet, const CBitcoinAddress& address, const int32_t gettxout_scriptPubKey(int32_t height,uint8_t *scriptPubKey,int32_t maxsize,uint256 txid,int32_t n) { static uint256 zero; int32_t i,m; uint8_t *ptr; CTransaction tx; uint256 hashBlock; - CTransactionRef txref=0; LOCK(cs_main); if ( KOMODO_TXINDEX != 0 ) { @@ -100,23 +99,29 @@ int32_t gettxout_scriptPubKey(int32_t height,uint8_t *scriptPubKey,int32_t maxsi if ( it != pwallet->mapWallet.end() ) { const CWalletTx& wtx = it->second; - txref = wtx.tx; + tx = *wtx.tx; fprintf(stderr,"found tx in wallet\n"); } } } - if ( txref != 0 && n >= 0 && n <= (int32_t)txref->vout.size() ) // vout.size() seems off by 1 + if ( &tx != 0 && n >= 0 && n <= (int32_t)tx.vout.size() ) // vout.size() seems off by 1 { - ptr = (uint8_t *)txref->vout[n].scriptPubKey.data(); - m = txref->vout[n].scriptPubKey.size(); - for (i=0; i voutsize.%d\n",height,n,(int32_t)txref->vout.size()); + else if ( &tx != 0 ) + fprintf(stderr,"gettxout_scriptPubKey ht.%d n.%d > voutsize.%d\n",height,n,(int32_t)tx.vout.size()); return(-1); } @@ -748,15 +753,14 @@ void komodo_importpubkeys() if ( (m= (int32_t)strlen((char *)Notaries_elected1[i][offset])) > 0 ) { pubkey = (char*) Notaries_elected1[i][offset]; - //fprintf(stderr,"pubkey=%s\n", pubkey ); const std::vector vPubkey(pubkey, pubkey + m); std::string addr = CBitcoinAddress(CPubKey(ParseHex(pubkey)).GetID()).ToString(); - //fprintf(stderr,"addr=%s\n", addr.c_str() ); + fprintf(stderr,"pubkey=%s, addr=%s\n", pubkey, addr.c_str() ); if ( (val= komodo_importaddress(addr)) < 0 ) - fprintf(stderr,"error importing (%s)\n",addr.c_str()); + LogPrintf("dpow: error importing (%s)\n",addr.c_str()); else if ( val == 0 ) dispflag++; } @@ -842,8 +846,8 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam did0 = 1; } memcpy(pubkeys,elected_pubkeys0,n0 * 33); - //if ( ASSETCHAINS_SYMBOL[0] != 0 ) - // fprintf(stderr,"%s height.%d t.%u elected.%d notaries\n",ASSETCHAINS_SYMBOL,height,timestamp,n0); + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + fprintf(stderr,"%s height.%d t.%u elected.%d notaries\n",ASSETCHAINS_SYMBOL,height,timestamp,n0); return(n0); } else //if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP2) || height <= KOMODO_NOTARIES_HEIGHT2 ) @@ -853,7 +857,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam n1 = (int32_t)(sizeof(Notaries_elected1)/sizeof(*Notaries_elected1)); for (i=0; i= nHeight ) { - LogPrintf("flag.1 i.%d np->ht %d [%d].ht %d >= nHeight.%d, last.%d num.%d\n",i,np->nHeight,i,NPOINTS[i].nHeight,nHeight,last_NPOINTSi,NUM_NPOINTS); + LogPrintf("dpow: flag.1 i.%d np->ht %d [%d].ht %d >= nHeight.%d, last.%d num.%d\n",i,np->nHeight,i,NPOINTS[i].nHeight,nHeight,last_NPOINTSi,NUM_NPOINTS); flag = 1; break; } @@ -996,6 +1000,7 @@ int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *n void komodo_notarized_update(int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth) { static int didinit; static uint256 zero; static FILE *fp; CBlockIndex *pindex; struct notarized_checkpoint *np,N; long fpos; + LogPrintf("dpow: komodod_notarized_update\n"); if ( didinit == 0 ) { char fname[512];int32_t latestht = 0; @@ -1006,7 +1011,7 @@ void komodo_notarized_update(int32_t nHeight,int32_t notarized_height,uint256 no #else sprintf(fname,"%s/notarizations",GetDefaultDataDir().string().c_str()); #endif -// printf("fname.(%s)\n",fname); + LogPrintf("dpow: fname.(%s)\n",fname); if ( (fp= fopen(fname,"rb+")) == 0 ) fp = fopen(fname,"wb+"); else @@ -1029,7 +1034,7 @@ void komodo_notarized_update(int32_t nHeight,int32_t notarized_height,uint256 no NOTARIZED_MOMDEPTH = np->MoMdepth; fprintf(stderr,"%d ",np->notarized_height); fpos = ftell(fp); - } //else fprintf(stderr,"%s error with notarization ht.%d %s\n",ASSETCHAINS_SYMBOL,N.notarized_height,pindex->GetBlockHash().ToString().c_str()); + } else LogPrintf("dpow: %s error with notarization ht.%d %s\n",ASSETCHAINS_SYMBOL,N.notarized_height,pindex->GetBlockHash().ToString().c_str()); } if ( ftell(fp) != fpos ) fseek(fp,fpos,SEEK_SET); @@ -1038,19 +1043,22 @@ void komodo_notarized_update(int32_t nHeight,int32_t notarized_height,uint256 no didinit = 1; } if ( notarized_height == 0 ) + { + LogPrintf("dpow: notarized_height=0, aborting\n"); return; + } if ( notarized_height >= nHeight ) { - fprintf(stderr,"komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight); + LogPrintf("dpow: komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight); return; } pindex = komodo_chainactive(notarized_height); if ( pindex == 0 || pindex->GetBlockHash() != notarized_hash || notarized_height != pindex->nHeight ) { - fprintf(stderr,"komodo_notarized_update reject nHeight.%d notarized_height.%d:%d\n",nHeight,notarized_height,(int32_t)pindex->nHeight); + LogPrintf("dpow: komodo_notarized_update reject nHeight.%d notarized_height.%d:%d\n",nHeight,notarized_height,(int32_t)pindex->nHeight); return; } - fprintf(stderr,"komodo_notarized_update nHeight.%d notarized_height.%d prev.%d\n",nHeight,notarized_height,NPOINTS!=0?NPOINTS[NUM_NPOINTS-1].notarized_height:-1); + LogPrintf("dpow: komodo_notarized_update nHeight.%d notarized_height.%d prev.%d\n",nHeight,notarized_height,NPOINTS!=0?NPOINTS[NUM_NPOINTS-1].notarized_height:-1); portable_mutex_lock(&komodo_mutex); NPOINTS = (struct notarized_checkpoint *)realloc(NPOINTS,(NUM_NPOINTS+1) * sizeof(*NPOINTS)); np = &NPOINTS[NUM_NPOINTS++]; @@ -1059,6 +1067,7 @@ void komodo_notarized_update(int32_t nHeight,int32_t notarized_height,uint256 no NOTARIZED_HEIGHT = np->notarized_height = notarized_height; NOTARIZED_HASH = np->notarized_hash = notarized_hash; NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; + printf("NOTARIZED (HEIGHT,HASH,DESTTXID) = (%d, %s, %s)\n", NOTARIZED_HEIGHT, NOTARIZED_HASH.GetHex().c_str(), NOTARIZED_DESTTXID.GetHex().c_str()); if ( MoM != zero && MoMdepth > 0 ) { NOTARIZED_MOM = np->MoM = MoM; @@ -1068,7 +1077,7 @@ void komodo_notarized_update(int32_t nHeight,int32_t notarized_height,uint256 no { if ( fwrite(np,1,sizeof(*np),fp) == sizeof(*np) ) fflush(fp); - else printf("error writing notarization to %d\n",(int32_t)ftell(fp)); + else LogPrintf("dpow: error writing notarization to %d\n",(int32_t)ftell(fp)); } // add to stored notarizations portable_mutex_unlock(&komodo_mutex); @@ -1076,7 +1085,6 @@ void komodo_notarized_update(int32_t nHeight,int32_t notarized_height,uint256 no int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 hash) { - int32_t notarized_height; uint256 zero,notarized_hash,notarized_desttxid; CBlockIndex *notary; CBlockIndex *pindex; memset(&zero,0,sizeof(zero)); //komodo_notarized_update(0,0,zero,zero,zero,0); @@ -1126,7 +1134,7 @@ void komodo_voutupdate(int32_t txi,int32_t vout,uint8_t *scriptbuf,int32_t scrip opretlen = scriptbuf[len++]; opretlen += (scriptbuf[len++] << 8); } - //printf("opretlen.%d vout.%d [%s].(%s)\n",opretlen,vout,(char *)&scriptbuf[len+32*2+4],ASSETCHAINS_SYMBOL); + printf("opretlen.%d vout.%d [%s].(%s)\n",opretlen,vout,(char *)&scriptbuf[len+32*2+4],ASSETCHAINS_SYMBOL); if ( vout == 1 && opretlen-3 >= 32*2+4 && strcmp(ASSETCHAINS_SYMBOL,(char *)&scriptbuf[len+32*2+4]) == 0 ) { len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&hash); @@ -1152,12 +1160,12 @@ void komodo_voutupdate(int32_t txi,int32_t vout,uint8_t *scriptbuf,int32_t scrip } else { - fprintf(stderr,"VALID %s MoM.%s [%d]\n",ASSETCHAINS_SYMBOL,MoM.ToString().c_str(),MoMdepth); + LogPrintf("dpow: VALID %s MoM.%s [%d]\n",ASSETCHAINS_SYMBOL,MoM.ToString().c_str(),MoMdepth); } } komodo_notarized_update(height,*notarizedheightp,hash,desttxid,MoM,MoMdepth); - fprintf(stderr,"%s ht.%d NOTARIZED.%d %s %sTXID.%s lens.(%d %d)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,hash.ToString().c_str(),"KMD",desttxid.ToString().c_str(),opretlen,len); - } else fprintf(stderr,"notarized.%d ht %d vs prev %d vs height.%d\n",notarized,*notarizedheightp,NOTARIZED_HEIGHT,height); + LogPrintf("dpow: %s ht.%d NOTARIZED.%d %s %sTXID.%s lens.(%d %d)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,hash.ToString().c_str(),"KMD",desttxid.ToString().c_str(),opretlen,len); + } else LogPrintf("dpow: notarized.%d ht %d vs prev %d vs height.%d\n",notarized,*notarizedheightp,NOTARIZED_HEIGHT,height); } } } @@ -1175,6 +1183,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) memset(&zero,0,sizeof(zero)); komodo_notarized_update(0,0,zero,zero,zero,0); numnotaries = komodo_notaries(pubkeys,pindex->nHeight,pindex->GetBlockTime()); + fprintf(stderr, "numnotaries=%d\n", numnotaries); if ( pindex->nHeight > hwmheight ) hwmheight = pindex->nHeight; @@ -1188,7 +1197,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) { height = pindex->nHeight; txn_count = block.vtx.size(); - //fprintf(stderr, "txn_count=%d\n", txn_count); + fprintf(stderr, "txn_count=%d\n", txn_count); for (i=0; iGetHash(); @@ -1196,30 +1205,47 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) specialtx = notarizedheight = notarized = 0; signedmask = 0; numvins = block.vtx[i].vin.size(); - //fprintf(stderr, "tx=%d, numvouts=%d, numvins=%d\n", i, numvouts, numvins ); + fprintf(stderr, "tx=%d, numvouts=%d, numvins=%d\n", i, numvouts, numvins ); for (j=0; j= KOMODO_MINRATIFY ) notarized = 1; - if ( NOTARY_PUBKEY33[0] != 0 ) - printf("(tx.%d: ",i); + //if ( NOTARY_PUBKEY33[0] != 0 ) + // printf("(tx.%d: ",i); for (j=0; j= (int32_t)sizeof(uint32_t) && len <= (int32_t)sizeof(scriptbuf) ) { From aac7ca1509230338fa012fa5ccf8be90f132213b Mon Sep 17 00:00:00 2001 From: Team ChainStrike Date: Thu, 27 Sep 2018 03:44:03 +1000 Subject: [PATCH 02/12] undo some refactoring that doesnt handle all edge cases --- src/komodo_validation011.h | 41 +++++++++++++++----------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/src/komodo_validation011.h b/src/komodo_validation011.h index c7976f5a8..2c884cb63 100644 --- a/src/komodo_validation011.h +++ b/src/komodo_validation011.h @@ -1210,32 +1210,23 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) { if ( i == 0 && j == 0 ) continue; - bool nonzero = (block.vtx[i].vin[j].prevout.hash != zero); - - if (nonzero) { - scriptlen = gettxout_scriptPubKey(height,scriptPubKey,sizeof(scriptPubKey),block.vtx[i].vin[j].prevout.hash,block.vtx[i].vin[j].prevout.n); - fprintf(stderr, "scriptlen=%d\n", scriptlen); - if (scriptlen == 35) - { - for (k=0; k= KOMODO_MINRATIFY ) From 8f6bb4f83cbcf2f913dbf5f1e78299d1ceee15cc Mon Sep 17 00:00:00 2001 From: Team ChainStrike Date: Thu, 27 Sep 2018 03:54:58 +1000 Subject: [PATCH 03/12] see if this changes anything --- src/komodo_validation011.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_validation011.h b/src/komodo_validation011.h index 2c884cb63..b58bc1374 100644 --- a/src/komodo_validation011.h +++ b/src/komodo_validation011.h @@ -84,7 +84,8 @@ int32_t gettxout_scriptPubKey(int32_t height,uint8_t *scriptPubKey,int32_t maxsi LOCK(cs_main); if ( KOMODO_TXINDEX != 0 ) { - if ( GetTransaction(txid,tx,hashBlock,false) == 0 ) + //if ( GetTransaction(txid,tx,hashBlock,false) == 0 ) + if ( GetTransaction(txid,tx,hashBlock,true) == 0 ) { fprintf(stderr,"ht.%d couldnt get txid.%s\n",height,txid.GetHex().c_str()); return(-1); From 32a01c0abf68dcf43db6eb88c88a8788ba1251a3 Mon Sep 17 00:00:00 2001 From: Team ChainStrike Date: Fri, 28 Sep 2018 03:40:17 +1000 Subject: [PATCH 04/12] fix segfault from reusing i variable and revert GetTransaction change --- src/komodo_validation011.h | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/komodo_validation011.h b/src/komodo_validation011.h index b58bc1374..29399d06a 100644 --- a/src/komodo_validation011.h +++ b/src/komodo_validation011.h @@ -84,10 +84,9 @@ int32_t gettxout_scriptPubKey(int32_t height,uint8_t *scriptPubKey,int32_t maxsi LOCK(cs_main); if ( KOMODO_TXINDEX != 0 ) { - //if ( GetTransaction(txid,tx,hashBlock,false) == 0 ) - if ( GetTransaction(txid,tx,hashBlock,true) == 0 ) + if ( GetTransaction(txid,tx,hashBlock,false) == 0 ) { - fprintf(stderr,"ht.%d couldnt get txid.%s\n",height,txid.GetHex().c_str()); + fprintf(stderr,"ht.%d couldnt get txid.%s !\n",height,txid.GetHex().c_str()); return(-1); } } @@ -111,13 +110,11 @@ int32_t gettxout_scriptPubKey(int32_t height,uint8_t *scriptPubKey,int32_t maxsi ptr = (uint8_t *)tx.vout[n].scriptPubKey.data(); m = tx.vout[n].scriptPubKey.size(); - fprintf(stderr,"m=%d\n", m); - fprintf(stderr,"maxsize=%d\n", maxsize); for (i=0; i Date: Sat, 29 Sep 2018 02:58:41 +1000 Subject: [PATCH 05/12] More cleaning up of debug stuff --- src/komodo_validation011.h | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/komodo_validation011.h b/src/komodo_validation011.h index 29399d06a..f0690bfae 100644 --- a/src/komodo_validation011.h +++ b/src/komodo_validation011.h @@ -141,7 +141,7 @@ int32_t komodo_importaddress(std::string addr) } else { - printf("komodo_importaddress %s\n",addr.c_str()); + //printf("komodo_importaddress %s\n",addr.c_str()); ImportAddress(pwallet, address, addr); return(1); } @@ -755,7 +755,7 @@ void komodo_importpubkeys() const std::vector vPubkey(pubkey, pubkey + m); std::string addr = CBitcoinAddress(CPubKey(ParseHex(pubkey)).GetID()).ToString(); - fprintf(stderr,"pubkey=%s, addr=%s\n", pubkey, addr.c_str() ); + //fprintf(stderr,"pubkey=%s, addr=%s\n", pubkey, addr.c_str() ); if ( (val= komodo_importaddress(addr)) < 0 ) LogPrintf("dpow: error importing (%s)\n",addr.c_str()); @@ -1181,7 +1181,6 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) memset(&zero,0,sizeof(zero)); komodo_notarized_update(0,0,zero,zero,zero,0); numnotaries = komodo_notaries(pubkeys,pindex->nHeight,pindex->GetBlockTime()); - fprintf(stderr, "numnotaries=%d\n", numnotaries); if ( pindex->nHeight > hwmheight ) hwmheight = pindex->nHeight; @@ -1194,7 +1193,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( pindex != 0 ) { height = pindex->nHeight; - txn_count = block.vtx.size(); + //txn_count = block.vtx.size(); fprintf(stderr, "txn_count=%d\n", txn_count); for (i=0; i Date: Sat, 29 Sep 2018 04:37:03 +1000 Subject: [PATCH 06/12] IS_NOTARY macro --- src/komodo_validation011.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/komodo_validation011.h b/src/komodo_validation011.h index f0690bfae..4fd0a3f26 100644 --- a/src/komodo_validation011.h +++ b/src/komodo_validation011.h @@ -70,6 +70,9 @@ #define KOMODO_NOTARIES_TIMESTAMP1 1525132800 // May 1st 2018 1530921600 // 7/7/2017 #define KOMODO_NOTARIES_HEIGHT1 ((814000 / KOMODO_ELECTION_GAP) * KOMODO_ELECTION_GAP) +// Is the current node a notary node? +#define IS_NOTARY (NOTARY_PUBKEY33[0] != 0) + union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uint64_t ulongs[4]; uint64_t txid; }; typedef union _bits256 bits256; @@ -1037,7 +1040,7 @@ void komodo_notarized_update(int32_t nHeight,int32_t notarized_height,uint256 no if ( ftell(fp) != fpos ) fseek(fp,fpos,SEEK_SET); } - LogPrintf("dpow: finished loading %s [%s]\n",fname,NOTARY_PUBKEY.c_str()); + LogPrintf("dpow: finished loading %s [pubkey %s]\n",fname,NOTARY_PUBKEY.c_str()); didinit = 1; } if ( notarized_height == 0 ) @@ -1065,7 +1068,7 @@ void komodo_notarized_update(int32_t nHeight,int32_t notarized_height,uint256 no NOTARIZED_HEIGHT = np->notarized_height = notarized_height; NOTARIZED_HASH = np->notarized_hash = notarized_hash; NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; - printf("NOTARIZED (HEIGHT,HASH,DESTTXID) = (%d, %s, %s)\n", NOTARIZED_HEIGHT, NOTARIZED_HASH.GetHex().c_str(), NOTARIZED_DESTTXID.GetHex().c_str()); + LogPrintf("dpow: NOTARIZED (HEIGHT,HASH,DESTTXID) = (%d, %s, %s)\n", NOTARIZED_HEIGHT, NOTARIZED_HASH.GetHex().c_str(), NOTARIZED_DESTTXID.GetHex().c_str()); if ( MoM != zero && MoMdepth > 0 ) { NOTARIZED_MOM = np->MoM = MoM; @@ -1224,12 +1227,12 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) numvalid = bitweight(signedmask); if ( numvalid >= KOMODO_MINRATIFY ) notarized = 1; - //if ( NOTARY_PUBKEY33[0] != 0 ) - // printf("(tx.%d: ",i); + if ( IS_NOTARY ) + printf("(tx.%d: ",i); for (j=0; j= (int32_t)sizeof(uint32_t) && len <= (int32_t)sizeof(scriptbuf) ) { From dc57855bf050de07652a7e99f27363f1a53d574d Mon Sep 17 00:00:00 2001 From: Team ChainStrike Date: Sat, 29 Sep 2018 04:40:19 +1000 Subject: [PATCH 07/12] Less noise --- src/komodo_validation011.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_validation011.h b/src/komodo_validation011.h index 4fd0a3f26..8812b21e0 100644 --- a/src/komodo_validation011.h +++ b/src/komodo_validation011.h @@ -1197,7 +1197,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) { height = pindex->nHeight; //txn_count = block.vtx.size(); - fprintf(stderr, "txn_count=%d\n", txn_count); + //fprintf(stderr, "txn_count=%d\n", txn_count); for (i=0; iGetHash(); From a4eb0294c665ecd43a8c9d0f6c0d80ce711d76da Mon Sep 17 00:00:00 2001 From: Team ChainStrike Date: Sat, 29 Sep 2018 06:47:59 +1000 Subject: [PATCH 08/12] Add dpow.py to test files --- qa/pull-tester/rpc-tests.sh | 1 + qa/rpc-tests/dpow.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/qa/pull-tester/rpc-tests.sh b/qa/pull-tester/rpc-tests.sh index b9a15ba00..8d753d596 100755 --- a/qa/pull-tester/rpc-tests.sh +++ b/qa/pull-tester/rpc-tests.sh @@ -11,6 +11,7 @@ export BITCOIND=${REAL_BITCOIND} #Run the tests testScripts=( + 'dpow.py' 'paymentdisclosure.py' 'prioritisetransaction.py' 'wallet_treestate.py' diff --git a/qa/rpc-tests/dpow.py b/qa/rpc-tests/dpow.py index 9cc146adf..c9247f404 100755 --- a/qa/rpc-tests/dpow.py +++ b/qa/rpc-tests/dpow.py @@ -18,6 +18,7 @@ class DPoWTest(BitcoinTestFramework): self.nodes = [] self.is_network_split = False self.nodes.append(start_node(0, self.options.tmpdir)) + self.sync_all() def run_test(self): self.nodes[0].generate(3) @@ -27,5 +28,8 @@ class DPoWTest(BitcoinTestFramework): result = rpc.calc_MoM(2,20) print result + result = rpc.getinfo() + assert result.notarized,42 + if __name__ == '__main__': DPoWTest().main() From 197414350ec2ced5c4c882ee8553ddc71ee9884b Mon Sep 17 00:00:00 2001 From: Team ChainStrike Date: Sat, 29 Sep 2018 06:48:03 +1000 Subject: [PATCH 09/12] less noise --- src/komodo_validation011.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_validation011.h b/src/komodo_validation011.h index 8812b21e0..3ab76d8f0 100644 --- a/src/komodo_validation011.h +++ b/src/komodo_validation011.h @@ -1033,7 +1033,7 @@ void komodo_notarized_update(int32_t nHeight,int32_t notarized_height,uint256 no NOTARIZED_DESTTXID = np->notarized_desttxid; NOTARIZED_MOM = np->MoM; NOTARIZED_MOMDEPTH = np->MoMdepth; - fprintf(stderr,"%d ",np->notarized_height); + //fprintf(stderr,"%d ",np->notarized_height); fpos = ftell(fp); } else LogPrintf("dpow: %s error with notarization ht.%d %s\n",ASSETCHAINS_SYMBOL,N.notarized_height,pindex->GetBlockHash().ToString().c_str()); } From 64ce14b0d49d15a7acc6126d7fd0daa7d220f4cf Mon Sep 17 00:00:00 2001 From: Team ChainStrike Date: Sat, 29 Sep 2018 06:58:38 +1000 Subject: [PATCH 10/12] Fix various bugs preventing hush tests from running correctly, mostly incorrect binary names --- qa/rpc-tests/test_framework/util.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index 1ff4209ed..73ffdf95e 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -89,7 +89,7 @@ def initialize_chain(test_dir): """ Create (or copy from cache) a 200-block-long chain and 4 wallets. - bitcoind and bitcoin-cli must be in search path. + hushd and hush-cli must be in search path. """ if not os.path.isdir(os.path.join("cache", "node0")): @@ -97,16 +97,16 @@ def initialize_chain(test_dir): # Create cache directories, run bitcoinds: for i in range(4): datadir=initialize_datadir("cache", i) - args = [ os.getenv("BITCOIND", "bitcoind"), "-keypool=1", "-datadir="+datadir, "-discover=0" ] + args = [ os.getenv("BITCOIND", "hushd"), "-keypool=1", "-datadir="+datadir, "-discover=0" ] if i > 0: args.append("-connect=127.0.0.1:"+str(p2p_port(0))) bitcoind_processes[i] = subprocess.Popen(args) if os.getenv("PYTHON_DEBUG", ""): - print "initialize_chain: bitcoind started, calling bitcoin-cli -rpcwait getblockcount" - subprocess.check_call([ os.getenv("BITCOINCLI", "bitcoin-cli"), "-datadir="+datadir, + print "initialize_chain: hushd started, calling hush-cli -rpcwait getblockcount" + subprocess.check_call([ os.getenv("BITCOINCLI", "hush-cli"), "-datadir="+datadir, "-rpcwait", "getblockcount"], stdout=devnull) if os.getenv("PYTHON_DEBUG", ""): - print "initialize_chain: bitcoin-cli -rpcwait getblockcount completed" + print "initialize_chain: hush-cli -rpcwait getblockcount completed" devnull.close() rpcs = [] for i in range(4): @@ -177,7 +177,7 @@ def _rpchost_to_args(rpchost): def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=None): """ - Start a bitcoind and return RPC connection to it + Start a hushd and return RPC connection to it """ datadir = os.path.join(dirname, "node"+str(i)) if binary is None: @@ -187,12 +187,12 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary= bitcoind_processes[i] = subprocess.Popen(args) devnull = open("/dev/null", "w+") if os.getenv("PYTHON_DEBUG", ""): - print "start_node: bitcoind started, calling bitcoin-cli -rpcwait getblockcount" - subprocess.check_call([ os.getenv("BITCOINCLI", "bitcoin-cli"), "-datadir="+datadir] + + print "start_node: hushd started, calling hush-cli -rpcwait getblockcount" + subprocess.check_call([ os.getenv("BITCOINCLI", "hush-cli"), "-datadir="+datadir] + _rpchost_to_args(rpchost) + ["-rpcwait", "getblockcount"], stdout=devnull) if os.getenv("PYTHON_DEBUG", ""): - print "start_node: calling bitcoin-cli -rpcwait getblockcount returned" + print "start_node: calling hush-cli -rpcwait getblockcount returned" devnull.close() url = "http://rt:rt@%s:%d" % (rpchost or '127.0.0.1', rpc_port(i)) if timewait is not None: From 2668e4fda5fc475554559ca77704e5da2de6ca2b Mon Sep 17 00:00:00 2001 From: Team ChainStrike Date: Sat, 29 Sep 2018 08:03:24 +1000 Subject: [PATCH 11/12] Fix binary name in start_node() test utility --- qa/rpc-tests/test_framework/util.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index 73ffdf95e..17e2a4b22 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -94,7 +94,7 @@ def initialize_chain(test_dir): if not os.path.isdir(os.path.join("cache", "node0")): devnull = open("/dev/null", "w+") - # Create cache directories, run bitcoinds: + # Create cache directories, run hushds: for i in range(4): datadir=initialize_datadir("cache", i) args = [ os.getenv("BITCOIND", "hushd"), "-keypool=1", "-datadir="+datadir, "-discover=0" ] @@ -181,7 +181,7 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary= """ datadir = os.path.join(dirname, "node"+str(i)) if binary is None: - binary = os.getenv("BITCOIND", "bitcoind") + binary = os.getenv("BITCOIND", "hushd") args = [ binary, "-datadir="+datadir, "-keypool=1", "-discover=0", "-rest" ] if extra_args is not None: args.extend(extra_args) bitcoind_processes[i] = subprocess.Popen(args) @@ -204,7 +204,7 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary= def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, binary=None): """ - Start multiple bitcoinds, return RPC connections to them + Start multiple hushds, return RPC connections to them """ if extra_args is None: extra_args = [ None for i in range(num_nodes) ] if binary is None: binary = [ None for i in range(num_nodes) ] From fba6a314b84852289bdb8447f0993952dcbbc8e0 Mon Sep 17 00:00:00 2001 From: Team ChainStrike Date: Sat, 29 Sep 2018 08:33:23 +1000 Subject: [PATCH 12/12] Enable indexes in regtest mode so we can test them --- qa/rpc-tests/dpow.py | 3 ++- qa/rpc-tests/test_framework/util.py | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/qa/rpc-tests/dpow.py b/qa/rpc-tests/dpow.py index c9247f404..8c78b92cf 100755 --- a/qa/rpc-tests/dpow.py +++ b/qa/rpc-tests/dpow.py @@ -12,7 +12,8 @@ class DPoWTest(BitcoinTestFramework): def setup_chain(self): print("Initializing test directory "+self.options.tmpdir) - initialize_chain_clean(self.options.tmpdir, 1) + num_nodes = 1 + initialize_chain_clean(self.options.tmpdir, num_nodes) def setup_network(self): self.nodes = [] diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index 17e2a4b22..3ee5972b0 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -83,6 +83,10 @@ def initialize_datadir(dirname, n): f.write("port="+str(p2p_port(n))+"\n"); f.write("rpcport="+str(rpc_port(n))+"\n"); f.write("listenonion=0\n"); + # TODO: maybe make these optional, defaulted to on for now + f.write("addressindex=1\n"); + f.write("spentindex=1\n"); + f.write("timestampindex=1\n"); return datadir def initialize_chain(test_dir): @@ -103,6 +107,7 @@ def initialize_chain(test_dir): bitcoind_processes[i] = subprocess.Popen(args) if os.getenv("PYTHON_DEBUG", ""): print "initialize_chain: hushd started, calling hush-cli -rpcwait getblockcount" + print [ os.getenv("BITCOINCLI", "hush-cli"), "-datadir="+datadir, "-rpcwait", "getblockcount"] subprocess.check_call([ os.getenv("BITCOINCLI", "hush-cli"), "-datadir="+datadir, "-rpcwait", "getblockcount"], stdout=devnull) if os.getenv("PYTHON_DEBUG", ""):