Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly match none case #6

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions Clear/PrimOps.lean
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ def primCall (s : State) : PrimOp → List Literal → State × List Literal
| .Sar, [a,b] => (s, [UInt256.sar a b])
| .Keccak256, [a,b] =>
match s.evm.keccak256 a b with
| .some (val, evm') => (s.setEvm evm', [val])
| .some a => (s.setEvm a.snd, [a.fst])
-- This is the hash collision case. It's essentially an unrecoverable
-- error, and we model it similar to how we model infinite loops, except we
-- put the error in the EVM instead, so we don't have to bother with it in
-- the interpreter.
| _ => (s.setEvm s.evm.addHashCollision, [0])
| .none => (s.setEvm s.evm.addHashCollision, [0])
| .Address, [] => (s, [s.evm.execution_env.code_owner])
| .Balance, [a] => (s, [s.evm.balanceOf a])
| .Origin, [] => (s, [s.evm.execution_env.sender])
Expand Down Expand Up @@ -129,7 +129,7 @@ lemma EVMByte' : primCall s .Byte [a,b] = (s, [UInt
lemma EVMShl' : primCall s .Shl [a,b] = (s, [Fin.shiftLeft b a]) := rfl
lemma EVMShr' : primCall s .Shr [a,b] = (s, [Fin.shiftRight b a]) := rfl
lemma EVMSar' : primCall s .Sar [a,b] = (s, [UInt256.sar a b]) := rfl
lemma EVMKeccak256' : primCall s .Keccak256 [a,b] = match s.evm.keccak256 a b with | .some (val, evm') => (s.setEvm evm', [val]) | _ => (s.setEvm s.evm.addHashCollision, [0]) := rfl
lemma EVMKeccak256' : primCall s .Keccak256 [a,b] = match s.evm.keccak256 a b with | .some a => (s.setEvm a.snd, [a.fst]) | .none => (s.setEvm s.evm.addHashCollision, [0]) := rfl
lemma EVMAddress' : primCall s .Address [] = (s, ([s.evm.execution_env.code_owner] : List Literal)) := rfl
lemma EVMBalance' : primCall s .Balance [a] = (s, [s.evm.balanceOf a]) := rfl
lemma EVMOrigin' : primCall s .Origin [] = (s, ([s.evm.execution_env.sender] : List Literal)) := rfl
Expand Down