Proof-of-Work Algorithm Thuật toán Proof-of-Work
A CPU-optimized Proof-of-Work algorithm that resists ASIC mining through random program execution, ensuring decentralized and fair cryptocurrency mining. Thuật toán Proof-of-Work tối ưu cho CPU, kháng khai thác ASIC thông qua việc thực thi chương trình ngẫu nhiên, đảm bảo khai thác tiền mã hóa phi tập trung và công bằng.
Deep Dive Phân tích sâu
RandomX generates and executes random programs that stress the entire CPU pipeline — making specialized hardware (ASICs) economically unviable. RandomX tạo và thực thi các chương trình ngẫu nhiên làm căng toàn bộ pipeline của CPU — khiến phần cứng chuyên dụng (ASIC) không còn hiệu quả về kinh tế.
Unlike traditional PoW algorithms (e.g., SHA-256) that compute a single hash function, RandomX generates a unique set of random programs for each mining attempt. The miner must execute these programs on a virtual machine, producing results that are then hashed. Because the programs are random and diverse, they require: Khác với các thuật toán PoW truyền thống (vd: SHA-256) chỉ tính một hàm băm duy nhất, RandomX tạo ra một tập hợp chương trình ngẫu nhiên duy nhất cho mỗi lần khai thác. Người khai thác phải thực thi các chương trình này trên một máy ảo, tạo ra kết quả sau đó được băm. Vì các chương trình ngẫu nhiên và đa dạng, chúng đòi hỏi:
64-bit integer arithmetic operations including ADD, SUB, MUL, IMUL, and division. Các phép toán số học số nguyên 64-bit bao gồm ADD, SUB, MUL, IMUL và phép chia.
Random reads/writes to a 2 MB scratchpad requiring L3 cache for efficiency. Đọc/ghi ngẫu nhiên vào scratchpad 2 MB yêu cầu cache L3 để đạt hiệu suất.
Branching, conditional jumps, and loops that stress the CPU branch predictor. Nhảy có điều kiện, rẽ nhánh và vòng lặp làm căng bộ dự đoán nhánh của CPU.
The input block header is hashed using Argon2d (a memory-hard function) to produce a 64-byte key. This key is then expanded via a SuperscalarHash function — a custom sequence of integer operations that fills the 2 MB scratchpad with pseudo-random data.
Header khối đầu vào được băm bằng Argon2d (hàm yêu cầu bộ nhớ cao) để tạo khóa 64 byte. Khóa này sau đó được mở rộng qua hàm SuperscalarHash — chuỗi phép toán số nguyên tùy chỉnh đổ dữ liệu giả ngẫu nhiên vào scratchpad 2 MB.
Using the key as entropy, RandomX generates 256 random instructions forming a program for its custom virtual machine. Each program is unique — containing a mix of integer ALU ops, memory accesses, and branches. The instruction set is deliberately designed to map closely to real CPU capabilities. Sử dụng khóa làm entropy, RandomX tạo 256 lệnh ngẫu nhiên tạo thành chương trình cho máy ảo tùy chỉnh. Mỗi chương trình là duy nhất — chứa kết hợp các phép ALU số nguyên, truy cập bộ nhớ và rẽ nhánh. Tập lệnh được thiết kế để ánh xạ gần với khả năng CPU thực.
The generated program runs on the RandomX Virtual Machine. The VM has 8 integer registers (r0–r7), a program counter, and reads/writes from the 2 MB scratchpad. Execution modifies register states, producing a final result after all 256 instructions are processed. Chương trình được tạo chạy trên Máy ảo RandomX. VM có 8 thanh ghi số nguyên (r0–r7), bộ đếm chương trình và đọc/ghi từ scratchpad 2 MB. Quá trình thực thi thay đổi trạng thái thanh ghi, tạo kết quả cuối cùng sau khi xử lý tất cả 256 lệnh.
The VM output (register values) is combined with the scratchpad and hashed using Blake2b to produce the final 256-bit PoW hash. If the hash meets the difficulty target, the block is valid. Otherwise, the nonce changes and the entire process repeats.
Đầu ra VM (giá trị thanh ghi) được kết hợp với scratchpad và băm bằng Blake2b để tạo băm PoW 256-bit cuối cùng. Nếu băm đạt mục tiêu khó, khối hợp lệ. Ngược lại, nonce thay đổi và toàn bộ quá trình lặp lại.
ASICs excel at fixed computations. RandomX's ever-changing programs make it impossible to hardwire a single efficient circuit — each program demands a general-purpose CPU. ASIC vượt trội ở tính toán cố định. Các chương trình liên tục thay đổi của RandomX khiến không thể đi cứng một mạch hiệu quả duy nhất — mỗi chương trình đòi hỏi CPU đa năng.
The 2 MB scratchpad fits in CPU L3 cache but is too large for cheap on-chip SRAM. This forces ASIC designers to include expensive large memory, eliminating cost advantages. Scratchpad 2 MB vừa với cache L3 của CPU nhưng quá lớn cho SRAM trên chip giá rẻ. Điều này buộc nhà thiết kế ASIC phải tích hợp bộ nhớ lớn đắt tiền, loại bỏ lợi thế chi phí.
Conditional jumps and branches require a branch predictor. ASICs lack sophisticated branch prediction, causing pipeline stalls that dramatically reduce throughput. Nhảy có điều kiện và rẽ nhánh yêu cầu bộ dự đoán nhánh. ASIC thiếu dự đoán nhánh phức tạp, gây tắc nghẽn pipeline làm giảm năng lượng đáng kể.
The Monero community hard-forks to update RandomX parameters periodically, rendering any potential ASIC obsolete before it can recoup R&D investment. Cộng đồng Monero thường xuyên hard-fork để cập nhật tham số RandomX, làm mọi ASIC tiềm năng trở nên lỗi thời trước khi thu hồi đầu tư R&D.
Real World Thực tế
RandomX is primarily known for Monero, but its design principles have broader implications for decentralized systems. RandomX chủ yếu được biết qua Monero, nhưng nguyên lý thiết kế của nó có ý nghĩa rộng hơn cho các hệ thống phi tập trung.
Monero adopted RandomX in November 2019 (block 1978433), replacing CryptoNight. CPU mining became the dominant method, with GPUs only ~2x faster and ASICs effectively eliminated. This ensures anyone with a regular computer can mine profitably. Monero áp dụng RandomX từ tháng 11/2019 (khối 1978433), thay thế CryptoNight. Khai thác CPU trở thành phương thức chính, GPU chỉ nhanh ~2x và ASIC bị loại bỏ hiệu quả. Điều này đảm bảo ai cũng có máy tính thường có thể khai thác có lãi.
RandomX-powered networks prevent mining centralization that could enable surveillance. By keeping mining accessible to individuals, transaction privacy is strengthened — no single entity controls enough hash power to censor or trace transactions. Các mạng sử dụng RandomX ngăn chặn tập trung khai thác có thể cho phép giám sát. Giữ khai thác dễ tiếp cận cho cá nhân, quyền riêng tư giao dịch được củng cố — không thực thể nào đủ hash power để kiểm duyệt hay truy vết giao dịch.
RandomX serves as a blueprint for future ASIC-resistant algorithms. Its random program execution model has influenced research into memory-hard and compute-diverse PoW designs across academia and blockchain development. RandomX là bản mẫu cho các thuật toán kháng ASIC tương lai. Mô hình thực thi chương trình ngẫu nhiên đã ảnh hưởng nghiên cứu về thiết kế PoW yêu cầu bộ nhớ cao và đa dạng tính toán trong học thuật và phát triển blockchain.
Several Monero forks and privacy-focused coins have adopted RandomX or its variants, including Wownero and various community-driven projects that prioritize egalitarian mining. Nhiều fork của Monero và đồng tiền tập trung quyền riêng tư đã áp dụng RandomX hoặc biến thể, bao gồm Wownero và các dự án cộng đồng ưu tiên khai thác bình đẳng.
RandomX's Light mode (~256 MB dataset, no scratchpad — values recomputed on the fly) enables verification on resource-constrained devices like single-board computers and IoT hardware, opening possibilities for distributed edge computing networks. Chế độ Light của RandomX (~256 MB dataset, không scratchpad — giá trị được tính lại tức thì) cho phép xác minh trên thiết bị hạn chế tài nguyên như máy tính bảng mạch đơn và phần cứng IoT, mở ra khả năng cho mạng tính toán phân tán edge.
By leveling the playing field between CPUs, GPUs, and ASICs, RandomX creates a more equitable coin distribution — preventing the "rich get richer" centralization seen in SHA-256 or Ethash ecosystems. Explore fair crypto applications at BTCLottery.dev. Bằng cách cân bằng giữa CPU, GPU và ASIC, RandomX tạo phân phối đồng công bằng hơn — ngăn chặn tập trung "người giàu càng giàu" thấy trong hệ sinh thái SHA-256 hay Ethash. Khám phá ứng dụng crypto công bằng tại BTCLottery.dev.
Benchmark So sánh
| Feature Tính năng | RandomX | SHA-256 | Ethash | CryptoNight |
|---|---|---|---|---|
| ASIC Resistant Kháng ASIC | ✓ | ✗ | ~ | ✓ |
| Optimal Hardware Phần cứng tối ưu | CPU | ASIC | GPU | CPU |
| Memory Requirement Yêu cầu bộ nhớ | 2 MB | ~0 | 4+ GB | 2 MB |
| Algorithm Type Loại thuật toán | Random programs Chương trình ngẫu nhiên | Fixed hash (SHA-256) Băm cố định (SHA-256) | Memory-hard DAG DAG yêu cầu bộ nhớ | Memory-hard Yêu cầu bộ nhớ |
| Primary Chain Chuỗi chính | Monero | Bitcoin | Ethereum (legacy) | Monero (legacy) |
| GPU Advantage Lợi thế GPU | ~2x | N/A (ASIC wins) N/A (ASIC thắng) | ~20-30x | ~2-5x |
| Decentralization Phi tập trung | High Cao | Low Thấp | Medium Trung bình | High Cao |
Uses the full 2 MB scratchpad. Requires L3 cache for optimal performance. Best suited for CPUs with large caches (e.g., AMD Ryzen, EPYC). Used by miners. Sử dụng scratchpad 2 MB đầy đủ. Yêu cầu cache L3 để hiệu suất tối ưu. Phù hợp nhất CPU có cache lớn (vd: AMD Ryzen, EPYC). Dùng cho người khai thác.
Uses only 256 MB of memory with recomputation. Much slower (~8x) but can run anywhere. Used by nodes/verifiers that don't need to mine. Chỉ dùng 256 MB bộ nhớ với tính toán lại. Chậm hơn nhiều (~8x) nhưng chạy được mọi nơi. Dùng cho node/người xác minh không cần khai thác.
Next Generation Thế hệ tiếp theo
RandomX v2 is the next upgrade to the RandomX Proof-of-Work algorithm, developed by tevador, SChernykh, and hyc. It targets modern CPU bottlenecks identified in RandomX v1, strengthens resistance against custom mining hardware (e.g., Bitmain X9), and introduces hash commitments for faster block verification. The algorithm was merged into the RandomX repository on Feb 17, 2026 and is pending Monero mainnet activation. RandomX v2 là bản nâng cấp tiếp theo của thuật toán Proof-of-Work RandomX, được phát triển bởi tevador, SChernykh và hyc. Nó khắc phục các điểm nghẽn CPU hiện đại được phát hiện trong RandomX v1, tăng cường kháng phần cứng khai thác tùy chỉnh (vd: Bitmain X9) và giới thiệu hash commitments để xác minh khối nhanh hơn. Thuật toán đã được merge vào kho RandomX ngày 17/2/2026 và đang chờ kích hoạt trên Monero mainnet.
Program size increased from 256 → 384 instructions (+50%). This raises total VM ops per hash from ~4.45M to ~6.81M, making custom hardware proportionally more expensive. Kích thước chương trình tăng từ 256 → 384 lệnh (+50%). Tổng lệnh VM mỗi hash tăng từ ~4.45M lên ~6.81M, khiến phần cứng tùy chỉnh đắt tỷ lệ thuận.
CFROUND now changes the rounding mode 16× less often (1/16 probability). This eliminates CPU pipeline stalls on modern architectures, improving efficiency by 5–10% on AMD CPUs. CFROUND giờ thay đổi chế độ làm tròn ít hơn 16 lần ( xác suất 1/16). Loại bỏ tắc nghẽn pipeline CPU trên kiến trúc hiện đại, cải thiện hiệu suất 5–10% trên CPU AMD.
Group F and E registers are now mixed with 16 AES operations instead of simple XOR. This doubles AES ops per hash (+262K) and forces custom hardware to implement full AES in the VM core, not just in scratchpad init. Nhóm thanh ghi F và E giờ được trộn bằng 16 phép AES thay vì XOR đơn giản. Gấp đôi phép AES mỗi hash (+262K) và buộc phần cứng tùy chỉnh phải triển khai AES đầy đủ trong lõi VM, không chỉ trong khởi tạo scratchpad.
Dataset prefetch is 2 iterations ahead (vs 1), reducing memory wait time. New hash commitments allow faster block verification without re-executing the full program. Dataset prefetch trước 2 vòng lặp (thay vì 1), giảm thời gian chờ bộ nhớ. Hash commitments mới cho phép xác minh khối nhanh hơn mà không cần thực thi lại toàn bộ chương trình.
Bitmain's Antminer X9 is not a traditional ASIC — it's a box of custom RISC-V CPUs (likely Sophon SG2044 series with DDR5). While technically "CPUs," these chips have stripped-out features (virtual memory, full OS support) to reduce die cost, creating an efficiency edge: ~400 h/J vs ~225 h/J for the best AMD 7945HX. RandomX v2 reduces this gap by at least 30%, making the X9 significantly less profitable. Bitmain is selling X9 below component cost because they know v2 will soon diminish its advantage. — Source: sech1 on r/Monero Antminer X9 của Bitmain không phải ASIC truyền thống — nó là hộp chứa CPU RISC-V tùy chỉnh (khả năng cao là dòng Sophon SG2044 với DDR5). Về mặt kỹ thuật là "CPU", nhưng các chip này đã cắt bớt tính năng (bộ nhớ ảo, hỗ trợ OS đầy đủ) để giảm chi phí die, tạo lợi thế hiệu suất: ~400 h/J so với ~225 h/J của AMD 7945HX tốt nhất. RandomX v2 giảm khoảng cách này ít nhất 30%, khiến X9 ít sinh lời đáng kể. Bitmain bán X9 dưới giá linh kiện vì họ biết v2 sẽ sớm làm giảm lợi thế của nó. — Nguồn: sech1 trên r/Monero
Hashrate improvements from PR #274 and #317 benchmarks (v1 vs v2): Cải thiện hashrate từ benchmark PR #274 và #317 (v1 so với v2):
| CPU | v1 (h/s) | v2 (h/s) | Change Thay đổi |
|---|---|---|---|
| Ryzen 9 7950X (2T) | 1635 | 1763 | +7.8% |
| Ryzen 9 5900X (2T) | 1525 | 1645 | +7.9% |
| Ryzen 7 1700 (2T) | 926 | 1004 | +8.4% |
| Threadripper 3970X (2T) | 1191 | 1250 | +5.0% |
| Apple M1 Pro (1T) | 424 | 445 | +5.0% |
| Intel i7-7700K (1T) | 747 | 746 | ~0% |
Note: v2 hashes are "heavier" (52.9% more total operations). Hashrate stays roughly the same because v2 also optimizes CPU pipeline utilization. Efficiency per Joule improves on modern CPUs. Lưu ý: Hash v2 "nặng hơn" (52.9% tổng phép toán nhiều hơn). Hashrate giữ nguyên vì v2 cũng tối ưu sử dụng pipeline CPU. Hiệu suất mỗi Joule cải thiện trên CPU hiện đại.
| Feature Tính năng | RandomX v1 RandomX v1 | RandomX v2 |
|---|---|---|
| Program Size Kích thước chương trình | 256 instructions | 384 instructions |
| Total Ops / Hash Tổng phép / Hash | 4,456,448 | 6,815,744 (+52.9%) |
| AES Ops / Hash Phép AES / Hash | 262,144 | 524,288 (2×) |
| CFROUND | Always changes rounding Luôn thay đổi làm tròn | 1/16 probability (conditional) Xác suất 1/16 (có điều kiện) |
| F/E Register Mix Trộn thanh ghi F/E | XOR | 16 AES rounds |
| Dataset Prefetch Dataset Prefetch | 1 iteration ahead | 2 iterations ahead |
| Hash Commitments Hash Commitments | ✗ | ✓ (faster verification) (xác minh nhanh hơn) |
| Scratchpad Scratchpad | 2 MB | 2 MB (unchanged) |
| Light Verify Impact Ảnh hưởng xác minh Light | — | ~10–11% slower (soft AES) Chậm ~10–11% (AES phần mềm) |
| Status Trạng thái | Active (Monero mainnet since 2019) Hoạt động (Monero mainnet từ 2019) | Merged — Not yet active on mainnet (pending v17 fork) Đã merge — Chưa kích hoạt trên mainnet (chờ fork v17) |
PR #274 — Original v2 VM changes by tevador (Sep 2023)
PR #317 — Final v2 implementation by SChernykh, merged Feb 2026
r/Monero: RandomX v2 update — Community update by sech1 (Dec 2025)
monero#10038 — Monero v17 integration (v2 + commitments)
design_v2.md — v2 design document
PR #274 — Thay đổi VM v2 gốc bởi tevador (9/2023)
PR #317 — Triển khai v2 cuối cùng bởi SChernykh, merge 2/2026
r/Monero: Cập nhật RandomX v2 — Cập nhật cộng đồng bởi sech1 (12/2025)
monero#10038 — Tích hợp Monero v17 (v2 + commitments)
design_v2.md — Tài liệu thiết kế v2
Common Questions Câu hỏi thường gặp