From b0910b9e2a17f93f908a47ac6170c46d49b3cb5b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Jul 2018 10:33:01 -1100 Subject: [PATCH 1/9] +print --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 400dc9088..4c3a66c2a 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4655,7 +4655,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt decode_hex((uint8_t *)utxotxidp,32,(char *)out.tx->GetHash().GetHex().c_str()); *utxovoutp = out.i; *txtimep = (uint32_t)out.tx->nLockTime; - fprintf(stderr,"earliest.%u [%d] (%s) nValue %.8f locktime.%u\n",earliest,(int32_t)(earliest- *blocktimep),CBitcoinAddress(address).ToString().c_str(),(double)nValue/COIN,*txtimep); + fprintf(stderr,"ht.%d earliest.%u [%d] (%s) nValue %.8f locktime.%u\n",(uint32_t)tipindex->nHeight+1,earliest,(int32_t)(earliest- *blocktimep),CBitcoinAddress(address).ToString().c_str(),(double)nValue/COIN,*txtimep); } } //else fprintf(stderr,"utxo not eligible\n"); } //else fprintf(stderr,"no tipindex\n"); From b30fdbd2378bbee5bb5801f83e5fc45d37ef5fc3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Jul 2018 10:48:32 -1100 Subject: [PATCH 2/9] +segids 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 e0c88065b..8c4e2c537 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1174,13 +1174,13 @@ int32_t komodo_segids(uint8_t *hashbuf,int32_t height,int32_t n) for (i=0; i Date: Thu, 12 Jul 2018 10:49:26 -1100 Subject: [PATCH 3/9] -prints --- src/komodo_bitcoind.h | 4 ++-- src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 8c4e2c537..e0c88065b 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1174,13 +1174,13 @@ int32_t komodo_segids(uint8_t *hashbuf,int32_t height,int32_t n) for (i=0; iGetHash().GetHex().c_str()); *utxovoutp = out.i; *txtimep = (uint32_t)out.tx->nLockTime; - fprintf(stderr,"ht.%d earliest.%u [%d] (%s) nValue %.8f locktime.%u\n",(uint32_t)tipindex->nHeight+1,earliest,(int32_t)(earliest- *blocktimep),CBitcoinAddress(address).ToString().c_str(),(double)nValue/COIN,*txtimep); + //fprintf(stderr,"ht.%d earliest.%u [%d] (%s) nValue %.8f locktime.%u\n",(uint32_t)tipindex->nHeight+1,earliest,(int32_t)(earliest- *blocktimep),CBitcoinAddress(address).ToString().c_str(),(double)nValue/COIN,*txtimep); } } //else fprintf(stderr,"utxo not eligible\n"); } //else fprintf(stderr,"no tipindex\n"); From 308ee0761c265b2c1af855d67a85b4e9014cc2dd Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Jul 2018 10:52:38 -1100 Subject: [PATCH 4/9] Guard error print --- src/komodo_bitcoind.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index e0c88065b..0c714ba9c 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1404,7 +1404,8 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ eligible = komodo_stake(1,bnTarget,height,txid,vout,pblock->nTime,prevtime+27,(char *)""); if ( eligible == 0 || eligible > pblock->nTime ) { - fprintf(stderr,"komodo_is_PoSblock PoS failure ht.%d eligible.%u vs blocktime.%u, lag.%d -> check to see if it is PoW block\n",height,eligible,(uint32_t)pblock->nTime,(int32_t)(eligible - pblock->nTime)); + if ( ASSETCHAINS_STAKED < 100 ) + fprintf(stderr,"komodo_is_PoSblock PoS failure ht.%d eligible.%u vs blocktime.%u, lag.%d -> check to see if it is PoW block\n",height,eligible,(uint32_t)pblock->nTime,(int32_t)(eligible - pblock->nTime)); } else isPoS = 1; } if ( slowflag == 0 ) // maybe previous block is not seen yet, do the best approx From 6d2faeb0b8ddcdf843198067740e8be7a7618e62 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Jul 2018 11:13:32 -1100 Subject: [PATCH 5/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 0c714ba9c..4b91f8230 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1259,7 +1259,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh } } //fprintf(stderr,"iterated until i.%d winner.%d\n",i,winner); - if ( 0 && validateflag != 0 ) + if ( validateflag != 0 ) { for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); From d5614a7628dd72f744ed15cd878f2b32dea8ebeb Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Jul 2018 11:43:32 -1100 Subject: [PATCH 6/9] Set nBits more often --- src/miner.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 8a0c63f88..dbe6dc41c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -832,8 +832,9 @@ void static BitcoinMiner() // Search // 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(); + pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); savebits = pblock->nBits; - HASHTarget = arith_uint256().SetCompact(pblock->nBits); + HASHTarget = arith_uint256().SetCompact(savebits); roundrobin_delay = ROUNDROBIN_DELAY; if ( ASSETCHAINS_SYMBOL[0] == 0 && notaryid >= 0 ) { From 3dcc06d3acbd1cca46554f72589c15da41b49c26 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Jul 2018 22:12:27 -1100 Subject: [PATCH 7/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 4b91f8230..74b9786f3 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1259,7 +1259,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh } } //fprintf(stderr,"iterated until i.%d winner.%d\n",i,winner); - if ( validateflag != 0 ) + //if ( validateflag != 0 ) { for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); From 5162b553a0e0f91d5a976d533b810e72855fd2ff Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Jul 2018 22:14:22 -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 74b9786f3..0c714ba9c 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1259,7 +1259,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh } } //fprintf(stderr,"iterated until i.%d winner.%d\n",i,winner); - //if ( validateflag != 0 ) + if ( 0 && validateflag != 0 ) { for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); From 0401884fee36534c5508b794d89c559bfd0a66ea Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 13 Jul 2018 04:45:32 -1100 Subject: [PATCH 9/9] Mitigation of very long block times, starting 2500 for PoW --- src/komodo_bitcoind.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 0c714ba9c..da244e079 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1219,6 +1219,8 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh vcalc_sha256(0,(uint8_t *)&hash,hashbuf,100 + (int32_t)sizeof(uint256)*2 + sizeof(vout)); for (iter=0; iter<180; iter++) { + if ( blocktime+iter+segid*2 < txtime+minage ) + continue; diff = (iter + blocktime - txtime - minage); if ( diff < 0 ) diff = 60; @@ -1229,9 +1231,9 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh } if ( iter > 0 ) diff += segid*2; - if ( blocktime+iter+segid*2 < txtime+minage ) - continue; coinage = (value * diff); + if ( nHeight >= 2500 && blocktime+iter+segid*2 > prevtime+180 ) + coinage *= ((blocktime+iter+segid*2) - (prevtime+60)); coinage256 = arith_uint256(coinage+1); hashval = ratio * (UintToArith256(hash) / coinage256); if ( nHeight >= 900 && nHeight < 916 )