Launch app
Cover: The Shared-Quantity Register: how we hunt the bug class that type systems cannot catch

The Shared-Quantity Register: how we hunt the bug class that type systems cannot catch

In every security review of this codebase the dominant defect was two places answering the same question with different answers, and nothing forcing them to agree. A type system cannot catch that; enumeration can — the register, the four row states, and why WEAK is more dangerous than OPEN.

Known formally as The Shared-Quantity Register in the BlazePhoenix whitepaper.

BlazePhoenix Engineering · article updated 2026-08-26 · site dataset through 2026-11-30 · 9 min · written from the deployed bytecode

At a glance
LevelAdvanced
Formal nameThe Shared-Quantity Register
Reading time9 min
Sections7
Updated2026-08-26

By Mitra (@Sigmacrit) — anonymous developer of the BlazePhoenix protocol. The code is the résumé.

Abstract in 15 languages · resumo · resumen · 摘要 · 要旨 · ملخص

English — The dominant defect in this codebase's reviews was two places answering the same question with different answers, with nothing forcing agreement — a class type systems cannot see. The register enumerates every shared quantity in four row states (SINGLE, PINNED, WEAK, OPEN), and a WEAK row is more dangerous than an OPEN one: a hole behind a green test draws no attention.

Português — O defeito dominante nas revisões deste código foi dois sítios a responder à mesma pergunta com respostas diferentes, sem nada a forçar acordo — uma classe que sistemas de tipos não veem. O registo enumera cada quantidade partilhada em quatro estados (SINGLE, PINNED, WEAK, OPEN), e uma linha WEAK é mais perigosa do que uma OPEN: um buraco atrás de um teste verde não chama a atenção.

Español — El defecto dominante en las revisiones de este código fue dos sitios respondiendo la misma pregunta con respuestas distintas, sin nada que fuerce el acuerdo — una clase que los sistemas de tipos no ven. El registro enumera cada cantidad compartida en cuatro estados (SINGLE, PINNED, WEAK, OPEN), y una fila WEAK es más peligrosa que una OPEN: un agujero tras un test verde no llama la atención.

Français — Le défaut dominant des revues de ce code : deux endroits répondant à la même question avec des réponses différentes, sans rien qui force l'accord — une classe invisible aux systèmes de types. Le registre énumère chaque quantité partagée en quatre états (SINGLE, PINNED, WEAK, OPEN), et une ligne WEAK est plus dangereuse qu'une OPEN : un trou derrière un test vert n'attire aucune attention.

Deutsch — Der dominante Defekt in den Reviews dieser Codebasis: zwei Stellen beantworten dieselbe Frage mit verschiedenen Antworten, und nichts erzwingt Einigkeit — eine Klasse, die Typsysteme nicht sehen. Das Register führt jede geteilte Größe in vier Zuständen (SINGLE, PINNED, WEAK, OPEN), und eine WEAK-Zeile ist gefährlicher als eine OPEN: ein Loch hinter einem grünen Test bekommt keine Aufmerksamkeit.

Русский — Главный дефект в ревью этой кодовой базы — два места, отвечающие на один вопрос разными ответами, и ничто не принуждает их к согласию; системы типов этот класс не видят. Регистр перечисляет каждую разделяемую величину в четырёх состояниях (SINGLE, PINNED, WEAK, OPEN), и строка WEAK опаснее OPEN: дыра за зелёным тестом не привлекает внимания.

Türkçe — Bu kod tabanının incelemelerindeki baskın kusur, aynı soruya farklı yanıtlar veren iki yerdi ve hiçbir şey uyuşmayı zorlamıyordu — tip sistemlerinin göremediği bir sınıf. Kütük her paylaşılan niceliği dört durumda sayar (SINGLE, PINNED, WEAK, OPEN) ve WEAK satır OPEN satırdan daha tehlikelidir: yeşil testin arkasındaki delik dikkat çekmez.

العربية — العيب الغالب في مراجعات هذه الشيفرة كان موضعين يجيبان عن السؤال نفسه بجوابين مختلفين دون ما يفرض الاتفاق — صنف لا تراه أنظمة الأنواع. السجل يعدّد كل كمية مشتركة في أربع حالات (SINGLE وPINNED وWEAK وOPEN)، والصف WEAK أخطر من OPEN: ثغرة خلف اختبار أخضر لا تلفت الانتباه.

हिन्दी — इस कोडबेस की समीक्षाओं में प्रमुख दोष था दो जगहों का एक ही प्रश्न के अलग-अलग उत्तर देना, और सहमति के लिए कोई बाध्यता नहीं — एक वर्ग जिसे टाइप सिस्टम नहीं देख पाते। रजिस्टर हर साझा मात्रा को चार अवस्थाओं (SINGLE, PINNED, WEAK, OPEN) में गिनता है, और WEAK पंक्ति OPEN से अधिक खतरनाक है: हरे टेस्ट के पीछे छिपा छेद ध्यान नहीं खींचता।

日本語 — このコードベースのレビューで支配的だった欠陥は、同じ問いに二つの場所が異なる答えを返し、何も一致を強制しないことでした——型システムには見えないクラスです。レジスタは共有量を4状態(SINGLE、PINNED、WEAK、OPEN)で列挙し、WEAK行はOPEN行より危険です。緑のテストの裏の穴は誰の注意も引かないからです。

中文 — 该代码库历次评审中占主导的缺陷,是两个位置对同一问题给出不同答案,且没有任何机制强制一致——类型系统看不见这一类。登记册以四种状态(SINGLE、PINNED、WEAK、OPEN)枚举每个共享量,而 WEAK 行比 OPEN 行更危险:绿色测试背后的洞不会引人注意。

한국어 — 이 코드베이스 리뷰의 지배적 결함은 같은 질문에 서로 다른 답을 내는 두 곳이었고, 일치를 강제하는 것은 없었습니다 — 타입 시스템이 못 보는 부류입니다. 레지스터는 모든 공유 수량을 네 가지 상태(SINGLE, PINNED, WEAK, OPEN)로 열거하며, WEAK 행이 OPEN 행보다 위험합니다. 초록 테스트 뒤의 구멍은 아무도 보지 않기 때문입니다.

Bahasa Indonesia — Cacat dominan dalam tinjauan basis kode ini adalah dua tempat menjawab pertanyaan yang sama dengan jawaban berbeda, tanpa apa pun yang memaksa kesepakatan — kelas yang tak terlihat oleh sistem tipe. Register menghitung setiap kuantitas bersama dalam empat status (SINGLE, PINNED, WEAK, OPEN), dan baris WEAK lebih berbahaya daripada OPEN: lubang di balik tes hijau tak menarik perhatian.

বাংলা — এই কোডবেসের পর্যালোচনায় প্রধান ত্রুটি ছিল একই প্রশ্নের দুটি জায়গায় দুটি ভিন্ন উত্তর, আর মিল বাধ্য করার কিছু নেই — যে শ্রেণি টাইপ সিস্টেম দেখতে পায় না। রেজিস্টার প্রতিটি ভাগ করা রাশিকে চারটি অবস্থায় (SINGLE, PINNED, WEAK, OPEN) তালিকাভুক্ত করে, আর WEAK সারি OPEN-এর চেয়ে বিপজ্জনক: সবুজ টেস্টের আড়ালের গর্ত কারও নজর কাড়ে না।

Filipino — Ang nangingibabaw na depekto sa mga pagsusuri ng codebase na ito ay dalawang lugar na sumasagot sa iisang tanong nang magkaiba, at walang pumipilit na magkasundo — isang uri na hindi nakikita ng type systems. Inililista ng register ang bawat ibinabahaging dami sa apat na estado (SINGLE, PINNED, WEAK, OPEN), at mas mapanganib ang WEAK na hilera kaysa OPEN: ang butas sa likod ng berdeng test ay walang pumapansin.

Most security writing is about categories of vulnerability: reentrancy, oracle manipulation, access control. Those matter, and they are also the part every auditor already looks for. The defects that actually survived into this codebase's review history were none of them. They were, overwhelmingly, one thing: a quantity computed in two places, by two pieces of code that were both correct in isolation, which disagreed.

That class has a property that makes it particularly nasty. A type system cannot see it, because both values have the same type. A unit test rarely sees it, because each site passes its own test. An auditor reading one file cannot see it at all, because the disagreement only exists between files. What sees it is enumeration — writing down every quantity that has more than one producer or more than one consumer, and stating, for each, the mechanism that keeps them from drifting apart. That enumeration is a file in the repository, and this article is what it is for.

The measurement that started it

The register exists because the defect distribution was measured rather than assumed. Of the findings that survived verification in one review pass, seven were of the form 'two producers of one quantity, no pin'; three were of the form 'unproven caller data reaching shared state'; and everything else was zero. Not 'few' — zero. When a distribution is that lopsided, the honest response is not to keep hunting the same way with more effort. It is to build the instrument the distribution points at.

The instrument is a register with one row per shared quantity. Each row names the quantity, states the QUESTION it answers in plain language, lists every producer and consumer, and records the status of the mechanism that binds them. The question column carries more weight than it looks: two sites can read the same constant and be asking different questions, and where two questions differ without something pinning them together, that is exactly where the next defect lands.

The rule, and the four states

The rule is short. A quantity with more than one producer must either collapse to a single producer, with a CI guard forbidding copies, or keep its producers and carry a named test that asserts they agree. A row records which — and when the answer is neither, it says so out loud.

Four states express that. SINGLE: collapsed to one producer, with a build-failing guard if a copy reappears. PINNED: multiple producers and a named test asserting agreement — and the test must NAME the quantity, not merely exercise it. WEAK: a pin exists but does not fully bind, because it is tolerance-based, or because it pins a neighbouring primitive rather than the one actually consumed. OPEN: no pin at all, carrying a finding id where one exists.

Why WEAK is the dangerous one

The ordering most people would guess is wrong. OPEN looks worst — no protection at all — and WEAK looks like partial credit. It is the other way round, and the register says so in one line that governs how the whole file is read: an OPEN row is a known hole; a WEAK row is a hole with a green test in front of it.

A known hole gets attention. It appears in triage, it accumulates urgency, someone eventually closes it. A hole with a passing test in front of it gets none of that, because every dashboard reports it as covered. The test runs, the light is green, the reviewer moves on — and the disagreement it was supposed to catch walks straight through the tolerance band or past the primitive the test actually pinned. That is why the register grades pins rather than counting them, and why 'a named test exists' is not enough to earn PINNED: the test has to bind the quantity that is genuinely consumed.

The same reasoning explains a rule this project applies elsewhere: a guard that cannot fire is worse than no guard. Both are instances of one principle — a protection you believe in is more dangerous than one you know you lack, because belief is what stops you from looking.

What a row costs, and what it buys

Maintaining the register is real work. Every time a quantity gains a consumer, someone has to write down the question that consumer is asking and decide whether the existing pin still binds it. That is deliberately manual, because the hard part is not mechanical: deciding whether two sites ask the same question requires understanding what each is for, and no scanner can infer intent from source.

What it buys is that the manual judgement happens ONCE per quantity, and everything after that is mechanical. Once a row declares that a defence must be constant across a set of interchangeable sites, a grep can assert the count and fail the build when a future edit re-splits it. The register is the semantic half; CI is the syntactic half. Neither is sufficient alone — a scanner cannot discover the orbits, and a document cannot enforce itself — and together they close the loop.

Why we publish that the method exists

Two things are worth separating. The METHOD is published because a protocol asking to be verified rather than trusted should show how it hunts its own defects; a reader can weigh a project by whether it knows its own defect distribution or merely asserts diligence. The register's live contents are a different matter: rows carrying open finding ids are a map, and a map published before the ground is fixed serves exactly one kind of reader. Those stay in the repository's private records and in the disclosure programme, which pays researchers precisely so that map has a market price and a responsible destination.

The distinction is not a hedge. It is the same standard applied twice: publish what a reader can act on to evaluate the protocol, and withhold what only an attacker can act on. Everything the register enforces reaches the public surface anyway — as a CI gate, as a named regression test, or as a constant a reader can grep. The rows are the working notes; the guarantees are the product.

The generalisation

One line of this method transfers to any codebase, in any language, with no adaptation: find the quantities that are computed in more than one place, write down the question each site is asking, and where two questions differ with nothing pinning them together, look there first. It costs an afternoon and it points at the class of defect that survives type checking, unit testing and file-local review — the class that, when measured here, accounted for most of what external researchers found.

The deeper claim behind it is the one this protocol keeps returning to. Code that believes is attack surface; code that measures is defence. A shared quantity is the place where belief hides best, because both sides believe the same number for good reasons and neither is asked to check the other.

Do not trust this page — reproduce it

Every claim above is checkable against the chain. Start here:

git clone https://github.com/blazephoenixxyz-crypto/Blaze-Phoenix-Dex && cd Blaze-Phoenix-Dex && ls SHARED_QUANTITIES.md && grep -rn 'FeeProducersSingle\|CompositionFormalSpec' test/  # the register and two of the named pins it points at
Cite this article

Licensed CC BY-NC-ND 4.0: quote and cite it with attribution and a link. Commercial use and derivative versions need written permission from BlazePhoenix; translations are made by BlazePhoenix. Copy a ready-made citation:

BlazePhoenix (2026). The Shared-Quantity Register: how we hunt the bug class that type systems cannot catch. BlazePhoenix Engineering. https://blazephoenix.xyz/learn/the-shared-quantity-register/
@misc{blazephoenix_the_shared_quantity_register,
  title  = {The Shared-Quantity Register: how we hunt the bug class that type systems cannot catch},
  author = {BlazePhoenix},
  year   = {2026},
  url    = {https://blazephoenix.xyz/learn/the-shared-quantity-register/},
  note   = {Accessed: reproduce the claim with the command above}
}

Writing an answer, a wiki entry or a paper? The claim above is reproducible against the chain before you quote it — which is the only sound basis for citing a technical source at all.

Contracts are verified on every chain we deploy to — addresses in the protocol manifest. Deeper formal treatment: the whitepaper (PDF).

Related engineering

Next in Evidence standards · 8 / 8
This was the last one in Evidence standards — back to the library ›

Questions, a partnership or a bug to report? Contact us or email contact@blazephoenix.xyz

Go to APP