From 4c1921341635ca47d16bc3bd0d91745b83cdfe25 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 16 Dec 2018 06:43:39 -1100 Subject: [PATCH 1/5] Test clean sync --- src/komodo_gateway.h | 2 +- src/main.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d42adc6b9..102245723 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1373,7 +1373,7 @@ void komodo_passport_iteration() { static long lastpos[34]; static char userpass[33][1024]; static uint32_t lasttime,callcounter,lastinterest; int32_t maxseconds = 10; - FILE *fp; uint8_t *filedata; long fpos,datalen,lastfpos; int32_t baseid,limit,n,ht,isrealtime,expired,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t buf[3],starttime; cJSON *infoobj,*result; uint64_t RTmask = 0; + FILE *fp; uint8_t *filedata; long fpos,datalen,lastfpos; int32_t baseid,limit,n,ht,isrealtime,expired,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t buf[3],starttime; cJSON *infoobj,*result; uint64_t RTmask = 0; //CBlockIndex *pindex; expired = 0; while ( KOMODO_INITDONE == 0 ) { diff --git a/src/main.cpp b/src/main.cpp index 5a38f7a39..1095ea038 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5048,6 +5048,18 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C auto verifier = libzcash::ProofVerifier::Disabled(); if ((!CheckBlock(futureblockp,pindex->GetHeight(),pindex,block, state, verifier,0)) || !ContextualCheckBlock(block, state, pindex->pprev)) { + static int32_t saplinght = -1; + CBlockIndex *tmpptr; + if ( saplinght == -1 ) + saplinght = Params().GetConsensus().vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight; + if ( saplinght < 0 ) + *futureblockp = 1; + if ( saplinght > 0 && (tmpptr= chainActive().LastTip()) != 0 ) + { + fprintf(stderr,"saplinght.%d tipht.%d blockht.%d cmp.%d\n",saplinght,(int32_t)tmpptr->nHeight,pindex->nHeight,pindex->nHeight < 0 || pindex->nHeight >= saplinght || (tmpptr->nHeight > saplinght-720 && tmpptr->nHeight < saplinht+720)); + if ( pindex->nHeight < 0 || pindex->nHeight >= saplinght || (tmpptr->nHeight > saplinght-720 && tmpptr->nHeight < saplinht+720) ) + *futureblockp = 1; + } if ( *futureblockp == 0 ) { if (state.IsInvalid() && !state.CorruptionPossible()) { From 58cecce56288878fa236da84110f46aaa7393f79 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 16 Dec 2018 06:46:53 -1100 Subject: [PATCH 2/5] GetHeight() --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1095ea038..9aaf1dd19 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5056,8 +5056,8 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C *futureblockp = 1; if ( saplinght > 0 && (tmpptr= chainActive().LastTip()) != 0 ) { - fprintf(stderr,"saplinght.%d tipht.%d blockht.%d cmp.%d\n",saplinght,(int32_t)tmpptr->nHeight,pindex->nHeight,pindex->nHeight < 0 || pindex->nHeight >= saplinght || (tmpptr->nHeight > saplinght-720 && tmpptr->nHeight < saplinht+720)); - if ( pindex->nHeight < 0 || pindex->nHeight >= saplinght || (tmpptr->nHeight > saplinght-720 && tmpptr->nHeight < saplinht+720) ) + fprintf(stderr,"saplinght.%d tipht.%d blockht.%d cmp.%d\n",saplinght,(int32_t)tmpptr->nHeight,pindex->GetHeight(),pindex->GetHeight() < 0 || pindex->GetHeight() >= saplinght || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinht+720)); + if ( pindex->GetHeight() < 0 || pindex->GetHeight() >= saplinght || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinht+720) ) *futureblockp = 1; } if ( *futureblockp == 0 ) From fe4eb7bb9299389f13d567ed816e9080c60f192e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 16 Dec 2018 06:49:27 -1100 Subject: [PATCH 3/5] Syntax --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 9aaf1dd19..e95b01368 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5054,9 +5054,9 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C saplinght = Params().GetConsensus().vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight; if ( saplinght < 0 ) *futureblockp = 1; - if ( saplinght > 0 && (tmpptr= chainActive().LastTip()) != 0 ) + if ( saplinght > 0 && (tmpptr= chainActive.LastTip()) != 0 ) { - fprintf(stderr,"saplinght.%d tipht.%d blockht.%d cmp.%d\n",saplinght,(int32_t)tmpptr->nHeight,pindex->GetHeight(),pindex->GetHeight() < 0 || pindex->GetHeight() >= saplinght || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinht+720)); + fprintf(stderr,"saplinght.%d tipht.%d blockht.%d cmp.%d\n",saplinght,(int32_t)tmpptr->GetHeight(),pindex->GetHeight(),pindex->GetHeight() < 0 || pindex->GetHeight() >= saplinght || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinht+720)); if ( pindex->GetHeight() < 0 || pindex->GetHeight() >= saplinght || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinht+720) ) *futureblockp = 1; } From dd3e21e79d76be99a6abbfbf23f811f4b36de4d4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 16 Dec 2018 06:50:26 -1100 Subject: [PATCH 4/5] Test --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index e95b01368..4b14ae87c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5054,10 +5054,11 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C saplinght = Params().GetConsensus().vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight; if ( saplinght < 0 ) *futureblockp = 1; + // the problem is when a future sapling block comes in before we detected saplinght if ( saplinght > 0 && (tmpptr= chainActive.LastTip()) != 0 ) { fprintf(stderr,"saplinght.%d tipht.%d blockht.%d cmp.%d\n",saplinght,(int32_t)tmpptr->GetHeight(),pindex->GetHeight(),pindex->GetHeight() < 0 || pindex->GetHeight() >= saplinght || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinht+720)); - if ( pindex->GetHeight() < 0 || pindex->GetHeight() >= saplinght || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinht+720) ) + if ( pindex->GetHeight() < 0 || pindex->GetHeight() >= saplinght || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinght+720) ) *futureblockp = 1; } if ( *futureblockp == 0 ) From b60630d5e3ac30d631d51e67ad4b5e63d7c2e36a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 16 Dec 2018 06:51:27 -1100 Subject: [PATCH 5/5] Syntax --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 4b14ae87c..20f28d46a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5057,7 +5057,7 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C // the problem is when a future sapling block comes in before we detected saplinght if ( saplinght > 0 && (tmpptr= chainActive.LastTip()) != 0 ) { - fprintf(stderr,"saplinght.%d tipht.%d blockht.%d cmp.%d\n",saplinght,(int32_t)tmpptr->GetHeight(),pindex->GetHeight(),pindex->GetHeight() < 0 || pindex->GetHeight() >= saplinght || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinht+720)); + fprintf(stderr,"saplinght.%d tipht.%d blockht.%d cmp.%d\n",saplinght,(int32_t)tmpptr->GetHeight(),pindex->GetHeight(),pindex->GetHeight() < 0 || pindex->GetHeight() >= saplinght || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinght+720)); if ( pindex->GetHeight() < 0 || pindex->GetHeight() >= saplinght || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinght+720) ) *futureblockp = 1; }