Skip to content

Conversation

@HashVault
Copy link

Description

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.

Motivation and Context

Mining pools that use the reserved_offset value from the proxy response were receiving an incorrect offset (e.g., 131) when the actual position in the modified blob was different (e.g., 166). This forced pools to calculate the correct position themselves by searching for the nonce pattern in the blob.

How Has This Been Tested?

Empirical testing the offset mismatch: daemon reported 131, actual position was 166, difference = 35 bytes.

What process can a PR reviewer use to test or verify this change?

  1. Start the merge mining proxy
  2. Request a block template via getblocktemplate RPC
  3. Verify that reserved_offset in the response equals the original monerod reserved_offset + 35

Breaking Changes

  • None
  • Requires data directory on base node to be deleted
  • Requires hard fork
  • Other - Please specify

@github-actions
Copy link

⚠️ This PR contains unsigned commits. To get your PR merged, please sign those commits (git rebase --exec 'git commit -S --amend --no-edit -n' @{upstream}) and force push them to this branch (git push --force-with-lease).

If you're new to commit signing, there are different ways to set it up:

Sign commits with gpg

Follow the steps below to set up commit signing with gpg:

  1. Generate a GPG key
  2. Add the GPG key to your GitHub account
  3. Configure git to use your GPG key for commit signing
Sign commits with ssh-agent

Follow the steps below to set up commit signing with ssh-agent:

  1. Generate an SSH key and add it to ssh-agent
  2. Add the SSH key to your GitHub account
  3. Configure git to use your SSH key for commit signing
Sign commits with 1Password

You can also sign commits using 1Password, which lets you sign commits with biometrics without the signing key leaving the local 1Password process.

Learn how to use 1Password to sign your commits.

Watch the demo

@gemini-code-assist
Copy link

Summary of Changes

Hello @HashVault, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an inaccuracy in the merge mining proxy's block template response. Previously, when the proxy inserted a 35-byte merge mining tag into the Monero coinbase transaction's extra field, it failed to update the reserved_offset accordingly. This led to mining pools receiving an incorrect offset for the nonce, forcing them to manually calculate the correct position. The change ensures that the reserved_offset is correctly incremented by 35 bytes, providing accurate information to mining pools and streamlining their operations.

Highlights

  • Introduced MERGE_MINING_TAG_SIZE constant: A new constant MERGE_MINING_TAG_SIZE set to 35 bytes has been added to define the size of the merge mining tag.
  • Corrected reserved_offset calculation: The reserved_offset in the Monero block template response is now adjusted by adding MERGE_MINING_TAG_SIZE to its original value, ensuring it accurately reflects the nonce position after the merge mining tag insertion.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly addresses an issue where the reserved_offset was not updated after the merge mining tag was inserted into the Monero coinbase transaction. The fix introduces a constant for the tag size and adds it to the original offset, which is the right approach. My review includes one suggestion for future improvement regarding the location of the new constant to enhance long-term maintainability by colocating it with the related logic in the tari_core crate.

Comment on lines +70 to +74
/// 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;

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.

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.
@HashVault HashVault force-pushed the fix/merge-mining-proxy-reserved-offset branch from 3d10fc1 to 5dea6b0 Compare January 17, 2026 18:28
@HashVault HashVault marked this pull request as ready for review January 17, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant