Repository navigation
Expand file tree
/
Copy pathSelectors.lean
More file actions
56 lines (43 loc) · 2.06 KB
/
Copy pathSelectors.lean
File metadata and controls
56 lines (43 loc) · 2.06 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
45
46
47
48
49
50
51
52
53
54
55
56
import Ethereum.Semantics
/-!
# FePackedStore selectors
Generated by `scripts/scaffold.py lean`: the selector table in `contract.transitions` order,
the selector predicates, and one kernel-checked keccak fact per ABI signature. The bridge from
each Stele transition's signature string to its entry (`transitionSigStr … = "…"`) is added by
the proof skeleton once `Spec.lean` exists.
-/
open Ethereum Ethereum.EVM
namespace FeProofs.PackedStore
/-- The 4-byte selector of `I`'s calldata equals `sel`. -/
abbrev selIs (I : ExecutionEnv) (sel : ByteArray) : Prop :=
(sel == I.calldata.extract 0 4) = true
/-- Function selectors in `contract.transitions` order (5 entries). -/
def fePackedStoreSelBytes : ℕ → ByteArray
| 0 => ⟨#[0x05, 0x4c, 0x1a, 0x75]⟩ -- get1()
| 1 => ⟨#[0x90, 0xbb, 0x7b, 0x44]⟩ -- get0()
| 2 => ⟨#[0x92, 0xcf, 0x1e, 0xf5]⟩ -- setBoth(uint256,uint256)
| 3 => ⟨#[0x9b, 0xc3, 0x9d, 0x3c]⟩ -- set1(uint256)
| _ => ⟨#[0xf2, 0x6f, 0xee, 0xc9]⟩ -- set0(uint256)
set_option maxHeartbeats 0
set_option maxRecDepth 1000000
/-- `keccak256("get1()")[0:4] = 0x054c1a75`. -/
theorem get1SelectorFact :
(Ethereum.KEC (String.toByteArray "get1()")).extract 0 4 = fePackedStoreSelBytes 0 := by
decide +kernel
/-- `keccak256("get0()")[0:4] = 0x90bb7b44`. -/
theorem get0SelectorFact :
(Ethereum.KEC (String.toByteArray "get0()")).extract 0 4 = fePackedStoreSelBytes 1 := by
decide +kernel
/-- `keccak256("setBoth(uint256,uint256)")[0:4] = 0x92cf1ef5`. -/
theorem setBothSelectorFact :
(Ethereum.KEC (String.toByteArray "setBoth(uint256,uint256)")).extract 0 4 = fePackedStoreSelBytes 2 := by
decide +kernel
/-- `keccak256("set1(uint256)")[0:4] = 0x9bc39d3c`. -/
theorem set1SelectorFact :
(Ethereum.KEC (String.toByteArray "set1(uint256)")).extract 0 4 = fePackedStoreSelBytes 3 := by
decide +kernel
/-- `keccak256("set0(uint256)")[0:4] = 0xf26feec9`. -/
theorem set0SelectorFact :
(Ethereum.KEC (String.toByteArray "set0(uint256)")).extract 0 4 = fePackedStoreSelBytes 4 := by
decide +kernel
end FeProofs.PackedStore