From 2ba9de01cb1f1ebaee4b88a23b6ab8329559b577 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 9 Jul 2018 22:15:27 -1100 Subject: [PATCH] 7250 diff cap.16 hardfork for PoS --- src/komodo_bitcoind.h | 11 +++++++++-- src/miner.cpp | 11 +++++++++-- src/pow.cpp | 15 +++++++++++++-- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a3077828a..1a679c485 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1159,6 +1159,13 @@ uint32_t komodo_newstake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHe } if ( nHeight < 4400 ) // POSTEST64 change newstake to stake and stake to oldstake and remove bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); + else if ( nHeight >= 7250 ) + { + bnMaxPoSdiff.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); + bnMaxPoSdiff = (bnMaxPoSdiff / arith_uint256(16)); + if ( bnTarget < bnMaxPoSdiff ) + bnTarget = bnMaxPoSdiff; + } mfactor = 1024; if ( (minage= nHeight*3) > 6000 ) // about 100 blocks minage = 6000; @@ -1491,8 +1498,8 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) { if ( KOMODO_TEST_ASSETCHAIN_SKIP_POW ) return(0); - //fprintf(stderr,"pow violation and no chance it is notary ht.%d %s\n",height,hash.ToString().c_str()); - return(-1); + if ( ASSETCHAINS_STAKED == 0 ) // komodo_is_PoSblock will check bnTarget + return(-1); } } if ( ASSETCHAINS_STAKED != 0 && height >= 2 ) // must PoS or have at least 16x better PoW diff --git a/src/miner.cpp b/src/miner.cpp index bbcbf6643..bc56df370 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -856,7 +856,7 @@ void static BitcoinMiner() // // Search // - uint8_t pubkeys[66][33]; uint32_t blocktimes[66]; int mids[256],nonzpkeys,i,j,externalflag; uint32_t savebits; int64_t nStart = GetTime(); + uint8_t pubkeys[66][33]; arith_uint256 bnMaxPoSdiff; uint32_t blocktimes[66]; int mids[256],nonzpkeys,i,j,externalflag; uint32_t savebits; int64_t nStart = GetTime(); savebits = pblock->nBits; HASHTarget = arith_uint256().SetCompact(pblock->nBits); roundrobin_delay = ROUNDROBIN_DELAY; @@ -911,10 +911,17 @@ void static BitcoinMiner() } //else fprintf(stderr,"duplicate at j.%d\n",j); } else Mining_start = 0; } else Mining_start = 0; - if ( ASSETCHAINS_STAKED != 0 && GetArg("-genproclimit", 0) == 0 ) + if ( ASSETCHAINS_STAKED != 0 ) { int32_t percPoS,z; HASHTarget_POW = komodo_PoWtarget(&percPoS,HASHTarget,Mining_height,ASSETCHAINS_STAKED); + if ( Mining_height >= 7250 ) + { + bnMaxPoSdiff.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); + bnMaxPoSdiff = (bnMaxPoSdiff / arith_uint256(16)); + if ( HASHtarget < bnMaxPoSdiff ) + HASHtarget = bnMaxPoSdiff; + } if ( ASSETCHAINS_STAKED < 100 ) { for (z=31; z>=0; z--) diff --git a/src/pow.cpp b/src/pow.cpp index a6117b35c..39204f7f9 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -190,8 +190,19 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash,unsigned int } if (fNegative || bnTarget == 0 || fOverflow || bnTarget > UintToArith256(params.powLimit)) return error("CheckProofOfWork(): nBits below minimum work"); - if ( ASSETCHAINS_STAKED != 0 && height >= 4200 && height < 4400 ) // POSTEST64 remove this - bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); + if ( ASSETCHAINS_STAKED != 0 ) + { + if ( height >= 4200 && height < 4400 ) + bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); + else if ( height >= 7250 ) + { + arith_uint256 bnMaxPoSdiff; + bnMaxPoSdiff.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); + bnMaxPoSdiff = (bnMaxPoSdiff / arith_uint256(16)); + if ( bnTarget < bnMaxPoSdiff ) + bnTarget = bnMaxPoSdiff; + } + } // Check proof of work matches claimed amount if ( UintToArith256(hash) > bnTarget ) {