fevm-replay

Fe ports, checked against mainnet

Five Solidity contracts from five compiler versions, rewritten in Fe to drop in for the deployed code. Each is checked against real Ethereum traffic by one command, fevm_replay certify, which writes the certificate linked below. A port only counts as verified when nothing it does differs from the deployed contract.

Fe port: TetherToken verified

USDT

TetherToken, solc 0.4.17 · ports/usdt

Mainnet transactions that ran it
21,230
…that behaved differently
0
Mutated mainnet runs that differ
0 of 324,340
Random calls that differ
0 of 1.2M
Port code reached
97%
Mutants caught
45 of 49
Gas on transfer
−4.1%
Fe port: UniswapV2Pair verified

Uniswap V2 pair

UniswapV2Pair, solc 0.5.16 · ports/uniswap-v2-pair

Mainnet transactions that ran it
1,687
…that behaved differently
0
Mutated mainnet runs that differ
0 of 513,600
Random calls that differ
0 of 1.2M
Port code reached
95%
Mutants caught
61 of 74
Gas on swap
−0.9%
Fe port: WETH9 verified

WETH9

Wrapped Ether, solc 0.4.19 · ports/weth9

Mainnet transactions that ran it
6,235
…that behaved differently
0
Mutated mainnet runs that differ
0 of 79,000
Random calls that differ
0 of 1.2M
Port code reached
89%
Mutants caught
12 of 13
Gas on balanceOf
−17.0%
Fe port: DAI verified

DAI

MakerDAO's Dai, solc 0.5.12 · ports/dai

Mainnet transactions that ran it
10,562
…that behaved differently
0
Mutated mainnet runs that differ
0 of 211,240
Random calls that differ
0 of 120,000
Port code reached
95%
Mutants caught
21 of 21
Gas on transfer
−1.5%
2 out-of-gas differences

USDC proxy

FiatTokenProxy, solc 0.4.24 · ports/usdc-proxy

Mainnet transactions that ran it
16,597
…that behaved differently
2
Mutated mainnet runs that differ
0 of 27,800
Random calls that differ
0 of 120,000
Port code reached
92%
Mutants caught
9 of 12
Gas on transfer
+0.3%

The two: callers with a gas allowance so tight that the deployed proxy fits and the port, 40 to 60 gas costlier per call, runs out.

What a certificate checks

  1. Mainnet as it happened. Every transaction of the saved blocks runs on its own pre-state with the port in place of every account holding the deployed code, and must leave the same logs, balances, nonces and storage. Differences where other code read the gas left or a code hash are labeled, and each label is proved from the call tree.
  2. Mainnet, mutated. Each transaction that touched the contract runs again with its calldata changed, or one call into the contract changed in flight, on both codes.
  3. Random calls against both codes in step, including the owner's functions, malformed calldata and dirty addresses.
  4. Mutation testing of the checks themselves: operators changed one at a time in the port's Fe source, built with fe; a check that catches no planted mistake proves nothing.

Any Fe project can run the same checks in CI with the repository's GitHub Action:

- uses: PugarHuda/fevm-replay@main
  with:
    deployed: "0xdac17f958d2ee523a2206206994597c13d831ec7"
    port-dir: ports/usdt
    contract: TetherToken
    token: usdt
    first-block: "26400000"
    blocks: "3"