assay
An assayer melts a sample down and tells you what fraction of it is real gold.
assay does that for Bittensor subnets.
assay-bittensor.vercel.app — docs, live scan output, and the full evidence trail
▶ Watch the 3-minute demo — every line of terminal output is real stdout, rendered to film (no screen recording, no stock footage)
Install · Use · Evidence · How it works · Roadmap
The 15-second version
A Bittensor subnet pays miners according to rules its owner wrote in code. Those rules are easy to write and almost impossible to test — there has been no way to know they can be gamed short of deploying and watching TAO drain out.
assay fixes that. Point it at your scoring logic, and it runs seven scripted
adversaries against it:
| adversary | what it does |
|---|---|
| lazy miner | submits whitespace, collects emission anyway |
| weight copier | submits a byte-identical copy of a peer's answer |
| collusion ring | four hotkeys fan out one unit of work |
| Sybil farm | one operator, eight hotkeys, one answer |
| stale replayer | submits last round's valid answer forever |
| noise flood | random bytes at 5 ms latency |
| (baseline) | honest miners, to prove the report is not vacuous |
You get a table of what survived, a named defect per failure, and an exit code that fails CI.
That output is the point of the whole project. The mechanism it is running
against, quality_only, is what a competent engineer writes on the first pass:
honest quality scoring, median of three samples, empty submissions rejected. It
handles lazy miners. It is not fooled by noise.
It still loses 5 of 7 — because copying, Sybil farming and replay are not quality problems. They are identity and freshness problems, and a mechanism that only measures quality has no defence against them.
Why now
Bittensor 11 removed the Axon/Dendrite/Synapse networking stack and replaced
it with btauth/1 signed HTTP requests. The official subnet template was
archived and no longer works with current releases. No replacement exists — a
GitHub search for a v11 subnet template returns zero repositories, and
bittensor-subnet-template returns 404 on PyPI.
Every subnet in the ecosystem is being rebuilt right now, which means every subnet owner is rewriting the exact code this tool tests.
Install
uvx --from assay-bittensor assay list # run it without installing anything
pip install assay-bittensor # or install it
uvx needs --from because the distribution name and the command name differ —
assay is taken on PyPI. Same reason python-dateutil installs dateutil.
For signature verification and live-chain replay, add the extra:
pip install 'assay-bittensor[chain]'
Install from a clone instead
git clone https://github.com/yu7dan/assay
cd assay
uv venv && source .venv/bin/activate
uv pip install -e '.[chain]'
Use it
1. Wrap your reward function. One method, ten lines:
assay init assay_my_subnet.py
from assay import Batch, Mechanism
class MyMechanism(Mechanism):
name = "my-subnet"
def score(self, batch: Batch, evaluate) -> dict[int, float]:
# evaluate(response) -> noisy quality in [0, 1]
return {r.uid: evaluate(r) for r in batch.responses}
MECHANISM = MyMechanism()
2. Run the library.
assay run assay_my_subnet.py # human table
assay run assay_my_subnet.py -f markdown # paste into your README
assay run assay_my_subnet.py -s sybil_farm # one scenario
assay run assay_my_subnet.py --netuid 64 # replay a real subnet's distribution
3. Gate your CI. Exit 0 means every scenario held; 1 means at least one
broke.
- run: assay run assay_my_subnet.py -f json -o assay.json
Or use the composite action, which also writes the table to the job summary:
- id: assay
uses: yu7dan/assay@main
with:
mechanism: ci/assay_adapter.py
fail-on-regression: "true"
A full PR-commenting example lives in
examples/workflows/assay-example.yml.
The commands
| command | what it answers |
|---|---|
assay run |
does my mechanism survive seven adversaries? |
assay consensus |
what can a hostile validator do to it? |
assay scan |
which subnets look structurally fragile right now? |
assay history |
is this subnet's supply base widening or narrowing? |
assay rate |
how does supply structure compare across subnets? |
assay live |
what does this one real subnet look like? |
assay fidelity |
is this tool's model of rewards actually correct? |
assay conformance |
does the btauth/1 wire format match the published vectors? |
assay report |
re-render a saved run as markdown or a table |
assay init |
scaffold an adapter |
Evidence
Everything below was produced by the tool, on real data, while building it.
Three tiers of mechanism, one suite
Same scenarios, same seeds, same evaluator noise — the only difference is policy.
| scenario | naive_flat |
quality_only |
hardened |
|---|---|---|---|
honest_baseline |
✅ 0.000 | ✅ 0.000 | ✅ 0.000 |
lazy_miner |
❌ 0.500 | ✅ 0.000 | ✅ 0.000 |
weight_copying |
❌ 1.000 | ❌ 0.958 | ✅ 0.000 |
collusion_ring |
❌ 6.40× | ❌ 3.20× | ✅ 0.00× |
sybil_farm |
❌ 1.000 | ❌ 0.551 | ✅ 0.067 |
stale_replay |
❌ 1.000 | ❌ 0.996 | ✅ 0.000 |
noise_flood |
❌ 0.500 | ❌ 0.121 | ✅ 0.000 |
| result | 6 of 7 broken | 5 of 7 broken | all held |
The gap between quality_only and hardened is four checks, not a research
project:
- freshness — a payload seen in a previous round earns nothing
- deduplication — one unit of work is paid once, to the earliest submitter
- quality floor — work below a threshold earns nothing, however fast it arrived
- robust sampling — median of k noisy evaluations instead of one lucky draw
A real finding, from running this on itself
The first version of hardened.py used a quality floor of 0.15. noise_flood
scored 0.053 and failed: with an evaluator noise band of ±0.12, a
0.10-quality garbage miner still cleared a 0.15 floor in roughly 20% of rounds and
collected 5.3% of emission. Raising the floor to 0.30 — clear of the noise band —
took it to 0.000.
That is the argument for this tool in one paragraph. The difference between "my mechanism is robust" and "my mechanism leaks 5% to garbage" was one constant, and nothing but an adversary would have found it.
Real subnets, right now
assay scan --top 24
| measure | result |
|---|---|
| subnets paying validators only, no miner earning | 7 of 24 |
| subnets with fewer than 5 paid miners | 6 of 24 |
| median paid miner count | 3 |
median gini* among paid sets |
0.219 |
Five shapes, all in one sample:
- 7 of 24 pay validators only. Every neuron with non-zero emission holds a validator permit and every miner UID sits at zero incentive. The subnet is still emitting — it just has no miner supply this epoch. That is a different condition from being inactive, and it needed its own label.
- 6 of 24 have thin supply — under five miners earn anything at all.
- netuid 15 (ORO): 70 miners are paid, and the top one takes 94.9% of the paid set.
- netuid 6 (Numinous): 163 paid, top-1 only 7.6%, but
gini*0.895 — a long tail where most earn crumbs. - netuids 5 / 13 / 22: ~97% of registered miners earn,
gini*under 0.2. These are what healthy subnets look like.
Two numbers, deliberately kept apart.
gini*is concentration among miners that actually earned — the signal.gini_allis across every registered UID, and is nearly identical for every subnet (0.94–0.99) because subnets have hundreds of slots and most holders never run a miner. Ranking ongini_allproduced four identical verdicts from four different subnets; that metric had quietly become a constant.A subnet whose commodity comes from two hotkeys has a supply problem no incentive design fixes, and it is invisible on any dashboard that reports emission totals.
Caveat that travels with this table: incentive is a per-epoch quantity. A
zero means "no reward that epoch", not "permanently unpaid". The scan ranks where
to investigate; it does not accuse anyone.
Real subnet patterns, not just reference mechanisms
examples/real/ holds scoring rules reproduced from actual Bittensor subnets,
so the question is not "how would a bad mechanism fail" but "how does this one
fail".
RaoFoundation's official template — the repository the Bittensor docs point new subnet owners at — fails 3 of 7:
| scenario | measured | allowed |
|---|---|---|
weight_copying |
1.000 | 0.25 |
sybil_farm |
0.510 | 0.40 |
stale_replay |
1.000 | 0.20 |
A copier scores exactly what the miner it copied scores, because the rule compares answers rather than identities. Eight sybil hotkeys from one operator capture half the per-UID reward an honest miner gets. A replayed answer never decays, because nothing in the rule mentions time.
The template is a minimal starting point and says so. But a subnet owner who ships it unchanged inherits all three, and two of them cost money.
Ranked harmonic — the ranking pattern — fails 4 of 7, and introduces one of its own: four colluding hotkeys submitting a single answer amplify to 3.28× their fair share, because four copies occupy four ranks.
make real # both, side by side
A snapshot answers "what". Only history answers "which way".
assay scan tells you sixteen subnets have thin supply today. It cannot tell you
whether netuid 64 paid 18 miners three weeks ago and 11 now — and that change
is the difference between a subnet having a bad week and a subnet losing its
supply base.
assay history --record --top 24 # append an observation
assay history --netuid 64 # read the line back
assay history · netuid 64 Chutes
────────────────────────────────────────────────────────────────────────────
4 observations over 21.0 days
paid miners 18 → 11 ↓ -7
top-1 share 8.7% → 24.1% ↑ +15.4%
gini* (paid set) 0.240 → 0.440 ↑ +0.200
paid set turnover 3 kept, 8 new
────────────────────────────────────────────────────────────────────────────
supply base narrowing on both measures
Storage is one append-only JSONL file per subnet — no database, no service,
tail-able and greppable. A trend is only reported from three observations
onward; two points describe a straight line between two points, not a
direction, and the report says so instead of drawing one.
A widening supply base is not a recommendation to hold anything. A narrowing one is not proof of a broken mechanism — the commodity may simply need fewer operators now. This is an observation about structure, not a forecast about price.
Rating subnets, and the four times the score was wrong
assay rate composes a 0–100 structural score from supply shape. The first
version was a plain weighted average, and running it against sixteen live subnets
produced four indefensible answers:
| subnet | what it looked like | why averaging failed |
|---|---|---|
| 42 · CADmind | 5 paid miners, gini* 0.000 → scored 77.1, "broad supply" |
a sqrt curve against 8 saturated at single digits, so five miners splitting evenly read as a market |
| 2 · DaniLabs | nobody paid → scored the same as 3 paid miners | one ceiling covered 0 and 3 miners alike |
| 18 · Zeus | top miner 90% → scored 46.4 | three mediocre components averaged the capture away |
| 8 · Vanta | 18 miners → labelled "broad supply" | the grade threshold sat below the supplier ceiling, so the label was reachable |
The fix was not to retune weights. It was to stop letting one catastrophic dimension average its way out: supplier count and top-1 share impose hard ceilings on the composite, and grade thresholds are aligned with those ceilings so a label can never describe a set the ceiling forbids.
assay rate · netuid 18 Zeus
structural 48.7 / 100 concentrated
one operator supplies most of the commodity
component weight score evidence
Independent suppliers 32% 0.79 33 miners paid
Evenness of the paid set 26% 0.10 paid-set gini 0.897
Largest single supplier 24% 0.04 top miner 89.7% — dominant
Share of registered miners earning 10% 0.67 20.0% of registered earn
The score is never shown alone: every component ships with its weight, sub-score and evidence, so a reader can disagree with the number on the evidence instead of trusting it.
Structural only. It scores how a subnet's reward is distributed, not whether the commodity is worth anything, and it cannot see the future. It is not a price signal and not an investment rating. Structure is not value — a subnet can distribute its reward perfectly and produce something nobody wants.
Validators: the other half
A miner can only misrepresent its own work. A validator misrepresents everyone's.
assay consensus runs the mechanism once per validator, applies each
validator's behaviour, and combines the results by stake — the same formula
fidelity verified against mainnet.
assay consensus examples/winner_take_all.py
What is the mechanism's fault, and what is not:
| scenario | gated? | why |
|---|---|---|
weight_concentration |
yes | how reward is shaped is entirely the mechanism's own output |
validator_outlier |
no | the validator overwrites the result after the mechanism runs |
validator_capture |
no | majority stake is a stake-distribution problem, not a code problem |
Two of three are informational and always will be. A hostile validator does not ask the mechanism's permission — it runs the code, then submits a different vector. No scoring rule prevents that, so asserting otherwise would be theatre.
What the numbers still buy you is a price on a stake distribution:
| attacker | emission handed to a zero-work miner |
|---|---|
| one validator holding 1/6 of stake | 0.167 |
| 40% outlier + 20% copier = 60% bloc | 0.600 |
The cheapest capture is not a bad validator — it is a lazy one. Consensus is
stake-weighted, so a copier adds no opinion of its own. It lends its stake to
somebody else's judgement. Recruiting one validator that resubmits another's
vector is worth as much as running a validator, and costs nothing. That is why
copier is modelled at all: it is the cheapest capture available, and it looks
like participation.
One scenario I wrote, then deleted
mechanism_agreement compared two honest validators' top choices. It ran,
produced numbers, and was worthless — four mechanisms from naive to hardened all
scored identically, because the outcome is governed by the population's quality gap
relative to evaluator noise, not by anything the mechanism does.
A test that cannot tell a broken mechanism from a good one is worse than no test, because it implies coverage it does not have. Its one mechanism-owned fragment survives as a measurement:
| mechanism | output drift when evaluator σ goes 0.10 → 0.25 |
|---|---|
naive_flat |
0.000 (ignores the evaluator entirely) |
quality_only (median of 3) |
0.110 |
single_sample (one look) |
0.184 |
Median-of-three roughly halves how much a mechanism's output moves when its evaluator gets noisier. Real, worth knowing, not strong enough to gate on.
The model is verified, not assumed
Every verdict above sits downstream of one transformation:
incentive[m] = Σ_v (stake_v × weight[v][m]) / Σ_v stake_v
assay fidelity reconstructs that from live validator weight rows and real stake,
then measures total variation distance from what the chain actually paid.
| measure | result |
|---|---|
| subnets checked (mainnet, 2026-11-28) | 17 |
| within tolerance (TVD ≤ 0.05) | 16 of 17 |
| median TVD | 0.001 |
assay fidelity --netuid 64
The bug this found
The first version reported TVD 0.37 on netuid 24, which looked like a topology difference worth writing up. It was a bug.
The chain stores a weight row for any hotkey that submits one, but a row from a hotkey without a validator permit never enters consensus. On netuid 24 one non-permitted hotkey held 37% of the stake and had submitted a full weight vector; counting it distorted the reconstruction completely. Filtering to permit-holders took that subnet from 0.37 to 0.0054. Eight of the 17 subnets sampled had such rows — the common case, silently corrupting an innocent-looking number.
btauth/1 conformance
The only part of this tool with an objective oracle. The v11 docs publish golden test vectors with a pinned ed25519 signature, so correctness is not a matter of opinion — the bytes either match or they don't.
assay conformance
PASS body sha256 341c57448e531310…
PASS payload layout 227 bytes, no trailing newline
PASS ed25519 golden signature byte-for-byte match
PASS sr25519 roundtrip sign → verify
PASS tamper rejection substituted body rejected
PASS receiver binding receiver is part of the signed payload
Four of the six checks need the optional bittensor dependency. Without it they
report SKIP and the summary says NOT verified — never "all checks held".
How it works
┌─────────────────────────────┐
│ subnet owner's code │
│ score(batch, evaluate) │ ~10 line adapter
└──────────────┬──────────────┘
│ uid -> weight
┌───────────────────────────────▼───────────────────────────────┐
│ assay harness │
│ │
│ population.py scripted adversaries │
│ scenarios.py 7 scenarios, one-sided assertions │
│ mechanism.py the ABI + NoisyEvaluator │
│ runner.py rounds, normalisation, per-round series │
│ consensus.py validator behaviours + stake aggregation │
│ live.py metagraph fetch + cache │
│ scan.py batch profiling across netuids │
│ fidelity.py verifies the model against the chain │
│ conformance.py btauth/1 golden vectors │
│ report.py table · json · markdown │
└───────────────────────────────┬───────────────────────────────┘
│
┌──────────────▼──────────────┐
│ table / JSON / markdown │
│ exit 0 = holds, 1 = broken │
└─────────────────────────────┘
Four design decisions worth naming:
- The mechanism never sees ground truth. It receives responses and a noisy
evaluate(). The harness knows which miners are honest and which are colluding; the mechanism does not — exactly as on a real subnet. - Assertions are one-sided. "This attacker must not earn more than X", never "you must earn exactly Y". The tool constrains exploitation without dictating a design.
- A baseline guards against vacuous passes. Every attack assertion is
satisfiable by a mechanism that pays nobody, so
honest_baselineruns first and a failure there invalidates the entire report. - Zero runtime dependencies.
bittensoris an optional extra.
What this does NOT test
A harness that overstates its coverage is worse than none, so:
- Quality model accuracy.
evaluate()is a stand-in. This tests how you aggregate and defend, not whether your model is good. - On-chain stake dynamics. Weights are modelled, not submitted. Emission, bonds, immunity periods and validator permits are out of scope.
- Real network conditions. No latency distributions, packet loss, or partial failures yet.
- Mechanism-specific exploits. The library is generic by design. Your subnet's commodity may have a domain-specific attack this does not know about.
- Adversaries that vary their payload. A Sybil that submits genuinely distinct work per hotkey is indistinguishable from N honest miners — that is not a bug in the harness, it is the definition of the problem.
Status, stated plainly
| version | v0.6.0 in this repo; PyPI still serves v0.4.1 — see below |
| tests | 216 passing, Python 3.10–3.13 |
| commands | 11 |
| real users | none yet |
| what is proven | the model reproduces on-chain rewards (17 subnets, median TVD 0.001); the conformance vectors match byte-for-byte |
| what is not | that any subnet has been made safer by it |
That last row is the honest one. Everything here is a simulation around a verified core; the product thesis is that a subnet owner who runs it will find a real defect before an attacker does. That thesis is untested.
The version table is the second-honest row. pip install assay-bittensor
today installs 0.4.1, and in 0.4.1 assay init crashes with
KeyError: 'uid' — the scaffold never writes a file. It is fixed here, but the
fix is unpublished while the PyPI trusted publisher is unconfigured. Until then
start from a clone:
git clone https://github.com/yu7dan/assay && cd assay && uv venv && uv pip install -e .
Roadmap
This is a hackathon entry, and also a product with its own plan. Stated so that neither is confused for the other.
| Now |
Seven adversary scenarios · validator-side consensus modelling · live metagraph
replay · batch scan · history and trend · structural rating ·
verified reward model · btauth/1 conformance · CI action · on PyPI.
|
| Next | A public monthly structural report built from accumulated history, so the data starts existing before anyone is asked to rely on it. Real validator weight vectors replayed as adversarial input rather than modelled stake. |
| Then | Hosted CI with report history and regression alerts. Mechanism audits as an engagement, using the same tooling this repository ships. |
| Positioning | Developer infrastructure — Track 2 of the 2026 Bittensor Global Hackathon. Not a fund, not a token: a testing tool. The judgement it produces may later be worth acting on, but the tool has to be trustworthy before that is a real question. |
Documentation
docs/subnets.md |
every netuid this tool has read, with real figures and dates |
docs/mechanism.md |
how the Bittensor claims are verified, file by file and command by command |
docs/STATUS.md |
the evidence collected during development, including what failed |
docs/ROADMAP.md |
what exists, what does not, and in what order |
CHANGELOG.md |
every version, including the bugs each one fixed |
.env.example |
there is nothing to configure — and the file says why |
Develop
make install # editable install + pytest
make test # 174 tests
make probe # three reference mechanisms, side by side
make consensus # validator-side scenarios
make rate # structural scores across the largest subnets
make track # record today's observation, read the trend back
make conformance # btauth/1 golden vectors
make all # what CI runs
Regenerate the images in this README from real output:
python tools/render_terminal_svg.py
They are vector text rendered from actual stdout, not screenshots — so they cannot drift from the code.
License
MIT.
Metadata
Release files for assay-bittensor 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| assay_bittensor-0.6.0.tar.gz | 125.3 kB | With provenance | Details for assay_bittensor-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| assay_bittensor-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for assay_bittensor-0.6.0-py3-none-any.whl |
Total release size: 201.2 kB
Release files / assay_bittensor-0.6.0.tar.gz
| Download URL | assay_bittensor-0.6.0.tar.gz |
|---|---|
| Size | 125.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5e5bb10cb219f44b4837058a0c9395deb8f17c48a9e05f23028ed0dfaf483d98
|
|
BLAKE2b-256 checksum How to use checksums |
88652c92274f415045d13bc1b1523fcff78c38d76fbbc014fae9981fc415f609
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logRelease files / assay_bittensor-0.6.0-py3-none-any.whl
| Download URL | assay_bittensor-0.6.0-py3-none-any.whl |
|---|---|
| Size | 75.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
036bd4e593deaa031ce8daa95eebd0ae661536ad51e38eff2fcc0407b0fc2948
|
|
BLAKE2b-256 checksum How to use checksums |
9843dec737c71a6a1b29696e74511faf0634732c3a7f5f761aa6c450d44ec23d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logSecurity for assay-bittensor 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for assay_bittensor-0.6.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.