From fbd69abd802e33a15434eac3fdd609d1adff9679 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 30 Jul 2019 03:37:46 -1100 Subject: [PATCH 1/4] +print --- src/komodo_bitcoind.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 0df145eee..f1caf47c0 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1434,8 +1434,8 @@ arith_uint256 komodo_adaptivepow_target(int32_t height,arith_uint256 bnTarget,ui bnTarget = easy; fprintf(stderr,"miner overflowed mult.%lld, set to mindiff\n",(long long)mult); } else fprintf(stderr,"miner elapsed %d, adjust by factor of %lld\n",diff,(long long)mult); - } - } //else fprintf(stderr,"cant find height.%d\n",height); + } else fprintf(stderr,"diff %d, vs 120\n",diff); + } else fprintf(stderr,"cant find height.%d\n",height); return(bnTarget); } From ab9169210ba36e6ff434cd09d413f2504fc022c7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 30 Jul 2019 04:06:18 -1100 Subject: [PATCH 2/4] Test changing of default --- src/komodo_utils.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 31e87d82b..d2a9e12a1 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -2431,6 +2431,14 @@ fprintf(stderr,"extralen.%d before disable bits\n",extralen); CCENABLE(EVAL_DICE); CCENABLE(EVAL_ORACLES); } + if ( (pindex= komodo_activechain(1)) != 0 ) + { + if ( pindex->nTime > 1564499104 ) + { + ASSETCHAINS_ADAPTIVEPOW = 1; + fprintf(stderr,"default activate adaptivepow\n"); + } + } else fprintf(stderr,"cant find height 1\n"); } else BITCOIND_RPCPORT = GetArg("-rpcport", BaseParams().RPCPort()); KOMODO_DPOWCONFS = GetArg("-dpowconfs",dpowconfs); if ( ASSETCHAINS_SYMBOL[0] == 0 || strcmp(ASSETCHAINS_SYMBOL,"SUPERNET") == 0 || strcmp(ASSETCHAINS_SYMBOL,"DEX") == 0 || strcmp(ASSETCHAINS_SYMBOL,"COQUI") == 0 || strcmp(ASSETCHAINS_SYMBOL,"PIRATE") == 0 || strcmp(ASSETCHAINS_SYMBOL,"KMDICE") == 0 ) From 96d9bcb45ebc788fb17b2f4e527fd47154024364 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 30 Jul 2019 04:07:34 -1100 Subject: [PATCH 3/4] Test timestamp --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index d2a9e12a1..8f9ece3a0 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -2433,7 +2433,7 @@ fprintf(stderr,"extralen.%d before disable bits\n",extralen); } if ( (pindex= komodo_activechain(1)) != 0 ) { - if ( pindex->nTime > 1564499104 ) + if ( pindex->nTime > 1564499104-365*2*1440 ) { ASSETCHAINS_ADAPTIVEPOW = 1; fprintf(stderr,"default activate adaptivepow\n"); From 6fbae7109cf99a0b78288bec490af20f23d4b1b9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 30 Jul 2019 04:09:37 -1100 Subject: [PATCH 4/4] Allow disabling adaptivepow --- src/komodo_bitcoind.h | 2 +- src/komodo_globals.h | 3 ++- src/komodo_utils.h | 2 +- src/miner.cpp | 10 +++++----- src/pow.cpp | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index f1caf47c0..2e4461e7b 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2283,7 +2283,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) if ( height == 0 ) return(0); } - if ( ASSETCHAINS_ADAPTIVEPOW != 0 ) + if ( ASSETCHAINS_ADAPTIVEPOW > 0 ) bnTarget = komodo_adaptivepow_target(height,bnTarget,pblock->nTime); if ( ASSETCHAINS_LWMAPOS != 0 && bhash > bnTarget ) { diff --git a/src/komodo_globals.h b/src/komodo_globals.h index de42f12b1..817e51027 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -50,7 +50,8 @@ uint256 KOMODO_EARLYTXID; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS,ASSETCHAINS_CBMATURITY,KOMODO_NSPV; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,ASSETCHAINS_SELFIMPORT,ASSETCHAINS_CCLIB; -uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_MARMARA,ASSETCHAINS_ADAPTIVEPOW; +uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_MARMARA; +int8_t ASSETCHAINS_ADAPTIVEPOW; bool VERUS_MINTBLOCKS; std::vector Mineropret; std::vector vWhiteListAddress; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 8f9ece3a0..9e470c657 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -2431,7 +2431,7 @@ fprintf(stderr,"extralen.%d before disable bits\n",extralen); CCENABLE(EVAL_DICE); CCENABLE(EVAL_ORACLES); } - if ( (pindex= komodo_activechain(1)) != 0 ) + if ( ASSETCHAINS_ADAPTIVEPOW == 0 && (pindex= komodo_activechain(1)) != 0 ) { if ( pindex->nTime > 1564499104-365*2*1440 ) { diff --git a/src/miner.cpp b/src/miner.cpp index 19e853479..05a24ca2f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1447,7 +1447,7 @@ void static BitcoinMiner_noeq() HASHTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); LogPrintf("Block %d : PoS %d%% vs target %d%%\n", Mining_height, percPoS, (int32_t)ASSETCHAINS_STAKED); } - else if ( ASSETCHAINS_ADAPTIVEPOW != 0 && ASSETCHAINS_STAKED == 0 ) + else if ( ASSETCHAINS_ADAPTIVEPOW > 0 && ASSETCHAINS_STAKED == 0 ) HASHTarget_POW = komodo_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime); while (true) @@ -1482,7 +1482,7 @@ void static BitcoinMiner_noeq() } else if ( ASSETCHAINS_STAKED == 100 && Mining_height > 100 ) hashTarget = HASHTarget; - else if ( ASSETCHAINS_ADAPTIVEPOW != 0 && ASSETCHAINS_STAKED == 0 ) + else if ( ASSETCHAINS_ADAPTIVEPOW > 0 && ASSETCHAINS_STAKED == 0 ) hashTarget = HASHTarget_POW; // for speed check NONCEMASK at a time @@ -1820,7 +1820,7 @@ void static BitcoinMiner() if ( ASSETCHAINS_STAKED < 100 ) LogPrintf("Block %d : PoS %d%% vs target %d%% \n",Mining_height,percPoS,(int32_t)ASSETCHAINS_STAKED); } - else if ( ASSETCHAINS_ADAPTIVEPOW != 0 ) + else if ( ASSETCHAINS_ADAPTIVEPOW > 0 ) HASHTarget_POW = komodo_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime); gotinvalid = 0; while (true) @@ -1849,7 +1849,7 @@ void static BitcoinMiner() arith_uint256 hashTarget; if ( KOMODO_MININGTHREADS > 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 && Mining_height > 10 ) hashTarget = HASHTarget_POW; - else if ( ASSETCHAINS_ADAPTIVEPOW != 0 ) + else if ( ASSETCHAINS_ADAPTIVEPOW > 0 ) hashTarget = HASHTarget_POW; else hashTarget = HASHTarget; std::function)> validBlock = @@ -2040,7 +2040,7 @@ void static BitcoinMiner() // Update nNonce and nTime pblock->nNonce = ArithToUint256(UintToArith256(pblock->nNonce) + 1); pblock->nBits = savebits; - if ( ASSETCHAINS_ADAPTIVEPOW != 0 ) + if ( ASSETCHAINS_ADAPTIVEPOW > 0 ) UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev); /*if ( NOTARY_PUBKEY33[0] == 0 ) { diff --git a/src/pow.cpp b/src/pow.cpp index bc862b835..18fda549f 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -453,7 +453,7 @@ bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t arith_uint256 bnMaxPoSdiff; bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); } - else if ( ASSETCHAINS_ADAPTIVEPOW != 0 && ASSETCHAINS_STAKED == 0 ) + else if ( ASSETCHAINS_ADAPTIVEPOW > 0 && ASSETCHAINS_STAKED == 0 ) bnTarget = komodo_adaptivepow_target(height,bnTarget,blkHeader.nTime); // Check proof of work matches claimed amount if ( UintToArith256(hash = blkHeader.GetHash()) > bnTarget && !blkHeader.IsVerusPOSBlock() )