Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: randomX on mac x86 #6559

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions base_layer/core/src/proof_of_work/randomx_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,24 @@ impl RandomXVMInstance {
dataset: Option<RandomXDataset>,
) -> Result<Self, RandomXVMFactoryError> {
// Note: Memory required per VM in light mode is 256MB

// 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)?;

Expand Down
Loading