A RandomX mining pool stratum server for Marscoin's marsqnet quantum-resistant testnet.
Built in Go. Adapted from sammy007/monero-stratum with a full rewrite of the RPC layer, block construction, and hashing for Bitcoin-style nodes running RandomX.
Live pool: mining-mars.com/testnet
- RandomX proof-of-work via CGo bindings to librandomx
- Bitcoin-style RPC -- connects to Marscoin Core nodes (not CryptoNote)
- xmrig-compatible stratum protocol (login, submit, getjob, keepalived)
- Block construction -- coinbase transactions, merkle trees, 80-byte headers
- Share validation -- full RandomX hash verification per share
- Automatic block submission when a share meets the network target
- Job broadcasting -- pushes new work to all miners on new blocks
- Cookie auth -- reads RPC credentials from the node's cookie file
- Multi-port with configurable per-port difficulty
- Go 1.18+
- A running marsqnet node (Marscoin Core
feat/pow-randomxbranch) - GCC/G++ for building the RandomX library
The stratum server links against librandomx. Build it from the marsqnet node source:
# Assuming marsqnet node source is at /opt/marscoin-marsqnet
RX_SRC=/opt/marscoin-marsqnet/src/crypto/randomx_vendor/src
mkdir -p randomx/lib randomx/include
cp $RX_SRC/randomx.h randomx/include/
# Compile C files
for f in argon2_core.c argon2_ref.c argon2_ssse3.c argon2_avx2.c reciprocal.c virtual_memory.c; do
gcc -c -fPIC -O2 -maes -mssse3 -mavx2 -I$RX_SRC -I$RX_SRC/blake2 $RX_SRC/$f -o /tmp/rx_$f.o
done
gcc -c -fPIC -O2 -I$RX_SRC/blake2 $RX_SRC/blake2/blake2b.c -o /tmp/rx_blake2b.o
gcc -c -fPIC $RX_SRC/jit_compiler_x86_static.S -o /tmp/rx_jit_x86_static.o
# Compile C++ files
for f in aes_hash.cpp allocator.cpp assembly_generator_x86.cpp blake2_generator.cpp \
bytecode_machine.cpp cpu.cpp dataset.cpp instruction.cpp instructions_portable.cpp \
jit_compiler_x86.cpp randomx.cpp soft_aes.cpp superscalar.cpp virtual_machine.cpp \
vm_compiled.cpp vm_compiled_light.cpp vm_interpreted.cpp vm_interpreted_light.cpp; do
g++ -c -fPIC -O2 -std=c++11 -maes -mssse3 -I$RX_SRC -I$RX_SRC/blake2 $RX_SRC/$f -o /tmp/rx_$f.o
done
# Create static library
ar rcs randomx/lib/librandomx.a /tmp/rx_*.ogit clone https://github.com/marscoin/marsqnet-stratum.git
cd marsqnet-stratum
go build -o marsqnet-stratum .cp config.example.json config.json
# Edit config.json with your node's RPC port and cookie file path./marsqnet-stratum config.json./xmrig -a rx/0 -o stratum+tcp://YOUR_HOST:3434 -u YOUR_ADDRESS.worker1 -p x{
"address": "mqt1...",
"chain": "marsqnet",
"bypassAddressValidation": true,
"upstream": [{
"name": "marsqnet-local",
"host": "127.0.0.1",
"port": 49332,
"timeout": "10s",
"cookieFile": "/var/lib/marscoin-marsqnet/regtest/.cookie"
}],
"stratum": {
"timeout": "120s",
"listen": [{
"host": "0.0.0.0",
"port": 3434,
"diff": 1000,
"maxConn": 1024
}]
},
"blockRefreshInterval": "500ms"
}| Field | Description |
|---|---|
address |
Pool payout address (marsqnet bech32 mqt1...) |
upstream.port |
marsqnet node RPC port |
upstream.cookieFile |
Path to the node's .cookie auth file |
stratum.listen.port |
Port miners connect to |
stratum.listen.diff |
Share difficulty for miners |
blockRefreshInterval |
How often to poll for new block templates |
CPU Miners (xmrig)
│
│ stratum protocol (login, submit, job)
▼
┌──────────────────┐
│ marsqnet-stratum │
│ (Go + RandomX) │
│ │
│ - Job manager │
│ - Share validator │
│ - Block submitter │
└────────┬─────────┘
│ Bitcoin-style JSON-RPC
▼
┌──────────────────┐
│ marsqnet node │
│ (Marscoin Core) │
│ RandomX PoW │
└──────────────────┘
- Template fetch -- polls the node's
getblocktemplateevery 500ms - Job creation -- builds a coinbase transaction, computes merkle root, serializes an 80-byte block header
- Job distribution -- sends the header blob + RandomX seed hash to connected miners
- Share validation -- when a miner submits a nonce, the stratum hashes the header with RandomX and checks against the share difficulty
- Block submission -- if a share also meets the network target, the full block is assembled and submitted via
submitblock
marsqnet-stratum/
├── main.go # Entry point
├── config.json # Runtime configuration
├── pool/
│ └── pool.go # Config types
├── rpc/
│ └── rpc.go # Bitcoin-style RPC client with cookie auth
├── blockutil/
│ └── blockutil.go # Block construction (coinbase, merkle, headers)
├── randomx/
│ ├── randomx.go # CGo bindings to librandomx
│ ├── include/randomx.h # RandomX C header
│ └── lib/librandomx.a # Compiled RandomX library (not committed)
├── stratum/
│ ├── stratum.go # Stratum server (connections, jobs, shares, blocks)
│ └── proto.go # Protocol message types
└── cmd/rpctest/
└── main.go # Standalone test miner (for development)
Marscoin's marsqnet testnet replaces scrypt with RandomX to achieve:
- CPU-friendly mining -- anyone with a laptop can mine, no ASICs needed
- ASIC resistance -- RandomX is designed to be inefficient on specialized hardware
- Quantum readiness -- preparing the network for post-quantum cryptography
- True decentralization -- when mining is accessible to everyone, no single entity controls the hashrate
- Adapted from sammy007/monero-stratum (Go stratum framework)
- RandomX by tevador (PoW algorithm)
- Marscoin -- the cryptocurrency for Mars
Released under the GNU General Public License v2.