Repository navigation
Expand file tree
/
Copy pathConstructor.lean
More file actions
47 lines (38 loc) · 2.12 KB
/
Copy pathConstructor.lean
File metadata and controls
47 lines (38 loc) · 2.12 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
import FeProofs.Identity.Common
import FeProofs.Identity.CreationBlocks_001
import FeProofs.Common.Constructor
/-!
# FeIdentity constructor correctness
Creation-code equivalence: the non-payable guard, then `CODECOPY` of the 58-byte runtime and its
`RETURN`, composed from the creation summaries.
-/
open Stele ABI Ethereum Ethereum.EVM Reasoning.Theory Reasoning.Reach
namespace FeProofs.Identity
/-- The initcode's `CODECOPY(0, 19, 58)` into empty memory reads back as the runtime code. -/
theorem feIdentityCreation_runtime_copy :
(feIdentityCreationBytecode.write (UInt256.ofNat 19).toNat ByteArray.empty
(⟨0⟩ : UInt256).toNat (UInt256.ofNat 58).toNat).readWithPadding
(⟨0⟩ : UInt256).toNat (UInt256.ofNat 58).toNat = feIdentityBytecode := by
native_decide
theorem feIdentityCtorRet {σ σ₀ : AccountMap} {A : Substate} {I : ExecutionEnv} {g : Sat256}
(hcode : I.code = feIdentityCreationBytecode) (hwv : I.weiValue = ⟨0⟩) :
RDret feIdentityCreationBytecode g (initState σ σ₀ g A I) σ feIdentityBytecode := by
have hcode' : I.code = feIdentityCreationBytecode ++ ByteArray.empty := by
rw [ByteArray.append_empty]; exact hcode
have rd := RD.initState (g := g) (σ := σ) (σ₀ := σ₀) (A := A) hcode'
rd_run rd using [hwv]
rwa [ByteArray.append_empty, feIdentityCreation_runtime_copy] at rd
theorem feIdentityCtorRev {σ σ₀ : AccountMap} {A : Substate} {I : ExecutionEnv} {g : Sat256}
(hcode : I.code = feIdentityCreationBytecode) (hwv : I.weiValue ≠ ⟨0⟩) :
RDrev feIdentityCreationBytecode g (initState σ σ₀ g A I) := by
have hcode' : I.code = feIdentityCreationBytecode ++ ByteArray.empty := by
rw [ByteArray.append_empty]; exact hcode
have rd := RD.initState (g := g) (σ := σ) (σ₀ := σ₀) (A := A) hcode'
rd_run rd using [isZero_eq_zero_of_ne hwv]
rwa [ByteArray.append_empty] at rd
theorem feIdentityConstructorCorrect :
typedConstructorRefinement config feIdentityCreationBytecode contract
(fun _ => feIdentityBytecode) :=
FeProofs.nonpayableEmptyConstructorCorrect rfl rfl rfl
feIdentityCtorRet feIdentityCtorRev
end FeProofs.Identity