From c7959ca288d297e8069845c84ef9bd8989afcf3a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 17:40:47 +0200 Subject: [PATCH 01/11] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index fcdcffd6b..f7ddea702 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -575,7 +575,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to PENDING_KOMODO_TX += pax->komodoshis; printf(" len.%d vout.%u DEPOSIT %.8f <- pax.%s pending ht %d %d %.8f | ",len,pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,pax->height,pax->otherheight,dstr(PENDING_KOMODO_TX)); } - if ( numvouts++ >= 1 ) + if ( numvouts++ >= 64 ) break; } if ( numvouts > 1 ) From deba1c4885b66884fe7461db915896a7f63eaf2e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 18:32:08 +0200 Subject: [PATCH 02/11] Test --- src/komodo_gateway.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f7ddea702..b56fb0d3d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -479,7 +479,8 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to } if ( i == 3 ) { - printf("%s not realtime ht.%d\n",ASSETCHAINS_SYMBOL,ht); + if ( tokomodo == 0 ) + printf("%s not realtime ht.%d\n",ASSETCHAINS_SYMBOL,ht); return(0); } if ( tokomodo == 0 ) From acad298339e81f0cce524fd08dea88acaac3233b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 19:07:26 +0200 Subject: [PATCH 03/11] Rewind < 0 --- src/init.cpp | 18 +++++++++++------- src/komodo_globals.h | 2 +- src/komodo_utils.h | 4 ++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 59dcc27b9..a03147089 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1456,13 +1456,17 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (mapArgs.count("-blocknotify")) uiInterface.NotifyBlockTip.connect(BlockNotifyCallback); - - uiInterface.InitMessage(_("Activating best chain...")); - // scan for better chains in the block chain database, that are not yet connected in the active best chain - CValidationState state; - if ( !ActivateBestChain(state)) - strErrors << "Failed to connect best block"; - + extern int32_t KOMODO_REWIND; + if ( KOMODO_REWIND < 0 ) + KOMODO_REWIND = 0; + else + { + uiInterface.InitMessage(_("Activating best chain...")); + // scan for better chains in the block chain database, that are not yet connected in the active best chain + CValidationState state; + if ( !ActivateBestChain(state)) + strErrors << "Failed to connect best block"; + } std::vector vImportFiles; if (mapArgs.count("-loadblock")) { diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 9b93ff57e..905b4fb4b 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -40,7 +40,7 @@ struct komodo_state KOMODO_STATES[34]; #define _COINBASE_MATURITY 100 int COINBASE_MATURITY = _COINBASE_MATURITY;//100; -int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET; +int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND; int32_t KOMODO_LASTMINED,prevKOMODO_LASTMINED; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES; uint8_t NOTARY_PUBKEY33[33]; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 1c32bb068..7c99aa4b2 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1463,10 +1463,10 @@ void komodo_args() KOMODO_PAX = 1; } else KOMODO_PAX = GetArg("-pax",0); name = GetArg("-ac_name",""); - /*if ( (KOMODO_REWIND= GetArg("-rewind",0)) != 0 ) + if ( (KOMODO_REWIND= GetArg("-rewind",0)) != 0 ) { printf("KOMODO_REWIND %d\n",KOMODO_REWIND); - }*/ + } if ( name.c_str()[0] != 0 ) { ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); From df35158ac28a75dce6626477804bd3309102982d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 19:13:14 +0200 Subject: [PATCH 04/11] Test --- src/init.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index a03147089..9ab3b675f 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -641,6 +641,8 @@ static void ZC_LoadParams() /** Initialize bitcoin. * @pre Parameters should be parsed and config file should be read. */ +extern int32_t KOMODO_REWIND; + bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) { // ********************************************************* Step 1: setup @@ -1244,10 +1246,13 @@ 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; + 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()); @@ -1456,7 +1461,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (mapArgs.count("-blocknotify")) uiInterface.NotifyBlockTip.connect(BlockNotifyCallback); - extern int32_t KOMODO_REWIND; if ( KOMODO_REWIND < 0 ) KOMODO_REWIND = 0; else From 8c82b6c5e02efeeb2d2f8c45ad0bddd32eee6a5f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 20:47:38 +0200 Subject: [PATCH 05/11] Test --- src/init.cpp | 6 ++---- src/main.cpp | 10 ++++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 9ab3b675f..0f03aac21 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1246,7 +1246,7 @@ 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 ( KOMODO_REWIND == 0 ) + if ( KOMODO_REWIND >= 0 ) { if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3), GetArg("-checkblocks", 288))) { @@ -1461,9 +1461,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (mapArgs.count("-blocknotify")) uiInterface.NotifyBlockTip.connect(BlockNotifyCallback); - if ( KOMODO_REWIND < 0 ) - KOMODO_REWIND = 0; - else + if ( KOMODO_REWIND >= 0 ) { uiInterface.InitMessage(_("Activating best chain...")); // scan for better chains in the block chain database, that are not yet connected in the active best chain diff --git a/src/main.cpp b/src/main.cpp index e8950f2ea..53906cbd8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2768,8 +2768,14 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo if (!DisconnectTip(state)) return false; } - /*fprintf(stderr,"chaintip %d vs rewind.%d\n",(int32_t)chainActive.Tip()->nHeight,KOMODO_REWIND); - if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight >= KOMODO_REWIND ) + extern int32_t KOMODO_REWIND; + if ( KOMODO_REWIND < 0 ) + { + fprintf(stderr,"chaintip %d vs rewind.%d\n",(int32_t)chainActive.Tip()->nHeight,KOMODO_REWIND); + sleep(3); + KOMODO_REWIND++; + } + /*if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight >= KOMODO_REWIND ) { fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight); while ( chainActive.Tip()->nHeight > KOMODO_REWIND ) From 8be34022b0702e7d8fa90eeb561441f73a7eca56 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 20:53:44 +0200 Subject: [PATCH 06/11] Test --- src/main.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 53906cbd8..c81dc77f3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2772,8 +2772,16 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo if ( KOMODO_REWIND < 0 ) { fprintf(stderr,"chaintip %d vs rewind.%d\n",(int32_t)chainActive.Tip()->nHeight,KOMODO_REWIND); + for (i=0; i<-KOMODO_REWIND; i++) + { + if ( !DisconnectTip(state) ) + { + //InvalidateBlock(state,chainActive.Tip()); + return false; + } + } sleep(3); - KOMODO_REWIND++; + KOMODO_REWIND = 0; } /*if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight >= KOMODO_REWIND ) { From 94ae3b61688486e8970b5f6308330dcef0d1a182 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 20:54:18 +0200 Subject: [PATCH 07/11] Test --- src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.cpp b/src/main.cpp index c81dc77f3..f95be2c40 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2772,6 +2772,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo if ( KOMODO_REWIND < 0 ) { fprintf(stderr,"chaintip %d vs rewind.%d\n",(int32_t)chainActive.Tip()->nHeight,KOMODO_REWIND); + int32_t i; for (i=0; i<-KOMODO_REWIND; i++) { if ( !DisconnectTip(state) ) From ae04f6178d85c50686313fe3532f130b7d80a4a4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 21:01:33 +0200 Subject: [PATCH 08/11] Test --- src/komodo_gateway.h | 7 +++++++ src/main.cpp | 16 ---------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b56fb0d3d..558d69575 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -694,6 +694,13 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above offset += komodo_scriptitemlen(&opretlen,&script[offset]); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { + extern int32_t KOMODO_REWIND; + if ( KOMODO_REWIND < 0 ) + { + fprintf(stderr,"rewind.%d\n",KOMODO_REWIND); + sleep(3); + KOMODO_REWIND = 0; + } for (i=0; inHeight,KOMODO_REWIND); - int32_t i; - for (i=0; i<-KOMODO_REWIND; i++) - { - if ( !DisconnectTip(state) ) - { - //InvalidateBlock(state,chainActive.Tip()); - return false; - } - } - sleep(3); - KOMODO_REWIND = 0; - } /*if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight >= KOMODO_REWIND ) { fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight); From 49b495854bc5ad382455df88969902c81db3e024 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 23:41:02 +0200 Subject: [PATCH 09/11] Metaphilibert requests --- src/miner.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index bd0e5c916..9c677d391 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -663,7 +663,7 @@ void static BitcoinMiner(CWallet *pwallet) if ( i == 33 ) externalflag = 1; else externalflag = 0; - if ( NOTARY_PUBKEY33[0] != 0 && notaryid < 3 ) + if ( NOTARY_PUBKEY33[0] != 0 && (notaryid < 3 || notaryid == 34 || notaryid == 51 || notaryid == 52) ) { for (i=1; i<66; i++) if ( memcmp(pubkeys[i],pubkeys[0],33) == 0 ) @@ -678,7 +678,7 @@ void static BitcoinMiner(CWallet *pwallet) } for (j=gpucount=0; j<65; j++) { - if ( mids[j] >= 0 ) + if ( mids[j] >= 0 || notaryid == 34 ) fprintf(stderr,"%d ",mids[j]); else fprintf(stderr,"GPU "); if ( mids[j] == -1 ) @@ -689,8 +689,10 @@ void static BitcoinMiner(CWallet *pwallet) for (j=0; j<65; j++) if ( mids[j] == notaryid ) break; + if ( j == 65 ) + KOMODO_LASTMINED = 0; } else fprintf(stderr,"no nonz pubkeys\n"); - if ( (Mining_height >= 235300 && Mining_height < 236000) || (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+1 && 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); From 9e5fc6d77d481fd3d012df1cd6339a432aab0e46 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 19 Mar 2017 00:30:50 +0200 Subject: [PATCH 10/11] Test --- src/komodo.h | 8 ++++++++ src/miner.cpp | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 33e4ea544..54838d94c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -545,6 +545,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); notarized = 1; } + if ( NOTARY_PUBKEY33[0] != 0 ) + printf("(tx.%d: ",i); for (j=0; j= sizeof(uint32_t) && len <= sizeof(scriptbuf) ) { @@ -578,6 +582,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } } + if ( NOTARY_PUBKEY33[0] != 0 ) + printf(") "); //printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d notarized.%d special.%d isratification.%d\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts,notarized,specialtx,isratification); if ( notarized != 0 && (notarizedheight != 0 || specialtx != 0) ) { @@ -618,6 +624,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } } + if ( NOTARY_PUBKEY33[0] != 0 ) + printf("ht.%d\n",height); if ( pindex->nHeight == hwmheight ) komodo_stateupdate(height,0,0,0,zero,0,0,0,0,height,(uint32_t)pindex->nTime,0,0,0,0); } else fprintf(stderr,"komodo_connectblock: unexpected null pindex\n"); diff --git a/src/miner.cpp b/src/miner.cpp index 9c677d391..dfec5825a 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -684,7 +684,7 @@ void static BitcoinMiner(CWallet *pwallet) if ( mids[j] == -1 ) gpucount++; } - fprintf(stderr," <- prev minerids from ht.%d notary.%d gpucount.%d %.2f%%\n",pindexPrev->nHeight,notaryid,gpucount,100.*(double)gpucount/j); + fprintf(stderr," <- prev minerids from ht.%d notary.%d gpucount.%d %.2f%% t.%u\n",pindexPrev->nHeight,notaryid,gpucount,100.*(double)gpucount/j,(uint32_t)time(NULL)); } for (j=0; j<65; j++) if ( mids[j] == notaryid ) From ac93bb3e19ba2c966047d8746830d1559ab25f63 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 19 Mar 2017 00:32:33 +0200 Subject: [PATCH 11/11] Test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 54838d94c..62c5a02de 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -625,7 +625,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } if ( NOTARY_PUBKEY33[0] != 0 ) - printf("ht.%d\n",height); + printf("%s ht.%d\n",ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL,height); if ( pindex->nHeight == hwmheight ) komodo_stateupdate(height,0,0,0,zero,0,0,0,0,height,(uint32_t)pindex->nTime,0,0,0,0); } else fprintf(stderr,"komodo_connectblock: unexpected null pindex\n");