Part V · Evidence and wrap-up

Evidence, source matching and the P0 wrap-up

By KangPublished: Chain snapshot: , block 12117419

“I have the code” and “I can prove this code is what runs on-chain” are different things. So are “all tests pass” and “there are no bugs”.

What P0 was

Phase 0 (P0) was a technical review and wrap-up of all the earlier Sepolia experiments: read-only on-chain checks, source and storage-layout review, Foundry tests, preparation for public source verification, and finally a list of decisions D-01 to D-05. It was the project’s own review, not a certificate from a professional third-party audit.

Conclusion: PASS WITH FINDINGS

Severity Count Items
Critical 0 —
High 0 —
Medium 1 F-V3-001: type(uint256).max approval overflows; no infinite allowance
Low 3 F-V3-002 dust truncation (not triggered on-chain now); F-V3-003 visible sum can drift if dust is injected; F-ALLOW-001 leftover MBox-Burn allowance (revoked by D-01)
Info 6 Event units (historical logs are in old units); centralised upgrade power; unused onlyOwner; V1/V2 source cannot be reproduced exactly from current files; npm audit (tooling); public RPC has no archive

No Critical or High issue was found that could let current test assets be stolen, minted or taken out of control.

Test layers: each answers a different question

Three layers: unit tests 49/49 pass; fuzz 9 tests × 1000 runs pass; invariant 256 runs × 100 calls = 25,600 calls with 4 invariants passing. Side note: beyond tests, check on-chain evidence and source matching. Bottom: all green does not mean no bugs; 1 Medium, 3 Low, 6 Info remain.
Figure 7 ·

P0 used several layers of tests, and every layer has limits and blind spots.

Open the full-size diagram in a new tab
Layer Actual parameters Result What it really means
Unit tests One run 49 / 49 pass (Counter 5, MBox 9, MBox-Burn 9, UBOX V1 6, V2 6, V3 14) The specific cases someone wrote down pass
Fuzz 1000 runs each, seed 0x5030 9 / 9 pass Assertions hold across many random inputs
Invariant 256 runs × 100 calls = 25,600 calls 1 suite, 4 invariants pass Under this test strategy the target properties were not broken

The tests used Foundry 1.9.0 with addresses generated by the test framework only, not the local private keys, and no production contract logic was changed to make tests pass.

Two instructive side stories

  • Fuzzing failed twice along the way: the cause was the assertion order in the test oracle (the test code that computes the expected result). The test was fixed; the contracts were not changed. A failing test does not always mean a buggy contract; the test itself can be wrong.
  • 16 unexpected Handler reverts: in the invariant run, batchTransferFrom was called 3,166 times and 16 of those calls (about 0.5%) reverted in a way the Handler did not expect. The whole Handler call rolled back and the invariants still held. P0 treated this as residue in the test scaffolding (an oracle edge case), not a contract bug; the careful next step is a minimal reproduction to confirm it is an expected constraint.

Source matching: Sourcify and Etherscan

What lives on-chain is bytecode, not source code. Source verification recompiles the source you submit with the same compiler settings; if the bytecode matches what is on-chain, the source is published and marked verified. (Appendix B explains how to get an Etherscan API key.)

Sourcify: all 8 addresses matched

Sourcify has two common results: exact_match (everything matches, including metadata) and match (the bytecode matches but the metadata does not entirely). Of the 8 addresses, 5 are exact_match and 3 are match, so you cannot call them all “exact”.

Why only “match” for V1 and V2? Chapter 14 changed V1’s source for V3, and at the time the workspace had no Git history, so the deployed version could not be retrieved. P0 rebuilt the historical source so that the main bytecode matches the chain, but the metadata (which includes a hash of the source) does not. The rebuilt source is kept as a separate historical snapshot and did not overwrite the current files.

Etherscan: submitted, still queued at the snapshot

All 8 contracts were submitted through the Etherscan API V2 (chainid=11155111) and each received a submission ID (GUID). But as of 2026-11-12 15:39 Singapore time, the status check still returned Pending in queue and getsourcecode still showed them as unverified. It must not be described as verified. Linking the proxy (verifyproxycontract) returned success and recognised V3 as the implementation, but noted “implementation saved (unverified - without ABI)”.

Receiving a GUID means “queued”, not “passed”.

V4: local only, never on-chain

Decision D-04 designed a UBOX V4 locally to fix F-V3-001 and the dust issues:

  • Storage-compatible: _scale stays in slot 58 and the new _v4Initialized is appended in slot 59, without reordering old slots.
  • initializeV4() runs only once and does not mint again; the implementation locks initialisation in its constructor.
  • type(uint256).max becomes an infinite-allowance sentinel: stored without scaling and never decremented when used.
  • New dustOf and sweepDust move invisible dust to another address without changing total supply.
  • Tests: unit 10/10 pass; fuzz 3/3 × 1000 (seed 0x5030) pass; a fork simulation against the latest Sepolia state passed (deploy about 2,777,602 gas, upgrade about 72,181 gas; after the upgrade supply 100, A 99.99, B 0.01, zero dust).

V4 was not deployed, signed or broadcast. A fork simulation produces no real transaction and no transaction hash. At the snapshot the UBOX proxy still pointed to V3.

Decision status

Decision What Outcome
D-01 Revoke the leftover MBox-Burn allowance Done on-chain (block 12117312, Chapter 11)
D-02 Submit source verification to Etherscan 8 submitted; still queued at the snapshot, not confirmed
D-03 Verify V1/V2 with rebuilt historical source Sourcify match, not exact
D-04 UBOX V4 Local only: development, tests and fork simulation; not on-chain
D-05 Local Git archive Local repository created (root commit 516dcf6); no remote, nothing pushed

A repeatable chain of evidence

  1. Find the address and its deployment/upgrade transactions; confirm the network is Sepolia (chainId 11155111).
  2. Find the matching compiler settings, source files and metadata; understand the difference between exact match and match.
  3. Read the proxy’s current implementation address; do not mistake a historical implementation for the current one.
  4. For any state change you want to prove, check transactions, events and storage reads around the relevant block.
  5. Record the source, time, block height, commands, results and anything uncertain.

It is like checking an app upgrade: look not only at the installer version, but at what is really running in production, its configuration and the migrated user data.

Limits of P0

  • The public RPC has no archive data, so pre-upgrade blocks could not be forked; P0 rebuilt the upgrade path locally instead and said so plainly (it did not report an unperformed fork as passing).
  • The static analyser Slither was not run (not installed; optional).
  • The next round only needs to track D-02’s final result and reproduce the 16 Handler reverts, rather than extending P0 forever.