Library QedkConcrete.protectedstoragenative
Delayed-threshold preservation by the concrete native precompile
From Stdlib Require Import List String ZArith Lia.
Require Import RocqOfOCaml.RocqOfOCaml.
Require Import QedkConcrete.protectedstorage QedkConcrete.hostcode
QedkConcrete.hoststoragewords QedkConcrete.hoststoragewf QedkConcrete.reserveencoding
QedkConcrete.reservestorage QedkConcrete.worldaccounts QedkConcrete.reserveprecompile
QedkConcrete.vmhostframe QedkConcrete.hostframe.
Set Default Goal Selector "!".
Local Open Scope Z_scope.
Section Native.
Context {UZ : Basics.Unreachable Z.t} {Uarr : Basics.Unreachable (OCamlIarray.t int)}
{UN : Basics.Unreachable Support.UintN.t} {U64 : Basics.Unreachable Numeric.U64.t}
{UR : Basics.Unreachable Numeric.U256.Repr.t} {UF : Basics.Unreachable Numeric.U256.t}
{UA : Basics.Unreachable Addr.t} {UB : Basics.Unreachable Byte_string.Bytes.t}
{UU : Basics.Unreachable unit} {US : Basics.Unreachable string}
{UI : Basics.Unreachable int} {UC : Basics.Unreachable ascii}
{UP : Basics.Unreachable (int × int)}
{U32 : Basics.Unreachable Byte_string.B32.(Byte_string.Fixed.Fixed_result.t)}.
Local Abbreviation readAccount := (fun world addr ⇒
State.op_pointcaretlparenrparen world (@W.account None addr)).
Local Abbreviation activate := (@Reserve_balance.activate_precompile).
Local Abbreviation setter := (@Reserve_balance.set_reserve_balance).
Local Abbreviation native := (@Reserve_balance.precompile_address).
Local Abbreviation store := (@storeConfigField).
Local Abbreviation readConfig := (@Reserve_balance.stored_config).
Local Abbreviation protected := (@protectedStorage native).
Lemma setter_native_storage world block addr value after :
stringmaps.WellFormed (W.t.accounts world) →
setter world block addr value = Some after →
A.t.nonce (readAccount after native) ≠ 0 ∧
∃ record : Reserve_config.t,
A.t.storage (readAccount after native) =
store (store (store (A.t.storage (readAccount world native))
addr 0 (Reserve_config.t.settled record))
addr 1 (Reserve_config.t.pending record)) addr 2 (Reserve_config.t.valid_from record).
Proof.
intros Hwf Hset. unfold Reserve_balance.set_reserve_balance in Hset.
match type of Hset with context [match ?result with None ⇒ _ | Some _ ⇒ _ end] ⇒
destruct result as [record|] end; [|discriminate].
injection Hset as <-.
pose proof (@active_account world Hwf) as [Hstored Hnonce].
assert (Hactive : stringmaps.WellFormed (W.t.accounts (activate world))).
{ apply account_write_wellformed. exact Hwf. }
set (storage := store (store (store (A.t.storage (readAccount (activate world) native))
addr 0 (Reserve_config.t.settled record)) addr 1 (Reserve_config.t.pending record))
addr 2 (Reserve_config.t.valid_from record)).
change (let after := State.op_pointcaretlparenrparenltminus (activate world)
(@W.account (Some false) native)
(A.t.with_storage storage (readAccount (activate world) native)) in
A.t.nonce (readAccount after native) ≠ 0 ∧
∃ other : Reserve_config.t, A.t.storage (readAccount after native) =
store (store (store (A.t.storage (readAccount world native))
addr 0 (Reserve_config.t.settled other)) addr 1 (Reserve_config.t.pending other))
addr 2 (Reserve_config.t.valid_from other)).
cbn beta zeta. rewrite account_read_after_write by exact Hactive.
rewrite Strings.String.eqb_refl, nonzero_nonce_not_empty by exact Hnonce.
split; [exact Hnonce|]. ∃ record.
cbn [A.t.storage A.t.with_storage]. unfold storage.
rewrite Hstored. reflexivity.
Qed.
Lemma setter_preserves_protected_storage P s block addr value after :
protected P s → setter (S.t.world_state s) block addr value = Some after →
P (storageBlock s) (A.t.storage (readAccount after native)) →
protected P (S.t.with_world_state after s).
Proof.
intros Hbefore Hset Hcontents.
pose proof (setter_code_frame (UI := Opaque.legacy_witness 0%Z) _ _ _ _ _ (protected_storage_map _ _ _ Hbefore) Hset) as [Hwf Hcode].
pose proof (proj1 (setter_native_storage _ _ _ _ _
(protected_storage_map _ _ _ Hbefore) Hset)) as Hnonce.
constructor.
- exact Hwf.
- exact Hnonce.
- change (A.t.code (readAccount after native) = Byte_string.Bytes.empty).
cbv beta. rewrite (Hcode native). exact (protected_storage_code _ _ _ Hbefore).
- exact Hcontents.
- exact (protected_storage_uncreated _ _ _ Hbefore).
- exact (protected_storage_undestroyed _ _ _ Hbefore).
Qed.
Require Import RocqOfOCaml.RocqOfOCaml.
Require Import QedkConcrete.protectedstorage QedkConcrete.hostcode
QedkConcrete.hoststoragewords QedkConcrete.hoststoragewf QedkConcrete.reserveencoding
QedkConcrete.reservestorage QedkConcrete.worldaccounts QedkConcrete.reserveprecompile
QedkConcrete.vmhostframe QedkConcrete.hostframe.
Set Default Goal Selector "!".
Local Open Scope Z_scope.
Section Native.
Context {UZ : Basics.Unreachable Z.t} {Uarr : Basics.Unreachable (OCamlIarray.t int)}
{UN : Basics.Unreachable Support.UintN.t} {U64 : Basics.Unreachable Numeric.U64.t}
{UR : Basics.Unreachable Numeric.U256.Repr.t} {UF : Basics.Unreachable Numeric.U256.t}
{UA : Basics.Unreachable Addr.t} {UB : Basics.Unreachable Byte_string.Bytes.t}
{UU : Basics.Unreachable unit} {US : Basics.Unreachable string}
{UI : Basics.Unreachable int} {UC : Basics.Unreachable ascii}
{UP : Basics.Unreachable (int × int)}
{U32 : Basics.Unreachable Byte_string.B32.(Byte_string.Fixed.Fixed_result.t)}.
Local Abbreviation readAccount := (fun world addr ⇒
State.op_pointcaretlparenrparen world (@W.account None addr)).
Local Abbreviation activate := (@Reserve_balance.activate_precompile).
Local Abbreviation setter := (@Reserve_balance.set_reserve_balance).
Local Abbreviation native := (@Reserve_balance.precompile_address).
Local Abbreviation store := (@storeConfigField).
Local Abbreviation readConfig := (@Reserve_balance.stored_config).
Local Abbreviation protected := (@protectedStorage native).
Lemma setter_native_storage world block addr value after :
stringmaps.WellFormed (W.t.accounts world) →
setter world block addr value = Some after →
A.t.nonce (readAccount after native) ≠ 0 ∧
∃ record : Reserve_config.t,
A.t.storage (readAccount after native) =
store (store (store (A.t.storage (readAccount world native))
addr 0 (Reserve_config.t.settled record))
addr 1 (Reserve_config.t.pending record)) addr 2 (Reserve_config.t.valid_from record).
Proof.
intros Hwf Hset. unfold Reserve_balance.set_reserve_balance in Hset.
match type of Hset with context [match ?result with None ⇒ _ | Some _ ⇒ _ end] ⇒
destruct result as [record|] end; [|discriminate].
injection Hset as <-.
pose proof (@active_account world Hwf) as [Hstored Hnonce].
assert (Hactive : stringmaps.WellFormed (W.t.accounts (activate world))).
{ apply account_write_wellformed. exact Hwf. }
set (storage := store (store (store (A.t.storage (readAccount (activate world) native))
addr 0 (Reserve_config.t.settled record)) addr 1 (Reserve_config.t.pending record))
addr 2 (Reserve_config.t.valid_from record)).
change (let after := State.op_pointcaretlparenrparenltminus (activate world)
(@W.account (Some false) native)
(A.t.with_storage storage (readAccount (activate world) native)) in
A.t.nonce (readAccount after native) ≠ 0 ∧
∃ other : Reserve_config.t, A.t.storage (readAccount after native) =
store (store (store (A.t.storage (readAccount world native))
addr 0 (Reserve_config.t.settled other)) addr 1 (Reserve_config.t.pending other))
addr 2 (Reserve_config.t.valid_from other)).
cbn beta zeta. rewrite account_read_after_write by exact Hactive.
rewrite Strings.String.eqb_refl, nonzero_nonce_not_empty by exact Hnonce.
split; [exact Hnonce|]. ∃ record.
cbn [A.t.storage A.t.with_storage]. unfold storage.
rewrite Hstored. reflexivity.
Qed.
Lemma setter_preserves_protected_storage P s block addr value after :
protected P s → setter (S.t.world_state s) block addr value = Some after →
P (storageBlock s) (A.t.storage (readAccount after native)) →
protected P (S.t.with_world_state after s).
Proof.
intros Hbefore Hset Hcontents.
pose proof (setter_code_frame (UI := Opaque.legacy_witness 0%Z) _ _ _ _ _ (protected_storage_map _ _ _ Hbefore) Hset) as [Hwf Hcode].
pose proof (proj1 (setter_native_storage _ _ _ _ _
(protected_storage_map _ _ _ Hbefore) Hset)) as Hnonce.
constructor.
- exact Hwf.
- exact Hnonce.
- change (A.t.code (readAccount after native) = Byte_string.Bytes.empty).
cbv beta. rewrite (Hcode native). exact (protected_storage_code _ _ _ Hbefore).
- exact Hcontents.
- exact (protected_storage_uncreated _ _ _ Hbefore).
- exact (protected_storage_undestroyed _ _ _ Hbefore).
Qed.
A finite sequence of successful concrete settings, newest first. This
records only surviving storage effects: rollback may discard a suffix of
execution. It permits proving isolation before assuming separation of the
storage slots of the finitely many accounts actually updated.
Inductive reserveStorageWrites (block : Support.UintN.t)
(initial : list (string × string)) :
list (Addr.t × Numeric.U256.t) → list (string × string) → Prop :=
| reserve_storage_initial : reserveStorageWrites block initial nil initial
| reserve_storage_setting writes storage world addr value after :
reserveStorageWrites block initial writes storage →
stringmaps.WellFormed (W.t.accounts world) →
A.t.storage (readAccount world native) = storage →
setter world block addr value = Some after →
reserveStorageWrites block initial ((addr, value) :: writes)
(A.t.storage (readAccount after native)).
Definition reachableReserveStorage block initial current storage : Prop :=
current = block ∧ ∃ writes, reserveStorageWrites block initial writes storage.
Lemma reserve_storage_writes_representation block initial writes storage :
stringmaps.WellFormed initial → storageWords initial →
reserveStorageWrites block initial writes storage →
stringmaps.WellFormed storage ∧ storageWords storage.
Proof using U32 UC UI UP UU.
intros Hwf Hwords Hwrites. induction Hwrites as
[|writes storage world addr value after Hwrites IH Hworld Hstorage Hset].
- split; assumption.
- destruct (proj2 (setter_native_storage _ _ _ _ _ Hworld Hset)) as [record Hstored].
rewrite Hstored, Hstorage. destruct IH as [Hmap Hwidth]. split.
+ repeat apply store_config_wellformed. exact Hmap.
+ repeat apply config_field_preserves_words. exact Hwidth.
Qed.
Lemma reserve_storage_writes_threshold block initial writes storage query target :
stringmaps.WellFormed initial → storageWords initial →
reserveStorageWrites block initial writes storage →
List.Forall (fun update ⇒ fst update = query ∨
@configSlotsDisjoint (fst update) query) writes →
(block ≤ target < block + 3)%N →
@Reserve_config.active
{| Reserve_config.t.settled := @readConfigField storage query 0;
Reserve_config.t.pending := @readConfigField storage query 1;
Reserve_config.t.valid_from := @readConfigField storage query 2 |}
target =
@Reserve_config.active
{| Reserve_config.t.settled := @readConfigField initial query 0;
Reserve_config.t.pending := @readConfigField initial query 1;
Reserve_config.t.valid_from := @readConfigField initial query 2 |}
target.
Proof using U32 UC UI UP UU.
intros Hwf Hwords Hwrites. induction Hwrites as
[|writes storage world addr value after Hwrites IH Hworld Hstorage Hset].
- reflexivity.
- intros Hslots Hrange. apply List.Forall_cons_iff in Hslots as [Hslot Htail].
pose proof (reserve_storage_writes_representation _ _ _ _ Hwf Hwords Hwrites)
as [Hmap Hwidth].
assert (Hmap' : stringmaps.WellFormed (A.t.storage (readAccount world native))).
{ rewrite Hstorage. exact Hmap. }
assert (Hwidth' : storageWords (A.t.storage (readAccount world native))).
{ rewrite Hstorage. exact Hwidth. }
pose proof (@native_setter_preserves_window world block addr query value after target Hworld Hmap' Hwidth' Hslot Hset Hrange) as Hstable.
rewrite <- Hstorage in IH. exact (eq_trans Hstable (IH Htail Hrange)).
Qed.
(initial : list (string × string)) :
list (Addr.t × Numeric.U256.t) → list (string × string) → Prop :=
| reserve_storage_initial : reserveStorageWrites block initial nil initial
| reserve_storage_setting writes storage world addr value after :
reserveStorageWrites block initial writes storage →
stringmaps.WellFormed (W.t.accounts world) →
A.t.storage (readAccount world native) = storage →
setter world block addr value = Some after →
reserveStorageWrites block initial ((addr, value) :: writes)
(A.t.storage (readAccount after native)).
Definition reachableReserveStorage block initial current storage : Prop :=
current = block ∧ ∃ writes, reserveStorageWrites block initial writes storage.
Lemma reserve_storage_writes_representation block initial writes storage :
stringmaps.WellFormed initial → storageWords initial →
reserveStorageWrites block initial writes storage →
stringmaps.WellFormed storage ∧ storageWords storage.
Proof using U32 UC UI UP UU.
intros Hwf Hwords Hwrites. induction Hwrites as
[|writes storage world addr value after Hwrites IH Hworld Hstorage Hset].
- split; assumption.
- destruct (proj2 (setter_native_storage _ _ _ _ _ Hworld Hset)) as [record Hstored].
rewrite Hstored, Hstorage. destruct IH as [Hmap Hwidth]. split.
+ repeat apply store_config_wellformed. exact Hmap.
+ repeat apply config_field_preserves_words. exact Hwidth.
Qed.
Lemma reserve_storage_writes_threshold block initial writes storage query target :
stringmaps.WellFormed initial → storageWords initial →
reserveStorageWrites block initial writes storage →
List.Forall (fun update ⇒ fst update = query ∨
@configSlotsDisjoint (fst update) query) writes →
(block ≤ target < block + 3)%N →
@Reserve_config.active
{| Reserve_config.t.settled := @readConfigField storage query 0;
Reserve_config.t.pending := @readConfigField storage query 1;
Reserve_config.t.valid_from := @readConfigField storage query 2 |}
target =
@Reserve_config.active
{| Reserve_config.t.settled := @readConfigField initial query 0;
Reserve_config.t.pending := @readConfigField initial query 1;
Reserve_config.t.valid_from := @readConfigField initial query 2 |}
target.
Proof using U32 UC UI UP UU.
intros Hwf Hwords Hwrites. induction Hwrites as
[|writes storage world addr value after Hwrites IH Hworld Hstorage Hset].
- reflexivity.
- intros Hslots Hrange. apply List.Forall_cons_iff in Hslots as [Hslot Htail].
pose proof (reserve_storage_writes_representation _ _ _ _ Hwf Hwords Hwrites)
as [Hmap Hwidth].
assert (Hmap' : stringmaps.WellFormed (A.t.storage (readAccount world native))).
{ rewrite Hstorage. exact Hmap. }
assert (Hwidth' : storageWords (A.t.storage (readAccount world native))).
{ rewrite Hstorage. exact Hwidth. }
pose proof (@native_setter_preserves_window world block addr query value after target Hworld Hmap' Hwidth' Hslot Hset Hrange) as Hstable.
rewrite <- Hstorage in IH. exact (eq_trans Hstable (IH Htail Hrange)).
Qed.
The delayed-value law holds even for colliding account records: a shared
record has one shared activation time. No hash-separation premise is needed.
Lemma reserve_storage_writes_threshold_any_account block initial writes storage query target :
stringmaps.WellFormed initial → storageWords initial →
reserveStorageWrites block initial writes storage →
(block ≤ target < block + 3)%N →
@Reserve_config.active
{| Reserve_config.t.settled := @readConfigField storage query 0;
Reserve_config.t.pending := @readConfigField storage query 1;
Reserve_config.t.valid_from := @readConfigField storage query 2 |}
target =
@Reserve_config.active
{| Reserve_config.t.settled := @readConfigField initial query 0;
Reserve_config.t.pending := @readConfigField initial query 1;
Reserve_config.t.valid_from := @readConfigField initial query 2 |}
target.
Proof using U32 UC UI UP UU.
intros Hwf Hwords Hwrites. induction Hwrites as
[|writes storage world addr value after Hwrites IH Hworld Hstorage Hset].
- reflexivity.
- intro Hrange.
pose proof (reserve_storage_writes_representation _ _ _ _ Hwf Hwords Hwrites)
as [Hmap Hwidth].
assert (Hmap' : stringmaps.WellFormed (A.t.storage (readAccount world native))).
{ rewrite Hstorage. exact Hmap. }
assert (Hwidth' : storageWords (A.t.storage (readAccount world native))).
{ rewrite Hstorage. exact Hwidth. }
pose proof (@native_setter_preserves_window_any_account world block addr query value after target Hworld Hmap' Hwidth' Hset Hrange) as Hstable.
rewrite <- Hstorage in IH. exact (eq_trans Hstable (IH Hrange)).
Qed.
Context {F : Reserve_balance_introspection.Make.FArgs}
{Useq : Basics.Unreachable (OCamlSeq.t (Addr.Map.key × A.t))}
{U64i : Basics.Unreachable MonadVM.Int64.t} {UG : Basics.Unreachable Gas.t}.
Local Abbreviation precompile := (@Reserve_balance_introspection.Make.precompile
F ).
Lemma native_preserves_protected_storage P msg :
(∀ s value after, protected P s →
setter (S.t.world_state s) (storageBlock s) (Evmc.Message.t.sender msg) value = Some after →
P (storageBlock s) (A.t.storage (readAccount after native))) →
preservesCallback (protected P) (precompile msg).
Proof.
intros Hsetter s Hbefore. change (protected P (snd (precompile msg s))).
destruct (@precompile_world_effect F msg s) as [Hsame|[value [world [Hwrite Hafter]]]].
- rewrite Hsame. exact Hbefore.
- rewrite Hafter. eapply setter_preserves_protected_storage;
[exact Hbefore|exact Hwrite|eapply Hsetter; eassumption].
Qed.
Lemma native_preserves_reachable_reserve_storage block initial msg :
preservesCallback (protected (reachableReserveStorage block initial)) (precompile msg).
Proof.
apply native_preserves_protected_storage.
intros s value after Hbefore Hset.
destruct (protected_storage_contents _ _ _ Hbefore) as [Hblock [writes Hwrites]].
split; [exact Hblock|]. ∃ ((Evmc.Message.t.sender msg, value) :: writes).
eapply reserve_storage_setting with (world := S.t.world_state s).
- exact Hwrites.
- exact (protected_storage_map _ _ _ Hbefore).
- reflexivity.
- rewrite <- Hblock. exact Hset.
Qed.
stringmaps.WellFormed initial → storageWords initial →
reserveStorageWrites block initial writes storage →
(block ≤ target < block + 3)%N →
@Reserve_config.active
{| Reserve_config.t.settled := @readConfigField storage query 0;
Reserve_config.t.pending := @readConfigField storage query 1;
Reserve_config.t.valid_from := @readConfigField storage query 2 |}
target =
@Reserve_config.active
{| Reserve_config.t.settled := @readConfigField initial query 0;
Reserve_config.t.pending := @readConfigField initial query 1;
Reserve_config.t.valid_from := @readConfigField initial query 2 |}
target.
Proof using U32 UC UI UP UU.
intros Hwf Hwords Hwrites. induction Hwrites as
[|writes storage world addr value after Hwrites IH Hworld Hstorage Hset].
- reflexivity.
- intro Hrange.
pose proof (reserve_storage_writes_representation _ _ _ _ Hwf Hwords Hwrites)
as [Hmap Hwidth].
assert (Hmap' : stringmaps.WellFormed (A.t.storage (readAccount world native))).
{ rewrite Hstorage. exact Hmap. }
assert (Hwidth' : storageWords (A.t.storage (readAccount world native))).
{ rewrite Hstorage. exact Hwidth. }
pose proof (@native_setter_preserves_window_any_account world block addr query value after target Hworld Hmap' Hwidth' Hset Hrange) as Hstable.
rewrite <- Hstorage in IH. exact (eq_trans Hstable (IH Hrange)).
Qed.
Context {F : Reserve_balance_introspection.Make.FArgs}
{Useq : Basics.Unreachable (OCamlSeq.t (Addr.Map.key × A.t))}
{U64i : Basics.Unreachable MonadVM.Int64.t} {UG : Basics.Unreachable Gas.t}.
Local Abbreviation precompile := (@Reserve_balance_introspection.Make.precompile
F ).
Lemma native_preserves_protected_storage P msg :
(∀ s value after, protected P s →
setter (S.t.world_state s) (storageBlock s) (Evmc.Message.t.sender msg) value = Some after →
P (storageBlock s) (A.t.storage (readAccount after native))) →
preservesCallback (protected P) (precompile msg).
Proof.
intros Hsetter s Hbefore. change (protected P (snd (precompile msg s))).
destruct (@precompile_world_effect F msg s) as [Hsame|[value [world [Hwrite Hafter]]]].
- rewrite Hsame. exact Hbefore.
- rewrite Hafter. eapply setter_preserves_protected_storage;
[exact Hbefore|exact Hwrite|eapply Hsetter; eassumption].
Qed.
Lemma native_preserves_reachable_reserve_storage block initial msg :
preservesCallback (protected (reachableReserveStorage block initial)) (precompile msg).
Proof.
apply native_preserves_protected_storage.
intros s value after Hbefore Hset.
destruct (protected_storage_contents _ _ _ Hbefore) as [Hblock [writes Hwrites]].
split; [exact Hblock|]. ∃ ((Evmc.Message.t.sender msg, value) :: writes).
eapply reserve_storage_setting with (world := S.t.world_state s).
- exact Hwrites.
- exact (protected_storage_map _ _ _ Hbefore).
- reflexivity.
- rewrite <- Hblock. exact Hset.
Qed.
A threshold used for a target block cannot change during execution of
a block less than K blocks earlier. The well-formedness conjuncts make
repeated settings usable, rather than proving only a single write.
Definition thresholdStorage query target threshold block storage : Prop :=
stringmaps.WellFormed storage ∧ storageWords storage ∧
(block ≤ target < block + 3)%N ∧
@Reserve_config.active
{| Reserve_config.t.settled := @readConfigField storage query 0;
Reserve_config.t.pending := @readConfigField storage query 1;
Reserve_config.t.valid_from := @readConfigField storage query 2 |}
target = threshold.
Lemma native_preserves_protected_threshold query target threshold msg :
(Evmc.Message.t.sender msg = query ∨
@configSlotsDisjoint (Evmc.Message.t.sender msg) query) →
preservesCallback (protected (thresholdStorage query target threshold)) (precompile msg).
Proof using F U32 U64i UC UP UU.
intro Hslots. apply native_preserves_protected_storage.
intros s value after Hbefore Hset.
pose proof (protected_storage_contents _ _ _ Hbefore) as Hcontents.
destruct Hcontents as [Hstorage [Hwords [Hrange Hthreshold]]].
pose proof (proj2 (setter_native_storage _ _ _ _ _
(protected_storage_map _ _ _ Hbefore) Hset)) as [record Hstored].
unfold thresholdStorage. split.
- rewrite Hstored. repeat apply store_config_wellformed. exact Hstorage.
- split.
+ rewrite Hstored. repeat apply config_field_preserves_words. exact Hwords.
+ split; [exact Hrange|].
change (@Reserve_config.active (readConfig after query) target = threshold).
pose proof (@native_setter_preserves_window
(S.t.world_state s) (storageBlock s) (Evmc.Message.t.sender msg) query value after target
(protected_storage_map _ _ _ Hbefore) Hstorage Hwords Hslots Hset Hrange) as Hstable.
rewrite Hstable. exact Hthreshold.
Qed.
End Native.
Print Assumptions setter_native_storage.
Print Assumptions native_preserves_protected_storage.
Print Assumptions native_preserves_protected_threshold.
stringmaps.WellFormed storage ∧ storageWords storage ∧
(block ≤ target < block + 3)%N ∧
@Reserve_config.active
{| Reserve_config.t.settled := @readConfigField storage query 0;
Reserve_config.t.pending := @readConfigField storage query 1;
Reserve_config.t.valid_from := @readConfigField storage query 2 |}
target = threshold.
Lemma native_preserves_protected_threshold query target threshold msg :
(Evmc.Message.t.sender msg = query ∨
@configSlotsDisjoint (Evmc.Message.t.sender msg) query) →
preservesCallback (protected (thresholdStorage query target threshold)) (precompile msg).
Proof using F U32 U64i UC UP UU.
intro Hslots. apply native_preserves_protected_storage.
intros s value after Hbefore Hset.
pose proof (protected_storage_contents _ _ _ Hbefore) as Hcontents.
destruct Hcontents as [Hstorage [Hwords [Hrange Hthreshold]]].
pose proof (proj2 (setter_native_storage _ _ _ _ _
(protected_storage_map _ _ _ Hbefore) Hset)) as [record Hstored].
unfold thresholdStorage. split.
- rewrite Hstored. repeat apply store_config_wellformed. exact Hstorage.
- split.
+ rewrite Hstored. repeat apply config_field_preserves_words. exact Hwords.
+ split; [exact Hrange|].
change (@Reserve_config.active (readConfig after query) target = threshold).
pose proof (@native_setter_preserves_window
(S.t.world_state s) (storageBlock s) (Evmc.Message.t.sender msg) query value after target
(protected_storage_map _ _ _ Hbefore) Hstorage Hwords Hslots Hset Hrange) as Hstable.
rewrite Hstable. exact Hthreshold.
Qed.
End Native.
Print Assumptions setter_native_storage.
Print Assumptions native_preserves_protected_storage.
Print Assumptions native_preserves_protected_threshold.