From ebb59e6038d9624c387b11549d86c799966a2b23 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 20 Apr 2018 22:10:25 +0300 Subject: [PATCH 1/5] Test --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ef4fee8e8..3fc4d857c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4133,7 +4133,7 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo bool checked; uint256 hash; auto verifier = libzcash::ProofVerifier::Disabled(); hash = pblock->GetHash(); - //fprintf(stderr,"process newblock %s\n",hash.ToString().c_str()); + fprintf(stderr,"process newblock %s\n",hash.ToString().c_str()); if ( chainActive.Tip() != 0 ) komodo_currentheight_set(chainActive.Tip()->nHeight); checked = CheckBlock(height!=0?height:komodo_block2height(pblock),0,*pblock, state, verifier,0); @@ -4144,7 +4144,7 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo if ( checked != 0 && komodo_checkPOW(from_miner && ASSETCHAINS_STAKED == 0,pblock,height) < 0 ) { checked = 0; - //fprintf(stderr,"passed checkblock but failed checkPOW.%d\n",from_miner && ASSETCHAINS_STAKED == 0); + fprintf(stderr,"passed checkblock but failed checkPOW.%d\n",from_miner && ASSETCHAINS_STAKED == 0); } if (!checked) { From 45af4c09d85de8ebbc7003755b414e15734674bf Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 20 Apr 2018 22:19:20 +0300 Subject: [PATCH 2/5] Test --- src/komodo_bitcoind.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 14985084c..b8f27fe28 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1277,6 +1277,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) bnTarget.SetCompact(pblock->nBits,&fNegative,&fOverflow); bhash = UintToArith256(hash); possible = komodo_block2pubkey33(pubkey33,pblock); + fprinf(stderr,"height.%d slowflag.%d possible.%d cmp.%d\n",height,slowflag,possible,bhash > bnTarget); if ( height == 0 && slowflag != 0 ) // we need to assume all prior height is in the block index { if ( (pprev= mapBlockIndex[pblock->hashPrevBlock]) != 0 ) @@ -1348,8 +1349,8 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } } } - //fprintf(stderr,"komodo_checkPOW slowflag.%d ht.%d notaryid.%d failed.%d\n",slowflag,height,notaryid,failed); - if ( failed != 0 && notaryid < 0 ) + fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed); + if ( failed != 0 && (possible == 0 || notaryid < 0) ) return(-1); else return(0); } From 350d40c747a0fc4c7abe2247302ae33279b40ddc Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 20 Apr 2018 22:19:56 +0300 Subject: [PATCH 3/5] Test --- src/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 3fc4d857c..73748df08 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3544,8 +3544,8 @@ CBlockIndex* AddToBlockIndex(const CBlockHeader& block) BlockMap::iterator miPrev = mapBlockIndex.find(block.hashPrevBlock); if (it != mapBlockIndex.end()) { - if ( ASSETCHAINS_STAKED == 0 || it->second != 0 ) // change behavior to allow komodo_ensure to work - //if ( vNodes.size() >= KOMODO_LIMITED_NETWORKSIZE || it->second != 0 ) // change behavior to allow komodo_ensure to work + //if ( ASSETCHAINS_STAKED == 0 || it->second != 0 ) // change behavior to allow komodo_ensure to work + if ( vNodes.size() >= KOMODO_LIMITED_NETWORKSIZE || it->second != 0 ) // change behavior to allow komodo_ensure to work { // this is the strange case where somehow the hash is in the mapBlockIndex via as yet undetermined process, but the pindex for the hash is not there. Theoretically it is due to processing the block headers, but I have seen it get this case without having received it from the block headers or anywhere else... jl777 //fprintf(stderr,"addtoblockindex already there %p\n",it->second); @@ -4156,7 +4156,7 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo } // Store to disk CBlockIndex *pindex = NULL; - if ( ASSETCHAINS_STAKED != 0 )//vNodes.size() < KOMODO_LIMITED_NETWORKSIZE ) + if ( vNodes.size() < KOMODO_LIMITED_NETWORKSIZE ) //ASSETCHAINS_STAKED != 0 )// { // without the komodo_ensure call, it is quite possible to get a non-error but null pindex returned from AcceptBlockHeader. In a 2 node network, it will be a long time before that block is reprocessed. Even though restarting makes it rescan, it seems much better to keep the nodes in sync komodo_ensure(pblock,hash); From bd30f12363a246b49113bf00294fb4123f077c97 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 20 Apr 2018 22:21:13 +0300 Subject: [PATCH 4/5] Test --- 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 b8f27fe28..d8da03d42 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1277,7 +1277,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) bnTarget.SetCompact(pblock->nBits,&fNegative,&fOverflow); bhash = UintToArith256(hash); possible = komodo_block2pubkey33(pubkey33,pblock); - fprinf(stderr,"height.%d slowflag.%d possible.%d cmp.%d\n",height,slowflag,possible,bhash > bnTarget); + fprintf(stderr,"height.%d slowflag.%d possible.%d cmp.%d\n",height,slowflag,possible,bhash > bnTarget); if ( height == 0 && slowflag != 0 ) // we need to assume all prior height is in the block index { if ( (pprev= mapBlockIndex[pblock->hashPrevBlock]) != 0 ) From c685d69264ab6c7d61f2a514ba3dad3929a69bd7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 20 Apr 2018 22:27:11 +0300 Subject: [PATCH 5/5] Test --- src/komodo_bitcoind.h | 6 +++--- src/main.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index d8da03d42..ecc568f6c 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1277,7 +1277,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) bnTarget.SetCompact(pblock->nBits,&fNegative,&fOverflow); bhash = UintToArith256(hash); possible = komodo_block2pubkey33(pubkey33,pblock); - fprintf(stderr,"height.%d slowflag.%d possible.%d cmp.%d\n",height,slowflag,possible,bhash > bnTarget); + //fprintf(stderr,"height.%d slowflag.%d possible.%d cmp.%d\n",height,slowflag,possible,bhash > bnTarget); if ( height == 0 && slowflag != 0 ) // we need to assume all prior height is in the block index { if ( (pprev= mapBlockIndex[pblock->hashPrevBlock]) != 0 ) @@ -1349,8 +1349,8 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } } } - fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed); - if ( failed != 0 && (possible == 0 || notaryid < 0) ) + //fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed); + if ( failed != 0 && possible == 0 && notaryid < 0 ) return(-1); else return(0); } diff --git a/src/main.cpp b/src/main.cpp index 73748df08..008bd3197 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4133,7 +4133,7 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo bool checked; uint256 hash; auto verifier = libzcash::ProofVerifier::Disabled(); hash = pblock->GetHash(); - fprintf(stderr,"process newblock %s\n",hash.ToString().c_str()); + //fprintf(stderr,"process newblock %s\n",hash.ToString().c_str()); if ( chainActive.Tip() != 0 ) komodo_currentheight_set(chainActive.Tip()->nHeight); checked = CheckBlock(height!=0?height:komodo_block2height(pblock),0,*pblock, state, verifier,0);