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
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
core_test sharechain_test share_test btc_share_test \
test_threading test_weights \
test_header_chain test_mempool test_template_builder \
test_doge_chain test_compact_blocks test_dash_x11_kat test_dash_header_chain test_dash_block_replay test_dash_conformance test_dash_subsidy test_dash_mempool test_dash_simplifiedmns test_dash_quorum test_dash_quorum_root test_dash_mn_state test_dash_embedded_gbt test_dash_smldiff test_dash_p2p_messages test_dash_p2p_connection test_dash_p2p_node test_dash_node_interface test_dash_config test_dash_broadcaster test_dash_broadcaster_full test_dash_share_hash_link test_dash_block_relay test_dash_rpc_request test_dash_rpc_conf test_dash_block_producer test_dash_embedded_relay_e2e test_dash_block_relay_plan test_dash_version_activation_latch test_dash_block_relay_binding test_dash_block_relay_dual_arm test_dash_coinbase_parity test_dash_donation_combined test_dash_g3_assembled test_dash_work_target test_dash_work_job_targets test_dash_stratum_binding test_dash_job_notify_roundtrip test_dash_cb_payee test_dash_stratum_notify_roundtrip test_dash_poolnode_messages test_dash_peer test_dash_share_tracker test_dash_node test_dash_share_messages test_dash_stratum_extranonce_split test_dash_stratum_submit_reassembly test_dash_difficulty_parity test_dash_auto_ratchet test_dash_min_protocol_gate test_dash_work_source test_dash_node_coin_state test_dash_coin_state_maintainer test_dash_node_embedded_wire test_dash_node_reception_wire \
test_doge_chain test_compact_blocks test_dash_x11_kat test_dash_header_chain test_dash_block_replay test_dash_conformance test_dash_subsidy test_dash_mempool test_dash_simplifiedmns test_dash_quorum test_dash_quorum_root test_dash_mn_state test_dash_embedded_gbt test_dash_smldiff test_dash_p2p_messages test_dash_p2p_connection test_dash_p2p_node test_dash_node_interface test_dash_config test_dash_broadcaster test_dash_broadcaster_full test_dash_share_hash_link test_dash_block_relay test_dash_rpc_request test_dash_rpc_conf test_dash_block_producer test_dash_embedded_relay_e2e test_dash_block_relay_plan test_dash_version_activation_latch test_dash_block_relay_binding test_dash_block_relay_dual_arm test_dash_coinbase_parity test_dash_donation_combined test_dash_g3_assembled test_dash_work_target test_dash_work_job_targets test_dash_stratum_binding test_dash_job_notify_roundtrip test_dash_cb_payee test_dash_stratum_notify_roundtrip test_dash_poolnode_messages test_dash_peer test_dash_share_tracker test_dash_node test_dash_share_messages test_dash_stratum_extranonce_split test_dash_stratum_submit_reassembly test_dash_difficulty_parity test_dash_auto_ratchet test_dash_min_protocol_gate test_dash_work_source test_dash_node_coin_state test_dash_coin_state_maintainer test_dash_node_embedded_wire test_dash_node_reception_wire test_dash_get_work \
test_multiaddress_pplns test_pplns_stress \
test_hash_link test_decay_pplns \
test_pplns_consensus \
Expand Down Expand Up @@ -252,7 +252,7 @@ jobs:
test_threading test_weights \
test_header_chain test_mempool test_template_builder \
test_doge_chain test_compact_blocks test_dash_x11_kat \
test_dash_header_chain test_dash_block_replay test_dash_conformance test_dash_subsidy test_dash_mempool test_dash_simplifiedmns test_dash_quorum test_dash_quorum_root test_dash_mn_state test_dash_embedded_gbt test_dash_smldiff test_dash_p2p_messages test_dash_p2p_connection test_dash_p2p_node test_dash_node_interface test_dash_config test_dash_broadcaster test_dash_broadcaster_full test_dash_share_hash_link test_dash_block_relay test_dash_rpc_request test_dash_rpc_conf test_dash_block_producer test_dash_embedded_relay_e2e test_dash_block_relay_plan test_dash_version_activation_latch test_dash_block_relay_binding test_dash_block_relay_dual_arm test_dash_coinbase_parity test_dash_donation_combined test_dash_g3_assembled test_dash_work_target test_dash_work_job_targets test_dash_stratum_binding test_dash_job_notify_roundtrip test_dash_cb_payee test_dash_stratum_notify_roundtrip test_dash_poolnode_messages test_dash_peer test_dash_share_tracker test_dash_node test_dash_share_messages test_dash_stratum_extranonce_split test_dash_stratum_submit_reassembly test_dash_difficulty_parity test_dash_auto_ratchet test_dash_min_protocol_gate test_dash_work_source test_dash_node_coin_state test_dash_coin_state_maintainer test_dash_node_embedded_wire test_dash_node_reception_wire \
test_dash_header_chain test_dash_block_replay test_dash_conformance test_dash_subsidy test_dash_mempool test_dash_simplifiedmns test_dash_quorum test_dash_quorum_root test_dash_mn_state test_dash_embedded_gbt test_dash_smldiff test_dash_p2p_messages test_dash_p2p_connection test_dash_p2p_node test_dash_node_interface test_dash_config test_dash_broadcaster test_dash_broadcaster_full test_dash_share_hash_link test_dash_block_relay test_dash_rpc_request test_dash_rpc_conf test_dash_block_producer test_dash_embedded_relay_e2e test_dash_block_relay_plan test_dash_version_activation_latch test_dash_block_relay_binding test_dash_block_relay_dual_arm test_dash_coinbase_parity test_dash_donation_combined test_dash_g3_assembled test_dash_work_target test_dash_work_job_targets test_dash_stratum_binding test_dash_job_notify_roundtrip test_dash_cb_payee test_dash_stratum_notify_roundtrip test_dash_poolnode_messages test_dash_peer test_dash_share_tracker test_dash_node test_dash_share_messages test_dash_stratum_extranonce_split test_dash_stratum_submit_reassembly test_dash_difficulty_parity test_dash_auto_ratchet test_dash_min_protocol_gate test_dash_work_source test_dash_node_coin_state test_dash_coin_state_maintainer test_dash_node_embedded_wire test_dash_node_reception_wire test_dash_get_work \
test_hash_link test_decay_pplns \
test_pplns_consensus \
test_v36_script_sorting test_v36_cross_impl_refhash \
Expand Down
66 changes: 66 additions & 0 deletions src/impl/dash/stratum/get_work.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
#pragma once

/// Phase C-TEMPLATE step 9 (capstone): the fused dash get_work() consumer.
///
/// Every prior slice landed one HALF of get_work in isolation:
/// * select_dash_work() / NodeCoinState::select_work() (work_source.hpp,
/// node_coin_state.hpp, #672/#673) -- the TEMPLATE source: prefer the
/// locally-assembled embedded template (build_embedded_workdata, oracle
/// parity vs frstrtr/p2pool-dash getwork(), older-than-v35) when the
/// node-held coin-state bundle is populated by the 4-leg reception wire
/// (#693/#694), else the RETAINED dashd getblocktemplate fallback;
/// * assemble_work_job_targets() (work_job_targets.hpp) -- the per-miner
/// JOB-TARGET arithmetic (work.py:368-426).
///
/// Nothing fused them: no production (non-test) caller ever ran
/// NodeCoinState::select_work() to source a template AND assembled the miner
/// job over it -- the two halves were exercised only by their own unit KATs.
/// get_work() is that single miner-facing entry point -- the
/// "DASHWorkSource::get_work()" the stratum headers reference as future work.
///
/// CONTRACT (matches the S8 embedded-arm invariants):
/// * the hot path reads the node-held NodeCoinState -- NO direct dashd poll
/// when the bundle is populated (the embedded arm assembles locally);
/// * dashd_fallback is REQUIRED and is invoked ONLY on a set-gap
/// (unpopulated / invalidated bundle) -- the always-reachable safety path
/// and the [GBT-XCHECK] cross-check, NEVER removed;
/// * the job-target assembly is a pure transform of caller inputs and rides
/// on top of EITHER template source unchanged.
///
/// STRICTLY single-coin: src/impl/dash/ only, no bitcoin_family / src/core
/// reach beyond the shared uint256/DashWorkData types the halves already use.

#include <impl/dash/coin/node_coin_state.hpp> // NodeCoinState, WorkSelection, WorkSource
#include <impl/dash/coin/rpc_data.hpp> // DashWorkData
#include <impl/dash/stratum/work_job_targets.hpp> // assemble_work_job_targets, WorkJobTargets, WorkJobTargetInputs

#include <functional>
#include <utility>

namespace dash::stratum {

/// The miner-facing result of get_work(): which arm sourced the template, the
/// selected block template itself, and the assembled stratum job targets.
struct GetWork {
coin::WorkSource source{coin::WorkSource::DashdFallback};
coin::DashWorkData work;
WorkJobTargets targets;
};

/// Fused get_work(): source the base block template off the node-held
/// coin-state (embedded when populated, retained dashd fallback on a set-gap)
/// and assemble the per-miner job targets over it. dashd_fallback is REQUIRED
/// -- it is the always-reachable safety/cross-check arm and is only invoked
/// when the embedded bundle is unavailable.
inline GetWork get_work(
const coin::NodeCoinState& coin_state,
const std::function<coin::DashWorkData()>& dashd_fallback,
const WorkJobTargetInputs& job_in)
{
coin::WorkSelection sel = coin_state.select_work(dashd_fallback);
WorkJobTargets targets = assemble_work_job_targets(job_in);
return GetWork{ sel.source, std::move(sel.work), targets };
}

} // namespace dash::stratum
11 changes: 11 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,17 @@ if (BUILD_TESTING AND GTest_FOUND)
)
target_link_libraries(test_dash_node_embedded_wire PRIVATE c2pool_payout c2pool_hashrate c2pool_merged_mining c2pool_storage pool) # OBJECT-lib SCC direct-naming (#22/#39)
gtest_add_tests(test_dash_node_embedded_wire "" AUTO)
# get_work() consumer capstone: fuses NodeCoinState::select_work() (embedded
# template source) with assemble_work_job_targets(); same OBJECT-lib SCC.
add_executable(test_dash_get_work test_dash_get_work.cpp)
target_link_libraries(test_dash_get_work PRIVATE
GTest::gtest_main GTest::gtest
dash_x11 core
nlohmann_json::nlohmann_json
${Boost_LIBRARIES}
)
target_link_libraries(test_dash_get_work PRIVATE c2pool_payout c2pool_hashrate c2pool_merged_mining c2pool_storage pool) # OBJECT-lib SCC direct-naming (#22/#39)
gtest_add_tests(test_dash_get_work "" AUTO)

# Reception wire (legs 1-3): interfaces::Node reception Events ->
# CoinStateMaintainer. Proves the wire_*_ingest() subscriptions fold off the
Expand Down
Loading
Loading