From c8d9bc5653070253fe051973212d18680dc7adb2 Mon Sep 17 00:00:00 2001 From: Some Random Crypto Guy Date: Wed, 26 Jun 2024 22:30:43 +0100 Subject: [PATCH 1/4] initial import of Salvium-specific details for Coin and WalletAddress information --- src/base/crypto/Coin.cpp | 1 + src/base/crypto/Coin.h | 1 + src/base/tools/cryptonote/WalletAddress.cpp | 12 ++++++++++++ 3 files changed, 14 insertions(+) diff --git a/src/base/crypto/Coin.cpp b/src/base/crypto/Coin.cpp index c528acec..6b0dac67 100644 --- a/src/base/crypto/Coin.cpp +++ b/src/base/crypto/Coin.cpp @@ -55,6 +55,7 @@ static const CoinInfo coinInfo[] = { { Algorithm::RX_WOW, "WOW", "Wownero", 300, 100000000000, MAGENTA_BG_BOLD(WHITE_BOLD_S " wownero ") }, { Algorithm::RX_0, "ZEPH", "Zephyr", 120, 1000000000000, BLUE_BG_BOLD( WHITE_BOLD_S " zephyr ") }, { Algorithm::RX_0, "Townforge","Townforge", 30, 100000000, MAGENTA_BG_BOLD(WHITE_BOLD_S " townforge ") }, + { Algorithm::RX_0, "SAL", "Salvium", 120, 100000000, BLUE_BG_BOLD( WHITE_BOLD_S " salvium ") }, }; diff --git a/src/base/crypto/Coin.h b/src/base/crypto/Coin.h index 12ac1497..8d8546a3 100644 --- a/src/base/crypto/Coin.h +++ b/src/base/crypto/Coin.h @@ -41,6 +41,7 @@ public: WOWNERO, ZEPHYR, TOWNFORGE, + SALVIUM, MAX }; diff --git a/src/base/tools/cryptonote/WalletAddress.cpp b/src/base/tools/cryptonote/WalletAddress.cpp index 3719031a..a66acbe1 100644 --- a/src/base/tools/cryptonote/WalletAddress.cpp +++ b/src/base/tools/cryptonote/WalletAddress.cpp @@ -261,6 +261,18 @@ const xmrig::WalletAddress::TagInfo &xmrig::WalletAddress::tagInfo(uint64_t tag) { 0x424220, { Coin::TOWNFORGE, STAGENET, PUBLIC, 38881, 38882 } }, { 0x424221, { Coin::TOWNFORGE, STAGENET, SUBADDRESS, 38881, 38882 } }, + { 0x3ef318, { Coin::SALVIUM, MAINNET, PUBLIC, 19081, 19082 } }, + { 0x55ef318, { Coin::SALVIUM, MAINNET, INTEGRATED, 19081, 19082 } }, + { 0xf5ef318, { Coin::SALVIUM, MAINNET, SUBADDRESS, 19081, 19082 } }, + + { 0x15beb318, { Coin::SALVIUM, TESTNET, PUBLIC, 29081, 29082 } }, + { 0xd055eb318, { Coin::SALVIUM, TESTNET, INTEGRATED, 29081, 29082 } }, + { 0xa59eb318, { Coin::SALVIUM, TESTNET, SUBADDRESS, 29081, 29082 } }, + + { 0x149eb318, { Coin::SALVIUM, STAGENET, PUBLIC, 39081, 39082 } }, + { 0xf343eb318, { Coin::SALVIUM, STAGENET, INTEGRATED, 39081, 39082 } }, + { 0x2d47eb318, { Coin::SALVIUM, STAGENET, SUBADDRESS, 39081, 39082 } }, + }; const auto it = tags.find(tag); 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 2/4] 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 Date: Thu, 27 Jun 2024 12:33:10 +0100 Subject: [PATCH 3/4] removed debug logging as no longer needed --- src/base/tools/cryptonote/BlockTemplate.cpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/base/tools/cryptonote/BlockTemplate.cpp b/src/base/tools/cryptonote/BlockTemplate.cpp index ee690cc2..84c4becf 100644 --- a/src/base/tools/cryptonote/BlockTemplate.cpp +++ b/src/base/tools/cryptonote/BlockTemplate.cpp @@ -23,7 +23,6 @@ #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) @@ -348,8 +347,6 @@ bool xmrig::BlockTemplate::parse(bool hashes) 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; } @@ -464,15 +461,6 @@ bool xmrig::BlockTemplate::parse(bool hashes) return false; } - const char * tx_type_strings[] = {"UNSET", "MINER", "PROTOCOL", "TRANSFER", "CONVERT", "BURN", "STAKE", "RETURN"}; - Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%s") WHITE_BOLD("%d"), "Protocol TX Version ", protocol_tx_version); - Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%s") WHITE_BOLD("%d"), "Protocol TX Unlock Time ", protocol_tx_unlock_time); - Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%s") WHITE_BOLD("%d"), "Protocol TX Num Inputs ", protocol_tx_num_inputs); - Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%s") WHITE_BOLD("%d"), "Protocol TX Input Type ", protocol_input_type); - Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%s") WHITE_BOLD("%d"), "Protocol TX Num Outputs ", protocol_num_outputs); - Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%s") WHITE_BOLD("%d"), "Protocol TX Extra Size ", protocol_extra_size); - Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%s") WHITE_BOLD("%s"), "Protocol TX Type ", tx_type_strings[protocol_tx_type]); - setOffset(PROTOCOL_TX_PREFIX_END_OFFSET, ar.index()); // Prefix end @@ -497,8 +485,6 @@ bool xmrig::BlockTemplate::parse(bool hashes) // Other transaction hashes ar(m_numHashes); - Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%s") WHITE_BOLD("%d"), "Num TX hashes ", m_numHashes); - if (hashes) { if (m_coin == Coin::SALVIUM) { From 303f15d6bd5775612ff71bd0604e2fdf1e30234f Mon Sep 17 00:00:00 2001 From: Some Random Crypto Guy Date: Sat, 29 Jun 2024 17:03:23 +0100 Subject: [PATCH 4/4] fixed parsing of protocol_tx outputs --- src/base/tools/cryptonote/BlockTemplate.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/base/tools/cryptonote/BlockTemplate.cpp b/src/base/tools/cryptonote/BlockTemplate.cpp index 84c4becf..c56c2987 100644 --- a/src/base/tools/cryptonote/BlockTemplate.cpp +++ b/src/base/tools/cryptonote/BlockTemplate.cpp @@ -427,6 +427,10 @@ bool xmrig::BlockTemplate::parse(bool hashes) ar(protocol_num_outputs); for (size_t protocol_output_idx=0; protocol_output_idx