Skip to content
Open
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
11 changes: 11 additions & 0 deletions applications/minotari_merge_mining_proxy/src/proxy/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ const LOG_TARGET: &str = "minotari_mm_proxy::proxy::inner";
/// The identifier used to identify the tari aux chain data
const TARI_CHAIN_ID: &str = "xtr";
const BUSY_QUALIFYING: &str = "BusyQualifyingMonerodUrl";
/// Size in bytes of the merge mining tag that is inserted into the Monero coinbase transaction's
/// extra field. When this tag is inserted at the beginning of the extra field, all subsequent
/// data (including the pool nonce reserved area) is shifted by this amount, so the `reserved_offset`
/// must be adjusted accordingly.
const MERGE_MINING_TAG_SIZE: u64 = 35;
Comment on lines +70 to +74
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While defining MERGE_MINING_TAG_SIZE here with a clear comment is a good improvement, this constant is tightly coupled to the implementation of the merge mining tag creation logic, which resides in the tari_core::proof_of_work::monero_rx module.

To improve maintainability and establish a single source of truth, it would be ideal to define this constant within the monero_rx module and export it for use here. This would prevent potential inconsistencies if the tag structure were to change in the future.

Since modifying tari_core might be out of scope for this PR, this is acceptable for now, but please consider creating a follow-up task to address this.


#[derive(Debug, Clone)]
pub struct InnerService {
Expand Down Expand Up @@ -425,6 +430,12 @@ impl InnerService {
monerod_resp["result"]["blocktemplate_blob"] = final_block_template_data.blocktemplate_blob.clone().into();
monerod_resp["result"]["blockhashing_blob"] = final_block_template_data.blockhashing_blob.clone().into();
monerod_resp["result"]["difficulty"] = final_block_template_data.target_difficulty.as_u64().into();
// Update reserved_offset to account for the merge mining tag inserted at the beginning
// of the coinbase extra field, which shifts all subsequent data including the nonce area.
if let Some(original_offset) = monerod_resp["result"]["reserved_offset"].as_u64() {
monerod_resp["result"]["reserved_offset"] =
(original_offset + MERGE_MINING_TAG_SIZE).into();
}

let tari_difficulty = final_block_template_data.template.tari_difficulty;
let tari_height = final_block_template_data
Expand Down
Loading