From 3c41ff9a17ffec36f88fe407ac4a840c820dee6b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 14 Jun 2019 01:08:07 +0800 Subject: [PATCH 1/7] fix oracles crash? --- src/cc/oracles.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/cc/oracles.cpp b/src/cc/oracles.cpp index 193f66a1a..2a89fe536 100644 --- a/src/cc/oracles.cpp +++ b/src/cc/oracles.cpp @@ -638,11 +638,7 @@ bool OraclesDataValidate(struct CCcontract_info *cp,Eval* eval,const CTransactio int32_t GetLatestTimestamp(int32_t height) { - uint256 blockHash; CBlock block; CBlockIndex* pindex; - - blockHash = chainActive[height]->GetBlockHash(); - pindex = mapBlockIndex[blockHash]; - return(pindex->nTime); + return(komodo_heightstamp(height)); } bool OraclesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) From 0d7c2f33fc80edf3419bf89b445483e23416c332 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 14 Jun 2019 01:16:59 +0800 Subject: [PATCH 2/7] try fix for chickenpool --- src/miner.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/miner.cpp b/src/miner.cpp index 9976909fa..312ee0a52 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -225,6 +225,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 CBlockIndex* pindexPrev = 0; { + boost::this_thread::interruption_point(); // exit thread before entering locks. ENTER_CRITICAL_SECTION(cs_main); ENTER_CRITICAL_SECTION(mempool.cs); pindexPrev = chainActive.LastTip(); From f2645aed1ba5f92a121bced412ea5cb22b1260ed Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 14 Jun 2019 01:53:17 +0800 Subject: [PATCH 3/7] better fix --- src/miner.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 312ee0a52..8ff4e2023 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -222,10 +222,13 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 boost::optional cheatSpend; uint256 cbHash; - + + boost::this_thread::interruption_point(); // exit thread before entering locks. + CBlockIndex* pindexPrev = 0; { - boost::this_thread::interruption_point(); // exit thread before entering locks. + // this should stop create block ever exiting until it has returned something. + boost::this_thread::disable_interruption(); ENTER_CRITICAL_SECTION(cs_main); ENTER_CRITICAL_SECTION(mempool.cs); pindexPrev = chainActive.LastTip(); From 288074439ae078a991753f966915be0851636c35 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 14 Jun 2019 02:54:14 +0800 Subject: [PATCH 4/7] fix settting IS_KOMODO_NOTARY --- src/komodo_utils.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 94ac60515..6f8b1c59a 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1717,15 +1717,17 @@ void komodo_args(char *argv0) // I think on season change should reccomend notaries to use -notary to avoid needing this. int32_t kmd_season = getacseason(time(NULL)); for (i=0; i<64; i++) - if ( strcmp(NOTARY_PUBKEY.c_str(),notaries_elected[kmd_season][NUM_KMD_NOTARIES][1]) == 0 ) + { + if ( strcmp(NOTARY_PUBKEY.c_str(),notaries_elected[kmd_season-1][i][1]) == 0 ) { IS_KOMODO_NOTARY = 1; KOMODO_MININGTHREADS = 1; mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS); IS_STAKED_NOTARY = -1; - fprintf(stderr,"running as notary.%d %s\n",i,notaries_elected[kmd_season][NUM_KMD_NOTARIES][0]); + fprintf(stderr,"running as notary.%d %s\n",i,notaries_elected[kmd_season-1][i][0]); break; } + } } } if ( IS_STAKED_NOTARY != -1 && IS_KOMODO_NOTARY == true ) { From ba20fdc252795aa5866de4a694a68876e42884cb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 18 Jun 2019 21:15:23 +0800 Subject: [PATCH 5/7] fix non determinate acccactivateht bug --- src/komodo_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 6f8b1c59a..09f7fb6a0 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1692,7 +1692,7 @@ int8_t equihash_params_possible(uint64_t n, uint64_t k) void komodo_args(char *argv0) { - std::string name,addn,hexstr,symbol; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[32756],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz=0,baseid,len,n,extralen = 0; uint64_t ccenables[256], ccEnablesHeight[512]; + std::string name,addn,hexstr,symbol; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[32756],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz=0,baseid,len,n,extralen = 0; uint64_t ccenables[256], ccEnablesHeight[512] = {0}; IS_KOMODO_NOTARY = GetBoolArg("-notary", false); IS_STAKED_NOTARY = GetArg("-stakednotary", -1); memset(ccenables,0,sizeof(ccenables)); @@ -1769,7 +1769,7 @@ void komodo_args(char *argv0) { int32_t ecode = ccEnablesHeight[i]; int32_t ht = ccEnablesHeight[i+1]; - if ( ecode > 256 ) + if ( ecode > 256 || ecode < 0 ) fprintf(stderr, "ac_ccactivateht: invalid evalcode.%i must be between 0 and 256.\n", ecode); else if ( ht > 0 ) { From eca62bb4f39fd697db8d35487e95035a503f1fcd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 18 Jun 2019 21:49:56 +0800 Subject: [PATCH 6/7] fix crash/lockup on KMD with mining pools when an old utxo makes IsFinalTx fail in TestBlockValidity. --- src/miner.cpp | 3 ++- src/rpc/mining.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 8ff4e2023..e4e907447 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -819,7 +819,8 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 LEAVE_CRITICAL_SECTION(cs_main); LEAVE_CRITICAL_SECTION(mempool.cs); } - throw std::runtime_error("CreateNewBlock(): TestBlockValidity failed"); + //throw std::runtime_error("CreateNewBlock(): TestBlockValidity failed"); // crashes the node, moved to GetBlockTemplate and issue return. + return(0); } //fprintf(stderr,"valid\n"); } diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 53a744497..4814d34dd 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -745,7 +745,8 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) #endif ENTER_CRITICAL_SECTION(cs_main); if (!pblocktemplate) - throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory or no available utxo for staking"); + throw std::runtime_error("CreateNewBlock(): create block failed"); + //throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory or no available utxo for staking"); // Need to update only after we know CreateNewBlockWithKey succeeded pindexPrev = pindexPrevNew; From 42c0630807e34b015e53d806d6cdba2be57e0b4b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 18 Jun 2019 22:28:45 +0800 Subject: [PATCH 7/7] fix eval code --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 09f7fb6a0..d1a84d53c 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1769,7 +1769,7 @@ void komodo_args(char *argv0) { int32_t ecode = ccEnablesHeight[i]; int32_t ht = ccEnablesHeight[i+1]; - if ( ecode > 256 || ecode < 0 ) + if ( ecode > 255 || ecode < 0 ) fprintf(stderr, "ac_ccactivateht: invalid evalcode.%i must be between 0 and 256.\n", ecode); else if ( ht > 0 ) {