From 7e9308be695136406231d851a4476ad517996fb5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 30 Jul 2019 05:31:53 -1100 Subject: [PATCH 1/9] Fix of by one --- 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 95f609483..f0baa74ba 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1425,7 +1425,7 @@ arith_uint256 komodo_adaptivepow_target(int32_t height,arith_uint256 bnTarget,ui tipdiff = (nTime - tipindex->nTime); if ( tipdiff > 13*ASSETCHAINS_BLOCKTIME ) diff = 13*ASSETCHAINS_BLOCKTIME; - if ( diff > 13 * ASSETCHAINS_BLOCKTIME ) + if ( diff >= 13 * ASSETCHAINS_BLOCKTIME ) { mult = diff - 12 * ASSETCHAINS_BLOCKTIME; mult = (mult / ASSETCHAINS_BLOCKTIME) * ASSETCHAINS_BLOCKTIME + ASSETCHAINS_BLOCKTIME / 2; @@ -1437,7 +1437,7 @@ 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,"diff %d, vs 120\n",diff); + } else fprintf(stderr,"height.%d tipdiff.%d diff %d, vs %d\n",height,tipdiff,diff,13*ASSETCHAINS_BLOCKTIME); } else fprintf(stderr,"cant find height.%d\n",height); return(bnTarget); } From 9496986ca908a29606d48ba2ea9addb96799aff7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 30 Jul 2019 06:09:41 -1100 Subject: [PATCH 2/9] Fix silly bug --- src/komodo_bitcoind.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index f0baa74ba..bd7de534d 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1424,7 +1424,7 @@ arith_uint256 komodo_adaptivepow_target(int32_t height,arith_uint256 bnTarget,ui diff = (nTime - tipindex->GetMedianTimePast()); tipdiff = (nTime - tipindex->nTime); if ( tipdiff > 13*ASSETCHAINS_BLOCKTIME ) - diff = 13*ASSETCHAINS_BLOCKTIME; + diff = tipdiff; if ( diff >= 13 * ASSETCHAINS_BLOCKTIME ) { mult = diff - 12 * ASSETCHAINS_BLOCKTIME; @@ -1435,10 +1435,10 @@ arith_uint256 komodo_adaptivepow_target(int32_t height,arith_uint256 bnTarget,ui if ( bnTarget < origtarget || bnTarget > easy ) // deal with overflow { 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); + fprintf(stderr,"height.%d miner overflowed mult.%lld, set to mindiff\n",height,(long long)mult); + } else fprintf(stderr,"height.%d miner elapsed %d, adjust by factor of %lld\n",height,diff,(long long)mult); } else fprintf(stderr,"height.%d tipdiff.%d diff %d, vs %d\n",height,tipdiff,diff,13*ASSETCHAINS_BLOCKTIME); - } else fprintf(stderr,"cant find height.%d\n",height); + } // else fprintf(stderr,"cant find height.%d\n",height); return(bnTarget); } From 1aab14606302eddc7abbb3bfa0706be7fcf68ec6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 30 Jul 2019 06:55:35 -1100 Subject: [PATCH 3/9] Recall hashtarget --- src/bitcoind.cpp | 2 +- src/komodo_bitcoind.h | 6 +++--- src/miner.cpp | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index cf9b1c20c..e293d6926 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -83,7 +83,7 @@ void WaitForShutdown(boost::thread_group* threadGroup) ASSETCHAINS_ADAPTIVEPOW = 1; fprintf(stderr,"default activate adaptivepow\n"); } else fprintf(stderr,"height1 time %u vs %u\n",pindex->nTime,ADAPTIVEPOW_CHANGETO_DEFAULTON); - } else fprintf(stderr,"cant find height 1\n"); + } //else fprintf(stderr,"cant find height 1\n"); if ( ASSETCHAINS_CBOPRET != 0 ) komodo_pricesinit(); while (!fShutdown) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index bd7de534d..2d1ff91a1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1435,10 +1435,10 @@ arith_uint256 komodo_adaptivepow_target(int32_t height,arith_uint256 bnTarget,ui if ( bnTarget < origtarget || bnTarget > easy ) // deal with overflow { bnTarget = easy; - fprintf(stderr,"height.%d miner overflowed mult.%lld, set to mindiff\n",height,(long long)mult); - } else fprintf(stderr,"height.%d miner elapsed %d, adjust by factor of %lld\n",height,diff,(long long)mult); + fprintf(stderr,"tipdiff.%d diff.%d height.%d miner overflowed mult.%lld, set to mindiff\n",tippdiff,diff,height,(long long)mult); + } else fprintf(stderr,"tipdiff.%d diff.%d height.%d miner elapsed %d, adjust by factor of %lld\n",tipdiff,diff,height,diff,(long long)mult); } else fprintf(stderr,"height.%d tipdiff.%d diff %d, vs %d\n",height,tipdiff,diff,13*ASSETCHAINS_BLOCKTIME); - } // else fprintf(stderr,"cant find height.%d\n",height); + } else fprintf(stderr,"adaptive cant find height.%d\n",height); return(bnTarget); } diff --git a/src/miner.cpp b/src/miner.cpp index 05a24ca2f..c72660651 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -2041,7 +2041,11 @@ void static BitcoinMiner() pblock->nNonce = ArithToUint256(UintToArith256(pblock->nNonce) + 1); pblock->nBits = savebits; if ( ASSETCHAINS_ADAPTIVEPOW > 0 ) + { + fprintf(stderr,"update time in miner\n"); UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev); + hashtarget = komodo_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime); + } /*if ( NOTARY_PUBKEY33[0] == 0 ) { int32_t percPoS; From 9ccc4fd560b79c13e2e8eee4b513e5c1120c667b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 30 Jul 2019 06:57:09 -1100 Subject: [PATCH 4/9] Tip-off --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 2d1ff91a1..bc0692cac 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1435,7 +1435,7 @@ arith_uint256 komodo_adaptivepow_target(int32_t height,arith_uint256 bnTarget,ui if ( bnTarget < origtarget || bnTarget > easy ) // deal with overflow { bnTarget = easy; - fprintf(stderr,"tipdiff.%d diff.%d height.%d miner overflowed mult.%lld, set to mindiff\n",tippdiff,diff,height,(long long)mult); + fprintf(stderr,"tipdiff.%d diff.%d height.%d miner overflowed mult.%lld, set to mindiff\n",tipdiff,diff,height,(long long)mult); } else fprintf(stderr,"tipdiff.%d diff.%d height.%d miner elapsed %d, adjust by factor of %lld\n",tipdiff,diff,height,diff,(long long)mult); } else fprintf(stderr,"height.%d tipdiff.%d diff %d, vs %d\n",height,tipdiff,diff,13*ASSETCHAINS_BLOCKTIME); } else fprintf(stderr,"adaptive cant find height.%d\n",height); From 467f59272b9b763566300fb00dc417621f2a5f10 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 30 Jul 2019 06:59:05 -1100 Subject: [PATCH 5/9] hashTarget --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index c72660651..7c31b1ee7 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -2044,7 +2044,7 @@ void static BitcoinMiner() { fprintf(stderr,"update time in miner\n"); UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev); - hashtarget = komodo_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime); + hashTarget = komodo_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime); } /*if ( NOTARY_PUBKEY33[0] == 0 ) { From b8ae0496895129390626070ad2a0293505734dc6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 30 Jul 2019 07:09:36 -1100 Subject: [PATCH 6/9] -print --- src/komodo_bitcoind.h | 2 +- src/miner.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index bc0692cac..84a84935b 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1437,7 +1437,7 @@ arith_uint256 komodo_adaptivepow_target(int32_t height,arith_uint256 bnTarget,ui bnTarget = easy; fprintf(stderr,"tipdiff.%d diff.%d height.%d miner overflowed mult.%lld, set to mindiff\n",tipdiff,diff,height,(long long)mult); } else fprintf(stderr,"tipdiff.%d diff.%d height.%d miner elapsed %d, adjust by factor of %lld\n",tipdiff,diff,height,diff,(long long)mult); - } else fprintf(stderr,"height.%d tipdiff.%d diff %d, vs %d\n",height,tipdiff,diff,13*ASSETCHAINS_BLOCKTIME); + } //else fprintf(stderr,"height.%d tipdiff.%d diff %d, vs %d\n",height,tipdiff,diff,13*ASSETCHAINS_BLOCKTIME); } else fprintf(stderr,"adaptive cant find height.%d\n",height); return(bnTarget); } diff --git a/src/miner.cpp b/src/miner.cpp index 7c31b1ee7..90020fc43 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -2042,7 +2042,6 @@ void static BitcoinMiner() pblock->nBits = savebits; if ( ASSETCHAINS_ADAPTIVEPOW > 0 ) { - fprintf(stderr,"update time in miner\n"); UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev); hashTarget = komodo_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime); } From d9020b8aa2922be1ba8b11f1483b4b2be3ded073 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 30 Jul 2019 07:24:07 -1100 Subject: [PATCH 7/9] HASHTarget_POW = --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 90020fc43..6d404161f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -2043,7 +2043,7 @@ void static BitcoinMiner() if ( ASSETCHAINS_ADAPTIVEPOW > 0 ) { UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev); - hashTarget = komodo_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime); + hashTarget = HASHTarget_POW = komodo_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime); } /*if ( NOTARY_PUBKEY33[0] == 0 ) { From 753f2f1d6299be0701fa437e682d129529b9e192 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 30 Jul 2019 07:30:41 -1100 Subject: [PATCH 8/9] +print --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 84a84935b..bc0692cac 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1437,7 +1437,7 @@ arith_uint256 komodo_adaptivepow_target(int32_t height,arith_uint256 bnTarget,ui bnTarget = easy; fprintf(stderr,"tipdiff.%d diff.%d height.%d miner overflowed mult.%lld, set to mindiff\n",tipdiff,diff,height,(long long)mult); } else fprintf(stderr,"tipdiff.%d diff.%d height.%d miner elapsed %d, adjust by factor of %lld\n",tipdiff,diff,height,diff,(long long)mult); - } //else fprintf(stderr,"height.%d tipdiff.%d diff %d, vs %d\n",height,tipdiff,diff,13*ASSETCHAINS_BLOCKTIME); + } else fprintf(stderr,"height.%d tipdiff.%d diff %d, vs %d\n",height,tipdiff,diff,13*ASSETCHAINS_BLOCKTIME); } else fprintf(stderr,"adaptive cant find height.%d\n",height); return(bnTarget); } From 8b5cbc45bfd9e6ac623f6b31bcfe6f69ae1ed890 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 30 Jul 2019 08:38:01 -1100 Subject: [PATCH 9/9] -print --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index bc0692cac..84a84935b 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1437,7 +1437,7 @@ arith_uint256 komodo_adaptivepow_target(int32_t height,arith_uint256 bnTarget,ui bnTarget = easy; fprintf(stderr,"tipdiff.%d diff.%d height.%d miner overflowed mult.%lld, set to mindiff\n",tipdiff,diff,height,(long long)mult); } else fprintf(stderr,"tipdiff.%d diff.%d height.%d miner elapsed %d, adjust by factor of %lld\n",tipdiff,diff,height,diff,(long long)mult); - } else fprintf(stderr,"height.%d tipdiff.%d diff %d, vs %d\n",height,tipdiff,diff,13*ASSETCHAINS_BLOCKTIME); + } //else fprintf(stderr,"height.%d tipdiff.%d diff %d, vs %d\n",height,tipdiff,diff,13*ASSETCHAINS_BLOCKTIME); } else fprintf(stderr,"adaptive cant find height.%d\n",height); return(bnTarget); }