TensileFe Builders Challenge, FE-019

Verifiable inference, written in Fe

A false answer on-chain, caught by re-running one neuron.

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.

Two and a half minutes, recorded in real time

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.

On a public chain: be the watcher

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.

Running on real data: a fee tier for a mainnet pool

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.

Watch it live Addresses and every transaction

Convolutions: too big to run, still cheap to dispute

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.

Tree ensembles get the same dispute

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.

Also a fixed-point library for Fe

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.

Library guide API reference

A dispute is priced by one neuron, not by the network

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
Parameters1,0425,21925,450109,386
Whole network on-chain, gas154,748466,4081,896,0438,219,318
Honest claim and finalise, gas281,361290,511295,147325,255
Honest path against one whole run181.8%62.3%15.6%4.0%
Dearest dispute, gas101,727116,791178,662185,003
Dearest dispute against one whole run65.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.

How a lie gets caught

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.

  1. Claim

    A claimant posts the answer, every hidden activation and every output, with a bond. The contract checks nothing yet and holds no weights.

  2. Watch

    A watcher re-runs the network off-chain with the same Fe kernel, native or WebAssembly, and finds the first value that differs.

  3. Challenge

    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.

Why this is a Fe project

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
  • Scales are computed in the types. A bias must have the scale of a weight times an activation, F + FW fractional bits. Give it another and the model does not compile. 13 such wrong models are kept as tests.
  • Overflow is ruled out at compile time. The where clause is a compile-time function proving the accumulator fits in 32 bits for every possible input of that length.
  • Effects make the security argument readable. Of the arbiter's handlers, exactly one declares that it can send ETH.
  • The dispute rule is a pure function. dispute::step(claim, now, action) is the whole lifecycle, with no storage and no clock, tested on both backends.
  • Built on 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.

Measured, not asserted

Every figure comes from a recorded run of a script in the repository, and is regenerated into docs/numbers.md.

0mismatches on all 10,000 MNIST test images, across the NumPy reference and the native, WebAssembly and EVM builds
59 / 59faults planted in the arbiter and caught, 11 of them by the compiler
85 + 45fe test tests and Foundry tests, differential and fuzz
1.26xthe gas of a hand-written Solidity twin, per claim (solc via-IR). Fe is not cheaper here, and the table says so

Limits, 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.

Check it yourself

From the repository root, with Fe 26.5.1.

CommandWhat it showsTime
open the demoDraw a digit, post a lie, watch one neuron disprove it2 min
fe test75 tests: kernel, tree kernel, model against the reference, dispute rule, contracts (Fe 26.5.1 or 26.7.0)50 s
node wasm/diff.mjsThe committed WebAssembly module against the NumPy reference: 10,000 images, 0 mismatches4 s
bash tools/check_compile_fail.sh -v13 wrong models that must not compile, each with the compiler's message, and one control that must17 s