Repository navigation
Expand file tree
/
Copy pathGet1.lean
More file actions
44 lines (37 loc) · 1.79 KB
/
Copy pathGet1.lean
File metadata and controls
44 lines (37 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import FeProofs.PackedStore.Dispatch
import FeProofs.PackedStore.Lanes
import FeProofs.Common.Basic
/-!
# FePackedStore `get1()`
Arm entry pc 260: call-value check, then `SLOAD(packedSlot)` and the lane extraction; the lane is
returned zero-extended to a word.
-/
open Stele ABI Ethereum Ethereum.EVM Reasoning.Theory Reasoning.Reach
namespace FeProofs.PackedStore
set_option maxRecDepth 2000000
theorem fePackedStoreGet1Body {σ σ₀ A I} {g : UInt256}
(hcode : I.code = fePackedStoreBytecode) (hsize : I.calldata.size < UInt256.size)
(hsel : selIs I (fePackedStoreSelBytes 0)) :
runtimeRefinementFor config contract σ σ₀ g A I := by
have hsz : 4 ≤ I.calldata.size := calldata_size_ge_of_selIs I (fePackedStoreSelBytes 0) rfl hsel
have hd := fePackedStoreDispatch_get1 hsel
obtain ⟨k, C, rd⟩ := fePackedStoreReachGet1Body (g := Sat256.ofUInt256 g) (σ := σ)
(σ₀ := σ₀) (A := A) hcode hsz hsize hsel
have hdec : config.externalABI.decodeCalldata? (get1Transition.params.map Param.name)
(transitionSignature get1Transition).paramTypes I.calldata = some ∅ := by
show decodeCalldata [] [] I.calldata = some ∅
exact decodeCalldata_empty_ok hsz
by_cases hwv : I.weiValue = ⟨0⟩
swap
· nonpayable_revert rd hcode hd hwv
rd_run rd using [hwv]
rw [keccak_packedSlot] at rd
u256_lits at rd
rw [toByteArray_write32_read_back _ _ 0 (Nat.zero_le _), packedByte_lane1] at rd
have hbody := nonpayableReturnExprBodyReturns (cfg := config) (contract := contract)
(imms := ∅) (evm := initState σ σ₀ (Sat256.ofUInt256 g) A I) (locals := ∅)
(by simp only [initState]; exact hwv)
(evalLaneCast "lane1" 1 (by simp) rfl rfl)
exact rd.reEquivExecution hcode hd hdec hbody
(returnEquiv_of_encode (uint256ReturnEncoding _))
end FeProofs.PackedStore