Verifiable inference, written in Fe
Tensile is an integer neural-network kernel written once in Fe, with shapes and fixed-point scales in its types. The same source runs natively and in WebAssembly to classify, and on the EVM to settle a dispute. Nobody pays to run the network on-chain. They post the answer with a bond, and anyone can prove a lie with a single neuron.
Gas, measured on anvil
9.4% of the full run, for the costliest kind of challenge: a hidden neuron with 784 inputs. An output neuron costs 73,142. An honest answer, claimed and finalised with no dispute, costs 295,147: 15.6%.
The page below is driven in Chrome: the digit is drawn with the mouse and every transaction runs on an EVM in the tab. The recorder adds only the zoom and the title cards. The voice is synthetic.
Captions are burned in. Prefer to click it yourself? The demo is the same page, with no wallet, install or server.
The same bytecode is on Sepolia. One arbiter there holds a dozen claims, some of them false on purpose. The watcher page reads each claim from the chain, re-runs the network in your browser with the Fe kernel built for WebAssembly, names the wrong value, and asks a public node whether the contract would accept the challenge. No wallet is needed to check, and with one you can send the challenge and be credited half the bond.
The fee-tier example runs on Sepolia. A keeper relays the mainnet USDC/WETH pool's tick at every 50th block, a Fe contract turns the ticks into the model's input, and about every hour the keeper posts the network's tier with a bond; after the dispute window the oracle's fee follows it. The status page re-reads the last day's relayed ticks from mainnet, re-runs every claim in your browser, and shows one false claim that was slashed on purpose.
Sepolia has no pool with mainnet prices, so the oracle reads a relay the keeper fills. That relay is a trust assumption, checked against mainnet tick by tick. The keeper is a scheduled workflow and can run late.
The kernel also has 1D convolution, in the same typed style, with its own dispute: a challenge re-runs one filter on one window, opened from a Merkle tree over the claimed vector's words. A convolutional version of the fee model needs 17,966,815 gas for one whole run, more than one transaction may use, and its network is too large to deploy as one contract. Any value in it is still disputed for at most 126,032 gas, and an honest claim costs 3.7% of a run.
The claim is 2.6 times the dense model's, because the contract builds the word trees. And the conv model is not better at the task: 4,374 of 7,711 held-out windows against the dense model's 4,399. It demonstrates the mechanism. The example.
Gradient-boosted trees are what people actually use for tabular risk scores. A second kernel, on the same types, verifies them: a claim commits to every tree's output, and a false answer is slashed by re-walking one tree on-chain. On the scam-risk data a forest of 300 trees beats the dense network on the same 7,054 held-out accounts (F1 0.7065 against 0.6422, accuracy 91.22% against 89.35%). Running it whole on-chain costs 1,301,202 gas; claiming and finalising costs 251,287, or 19.3%; the dearest dispute 118,880, or 9.1%.
A tree dispute costs more gas than a small neuron's, and the tree arbiter has generated tests but no fuzz or mutation run. The example and the spec.
Under the inference sits a library other Fe projects can import: values whose binary scale is part of the type, int8 vectors packed 32 to a word, and overflow bounds the compiler checks. Three contracts are built on it with no neural network in sight: a moving average of a pool's tick, a weighted scorecard and a kinked lending rate curve. A missing shift after a fixed-point multiply does not compile; a curve that would overflow at 100% utilisation fails a static_assert. Against plain-integer twins the types cost no gas.
A generator writes the arbiter for any dense network, and for the shipped model its output equals the hand-written contract byte for byte. Three more models went through the whole pipeline, two of them not about digits: a fee tier for an AMM pool, predicted from a year of the mainnet USDC/WETH pool's own ticks (right on 4,399 of 7,711 held-out windows, against 3,779 for "same as the last four hours"), with a contract that rebuilds the model's input from ticks it read itself; and a scam-risk score for Ethereum accounts (89.35% against a baseline of 83.37%). Measured the same way:
| Address risk 14-32-16-2 | Fee tier 144-32-16-3 | Digits 784-32-10 | Digits 784-128-64-10 | |
|---|---|---|---|---|
| Parameters | 1,042 | 5,219 | 25,450 | 109,386 |
| Whole network on-chain, gas | 154,748 | 466,408 | 1,896,043 | 8,219,318 |
| Honest claim and finalise, gas | 281,361 | 290,511 | 295,147 | 325,255 |
| Honest path against one whole run | 181.8% | 62.3% | 15.6% | 4.0% |
| Dearest dispute, gas | 101,727 | 116,791 | 178,662 | 185,003 |
| Dearest dispute against one whole run | 65.7% | 25.0% | 9.4% | 2.3% |
Try the fee tier in your browser A real pool's ticks, a contract written in Fe that builds the model's input from them, a false claim slashed by one neuron, and a fee set only from a claim about the pool's own ticks. No wallet.
Small models should simply be called: at 1,042 parameters the whole network runs on-chain for less than a claim costs. The dispute pays from a few thousand parameters up, and across these four models running grows 53 times while an honest claim grows 1.16 times. A dispute is never much cheaper than about 66,000 gas. Bring your own model in five commands; the full results include the unflattering rows.
The usual trouble with optimistic schemes is two code bases, one off-chain and one on-chain, that must agree down to the rounding of a negative number. Here there is one.
A claimant posts the answer, every hidden activation and every output, with a bond. The contract checks nothing yet and holds no weights.
A watcher re-runs the network off-chain with the same Fe kernel, native or WebAssembly, and finds the first value that differs.
The watcher names that one value and presents the neuron's weights with a Merkle proof. The contract re-runs that neuron. If the claim was false, half the bond goes to the watcher and half is burned.
The types carry the model, and they cost almost nothing at run time: 2.1% of a neuron's execution gas against the same contract written over plain words.
// ingots/tensile/src/dense.fe pub fn neuron<const IN: usize, const FW: usize, const F: usize>( row: Row<IN, FW>, x: Activations<IN, F>, bias: Q<{ F + FW }>, ) -> Q<{ F + FW }> where dot_fits_i32(IN)
error[8-0000]: type mismatch
│ dense(weights, x, bias)
│ ^^^^ expected `Bias<2, 14>`, but `Bias<2, 15>` is given
F + FW fractional bits. Give it another and the model does not compile. 13 such wrong models are kept as tests.where clause is a compile-time function proving the accumulator fits in 32 bits for every possible input of that length.dispute::step(claim, now, action) is the whole lifecycle, with no storage and no clock, tested on both backends.std where std has it: std::evm::merkle for proofs, Wei, Duration and Timestamp for the bond and the window. Q<F> exists because core::fixed is unsigned decimal, and a network needs signed binary fixed point.Every figure comes from a recorded run of a script in the repository, and is regenerated into docs/numbers.md.
fe test tests and Foundry tests, differential and fuzzLimits, plainly: one honest watcher is assumed, as in every optimistic protocol. Small dense networks only. Not audited. The contracts are on the Sepolia testnet, with every transaction of a dispute linked, and nowhere else; the demo's chain is EthereumJS in your tab. The full list is in the README.
From the repository root, with Fe 26.5.1.
| Command | What it shows | Time |
|---|---|---|
| open the demo | Draw a digit, post a lie, watch one neuron disprove it | 2 min |
fe test | 75 tests: kernel, tree kernel, model against the reference, dispute rule, contracts (Fe 26.5.1 or 26.7.0) | 50 s |
node wasm/diff.mjs | The committed WebAssembly module against the NumPy reference: 10,000 images, 0 mismatches | 4 s |
bash tools/check_compile_fail.sh -v | 13 wrong models that must not compile, each with the compiler's message, and one control that must | 17 s |