From e8d79f05b8c206d035da4d29e3c8538d03c0f882 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 24 Mar 2017 07:31:40 +0200 Subject: [PATCH 1/4] Test --- src/main.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c0d4ec9a9..18bdff835 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -710,7 +710,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason) uint32_t komodo_heightstamp(int32_t height); -int32_t komodo_validate_interest(uint32_t *expiredp,const CTransaction& tx,int32_t txheight,uint32_t prevblocktime) +int32_t komodo_validate_interest(uint32_t *expiredp,const CTransaction& tx,int32_t txheight,uint32_t prevblocktime,int32_t strictflag) { int32_t i; uint32_t cmptime=0,tiptime=0,locktime=0; uint64_t value=0; CBlockIndex *tip=0; if ( KOMODO_REWIND == 0 && ASSETCHAINS_SYMBOL[0] == 0 && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD )//1473793441 ) @@ -734,12 +734,11 @@ int32_t komodo_validate_interest(uint32_t *expiredp,const CTransaction& tx,int32 { if ( txheight == 0 || txheight == chainActive.Tip()->nHeight+1 ) prevblocktime = chainActive.Tip()->nTime; - else + else if ( strictflag == 0 ) { prevblocktime = chainActive.Tip()->nTime; - fprintf(stderr,"couldnt get prevblocktime for [%d] tiptime.%u\n",txheight,prevblocktime); - return(-1); - } + fprintf(stderr,"couldnt get prevblocktime for [%d] use tiptime.%u\n",txheight,prevblocktime); + } else return(-1); } } if ( prevblocktime == 0 ) @@ -828,7 +827,7 @@ bool IsFinalTx(uint32_t *expiredp,const CTransaction &tx, int nBlockHeight, int6 return true; if ( ASSETCHAINS_SYMBOL[0] == 0 && flags == STANDARD_LOCKTIME_VERIFY_FLAGS && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD )//&& nBlockTime >= 1473793441 ) //&& (int64_t)tx.nLockTime < nBlockTime-3600 { - if ( komodo_validate_interest(expiredp,tx,nBlockHeight,prevblocktime < nBlockTime ? nBlockTime : prevblocktime) < 0 ) //if ( nBlockTime >= 1490159171 ) // 246748 + if ( komodo_validate_interest(expiredp,tx,nBlockHeight,prevblocktime < nBlockTime ? nBlockTime : prevblocktime,1) < 0 ) //if ( nBlockTime >= 1490159171 ) // 246748 { fprintf(stderr,"[%d] IsFinalTx reject.%d locktime %u vs nBlockTime %u\n",(int32_t)(tx.nLockTime-nBlockTime),(int32_t)nBlockHeight,tx.nLockTime,(uint32_t)nBlockTime); return(false); // need to prevent pastdating tx @@ -2422,7 +2421,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin if ( height > 0 && (ptr= chainActive[height-1]) != 0 ) prevtime = ptr->nTime; }*/ - if ( komodo_validate_interest(0,tx,pindex->nHeight,prevtime) < 0 ) + if ( komodo_validate_interest(0,tx,pindex->nHeight,prevtime,1) < 0 ) { //fprintf(stderr,"CheckBlock(%d:%d) %d, %u: komodo_validate_interest failure blocksize.%d tiptime.%u %u\n",height,komodo_block2height((CBlock *)&block),pindex!=0?(int32_t)pindex->nHeight:0,pindex!=0?(int32_t)pindex->nTime:0,(int32_t)block.vtx.size(),chainActive.Tip()->nTime,prevtime); return state.DoS(10, error("ConnectBlock(): validate interest failed"),REJECT_INVALID, "bad-apr-calc"); @@ -3361,7 +3360,7 @@ bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidat // Check transactions BOOST_FOREACH(const CTransaction& tx, block.vtx) { - /*uint32_t prevtime = 0; CBlockIndex *ptr; + uint32_t prevtime = 0; CBlockIndex *ptr; if ( chainActive.Tip() != 0 && height == chainActive.Tip()->nHeight+1 ) prevtime = chainActive.Tip()->nTime; else if ( pindex != 0 ) @@ -3374,11 +3373,11 @@ bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidat if ( height > 0 && (ptr= chainActive[height-1]) != 0 ) prevtime = ptr->nTime; } - if ( komodo_validate_interest(0,tx,height,prevtime) < 0 ) + if ( komodo_validate_interest(0,tx,height,prevtime,0) < 0 ) { //fprintf(stderr,"CheckBlock(%d:%d) %d, %u: komodo_validate_interest failure blocksize.%d tiptime.%u %u\n",height,komodo_block2height((CBlock *)&block),pindex!=0?(int32_t)pindex->nHeight:0,pindex!=0?(int32_t)pindex->nTime:0,(int32_t)block.vtx.size(),chainActive.Tip()->nTime,prevtime); return error("CheckBlock: komodo_validate_interest failed"); - }*/ + } if (!CheckTransaction(tx, state, verifier)) return error("CheckBlock(): CheckTransaction failed"); } From b60897a5112f730f1ad824c7aefaabd57efcd5e4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 24 Mar 2017 07:35:46 +0200 Subject: [PATCH 2/4] Test --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 18bdff835..8f2870fa9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -806,14 +806,14 @@ int32_t komodo_validate_interest(uint32_t *expiredp,const CTransaction& tx,int32 { if ( tx.nLockTime != 1477258935 ) { - fprintf(stderr,"komodo_validate_interest reject.%d [%d] locktime %u tiptime.%u cmp.%u\n",txheight,(int32_t)(tx.nLockTime - (cmptime-3600)),(uint32_t)tx.nLockTime,(uint32_t)(tip != 0 ? tip->nTime : 0),cmptime); + //fprintf(stderr,"komodo_validate_interest reject.%d [%d] locktime %u tiptime.%u cmp.%u\n",txheight,(int32_t)(tx.nLockTime - (cmptime-3600)),(uint32_t)tx.nLockTime,(uint32_t)(tip != 0 ? tip->nTime : 0),cmptime); } if ( expiredp != 0 ) *expiredp = cmptime-3600; return(-1); } } - fprintf(stderr,"validateinterest accept.%d [%d] tip.%d locktime %u cmp.%u\n",(int32_t)txheight,(int32_t)(tx.nLockTime - (cmptime-3600)),(int32_t)(tip != 0 ? tip->nHeight : 0),(int32_t)tx.nLockTime,cmptime); + fprintf(stderr,"validateinterest strict.%d accept.%d [%d] tip.%d locktime %u cmp.%u\n",strictflag,(int32_t)txheight,(int32_t)(tx.nLockTime - (cmptime-3600)),(int32_t)(tip != 0 ? tip->nHeight : 0),(int32_t)tx.nLockTime,cmptime); } return(0); } From c8e854e4c66fd7adf630796fa2b322c5c4407843 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 24 Mar 2017 07:38:40 +0200 Subject: [PATCH 3/4] Test --- src/main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 8f2870fa9..9e92c398e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -732,13 +732,13 @@ int32_t komodo_validate_interest(uint32_t *expiredp,const CTransaction& tx,int32 { if ( chainActive.Tip() != 0 ) { - if ( txheight == 0 || txheight == chainActive.Tip()->nHeight+1 ) + if ( strictflag == 0 || txheight == 0 || txheight == chainActive.Tip()->nHeight+1 ) prevblocktime = chainActive.Tip()->nTime; - else if ( strictflag == 0 ) + else { - prevblocktime = chainActive.Tip()->nTime; - fprintf(stderr,"couldnt get prevblocktime for [%d] use tiptime.%u\n",txheight,prevblocktime); - } else return(-1); + fprintf(stderr,"couldnt get prevblocktime for [%d] tiptime.%u\n",txheight,chainActive.Tip()->nTime); + return(-1); + } } } if ( prevblocktime == 0 ) From eeef062480bc0a419c3bcd76ef671496bb8b793e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 24 Mar 2017 07:40:34 +0200 Subject: [PATCH 4/4] Test --- src/main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 9e92c398e..7eabc07ff 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -813,7 +813,8 @@ int32_t komodo_validate_interest(uint32_t *expiredp,const CTransaction& tx,int32 return(-1); } } - fprintf(stderr,"validateinterest strict.%d accept.%d [%d] tip.%d locktime %u cmp.%u\n",strictflag,(int32_t)txheight,(int32_t)(tx.nLockTime - (cmptime-3600)),(int32_t)(tip != 0 ? tip->nHeight : 0),(int32_t)tx.nLockTime,cmptime); + if ( strictflag != 0 ) + fprintf(stderr,"validateinterest strict.%d accept.%d [%d] tip.%d locktime %u cmp.%u\n",strictflag,(int32_t)txheight,(int32_t)(tx.nLockTime - (cmptime-3600)),(int32_t)(tip != 0 ? tip->nHeight : 0),(int32_t)tx.nLockTime,cmptime); } return(0); } @@ -2421,7 +2422,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin if ( height > 0 && (ptr= chainActive[height-1]) != 0 ) prevtime = ptr->nTime; }*/ - if ( komodo_validate_interest(0,tx,pindex->nHeight,prevtime,1) < 0 ) + if ( komodo_validate_interest(0,tx,pindex->nHeight,prevtime,2) < 0 ) { //fprintf(stderr,"CheckBlock(%d:%d) %d, %u: komodo_validate_interest failure blocksize.%d tiptime.%u %u\n",height,komodo_block2height((CBlock *)&block),pindex!=0?(int32_t)pindex->nHeight:0,pindex!=0?(int32_t)pindex->nTime:0,(int32_t)block.vtx.size(),chainActive.Tip()->nTime,prevtime); return state.DoS(10, error("ConnectBlock(): validate interest failed"),REJECT_INVALID, "bad-apr-calc");