From 6ff77181f26f61fdd23d7cc61f5cf072881bf9fb Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 18:23:20 +0200 Subject: [PATCH 01/14] Test --- src/main.cpp | 17 +++++++++++------ src/main.h | 2 +- src/miner.cpp | 12 +++++++++--- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 3f944a3bc..d258d185c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -721,7 +721,7 @@ int32_t komodo_validate_interest(const CTransaction& tx) } if ( (int64_t)tx.nLockTime < txheighttime-3600 ) { - if ( txheighttime > 1490159171 || (txheight == 0 && txheighttime >= 1490159171) ) // 246748 + if ( txheighttime > 1490159171 )//|| (txheight == 0 && txheighttime >= 1490159171) ) // 246748 { static uint32_t counter; if ( counter++ < 100 ) @@ -733,18 +733,20 @@ int32_t komodo_validate_interest(const CTransaction& tx) return(0); } -bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime,int flags) +bool IsFinalTx(uint32_t *expiredp,const CTransaction &tx, int nBlockHeight, int64_t nBlockTime,int flags) { int32_t i; + if ( expiredp != 0 ) + *expiredp = 0; if (tx.nLockTime == 0) return true; if ( ASSETCHAINS_SYMBOL[0] == 0 && flags == STANDARD_LOCKTIME_VERIFY_FLAGS && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD && (int64_t)tx.nLockTime < nBlockTime-3600 ) { - //if ( komodo_validate_interest(tx) < 0 ) - // return(false); if ( nBlockTime >= 1490159171 || nBlockHeight > 246748 ) // 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); + if ( expiredp != 0 ) + *expiredp = nBlockTime-3600; return(false); // need to prevent pastdating tx } else fprintf(stderr,"IsFinalTx grandfather.%d locktime %u vs nBlockTime %u\n",(int32_t)nBlockHeight,tx.nLockTime,(uint32_t)nBlockTime); } @@ -793,7 +795,7 @@ bool CheckFinalTx(const CTransaction &tx, int flags) ? chainActive.Tip()->GetMedianTimePast() : GetAdjustedTime(); - return IsFinalTx(tx, nBlockHeight, nBlockTime,flags); + return IsFinalTx(0,tx, nBlockHeight, nBlockTime,flags); } /** @@ -899,7 +901,10 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state,libzcash:: if ( *(int32_t *)&array[0] == 0 ) komodo_bannedset(array,(int32_t)(sizeof(array)/sizeof(*array))); if ( komodo_validate_interest(tx) < 0 ) + { + fprintf(stderr,"CheckTransaction komodo_validate_interest error\n"); return(false); + } n = tx.vin.size(); for (j=0; jGetMedianTimePast() : block.GetBlockTime(); - if (!IsFinalTx(tx, nHeight, nLockTimeCutoff,0*STANDARD_LOCKTIME_VERIFY_FLAGS)) { + if (!IsFinalTx(0,tx, nHeight, nLockTimeCutoff,0*STANDARD_LOCKTIME_VERIFY_FLAGS)) { return state.DoS(10, error("%s: contains a non-final transaction", __func__), REJECT_INVALID, "bad-txns-nonfinal"); } } diff --git a/src/main.h b/src/main.h index 0a137188d..dcbd23632 100644 --- a/src/main.h +++ b/src/main.h @@ -351,7 +351,7 @@ bool IsStandardTx(const CTransaction& tx, std::string& reason); * Check if transaction is final and can be included in a block with the * specified height and time. Consensus critical. */ -bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime, int flags); +bool IsFinalTx(uint32_t *expiredp,const CTransaction &tx, int nBlockHeight, int64_t nBlockTime, int flags); /** * Check if transaction will be final in the next block to be created. diff --git a/src/miner.cpp b/src/miner.cpp index ab95c4aa6..cb6d4e23a 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -183,7 +183,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblock->nTime = GetAdjustedTime(); const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); CCoinsViewCache view(pcoinsTip); - + uin32_t expired; + // Priority order to process transactions list vOrphan; // list memory doesn't move map > mapDependers; @@ -201,9 +202,14 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) ? nMedianTimePast : pblock->GetBlockTime(); - if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, nLockTimeCutoff,STANDARD_LOCKTIME_VERIFY_FLAGS)) + if (tx.IsCoinBase() || !IsFinalTx(&expired,tx, nHeight, nLockTimeCutoff,STANDARD_LOCKTIME_VERIFY_FLAGS)) + { + if ( expired != 0 ) + { + fprintf(stderr,"expire from mempool tx.(%d %d) %.8f\n",tx.vins.size(),tx.vouts.size(),(double)tx.vouts[0].nValue/COIN); + } continue; - + } COrphan* porphan = NULL; double dPriority = 0; CAmount nTotalIn = 0; From 0a4ad821515eff6f4f3a4d22d5d687f8f044669e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 18:30:02 +0200 Subject: [PATCH 02/14] Test --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index cb6d4e23a..aaf481db2 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -183,7 +183,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblock->nTime = GetAdjustedTime(); const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); CCoinsViewCache view(pcoinsTip); - uin32_t expired; + uint32_t expired; // Priority order to process transactions list vOrphan; // list memory doesn't move @@ -206,7 +206,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) { if ( expired != 0 ) { - fprintf(stderr,"expire from mempool tx.(%d %d) %.8f\n",tx.vins.size(),tx.vouts.size(),(double)tx.vouts[0].nValue/COIN); + fprintf(stderr,"expire from mempool tx.\n");//(%d %d) %.8f\n",tx.vins.size(),tx.vouts.size(),(double)tx.vouts[0].nValue/COIN); } continue; } From a6e10f4082895fed788dfc6a776a81812d26bae0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 19:29:04 +0200 Subject: [PATCH 03/14] Test --- src/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index d258d185c..df92930a7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -712,6 +712,8 @@ int32_t komodo_validate_interest(const CTransaction& tx) if ( ASSETCHAINS_SYMBOL[0] == 0 && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD ) { locktime = komodo_interest_args(&txheighttime,&txheight,&tiptime,&value,tx.GetHash(),0); + if ( tiptime == 0 ) + tiptime = (int32_t)chainActive.Tip()->nTime; if ( txheighttime == 0 ) { static uint32_t counter0; @@ -723,12 +725,14 @@ int32_t komodo_validate_interest(const CTransaction& tx) { if ( txheighttime > 1490159171 )//|| (txheight == 0 && txheighttime >= 1490159171) ) // 246748 { + // komodo_validate_interest reject.0 locktime 1490193206/0 vs nBlockTime 1490202625 txheighttime.1490202625 tiptime.0 static uint32_t counter; if ( counter++ < 100 ) fprintf(stderr,"komodo_validate_interest reject.%d locktime %u/%u vs nBlockTime %u txheighttime.%u tiptime.%u\n",txheight,(uint32_t)tx.nLockTime,locktime,(uint32_t)chainActive.Tip()->nTime,txheighttime,tiptime); return(-1); } else fprintf(stderr,"validateinterest grandfather.%d locktime %u vs txheighttime.%u tiptime.%u\n",(int32_t)txheight,tx.nLockTime,txheighttime,tiptime); } + fprintf(stderr,"validateinterest accept.%d locktime %u/%u vs txheighttime.%u tiptime.%u\n",(int32_t)txheight,(int32_t)tx.nLockTime,locktime,txheighttime,tiptime); } return(0); } From b667a3cc4d8570627ba495aa6b5fbdcff2eaaef9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 19:35:42 +0200 Subject: [PATCH 04/14] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index df92930a7..f561d504d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -723,7 +723,7 @@ int32_t komodo_validate_interest(const CTransaction& tx) } if ( (int64_t)tx.nLockTime < txheighttime-3600 ) { - if ( txheighttime > 1490159171 )//|| (txheight == 0 && txheighttime >= 1490159171) ) // 246748 + if ( txheighttime > 1490159171 || (txheight == 0 && txheighttime >= 1490159171) ) // 246748 { // komodo_validate_interest reject.0 locktime 1490193206/0 vs nBlockTime 1490202625 txheighttime.1490202625 tiptime.0 static uint32_t counter; From 3087a316f42b1150f507bc923505e83c3c5a55eb Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 19:45:09 +0200 Subject: [PATCH 05/14] Test --- src/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index f561d504d..c98a985e8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -723,11 +723,11 @@ int32_t komodo_validate_interest(const CTransaction& tx) } if ( (int64_t)tx.nLockTime < txheighttime-3600 ) { - if ( txheighttime > 1490159171 || (txheight == 0 && txheighttime >= 1490159171) ) // 246748 + if ( txheighttime > 1490159171 )//|| (txheight == 0 && txheighttime >= 1490159171) ) // 246748 { // komodo_validate_interest reject.0 locktime 1490193206/0 vs nBlockTime 1490202625 txheighttime.1490202625 tiptime.0 - static uint32_t counter; - if ( counter++ < 100 ) + //static uint32_t counter; + //if ( counter++ < 100 ) fprintf(stderr,"komodo_validate_interest reject.%d locktime %u/%u vs nBlockTime %u txheighttime.%u tiptime.%u\n",txheight,(uint32_t)tx.nLockTime,locktime,(uint32_t)chainActive.Tip()->nTime,txheighttime,tiptime); return(-1); } else fprintf(stderr,"validateinterest grandfather.%d locktime %u vs txheighttime.%u tiptime.%u\n",(int32_t)txheight,tx.nLockTime,txheighttime,tiptime); From 74d56dfd45b584df0c4d4ebc23cd8c7241ea5c67 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 19:58:37 +0200 Subject: [PATCH 06/14] Test --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c98a985e8..3fa381af1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -904,7 +904,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state,libzcash:: static uint256 array[15]; int32_t j,k,n; if ( *(int32_t *)&array[0] == 0 ) komodo_bannedset(array,(int32_t)(sizeof(array)/sizeof(*array))); - if ( komodo_validate_interest(tx) < 0 ) + if ( 0 && komodo_validate_interest(tx) < 0 ) { fprintf(stderr,"CheckTransaction komodo_validate_interest error\n"); return(false); @@ -3329,7 +3329,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST) ? pindexPrev->GetMedianTimePast() : block.GetBlockTime(); - if (!IsFinalTx(0,tx, nHeight, nLockTimeCutoff,0*STANDARD_LOCKTIME_VERIFY_FLAGS)) { + if (!IsFinalTx(0,tx, nHeight, nLockTimeCutoff,STANDARD_LOCKTIME_VERIFY_FLAGS)) { return state.DoS(10, error("%s: contains a non-final transaction", __func__), REJECT_INVALID, "bad-txns-nonfinal"); } } From 1ebbcd18b3565ddcd66f94703edf5be33f546a9e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 20:04:03 +0200 Subject: [PATCH 07/14] Test --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 3fa381af1..c98a985e8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -904,7 +904,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state,libzcash:: static uint256 array[15]; int32_t j,k,n; if ( *(int32_t *)&array[0] == 0 ) komodo_bannedset(array,(int32_t)(sizeof(array)/sizeof(*array))); - if ( 0 && komodo_validate_interest(tx) < 0 ) + if ( komodo_validate_interest(tx) < 0 ) { fprintf(stderr,"CheckTransaction komodo_validate_interest error\n"); return(false); @@ -3329,7 +3329,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST) ? pindexPrev->GetMedianTimePast() : block.GetBlockTime(); - if (!IsFinalTx(0,tx, nHeight, nLockTimeCutoff,STANDARD_LOCKTIME_VERIFY_FLAGS)) { + if (!IsFinalTx(0,tx, nHeight, nLockTimeCutoff,0*STANDARD_LOCKTIME_VERIFY_FLAGS)) { return state.DoS(10, error("%s: contains a non-final transaction", __func__), REJECT_INVALID, "bad-txns-nonfinal"); } } From 837b94ee83f634e1ee17adec0712720b11e9582f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 20:18:41 +0200 Subject: [PATCH 08/14] Test --- src/main.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c98a985e8..29b11998e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -706,7 +706,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason) return true; } -int32_t komodo_validate_interest(const CTransaction& tx) +int32_t komodo_validate_interest(const CTransaction& tx,uint32_t txblocktime) { int32_t i,txheight=0; uint32_t txheighttime,tiptime=0,locktime; uint64_t value=0; if ( ASSETCHAINS_SYMBOL[0] == 0 && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD ) @@ -746,7 +746,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 && (int64_t)tx.nLockTime < nBlockTime-3600 ) { - if ( nBlockTime >= 1490159171 || nBlockHeight > 246748 ) // 246748 + 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); if ( expiredp != 0 ) @@ -904,11 +904,11 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state,libzcash:: static uint256 array[15]; int32_t j,k,n; if ( *(int32_t *)&array[0] == 0 ) komodo_bannedset(array,(int32_t)(sizeof(array)/sizeof(*array))); - if ( komodo_validate_interest(tx) < 0 ) + /*if ( komodo_validate_interest(tx) < 0 ) { fprintf(stderr,"CheckTransaction komodo_validate_interest error\n"); return(false); - } + }*/ n = tx.vin.size(); for (j=0; j Date: Wed, 22 Mar 2017 20:22:05 +0200 Subject: [PATCH 09/14] Test --- src/main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 29b11998e..7fdc7fc44 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -721,18 +721,18 @@ int32_t komodo_validate_interest(const CTransaction& tx,uint32_t txblocktime) if ( counter0++ < 3 ) fprintf(stderr,"error getting txheighttime, set to tiptime.%u\n",txheighttime); } - if ( (int64_t)tx.nLockTime < txheighttime-3600 ) + if ( (int64_t)tx.nLockTime < txblocktime-3600 )//txheighttime-3600 ) { if ( txheighttime > 1490159171 )//|| (txheight == 0 && txheighttime >= 1490159171) ) // 246748 { // komodo_validate_interest reject.0 locktime 1490193206/0 vs nBlockTime 1490202625 txheighttime.1490202625 tiptime.0 //static uint32_t counter; //if ( counter++ < 100 ) - fprintf(stderr,"komodo_validate_interest reject.%d locktime %u/%u vs nBlockTime %u txheighttime.%u tiptime.%u\n",txheight,(uint32_t)tx.nLockTime,locktime,(uint32_t)chainActive.Tip()->nTime,txheighttime,tiptime); + fprintf(stderr,"komodo_validate_interest reject.%d locktime %u/%u vs nBlockTime %u txheighttime.%u tiptime.%u txb.%u\n",txheight,(uint32_t)tx.nLockTime,locktime,(uint32_t)chainActive.Tip()->nTime,txheighttime,tiptime,txblocktime); return(-1); - } else fprintf(stderr,"validateinterest grandfather.%d locktime %u vs txheighttime.%u tiptime.%u\n",(int32_t)txheight,tx.nLockTime,txheighttime,tiptime); + } else fprintf(stderr,"validateinterest grandfather.%d locktime %u vs txheighttime.%u tiptime.%u txb.%u\n",(int32_t)txheight,tx.nLockTime,txheighttime,tiptime,txblocktime); } - fprintf(stderr,"validateinterest accept.%d locktime %u/%u vs txheighttime.%u tiptime.%u\n",(int32_t)txheight,(int32_t)tx.nLockTime,locktime,txheighttime,tiptime); + fprintf(stderr,"validateinterest accept.%d locktime %u/%u vs txheighttime.%u tiptime.%u txb.%u\n",(int32_t)txheight,(int32_t)tx.nLockTime,locktime,txheighttime,tiptime,txblocktime); } return(0); } @@ -3251,7 +3251,7 @@ bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidat // Check transactions BOOST_FOREACH(const CTransaction& tx, block.vtx) { - if ( komodo_validate_interest(tx,block.vtx.nTime) < 0 ) + if ( komodo_validate_interest(tx,block.nTime) < 0 ) { fprintf(stderr,"CheckBlock(): komodo_validate_interest failure\n"); return error("CheckBlock: komodo_validate_interest failed"); From de463b10508dae4364dac6b57ad5a0a8865fc855 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 20:45:07 +0200 Subject: [PATCH 10/14] Test --- src/main.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 7fdc7fc44..236b4b1af 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -708,7 +708,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason) int32_t komodo_validate_interest(const CTransaction& tx,uint32_t txblocktime) { - int32_t i,txheight=0; uint32_t txheighttime,tiptime=0,locktime; uint64_t value=0; + int32_t i,txheight=0; uint32_t cmptime,txheighttime,tiptime=0,locktime; uint64_t value=0; if ( ASSETCHAINS_SYMBOL[0] == 0 && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD ) { locktime = komodo_interest_args(&txheighttime,&txheight,&tiptime,&value,tx.GetHash(),0); @@ -721,9 +721,17 @@ int32_t komodo_validate_interest(const CTransaction& tx,uint32_t txblocktime) if ( counter0++ < 3 ) fprintf(stderr,"error getting txheighttime, set to tiptime.%u\n",txheighttime); } - if ( (int64_t)tx.nLockTime < txblocktime-3600 )//txheighttime-3600 ) + if ( txheighttime != 0 && txblocktime != 0 ) { - if ( txheighttime > 1490159171 )//|| (txheight == 0 && txheighttime >= 1490159171) ) // 246748 + cmptime = txheighttime; + if ( txblocktime < cmptime ) + cmptime = txblocktime; + } + else if ( (cmptime= txheighttime) == 0 ) + cmptime = txblockime; + if ( cmptime != 0 && (int64_t)tx.nLockTime < cmptime-3600 ) + { + if ( txheighttime > 1490159171 || (locktime == 0 && txheighttime >= 1490159171) ) // 246748 { // komodo_validate_interest reject.0 locktime 1490193206/0 vs nBlockTime 1490202625 txheighttime.1490202625 tiptime.0 //static uint32_t counter; From 7133babe5fe78c35d76f124e6b3c312ff196627d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 20:47:03 +0200 Subject: [PATCH 11/14] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 236b4b1af..01e0fc7f9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -728,7 +728,7 @@ int32_t komodo_validate_interest(const CTransaction& tx,uint32_t txblocktime) cmptime = txblocktime; } else if ( (cmptime= txheighttime) == 0 ) - cmptime = txblockime; + cmptime = txblocktime; if ( cmptime != 0 && (int64_t)tx.nLockTime < cmptime-3600 ) { if ( txheighttime > 1490159171 || (locktime == 0 && txheighttime >= 1490159171) ) // 246748 From 241a6ce5f4423b41976ef0fb6cac991b7af5a78d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 21:34:03 +0200 Subject: [PATCH 12/14] Test --- src/main.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 01e0fc7f9..6afb42ce6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -729,6 +729,11 @@ int32_t komodo_validate_interest(const CTransaction& tx,uint32_t txblocktime) } else if ( (cmptime= txheighttime) == 0 ) cmptime = txblocktime; + if ( tiptime != 0 && tiptime < cmptime ) + cmptime = tiptime; + //validateinterest accept.246749 locktime 1490205024/1490205024 vs txheighttime.1490205794 tiptime.1490159171 txb.1490205794 + //komodo_validate_interest reject.246749 locktime 1490201846/1490201846 vs nBlockTime 1490159171 txheighttime.1490205794 tiptime.1490159171 txb.1490205794 + //CheckBlock(): komodo_validate_interest failure if ( cmptime != 0 && (int64_t)tx.nLockTime < cmptime-3600 ) { if ( txheighttime > 1490159171 || (locktime == 0 && txheighttime >= 1490159171) ) // 246748 @@ -736,11 +741,11 @@ int32_t komodo_validate_interest(const CTransaction& tx,uint32_t txblocktime) // komodo_validate_interest reject.0 locktime 1490193206/0 vs nBlockTime 1490202625 txheighttime.1490202625 tiptime.0 //static uint32_t counter; //if ( counter++ < 100 ) - fprintf(stderr,"komodo_validate_interest reject.%d locktime %u/%u vs nBlockTime %u txheighttime.%u tiptime.%u txb.%u\n",txheight,(uint32_t)tx.nLockTime,locktime,(uint32_t)chainActive.Tip()->nTime,txheighttime,tiptime,txblocktime); + fprintf(stderr,"komodo_validate_interest reject.%d locktime %u/%u vs nBlockTime %u txheighttime.%u tiptime.%u txb.%u cmp.%u\n",txheight,(uint32_t)tx.nLockTime,locktime,(uint32_t)chainActive.Tip()->nTime,txheighttime,tiptime,txblocktime,cmptime); return(-1); - } else fprintf(stderr,"validateinterest grandfather.%d locktime %u vs txheighttime.%u tiptime.%u txb.%u\n",(int32_t)txheight,tx.nLockTime,txheighttime,tiptime,txblocktime); + } else fprintf(stderr,"validateinterest grandfather.%d locktime %u vs txheighttime.%u tiptime.%u txb.%u cmp.%u\n",(int32_t)txheight,tx.nLockTime,txheighttime,tiptime,txblocktime,cmptime); } - fprintf(stderr,"validateinterest accept.%d locktime %u/%u vs txheighttime.%u tiptime.%u txb.%u\n",(int32_t)txheight,(int32_t)tx.nLockTime,locktime,txheighttime,tiptime,txblocktime); + fprintf(stderr,"validateinterest accept.%d locktime %u/%u vs txheighttime.%u tiptime.%u txb.%u cmp.%u\n",(int32_t)txheight,(int32_t)tx.nLockTime,locktime,txheighttime,tiptime,txblocktime,cmptime); } return(0); } From d022ff08d461b8562bb88c2bc5f882691fee40e2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 22:07:39 +0200 Subject: [PATCH 13/14] Test --- src/main.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 6afb42ce6..82cd0f366 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -709,7 +709,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason) int32_t komodo_validate_interest(const CTransaction& tx,uint32_t txblocktime) { int32_t i,txheight=0; uint32_t cmptime,txheighttime,tiptime=0,locktime; uint64_t value=0; - if ( ASSETCHAINS_SYMBOL[0] == 0 && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD ) + if ( ASSETCHAINS_SYMBOL[0] == 0 && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD && txblocktime > 1490159171-24*3600*100 ) { locktime = komodo_interest_args(&txheighttime,&txheight,&tiptime,&value,tx.GetHash(),0); if ( tiptime == 0 ) @@ -757,9 +757,10 @@ bool IsFinalTx(uint32_t *expiredp,const CTransaction &tx, int nBlockHeight, int6 *expiredp = 0; if (tx.nLockTime == 0) return true; - if ( ASSETCHAINS_SYMBOL[0] == 0 && flags == STANDARD_LOCKTIME_VERIFY_FLAGS && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD && (int64_t)tx.nLockTime < nBlockTime-3600 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 && flags == STANDARD_LOCKTIME_VERIFY_FLAGS && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD && nBlockTime > 1490159171-24*3600*100 ) //&& (int64_t)tx.nLockTime < nBlockTime-3600 { - if ( nBlockTime >= 1490159171 ) // 246748 + if ( komodo_validate_interest(tx,nBlockTime) < 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); if ( expiredp != 0 ) From 3d7d73a47a94553e00050720eb036113956306c4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 22:12:07 +0200 Subject: [PATCH 14/14] Test --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 82cd0f366..62a476c4b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -709,7 +709,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason) int32_t komodo_validate_interest(const CTransaction& tx,uint32_t txblocktime) { int32_t i,txheight=0; uint32_t cmptime,txheighttime,tiptime=0,locktime; uint64_t value=0; - if ( ASSETCHAINS_SYMBOL[0] == 0 && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD && txblocktime > 1490159171-24*3600*100 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD && txblocktime >= 1473793441 ) { locktime = komodo_interest_args(&txheighttime,&txheight,&tiptime,&value,tx.GetHash(),0); if ( tiptime == 0 ) @@ -757,7 +757,7 @@ bool IsFinalTx(uint32_t *expiredp,const CTransaction &tx, int nBlockHeight, int6 *expiredp = 0; if (tx.nLockTime == 0) return true; - if ( ASSETCHAINS_SYMBOL[0] == 0 && flags == STANDARD_LOCKTIME_VERIFY_FLAGS && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD && nBlockTime > 1490159171-24*3600*100 ) //&& (int64_t)tx.nLockTime < nBlockTime-3600 + 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(tx,nBlockTime) < 0 ) //if ( nBlockTime >= 1490159171 ) // 246748