Skip to content

Commit 29d0c79

Browse files
committed
Fix deadlock #2: skip state_root in build_merged_header_info (avoids m_work_mutex reentry)
1 parent 2ad0c02 commit 29d0c79

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/c2pool/merged/merged_mining.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -874,8 +874,10 @@ MergedMiningManager::build_merged_header_info() const
874874
info.block_height = static_cast<uint32_t>(snap.height);
875875

876876
// Build PPLNS coinbase for this chain (NO lock held — safe)
877+
LOG_TRACE << "[MM-header] building header for chain " << snap.chain_id;
877878
auto payouts = payout_fn(snap.chain_id, snap.coinbase_value);
878-
if (payouts.empty()) continue;
879+
if (payouts.empty()) { LOG_TRACE << "[MM-header] empty payouts, skip"; continue; }
880+
LOG_TRACE << "[MM-header] got " << payouts.size() << " payouts";
879881

880882
// Build coinbase hex using the same logic as build_multiaddress_block
881883
// (simplified — just need the coinbase hash + tx hashes for merkle)
@@ -887,8 +889,12 @@ MergedMiningManager::build_merged_header_info() const
887889
std::string bits_hex = tmpl.value("bits", std::string("1d00ffff"));
888890

889891
try {
890-
uint256 state_root;
891-
if (state_fn) state_root = state_fn();
892+
LOG_TRACE << "[MM-header] building coinbase hex...";
893+
// NOTE: state_root is NOT fetched here — it would deadlock
894+
// (state_fn → MiningInterface::get_the_state_root → m_work_mutex).
895+
// The state_root in merged coinbase is informational, not consensus.
896+
// Use a zero root; the actual THE commitment is in the LTC coinbase.
897+
uint256 state_root; // zero — avoid deadlock
892898

893899
// Build coinbase, compute merkle root + link using shared helpers
894900
std::string coinbase_hex = build_pplns_coinbase_hex(

0 commit comments

Comments
 (0)