Library QedkConcrete.transactionhistory
Exact activity history through concrete transactions
From Stdlib Require Import List NArith ZArith Lia.
Require Import RocqOfOCaml.RocqOfOCaml.
Require Import MonadVM.Execution QedkConcrete.authorization QedkConcrete.emptyinghistory
QedkConcrete.executioncontext QedkConcrete.hostframe QedkConcrete.validation
QedkConcrete.stringmaps QedkConcrete.transactionchecked.
Set Default Goal Selector "!".
Import ListNotations.
Module E := Execution.Make.
Module S := State.TransactionState.
Module B := State.BlockState.
Module W := State.WorldState.
Module A := Chain.Ethereum.Account.
Module T := Chain.Ethereum.Transaction.
Section Execution.
Context {F : E.FArgs}.
Context {UI0 : Basics.Unreachable Support.UintN.Impl.t}
{UB : Basics.Unreachable Bloom.t}
{U8 : Basics.Unreachable Byte_string.B8.(Byte_string.Fixed.Fixed_result.t)}.
Require Import RocqOfOCaml.RocqOfOCaml.
Require Import MonadVM.Execution QedkConcrete.authorization QedkConcrete.emptyinghistory
QedkConcrete.executioncontext QedkConcrete.hostframe QedkConcrete.validation
QedkConcrete.stringmaps QedkConcrete.transactionchecked.
Set Default Goal Selector "!".
Import ListNotations.
Module E := Execution.Make.
Module S := State.TransactionState.
Module B := State.BlockState.
Module W := State.WorldState.
Module A := Chain.Ethereum.Account.
Module T := Chain.Ethereum.Transaction.
Section Execution.
Context {F : E.FArgs}.
Context {UI0 : Basics.Unreachable Support.UintN.Impl.t}
{UB : Basics.Unreachable Bloom.t}
{U8 : Basics.Unreachable Byte_string.B8.(Byte_string.Fixed.Fixed_result.t)}.
Exactly the fee/nonce write and authorization fold in process_transaction.
The returned list records applied authorities, in reverse application order;
invalid entries are omitted. Naming this prefix does not add an executor.
Definition transactionPrefix block tx (validation : E.transaction_validation) :
list Chain.Ethereum.Address.t × S.t :=
let sender := E.transaction_validation.sender validation in
let initial := @S.make
block sender tx in
let charged := State.op_pointcaretdollarlparenrparenltminus initial
(@S.account None sender)
(fun account ⇒ A.t.with_balance
(@Numeric.U256.op_minus (A.t.balance account) (E.transaction_validation.total_fee validation))
(A.t.with_nonce (@Numeric.U64.op_plus (A.t.nonce account) (@Numeric.U64.one)) account)) in
Result.List.fold_left (fun '(authorities, state) auth ⇒
match @E.process_authorization F state auth with
| (None, next) ⇒ (authorities, next)
| (Some authority, next) ⇒ (authority :: authorities, next)
end) ([], charged) (T.authorization_list tx).
Lemma authorizations_preserve_context auths authorities s :
transactionContext (snd (Result.List.fold_left
(fun '(applied, state) auth ⇒
match @E.process_authorization F state auth with
| (None, next) ⇒ (applied, next)
| (Some authority, next) ⇒ (authority :: applied, next)
end) (authorities, s) auths)) = transactionContext s.
Proof.
revert authorities s. induction auths as [|auth auths IH]; intros authorities s.
- reflexivity.
- change (@Result.List.fold_left) with (@OCamlList.fold_left).
cbn [OCamlList.fold_left].
pose proof (@authorization_preserves_context F s auth) as Hcontext.
destruct (@E.process_authorization F s auth) as [[authority|] next]; cbn [snd] in Hcontext.
all: rewrite IH; exact Hcontext.
Qed.
Lemma transaction_prefix_context block tx validation :
transactionContext (snd (transactionPrefix block tx validation)) =
transactionContext (@S.make
block (E.transaction_validation.sender validation) tx).
Proof. unfold transactionPrefix. rewrite authorizations_preserve_context. reflexivity. Qed.
Lemma delete_accounts_history block addresses :
W.t.history (B.t.world_state (OCamlSeq.fold_left
(fun s addr ⇒ State.op_pointcaretlparenrparenltminus s
(@B.account_opt None addr) None) block addresses)) =
W.t.history (B.t.world_state block).
Proof.
revert block. induction addresses as [|addr addresses IH]; intro block;
[reflexivity|cbn [OCamlSeq.fold_left]; rewrite IH; reflexivity].
Qed.
Lemma delete_accounts_counters block addresses :
W.t.next_emptying_transaction_block (B.t.world_state (OCamlSeq.fold_left
(fun s addr ⇒ State.op_pointcaretlparenrparenltminus s
(@B.account_opt None addr) None) block addresses)) =
W.t.next_emptying_transaction_block (B.t.world_state block).
Proof.
revert block. induction addresses as [|addr addresses IH]; intro block;
[reflexivity|cbn [OCamlSeq.fold_left]; rewrite IH; reflexivity].
Qed.
Local Abbreviation readCounter := (fun world addr ⇒
State.op_pointcaretlparenrparen world (@W.next_emptying_transaction_block_for addr)).
list Chain.Ethereum.Address.t × S.t :=
let sender := E.transaction_validation.sender validation in
let initial := @S.make
block sender tx in
let charged := State.op_pointcaretdollarlparenrparenltminus initial
(@S.account None sender)
(fun account ⇒ A.t.with_balance
(@Numeric.U256.op_minus (A.t.balance account) (E.transaction_validation.total_fee validation))
(A.t.with_nonce (@Numeric.U64.op_plus (A.t.nonce account) (@Numeric.U64.one)) account)) in
Result.List.fold_left (fun '(authorities, state) auth ⇒
match @E.process_authorization F state auth with
| (None, next) ⇒ (authorities, next)
| (Some authority, next) ⇒ (authority :: authorities, next)
end) ([], charged) (T.authorization_list tx).
Lemma authorizations_preserve_context auths authorities s :
transactionContext (snd (Result.List.fold_left
(fun '(applied, state) auth ⇒
match @E.process_authorization F state auth with
| (None, next) ⇒ (applied, next)
| (Some authority, next) ⇒ (authority :: applied, next)
end) (authorities, s) auths)) = transactionContext s.
Proof.
revert authorities s. induction auths as [|auth auths IH]; intros authorities s.
- reflexivity.
- change (@Result.List.fold_left) with (@OCamlList.fold_left).
cbn [OCamlList.fold_left].
pose proof (@authorization_preserves_context F s auth) as Hcontext.
destruct (@E.process_authorization F s auth) as [[authority|] next]; cbn [snd] in Hcontext.
all: rewrite IH; exact Hcontext.
Qed.
Lemma transaction_prefix_context block tx validation :
transactionContext (snd (transactionPrefix block tx validation)) =
transactionContext (@S.make
block (E.transaction_validation.sender validation) tx).
Proof. unfold transactionPrefix. rewrite authorizations_preserve_context. reflexivity. Qed.
Lemma delete_accounts_history block addresses :
W.t.history (B.t.world_state (OCamlSeq.fold_left
(fun s addr ⇒ State.op_pointcaretlparenrparenltminus s
(@B.account_opt None addr) None) block addresses)) =
W.t.history (B.t.world_state block).
Proof.
revert block. induction addresses as [|addr addresses IH]; intro block;
[reflexivity|cbn [OCamlSeq.fold_left]; rewrite IH; reflexivity].
Qed.
Lemma delete_accounts_counters block addresses :
W.t.next_emptying_transaction_block (B.t.world_state (OCamlSeq.fold_left
(fun s addr ⇒ State.op_pointcaretlparenrparenltminus s
(@B.account_opt None addr) None) block addresses)) =
W.t.next_emptying_transaction_block (B.t.world_state block).
Proof.
revert block. induction addresses as [|addr addresses IH]; intro block;
[reflexivity|cbn [OCamlSeq.fold_left]; rewrite IH; reflexivity].
Qed.
Local Abbreviation readCounter := (fun world addr ⇒
State.op_pointcaretlparenrparen world (@W.next_emptying_transaction_block_for addr)).
Applied authorizations and the sender remain recent even when execution
reverts. Unrelated accounts keep their previous counter. Neither receiving
the fee nor deleting a selfdestructed account erases this activity.
Theorem process_transaction_activity_history block tx validation post :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
WellFormed (W.t.next_emptying_transaction_block (B.t.world_state block)) →
@E.validate_transaction F block tx = inl validation →
@E.process_transaction F block tx = inl post →
W.t.history (B.t.world_state post) = W.t.history (B.t.world_state block) ∧
WellFormed (W.t.next_emptying_transaction_block (B.t.world_state post)) ∧
∀ query, readCounter (B.t.world_state post) query =
if existsb (fun addr ⇒ String.eqb addr query)
(E.transaction_validation.sender validation :: fst (transactionPrefix block tx validation))
then (Chain.Ethereum.Block.Header.t.number
(Chain.Ethereum.Block.t.header (B.t.current_block block)) +
@Reserve_balance.execution_consensus_delay )%N
else readCounter (B.t.world_state block) query.
Proof.
intros Hrevision Hwf Hvalidation Hrun.
unfold E.process_transaction in Hrun. rewrite Hvalidation in Hrun.
destruct validation as [sender fee price intrinsic].
change (@Result.op_letdollar) with
(fun (A B C : Set) (r : A + B) (f : A → C + B) ⇒
match r with inl value ⇒ f value | inr error ⇒ inr error end) in Hrun.
cbn beta iota zeta delta [E.transaction_validation.sender E.transaction_validation.total_fee
E.transaction_validation.intrinsic_gas E.transaction_validation.effective_gas_price] in Hrun.
match type of Hrun with context [Result.List.fold_left ?f ?start (T.authorization_list tx)] ⇒
change (Result.List.fold_left f start (T.authorization_list tx)) with (transactionPrefix block tx
{| E.transaction_validation.sender := sender; E.transaction_validation.total_fee := fee;
E.transaction_validation.effective_gas_price := price;
E.transaction_validation.intrinsic_gas := intrinsic |}) in Hrun end.
pose proof (transaction_prefix_context block tx
{| E.transaction_validation.sender := sender; E.transaction_validation.total_fee := fee;
E.transaction_validation.effective_gas_price := price;
E.transaction_validation.intrinsic_gas := intrinsic |}) as Hprefix.
destruct (transactionPrefix block tx
{| E.transaction_validation.sender := sender; E.transaction_validation.total_fee := fee;
E.transaction_validation.effective_gas_price := price;
E.transaction_validation.intrinsic_gas := intrinsic |}) as [authorities prepared] eqn:Hprepared.
cbn beta iota zeta delta [fst snd] in Hprefix, Hrun |- ×.
unfold transactionContext in Hprefix.
injection Hprefix as Hinitial Hblock Horigin Hgas Hprice Hhistory Hcounters.
assert (HpreparedWf : WellFormed (W.t.next_emptying_transaction_block (S.t.world_state prepared))).
{ rewrite Hcounters. exact Hwf. }
pose proof (@bump_counters_exact F prepared authorities HpreparedWf)
as [HauthWf [_ [HauthHistory HauthCounters]]].
match type of Hrun with context [E.Host.call_from_eoa tx ?message ?initial] ⇒
set (beforeVm := initial) in ×
end.
match type of Hrun with context [E.Host.call_from_eoa tx ?message beforeVm] ⇒
set (msg := message) in ×
end.
pose proof (validated_message_gas block tx _ (S.t.world_state beforeVm) Hvalidation) as Hmsg.
change (0 ≤ Evmc.Message.t.gas msg < 2^63)%Z in Hmsg.
pose proof (@execution_call_from_eoa_preserves_context F
tx msg Hrevision Hmsg beforeVm) as Hvm.
destruct (E.Host.call_from_eoa tx msg beforeVm) as [result afterVm] eqn:Hcall.
cbn [snd] in Hvm. unfold transactionContext in Hvm.
injection Hvm as Hvminitial Hvmblock Hvmorigin Hvmgas Hvmprice Hvmhistory Hvmcounters.
assert (HafterWf : WellFormed (W.t.next_emptying_transaction_block (S.t.world_state afterVm))).
{ rewrite Hvmcounters. exact HauthWf. }
pose proof (@bump_counters_exact F afterVm [sender] HafterWf)
as [HfinalWf [_ [HfinalHistory HfinalCounters]]].
injection Hrun as <-.
cbn beta iota zeta delta [B.t.with_transactions_processed B.t.with_gas_used B.t.world_state].
change (@Result.Seq.fold_left) with (@OCamlSeq.fold_left).
split.
{ rewrite delete_accounts_history. change
(W.t.history (S.t.world_state (@E.bump_emptying_transaction_counters F [sender] afterVm)) =
W.t.history (B.t.world_state block)).
rewrite HfinalHistory, Hvmhistory. change
(W.t.history (S.t.world_state (@E.bump_emptying_transaction_counters F authorities prepared)) =
W.t.history (B.t.world_state block)).
rewrite HauthHistory. exact Hhistory. }
split.
{ rewrite delete_accounts_counters. exact HfinalWf. }
intro query.
match goal with |- State.op_pointcaretlparenrparen ?world _ = ?rhs ⇒
change ((match OCamlMap.Make.find_opt stringOrder query
(W.t.next_emptying_transaction_block world) with
| Some value ⇒ value | None ⇒ 0%N end) = rhs)
end.
rewrite delete_accounts_counters.
match goal with |- _ = ?rhs ⇒
change (readCounter (S.t.world_state
(@E.bump_emptying_transaction_counters F [sender] afterVm)) query = rhs)
end.
cbv beta. rewrite HfinalCounters, Hvmblock, Hblock.
cbn [existsb E.transaction_validation.sender].
destruct (String.eqb sender query) eqn:Hsender; [reflexivity|].
cbn [orb].
match goal with |- State.op_pointcaretlparenrparen ?world _ = ?rhs ⇒
change ((match OCamlMap.Make.find_opt stringOrder query
(W.t.next_emptying_transaction_block world) with
| Some value ⇒ value | None ⇒ 0%N end) = rhs)
end.
rewrite Hvmcounters.
match goal with |- _ = ?rhs ⇒
change (readCounter (S.t.world_state
(@E.bump_emptying_transaction_counters F authorities prepared)) query = rhs)
end.
cbv beta. rewrite HauthCounters, Hblock.
destruct (existsb (fun addr ⇒ String.eqb addr query) authorities); [reflexivity|].
change ((match OCamlMap.Make.find_opt stringOrder query
(W.t.next_emptying_transaction_block (S.t.world_state prepared)) with
| Some value ⇒ value | None ⇒ 0%N end) = readCounter (B.t.world_state block) query).
rewrite Hcounters. reflexivity.
Qed.
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
WellFormed (W.t.next_emptying_transaction_block (B.t.world_state block)) →
@E.validate_transaction F block tx = inl validation →
@E.process_transaction F block tx = inl post →
W.t.history (B.t.world_state post) = W.t.history (B.t.world_state block) ∧
WellFormed (W.t.next_emptying_transaction_block (B.t.world_state post)) ∧
∀ query, readCounter (B.t.world_state post) query =
if existsb (fun addr ⇒ String.eqb addr query)
(E.transaction_validation.sender validation :: fst (transactionPrefix block tx validation))
then (Chain.Ethereum.Block.Header.t.number
(Chain.Ethereum.Block.t.header (B.t.current_block block)) +
@Reserve_balance.execution_consensus_delay )%N
else readCounter (B.t.world_state block) query.
Proof.
intros Hrevision Hwf Hvalidation Hrun.
unfold E.process_transaction in Hrun. rewrite Hvalidation in Hrun.
destruct validation as [sender fee price intrinsic].
change (@Result.op_letdollar) with
(fun (A B C : Set) (r : A + B) (f : A → C + B) ⇒
match r with inl value ⇒ f value | inr error ⇒ inr error end) in Hrun.
cbn beta iota zeta delta [E.transaction_validation.sender E.transaction_validation.total_fee
E.transaction_validation.intrinsic_gas E.transaction_validation.effective_gas_price] in Hrun.
match type of Hrun with context [Result.List.fold_left ?f ?start (T.authorization_list tx)] ⇒
change (Result.List.fold_left f start (T.authorization_list tx)) with (transactionPrefix block tx
{| E.transaction_validation.sender := sender; E.transaction_validation.total_fee := fee;
E.transaction_validation.effective_gas_price := price;
E.transaction_validation.intrinsic_gas := intrinsic |}) in Hrun end.
pose proof (transaction_prefix_context block tx
{| E.transaction_validation.sender := sender; E.transaction_validation.total_fee := fee;
E.transaction_validation.effective_gas_price := price;
E.transaction_validation.intrinsic_gas := intrinsic |}) as Hprefix.
destruct (transactionPrefix block tx
{| E.transaction_validation.sender := sender; E.transaction_validation.total_fee := fee;
E.transaction_validation.effective_gas_price := price;
E.transaction_validation.intrinsic_gas := intrinsic |}) as [authorities prepared] eqn:Hprepared.
cbn beta iota zeta delta [fst snd] in Hprefix, Hrun |- ×.
unfold transactionContext in Hprefix.
injection Hprefix as Hinitial Hblock Horigin Hgas Hprice Hhistory Hcounters.
assert (HpreparedWf : WellFormed (W.t.next_emptying_transaction_block (S.t.world_state prepared))).
{ rewrite Hcounters. exact Hwf. }
pose proof (@bump_counters_exact F prepared authorities HpreparedWf)
as [HauthWf [_ [HauthHistory HauthCounters]]].
match type of Hrun with context [E.Host.call_from_eoa tx ?message ?initial] ⇒
set (beforeVm := initial) in ×
end.
match type of Hrun with context [E.Host.call_from_eoa tx ?message beforeVm] ⇒
set (msg := message) in ×
end.
pose proof (validated_message_gas block tx _ (S.t.world_state beforeVm) Hvalidation) as Hmsg.
change (0 ≤ Evmc.Message.t.gas msg < 2^63)%Z in Hmsg.
pose proof (@execution_call_from_eoa_preserves_context F
tx msg Hrevision Hmsg beforeVm) as Hvm.
destruct (E.Host.call_from_eoa tx msg beforeVm) as [result afterVm] eqn:Hcall.
cbn [snd] in Hvm. unfold transactionContext in Hvm.
injection Hvm as Hvminitial Hvmblock Hvmorigin Hvmgas Hvmprice Hvmhistory Hvmcounters.
assert (HafterWf : WellFormed (W.t.next_emptying_transaction_block (S.t.world_state afterVm))).
{ rewrite Hvmcounters. exact HauthWf. }
pose proof (@bump_counters_exact F afterVm [sender] HafterWf)
as [HfinalWf [_ [HfinalHistory HfinalCounters]]].
injection Hrun as <-.
cbn beta iota zeta delta [B.t.with_transactions_processed B.t.with_gas_used B.t.world_state].
change (@Result.Seq.fold_left) with (@OCamlSeq.fold_left).
split.
{ rewrite delete_accounts_history. change
(W.t.history (S.t.world_state (@E.bump_emptying_transaction_counters F [sender] afterVm)) =
W.t.history (B.t.world_state block)).
rewrite HfinalHistory, Hvmhistory. change
(W.t.history (S.t.world_state (@E.bump_emptying_transaction_counters F authorities prepared)) =
W.t.history (B.t.world_state block)).
rewrite HauthHistory. exact Hhistory. }
split.
{ rewrite delete_accounts_counters. exact HfinalWf. }
intro query.
match goal with |- State.op_pointcaretlparenrparen ?world _ = ?rhs ⇒
change ((match OCamlMap.Make.find_opt stringOrder query
(W.t.next_emptying_transaction_block world) with
| Some value ⇒ value | None ⇒ 0%N end) = rhs)
end.
rewrite delete_accounts_counters.
match goal with |- _ = ?rhs ⇒
change (readCounter (S.t.world_state
(@E.bump_emptying_transaction_counters F [sender] afterVm)) query = rhs)
end.
cbv beta. rewrite HfinalCounters, Hvmblock, Hblock.
cbn [existsb E.transaction_validation.sender].
destruct (String.eqb sender query) eqn:Hsender; [reflexivity|].
cbn [orb].
match goal with |- State.op_pointcaretlparenrparen ?world _ = ?rhs ⇒
change ((match OCamlMap.Make.find_opt stringOrder query
(W.t.next_emptying_transaction_block world) with
| Some value ⇒ value | None ⇒ 0%N end) = rhs)
end.
rewrite Hvmcounters.
match goal with |- _ = ?rhs ⇒
change (readCounter (S.t.world_state
(@E.bump_emptying_transaction_counters F authorities prepared)) query = rhs)
end.
cbv beta. rewrite HauthCounters, Hblock.
destruct (existsb (fun addr ⇒ String.eqb addr query) authorities); [reflexivity|].
change ((match OCamlMap.Make.find_opt stringOrder query
(W.t.next_emptying_transaction_block (S.t.world_state prepared)) with
| Some value ⇒ value | None ⇒ 0%N end) = readCounter (B.t.world_state block) query).
rewrite Hcounters. reflexivity.
Qed.
A whole transaction list can only retain an account's old activity counter
or set it to this block's deadline. In particular a later transaction
cannot erase activity already recorded earlier in the block.
Theorem transactions_activity_history block txs post :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
WellFormed (W.t.next_emptying_transaction_block (B.t.world_state block)) →
Result.List.fold_leftM (@E.process_transaction F) block txs = inl post →
W.t.history (B.t.world_state post) = W.t.history (B.t.world_state block) ∧
WellFormed (W.t.next_emptying_transaction_block (B.t.world_state post)) ∧
B.t.current_block post = B.t.current_block block ∧
∀ query,
readCounter (B.t.world_state post) query = readCounter (B.t.world_state block) query ∨
readCounter (B.t.world_state post) query =
(Chain.Ethereum.Block.Header.t.number
(Chain.Ethereum.Block.t.header (B.t.current_block block)) +
@Reserve_balance.execution_consensus_delay )%N.
Proof.
intros Hrevision. revert block. induction txs as [|tx txs IH]; intros block Hwf Hrun.
- injection Hrun as <-. split; [reflexivity|]. split; [exact Hwf|].
split; [reflexivity|]. intro query. left. reflexivity.
- change (Result.op_letdollar (@E.process_transaction F block tx)
(fun next ⇒ Result.List.fold_leftM (@E.process_transaction F) next txs) = inl post) in Hrun.
destruct (@E.process_transaction F block tx) as [next|error] eqn:Hstep;
[|discriminate Hrun].
destruct (@E.validate_transaction F block tx) as [validation|error] eqn:Hvalidation.
2: { unfold E.process_transaction in Hstep. rewrite Hvalidation in Hstep. discriminate Hstep. }
destruct (process_transaction_activity_history block tx validation next
Hrevision Hwf Hvalidation Hstep) as [Hhistory [HnextWf Hcounters]].
pose proof (@process_transaction_current_block F
block tx next Hstep) as Hblock.
destruct (IH next HnextWf Hrun) as [HtailHistory [HpostWf [HtailBlock HtailCounters]]].
split; [congruence|]. split; [exact HpostWf|]. split; [congruence|].
intro query. destruct (HtailCounters query) as [Hsame|Hbumped].
+ rewrite Hsame, Hcounters.
destruct (existsb (fun addr ⇒ String.eqb addr query)
(E.transaction_validation.sender validation :: fst (transactionPrefix block tx validation)));
[right|left]; reflexivity.
+ right. rewrite Hbumped, Hblock. reflexivity.
Qed.
Lemma process_monad_system_transaction_activity_history block tx post :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
@E.process_monad_system_transaction F block tx = inl post →
W.t.history (B.t.world_state post) = W.t.history (B.t.world_state block) ∧
W.t.next_emptying_transaction_block (B.t.world_state post) =
W.t.next_emptying_transaction_block (B.t.world_state block) ∧
B.t.current_block post = B.t.current_block block.
Proof.
intros Hrevision Hrun. unfold E.process_monad_system_transaction in Hrun.
destruct (@E.validate_monad_system_transaction F block tx Chain.Monad.system_sender)
as [[]|error]; [|discriminate Hrun].
change (@Result.op_letdollar) with
(fun (A B C : Set) (r : A + B) (f : A → C + B) ⇒
match r with inl value ⇒ f value | inr error ⇒ inr error end) in Hrun.
cbv beta iota zeta in Hrun.
match type of Hrun with context [E.Host.call_from_monad_system_transaction ?message ?initial] ⇒
set (msg := message) in *; set (beforeVm := initial) in ×
end.
assert (Hgas : (0 ≤ Evmc.Message.t.gas msg < 2^63)%Z).
{ unfold msg, E.prepare_message. destruct (T.call_or_create_value tx) as [[]|[]];
change (0 ≤ 0 < 2^63)%Z; lia. }
pose proof (@execution_call_from_monad_system_transaction_preserves_context F
msg Hrevision Hgas beforeVm) as Hvm.
destruct (E.Host.call_from_monad_system_transaction msg beforeVm) as [result afterVm].
cbn [snd] in Hvm. unfold transactionContext in Hvm.
injection Hvm as Hinitial Hblock Horigin Hlimit Hprice Hhistory Hcounters.
unfold Result.when_ in Hrun.
destruct (negb (Evmc.Result.StatusCode.is_success (Evmc.Result.t.status_code result)));
[discriminate Hrun|].
injection Hrun as <-.
split; [exact Hhistory|split; [exact Hcounters|reflexivity]].
Qed.
Lemma system_message_activity_history block addr data :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
let post := snd (@E.process_system_message F
block addr data) in
W.t.history (B.t.world_state post) = W.t.history (B.t.world_state block) ∧
W.t.next_emptying_transaction_block (B.t.world_state post) =
W.t.next_emptying_transaction_block (B.t.world_state block).
Proof.
intro Hrevision. cbn zeta. unfold E.process_system_message.
match goal with |- context [if ?test then _ else _] ⇒ destruct test end;
[split; reflexivity|].
cbn beta iota zeta.
match goal with |- context [E.Host.call ?message ?entry] ⇒
set (msg := message); set (initial := entry)
end.
assert (Hgas : (0 ≤ Evmc.Message.t.gas msg < 2^63)%Z)
by (change (0 ≤ 30000000 < 2^63)%Z; lia).
pose proof (@execution_call_preserves_context F
msg Hrevision Hgas initial) as Hcontext.
destruct (E.Host.call msg initial) as [result afterVm].
cbn [snd] in Hcontext. unfold transactionContext in Hcontext.
injection Hcontext as Hinitial Hblock Horigin Hlimit Hprice Hhistory Hcounters.
split; assumption.
Qed.
Lemma read_counter_same_map world other query :
W.t.next_emptying_transaction_block world = W.t.next_emptying_transaction_block other →
readCounter world query = readCounter other query.
Proof.
intro Hmaps. change ((match OCamlMap.Make.find_opt stringOrder query
(W.t.next_emptying_transaction_block world) with
| Some value ⇒ value | None ⇒ 0%N end) = readCounter other query).
rewrite Hmaps. reflexivity.
Qed.
Theorem dispatched_transactions_activity_history block txs post :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
WellFormed (W.t.next_emptying_transaction_block (B.t.world_state block)) →
Result.List.fold_leftM (@E.dispatch_transaction F) block txs = inl post →
W.t.history (B.t.world_state post) = W.t.history (B.t.world_state block) ∧
WellFormed (W.t.next_emptying_transaction_block (B.t.world_state post)) ∧
B.t.current_block post = B.t.current_block block ∧
∀ query,
readCounter (B.t.world_state post) query = readCounter (B.t.world_state block) query ∨
readCounter (B.t.world_state post) query =
(Chain.Ethereum.Block.Header.t.number
(Chain.Ethereum.Block.t.header (B.t.current_block block)) +
@Reserve_balance.execution_consensus_delay )%N.
Proof.
intros Hrevision. revert block. induction txs as [|tx txs IH]; intros block Hwf Hrun.
- injection Hrun as <-. split; [reflexivity|]. split; [exact Hwf|].
split; [reflexivity|]. intro query. left. reflexivity.
- change (Result.op_letdollar (@E.dispatch_transaction F block tx)
(fun next ⇒ Result.List.fold_leftM (@E.dispatch_transaction F) next txs) = inl post) in Hrun.
destruct (@E.dispatch_transaction F block tx) as [next|error] eqn:Hstep;
[|discriminate Hrun].
assert (HstepProps :
W.t.history (B.t.world_state next) = W.t.history (B.t.world_state block) ∧
WellFormed (W.t.next_emptying_transaction_block (B.t.world_state next)) ∧
B.t.current_block next = B.t.current_block block ∧
∀ query,
readCounter (B.t.world_state next) query = readCounter (B.t.world_state block) query ∨
readCounter (B.t.world_state next) query =
(Chain.Ethereum.Block.Header.t.number
(Chain.Ethereum.Block.t.header (B.t.current_block block)) +
@Reserve_balance.execution_consensus_delay )%N).
{ destruct (@transactionformat.dispatch_transaction_cases F block tx next Hstep)
as [[sender [_ Hstep']] | [_ Hstep']].
- destruct (@E.validate_transaction F block tx) as [validation|error] eqn:Hvalidation.
2: { unfold E.process_transaction in Hstep'. rewrite Hvalidation in Hstep'. discriminate Hstep'. }
destruct (process_transaction_activity_history block tx validation next
Hrevision Hwf Hvalidation Hstep') as [Hhistory [HnextWf Hcounters]].
pose proof (@process_transaction_current_block F block tx next Hstep') as Hblock.
split; [exact Hhistory|]. split; [exact HnextWf|]. split; [exact Hblock|].
intro query. rewrite Hcounters.
destruct (existsb (fun addr ⇒ String.eqb addr query)
(E.transaction_validation.sender validation :: fst (transactionPrefix block tx validation)));
[right|left]; reflexivity.
- destruct (process_monad_system_transaction_activity_history block tx next Hrevision Hstep')
as [Hhistory [Hcounters Hblock]].
split; [exact Hhistory|]. split; [rewrite Hcounters; exact Hwf|]. split; [exact Hblock|].
intro query. left. exact (read_counter_same_map _ _ query Hcounters). }
destruct HstepProps as [Hhistory [HnextWf [Hblock Hcounters]]].
destruct (IH next HnextWf Hrun) as [HtailHistory [HpostWf [HtailBlock HtailCounters]]].
split; [congruence|]. split; [exact HpostWf|]. split; [congruence|].
intro query. destruct (HtailCounters query) as [Hsame|Hbumped].
+ rewrite Hsame. exact (Hcounters query).
+ right. rewrite Hbumped, Hblock. reflexivity.
Qed.
Lemma withdrawals_activity_history block withdrawals :
let post := OCamlList.fold_left (@E.process_withdrawal F) block withdrawals in
W.t.history (B.t.world_state post) = W.t.history (B.t.world_state block) ∧
W.t.next_emptying_transaction_block (B.t.world_state post) =
W.t.next_emptying_transaction_block (B.t.world_state block).
Proof.
revert block. induction withdrawals as [|wd withdrawals IH]; intro block.
- split; reflexivity.
- cbn [OCamlList.fold_left]. exact (IH (@E.process_withdrawal F block wd)).
Qed.
Context {UTries : Basics.Unreachable (OCamlIarray.t Mpt.Trie.t)}
{UChar : Basics.Unreachable OCamlChar.t} {UWorld : Basics.Unreachable W.t}
{UTrie : Basics.Unreachable Mpt.Trie.t} {UNibbles : Basics.Unreachable Mpt.Nibbles.t}
{UBlock : Basics.Unreachable Chain.Ethereum.Block.t}.
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
WellFormed (W.t.next_emptying_transaction_block (B.t.world_state block)) →
Result.List.fold_leftM (@E.process_transaction F) block txs = inl post →
W.t.history (B.t.world_state post) = W.t.history (B.t.world_state block) ∧
WellFormed (W.t.next_emptying_transaction_block (B.t.world_state post)) ∧
B.t.current_block post = B.t.current_block block ∧
∀ query,
readCounter (B.t.world_state post) query = readCounter (B.t.world_state block) query ∨
readCounter (B.t.world_state post) query =
(Chain.Ethereum.Block.Header.t.number
(Chain.Ethereum.Block.t.header (B.t.current_block block)) +
@Reserve_balance.execution_consensus_delay )%N.
Proof.
intros Hrevision. revert block. induction txs as [|tx txs IH]; intros block Hwf Hrun.
- injection Hrun as <-. split; [reflexivity|]. split; [exact Hwf|].
split; [reflexivity|]. intro query. left. reflexivity.
- change (Result.op_letdollar (@E.process_transaction F block tx)
(fun next ⇒ Result.List.fold_leftM (@E.process_transaction F) next txs) = inl post) in Hrun.
destruct (@E.process_transaction F block tx) as [next|error] eqn:Hstep;
[|discriminate Hrun].
destruct (@E.validate_transaction F block tx) as [validation|error] eqn:Hvalidation.
2: { unfold E.process_transaction in Hstep. rewrite Hvalidation in Hstep. discriminate Hstep. }
destruct (process_transaction_activity_history block tx validation next
Hrevision Hwf Hvalidation Hstep) as [Hhistory [HnextWf Hcounters]].
pose proof (@process_transaction_current_block F
block tx next Hstep) as Hblock.
destruct (IH next HnextWf Hrun) as [HtailHistory [HpostWf [HtailBlock HtailCounters]]].
split; [congruence|]. split; [exact HpostWf|]. split; [congruence|].
intro query. destruct (HtailCounters query) as [Hsame|Hbumped].
+ rewrite Hsame, Hcounters.
destruct (existsb (fun addr ⇒ String.eqb addr query)
(E.transaction_validation.sender validation :: fst (transactionPrefix block tx validation)));
[right|left]; reflexivity.
+ right. rewrite Hbumped, Hblock. reflexivity.
Qed.
Lemma process_monad_system_transaction_activity_history block tx post :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
@E.process_monad_system_transaction F block tx = inl post →
W.t.history (B.t.world_state post) = W.t.history (B.t.world_state block) ∧
W.t.next_emptying_transaction_block (B.t.world_state post) =
W.t.next_emptying_transaction_block (B.t.world_state block) ∧
B.t.current_block post = B.t.current_block block.
Proof.
intros Hrevision Hrun. unfold E.process_monad_system_transaction in Hrun.
destruct (@E.validate_monad_system_transaction F block tx Chain.Monad.system_sender)
as [[]|error]; [|discriminate Hrun].
change (@Result.op_letdollar) with
(fun (A B C : Set) (r : A + B) (f : A → C + B) ⇒
match r with inl value ⇒ f value | inr error ⇒ inr error end) in Hrun.
cbv beta iota zeta in Hrun.
match type of Hrun with context [E.Host.call_from_monad_system_transaction ?message ?initial] ⇒
set (msg := message) in *; set (beforeVm := initial) in ×
end.
assert (Hgas : (0 ≤ Evmc.Message.t.gas msg < 2^63)%Z).
{ unfold msg, E.prepare_message. destruct (T.call_or_create_value tx) as [[]|[]];
change (0 ≤ 0 < 2^63)%Z; lia. }
pose proof (@execution_call_from_monad_system_transaction_preserves_context F
msg Hrevision Hgas beforeVm) as Hvm.
destruct (E.Host.call_from_monad_system_transaction msg beforeVm) as [result afterVm].
cbn [snd] in Hvm. unfold transactionContext in Hvm.
injection Hvm as Hinitial Hblock Horigin Hlimit Hprice Hhistory Hcounters.
unfold Result.when_ in Hrun.
destruct (negb (Evmc.Result.StatusCode.is_success (Evmc.Result.t.status_code result)));
[discriminate Hrun|].
injection Hrun as <-.
split; [exact Hhistory|split; [exact Hcounters|reflexivity]].
Qed.
Lemma system_message_activity_history block addr data :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
let post := snd (@E.process_system_message F
block addr data) in
W.t.history (B.t.world_state post) = W.t.history (B.t.world_state block) ∧
W.t.next_emptying_transaction_block (B.t.world_state post) =
W.t.next_emptying_transaction_block (B.t.world_state block).
Proof.
intro Hrevision. cbn zeta. unfold E.process_system_message.
match goal with |- context [if ?test then _ else _] ⇒ destruct test end;
[split; reflexivity|].
cbn beta iota zeta.
match goal with |- context [E.Host.call ?message ?entry] ⇒
set (msg := message); set (initial := entry)
end.
assert (Hgas : (0 ≤ Evmc.Message.t.gas msg < 2^63)%Z)
by (change (0 ≤ 30000000 < 2^63)%Z; lia).
pose proof (@execution_call_preserves_context F
msg Hrevision Hgas initial) as Hcontext.
destruct (E.Host.call msg initial) as [result afterVm].
cbn [snd] in Hcontext. unfold transactionContext in Hcontext.
injection Hcontext as Hinitial Hblock Horigin Hlimit Hprice Hhistory Hcounters.
split; assumption.
Qed.
Lemma read_counter_same_map world other query :
W.t.next_emptying_transaction_block world = W.t.next_emptying_transaction_block other →
readCounter world query = readCounter other query.
Proof.
intro Hmaps. change ((match OCamlMap.Make.find_opt stringOrder query
(W.t.next_emptying_transaction_block world) with
| Some value ⇒ value | None ⇒ 0%N end) = readCounter other query).
rewrite Hmaps. reflexivity.
Qed.
Theorem dispatched_transactions_activity_history block txs post :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
WellFormed (W.t.next_emptying_transaction_block (B.t.world_state block)) →
Result.List.fold_leftM (@E.dispatch_transaction F) block txs = inl post →
W.t.history (B.t.world_state post) = W.t.history (B.t.world_state block) ∧
WellFormed (W.t.next_emptying_transaction_block (B.t.world_state post)) ∧
B.t.current_block post = B.t.current_block block ∧
∀ query,
readCounter (B.t.world_state post) query = readCounter (B.t.world_state block) query ∨
readCounter (B.t.world_state post) query =
(Chain.Ethereum.Block.Header.t.number
(Chain.Ethereum.Block.t.header (B.t.current_block block)) +
@Reserve_balance.execution_consensus_delay )%N.
Proof.
intros Hrevision. revert block. induction txs as [|tx txs IH]; intros block Hwf Hrun.
- injection Hrun as <-. split; [reflexivity|]. split; [exact Hwf|].
split; [reflexivity|]. intro query. left. reflexivity.
- change (Result.op_letdollar (@E.dispatch_transaction F block tx)
(fun next ⇒ Result.List.fold_leftM (@E.dispatch_transaction F) next txs) = inl post) in Hrun.
destruct (@E.dispatch_transaction F block tx) as [next|error] eqn:Hstep;
[|discriminate Hrun].
assert (HstepProps :
W.t.history (B.t.world_state next) = W.t.history (B.t.world_state block) ∧
WellFormed (W.t.next_emptying_transaction_block (B.t.world_state next)) ∧
B.t.current_block next = B.t.current_block block ∧
∀ query,
readCounter (B.t.world_state next) query = readCounter (B.t.world_state block) query ∨
readCounter (B.t.world_state next) query =
(Chain.Ethereum.Block.Header.t.number
(Chain.Ethereum.Block.t.header (B.t.current_block block)) +
@Reserve_balance.execution_consensus_delay )%N).
{ destruct (@transactionformat.dispatch_transaction_cases F block tx next Hstep)
as [[sender [_ Hstep']] | [_ Hstep']].
- destruct (@E.validate_transaction F block tx) as [validation|error] eqn:Hvalidation.
2: { unfold E.process_transaction in Hstep'. rewrite Hvalidation in Hstep'. discriminate Hstep'. }
destruct (process_transaction_activity_history block tx validation next
Hrevision Hwf Hvalidation Hstep') as [Hhistory [HnextWf Hcounters]].
pose proof (@process_transaction_current_block F block tx next Hstep') as Hblock.
split; [exact Hhistory|]. split; [exact HnextWf|]. split; [exact Hblock|].
intro query. rewrite Hcounters.
destruct (existsb (fun addr ⇒ String.eqb addr query)
(E.transaction_validation.sender validation :: fst (transactionPrefix block tx validation)));
[right|left]; reflexivity.
- destruct (process_monad_system_transaction_activity_history block tx next Hrevision Hstep')
as [Hhistory [Hcounters Hblock]].
split; [exact Hhistory|]. split; [rewrite Hcounters; exact Hwf|]. split; [exact Hblock|].
intro query. left. exact (read_counter_same_map _ _ query Hcounters). }
destruct HstepProps as [Hhistory [HnextWf [Hblock Hcounters]]].
destruct (IH next HnextWf Hrun) as [HtailHistory [HpostWf [HtailBlock HtailCounters]]].
split; [congruence|]. split; [exact HpostWf|]. split; [congruence|].
intro query. destruct (HtailCounters query) as [Hsame|Hbumped].
+ rewrite Hsame. exact (Hcounters query).
+ right. rewrite Hbumped, Hblock. reflexivity.
Qed.
Lemma withdrawals_activity_history block withdrawals :
let post := OCamlList.fold_left (@E.process_withdrawal F) block withdrawals in
W.t.history (B.t.world_state post) = W.t.history (B.t.world_state block) ∧
W.t.next_emptying_transaction_block (B.t.world_state post) =
W.t.next_emptying_transaction_block (B.t.world_state block).
Proof.
revert block. induction withdrawals as [|wd withdrawals IH]; intro block.
- split; reflexivity.
- cbn [OCamlList.fold_left]. exact (IH (@E.process_withdrawal F block wd)).
Qed.
Context {UTries : Basics.Unreachable (OCamlIarray.t Mpt.Trie.t)}
{UChar : Basics.Unreachable OCamlChar.t} {UWorld : Basics.Unreachable W.t}
{UTrie : Basics.Unreachable Mpt.Trie.t} {UNibbles : Basics.Unreachable Mpt.Nibbles.t}
{UBlock : Basics.Unreachable Chain.Ethereum.Block.t}.
At block end, each counter is either unchanged or set to block + K.
This follows from actual transaction processing, including both system
calls and withdrawals; no premise assumes those calls are harmless.
Together with process_transaction_activity_history, this rules out
later operations erasing a sender's or applied authority's recent activity.
Theorem process_block_counter_values verify world block post :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
WellFormed (W.t.next_emptying_transaction_block world) →
@E.process_block F verify world block = inl post →
WellFormed (W.t.next_emptying_transaction_block post) ∧
∀ query,
readCounter post query = readCounter world query ∨
readCounter post query = (Chain.Ethereum.Block.Header.t.number
(Chain.Ethereum.Block.t.header block) + @Reserve_balance.execution_consensus_delay )%N.
Proof.
intros Hrevision Hwf Hrun.
unfold E.process_block in Hrun. rewrite Hrevision in Hrun.
change (@Result.op_letdollar) with
(fun (A B C : Set) (r : A + B) (f : A → C + B) ⇒
match r with inl value ⇒ f value | inr error ⇒ inr error end) in Hrun.
destruct (@E.validate_block F world block) as [[]|error]; [|discriminate Hrun].
cbn beta iota zeta in Hrun.
match type of Hrun with context [B.make ?w block] ⇒ set (initial := B.make w block) in × end.
match type of Hrun with context [E.process_system_message initial ?addr ?data] ⇒
pose proof (system_message_activity_history initial addr data Hrevision) as Hbeacon;
pose proof (@system_message_current_block F
initial addr data) as HbeaconBlock;
destruct (E.process_system_message initial addr data) as [beaconResult afterBeacon]
end.
cbn beta iota zeta delta [snd] in Hbeacon, HbeaconBlock, Hrun.
match type of Hrun with context [E.process_system_message afterBeacon ?addr ?data] ⇒
pose proof (system_message_activity_history afterBeacon addr data Hrevision) as Hhistory;
pose proof (@system_message_current_block F
afterBeacon addr data) as HhistoryBlock;
destruct (E.process_system_message afterBeacon addr data) as [historyResult afterHistory]
end.
cbn beta iota zeta delta [snd] in Hhistory, HhistoryBlock, Hrun.
assert (HbaseMap : W.t.next_emptying_transaction_block (B.t.world_state afterHistory) =
W.t.next_emptying_transaction_block world).
{ rewrite (proj2 Hhistory), (proj2 Hbeacon). reflexivity. }
assert (HbaseWf : WellFormed (W.t.next_emptying_transaction_block (B.t.world_state afterHistory))).
{ rewrite HbaseMap. exact Hwf. }
match type of Hrun with context [Result.List.fold_leftM ?step afterHistory ?txs] ⇒
destruct (Result.List.fold_leftM step afterHistory txs) as [afterTransactions|error] eqn:Htransactions
end.
2: discriminate Hrun.
cbn beta iota zeta in Hrun.
destruct (dispatched_transactions_activity_history afterHistory _ afterTransactions
Hrevision HbaseWf Htransactions) as [_ [HtxWf [_ HtxCounters]]].
pose proof (withdrawals_activity_history afterTransactions
(Chain.Ethereum.Block.t.withdrawals block)) as [_ Hwithdrawals].
match type of Hrun with context [E.validate_block ?world ?block] ⇒
destruct (E.validate_block world block) as [[]|error]
end.
2: discriminate Hrun.
match type of Hrun with context [if verify then ?check else _] ⇒
destruct verify; [destruct check as [[]|error]; [|discriminate Hrun]|]
end.
all: injection Hrun as <-; split.
1,3: change (WellFormed (W.t.next_emptying_transaction_block (B.t.world_state
(OCamlList.fold_left (@E.process_withdrawal F) afterTransactions
(Chain.Ethereum.Block.t.withdrawals block)))));
rewrite Hwithdrawals; exact HtxWf.
all: intro query;
change (readCounter (B.t.world_state (OCamlList.fold_left (@E.process_withdrawal F)
afterTransactions (Chain.Ethereum.Block.t.withdrawals block))) query = readCounter world query ∨
readCounter (B.t.world_state (OCamlList.fold_left (@E.process_withdrawal F)
afterTransactions (Chain.Ethereum.Block.t.withdrawals block))) query =
(Chain.Ethereum.Block.Header.t.number (Chain.Ethereum.Block.t.header block) +
@Reserve_balance.execution_consensus_delay )%N).
all: cbv beta; rewrite (read_counter_same_map _ _ query Hwithdrawals);
specialize (HtxCounters query);
rewrite (read_counter_same_map _ _ query HbaseMap), HhistoryBlock, HbeaconBlock in HtxCounters;
exact HtxCounters.
Qed.
End Execution.
Print Assumptions process_transaction_activity_history.
Print Assumptions transactions_activity_history.
Print Assumptions system_message_activity_history.
Print Assumptions process_block_counter_values.
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
WellFormed (W.t.next_emptying_transaction_block world) →
@E.process_block F verify world block = inl post →
WellFormed (W.t.next_emptying_transaction_block post) ∧
∀ query,
readCounter post query = readCounter world query ∨
readCounter post query = (Chain.Ethereum.Block.Header.t.number
(Chain.Ethereum.Block.t.header block) + @Reserve_balance.execution_consensus_delay )%N.
Proof.
intros Hrevision Hwf Hrun.
unfold E.process_block in Hrun. rewrite Hrevision in Hrun.
change (@Result.op_letdollar) with
(fun (A B C : Set) (r : A + B) (f : A → C + B) ⇒
match r with inl value ⇒ f value | inr error ⇒ inr error end) in Hrun.
destruct (@E.validate_block F world block) as [[]|error]; [|discriminate Hrun].
cbn beta iota zeta in Hrun.
match type of Hrun with context [B.make ?w block] ⇒ set (initial := B.make w block) in × end.
match type of Hrun with context [E.process_system_message initial ?addr ?data] ⇒
pose proof (system_message_activity_history initial addr data Hrevision) as Hbeacon;
pose proof (@system_message_current_block F
initial addr data) as HbeaconBlock;
destruct (E.process_system_message initial addr data) as [beaconResult afterBeacon]
end.
cbn beta iota zeta delta [snd] in Hbeacon, HbeaconBlock, Hrun.
match type of Hrun with context [E.process_system_message afterBeacon ?addr ?data] ⇒
pose proof (system_message_activity_history afterBeacon addr data Hrevision) as Hhistory;
pose proof (@system_message_current_block F
afterBeacon addr data) as HhistoryBlock;
destruct (E.process_system_message afterBeacon addr data) as [historyResult afterHistory]
end.
cbn beta iota zeta delta [snd] in Hhistory, HhistoryBlock, Hrun.
assert (HbaseMap : W.t.next_emptying_transaction_block (B.t.world_state afterHistory) =
W.t.next_emptying_transaction_block world).
{ rewrite (proj2 Hhistory), (proj2 Hbeacon). reflexivity. }
assert (HbaseWf : WellFormed (W.t.next_emptying_transaction_block (B.t.world_state afterHistory))).
{ rewrite HbaseMap. exact Hwf. }
match type of Hrun with context [Result.List.fold_leftM ?step afterHistory ?txs] ⇒
destruct (Result.List.fold_leftM step afterHistory txs) as [afterTransactions|error] eqn:Htransactions
end.
2: discriminate Hrun.
cbn beta iota zeta in Hrun.
destruct (dispatched_transactions_activity_history afterHistory _ afterTransactions
Hrevision HbaseWf Htransactions) as [_ [HtxWf [_ HtxCounters]]].
pose proof (withdrawals_activity_history afterTransactions
(Chain.Ethereum.Block.t.withdrawals block)) as [_ Hwithdrawals].
match type of Hrun with context [E.validate_block ?world ?block] ⇒
destruct (E.validate_block world block) as [[]|error]
end.
2: discriminate Hrun.
match type of Hrun with context [if verify then ?check else _] ⇒
destruct verify; [destruct check as [[]|error]; [|discriminate Hrun]|]
end.
all: injection Hrun as <-; split.
1,3: change (WellFormed (W.t.next_emptying_transaction_block (B.t.world_state
(OCamlList.fold_left (@E.process_withdrawal F) afterTransactions
(Chain.Ethereum.Block.t.withdrawals block)))));
rewrite Hwithdrawals; exact HtxWf.
all: intro query;
change (readCounter (B.t.world_state (OCamlList.fold_left (@E.process_withdrawal F)
afterTransactions (Chain.Ethereum.Block.t.withdrawals block))) query = readCounter world query ∨
readCounter (B.t.world_state (OCamlList.fold_left (@E.process_withdrawal F)
afterTransactions (Chain.Ethereum.Block.t.withdrawals block))) query =
(Chain.Ethereum.Block.Header.t.number (Chain.Ethereum.Block.t.header block) +
@Reserve_balance.execution_consensus_delay )%N).
all: cbv beta; rewrite (read_counter_same_map _ _ query Hwithdrawals);
specialize (HtxCounters query);
rewrite (read_counter_same_map _ _ query HbaseMap), HhistoryBlock, HbeaconBlock in HtxCounters;
exact HtxCounters.
Qed.
End Execution.
Print Assumptions process_transaction_activity_history.
Print Assumptions transactions_activity_history.
Print Assumptions system_message_activity_history.
Print Assumptions process_block_counter_values.