# How DragonX uses RandomX

DragonX uses **RandomX** as its Proof-of-Work algorithm. RandomX is CPU-friendly
and ASIC/GPU-resistant, which keeps mining accessible to ordinary hardware.
RandomX is the same family of algorithm that Monero (XMR) and various other
coins use, though DragonX uses its own configuration (see "RandomX Internals"
below), so DragonX RandomX is not compatible with Monero mining hardware.

DragonX descends from the Hush lineage (Bitcoin -> Zcash -> Komodo -> Hush ->
DragonX). The RandomX integration in this codebase originates from that Hush
work; DragonX ships it as a fixed part of consensus rather than as a launcher
option.

## DragonX consensus parameters

DragonX is a single, fully private chain. Its consensus is fixed (you do not
pass `-ac_*` arguments to run a DragonX node):

  * **PoW algorithm:** RandomX (CPU mineable)
  * **Block time:** 36 seconds on average
  * **Block reward:** 3 DRAGONX per block
  * **Halving:** every 3,500,000 blocks
  * **Private from genesis:** `ac_private=1`, with Sapling active at height 1.
    Transparent sends are banned from block 1; transparent addresses only
    receive mining coinbase (directly spendable, shielding optional). There is
    no "privacy switches on later" phase — DragonX is private from the very
    first block.

To run a DragonX node and mine on the network, use `dragonxd` (mining is
enabled with `-gen=1` and CPU threads set via `-genproclimit=N`), for example:

```
./src/dragonxd -gen=1 -genproclimit=1
```

You do not need to choose an algorithm, block time, reward, or supply — these
are baked into DragonX consensus.

## RandomX key-block tuning options

RandomX periodically rotates the "key block" it derives its dataset from. Two
advanced options control this. They are inherited from the upstream Hush /
Arrakis-chain tooling and default to values suited to DragonX's 36s block time;
you should not normally change them:

  * `-ac_randomx_interval` controls how often the RandomX key block changes
    * Default is 1024 blocks
    * At DragonX's 36s block time this is roughly ~10.2 hours
  * `-ac_randomx_lag` sets the number of blocks to wait before updating the key block
    * Default is 64 blocks
    * At DragonX's 36s block time this is roughly ~38 minutes
  * `-ac_randomx_interval` should always be larger than 2 times `-ac_randomx_lag`
  * Setting these to arbitrary values could affect chain security
    * Do not change these values unless you are really sure why you are doing it

# RandomX Internals

This section is not required reading if you just want to run or mine DragonX.
Here we explain how the internals of RandomX work inside the codebase.

We use the official RandomX implementation from https://github.com/tevador/RandomX
with custom configuration options. Because the configuration differs from the
Monero (XMR) RandomX configuration, hardware built to mine XMR RandomX is not
compatible with DragonX's RandomX. This is by design. The source code of RandomX
is embedded at `./src/RandomX` and the configuration options used are at
`./src/RandomX/src/configuration.h`.

The changes from default RandomX configuration options are listed below.

```
 //Argon2d salt
-#define RANDOMX_ARGON_SALT         "RandomX\x03"
+#define RANDOMX_ARGON_SALT         "RandomXHUSH\x03"

 //Number of Argon2d iterations for Cache initialization.
-#define RANDOMX_ARGON_ITERATIONS   3
+#define RANDOMX_ARGON_ITERATIONS   5
 
 //Number of parallel lanes for Cache initialization.
 #define RANDOMX_ARGON_LANES        1
@@ -53,13 +53,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #define RANDOMX_DATASET_EXTRA_SIZE 33554368
 
 //Number of instructions in a RandomX program. Must be divisible by 8.
-#define RANDOMX_PROGRAM_SIZE       256
+#define RANDOMX_PROGRAM_SIZE       512
 
 //Number of iterations during VM execution.
-#define RANDOMX_PROGRAM_ITERATIONS 2048
+#define RANDOMX_PROGRAM_ITERATIONS 4096
 
 //Number of chained VM executions per hash.
-#define RANDOMX_PROGRAM_COUNT      8
+#define RANDOMX_PROGRAM_COUNT      16
 
```
RandomX opcode frequencies were not modified, the defaults are used.
