Skip to content

Commit e450df9

Browse files
committed
Fix DOGE P2P: protocol version 70015 in getheaders + diagnostics
CoinBroadcaster::request_headers() hardcoded 70017 (LTC) for all chains. DOGE requires 70015 — dogecoind ignores getheaders with wrong version, causing embedded header sync to stall permanently. Added diagnostic logging throughout DOGE pipeline: - Full block receipt + UTXO connection (every block) - Mempool tx arrival with txid - Mempool cleanup per block - Fee revalidation results - Template builder output (height, subsidy, fees, txs) - BIP 35 clarification (DOGE uses inv/tx, not mempool msg)
1 parent a5f17c4 commit e450df9

3 files changed

Lines changed: 49 additions & 7 deletions

File tree

src/c2pool/c2pool_refactored.cpp

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3618,8 +3618,11 @@ int main(int argc, char* argv[]) {
36183618
ltc::coin::MutableTransaction mtx(tx);
36193619
bool added = pool->add_tx(mtx, utxo);
36203620
if (added) {
3621-
LOG_DEBUG_COIND << "[DOGE] TX from " << peer_key
3622-
<< " added to mempool (size=" << pool->size() << ")";
3621+
auto txid = ltc::coin::compute_txid(mtx);
3622+
LOG_INFO << "[EMB-DOGE] Mempool: tx=" << txid.GetHex().substr(0, 16)
3623+
<< " from=" << peer_key
3624+
<< " size=" << pool->size()
3625+
<< " fee=" << (pool->contains(txid) ? "pending" : "?");
36233626
}
36243627
});
36253628
LOG_INFO << "DOGE mempool wired via P2P broadcaster";
@@ -3713,6 +3716,11 @@ int main(int argc, char* argv[]) {
37133716
if (entry) height = entry->height;
37143717
else { auto prev = chain->get_header(block.m_previous_block); if (prev) height = prev->height + 1; }
37153718
}
3719+
LOG_INFO << "[EMB-DOGE] Full block received: height=" << height
3720+
<< " hash=" << block_hash.GetHex().substr(0, 16) << "..."
3721+
<< " txs=" << block.m_txs.size()
3722+
<< " from=" << peer;
3723+
37163724
// UTXO connect (before mempool cleanup)
37173725
if (utxo && utxo_db) {
37183726
// DOGE: txid = hash of full serialization (no witness stripping)
@@ -3722,13 +3730,21 @@ int main(int argc, char* argv[]) {
37223730
auto undo = utxo->connect_block(block, height, txid_fn);
37233731
utxo_db->put_block_undo(height, undo);
37243732
utxo->flush(block_hash, height);
3725-
3726-
// Enable BIP 35 mempool sync after first block
3733+
LOG_INFO << "[EMB-DOGE] UTXO: connected block " << height
3734+
<< " hash=" << block_hash.GetHex().substr(0, 16)
3735+
<< " txs=" << block.m_txs.size()
3736+
<< " cache=" << utxo->cache_size();
3737+
3738+
// Enable mempool tx relay after first block.
3739+
// DOGE does NOT support BIP 35 (mempool msg) or
3740+
// wtxidrelay (BIP 339). Txs arrive via standard inv/tx.
3741+
// enable_mempool_request() enables inv processing;
3742+
// the BIP 35 mempool msg is only sent if peer has NODE_BLOOM.
37273743
static bool doge_mempool_requested = false;
37283744
if (!doge_mempool_requested && bcaster_ptr) {
37293745
bcaster_ptr->enable_mempool_request();
37303746
doge_mempool_requested = true;
3731-
LOG_INFO << "[EMB-DOGE] UTXO ready — enabled BIP 35 mempool sync";
3747+
LOG_INFO << "[EMB-DOGE] UTXO ready — mempool tx relay active (inv/tx, no BIP 35)";
37323748
// Bootstrap: seed UTXO with coinbase_maturity blocks
37333749
if (chain && utxo_db->get_best_height() <= height) {
37343750
int req = 0;
@@ -3741,12 +3757,22 @@ int main(int argc, char* argv[]) {
37413757
}
37423758
}
37433759
if (pool) {
3760+
auto before = pool->size();
37443761
pool->set_tip_height(height);
37453762
pool->remove_for_block(block);
3763+
auto after = pool->size();
3764+
if (before != after) {
3765+
LOG_INFO << "[EMB-DOGE] Mempool: removed " << (before - after)
3766+
<< " txs for block " << height
3767+
<< " (remaining=" << after << ")";
3768+
}
37463769
if (utxo) {
37473770
int resolved = pool->recompute_unknown_fees(utxo);
3748-
if (resolved > 0)
3771+
if (resolved > 0) {
3772+
LOG_INFO << "[EMB-DOGE] Fee revalidation: resolved=" << resolved
3773+
<< " pool_size=" << after;
37493774
web_server.trigger_work_refresh_debounced();
3775+
}
37503776
}
37513777
}
37523778
});

src/c2pool/merged/coin_broadcaster.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ class CoinBroadcaster
302302
int sent = 0;
303303
for (auto& [key, peer] : m_peers) {
304304
try {
305-
peer->node_p2p.send_getheaders(70017, locator, stop_hash);
305+
// DOGE uses protocol 70015, LTC uses 70017
306+
uint32_t proto = (m_symbol == "DOGE" || m_symbol == "doge") ? 70015 : 70017;
307+
peer->node_p2p.send_getheaders(proto, locator, stop_hash);
306308
++sent;
307309
} catch (const std::exception& e) {
308310
LOG_WARNING << "[" << m_symbol << "] getheaders to "

src/impl/doge/coin/template_builder.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include "header_chain.hpp" // DOGE HeaderChain (uses DOGEChainParams)
1010
#include "chain_params.hpp" // get_doge_block_subsidy(), calculate_doge_next_work()
1111

12+
#include <core/log.hpp>
13+
1214
// Reuse LTC's generic components (Mempool, block format, RPC data, merkle)
1315
#include <impl/ltc/coin/mempool.hpp>
1416
#include <impl/ltc/coin/rpc_data.hpp>
@@ -133,6 +135,18 @@ class TemplateBuilder {
133135
data["weightlimit"] = 4'000'000;
134136
data["mintime"] = static_cast<int64_t>(tip.header.m_timestamp + 1);
135137

138+
LOG_INFO << "[EMB-DOGE] TemplateBuilder: height=" << next_h
139+
<< " version=0x" << std::hex << block_version << std::dec
140+
<< " prev=" << tip.block_hash.GetHex().substr(0, 16) << "..."
141+
<< " bits=" << bits_to_hex(next_bits)
142+
<< " subsidy=" << subsidy
143+
<< " fees=" << total_fees
144+
<< " coinbasevalue=" << coinbasevalue << " sat"
145+
<< " txs=" << selected_txs.size()
146+
<< " tip_ts=" << tip.header.m_timestamp
147+
<< " now=" << now_ts
148+
<< " synced=" << (chain.is_synced() ? "true" : "false");
149+
136150
return ltc::coin::rpc::WorkData{std::move(data), std::move(tx_objects), std::move(tx_hashes), 0};
137151
}
138152
};

0 commit comments

Comments
 (0)