Monero’s RandomX Proof‑of‑Work Explained
Outline how RandomX builds a 2 GiB dataset from a 256 MiB cache using Argon2d, then runs 8 chained VM programs to produce a 256‑bit hash.
Check the RandomX reference README for dataset size and mode details.
Summary
Monero’s proof‑of‑work algorithm, RandomX, replaces the fixed SHA‑256 hash of Bitcoin with a memory‑hard, CPU‑intensive process that resists ASIC mining. The algorithm begins by deriving a 256 MiB cache from a key block hash using Argon2d, which is then expanded into a 2 GiB dataset that forces ~16 384 memory accesses per hash, ensuring heavy DRAM traffic. For each nonce, RandomX seeds a 2 MiB scratchpad with Blake2b(H) and generates a 256‑instruction VM program from random 8‑byte words; the program runs 2048 iterations, reading ~504 bytes and writing ~256 bytes per iteration while occasionally taking a low‑probability branch. To prevent pre‑selection of easy work, RandomX chains eight such programs, passing the final state of one as the seed for the next, and finally hashes the combined state with AES and Blake2b to produce a 256‑bit output. The reference implementation offers a fast mode that uses the full 2 GiB dataset for mining and a light mode that uses only the 256 MiB cache for verification, keeping verification cost reasonable while still deterring ASICs. The design deliberately includes branching (~1/256 chance) and floating‑point operations to keep the workload similar to general‑purpose CPU tasks. RandomX’s memory‑hardness and dynamic code generation make it difficult for specialized hardware to outperform general CPUs, aligning with Monero’s goal of keeping mining decentralised. The algorithm’s parameters, such as key‑block rotation every 2048 blocks and the 64‑block delay, are specified in the reference README and are critical for maintaining network security.
Key changes
- RandomX uses a 256 MiB cache derived from Argon2d on a key block, expanded into a 2 GiB dataset.
- The dataset is read‑only and forces ~16 384 memory accesses per hash, targeting DRAM.
- Each hash uses a 2 MiB scratchpad seeded by Blake2b(H), split into L1/L2/L3 cache sizes.
- RandomX generates 256‑instruction VM programs from random 8‑byte words, executed 2048 times per program.
- Eight chained programs per hash, with each program’s final state feeding the next, preventing pre‑selection.
- Final state is hashed via AES fingerprint + Blake2b to produce a 256‑bit output.
- Fast mode uses full 2 GiB dataset; light mode uses only 256 MiB cache for verification.
- The design intentionally includes low‑probability branches (~1/256) to hinder ASIC optimization.