From 64b0d9562eded654a5eed7159737d5c9b6ca266b Mon Sep 17 00:00:00 2001 From: SChernykh Date: Sat, 21 Jan 2023 16:02:47 +0100 Subject: [PATCH] Fixed broken RandomX light mode mining RandomX VMs didn't get updated properly in light mode. --- src/backend/cpu/CpuWorker.cpp | 6 ++++++ src/backend/cpu/CpuWorker.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/backend/cpu/CpuWorker.cpp b/src/backend/cpu/CpuWorker.cpp index 3eb6e4683..d0047e4b7 100644 --- a/src/backend/cpu/CpuWorker.cpp +++ b/src/backend/cpu/CpuWorker.cpp @@ -33,6 +33,7 @@ #include "crypto/common/Nonce.h" #include "crypto/common/VirtualMemory.h" #include "crypto/rx/Rx.h" +#include "crypto/rx/RxCache.h" #include "crypto/rx/RxDataset.h" #include "crypto/rx/RxVm.h" #include "crypto/ghostrider/ghostrider.h" @@ -145,6 +146,11 @@ void xmrig::CpuWorker::allocateRandomX_VM() uint8_t* scratchpad = m_memory->isHugePages() ? m_memory->scratchpad() : dataset->tryAllocateScrathpad(); m_vm = RxVm::create(dataset, scratchpad ? scratchpad : m_memory->scratchpad(), !m_hwAES, m_assembly, node()); } + else if (!dataset->get() && (m_job.currentJob().seed() != m_seed)) { + // Update RandomX light VM with the new seed + randomx_vm_set_cache(m_vm, dataset->cache()->get()); + } + m_seed = m_job.currentJob().seed(); } #endif diff --git a/src/backend/cpu/CpuWorker.h b/src/backend/cpu/CpuWorker.h index 5fc06fd3e..18e4fed5c 100644 --- a/src/backend/cpu/CpuWorker.h +++ b/src/backend/cpu/CpuWorker.h @@ -97,6 +97,7 @@ private: # ifdef XMRIG_ALGO_RANDOMX randomx_vm *m_vm = nullptr; + Buffer m_seed; # endif # ifdef XMRIG_ALGO_GHOSTRIDER