arXiv:2610.19764cs.PLOct 2026

Manuscript Offprint

arXiv:2610.19764

Verifying deployed bytecode against executable EVM semantics, with exact gas and no added axioms

Seulkee Baek

Abstract

Much of Ethereum’s most consequential code is immutable bytecode: old output of unverified compilers, and protocol logic run as contract code. We show that such bytecode can be verified as it is, without trusting what produced it, without simplifying the machine it runs on, and with no axioms beyond Lean’s own. Blanc, a Lean 4 verification stack, reads fixed runtime bytes via kernel-checked certificates and states every theorem against Jaune, an executable semantics of the EVM and block processing that passes all 34,205 blockchain-test cases of Ethereum’s fixture release v20.0.2 that involve only forks that have governed mainnet since May 2025. Eight artifacts, deployed from 2017 to 2026, come from seven compiler versions and an assembler. For the EIP-7002 contract, we prove that the end-of-block call to it, whose failure would invalidate the block, succeeds whatever its storage holds, and that each block’s withdrawal requests are exactly the oldest pending submissions; mainnet met these theorems’ starting premises when Prague began. For a Uniswap V2 pair, we prove that after any valid history whose hashed slots stay apart, from any checkpoint representing its Solidity model’s state, the storage represents that model replayed over exactly the committed calls, a balanced liquidity ledger stays balanced, and, under a premise on token answers, geometric-mean reserves per share fall only through the protocol fee. Exact gas makes liveness provable: a tracked WETH9 holder without code can withdraw by a transaction whose gas has a closed form, matching all 3,748 comparable mainnet receipts of its shape in 30,000 blocks. On Curve pool bytes compiled with the lock bug exploited in 2023, Jaune executes such a reentrancy from deployment; for bytes from a fixed compiler, we prove the lock excludes it. AI agents wrote the proofs in fifteen days under one author’s direction, atop an existing stack.

Statements about Blanc’s theorems, and every figure drawn from its Git history, refer to Blanc commit 5048a51f on its main branch and to the Jaune revision it pins, 2737c8eb. Unless a section says otherwise, on-chain figures were read at block 26,141,229 (7 October 2026, 14:53 UTC) from the public providers named in Appendix B. We say that a result uses no added axioms when everything it depends on reaches only the three standard axioms of Lean’s core library, propext, Classical.choice and Quot.sound, with no sorry, no native evaluation and no foreign function anywhere in its proof.

1 Introduction

On 30 July 2023, attackers drained several Curve liquidity pools of assets worth tens of millions of dollars [LlamaRisk]. The pools' source marked every function that moves liquidity with the same reentrancy key, @nonreentrant('lock'), which asks the compiler for one lock shared by all of them. The affected Vyper versions, 0.2.15, 0.2.16 and 0.3.0, instead reserved a separate lock slot for every decorated function [VyperPM]. An attacker could receive ether from remove_liquidity while it held its lock, call add_liquidity, find that function's lock free, and mint pool tokens against a pool that was only half updated. A proof about the source that took the compiler at its word would have certified the guard; the defect could be seen only in the bytes.

The bytes are what users ultimately rely on: every node executes them, nobody can patch them, and many are old. WETH9, the canonical wrapped ether, holds about 2.16 million ether in 3,124 bytes that solc 0.4.19 produced in December 2017. The Beacon deposit contract, 6,358 bytes produced by solc 0.6.11, is the only way onto the beacon chain: every validator on mainnet was created by one of the 2,565,727 deposits made through it. One 11,293-byte runtime, produced by solc 0.5.16 in 2020, runs at every one of the 524,109 trading pairs that Uniswap V2's factory has created (Appendix B). 1^{1} And since the Prague upgrade, every withdrawal request triggered from the execution layer passes through a 504-byte contract

1^{1}Balances, the deposit contract’s get_deposit_count(), and the factory’s allPairsLength(), at block 26,141,229 (7 October 2026), read from three separately operated public providers, which agreed (Appendix B).

written in assembly, and a block whose end-of-block call to that contract fails is invalid. A proof about the source of any of these reaches the bytes only through a link between source and bytes: trust in the compiler, a verified compiler, or a translation checked after the fact, by translation validation [Pnueli98] or an equivalence check of the bytes against a specification [Act]. None of the tools that produced these bytes is a verified compiler; a proof about the bytes themselves needs no such link.

We ask six questions of any verification result about such code.

  1. Is it about the code that runs? A theorem about source code, a model or a recompilation reaches the deployed contract only through the link between source and bytes, and the 2023 incident shows what trusting a compiler can cost.

  2. What does the proof rest on? A proof checked by a small kernel rests on less than one that admits lemmas, evaluates by compiled code, or adds axioms such as the convenient and false axiom that Keccak-256 is injective.

  3. Was the code written for the verifier? Code written in a verifier's language, or emitted by a verifier's own compiler, is rarely the code that holds today's assets.

  4. Is the machine the real machine? The semantics should be the whole EVM, with every opcode, precompile, transaction type, fork rule and gas cost, and executable, so that the official conformance suite can test it.

  5. Does the theorem matter? It should tell users what they want to know: that balances are backed, a queue delivers what was put in, a lock excludes what it should.

  6. Does it say the contract works? A contract that always reverts preserves every invariant its storage satisfies. Users also need liveness, the assurance that a transaction they send is admitted and succeeds, and on the EVM liveness is a statement about gas. Our liveness theorems execute a transaction at the state a history reaches, or at a given position of a given valid block; whether any block will include it is outside them.

Each question has been answered before, though rarely together. Symbolic tools such as hevm, halmos and the Certora Prover reach bytecode at a scale, and with a degree of automation, that interactive proof does not approach, each approximating Keccak-256 in a documented way [hevm; halmos; Certora]. Bytecode of contracts in our corpus, of other builds of their sources, or of earlier versions of them, has been verified in K, with gas [KEVM-Deposit; RV-DepositSol; dapp-UniV2], and checked with Halmos, loops bounded [Halmos-Pectra]; verified compilers cover the code they emit, not code already deployed [DeepSEA; powdr; Solidus; Verity]; and EquiVM proves that local builds of more than twenty contracts refine whole-interface specifications, leaving gas out [EquiVM]. To our knowledge no prior result answers all six questions at once; Section 6 describes what each system does that we do not.

This paper shows that the six answers can be had together, for ordinary compiler output and hand-written assembly that our tools had no part in shaping. Blanc [Blanc] is a verification stack for the EVM in Lean 4 [Lean4], with its own contract language and compiler; the work reported here is a recent extension that lifts bytecode Blanc did not produce. An untrusted program proposes a structured reading of the bytes, a certificate, which a decision procedure evaluated by Lean's kernel accepts or rejects against the literal bytes. Generic theorems carry reasoning about the reading back to the bytes, for safety, for executions of any outcome, and for liveness given enough gas. Every theorem is stated against Jaune [Jaune], an executable semantics of the EVM and of block processing, also in Lean, which passes every blockchain test of Ethereum's fixture release tests@v20.0.2 that involves only the forks that have governed mainnet since May 2025 (Section 3.1). No declaration in the 725,186-line Blanc library reaches an axiom beyond Lean's three, and Lean's kernel, replaying the compiled library in a separate process, accepts every declaration (Section 3.11).

Here is the kind of statement this makes possible.

WETH9 exit. Fix a checkpoint at which the WETH9 bytes are installed and the contract's storage satisfies its footprint invariant, and take any history of valid blocks from there, under the rules of Prague, Osaka, BPO1 or BPO2, in which the storage keys touched do not collide. Let E be an account without code, so neither a contract nor an account with an EIP-7702 delegation, whose balance key is tracked and whose WETH balance is at least w (an amount in wei). A signed type-2 transaction from E calling withdraw(w), with zero value and no access list, the usual chain, nonce, fee, funding and block-room conditions, a fee recipient other than E and the contract, and a gas limit between its intrinsic cost plus the frame's cost plus 811 and 2242^{24}, is admitted by Jaune's processTransaction at the state the history reaches. In the world it returns, E's WETH balance is w lower, the contract has paid w wei to E, no other storage has changed, and the transaction has used exactly

gasUsed = 21,000 + 4·tokens(calldata) + (13,940 if w≠0w \neq 0, otherwise 4,440) - (4,800 if w≠0w \neq 0 and the withdrawal empties the balance)

where tokens(calldata) counts each zero byte once and each nonzero byte four times, so that the calldata costs 4 gas per zero byte and 16 per nonzero byte.

This one theorem answers all six questions (Section 2): it concerns the 3,124 bytes that three providers return for 0xC02a...6Cc2, 2017 compiler output never meant to be verified, under every fork that has governed mainnet since 7 May 2025; its proof rests only on the kernel and Lean's three axioms; and it tells a holder that an exit transaction is admitted at the state any such history reaches, pays out, and costs exactly the stated gas. In a window of 30,000 blocks, every mainnet withdrawal of this shape whose starting balance the logs determine, 3,748 of 3,780, used exactly the predicted gas (Section 2.4).

A seventh question is whether a theorem’s starting assumption holds of the contract on mainnet today. For WETH9, the deposit contract, 3Crv and the Uniswap pair, deployed long before Prague, we answer it only for a modeled fresh deployment; the live contracts need an invariant checked on a complete enumeration of their storage (Section 7), which we have not done. The EIP-7002 contract, below, is the exception, and the CircuitBreaker’s live registry passes its finite check, evaluated by a script rather than by the kernel (Section 7).

WETH9 is one of eight artifacts (Table 2). For the protocol itself, the most consequential is the EIP-7002 contract, through which every execution-layer withdrawal request passes and whose failing end-of-block call would invalidate the block. Whatever its storage holds, as long as its canonical code is installed, the client's end-of-block call to it succeeds, using at most 210,000 gas, and no history removes that code. Each block's withdrawal requests are exactly the first queued entries, at most sixteen, in order. Each request records exactly one committed submission, and no submission is dropped, duplicated, reordered or emitted early. These theorems need no hash premise and no entry condition on the frames that run the contract. They cover every fork since the contract's use began at Prague's activation, and mainnet's state at that moment, as providers report it, met their starting premises (Section 5.1). The other results replay histories exactly, for the deposit contract's accumulator, 3Crv's ledger and the Uniswap pair's nested calls, with share-value bounds for the pair under a premise on the tokens' actual answers. They keep the CircuitBreaker's registry consistent under universal hash premises, which a finite tier replaces by decidable checks for a single update. And they separate the two Curve pool implementations, executing the reentrancy on the vulnerable bytes and proving that the fixed bytes' lock excludes it.

This paper makes the following contributions.

• A corpus of machine-checked theorems about eight artifacts deployed on Ethereum mainnet between 2017 and 2026, compiled by solc 0.4.19, 0.5.16, 0.6.11 and 0.8.34 and by Vyper 0.2.4, 0.2.15 and 0.3.7, or written in assembly, among them the protocol's own EIP-7002 contract, whose end-of-block call is proved to succeed whatever its storage holds (Section 4).

• A method for bytecode produced by someone else's tools, with no compiler, no added axiom and no abstraction of the EVM in its trust base: kernel-checked certificates, histories replayed over exactly the calls whose effects survived, other contracts' answers as inputs, and hash premises over the keys a history touches or decidable by the kernel (Section 3).

• Liveness from exact gas, from a single frame up to a signed transaction admitted after any valid history, with explicit premises about the callees a function depends on. The theorems prove admission and execution, not inclusion (Section 3.8).

• Statements that can fail. Kernel-checked counterexamples show that key premises cannot be dropped; one refutes a premise our own earlier statements made, and another the natural guarantee that every EIP-7002 submission paid the EIP’s fee (Sections 3.10, 4.2 and 4.5).

• A case study in agent-written proof. The lift was written by AI agents in fifteen days, under one author's direction, on top of an existing stack; the bottleneck was not writing proofs but knowing that their statements mean what they should (Section 5.3).

Section 2 examines the WETH9 theorem, Section 3 the semantics and the method, Section 4 the corpus and Section 5 the evaluation; Sections 6 and 7 discuss related work and limitations.