Skip to content

Commit

Permalink
feat: add logging of Monero PoW data to debug merge mining (#3276)
Browse files Browse the repository at this point in the history
Description
---
An intermittent error is being observed where Xmrig submits what it considers a valid PoW solution but the Base Node validation rejects the block with a low (1, 2, 3) difficulty.

Adding two sets of logs to provide more detail on the data used to perform the RandomX hash when verifying a submitting merge mined block. Added a log to the  Merge Mining Proxy to show the full Monero PoW data received from Xmrig and added a log in the Base Node to show the RandomX hash that it produces.

Motivation and Context
---
These logs will help us confirm where the issue is in this disconnect between Xmrig’s calculation and our validation.

How Has This Been Tested?
---
Manually
  • Loading branch information
philipr-za authored Sep 3, 2021
1 parent 864d690 commit b0bf982
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions applications/tari_merge_mining_proxy/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ impl InnerService {

let monero_data = monero_rx::construct_monero_data(monero_block, block_data.monero_seed.clone())?;

debug!(target: LOG_TARGET, "Monero PoW Data: {:?}", monero_data);

let header_mut = block_data.tari_block.header.as_mut().unwrap();
let height = header_mut.height;
header_mut.pow.as_mut().unwrap().pow_data = monero_rx::serialize(&monero_data);
Expand Down
1 change: 1 addition & 0 deletions base_layer/core/src/proof_of_work/monero_rx/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub fn monero_difficulty(header: &BlockHeader, randomx_factory: &RandomXFactory)

fn get_random_x_difficulty(input: &[u8], vm: &RandomXVMInstance) -> Result<(Difficulty, Vec<u8>), MergeMineError> {
let hash = vm.calculate_hash(&input)?;
debug!(target: LOG_TARGET, "RandomX Hash: {:?}", hash);
let difficulty = little_endian_difficulty(&hash);
Ok((difficulty, hash))
}
Expand Down

0 comments on commit b0bf982

Please sign in to comment.