12 releases (5 stable)

1.3.2 Nov 22, 2024
1.3.0 Nov 1, 2023
1.1.9 Sep 1, 2021
0.5.0 Jan 22, 2021
0.1.1 Nov 27, 2019

#2 in #random-x

Download history 769/week @ 2024-08-20 911/week @ 2024-08-27 1641/week @ 2024-09-03 1327/week @ 2024-09-10 1480/week @ 2024-09-17 1398/week @ 2024-09-24 1205/week @ 2024-10-01 1943/week @ 2024-10-08 1788/week @ 2024-10-15 1468/week @ 2024-10-22 1139/week @ 2024-10-29 1432/week @ 2024-11-05 1349/week @ 2024-11-12 1689/week @ 2024-11-19 1365/week @ 2024-11-26 1504/week @ 2024-12-03

6,125 downloads per month
Used in 2 crates (via tari_core)

BSD-3-Clause

1.5MB
16K SLoC

C++ 8K SLoC // 0.1% comments Visual Studio Project 2K SLoC GNU Style Assembly 1.5K SLoC // 0.1% comments Rust 1K SLoC // 0.1% comments C 1K SLoC // 0.2% comments Assembly 1K SLoC // 0.2% comments Bitbake 263 SLoC Visual Studio Solution 177 SLoC Shell 71 SLoC // 0.3% comments PowerShell 34 SLoC // 0.5% comments

CI Coverage Status

RandomX-rs

Rust bindings to the RandomX proof-of-work (Pow) system

Build Dependencies

This repo makes use of git submodules.

The first time you compile, or perhaps after a big update after a git pull, you need to update the submodules:

git submodule init
git submodule update

If you see an error like

fatal: Needed a single revision
Unable to find current revision in submodule path 'RandomX'

you might want to see if there is a RandomX folder in the source tree. (On case insensitive systems, like OsX and Windows, it might even be randomx). Deleting this folder and repeating the commands above should resolve the issue.

Mac

Install XCode and then the XCode Command Line Tools with the following command

xcode-select --install

For macOS Mojave additional headers need to be installed, run

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

and follow the prompts

Install Brew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Run the following to install needed bottles

brew install git
brew install cmake

Linux

Run the following to install dependencies

apt-get install git cmake libc++-dev libc++abi-dev

Windows

Install Git

Install CMake

Install Build Tools for Visual Studio 2019

Android

To build using the Android NDK the ANDROID_SDK_ROOT environment variable needs to be set. Other variables are optional as they have defaults. Example build command for ARM64:

ANDROID_SDK_ROOT=/home/user/Android/Sdk \
ANDROID_PLATFORM=android-25 \
ANDROID_CMAKE=/home/user/Android/Sdk/cmake/3.22.1/bin/cmake \
ANDROID_CMAKE_TOOLCHAIN=/home/user/Android/Sdk/ndk/22.1.7171670/build/cmake/android.toolchain.cmake \
cargo build --target=aarch64-linux-android

Troubleshooting

Mac/OSX

If you're experiencing linker issues, or messages like

cstdint:153:8: error: no member named 'int8_t' in the global namespace

then you might have multiple conflicting versions of clang installed.

Try:

  • Does which cc report more than one binary? If so, uninstalling one of the clang compilers might help.
  • Upgrading cmake. brew uninstall cmake && brew install cmake
  • cargo clean

On Apple ARM64 hardware and newer XCode releases, RandomX might fail the randomx-tests.

[83] Hash test 1e (interpreter)               ... PASSED
[84] Hash test 2a (compiler)                  ... Assertion failed: (equalsHex(hash, "639183aae1bf4c9a35884cb46b09cad9175f04efd7684e7262a0ac1c2f0b4e3f")), function operator(), file tests.cpp, line 966.
zsh: abort      ./randomx-tests

or

[88] Hash test 2e (compiler)                  ... PASSED
[89] Cache initialization: SSSE3              ... SKIPPED
[90] Cache initialization: AVX2               ... SKIPPED
[91] Hash batch test                          ... Assertion failed: (equalsHex(hash3, "c36d4ed4191e617309867ed66a443be4075014e2b061bcdaf9ce7b721d2b77a8")), function operator(), file tests.cpp, line 1074.
zsh: abort      ./randomx-tests

Building using an older SDK might help. Find location of current SDKs with xcrun --show-sdk-path, then for example:

export RANDOMX_RS_CMAKE_OSX_SYSROOT="/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk"
cargo build

Quick test with built binaries

find target -name randomx-tests -exec {} \;

Dependencies