Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/c2pool/main_dash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,17 +486,18 @@ int run_node(bool testnet, const std::string& rpc_endpoint,
// same scope). The StratumServer co-owns the work source via shared_ptr.
auto work_source = std::make_shared<dash::stratum::DASHWorkSource>(
node_coin_state, std::move(dashd_fallback), std::move(stratum_submit_fn),
core::stratum::StratumConfig{});
core::stratum::StratumConfig{}, testnet);

if (stratum_port != 0) {
stratum_server = std::make_unique<core::StratumServer>(
ioc, stratum_host, stratum_port, work_source);
if (stratum_server->start()) {
std::cout << "[run] stratum listening on " << stratum_host << ":"
<< stratum_port
<< " (work source: DASHWorkSource 4a/4b skeleton -- X11;"
<< " get_work routes to the dashd-RPC fallback until the"
<< " node-held coin-state is seeded)\n";
<< " (work source: DASHWorkSource 4c/4d -- X11 template"
<< " serving + submit scoring; templates source from the"
<< " embedded coin-state when seeded, else the retained"
<< " dashd-RPC GBT fallback)\n";
} else {
std::cout << "[run] stratum FAILED to bind " << stratum_host << ":"
<< stratum_port << " -- stratum disabled\n";
Expand Down
1 change: 1 addition & 0 deletions src/c2pool/main_ltc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ int main(int argc, char* argv[]) {

// Stratum tuning (configurable via CLI or YAML)
core::StratumConfig stratum_config; // defaults: min=0.0005, max=65536, target=3.0s, vardiff=true
stratum_config.coin_symbol = "LTC"; // runtime coin tag for coin-agnostic core log lines

// Operational tuning (configurable via CLI or YAML)
std::string log_file; // empty = default "debug.log"
Expand Down
12 changes: 10 additions & 2 deletions src/core/stratum_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1322,8 +1322,16 @@ void StratumSession::send_notify_work(bool force_clean, const uint256* frozen_be
auto now = std::chrono::steady_clock::now().time_since_epoch().count();
auto prev = s_last_warn.load();
if (now - prev > 30'000'000'000LL) { // 30 seconds
if (s_last_warn.compare_exchange_strong(prev, now))
LOG_WARNING << "[LTC] Waiting for block template (header sync in progress)...";
if (s_last_warn.compare_exchange_strong(prev, now)) {
// Runtime coin tag from the work-source config — this core is
// coin-agnostic and must never hardcode a coin (issue #732:
// a DASH binary logging "[LTC]" sent the operator diagnosing
// the wrong coin). Neutral fallback when unset.
const std::string& sym =
mining_interface_->get_stratum_config().coin_symbol;
LOG_WARNING << "[" << (sym.empty() ? "Stratum" : sym)
<< "] Waiting for block template (header sync in progress)...";
}
}
auto timer = std::make_shared<boost::asio::steady_timer>(socket_.get_executor());
timer->expires_after(std::chrono::seconds(1));
Expand Down
5 changes: 5 additions & 0 deletions src/core/stratum_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ struct StratumConfig {
// max_stratum_connections (YAML) / --max-stratum-connections (CLI).
// Admission control only — zero wire-byte change for admitted sessions.
size_t max_stratum_connections = 100;
// Runtime coin tag for coin-agnostic core log lines (e.g. the "waiting
// for block template" warning). Set by each coin's work source / main so
// a DASH binary never logs "[LTC]" (issue #732 secondary defect). Empty
// -> the core falls back to the neutral "[Stratum]" tag.
std::string coin_symbol;
};

/// Frozen share-construction fields returned by ref_hash_fn. These
Expand Down
3 changes: 3 additions & 0 deletions src/impl/btc/stratum/work_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ BTCWorkSource::BTCWorkSource(btc::coin::HeaderChain& chain,
// 65536x-inflated wire diff that starves low-rate SHA256d miners of
// acceptable shares. Wire-only; does not touch the share-accept target.
config_.set_difficulty_multiplier = 1.0;
// Runtime coin tag for coin-agnostic core log lines (#732).
if (config_.coin_symbol.empty())
config_.coin_symbol = "BTC";

LOG_INFO << "[BTC-STRATUM] BTCWorkSource constructed"
<< " (testnet=" << is_testnet_
Expand Down
6 changes: 5 additions & 1 deletion src/impl/dash/share.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ struct DashShare : chain::BaseShare<uint256, 16>
uint64_t m_last_txout_nonce{0};
HashLinkType m_hash_link;
MerkleLink m_merkle_link;
BaseScript m_coinbase_payload_outer; // PossiblyNone('', VarStr) — outer coinbase_payload
// Outer coinbase_payload — PossiblyNone('', VarStr) on the wire. The VALUE
// is the oracle's coinbase_payload_data = VarStrType().pack(raw_payload)
// (data.py:277-289), i.e. m_data holds [compactsize(len raw)][raw], NOT the
// bare payload; Share.__init__ appends it verbatim to the hash_link data.
BaseScript m_coinbase_payload_outer;

// Identity hash (computed, not serialized)
uint256 m_hash;
Expand Down
31 changes: 17 additions & 14 deletions src/impl/dash/share_check.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,23 +276,26 @@ inline uint256 share_init_verify(const DashShare& share,
hash_link_data.insert(hash_link_data.end(), p, p + 4);
}
// Append outer coinbase_payload (coinbase_payload_data in Python).
// Oracle data.py:278,346-348: coinbase_payload_data = pack.VarStrType().pack(payload)
// = [compactsize(len)][payload]; check_hash_link appends THAT (or b"" when None).
// BaseScript C2POOL_SERIALIZE_METHODS does READWRITE(m_data) over a byte vector,
// which strips one VarStr layer on read (so m_data holds the RAW payload) and
// re-adds the compactsize prefix on write. Serialize via the stream rather than
// appending m_data raw — the raw append dropped the prefix, diverging gentx_hash
// from the oracle on any non-empty (DIP4 CbTx) payload. PRESERVE the empty branch:
// the oracle appends nothing (b"") when the payload is None/empty, NOT a 0x00.
// Oracle data.py:277-289: the outer contents['coinbase_payload'] VALUE is
// coinbase_payload_data = pack.VarStrType().pack(raw_payload) — i.e. the
// VarStr-PACKED payload ([compactsize(len)][payload]) — and Share.__init__
// (data.py:346-348) appends that value VERBATIM to the check_hash_link
// data (b"" when None). On the wire the PossiblyNone(b'', VarStr) outer
// layer adds one MORE compactsize prefix around the value, so
// DashFormatter's single READWRITE(m_data) strip leaves m_data holding
// exactly the oracle field value: [compactsize(len raw)][raw]. Append it
// RAW. (#412 correctly established that the compactsize prefix belongs in
// this data — but re-serializing m_data as a VarStr added a SECOND prefix
// on top of the one m_data already carries, diverging gentx_hash from the
// oracle on every real DIP4 CbTx share. The share-producer slice pins the
// corrected framing: producer KATs in test_dash_share_producer.cpp,
// updated oracle anchors in test_dash_share_hash_link.cpp.)
// PRESERVE the empty branch: the oracle appends nothing (b"") when the
// payload is None/empty, NOT a 0x00.
{
auto& cpd = share.m_coinbase_payload_outer.m_data;
if (!cpd.empty())
{
PackStream cpd_stream;
cpd_stream << share.m_coinbase_payload_outer; // VarStr-pack: [compactsize][payload]
auto* cp = reinterpret_cast<const unsigned char*>(cpd_stream.data());
hash_link_data.insert(hash_link_data.end(), cp, cp + cpd_stream.size());
}
hash_link_data.insert(hash_link_data.end(), cpd.begin(), cpd.end());
}

auto gentx_before_refhash = compute_gentx_before_refhash();
Expand Down
Loading
Loading