From e0d9b0c18f8fe85cef8f6f86d447d7a6fc4de9ff Mon Sep 17 00:00:00 2001 From: Some Random Crypto Guy Date: Thu, 27 Jun 2024 10:31:43 +0100 Subject: [PATCH] Added debug logging to diagnose the issue with Salvium not mining successfully --- src/base/tools/cryptonote/BlockTemplate.cpp | 166 +++++++++++++++++++- src/base/tools/cryptonote/BlockTemplate.h | 2 + 2 files changed, 160 insertions(+), 8 deletions(-) diff --git a/src/base/tools/cryptonote/BlockTemplate.cpp b/src/base/tools/cryptonote/BlockTemplate.cpp index 310fedf4..ee690cc2 100644 --- a/src/base/tools/cryptonote/BlockTemplate.cpp +++ b/src/base/tools/cryptonote/BlockTemplate.cpp @@ -23,6 +23,7 @@ #include "base/crypto/keccak.h" #include "base/tools/cryptonote/BlobReader.h" #include "base/tools/Cvt.h" +#include "base/io/log/Log.h" void xmrig::BlockTemplate::calculateMinerTxHash(const uint8_t *prefix_begin, const uint8_t *prefix_end, uint8_t *hash) @@ -67,7 +68,7 @@ void xmrig::BlockTemplate::calculateMerkleTreeHash() { m_minerTxMerkleTreeBranch.clear(); - const uint64_t count = m_numHashes + 1; + const uint64_t count = m_numHashes + ((m_coin == Coin::SALVIUM) ? 2 : 1); const uint8_t *h = m_hashes.data(); if (count == 1) { @@ -169,7 +170,7 @@ void xmrig::BlockTemplate::generateHashingBlob(Buffer &out) const out.assign(m_blob.begin(), m_blob.begin() + offset(MINER_TX_PREFIX_OFFSET)); out.insert(out.end(), m_rootHash, m_rootHash + kHashSize); - uint64_t k = m_numHashes + 1; + uint64_t k = m_numHashes + ((m_coin == Coin::SALVIUM) ? 2 : 1); while (k >= 0x80) { out.emplace_back((static_cast(k) & 0x7F) | 0x80); k >>= 7; @@ -250,7 +251,20 @@ bool xmrig::BlockTemplate::parse(bool hashes) ar(m_ephPublicKey, kKeySize); - if (m_coin == Coin::ZEPHYR) { + if (m_coin == Coin::SALVIUM) { + + uint8_t asset_type_len; + ar(asset_type_len); + ar.skip(asset_type_len); + + uint64_t output_unlock_time; + ar(output_unlock_time); + + if (m_outputType == 3) { + ar(m_viewTag); + } + + } else if (m_coin == Coin::ZEPHYR) { if (m_outputType != 2) { return false; } @@ -329,7 +343,21 @@ bool xmrig::BlockTemplate::parse(bool hashes) } } - if (m_coin == Coin::ZEPHYR) { + if (m_coin == Coin::SALVIUM) { + + uint8_t tx_type; + ar(tx_type); + + const char * tx_type_strings[] = {"UNSET", "MINER", "PROTOCOL", "TRANSFER", "CONVERT", "BURN", "STAKE", "RETURN"}; + Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%s") WHITE_BOLD("%s"), "TX Type ", tx_type_strings[tx_type]); + if (tx_type != 1) { + return false; + } + + uint64_t amount_burnt; + ar(amount_burnt); + + } else if (m_coin == Coin::ZEPHYR) { uint64_t pricing_record_height, amount_burnt, amount_minted; ar(pricing_record_height); ar(amount_burnt); @@ -361,19 +389,141 @@ bool xmrig::BlockTemplate::parse(bool hashes) return false; } + if (m_coin == Coin::SALVIUM) { + + // Protocol transaction begin + // Prefix begin + setOffset(PROTOCOL_TX_PREFIX_OFFSET, ar.index()); + + // Parse/skip the protocol_tx + uint64_t protocol_tx_version, protocol_tx_unlock_time, protocol_tx_num_inputs; + ar(protocol_tx_version); + if (protocol_tx_version != 2) { + return false; + } + + ar(protocol_tx_unlock_time); + ar(protocol_tx_num_inputs); + + // must be 1 input + if (protocol_tx_num_inputs != 1) { + return false; + } + + uint8_t protocol_input_type; + ar(protocol_input_type); + + // input type must be txin_gen (0xFF) + if (protocol_input_type != 0xFF) { + return false; + } + + uint64_t protocol_height; + ar(protocol_height); + + // height must match miner_tx + if (protocol_height != m_height) { + return false; + } + + uint64_t protocol_num_outputs; + ar(protocol_num_outputs); + + for (size_t protocol_output_idx=0; protocol_output_idx