RandomX 설명: 모네로를 탈중앙화로 유지하는 마이닝 알고리즘
Introduction: Mining and the Centralization Problem
The security of any proof-of-work cryptocurrency depends on who controls the mining power. When mining becomes dominated by specialized hardware manufacturers and large-scale operations, the network centralizes around a few powerful entities. This centralization threatens the censorship resistance and trustlessness that make cryptocurrencies valuable in the first place. Monero recognized this threat early and took decisive action with the introduction of RandomX, a mining algorithm specifically designed to keep mining accessible to ordinary computer users.
RandomX represents one of the most innovative approaches to proof-of-work mining in the cryptocurrency space. By designing an algorithm that runs optimally on general-purpose CPUs, Monero ensures that anyone with a standard computer can participate meaningfully in securing the network. This article provides a comprehensive technical explanation of how RandomX works and why it matters for the future of decentralized mining.
The Problem with CryptoNight
Before RandomX, Monero used the CryptoNight family of mining algorithms. CryptoNight was originally designed to be ASIC-resistant by requiring a large amount of fast memory (a scratchpad) that would be expensive to implement in custom hardware. For several years, this approach worked well, and Monero mining remained dominated by CPUs and GPUs.
However, the economics of cryptocurrency mining create powerful incentives for hardware specialization. By 2018, companies like Bitmain had developed ASIC miners for CryptoNight that were orders of magnitude more efficient than consumer hardware. These ASICs threatened to centralize Monero mining in the hands of a few manufacturers and their customers, undermining the network's decentralization goals.
The Monero development team responded by modifying CryptoNight every six months through hard forks, each time breaking compatibility with existing ASICs. While effective in the short term, this approach was unsustainable. Each fork required coordination across the entire ecosystem, and ASIC manufacturers were getting faster at producing new designs. A more permanent solution was needed.
How RandomX Works
The Core Concept: Random Program Execution
RandomX takes a fundamentally different approach to ASIC resistance. Instead of relying on memory hardness alone, it generates and executes random programs for each mining attempt. These programs use the full range of CPU capabilities including integer arithmetic, floating-point operations, branching, and memory access patterns. Because the programs are different for every hash, any hardware that mines RandomX efficiently must essentially be a general-purpose CPU.
The algorithm works in several stages. First, a random program is generated from the block header data using a deterministic process. This program consists of a sequence of instructions drawn from a carefully designed instruction set. The program is then compiled and executed, with its output feeding into the next stage of the hash calculation. This process repeats for multiple iterations, with each iteration generating a new random program based on the results of the previous one.
The RandomX Virtual Machine
At the heart of RandomX is a custom virtual machine (VM) designed to mirror the capabilities of modern CPU architectures. The VM includes eight integer registers and twelve floating-point registers, a scratchpad memory of approximately 2 MB (sized to fit in typical CPU L3 cache), and an instruction set of around 30 operations covering arithmetic, logical, floating-point, and memory operations.
The VM's design is crucial to RandomX's ASIC resistance. By requiring both integer and floating-point arithmetic with full IEEE 754 compliance, the algorithm forces any efficient implementation to include the full complement of arithmetic units found in a modern CPU. The random branching patterns prevent the pipelining optimizations that ASICs typically exploit, and the memory access patterns are designed to utilize the CPU cache hierarchy efficiently while penalizing simpler memory architectures.
Dataset and Cache
RandomX uses a large dataset (approximately 2 GB) that is regenerated every 2048 blocks, roughly every 2.8 days. This dataset is derived from the blockchain data using the AES hash function and serves as a read-only lookup table during mining. The dataset is too large to store in on-chip memory, requiring miners to either store it in RAM or regenerate portions on the fly.
For miners, the full dataset is stored in memory and accessed randomly during program execution. For validators who only need to verify blocks rather than mine them, a smaller cache (256 MB) can be used to regenerate dataset entries on demand. This asymmetry means that verification is much less resource-intensive than mining, which is an important property for maintaining a healthy network of full nodes.
Superscalar Hash Function
RandomX includes a custom superscalar hash function that generates portions of the dataset. This function is specifically designed to be efficient on out-of-order CPUs with multiple execution units. It creates chains of dependent instructions that benefit from the instruction-level parallelism found in modern CPU cores but would not benefit from the simpler execution models used in ASICs or GPUs.
Why RandomX Favors CPUs
CPUs vs GPUs
GPUs excel at executing the same instruction across thousands of data elements simultaneously, a paradigm known as SIMD (Single Instruction, Multiple Data). RandomX's random programs include unpredictable branches and varied instruction sequences that are fundamentally incompatible with this execution model. Each mining thread needs to execute a different random program, and these programs include conditional branches that cause threads to diverge, destroying GPU efficiency.
Additionally, RandomX's floating-point operations require full IEEE 754 compliance with specific rounding modes. While GPUs support floating-point arithmetic, their implementations often take shortcuts for performance that produce different results than CPUs. RandomX exploits these differences to ensure that GPU implementations must either sacrifice performance for correctness or produce invalid results.
In practice, GPUs achieve roughly one-quarter to one-third the performance per watt compared to CPUs on RandomX. This inverts the typical relationship seen with other mining algorithms, where GPUs often outperform CPUs by ten times or more.
CPUs vs ASICs
The economic case for building a RandomX ASIC is weak because any efficient RandomX ASIC would essentially be a general-purpose CPU. The algorithm requires a large cache hierarchy, out-of-order execution, branch prediction, full floating-point units, and a complex memory controller. These are exactly the components that make up a modern CPU, and CPU manufacturers like AMD and Intel have spent decades and billions of dollars optimizing them.
Any ASIC designer attempting to beat commodity CPUs at RandomX would need to replicate most of this functionality while somehow doing it more efficiently than companies with vastly more resources and experience. The expected performance advantage of a RandomX ASIC over a modern CPU is estimated at 2x to 5x at best, compared to the 1000x or greater advantage that Bitcoin ASICs have over CPUs on SHA-256. This marginal advantage is unlikely to justify the hundreds of millions of dollars in development costs.
The 2019 Hard Fork
RandomX was activated on the Monero network on November 30, 2019, at block height 1978433. The hard fork was the culmination of over a year of development, testing, and community discussion. The algorithm was developed primarily by tevador, hyc, vielmetti, and SChernykh, with extensive review and auditing by the broader community and professional security auditors.
Prior to activation, RandomX underwent a four-month audit by Trail of Bits, QuarksLab, Kudelski Security, and X41 D-Sec. These audits identified and resolved several issues, and the final algorithm incorporated all recommended fixes. The thoroughness of this review process set a high standard for cryptocurrency algorithm changes.
The impact of the switch was immediate. GPU mining profitability on Monero dropped dramatically, and the network hash rate initially decreased as GPU miners left. However, CPU mining participation surged, and the hash rate recovered within weeks. The geographic and demographic distribution of miners became significantly more diverse as anyone with a modern CPU could now participate profitably.
CPU Benchmarks and Performance
RandomX performance varies significantly across CPU architectures, with AMD Ryzen processors generally leading due to their large L3 cache sizes. A Ryzen 9 5950X with 16 cores achieves approximately 16,000 hashes per second (H/s), while a Ryzen 7 5800X with 8 cores reaches roughly 8,500 H/s. Intel processors perform well but typically trail AMD equivalents. A Core i9-12900K achieves around 10,500 H/s, and a Core i7-12700 reaches approximately 7,200 H/s.
Server-class processors like the AMD EPYC 7763 with 64 cores can achieve over 40,000 H/s, making them attractive for larger mining operations. However, the key insight is that consumer-grade hardware remains competitive on a per-dollar basis. A used Ryzen desktop costing a few hundred dollars can mine Monero profitably in many electricity markets, maintaining the accessibility that RandomX was designed to provide.
Newer generation processors continue to improve RandomX performance. The AMD Ryzen 7000 and 9000 series show improvements of 10 to 20 percent over their predecessors, primarily through higher clock speeds and improved cache architectures. This ongoing improvement through commodity hardware advancement is exactly the dynamic RandomX was designed to create.
RandomX vs Bitcoin's SHA-256
The contrast between RandomX and Bitcoin's SHA-256 illustrates two fundamentally different philosophies about mining hardware. SHA-256 is a simple, deterministic hash function that performs the same operations every time. This predictability makes it trivially easy to implement in specialized hardware, and modern Bitcoin ASICs are billions of times more efficient than CPUs at computing SHA-256 hashes.
As a result, Bitcoin mining is dominated by a handful of ASIC manufacturers and large-scale mining farms located in regions with the cheapest electricity. The barrier to entry for meaningful Bitcoin mining is now measured in millions of dollars. Individual miners cannot compete, and the network's security depends on a relatively small number of entities.
RandomX deliberately sacrifices raw hashing efficiency to maintain hardware diversity and mining accessibility. While a purpose-built RandomX miner might be two to five times more efficient than a consumer CPU, this margin is too small to justify the investment in custom hardware development. The result is a mining ecosystem where anyone with a standard computer can participate, and no single hardware manufacturer can dominate the network.
The Future of RandomX
RandomX has proven remarkably successful since its 2019 introduction. No commercially viable ASIC has been produced for the algorithm, and CPU mining remains the dominant approach. The algorithm's design principles have influenced other cryptocurrency projects seeking ASIC resistance, and it is widely regarded as one of the most effective anti-ASIC mining algorithms ever deployed.
The Monero community continues to monitor for potential threats to RandomX's ASIC resistance. If advances in custom hardware design ever produce a viable RandomX ASIC, the algorithm can be updated through a hard fork. However, the fundamental economics of RandomX, that any efficient implementation must essentially be a general-purpose CPU, suggest that this scenario is unlikely in the foreseeable future.
Conclusion
RandomX represents a thoughtful and effective solution to one of cryptocurrency's most persistent challenges: maintaining mining decentralization in the face of powerful economic incentives toward specialization. By designing an algorithm that leverages the full capabilities of modern CPUs, Monero ensures that securing the network remains accessible to individuals around the world, not just well-funded mining operations.
At MoneroSwapper, we value Monero's commitment to decentralization as much as its commitment to privacy. RandomX is a critical component of that commitment, ensuring that the network remains resilient, censorship-resistant, and truly owned by its community of users and miners.
🌍 다른 언어로 읽기