JPYC.allowlist_revert_noop
名称・種別
- 名称:
JPYC.allowlist_revert_noop - 種別: theorem
- モジュール:
JpycFormalVerification.AccessControlTheorems - ソース:
JpycFormalVerification/AccessControlTheorems.lean:798-799 - 概要: allowlist が revert した場合、状態は一切変化しない、という定理。
- 仕様: 対象
型シグネチャ
lean
∀ {s : JPYC.State} {ctx : JPYC.CallContext} {account : JPYC.Address} {e : JPYC.Error}, Eq (JPYC.allowlist s ctx account) (Except.error e) → Eq (s.afterCall (JPYC.allowlist s ctx account)) sallowlist が revert したとき、観測される状態(afterCall)は呼び出し前の状態に等しい、という「revert すれば状態は変わらない」定理です。
解説
何を述べているか。 allowlist が Except.error e を返したとき、s.afterCall (allowlist s ctx account) = s です。afterCall は「成功なら新状態、失敗なら元の状態」を返す観測関数なので、失敗時は定義から元の状態 s に簡約されます(simp [h])。
直感。 EVM のトランザクション・ロールバックを模したものです。「途中で revert したら、何もなかったことになる」。
なぜ安全性に効くか。 no-op on revert は、失敗した呼び出しが副作用を残さないという基本的な安全性です。ガードに弾かれた操作・あふれた算術などが、状態を中途半端に壊さないことを保証します。allowlist についてこれを個別に確認しています。
図解
Lean ソースコード
lean
theorem allowlist_revert_noop {s : State} {ctx : CallContext} {account : Address} {e : Error}
(h : allowlist s ctx account = .error e) : s.afterCall (allowlist s ctx account) = s := by simp [h]