much debug such wow
This commit is contained in:
@@ -504,11 +504,13 @@ void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotarie
|
|||||||
|
|
||||||
int32_t hush_validate_chain(uint256 srchash,int32_t notarized_height)
|
int32_t hush_validate_chain(uint256 srchash,int32_t notarized_height)
|
||||||
{
|
{
|
||||||
|
fprintf(stderr,"%s\n", __func__);
|
||||||
static int32_t last_rewind; int32_t rewindtarget; CBlockIndex *pindex; struct hush_state *sp; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN];
|
static int32_t last_rewind; int32_t rewindtarget; CBlockIndex *pindex; struct hush_state *sp; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN];
|
||||||
if ( (sp= hush_stateptr(symbol,dest)) == 0 )
|
if ( (sp= hush_stateptr(symbol,dest)) == 0 )
|
||||||
return(0);
|
return(0);
|
||||||
if ( IsInitialBlockDownload() == 0 && ((pindex= hush_getblockindex(srchash)) == 0 || pindex->GetHeight() != notarized_height) )
|
if ( IsInitialBlockDownload() == 0 && ((pindex= hush_getblockindex(srchash)) == 0 || pindex->GetHeight() != notarized_height) )
|
||||||
{
|
{
|
||||||
|
fprintf(stderr,"%s: Not in IBD, height=%d\n", __func__, pindex->GetHeight() );
|
||||||
if ( sp->NOTARIZED_HEIGHT > 0 && sp->NOTARIZED_HEIGHT < notarized_height )
|
if ( sp->NOTARIZED_HEIGHT > 0 && sp->NOTARIZED_HEIGHT < notarized_height )
|
||||||
rewindtarget = sp->NOTARIZED_HEIGHT - 1;
|
rewindtarget = sp->NOTARIZED_HEIGHT - 1;
|
||||||
else if ( notarized_height > 101 )
|
else if ( notarized_height > 101 )
|
||||||
|
|||||||
18
src/main.cpp
18
src/main.cpp
@@ -2403,7 +2403,9 @@ bool IsInitialBlockDownload()
|
|||||||
{
|
{
|
||||||
LogPrintf("Leaving InitialBlockDownload (latching to false)\n");
|
LogPrintf("Leaving InitialBlockDownload (latching to false)\n");
|
||||||
latchToFalse.store(true, std::memory_order_relaxed);
|
latchToFalse.store(true, std::memory_order_relaxed);
|
||||||
} // else fprintf(stderr,"state.%d ht.%d vs %d, t.%u\n",state,(int32_t)chainActive.Height(),(uint32_t)ptr->GetHeight(),(int32_t)ptr->GetBlockTime());
|
} else {
|
||||||
|
fprintf(stderr,"%s: state.%d ht.%d vs %d, t.%u\n",__func__, state,(int32_t)chainActive.Height(),(uint32_t)ptr->GetHeight(),(int32_t)ptr->GetBlockTime());
|
||||||
|
}
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2446,12 +2448,14 @@ static CBlockIndex *pindexBestForkBase = NULL;
|
|||||||
|
|
||||||
void CheckForkWarningConditions()
|
void CheckForkWarningConditions()
|
||||||
{
|
{
|
||||||
|
fprintf(stderr,"%s checking for IBD\n", __func__);
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
// Before we get past initial download, we cannot reliably alert about forks
|
// Before we get past initial download, we cannot reliably alert about forks
|
||||||
// (we assume we don't get stuck on a fork before finishing our initial sync)
|
// (we assume we don't get stuck on a fork before finishing our initial sync)
|
||||||
if (IsInitialBlockDownload())
|
if (IsInitialBlockDownload())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
fprintf(stderr,"%s not in IBD\n", __func__);
|
||||||
// If our best fork is no longer within 288 blocks (+/- 12 hours if no one mines it)
|
// If our best fork is no longer within 288 blocks (+/- 12 hours if no one mines it)
|
||||||
// of our head, drop it
|
// of our head, drop it
|
||||||
if (pindexBestForkTip && chainActive.Height() - pindexBestForkTip->GetHeight() >= 288)
|
if (pindexBestForkTip && chainActive.Height() - pindexBestForkTip->GetHeight() >= 288)
|
||||||
@@ -2479,9 +2483,7 @@ void CheckForkWarningConditions()
|
|||||||
CAlert::Notify(warning, true);
|
CAlert::Notify(warning, true);
|
||||||
fLargeWorkInvalidChainFound = true;
|
fLargeWorkInvalidChainFound = true;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
fLargeWorkForkFound = false;
|
fLargeWorkForkFound = false;
|
||||||
fLargeWorkInvalidChainFound = false;
|
fLargeWorkInvalidChainFound = false;
|
||||||
}
|
}
|
||||||
@@ -5537,23 +5539,23 @@ bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex
|
|||||||
// NOTE: CheckBlockHeader is called by CheckBlock
|
// NOTE: CheckBlockHeader is called by CheckBlock
|
||||||
if (!ContextualCheckBlockHeader(block, state, pindexPrev))
|
if (!ContextualCheckBlockHeader(block, state, pindexPrev))
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"TestBlockValidity failure A checkPOW.%d\n",fCheckPOW);
|
fprintf(stderr,"%s: failure A checkPOW=%d\n",__func__,fCheckPOW);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int32_t futureblock;
|
int32_t futureblock;
|
||||||
if (!CheckBlock(&futureblock,indexDummy.GetHeight(),0,block, state, verifier, fCheckPOW, fCheckMerkleRoot))
|
if (!CheckBlock(&futureblock,indexDummy.GetHeight(),0,block, state, verifier, fCheckPOW, fCheckMerkleRoot))
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"TestBlockValidity failure B checkPOW.%d\n",fCheckPOW);
|
fprintf(stderr,"%s: failure B checkPOW=%d\n",__func__, fCheckPOW);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!ContextualCheckBlock(0,block, state, pindexPrev))
|
if (!ContextualCheckBlock(0,block, state, pindexPrev))
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"TestBlockValidity failure C checkPOW.%d\n",fCheckPOW);
|
fprintf(stderr,"%s: failure C checkPOW=%d\n",__func__, fCheckPOW);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!ConnectBlock(block, state, &indexDummy, viewNew, true,fCheckPOW))
|
if (!ConnectBlock(block, state, &indexDummy, viewNew, true,fCheckPOW))
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"TestBlockValidity failure D checkPOW.%d\n",fCheckPOW);
|
fprintf(stderr,"%s: failure D checkPOW=%d\n",__func__,fCheckPOW);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
assert(state.IsValid());
|
assert(state.IsValid());
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ bool hush_appendACscriptpub();
|
|||||||
|
|
||||||
CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake)
|
CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake)
|
||||||
{
|
{
|
||||||
|
fprintf(stderr,"%s\n", __func__);
|
||||||
CScript scriptPubKeyIn(_scriptPubKeyIn);
|
CScript scriptPubKeyIn(_scriptPubKeyIn);
|
||||||
|
|
||||||
CPubKey pk;
|
CPubKey pk;
|
||||||
@@ -172,14 +173,14 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
uint64_t deposits,voutsum=0; int32_t isrealtime,hushheight; uint32_t blocktime; const CChainParams& chainparams = Params();
|
uint64_t deposits,voutsum=0; int32_t isrealtime,hushheight; uint32_t blocktime; const CChainParams& chainparams = Params();
|
||||||
bool fNotarizationBlock = false; std::vector<int8_t> NotarizationNotaries;
|
bool fNotarizationBlock = false; std::vector<int8_t> NotarizationNotaries;
|
||||||
|
|
||||||
//fprintf(stderr,"create new block\n");
|
fprintf(stderr,"%s: create new block with pubkey=%s\n", __func__, HexStr(pk).c_str());
|
||||||
// Create new block
|
// Create new block
|
||||||
if ( gpucount < 0 )
|
if ( gpucount < 0 )
|
||||||
gpucount = HUSH_MAXGPUCOUNT;
|
gpucount = HUSH_MAXGPUCOUNT;
|
||||||
std::unique_ptr<CBlockTemplate> pblocktemplate(new CBlockTemplate());
|
std::unique_ptr<CBlockTemplate> pblocktemplate(new CBlockTemplate());
|
||||||
if(!pblocktemplate.get())
|
if(!pblocktemplate.get())
|
||||||
{
|
{
|
||||||
fprintf(stderr,"pblocktemplate.get() failure\n");
|
fprintf(stderr,"%s: pblocktemplate.get() failure\n", __func__);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
CBlock *pblock = &pblocktemplate->block; // pointer for convenience
|
CBlock *pblock = &pblocktemplate->block; // pointer for convenience
|
||||||
@@ -505,8 +506,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
//fprintf(stderr,"fee rate skip\n");
|
//fprintf(stderr,"fee rate skip\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Prioritise by fee once past the priority size or we run out of high-priority
|
// Prioritize by fee once past the priority size or we run out of high-priority transactions
|
||||||
// transactions:
|
|
||||||
if (!fSortedByFee &&
|
if (!fSortedByFee &&
|
||||||
((nBlockSize + nTxSize >= nBlockPrioritySize) || !AllowFree(dPriority)))
|
((nBlockSize + nTxSize >= nBlockPrioritySize) || !AllowFree(dPriority)))
|
||||||
{
|
{
|
||||||
@@ -595,7 +595,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
txNew.vout.resize(1);
|
txNew.vout.resize(1);
|
||||||
txNew.vout[0].scriptPubKey = scriptPubKeyIn;
|
txNew.vout[0].scriptPubKey = scriptPubKeyIn;
|
||||||
txNew.vout[0].nValue = GetBlockSubsidy(nHeight,consensusParams) + nFees;
|
txNew.vout[0].nValue = GetBlockSubsidy(nHeight,consensusParams) + nFees;
|
||||||
fprintf(stderr,"mine ht.%d with %.8f\n",nHeight,(double)txNew.vout[0].nValue/COIN);
|
fprintf(stderr,"%s: mine ht.%d with %.8f\n",__func__,nHeight,(double)txNew.vout[0].nValue/COIN);
|
||||||
txNew.nExpiryHeight = 0;
|
txNew.nExpiryHeight = 0;
|
||||||
if ( ASSETCHAINS_ADAPTIVEPOW <= 0 )
|
if ( ASSETCHAINS_ADAPTIVEPOW <= 0 )
|
||||||
txNew.nLockTime = std::max(pindexPrev->GetMedianTimePast()+1, GetTime());
|
txNew.nLockTime = std::max(pindexPrev->GetMedianTimePast()+1, GetTime());
|
||||||
@@ -741,7 +741,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
else if ( ASSETCHAINS_CC == 0 && pindexPrev != 0 && ASSETCHAINS_STAKED == 0 && (SMART_CHAIN_SYMBOL[0] != 0 || IS_HUSH_NOTARY == 0 || My_notaryid < 0) )
|
else if ( ASSETCHAINS_CC == 0 && pindexPrev != 0 && ASSETCHAINS_STAKED == 0 && (SMART_CHAIN_SYMBOL[0] != 0 || IS_HUSH_NOTARY == 0 || My_notaryid < 0) )
|
||||||
{
|
{
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
//fprintf(stderr,"check validity\n");
|
fprintf(stderr,"%s: check validity\n", __func__);
|
||||||
if ( !TestBlockValidity(state, *pblock, pindexPrev, false, false)) // invokes CC checks
|
if ( !TestBlockValidity(state, *pblock, pindexPrev, false, false)) // invokes CC checks
|
||||||
{
|
{
|
||||||
if ( SMART_CHAIN_SYMBOL[0] == 0 || (SMART_CHAIN_SYMBOL[0] != 0 && !isStake) )
|
if ( SMART_CHAIN_SYMBOL[0] == 0 || (SMART_CHAIN_SYMBOL[0] != 0 && !isStake) )
|
||||||
@@ -749,6 +749,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
LEAVE_CRITICAL_SECTION(cs_main);
|
LEAVE_CRITICAL_SECTION(cs_main);
|
||||||
LEAVE_CRITICAL_SECTION(mempool.cs);
|
LEAVE_CRITICAL_SECTION(mempool.cs);
|
||||||
}
|
}
|
||||||
|
fprintf(stderr,"%s: TestBlockValidity failed!\n", __func__);
|
||||||
//throw std::runtime_error("CreateNewBlock(): TestBlockValidity failed"); // crashes the node, moved to GetBlockTemplate and issue return.
|
//throw std::runtime_error("CreateNewBlock(): TestBlockValidity failed"); // crashes the node, moved to GetBlockTemplate and issue return.
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
@@ -760,7 +761,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
LEAVE_CRITICAL_SECTION(cs_main);
|
LEAVE_CRITICAL_SECTION(cs_main);
|
||||||
LEAVE_CRITICAL_SECTION(mempool.cs);
|
LEAVE_CRITICAL_SECTION(mempool.cs);
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"done new block\n");
|
fprintf(stderr,"%s: done\n", __func__);
|
||||||
return pblocktemplate.release();
|
return pblocktemplate.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -771,6 +772,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
|
|
||||||
void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce)
|
void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce)
|
||||||
{
|
{
|
||||||
|
fprintf(stderr,"RandomXMiner: %s with nExtraNonce=%u\n", __func__, nExtraNonce);
|
||||||
// Update nExtraNonce
|
// Update nExtraNonce
|
||||||
static uint256 hashPrevBlock;
|
static uint256 hashPrevBlock;
|
||||||
if (hashPrevBlock != pblock->hashPrevBlock)
|
if (hashPrevBlock != pblock->hashPrevBlock)
|
||||||
@@ -794,12 +796,14 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int&
|
|||||||
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, int32_t gpucount, bool isStake)
|
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, int32_t gpucount, bool isStake)
|
||||||
{
|
{
|
||||||
CPubKey pubkey; CScript scriptPubKey; uint8_t *script,*ptr; int32_t i,len;
|
CPubKey pubkey; CScript scriptPubKey; uint8_t *script,*ptr; int32_t i,len;
|
||||||
|
fprintf(stderr,"%s: with nHeight=%d\n", __func__, nHeight);
|
||||||
if ( nHeight == 1 && ASSETCHAINS_COMMISSION != 0 && ASSETCHAINS_SCRIPTPUB[ASSETCHAINS_SCRIPTPUB.back()] != 49 && ASSETCHAINS_SCRIPTPUB[ASSETCHAINS_SCRIPTPUB.back()-1] != 51 )
|
if ( nHeight == 1 && ASSETCHAINS_COMMISSION != 0 && ASSETCHAINS_SCRIPTPUB[ASSETCHAINS_SCRIPTPUB.back()] != 49 && ASSETCHAINS_SCRIPTPUB[ASSETCHAINS_SCRIPTPUB.back()-1] != 51 )
|
||||||
{
|
{
|
||||||
if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 )
|
if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 )
|
||||||
{
|
{
|
||||||
pubkey = ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY);
|
pubkey = ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY);
|
||||||
scriptPubKey = CScript() << ParseHex(HexStr(pubkey)) << OP_CHECKSIG;
|
scriptPubKey = CScript() << ParseHex(HexStr(pubkey)) << OP_CHECKSIG;
|
||||||
|
fprintf(stderr,"%s: with pubkey=%s\n", __func__, HexStr(pubkey).c_str() );
|
||||||
} else {
|
} else {
|
||||||
len = strlen(ASSETCHAINS_SCRIPTPUB.c_str());
|
len = strlen(ASSETCHAINS_SCRIPTPUB.c_str());
|
||||||
len >>= 1;
|
len >>= 1;
|
||||||
@@ -823,16 +827,20 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight,
|
|||||||
} else {
|
} else {
|
||||||
// wallet disabled
|
// wallet disabled
|
||||||
CTxDestination dest = DecodeDestination(GetArg("-mineraddress", ""));
|
CTxDestination dest = DecodeDestination(GetArg("-mineraddress", ""));
|
||||||
|
char destaddr[65];
|
||||||
if (IsValidDestination(dest)) {
|
if (IsValidDestination(dest)) {
|
||||||
// CKeyID keyID = boost::get<CKeyID>(dest);
|
// CKeyID keyID = boost::get<CKeyID>(dest);
|
||||||
// scriptPubKey = CScript() << OP_DUP << OP_HASH160 << ToByteVector(keyID) << OP_EQUALVERIFY << OP_CHECKSIG;
|
// scriptPubKey = CScript() << OP_DUP << OP_HASH160 << ToByteVector(keyID) << OP_EQUALVERIFY << OP_CHECKSIG;
|
||||||
scriptPubKey = GetScriptForDestination(dest);
|
scriptPubKey = GetScriptForDestination(dest);
|
||||||
|
Getscriptaddress(destaddr,scriptPubKey);
|
||||||
|
fprintf(stderr,"%s: wallet disabled with mineraddress=%s\n", __func__, destaddr);
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fprintf(stderr,"%s: calling CreateNewBlock\n", __func__);
|
||||||
return CreateNewBlock(pubkey, scriptPubKey, gpucount, isStake);
|
return CreateNewBlock(pubkey, scriptPubKey, gpucount, isStake);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1040,6 +1048,7 @@ void static RandomXMiner()
|
|||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
fprintf(stderr,"RandomXMiner: beginning mining loop on %s with nExtraNonce=%u\n",SMART_CHAIN_SYMBOL, nExtraNonce);
|
||||||
if (chainparams.MiningRequiresPeers()) {
|
if (chainparams.MiningRequiresPeers()) {
|
||||||
//if ( ASSETCHAINS_SEED != 0 && chainActive.LastTip()->GetHeight() < 100 )
|
//if ( ASSETCHAINS_SEED != 0 && chainActive.LastTip()->GetHeight() < 100 )
|
||||||
// break;
|
// break;
|
||||||
@@ -1061,9 +1070,8 @@ void static RandomXMiner()
|
|||||||
//fprintf(stderr,"%s Found peers\n",SMART_CHAIN_SYMBOL);
|
//fprintf(stderr,"%s Found peers\n",SMART_CHAIN_SYMBOL);
|
||||||
miningTimer.start();
|
miningTimer.start();
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// Create new block
|
// Create new block
|
||||||
//
|
|
||||||
unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
|
unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
|
||||||
CBlockIndex* pindexPrev = chainActive.LastTip();
|
CBlockIndex* pindexPrev = chainActive.LastTip();
|
||||||
if ( Mining_height != pindexPrev->GetHeight()+1 )
|
if ( Mining_height != pindexPrev->GetHeight()+1 )
|
||||||
@@ -1071,11 +1079,14 @@ void static RandomXMiner()
|
|||||||
Mining_height = pindexPrev->GetHeight()+1;
|
Mining_height = pindexPrev->GetHeight()+1;
|
||||||
Mining_start = (uint32_t)time(NULL);
|
Mining_start = (uint32_t)time(NULL);
|
||||||
}
|
}
|
||||||
|
fprintf(stderr,"RandomXMiner: Mining_start=%u\n", Mining_start);
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, 0);
|
CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, 0);
|
||||||
#else
|
#else
|
||||||
CBlockTemplate *ptr = CreateNewBlockWithKey();
|
CBlockTemplate *ptr = CreateNewBlockWithKey();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
fprintf(stderr,"RandomXMiner: created new block\n");
|
||||||
if ( ptr == 0 )
|
if ( ptr == 0 )
|
||||||
{
|
{
|
||||||
if ( !GetBoolArg("-gen",false))
|
if ( !GetBoolArg("-gen",false))
|
||||||
@@ -1087,11 +1098,11 @@ void static RandomXMiner()
|
|||||||
}
|
}
|
||||||
static uint32_t counter;
|
static uint32_t counter;
|
||||||
if ( counter++ < 10 && ASSETCHAINS_STAKED == 0 )
|
if ( counter++ < 10 && ASSETCHAINS_STAKED == 0 )
|
||||||
fprintf(stderr,"created illegal blockB, retry\n");
|
fprintf(stderr,"RandomXMiner: created illegal blockB, retry with counter=%u\n", counter);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"get template\n");
|
fprintf(stderr,"RandomXMiner: getting block template\n");
|
||||||
unique_ptr<CBlockTemplate> pblocktemplate(ptr);
|
unique_ptr<CBlockTemplate> pblocktemplate(ptr);
|
||||||
if (!pblocktemplate.get())
|
if (!pblocktemplate.get())
|
||||||
{
|
{
|
||||||
@@ -1133,7 +1144,7 @@ void static RandomXMiner()
|
|||||||
gotinvalid = 0;
|
gotinvalid = 0;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"gotinvalid.%d\n",gotinvalid);
|
fprintf(stderr,"RandomXMiner: gotinvalid=%d\n",gotinvalid);
|
||||||
if ( gotinvalid != 0 )
|
if ( gotinvalid != 0 )
|
||||||
break;
|
break;
|
||||||
hush_longestchain();
|
hush_longestchain();
|
||||||
@@ -1186,13 +1197,14 @@ void static RandomXMiner()
|
|||||||
// This lag is 80 mins for 75s blocktime and 64 mins for 60s (default) blocktime for HSCs
|
// This lag is 80 mins for 75s blocktime and 64 mins for 60s (default) blocktime for HSCs
|
||||||
int randomxBlockLag = 64;
|
int randomxBlockLag = 64;
|
||||||
|
|
||||||
fprintf(stderr,"RandomX using initial key with interval=%d and lag=%d\n", randomxInterval, randomxBlockLag);
|
fprintf(stderr,"RandomXMiner: using initial key with interval=%d and lag=%d\n", randomxInterval, randomxBlockLag);
|
||||||
fprintf(stderr,"RandomXMiner: Mining_height=%u\n", Mining_height);
|
fprintf(stderr,"RandomXMiner: Mining_height=%u\n", Mining_height);
|
||||||
// Use the initial key at the start of the chain
|
// Use the initial key at the start of the chain
|
||||||
if( (Mining_height) < randomxInterval + randomxBlockLag) {
|
if( (Mining_height) < randomxInterval + randomxBlockLag) {
|
||||||
randomx_init_cache(randomxCache, &randomxKey, sizeof randomxKey);
|
randomx_init_cache(randomxCache, &randomxKey, sizeof randomxKey);
|
||||||
fprintf(stderr,"RandomXMiner: initialized cache with initial key\n");
|
fprintf(stderr,"RandomXMiner: initialized cache with initial key\n");
|
||||||
} else {
|
} else {
|
||||||
|
fprintf(stderr,"RandomXMiner: calculating keyHeight with randomxInterval=%d\n", randomxInterval);
|
||||||
// At heights between intervals, we use the same block key and wait randomxBlockLag blocks until changing
|
// At heights between intervals, we use the same block key and wait randomxBlockLag blocks until changing
|
||||||
int keyHeight = ((Mining_height - randomxBlockLag) / randomxInterval) * randomxInterval;
|
int keyHeight = ((Mining_height - randomxBlockLag) / randomxInterval) * randomxInterval;
|
||||||
fprintf(stderr,"RandomXMiner: key height=%d\n", keyHeight);
|
fprintf(stderr,"RandomXMiner: key height=%d\n", keyHeight);
|
||||||
@@ -1202,12 +1214,12 @@ void static RandomXMiner()
|
|||||||
crypto_generichash_blake2b_final(&state, randomxInput, 32);
|
crypto_generichash_blake2b_final(&state, randomxInput, 32);
|
||||||
|
|
||||||
randomx_init_cache(randomxCache, &randomxBlockKey, sizeof randomxKey);
|
randomx_init_cache(randomxCache, &randomxBlockKey, sizeof randomxKey);
|
||||||
fprintf(stderr,"RandomXMiner: initialized cache\n");
|
fprintf(stderr,"RandomXMiner: initialized cache with randomxBlockKey=%s\n", randomxBlockKey.ToString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
randomx_vm *myVM = randomx_create_vm(flags, randomxCache, NULL);
|
randomx_vm *myVM = randomx_create_vm(flags, randomxCache, NULL);
|
||||||
if(myVM == NULL) {
|
if(myVM == NULL) {
|
||||||
LogPrintf("Cannot create RandomX VM, aborting!\n");
|
fprintf(stderr,"RandomXMiner: Cannot create RandomX VM, aborting!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fprintf(stderr,"RandomXMiner: created VM\n");
|
fprintf(stderr,"RandomXMiner: created VM\n");
|
||||||
@@ -1303,7 +1315,7 @@ void static RandomXMiner()
|
|||||||
// because they become invalid as we created a new block in blockchain.
|
// because they become invalid as we created a new block in blockchain.
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"HushRandomXMiner: solution not found, validBlock=false\n");
|
fprintf(stderr,"RandomXMiner: solution not found, validBlock=false\n");
|
||||||
}
|
}
|
||||||
} catch (RandomXSolverCanceledException&) {
|
} catch (RandomXSolverCanceledException&) {
|
||||||
LogPrintf("HushRandomXMiner solver canceled\n");
|
LogPrintf("HushRandomXMiner solver canceled\n");
|
||||||
@@ -1331,19 +1343,15 @@ void static RandomXMiner()
|
|||||||
pblock->nBits = savebits;
|
pblock->nBits = savebits;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (const boost::thread_interrupted&) {
|
||||||
catch (const boost::thread_interrupted&)
|
|
||||||
{
|
|
||||||
miningTimer.stop();
|
miningTimer.stop();
|
||||||
c.disconnect();
|
c.disconnect();
|
||||||
LogPrintf("HushRandomXMiner terminated\n");
|
LogPrintf("HushRandomXMiner terminated\n");
|
||||||
throw;
|
throw;
|
||||||
}
|
} catch (const std::runtime_error &e) {
|
||||||
catch (const std::runtime_error &e)
|
|
||||||
{
|
|
||||||
miningTimer.stop();
|
miningTimer.stop();
|
||||||
c.disconnect();
|
c.disconnect();
|
||||||
LogPrintf("HushRandomXMiner runtime error: %s\n", e.what());
|
fprintf(stderr,"RandomXMiner: runtime error: %s\n", e.what());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
miningTimer.stop();
|
miningTimer.stop();
|
||||||
|
|||||||
Reference in New Issue
Block a user