Fe port certificate

UniswapV2Pair

Port source ports/uniswap-v2-pair, runtime code hash 0x443e928a28d99481a56b924e038dbc0427a440e9ede17cc51aaf017d20492983 (5878 bytes), in place of the deployed code with hash 0x5b83bdbcc56b2e630f2807bbadd2b0c21619108066b92a58de081261089e9ce5 (11293 bytes). Blocks /root/v2blocks/0x192d500 to /root/v2blocks/0x192d5c7.

No behavior difference: every transaction that ran the port, every mutation of them and every random call behaved as on the deployed code.

Mainnet, as it happenedpassed
Mainnet, mutatedpassed
Random callspassed
Mutants: the unchanged portpassed

Mainnet, as it happened

Each transaction of the blocks ran on its own mainnet pre-state, with the port in place of every account holding the deployed code, and was compared with the chain: status, logs, every balance, nonce and storage slot. Only gas may differ.

Blocks200
Transactions69643
Transactions that ran the port856
Identical to the chain806
Differ where other code read the gas left47
  of which part at or under that code47
Differ where other code read code hashes3
Only the deployed code ran out of gas0
Behave differently0

Gas per call in identical transactions

FunctionIn the port's sourceCallsDeployedPortChange
Swapsrc/lib.fe:4678735830857761-0.9%
Token0src/lib.fe:3334921362063-3.4%
Token1src/lib.fe:3372620491976-3.5%
GetReservessrc/lib.fe:34180321852088-4.4%
Factorysrc/lib.fe:3294324022329-3%
KLastsrc/lib.fe:353123882316-3%
TotalSupplysrc/lib.fe:234723882315-3%
Approvesrc/lib.fe:262173427190-2%
TransferFromsrc/lib.fe:27413544934939-1.4%
Burnsrc/lib.fe:4181172325167369-2.8%
Mintsrc/lib.fe:36915730451563-10%
Price0CumulativeLastsrc/lib.fe:345223872315-3%
Price1CumulativeLastsrc/lib.fe:349124092337-2.9%
Syncsrc/lib.fe:55073349833902+1.2%
Transfersrc/lib.fe:26812984029614-0.7%

Mainnet, mutated

Each transaction that touched the deployed code ran again with its calldata changed, or with one call into the contract changed in flight, on both codes, gas free.

Transactions856
Runs17120
Identical16591
Differ where other code read the gas left or code hashes489
  of which code hashes49
  of the rest, part at or under the code that read the gas left440
Only the deployed code ran out of gas40
Differ after an address-shaped word got upper bits0
Differ after the calldata was cut short0
Differ0

The port ran 2556 of its 3466 instructions (73.7%) in these runs.

Random calls

1,000 sessions of up to 60 random calls each, against both codes in step, checking the pair's invariants after every call.

Well-formed calls49464
Well-formed calls that differ0
Calls with short calldata that differ0
Calls with dirty addresses that differ0
Invariants broken0

The port ran 3299 of its 3466 instructions (95.1%).

How sharp the checks are

Mutants of the port's source, one operator changed each, built with fe and put through random calls and then mutations of the first ten blocks. The unchanged port passed the same checks first.

Operators in the source74
Mutants built74
Killed by random calls61
Killed by mainnet mutations0
Survived13

82.4% killed. A survivor is a blind spot of the checks or a change that means the same; each deserves a look:

line 522: if mul(adjusted0, adjusted1) <= mul(mul(reserve0, reserve1), 1_000_000) {
line 675: let size: usize = (if reason.len >= 32 { 132 } else { 100 })
line 681: if reason.len >= 32 {
line 735: if x <= y { x } else { y }
line 740: if y >= 3 {
line 742: var x = y / 2 - 1
line 749: if y == 0 { 1 } else { 0 }
line 754: if balance >= left {
line 809: if elapsed >= 0 && reserve0 != 0 && reserve1 != 0 {
line 847: if root_k >= root_k_last {
line 851: if liquidity >= 0 {
line 856: } else if last == 0 { k_last = 0 }
line 928: if data.len() != 0 { return }

Made by fevm-replay certify, written in Fe and running fevm, the EVM written in Fe.