Merge pull request #1568 from blackjok3rtt/FSM

various bug fixes
This commit is contained in:
jl777
2019-06-18 04:26:50 -11:00
committed by GitHub
4 changed files with 16 additions and 12 deletions

View File

@@ -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)

View File

@@ -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));
@@ -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 ) {
@@ -1767,7 +1769,7 @@ void komodo_args(char *argv0)
{
int32_t ecode = ccEnablesHeight[i];
int32_t ht = ccEnablesHeight[i+1];
if ( ecode > 256 )
if ( ecode > 255 || ecode < 0 )
fprintf(stderr, "ac_ccactivateht: invalid evalcode.%i must be between 0 and 256.\n", ecode);
else if ( ht > 0 )
{

View File

@@ -222,9 +222,13 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
boost::optional<CTransaction> cheatSpend;
uint256 cbHash;
boost::this_thread::interruption_point(); // exit thread before entering locks.
CBlockIndex* pindexPrev = 0;
{
// 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();
@@ -815,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");
}

View File

@@ -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;