Skip to content

Commit

Permalink
Add DGP debug logging category
Browse files Browse the repository at this point in the history
  • Loading branch information
nibbles83 committed May 23, 2023
1 parent dc59935 commit cb8515d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ const CLogCategoryDesc LogCategories[] =
{BCLog::LEVELDB, "leveldb"},
{BCLog::COINSTAKE, "coinstake"},
{BCLog::HTTPPOLL, "http-poll"},
{BCLog::DGP, "dgp"},
{BCLog::ALL, "1"},
{BCLog::ALL, "all"},
};
Expand Down
1 change: 1 addition & 0 deletions src/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace BCLog {
LEVELDB = (1 << 20),
COINSTAKE = (1 << 21),
HTTPPOLL = (1 << 22),
DGP = (1 << 23),
ALL = ~(uint32_t)0,
};

Expand Down
6 changes: 3 additions & 3 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ bool BlockAssembler::IsRewardToSelf(dev::Address addrWinner, CMutableTransaction
PKHash senderAddress;
txnouttype txType;
if(!ExtractDestination(coinstakeTx->vout[1].scriptPubKey, addressBit, &txType)) {
LogPrintf("IsRewardToSelf: Could not extract sender pubkey from output.\n");
LogPrint(BCLog::DGP, "IsRewardToSelf: Could not extract sender pubkey from output.\n");
return false;
}

Expand All @@ -627,7 +627,7 @@ bool BlockAssembler::IsRewardToSelf(dev::Address addrWinner, CMutableTransaction
// Get convert the govWinner hex to a PK address
std::string hexAddress = HexStr(addrWinner.asBytes());
if (hexAddress.size() != 40) {
LogPrintf("IsRewardToSelf: Invalid pubkeyhash hex size (should be 40 hex characters)\n");
LogPrint(BCLog::DGP, "IsRewardToSelf: Invalid pubkeyhash hex size (should be 40 hex characters)\n");
return false;
}
PKHash raw;
Expand All @@ -639,7 +639,7 @@ bool BlockAssembler::IsRewardToSelf(dev::Address addrWinner, CMutableTransaction
// If these match then the staker is choosing itsself as winning gov.
// In rare cases this causes bad consensus, and should just be avoided.
if (currentAddress == govWinnerStr) {
LogPrintf("IsRewardToSelf: Gov Winner : %s, Staker Address : %s, gov reward abandoned. The winner cannot be the staker.\n", govWinnerStr, currentAddress);
LogPrint(BCLog::DGP, "IsRewardToSelf: Gov Winner : %s, Staker Address : %s, gov reward abandoned. The winner cannot be the staker.\n", govWinnerStr, currentAddress);
return true;
}

Expand Down
10 changes: 7 additions & 3 deletions src/qtum/qtumDGP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ dev::Address QtumDGP::getGovernanceWinner(unsigned int blockHeight){
std::vector<uint64_t> v = getUint64VectorFromDGP(blockHeight, getGovernanceDGP(), ParseHex("e3eece26000000000000000000000000" + HexStr(value.asBytes())));
if (::ChainActive().Tip()->nHeight < v[0] + 1920) {
//Take the registration block and add 48hrs worth of blocks
LogPrintf("Governor immature - Address: %s | Registration Block: %u\n", HexStr(value.asBytes()), v[0] + 1920);
LogPrint(BCLog::DGP,"Governor immature - Address: %s | Registration Block: %u\n", HexStr(value.asBytes()), v[0] + 1920);
value = dev::Address(0x0);
}
}
Expand Down Expand Up @@ -294,11 +294,14 @@ dev::Address QtumDGP::getGovernanceWinner(unsigned int blockHeight){
dgpCollateral == govCollateral &&
height >= govBlockHeight + minMaturity &&
height <= govlastPing + pingInterval) {
LogPrintf("Governor valid - Address: %s | Registration block: %i | Last Rewarded: %i\n", HexStr(value.asBytes()), v[0], v[3]);
LogPrint(BCLog::DGP, "Governor valid - Address: %s | Registration block: %i | Last Rewarded: %i\n", HexStr(value.asBytes()), v[0], v[3]);
return value;
} else {
dev::Address oldValue = value;
LogPrint(BCLog::DGP, "Governor invalid - Address: %s | Registration block: %i | Last Rewarded: %i | Last Ping: %i | Current height: %i\n", HexStr(oldValue.asBytes()), v[0], v[3], v[1], height);
// if winner selection doesn't pass criteria checks then manually try and find an eligible one.
// Get the list of currently active governors

std::vector<dev::Address> governorAddresses = getAddressVectorFromDGP(blockHeight, getGovernanceDGP(), ParseHex("883703c2"));
for(std::vector<uint64_t>::size_type i = 0; i != governorAddresses.size(); i++) {
dev::Address value = dev::Address(governorAddresses[i]);
Expand All @@ -316,7 +319,8 @@ dev::Address QtumDGP::getGovernanceWinner(unsigned int blockHeight){
dgpCollateral == govCollateral &&
height >= govBlockHeight + minMaturity &&
height <= govlastPing + pingInterval) {
LogPrintf("Governor valid - Address: %s | Registration block: %i | Last Rewarded: %i\n", HexStr(value.asBytes()), v[0], v[3]);
LogPrint(BCLog::DGP, "Governor valid - Address: %s | Registration block: %i | Last Rewarded: %i\n", HexStr(value.asBytes()), v[0], v[3]);
LogPrint(BCLog::DGP, "Winner manual mismatch - Original Address: %s | New Address: %s | Current Height: %i\n", HexStr(oldValue.asBytes()), HexStr(value.asBytes()), height);
return value;
}
}
Expand Down

0 comments on commit cb8515d

Please sign in to comment.