Skip to content

Commit a013f4d

Browse files
committed
P2Pool-style block-found logs + fix self-banning on localhost:0
Block-found notifications now match p2pool format: ### PARENT NETWORK BLOCK FOUND! ### Network: Litecoin (tLTC) Height: 16001 Block hash: 05ae9008... Status: ACCEPTED ### MERGED BLOCK FOUND! DOGE ### Chain: DOGE (chain_id=2) Height: 23059 Aux hash: 90f7bfb5... Fix: skip banning localhost:0 (port==0) peers — these are our own locally created shares that can fail GENTX verification during chain growth. This is a timing race, not a protocol error.
1 parent a71ebad commit a013f4d

3 files changed

Lines changed: 24 additions & 10 deletions

File tree

src/c2pool/c2pool_refactored.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,8 @@ int main(int argc, char* argv[]) {
12581258
// When a block submission is attempted, broadcast bestblock to all P2P peers
12591259
// and record the found block for the /recent_blocks REST endpoint.
12601260
// stale_info: 0=accepted, 253=orphan (stale prev), 254=doa (daemon rejected)
1261-
web_server.set_on_block_submitted([&p2p_node, &web_server, &ioc, &node_rpc, embedded_ltc](const std::string& header_hex, int stale_info) {
1261+
bool is_testnet = settings->m_testnet;
1262+
web_server.set_on_block_submitted([&p2p_node, &web_server, &ioc, &node_rpc, embedded_ltc, is_testnet](const std::string& header_hex, int stale_info) {
12621263
if (header_hex.size() < 160) return;
12631264
// Parse the 80-byte Bitcoin wire-format block header
12641265
auto hb = [&](int i) -> uint8_t {
@@ -1304,13 +1305,16 @@ int main(int argc, char* argv[]) {
13041305
height = tmpl["height"].get<uint64_t>();
13051306
web_server.get_mining_interface()->record_found_block(height, block_hash);
13061307

1307-
const char* stale_str = (stale_info == 253) ? " [ORPHAN]"
1308-
: (stale_info == 254) ? " [DOA]"
1308+
const char* stale_str = (stale_info == 253) ? " [ORPHAN — stale prev]"
1309+
: (stale_info == 254) ? " [DOA — daemon rejected]"
13091310
: "";
1310-
LOG_INFO << "Block found! height=" << height
1311-
<< " hash=" << block_hash.GetHex()
1312-
<< stale_str
1313-
<< " — broadcast bestblock to P2P peers";
1311+
LOG_INFO << "\n"
1312+
<< " ### PARENT NETWORK BLOCK FOUND! ###\n"
1313+
<< " Network: Litecoin (" << (is_testnet ? "tLTC" : "LTC") << ")\n"
1314+
<< " Height: " << height << "\n"
1315+
<< " Block hash: " << block_hash.GetHex() << "\n"
1316+
<< " Status: " << (stale_info == 0 ? "ACCEPTED" : stale_str) << "\n"
1317+
<< " Broadcast: bestblock sent to P2P peers";
13141318

13151319
// Schedule post-submission orphan check at +30s and +120s (RPC mode only)
13161320
if (stale_info == 0 && !embedded_ltc)

src/c2pool/merged/merged_mining.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ bool AuxChainRPC::submit_aux_block(const uint256& block_hash, const std::string&
426426
{
427427
try {
428428
call("submitauxblock", nlohmann::json::array({block_hash.GetHex(), auxpow_hex}));
429-
LOG_INFO << "[MM:" << m_config.symbol << "] Aux block submitted successfully!";
429+
LOG_INFO << "[MM:" << m_config.symbol << "] Aux block ACCEPTED by daemon!";
430430
return true;
431431
} catch (const std::exception& e) {
432432
LOG_WARNING << "[MM:" << m_config.symbol << "] submitauxblock failed: " << e.what();
@@ -662,7 +662,13 @@ void MergedMiningManager::try_submit_merged_blocks(
662662
continue; // doesn't meet this chain's target
663663
}
664664

665-
LOG_INFO << "[MM:" << chain.config.symbol << "] Parent PoW meets aux target! Submitting merged block...";
665+
LOG_INFO << "\n"
666+
<< " ### MERGED BLOCK FOUND! " << chain.config.symbol << " ###\n"
667+
<< " Chain: " << chain.config.symbol << " (chain_id=" << chain.config.chain_id << ")\n"
668+
<< " Height: " << chain.current_work.height << "\n"
669+
<< " Aux hash: " << chain.current_work.block_hash.GetHex().substr(0, 32) << "...\n"
670+
<< " Aux target: " << chain.current_work.target.GetHex().substr(0, 32) << "...\n"
671+
<< " Parent PoW: " << parent_hash.GetHex().substr(0, 32) << "...";
666672

667673
// Build aux merkle proof for this chain's slot
668674
auto proof = m_tree.compute_root(slot_hashes, slot);

src/impl/ltc/node.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,9 +717,13 @@ void NodeImpl::run_think()
717717
trim_chain(m_tracker.verified, "verified", /*owns_data=*/false);
718718
trim_chain(m_tracker.chain, "chain");
719719

720-
// Ban peers that provided invalid/unverifiable shares
720+
// Ban peers that provided invalid/unverifiable shares.
721+
// Skip localhost:0 — that's our own locally created shares
722+
// which can fail GENTX during chain growth (timing race, not a bug).
721723
auto now = std::chrono::steady_clock::now();
722724
for (const auto& bad_addr : result.bad_peer_addresses) {
725+
if (bad_addr.port() == 0)
726+
continue; // local share — don't ban ourselves
723727
LOG_WARNING << "run_think: banning peer " << bad_addr.to_string()
724728
<< " for unverifiable shares";
725729
m_ban_list[bad_addr] = now + m_ban_duration;

0 commit comments

Comments
 (0)