Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
289fbdd
ERC20 code generated by VC
jkopanski Aug 5, 2024
8966ea2
totalSupply verification
jkopanski Aug 6, 2024
bb2c323
Explicitly match none case
jkopanski Aug 22, 2024
bef6cf9
Additional Address lemmas
jkopanski Aug 22, 2024
a154fbd
EVM state reasoning lemmas
jkopanski Aug 26, 2024
e9f9951
Verify helper for accessing dynamic arrays
jkopanski Aug 22, 2024
561e7f8
[wip] Useful lemmas, mostly regarding memory
jkopanski Sep 10, 2024
e748061
keccak based proof
jkopanski Sep 26, 2024
1b79eb4
Remove unneeded `aesop` Fixes build of `State.lean`
Coda-Coda Sep 27, 2024
ee2c85c
Add `mstore_preserves_keccak_map` lemma and use it to progress the proof
Coda-Coda Sep 27, 2024
805f3cd
Spec and proof for the address keccak helper
jkopanski Sep 27, 2024
6697b11
[wip] balance of
jkopanski Oct 1, 2024
666be98
Other kind of isPure
jkopanski Oct 1, 2024
7df27ae
Add more preserved lemmas, finish balanceOf with it
jkopanski Oct 2, 2024
ddde452
Remove unused preds from proofs
jkopanski Oct 3, 2024
313e842
ERC20 predicate
jkopanski Oct 4, 2024
25dc2aa
Total supply that works with ERC20 predicate
jkopanski Oct 4, 2024
032ec1c
[wip] rewark balance_of using ERC20 predicate
jkopanski Oct 4, 2024
5853aeb
Progess `balanceOf` proof
Coda-Coda Oct 7, 2024
c08c17c
Updated predicate, some lemmas
jkopanski Oct 7, 2024
4ec6099
[wip]
jkopanski Oct 8, 2024
92219ee
more [wip]
jkopanski Oct 9, 2024
2ebf7f8
almost there
jkopanski Oct 14, 2024
ff583de
Use proper items from predicate
jkopanski Oct 14, 2024
2db665f
Extending keccak used range
jkopanski Oct 16, 2024
0da520c
Ensure type of `owner` and `spender` is `Address` not `UInt256`
Coda-Coda Oct 17, 2024
7d30c37
[wip]
Coda-Coda Oct 16, 2024
c262ae1
[wip]
Coda-Coda Oct 17, 2024
d267d41
[wip]
Coda-Coda Oct 17, 2024
ab6bec4
keccak injectivity preservation
jkopanski Oct 17, 2024
5a68d47
possible new spec
jkopanski Oct 17, 2024
d962a22
[wip] Fill sorry for `s["var_spender"]!! = var_spender`
Coda-Coda Oct 18, 2024
a5956ef
[wip] Main aspects of `allowance` proof finished
Coda-Coda Oct 21, 2024
fb2e9c9
[wip] Fill final two sorries in `fun_allowance_abs_of_concrete`
Coda-Coda Oct 21, 2024
ab1c421
[wip] Update `balanceOf` proof so that it still builds
Coda-Coda Oct 22, 2024
4d1dfd9
[wip] Begin making proof style improvements
Coda-Coda Oct 22, 2024
0b333cf
Merge pull request #15 from NethermindEth/allowance
jkopanski Oct 22, 2024
e33c914
[wip] Handle hash collisions properly in specifications for `allowanc…
Coda-Coda Oct 24, 2024
cdcdb54
updated_keccak_map
jkopanski Oct 24, 2024
74d7435
[wip] a bit of adjustment for new spec
jkopanski Oct 24, 2024
2dfc22a
[wip] Correction to helper spec
Coda-Coda Oct 25, 2024
c185534
[wip] QED on allowance, except sorries
Coda-Coda Oct 25, 2024
c836928
[wip]
Coda-Coda Oct 25, 2024
6840248
[wip] QED on allowance
Coda-Coda Oct 25, 2024
2d37414
[wip] QED on `balanceOf`
Coda-Coda Oct 25, 2024
4bd6a34
[wip] Remove some leftover commented out code
Coda-Coda Oct 25, 2024
fa05917
Merge pull request #16 from NethermindEth/WIP-erc20-daniel-3
jkopanski Oct 25, 2024
6ee04d8
Fixed deep recursion in the panic_error_0x11
jkopanski Oct 25, 2024
f20cdff
keccak helper
jkopanski Oct 25, 2024
5dd0ad9
[wip] adjust for EVM structure split
jkopanski Oct 25, 2024
9c5e923
Make use of the keccak helper proof for the other keccak helper
Coda-Coda Oct 29, 2024
6586986
Merge pull request #18 from NethermindEth/keccak-helper-for-allowance
jkopanski Oct 29, 2024
9df1fda
Use new tactic
jkopanski Oct 29, 2024
f223382
Add `mstore_preserves_used_range` lemma
Coda-Coda Nov 8, 2024
c243670
Add preservation of `isEVMState` to helper spec and prove it
Coda-Coda Nov 8, 2024
26439d7
Fill sorries related to preservation of `isEVMState`
Coda-Coda Nov 8, 2024
74ef5ef
Fixed some simple remaining sorrys
Julek Nov 10, 2024
1a96b5e
fix generation of double { {, credit to Daniel
Ferinko Nov 11, 2024
004ecae
Improvements to generator: switch cases. By František
Coda-Coda Nov 18, 2024
583fd60
Improvements to generator. By František
Coda-Coda Nov 18, 2024
4befbe0
Generate `erc20shim.yul` as described in `erc20shim-generation.md`
Coda-Coda Nov 20, 2024
9974e69
Regenerate ERC20, excluding files with existing proofs
Coda-Coda Nov 20, 2024
715d172
[To revert] Regenerate rest of ERC20, overwriting existing proofs
Coda-Coda Nov 20, 2024
d9d3122
Revert "[To revert] Regenerate rest of ERC20, overwriting existing pr…
Coda-Coda Nov 20, 2024
892c143
Improve `balanceOf` proof. By František.
Coda-Coda Nov 20, 2024
c1b6bdc
Change `clr_varstore` tactic and include it in generator. By František.
Coda-Coda Nov 20, 2024
ca1f0a0
Update `stack.yaml.lock` (automatic change from `stack build`)
Coda-Coda Nov 20, 2024
0c9754a
Regenerate ERC20, excluding files with existing proofs
Coda-Coda Nov 20, 2024
cf4e755
[To revert] Regenerate ERC20, overwriting existing proofs
Coda-Coda Nov 20, 2024
57c033d
Revert "[To revert] Regenerate ERC20, overwriting existing proofs"
Coda-Coda Nov 20, 2024
087fa5c
Add commas to reflect new `clr_varstore` syntax
Coda-Coda Nov 20, 2024
73ac12f
Add spec for `transferFrom`
Coda-Coda Nov 28, 2024
22a9980
Fix `transferFrom` spec for transfers from an address to itself
Coda-Coda Nov 28, 2024
575279f
Add spec and proof for `msgSender`
Coda-Coda Nov 29, 2024
cc4c09d
Change `sender` to `source` in `transferFrom` spec
Coda-Coda Nov 29, 2024
a4a2721
Make `transferFrom` spec more succinct using `evm` function
Coda-Coda Dec 2, 2024
39dfc9a
Fix `transferFrom` spec in the case of infinite approval
Coda-Coda Dec 2, 2024
3c54a7d
Add spec for `spendAllowance`
Coda-Coda Dec 2, 2024
015a295
Add spec for `_transfer`
Coda-Coda Dec 2, 2024
a8140a1
Add `hash_collision` condition to specs
Coda-Coda Dec 2, 2024
f74298e
Refactor update of `allowances` and `balances`
Coda-Coda Dec 3, 2024
3e35947
Add missing `ne` assumption to `mstore_mstore_of_ne`
Coda-Coda Dec 3, 2024
b377507
Defining transfer function
Feb 6, 2025
b1d15cc
Progress
Feb 20, 2025
9d63f25
prove IsERC20 erc_20_ s
Ferinko Feb 20, 2025
e56e2f9
progress
Feb 24, 2025
62156cb
prove not out of fuel
Ferinko Feb 24, 2025
7fd3d89
Merge branch 'erc20_Elliot' of https://github.com/EllbellCode/Clear_f…
Feb 25, 2025
7762985
Merge branch 'erc20_Elliot' of https://github.com/EllbellCode/Clear_f…
Feb 25, 2025
fde1a09
finish h3
Ferinko Feb 25, 2025
4acbd12
Completed fun_transfer lemma
Feb 26, 2025
515c34e
tidying up transfer proof
Mar 3, 2025
26e0247
tidying up transfer lemma
Mar 3, 2025
38fa95a
Edited msgSender, _transfer
Mar 4, 2025
ed3d3ae
progress
Mar 4, 2025
e09da54
completion of transferfrom
Mar 6, 2025
244ac12
updated reversion
Mar 12, 2025
1471420
reversion update
Mar 12, 2025
581b282
abi_encode
Mar 18, 2025
140074a
encode function verifications
Mar 19, 2025
098f978
encode functions
Mar 19, 2025
f5f5b0f
encode polish
Mar 19, 2025
34424ef
progress and modification of revert
Mar 26, 2025
cf3225b
nested encodings
Mar 31, 2025
6bf8e0d
storage logic
Apr 1, 2025
a609790
checked_add proof
Apr 2, 2025
0ad259d
sorted mapping issue that broke clr_spec
Apr 4, 2025
3bf97b0
switch proof
Apr 7, 2025
54cfcc7
switch 2
Apr 7, 2025
67d0a69
update spec
Apr 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
248 changes: 235 additions & 13 deletions All.lean

Large diffs are not rendered by default.

65 changes: 62 additions & 3 deletions Clear/Abstraction.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Clear.ExecLemmas
import Clear.OutOfFuelLemmas
import Clear.JumpLemmas
import Clear.YulNotation
import Clear.Wheels

namespace Clear.Abstraction

Expand All @@ -18,7 +19,7 @@ variable {s s₀ s₁ sEnd : State}

-- | General form for relational specs (concrete and abstract).
@[aesop safe 0 unfold (rule_sets := [Clear.aesop_spec])]
def Spec (R : State → State → Prop) (s₀ s₁ : State) : Prop :=
def Spec (R : State → State → Prop) (s₀ s₁ : State) :=
match s₀ with
| OutOfFuel => ❓ s₁
| Checkpoint c => s₁.isJump c
Expand All @@ -31,6 +32,30 @@ lemma Spec_ok_unfold {P : State → State → Prop} :
unfold Spec
aesop

-- -- | Specs that are somewhat pure
-- @[aesop safe 0 unfold (rule_sets := [Clear.aesop_spec])]
-- def PureSpec (R : State → State → Prop) : State → State → Prop :=
-- Spec (R ∩ (preserved on evm))

-- lemma PureSpec_ok_unfold {P : State → State → Prop} :
-- ∀ {s s' : State}, s.isOk → ¬ ❓ s' → PureSpec P s s' → (P ∩ (preserved on evm)) s s' := by
-- intros s s' h h'
-- unfold PureSpec Spec
-- aesop

-- -- | Specs for code that might result in hash collision
-- @[aesop safe 0 unfold (rule_sets := [Clear.aesop_spec])]
-- def CollidingSpec (R : State → State → Prop) (s₀ s₁ : State) : Prop :=
-- if s₀.evm.hash_collision
-- then ❓ s₁
-- else ¬ s₁.evm.hash_collision → Spec R s₀ s₁

-- lemma CollidingSpec_ok_unfold {P : State → State → Prop} :
-- ∀ {s s' : State}, s.isOk → ¬ ❓ s' → ¬ s'.evm.hash_collision → CollidingSpec P s s' → P s s' := by
-- intros s s' h h' h''
-- unfold CollidingSpec Spec
-- aesop

open Lean Elab Tactic in
elab "clr_spec" "at" h:ident : tactic => do
evalTactic <| ← `(tactic| (
Expand All @@ -46,6 +71,12 @@ lemma not_isOutOfFuel_Spec (spec : Spec R s₀ s₁) (h : ¬ isOutOfFuel s₁) :
intros hs₀
aesop_spec

-- | No hash collision propagates backwards through specs.
-- lemma not_hashCollision_Spec
-- (spec : CollidingSpec R s₀ s₁) (h : ¬ s₁.evm.hasHashCollision) : ¬ s₀.evm.hasHashCollision := by
-- intros hs₀
-- aesop_spec

-- ============================================================================
-- TACTICS
-- ============================================================================
Expand Down Expand Up @@ -97,6 +128,34 @@ end Clear.Abstraction

namespace Clear

/-- Looking at the code of fun_transfer :

``` def fun_transfer : FunctionDefinition := <f
function fun_transfer(var_to, var_value) -> var

{
let _1 := fun_msgSender()
fun__transfer(_1, var_to, var_value)
var := 1
}

>
```
Should return 0 (var = 0) in case
`fun__transfer` reverts. As such, it would appear that `var := 1`
must not execute in case `fun_transfer` reverts. This would entail
that modelling revert would necessitate changing the evaluation function,
which is not straightforward!

Thus, EGREGIOUS_HACK_REVERTED was born :o

TODO:
- FIX THIS

-/
lemma EGREGIOUS_HACK_REVERTED (s₀ s₉ : State) {s : State} (h : s.evm.reverted = true) :
s₀ = s₉ := sorry

open Abstraction State

lemma spec_of_ok {s₀ s₉ : State} {S₁ S₂ : State → State → Prop}
Expand All @@ -107,7 +166,7 @@ lemma spec_of_ok {s₀ s₉ : State} {S₁ S₂ : State → State → Prop}
lemma isOutOfFuel_iff_s_eq_OutOfFuel {s : State} : ❓ s ↔ (s = OutOfFuel) := by unfold isOutOfFuel; aesop

@[simp]
lemma setBreak_OutOfFuel_eq_OutOfFuel : 💔OutOfFuel = OutOfFuel := rfl
lemma setBreak_OutOfFuel_eq_OutOfFuel : 💔OutOfFuel = OutOfFuel := rfl

@[aesop norm 100 simp (rule_sets := [Clear.aesop_spec])]
lemma setBreak_ok_eq_checkpoint {evm : EVM} {varstore : VarStore} :
Expand Down Expand Up @@ -151,7 +210,7 @@ elab "clr_funargs" "at" h:ident : tactic => do
simp only [multifill_cons, multifill_nil', isOk_insert, isOk_Ok, isOutOfFuel_Ok,
not_false_eq_true, imp_false, Ok.injEq, and_imp, forall_apply_eq_imp_iff₂,
forall_apply_eq_imp_iff] at $h:ident
repeat (rw [←State.insert] at $h:ident)
repeat (rw [←State.insert] at $h:ident)
))

end Clear
Loading
Loading