From 3415c00f860b23695cb5cd4d21ac7f23fe7932ed Mon Sep 17 00:00:00 2001 From: SW van Heerden Date: Thu, 12 Sep 2024 15:03:14 +0200 Subject: [PATCH 1/2] WIP on test-randomx_x86 testrandomx --- .../core/src/proof_of_work/randomx_factory.rs | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/base_layer/core/src/proof_of_work/randomx_factory.rs b/base_layer/core/src/proof_of_work/randomx_factory.rs index 4f96871f0f..d3c0731029 100644 --- a/base_layer/core/src/proof_of_work/randomx_factory.rs +++ b/base_layer/core/src/proof_of_work/randomx_factory.rs @@ -43,11 +43,28 @@ impl RandomXVMInstance { ) -> Result { // Note: Memory required per VM in light mode is 256MB + debug!( + target: LOG_TARGET, + "flags: {:?}, cache: {}, dataset: {}", flags, cache.is_some(), dataset.is_some() + ); // Note: RandomXFlag::FULL_MEM and RandomXFlag::LARGE_PAGES are incompatible with // light mode. These are not set by RandomX automatically even in fast mode. - let cache = match cache { - Some(c) => c, - None => RandomXCache::new(flags, key)?, + let (flags, cache) = match cache { + Some(c) => (flags, c), + None => match RandomXCache::new(flags, key) { + Ok(cache) => (flags, cache), + Err(err) => { + warn!( + target: LOG_TARGET, + "Error initializing RandomX cache with flags {:?}. {:?}. Fallback to default flags", flags, err + ); + // This is informed by how RandomX falls back on any cache allocation failure + // https://github.com/xmrig/xmrig/blob/02b2b87bb685ab83b132267aa3c2de0766f16b8b/src/crypto/rx/RxCache.cpp#L88 + let flags = RandomXFlag::FLAG_DEFAULT; + let cache = RandomXCache::new(flags, key)?; + (flags, cache) + }, + }, }; let vm = RandomXVM::new(flags, Some(cache), dataset)?; From a110bca2f721cafba43bcd273a93b47c70252b5b Mon Sep 17 00:00:00 2001 From: SW van Heerden Date: Thu, 12 Sep 2024 15:40:03 +0200 Subject: [PATCH 2/2] remove log --- base_layer/core/src/proof_of_work/randomx_factory.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/base_layer/core/src/proof_of_work/randomx_factory.rs b/base_layer/core/src/proof_of_work/randomx_factory.rs index d3c0731029..72378f6a4d 100644 --- a/base_layer/core/src/proof_of_work/randomx_factory.rs +++ b/base_layer/core/src/proof_of_work/randomx_factory.rs @@ -42,11 +42,6 @@ impl RandomXVMInstance { dataset: Option, ) -> Result { // Note: Memory required per VM in light mode is 256MB - - debug!( - target: LOG_TARGET, - "flags: {:?}, cache: {}, dataset: {}", flags, cache.is_some(), dataset.is_some() - ); // Note: RandomXFlag::FULL_MEM and RandomXFlag::LARGE_PAGES are incompatible with // light mode. These are not set by RandomX automatically even in fast mode. let (flags, cache) = match cache {