WorkFormal verificationEmet
No proof,
no upgrade.
A contract upgrade needs a proof. Emet checks a Lean claim on NEAR testnet, then lets a separate gate install the matching registered patch.
NEAR testnet · One-expression proof · v2
- 5
- candidate refund expressions
- 4
- candidates with counterexamples
- 1
- repair satisfies the rule
- v2
- documented checker correction
Recorded evidence
One line. Five candidates.
A refund must fit within the requested amount, the deposit and the receiver’s balance. It must also return the full amount that those three limits allow. Four candidate expressions fail that rule; the NEAR Intents team’s fix satisfies it.
balance_left.min(requested_refund)
A counterexample breaks the rule.
The expression returns 100; the rule requires 1. It refunds more than was deposited.
- Requested
- 100
- Deposited
- 1
- Balance
- 1001
Published proof results from source f363c45. This viewer does not run the checker. Inspect the data or ask the testnet checker.
The case uses a previously known NEAR Intents defect and the team’s own repair. Emet did not discover the incident. Its experiment asks whether a contract can refuse a registered upgrade until the required proof is checked.
The rule
Turn a comment into a condition for an upgrade.
The rule describes one refund expression. It does not assert that every operation in the contract is correct. In the model, the result must be the smallest of the three amounts:
def Rule (a : Args) (r : Nat) : Prop :=
r ≤ a.requested ∧
r ≤ a.deposited ∧
r ≤ a.balance ∧
(r = a.requested ∨ r = a.deposited ∨ r = a.balance)- 01 / Candidate
Register the patch
The deployer pairs a permitted binary with its source. That pairing remains part of the trust boundary.
- 02 / Proof
Check the Lean claim
The checker contract checks the submitted proof for the candidate’s claim on NEAR testnet.
- 03 / Certificate
Record the result
A separate board records the certificate used by the upgrade gate.
- 04 / Upgrade
Match before installing
The gate permits the registered upgrade only when its required certificate is present.
Demonstration
Follow the contract through the upgrade.
The project video walks through the case. The live demonstration lets you select a patch and ask the NEAR testnet checker for its result.
Reproduce
Check the record, then inspect the boundary.
The verification script checks recorded evidence and reads NEAR testnet. The repository also describes rebuilding the Lean export and binaries. Its first deployment had an unsound checker extension; the disclosed v2 fix is part of the record.
git clone https://github.com/formalized-si/emet
cd emet
./verify.shResearch summary
- Problem
- Can a contract's upgrade authority enforce a small mathematical rule before accepting a registered patch?
- Result
- On NEAR testnet, a proof-checker contract checks a Lean claim, a board records its certificate and a separate gate permits a matching registered upgrade. The v2 demonstration uses a previously known NEAR Intents refund defect and the Intents team's fix.
- How to check it
- The repository's ./verify.sh checks recorded evidence and makes read-only testnet RPC calls. Optional rebuild commands compare the Lean export and contract binaries. Recorded transactions show rejected candidates and the certified upgrade.
- Limits
- The proof concerns one expression, not the entire contract or binary. The extractor, compiler, source-to-binary pairing, checker and NEAR remain trusted. The first deployment was unsound; v2 fixes that disclosed checker-extension bug. Emet did not discover the Intents incident.
- Research question
- How can source-to-binary correspondence and the trusted checker be strengthened while supporting rules beyond one expression?
Emet · Formalized · All work ↗