From a25b5c971387dc7636046d999df1868d81cf0a79 Mon Sep 17 00:00:00 2001 From: SChernykh <15806605+SChernykh@users.noreply.github.com> Date: Sat, 11 May 2024 18:58:53 +0200 Subject: [PATCH] Tari: fixed `pow_data` generation --- src/merge_mining_client_tari.cpp | 9 +++++++-- src/params.cpp | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/merge_mining_client_tari.cpp b/src/merge_mining_client_tari.cpp index 506852d..f3bdf88 100644 --- a/src/merge_mining_client_tari.cpp +++ b/src/merge_mining_client_tari.cpp @@ -153,8 +153,12 @@ void MergeMiningClientTari::submit_solution(const BlockTemplate* block_tpl, cons return; } + if (transaction_count > std::numeric_limits::max()) { + return; + } + // Total number of transactions in this block (including the miner tx) - data.append(reinterpret_cast(&transaction_count), 2); + data.append(reinterpret_cast(&transaction_count), sizeof(uint16_t)); // Tx Merkle tree root data.append(reinterpret_cast(hashing_blob + nonce_offset + sizeof(uint32_t)), HASH_SIZE); @@ -198,6 +202,7 @@ void MergeMiningClientTari::submit_solution(const BlockTemplate* block_tpl, cons uint32_t tx_extra_size; p = readVarint(p, e, tx_extra_size); if (!p) return; + const uint8_t* tx_extra_begin = p; p = coinbase_tx; while (offset >= KeccakParams::HASH_DATA_AREA) { @@ -227,7 +232,7 @@ void MergeMiningClientTari::submit_solution(const BlockTemplate* block_tpl, cons // coinbase_tx_extra data.append(reinterpret_cast(&tx_extra_size), sizeof(tx_extra_size)); - data.append(reinterpret_cast(p), tx_extra_size); + data.append(reinterpret_cast(tx_extra_begin), tx_extra_size); // aux_chain_merkle_proof data.append(1, static_cast(merkle_proof.size())); diff --git a/src/params.cpp b/src/params.cpp index d09f6e4..9789b83 100644 --- a/src/params.cpp +++ b/src/params.cpp @@ -235,6 +235,11 @@ bool Params::valid() const return false; } + if (m_mergeMiningHosts.size() > 10) { + LOGERR(1, "Too many merge mining blockchains."); + return false; + } + return true; }