Merge branch 'mxhess:main' into main

This commit is contained in:
tiamak
2025-11-17 00:56:35 +01:00
committed by GitHub
2 changed files with 54 additions and 30 deletions

View File

@@ -279,13 +279,24 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, const
m_blockHeaderSize = m_blockHeader.size();
m_poolBlockTemplate->m_minerWallet = in_donation_mode ? params->m_devWallet : params->m_miningWallet;
m_poolBlockTemplate->m_minerWallet = params->m_miningWallet;
if (!m_sidechain->fill_sidechain_data(*m_poolBlockTemplate, m_shares)) {
use_old_template();
return;
}
// Whole-block donation: replace all miner shares with single dev wallet output
if (in_donation_mode && !m_shares.empty()) {
difficulty_type total_weight;
for (const auto& share : m_shares) {
total_weight += share.m_weight;
}
m_shares.clear();
m_shares.emplace_back(total_weight, &params->m_devWallet);
LOGINFO(4, "Donation mode: entire block reward goes to dev wallet");
}
// Pre-calculate outputs to speed up miner tx generation
if (!m_shares.empty()) {
struct Precalc
@@ -634,7 +645,7 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, const
m_poolBlockTemplate->m_transactions.push_back(m_mempoolTxs[m_mempoolTxsOrder[i]].id);
}
m_poolBlockTemplate->m_minerWallet = in_donation_mode ? params->m_devWallet : params->m_miningWallet;
m_poolBlockTemplate->m_minerWallet = params->m_miningWallet;
// Layout: [software id, version, random number, sidechain extra_nonce]
uint32_t* sidechain_extra = m_poolBlockTemplate->m_sidechainExtraBuf;
@@ -769,6 +780,17 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, const
calc_merkle_tree_main_branch();
// DEBUG: Log block template structure
LOGINFO(0, "DEBUG P2POOL TEMPLATE (" << m_blockTemplateBlob.size() << " bytes)");
std::string hex;
hex.reserve(400);
for (size_t i = 0; i < std::min<size_t>(200, m_blockTemplateBlob.size()); ++i) {
char buf[3];
snprintf(buf, 3, "%02x", m_blockTemplateBlob[i]);
hex += buf;
}
LOGINFO(0, "P2POOL FIRST 200 BYTES: " << hex);
LOGINFO(3, "final reward = " << log::Gray() << log::XMRAmount(final_reward) << log::NoColor() <<
", weight = " << log::Gray() << final_weight << log::NoColor() <<
", outputs = " << log::Gray() << m_poolBlockTemplate->m_outputAmounts.size() << log::NoColor() <<
@@ -931,8 +953,9 @@ int BlockTemplate::create_miner_tx(const MinerData& data, const std::vector<Mine
// Miner transaction (coinbase)
m_minerTx.clear();
const size_t num_outputs = shares.size();
m_minerTx.reserve(num_outputs * 39 + 55);
const size_t num_outputs = shares.size();
LOGINFO(0, "DEBUG: Creating miner_tx with " << num_outputs << " outputs from " << num_outputs << " unique miners");
m_minerTx.reserve(num_outputs * 39 + 55);
// tx version
m_minerTx.push_back(TX_VERSION);

View File

@@ -1139,32 +1139,33 @@ void p2pool::submit_block() const
bool is_external = false;
if (submit_data.blob.empty()) {
submit_data.blob = m_blockTemplate->get_block_template_blob(submit_data.template_id, submit_data.extra_nonce, nonce_offset, extra_nonce_offset, merkle_root_offset, merge_mining_root, &block_tpl);
LOGINFO(0, log::LightGreen() << "submit_block: height = " << height
<< ", template id = " << submit_data.template_id
<< ", nonce = " << submit_data.nonce
<< ", extra_nonce = " << submit_data.extra_nonce
<< ", mm_root = " << merge_mining_root);
if (submit_data.blob.empty()) {
LOGERR(0, "submit_block: couldn't find block template with id " << submit_data.template_id);
return;
}
}
else {
LOGINFO(0, log::LightGreen() << "submit_block: height = " << height << ", external blob (" << submit_data.blob.size() << " bytes)");
std::string hex;
hex.reserve(submit_data.blob.size() * 2);
for (size_t i = 0; i < std::min<size_t>(submit_data.blob.size(), 400); ++i) {
char buf[3];
snprintf(buf, sizeof(buf), "%02x", submit_data.blob[i]);
hex.append(buf);
}
LOGINFO(0, "BLOB HEX (first 400 bytes): " << hex);
is_external = true;
}
if (submit_data.blob.empty()) {
submit_data.blob = m_blockTemplate->get_block_template_blob(submit_data.template_id, submit_data.extra_nonce, nonce_offset, extra_nonce_offset, merkle_root_offset, merge_mining_root, &block_tpl);
LOGINFO(0, log::LightGreen() << "submit_block: height = " << height
<< ", template id = " << submit_data.template_id
<< ", nonce = " << submit_data.nonce
<< ", extra_nonce = " << submit_data.extra_nonce
<< ", mm_root = " << merge_mining_root);
// DEBUG: Log what we're submitting
std::string hex;
hex.reserve(submit_data.blob.size() * 2);
for (size_t i = 0; i < submit_data.blob.size(); ++i) {
char buf[3];
snprintf(buf, sizeof(buf), "%02x", submit_data.blob[i]);
hex.append(buf);
}
LOGINFO(0, "DEBUG BLOCK BLOB: " << hex);
if (submit_data.blob.empty()) {
LOGERR(0, "submit_block: couldn't find block template with id " << submit_data.template_id);
return;
}
}
else {
LOGINFO(0, log::LightGreen() << "submit_block: height = " << height << ", external blob");
is_external = true;
}
std::string request;
request.reserve(submit_data.blob.size() * 2 + 128);