From 572e8f4668c312e95b7ed83d53485f4091c67eb9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 12:32:20 +0200 Subject: [PATCH 1/9] test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index a62103f7c..a8e283b3d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3308,7 +3308,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST) ? pindexPrev->GetMedianTimePast() : block.GetBlockTime(); - if (!IsFinalTx(tx, nHeight, nLockTimeCutoff,0)) { + if (!IsFinalTx(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 c70da04f91c70e5745bec10c1b856377e8c83b3a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 12:58:08 +0200 Subject: [PATCH 2/9] Test --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index a8e283b3d..d2daa67d1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -891,8 +891,8 @@ 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 ) - return(false); + //if ( komodo_validate_interest(tx) < 0 ) + // return(false); n = tx.vin.size(); for (j=0; j Date: Wed, 22 Mar 2017 13:02:06 +0200 Subject: [PATCH 3/9] Test --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index d2daa67d1..a8e283b3d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -891,8 +891,8 @@ 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 ) - // return(false); + if ( komodo_validate_interest(tx) < 0 ) + return(false); n = tx.vin.size(); for (j=0; j Date: Wed, 22 Mar 2017 13:28:50 +0200 Subject: [PATCH 4/9] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index a8e283b3d..a62103f7c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3308,7 +3308,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST) ? pindexPrev->GetMedianTimePast() : block.GetBlockTime(); - if (!IsFinalTx(tx, nHeight, nLockTimeCutoff,STANDARD_LOCKTIME_VERIFY_FLAGS)) { + if (!IsFinalTx(tx, nHeight, nLockTimeCutoff,0)) { return state.DoS(10, error("%s: contains a non-final transaction", __func__), REJECT_INVALID, "bad-txns-nonfinal"); } } From 886a58ba8bf8fd62cf79973dedc1916a55ff21fa Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 13:43:43 +0200 Subject: [PATCH 5/9] Test --- src/main.cpp | 60 +++++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index a62103f7c..42ffa2e50 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -706,18 +706,46 @@ bool IsStandardTx(const CTransaction& tx, string& reason) return true; } +int32_t komodo_validate_interest(const CTransaction& tx) +{ + int32_t i,txheight=0; uint32_t prevblocktime=0,locktime; uint64_t value=0; + if ( ASSETCHAINS_SYMBOL[0] == 0 && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD ) + { + locktime = komodo_interest_args(&txheight,&prevblocktime,&value,tx.GetHash(),0); + if ( prevblocktime == 0 ) + { + prevblocktime = chainActive.Tip()->nTime; + fprintf(stderr,"error getting prevblocktime, set to tiptime.%u\n",prevblocktime); + } + if ( (int64_t)tx.nLockTime < prevblocktime-3600 ) + { + if ( tiptime > 1490159171 || (txheight == 0 && prevblocktime >= 1490159171) ) // 246748 + { + static uint32_t counter; + if ( counter++ < 100 ) + fprintf(stderr,"komodo_validate_interest reject.%d locktime %u/%u vs nBlockTime %u prevblocktime.%u\n",txheight,(uint32_t)tx.nLockTime,locktime,(uint32_t)chainActive.Tip()->nTime,prevblocktime); + return(-1); + } else fprintf(stderr,"validateinterest grandfather.%d locktime %u vs nBlockTime %u\n",(int32_t)txheight,tx.nLockTime,(uint32_t)prevblocktime); + } + } + return(0); +} + bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime,int flags) { int32_t i; 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 )//&& (int64_t)tx.nLockTime < nBlockTime-3600 ) { + if ( komodo_validate_interest(tx) < 0 ) + return(false); + /* 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 - } else fprintf(stderr,"IsFinalTx grandfather.%d locktime %u vs nBlockTime %u\n",(int32_t)nBlockHeight,tx.nLockTime,(uint32_t)nBlockTime); + } else fprintf(stderr,"IsFinalTx grandfather.%d locktime %u vs nBlockTime %u\n",(int32_t)nBlockHeight,tx.nLockTime,(uint32_t)nBlockTime);*/ } if ((int64_t)tx.nLockTime < ((int64_t)tx.nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime)) return true; @@ -864,35 +892,13 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in return nSigOps; } -int32_t komodo_validate_interest(const CTransaction& tx) -{ - int32_t i,txheight=0; uint32_t tiptime=0,locktime; uint64_t value=0; - if ( ASSETCHAINS_SYMBOL[0] == 0 && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD ) - { - locktime = komodo_interest_args(&txheight,&tiptime,&value,tx.GetHash(),0); - if ( tiptime == 0 ) - tiptime = chainActive.Tip()->nTime; - if ( (int64_t)tx.nLockTime < tiptime-3600 ) - { - if ( tiptime > 1490159171 || (txheight == 0 && tiptime >= 1490159171) ) // 246748 - { - static uint32_t counter; - if ( counter++ < 100 ) - fprintf(stderr,"komodo_validate_interest reject.%d locktime %u/%u vs nBlockTime %u tiptime.%u\n",txheight,(uint32_t)tx.nLockTime,locktime,(uint32_t)chainActive.Tip()->nTime,tiptime); - return(-1); - } - } - } - return(0); -} - bool CheckTransaction(const CTransaction& tx, CValidationState &state,libzcash::ProofVerifier& verifier) { 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 ) - return(false); + //if ( komodo_validate_interest(tx) < 0 ) + // return(false); n = tx.vin.size(); for (j=0; jGetMedianTimePast() : block.GetBlockTime(); - if (!IsFinalTx(tx, nHeight, nLockTimeCutoff,0)) { + if (!IsFinalTx(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 661daa22580615256ce3e19b6e56aba9866d67c5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 13:45:02 +0200 Subject: [PATCH 6/9] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 42ffa2e50..80e77a733 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -719,7 +719,7 @@ int32_t komodo_validate_interest(const CTransaction& tx) } if ( (int64_t)tx.nLockTime < prevblocktime-3600 ) { - if ( tiptime > 1490159171 || (txheight == 0 && prevblocktime >= 1490159171) ) // 246748 + if ( prevblocktime > 1490159171 || (txheight == 0 && prevblocktime >= 1490159171) ) // 246748 { static uint32_t counter; if ( counter++ < 100 ) From ab22c26ab77cc71811081b5fa2063e833be54ed9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 13:57:23 +0200 Subject: [PATCH 7/9] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 80e77a733..a12d88994 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1158,7 +1158,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa // be mined yet. if (!CheckFinalTx(tx, STANDARD_LOCKTIME_VERIFY_FLAGS)) { - fprintf(stderr,"AcceptToMemoryPool non-final\n"); + fprintf(stderr,"AcceptToMemoryPool reject non-final\n"); return state.DoS(0, false, REJECT_NONSTANDARD, "non-final"); } // is it already in the memory pool? From af484891141de188d52ecc7d43792db4c5bac622 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 14:22:31 +0200 Subject: [PATCH 8/9] Remove prints --- src/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index a12d88994..2233faed8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -714,8 +714,10 @@ int32_t komodo_validate_interest(const CTransaction& tx) locktime = komodo_interest_args(&txheight,&prevblocktime,&value,tx.GetHash(),0); if ( prevblocktime == 0 ) { + static uint32_t counter0; prevblocktime = chainActive.Tip()->nTime; - fprintf(stderr,"error getting prevblocktime, set to tiptime.%u\n",prevblocktime); + if ( counter0++ < 100 ) + fprintf(stderr,"error getting prevblocktime, set to tiptime.%u\n",prevblocktime); } if ( (int64_t)tx.nLockTime < prevblocktime-3600 ) { From a3197ff2e7a4d241843062cba5bb3111256ebeb1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 14:23:45 +0200 Subject: [PATCH 9/9] Synchronize to 60 --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index f53c7086a..ad671896d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -100,7 +100,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, #define ASSETCHAINS_MINHEIGHT 100 #define KOMODO_ELECTION_GAP 2000 -#define ROUNDROBIN_DELAY 59 +#define ROUNDROBIN_DELAY 60 extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; extern char ASSETCHAINS_SYMBOL[16]; extern std::string NOTARY_PUBKEY;