Skip to content

Commit 5dea6b0

Browse files
committed
fix(mm_proxy): update reserved_offset after inserting merge mining tag
The merge mining proxy inserts a merge mining tag at the beginning of the Monero coinbase transaction's extra field, which shifts all subsequent data by 35 bytes. However, the `reserved_offset` field in the response was not being updated to reflect this shift. This caused mining pools to have to calculate the correct nonce position themselves instead of using the provided `reserved_offset` value. This fix adjusts `reserved_offset` by adding the merge mining tag size (35 bytes) after modifying the block template.
1 parent abdc3cb commit 5dea6b0

File tree

1 file changed

+11
-0
lines changed
  • applications/minotari_merge_mining_proxy/src/proxy

1 file changed

+11
-0
lines changed

applications/minotari_merge_mining_proxy/src/proxy/inner.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ const LOG_TARGET: &str = "minotari_mm_proxy::proxy::inner";
6767
/// The identifier used to identify the tari aux chain data
6868
const TARI_CHAIN_ID: &str = "xtr";
6969
const BUSY_QUALIFYING: &str = "BusyQualifyingMonerodUrl";
70+
/// Size in bytes of the merge mining tag that is inserted into the Monero coinbase transaction's
71+
/// extra field. When this tag is inserted at the beginning of the extra field, all subsequent
72+
/// data (including the pool nonce reserved area) is shifted by this amount, so the `reserved_offset`
73+
/// must be adjusted accordingly.
74+
const MERGE_MINING_TAG_SIZE: u64 = 35;
7075

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

429440
let tari_difficulty = final_block_template_data.template.tari_difficulty;
430441
let tari_height = final_block_template_data

0 commit comments

Comments
 (0)