Skip to main content

Building your Score

How the validator set is chosen each epoch, how solver and vault emissions are paid, and how to produce, submit and track MatMul solutions.

Your score is the number of valid MatMul solutions ("sols") your key has submitted in the current epoch. An epoch is 100,000 blocks, about 13 hours 53 minutes. Scores reset at every epoch boundary.

How the validator set is chosen​

At the end of each epoch the chain builds the validator set for the next one from two groups:

  • Top solvers. The 33 keys with the most sols this epoch. Keys removed by a slashing motion this epoch are left out.
  • Vault-backed validators. Every key backed by at least 1,000,000 AMA in staking vaults, counting each vault's amount plus accrued yield.

A key in both groups appears once. The combined set is shuffled, and there is no fixed size cap.

How emissions are paid​

Each epoch emits a fixed amount of new AMA that decays over time; read the current value from emission_for_epoch in /api/chain/stats. The emission is split in two halves:

  • Solver half. Paid to every key that is in the current validator set and submitted sols this epoch, pro rata by sol count. Whether you make it into the next set does not matter. Sols from keys outside the current set build their score for the next set but earn nothing this epoch. Slashed keys earn nothing.
  • Vault half. Pays the APY of vaults that back a validator in the set. See Staking vaults.

Network participation curbs the solver half. The chain estimates network compute from all sols submitted this epoch (the pflops field of /api/chain/stats). At 100 PFLOPS or more the full solver half is paid. Below that, only pflops% of it is paid, never less than 10%, and the rest accrues in a pool. From epoch 1150 on, the same curb also applies to vault APY.

A 25% network tax on everything paid goes to the treasury. It is funded from the unused vault budget (the vault half plus the carried-over pool) and never reduces a payout. If that leftover is smaller than 25% of the payouts, the tax is capped at the leftover.

Validators also keep half of the transaction fees in the blocks they produce. The other half is burned.

What a sol is​

A sol is 1,264 bytes: a 240-byte seed followed by a 1,024-byte matrix product.

<<
epoch::32-little, # current epoch
segment_vr_hash::32-binary, # bic:epoch:segment_vr_hash on chain
node_pk::48-binary, # the key that gets the score
node_pop::96-binary, # proof of possession for node_pk
computor_pk::48-binary, # who computed it (the built-in solver puts node_pk here)
nonce::12-binary, # random
tensor_c::1024-binary # C = A x B
>>

To build the product, hash the 240-byte seed with Blake3 in extendable-output mode and read 1,607,680 bytes. The first 16 × 50,240 bytes are matrix A (unsigned 8-bit, row-major), and the next 50,240 × 16 bytes are matrix B (signed 8-bit, row-major). C = A × B is a 16 × 16 matrix of signed 32-bit integers, stored little-endian.

The chain accepts a sol only when all of these hold:

  • Its epoch is the current epoch and its segment_vr_hash matches the chain's current value.
  • The Blake3 hash of the full 1,264 bytes starts with at least diff_bits zero bits.
  • A Freivalds check confirms that C really is A × B.
  • The same sol has not been submitted before in this epoch.
  • If the key has no proof of possession on chain yet, node_pop must be a valid one for node_pk.

diff_bits adjusts every epoch to aim at 180,000 sols per epoch from the solvers in the set, within a 10% tolerance and between 20 and 64 bits. The current value is in diff_bits of /api/chain/stats. Consensus verifies sols in the node's Rust code, in ex/native/rdb/src/consensus/bic (sol.rs, sol_difficulty.rs, sol_freivalds.rs, epoch.rs).

You submit a sol with an Epoch.submit_sol transaction. The first accepted sol for a key also records its proof of possession on chain. Like every transaction, it reserves a 0.01 AMA budget from the signer and refunds what it does not use, so the signing key needs at least 0.01 AMA.

Run the built-in solver​

The simplest way to build a score is to let the node solve. Start it with COMPUTOR=true:

COMPUTOR=true ./amadeusd

# limit the solver threads (default: half the CPU schedulers minus 2, at least 1)
COMPUTOR=true COMPUTOR_UPOW_THREADS=8 ./amadeusd
warning

The solver starts whenever COMPUTOR is set, even to false. To keep it off, leave the variable unset.

The solver:

  • Works through every key in $WORKFOLDER/seeds in turn and submits sols for each.
  • Skips keys with less than 0.01 AMA and prints 🔴 key <pk> has less than 0.01 AMA, skipping. Fund each key before you start.
  • Skips keys that were slashed this epoch until the next epoch begins.
  • Pauses while the node is out of sync (🔴 cannot compute: out_of_sync).
  • Prints 🔢 tensor matmul complete! tx <hash> key <pk> for every sol it submits.
  • Uses the AVX-512 VNNI path when the CPU supports it, otherwise AVX2.

Solve from the REPL​

The built-in solver runs this loop for you. To run one round by hand in the node's REPL, using the node's first key:

key = Application.fetch_env!(:ama, :keys) |> hd()
threads = Application.fetch_env!(:ama, :computor_upow_threads)

epoch = DB.Chain.epoch()
segment_vr_hash = DB.Chain.segment_vr_hash()
diff_bits = DB.Chain.diff_bits()

# tries one batch of nonces; returns nil when none meets diff_bits
sol = UPOW.compute(epoch, key.pk, key.pop, key.pk, segment_vr_hash, diff_bits, 20_000, threads)

if sol do
tx_packed = TX.build(key.seed, "Epoch", "submit_sol", [sol])
TXPool.insert_and_broadcast(tx_packed)
end

Track your score​

From any machine, ask the RPC for one key's score in the current epoch (API reference):

curl -s https://mainnet-rpc.ama.one/api/epoch/score/<your_pk>
# {"error":"ok","score":33577}

/api/chain/stats lists every validator and staked key with its current sols and whether it is in the set:

curl -s https://mainnet-rpc.ama.one/api/chain/stats | jq '.stats.validators["<your_pk>"]'
# {
# "commission_bps": 0,
# "sols": 33609,
# "in_validator_set": true,
# "staked": 0.0,
# "staked_flat": 0
# }

In the REPL, API.Epoch.score(pk) returns the same count for one key, and API.Epoch.score() lists every key that submitted sols this epoch, highest first.

Send rewards to a cold wallet​

By default, solver emission is paid to the key that earned it. To send it elsewhere, the validator key sets an emission address. In the node's REPL, this signs with the node's first key:

API.Epoch.set_emission_address("<cold_wallet_pk>")

The emission address also receives the validator's vault commission. To check it, call API.Epoch.get_emission_address() in the REPL or GET /api/epoch/get_emission_address/<pk> (API reference).

Build an external solver (testnet)​

Testnet RPC nodes expose helpers for building and testing your own solver, for example on GPUs. They do not exist on mainnet.

EndpointReturns
GET /api/upow/seedA fresh 240-byte seed
GET /api/upow/seed_with_matrix_a_bThe 240-byte seed followed by matrices A and B (1,607,920 bytes in total)
POST /api/upow/validateChecks a 1,264-byte sol sent as the raw body: {"valid": ..., "valid_math": ...}
GET /api/upow/validate/<sol in Base58>The same check

valid_math tells you whether C = A × B is correct. valid additionally requires the hash to meet diff_bits, so it stays false until you find a winning nonce. This round trip checks a CPU implementation with numpy:

curl -s https://testnet-rpc.ama.one/api/upow/seed_with_matrix_a_b -o seed_ab.bin
python3 matmul.py
curl -s -X POST --data-binary @sol.bin https://testnet-rpc.ama.one/api/upow/validate
# {"valid":false,"valid_math":true}
# matmul.py
import numpy as np

INNER = 50_240

payload = open("seed_ab.bin", "rb").read()
seed = payload[:240]
matrix_bytes = payload[240:]
matrix_a = np.frombuffer(matrix_bytes[: 16 * INNER], dtype=np.uint8).reshape(16, INNER)
matrix_b = np.frombuffer(matrix_bytes[16 * INNER :], dtype=np.int8).reshape(INNER, 16)
tensor_c = matrix_a.astype(np.int32) @ matrix_b.astype(np.int32)

open("sol.bin", "wb").write(seed + tensor_c.astype("<i4").tobytes())

The seeds these endpoints return carry the serving node's own key, so sols built from them score for that node, not for you. To score for your own key, build the 240-byte seed yourself with your public key and proof of possession, using the current segment_vr_hash (Base58 in /api/chain/stats), and derive A and B from it as described in What a sol is.