Repository navigation
Expand file tree
/
Copy pathSpec.lean
More file actions
54 lines (39 loc) · 1.97 KB
/
Copy pathSpec.lean
File metadata and controls
54 lines (39 loc) · 1.97 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
import FeProofs.IndexedPackedStore.SpecSyntax
import Stele.Semantics
import Stele.SolidityLayout
import Stele.MetaSolidityLayout
import Stele.Refine
import FeProofs.Common.PackedByte
import FeProofs.Common.Storage
/-!
# FeIndexedPackedStore spec assembly (generated by `scripts/proof_skeleton.py`)
The contract is defined by `SpecSyntax.lean`; this file only names its parts: the transition
handles the proof files unfold, the storage backend (solc layout, from the
declarations), the external-call ABI, and the `Config`.
-/
open Stele ABI
namespace FeProofs.IndexedPackedStore
def contract : ContractDecl := Syntax.contractSyntax
/-! ## Transition handles, in `contract.transitions` order -/
abbrev setTransition : TransitionDecl := contract.transitions[0]! -- set(uint256,uint256)
abbrev setTwoTransition : TransitionDecl := contract.transitions[1]! -- setTwo(uint256,uint256,uint256,uint256)
abbrev getTransition : TransitionDecl := contract.transitions[2]! -- get(uint256)
/-! ## Storage layout: Fe's `StoragePackedArray<8>` at slot 0
Fe does not use solc's layout for this field: the array's words are the entries of a
`StorageMap<u256, u256>` at the array's slot, so word `w` lies at `keccak256(w ‖ 0)`, and element
`i` is byte `i % 32` of word `i / 32`. `uint8[64] pack` names the first 64 elements. -/
/-- The word and byte of element `i`. -/
def elemLoc (i : Nat) : StorageLoc :=
FeProofs.packedByteLoc (FeProofs.mapSlot (Ethereum.UInt256.ofNat (i / 32)) ⟨0⟩)
⟨i % 32, Nat.mod_lt _ (by decide)⟩
def storageLayout : StorageLayout
| { base := "pack", steps := [.aindex (.int i)] } =>
if 0 ≤ i ∧ i < 64 then some (.leaf (elemLoc i.toNat)) else none
| _ => none
def storageBackend : StorageBackend := solidityStorageBackend storageLayout
/-! ## Config -/
def config : Config :=
{ storageBackend := storageBackend
externalABI := defaultExternalCallABI
selfDeployment := genSolidityConstructorDeployment contract.ctor.params }
end FeProofs.IndexedPackedStore