Library QedkConcrete.consensuscorrectnessproofs
Proof assembly for consensus_correct; no protocol or execution changes.
From Stdlib Require Import List ZArith Lia.
Require Export QedkConcrete.consensuscorrectness.
Require Import QedkConcrete.consensusadvance QedkConcrete.consensusblocks
QedkConcrete.consensuswindow QedkConcrete.consensuswindowproofs
QedkConcrete.consensusbacking QedkConcrete.consensustransaction
QedkConcrete.consensushistoryproofs QedkConcrete.transactionhistoryprojection
QedkConcrete.consensusprefix QedkConcrete.supply QedkConcrete.hostaccountformat
QedkConcrete.blockpersistentcode QedkConcrete.hashwords QedkConcrete.blsmapbounds
QedkConcrete.precompileoutputs QedkConcrete.dispatchoutputs
QedkConcrete.reservewindowtrace QedkConcrete.hoststoragewords
QedkConcrete.blockreservewindow QedkConcrete.blocktransactionentry QedkConcrete.miscblockproofs
QedkConcrete.vendorAssumptions.
Set Default Goal Selector "!".
#[local] Hint Extern 100 (Basics.Unreachable _) ⇒
(apply Opaque.legacy_witness; Opaque.opaque_inhabit 64%nat) : typeclass_instances.
Import ListNotations Execution.Error.
Local Open Scope Z_scope.
Section Runtime.
Context {F : E.FArgs}.
Local Abbreviation processBlocks verify :=
(Result.List.fold_leftM (@E.process_block F verify)).
Lemma conditions_prefix signers until verify snapshot past rest :
WindowConditions signers until verify snapshot (past ++ rest) →
WindowConditions signers until verify snapshot past.
Proof.
intros [Hsnapshot Hinputs Horder Hcreation Hstaking Hsupply].
rewrite Forall_app in Hinputs. destruct Hinputs as [Hpast Hrest].
constructor; try assumption.
- exact (ordered_block_numbers_prefix past rest Horder).
- exact (window_creation_safe_prefix signers verify snapshot past rest Hcreation).
- exact (window_staking_valid_prefix verify snapshot past rest Hstaking).
- pose proof (input_window_credits_nonnegative signers until rest Hrest).
rewrite window_credits_app in Hsupply. lia.
Qed.
Lemma acceptance_prefix snapshot height past rest :
consensusAccepts snapshot height (past ++ rest) →
consensusAccepts snapshot height past.
Proof.
intros [next Hcheck]. rewrite check_blocks_app in Hcheck.
destruct (checkBlocks snapshot (initialConsensusState snapshot height) past)
as [middle|] eqn:Hpast; [∃ middle; exact Hpast|discriminate].
Qed.
Lemma accepted_window_validates signers until verify snapshot blocks height :
ProtocolConditions → WindowConditions signers until verify snapshot blocks →
consensusAccepts snapshot height blocks →
∀ details, processBlocks verify snapshot blocks ≠
inr (Execution.Error.Invalid_transaction details).
Proof.
intros [Hrevision Hchain]
[[Hformat Hsenders Hnative Hbalance Hcounters Hsystem Hcode Hstorage]
Hinputs Horder Hcreation Hstaking Hsupply] [next Hcheck] details Herror.
exact (consensus_no_transaction_validation_error bls_g1_cofactor_order bls_g2_cofactor_order
snapshot signers until verify blocks height next details Hrevision
keccak256_output_size sha256_output_size Hchain Hformat Hsenders Hnative
Hinputs Hcreation Hstaking Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Herror).
Qed.
Lemma accepted_suffix_rechecks signers until verify snapshot past first rest height post :
ProtocolConditions →
WindowConditions signers until verify snapshot (past ++ first :: rest) →
consensusAccepts snapshot height (past ++ first :: rest) →
processBlocks verify snapshot past = inl post →
consensusAccepts post (remainingHeight height (first :: rest)) (first :: rest) ∧
WindowConditions signers until verify post (first :: rest).
Proof.
intros [Hrevision Hchain]
[[Hformat Hsenders Hnative Hbalance Hcounters Hsystem Hcode Hstorage]
Hinputs Horder Hcreation Hstaking Hsupply] [next Hcheck] Hrun.
destruct (consensus_snapshot_advancement bls_g1_cofactor_order bls_g2_cofactor_order
snapshot signers until verify past first rest height next post Hrevision
keccak256_output_size sha256_output_size Hchain Hformat Hsenders
Hnative Hinputs Hcreation Hstaking Hbalance Hcounters Hsystem Hcode Hstorage Hsupply
Hcheck Horder Hrun)
as [Haccept [Hsenders' [Hbalance' [Hformat' [Hsystem' [Hcounters'
[Hcode' [Hstorage' [Hsupply' [Hcreation' Hstaking']]]]]]]]]].
split; [exact Haccept|]. constructor; try assumption.
- constructor; assumption.
- rewrite Forall_app in Hinputs. exact (proj2 Hinputs).
- intros before block after Hsplit.
specialize (Horder (past ++ before) block after
ltac:(rewrite <- app_assoc, <- Hsplit; reflexivity)).
rewrite Forall_app in Horder. exact (proj2 Horder).
Qed.
Require Export QedkConcrete.consensuscorrectness.
Require Import QedkConcrete.consensusadvance QedkConcrete.consensusblocks
QedkConcrete.consensuswindow QedkConcrete.consensuswindowproofs
QedkConcrete.consensusbacking QedkConcrete.consensustransaction
QedkConcrete.consensushistoryproofs QedkConcrete.transactionhistoryprojection
QedkConcrete.consensusprefix QedkConcrete.supply QedkConcrete.hostaccountformat
QedkConcrete.blockpersistentcode QedkConcrete.hashwords QedkConcrete.blsmapbounds
QedkConcrete.precompileoutputs QedkConcrete.dispatchoutputs
QedkConcrete.reservewindowtrace QedkConcrete.hoststoragewords
QedkConcrete.blockreservewindow QedkConcrete.blocktransactionentry QedkConcrete.miscblockproofs
QedkConcrete.vendorAssumptions.
Set Default Goal Selector "!".
#[local] Hint Extern 100 (Basics.Unreachable _) ⇒
(apply Opaque.legacy_witness; Opaque.opaque_inhabit 64%nat) : typeclass_instances.
Import ListNotations Execution.Error.
Local Open Scope Z_scope.
Section Runtime.
Context {F : E.FArgs}.
Local Abbreviation processBlocks verify :=
(Result.List.fold_leftM (@E.process_block F verify)).
Lemma conditions_prefix signers until verify snapshot past rest :
WindowConditions signers until verify snapshot (past ++ rest) →
WindowConditions signers until verify snapshot past.
Proof.
intros [Hsnapshot Hinputs Horder Hcreation Hstaking Hsupply].
rewrite Forall_app in Hinputs. destruct Hinputs as [Hpast Hrest].
constructor; try assumption.
- exact (ordered_block_numbers_prefix past rest Horder).
- exact (window_creation_safe_prefix signers verify snapshot past rest Hcreation).
- exact (window_staking_valid_prefix verify snapshot past rest Hstaking).
- pose proof (input_window_credits_nonnegative signers until rest Hrest).
rewrite window_credits_app in Hsupply. lia.
Qed.
Lemma acceptance_prefix snapshot height past rest :
consensusAccepts snapshot height (past ++ rest) →
consensusAccepts snapshot height past.
Proof.
intros [next Hcheck]. rewrite check_blocks_app in Hcheck.
destruct (checkBlocks snapshot (initialConsensusState snapshot height) past)
as [middle|] eqn:Hpast; [∃ middle; exact Hpast|discriminate].
Qed.
Lemma accepted_window_validates signers until verify snapshot blocks height :
ProtocolConditions → WindowConditions signers until verify snapshot blocks →
consensusAccepts snapshot height blocks →
∀ details, processBlocks verify snapshot blocks ≠
inr (Execution.Error.Invalid_transaction details).
Proof.
intros [Hrevision Hchain]
[[Hformat Hsenders Hnative Hbalance Hcounters Hsystem Hcode Hstorage]
Hinputs Horder Hcreation Hstaking Hsupply] [next Hcheck] details Herror.
exact (consensus_no_transaction_validation_error bls_g1_cofactor_order bls_g2_cofactor_order
snapshot signers until verify blocks height next details Hrevision
keccak256_output_size sha256_output_size Hchain Hformat Hsenders Hnative
Hinputs Hcreation Hstaking Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Herror).
Qed.
Lemma accepted_suffix_rechecks signers until verify snapshot past first rest height post :
ProtocolConditions →
WindowConditions signers until verify snapshot (past ++ first :: rest) →
consensusAccepts snapshot height (past ++ first :: rest) →
processBlocks verify snapshot past = inl post →
consensusAccepts post (remainingHeight height (first :: rest)) (first :: rest) ∧
WindowConditions signers until verify post (first :: rest).
Proof.
intros [Hrevision Hchain]
[[Hformat Hsenders Hnative Hbalance Hcounters Hsystem Hcode Hstorage]
Hinputs Horder Hcreation Hstaking Hsupply] [next Hcheck] Hrun.
destruct (consensus_snapshot_advancement bls_g1_cofactor_order bls_g2_cofactor_order
snapshot signers until verify past first rest height next post Hrevision
keccak256_output_size sha256_output_size Hchain Hformat Hsenders
Hnative Hinputs Hcreation Hstaking Hbalance Hcounters Hsystem Hcode Hstorage Hsupply
Hcheck Horder Hrun)
as [Haccept [Hsenders' [Hbalance' [Hformat' [Hsystem' [Hcounters'
[Hcode' [Hstorage' [Hsupply' [Hcreation' Hstaking']]]]]]]]]].
split; [exact Haccept|]. constructor; try assumption.
- constructor; assumption.
- rewrite Forall_app in Hinputs. exact (proj2 Hinputs).
- intros before block after Hsplit.
specialize (Horder (past ++ before) block after
ltac:(rewrite <- app_assoc, <- Hsplit; reflexivity)).
rewrite Forall_app in Horder. exact (proj2 Horder).
Qed.
The empty-suffix case still preserves the final state conditions. There
is no next block to use in consensus_snapshot_advancement, so use the
same execution induction and reserve-storage trace directly.
Lemma accepted_execution_preserves_snapshot signers until verify snapshot blocks height post :
ProtocolConditions → WindowConditions signers until verify snapshot blocks →
consensusAccepts snapshot height blocks →
processBlocks verify snapshot blocks = inl post →
SnapshotConditions signers post.
Proof.
intros [Hrevision Hchain]
[[Hformat Hsenders Hnative Hbalance Hcounters Hsystem Hcode Hstorage]
Hinputs Horder Hcreation _ Hsupply] [next Hcheck] Hrun.
pose proof (@native_output_bounds_from_bls_maps E.Instantiation_fargs Hrevision sha256_output_size
(@bls_map_output_bounds_from_cofactor_orders E.Instantiation_fargs
bls_g1_cofactor_order bls_g2_cofactor_order)) as Houtputs.
pose proof (ordered_window_configuration snapshot signers until verify blocks
Hrevision Hformat Hbalance Hcode Hstorage
(fun a Ha ⇒ proj1 (Hnative a Ha)) Hinputs Horder) as Hconfig.
assert (Hinitial : BudgetBacking snapshot (initialConsensusState snapshot height)
snapshot signers height until).
{ constructor.
- apply initial_history_matches; assumption || exact (proj1 Hbalance).
- intros a _. apply initial_budget_backed; assumption.
- intros; lia. }
pose proof (window_induction_under_configuration_agreement snapshot signers until
verify blocks snapshot Hrevision keccak256_output_size Houtputs Hchain Hformat Hsenders Hnative
Hinputs Hcreation _ next height Hbalance Hformat Hsystem Hinitial Hsupply Hconfig Hcheck)
as Hpreserved.
change (processBlocks verify snapshot blocks = inl post) in Hrun.
rewrite Hrun in Hpreserved.
destruct Hpreserved as [finalHeight [Hbacked [Hbalance' [Hformat' [Hsystem' Htotal]]]]].
pose proof (input_signature_exclusions signers until blocks
(fun a Ha ⇒ proj1 (Hnative a Ha)) Hinputs) as Hsignatures.
destruct (process_blocks_reserve_trace verify blocks Hrevision Hsignatures snapshot post
(proj1 Hbalance) Hcode Hrun) as [trace [Hheights [Htrace [_ Hcode']]]].
constructor; try assumption.
- exact (history_noncontract _ _ _ _ _ (backing_history _ _ _ _ _ _ Hbacked)).
- exact (history_counters_wf _ _ _ _ _ (backing_history _ _ _ _ _ _ Hbacked)).
- exact (proj1 (reserve_trace_representation _ _ _ Hstorage
(read_account_storage_words _ _
(proj1 (proj1 (world_format_components snapshot) Hformat))) Htrace)).
Qed.
End Runtime.
Section ConcreteExecutor.
Variable params : Execution.Make_Params_signature.
#[local] Instance execution : E.FArgs := executionArgs params.
ProtocolConditions → WindowConditions signers until verify snapshot blocks →
consensusAccepts snapshot height blocks →
processBlocks verify snapshot blocks = inl post →
SnapshotConditions signers post.
Proof.
intros [Hrevision Hchain]
[[Hformat Hsenders Hnative Hbalance Hcounters Hsystem Hcode Hstorage]
Hinputs Horder Hcreation _ Hsupply] [next Hcheck] Hrun.
pose proof (@native_output_bounds_from_bls_maps E.Instantiation_fargs Hrevision sha256_output_size
(@bls_map_output_bounds_from_cofactor_orders E.Instantiation_fargs
bls_g1_cofactor_order bls_g2_cofactor_order)) as Houtputs.
pose proof (ordered_window_configuration snapshot signers until verify blocks
Hrevision Hformat Hbalance Hcode Hstorage
(fun a Ha ⇒ proj1 (Hnative a Ha)) Hinputs Horder) as Hconfig.
assert (Hinitial : BudgetBacking snapshot (initialConsensusState snapshot height)
snapshot signers height until).
{ constructor.
- apply initial_history_matches; assumption || exact (proj1 Hbalance).
- intros a _. apply initial_budget_backed; assumption.
- intros; lia. }
pose proof (window_induction_under_configuration_agreement snapshot signers until
verify blocks snapshot Hrevision keccak256_output_size Houtputs Hchain Hformat Hsenders Hnative
Hinputs Hcreation _ next height Hbalance Hformat Hsystem Hinitial Hsupply Hconfig Hcheck)
as Hpreserved.
change (processBlocks verify snapshot blocks = inl post) in Hrun.
rewrite Hrun in Hpreserved.
destruct Hpreserved as [finalHeight [Hbacked [Hbalance' [Hformat' [Hsystem' Htotal]]]]].
pose proof (input_signature_exclusions signers until blocks
(fun a Ha ⇒ proj1 (Hnative a Ha)) Hinputs) as Hsignatures.
destruct (process_blocks_reserve_trace verify blocks Hrevision Hsignatures snapshot post
(proj1 Hbalance) Hcode Hrun) as [trace [Hheights [Htrace [_ Hcode']]]].
constructor; try assumption.
- exact (history_noncontract _ _ _ _ _ (backing_history _ _ _ _ _ _ Hbacked)).
- exact (history_counters_wf _ _ _ _ _ (backing_history _ _ _ _ _ _ Hbacked)).
- exact (proj1 (reserve_trace_representation _ _ _ Hstorage
(read_account_storage_words _ _
(proj1 (proj1 (world_format_components snapshot) Hformat))) Htrace)).
Qed.
End Runtime.
Section ConcreteExecutor.
Variable params : Execution.Make_Params_signature.
#[local] Instance execution : E.FArgs := executionArgs params.
Generalized internal statement: preserve the result for arbitrary
initial reserve-lookup and upper window heights. The public statement
consensusCorrect derives those values from its block lists.
Definition consensusCorrectAtHeights : Prop :=
∀ snapshot signers until height prefix rest,
ProtocolConditions →
WindowConditions signers until false snapshot (prefix ++ rest) →
miscBlockChecks snapshot (prefix ++ rest) = true →
consensusAccepts snapshot height (prefix ++ rest) →
match executeBlocks params false snapshot prefix with
| inl post ⇒
consensusAccepts post (remainingHeight height rest) rest ∧
WindowConditions signers until false post rest ∧
miscBlockChecks post rest = true
| inr (Invalid_transaction _) ⇒ False
| inr (Invalid_block _) ⇒ False
end.
Theorem consensus_correct_at_heights : consensusCorrectAtHeights.
Proof.
unfold consensusCorrectAtHeights.
intros snapshot signers until height prefix rest Hprotocol Hconditions Hmisc Haccept.
pose proof (conditions_prefix _ _ _ _ _ _ Hconditions) as HprefixConditions.
pose proof (acceptance_prefix _ _ _ _ Haccept) as HprefixAccept.
pose proof (misc_checks_prefix_execution snapshot prefix rest
(protocol_revision Hprotocol) Hmisc) as HblockSafe.
change (match executeBlocks params false snapshot prefix with
| inl post ⇒ miscBlockChecks post rest = true
| inr (Execution.Error.Invalid_block _) ⇒ False
| inr (Execution.Error.Invalid_transaction _) ⇒ True
end) in HblockSafe.
destruct (executeBlocks params false snapshot prefix) as [post|[blockError|txError]] eqn:Hrun.
- assert (Hpostconditions : consensusAccepts post (remainingHeight height rest) rest ∧
WindowConditions signers until false post rest).
{ destruct rest as [|first rest].
- split; [eexists; reflexivity|].
pose proof (accepted_execution_preserves_snapshot _ _ _ _ _ _ _
Hprotocol HprefixConditions HprefixAccept Hrun) as Hpost.
constructor.
+ exact Hpost.
+ constructor.
+ intros before block after Hsplit.
destruct before; discriminate.
+ intros before block after reached Hsplit. destruct before; discriminate.
+ intros before block after reached Hsplit. destruct before; discriminate.
+ change (totalBalance post + 0 < 2^256).
destruct (snapshot_balances _ _ Hpost) as [_ [_ Hbound]]. lia.
- exact (accepted_suffix_rechecks _ _ _ _ _ _ _ _ _
Hprotocol Hconditions Haccept Hrun). }
destruct Hpostconditions as [Haccept' Hconditions'].
split; [exact Haccept'|]. split; assumption.
- exact HblockSafe.
- exact (accepted_window_validates _ _ _ _ _ _
Hprotocol HprefixConditions HprefixAccept txError Hrun).
Qed.
∀ snapshot signers until height prefix rest,
ProtocolConditions →
WindowConditions signers until false snapshot (prefix ++ rest) →
miscBlockChecks snapshot (prefix ++ rest) = true →
consensusAccepts snapshot height (prefix ++ rest) →
match executeBlocks params false snapshot prefix with
| inl post ⇒
consensusAccepts post (remainingHeight height rest) rest ∧
WindowConditions signers until false post rest ∧
miscBlockChecks post rest = true
| inr (Invalid_transaction _) ⇒ False
| inr (Invalid_block _) ⇒ False
end.
Theorem consensus_correct_at_heights : consensusCorrectAtHeights.
Proof.
unfold consensusCorrectAtHeights.
intros snapshot signers until height prefix rest Hprotocol Hconditions Hmisc Haccept.
pose proof (conditions_prefix _ _ _ _ _ _ Hconditions) as HprefixConditions.
pose proof (acceptance_prefix _ _ _ _ Haccept) as HprefixAccept.
pose proof (misc_checks_prefix_execution snapshot prefix rest
(protocol_revision Hprotocol) Hmisc) as HblockSafe.
change (match executeBlocks params false snapshot prefix with
| inl post ⇒ miscBlockChecks post rest = true
| inr (Execution.Error.Invalid_block _) ⇒ False
| inr (Execution.Error.Invalid_transaction _) ⇒ True
end) in HblockSafe.
destruct (executeBlocks params false snapshot prefix) as [post|[blockError|txError]] eqn:Hrun.
- assert (Hpostconditions : consensusAccepts post (remainingHeight height rest) rest ∧
WindowConditions signers until false post rest).
{ destruct rest as [|first rest].
- split; [eexists; reflexivity|].
pose proof (accepted_execution_preserves_snapshot _ _ _ _ _ _ _
Hprotocol HprefixConditions HprefixAccept Hrun) as Hpost.
constructor.
+ exact Hpost.
+ constructor.
+ intros before block after Hsplit.
destruct before; discriminate.
+ intros before block after reached Hsplit. destruct before; discriminate.
+ intros before block after reached Hsplit. destruct before; discriminate.
+ change (totalBalance post + 0 < 2^256).
destruct (snapshot_balances _ _ Hpost) as [_ [_ Hbound]]. lia.
- exact (accepted_suffix_rechecks _ _ _ _ _ _ _ _ _
Hprotocol Hconditions Haccept Hrun). }
destruct Hpostconditions as [Haccept' Hconditions'].
split; [exact Haccept'|]. split; assumption.
- exact HblockSafe.
- exact (accepted_window_validates _ _ _ _ _ _
Hprotocol HprefixConditions HprefixAccept txError Hrun).
Qed.
Retain the generalized whole-window result for internal callers.
Corollary consensus_window_executes_at_heights snapshot signers until height blocks :
ProtocolConditions →
WindowConditions signers until false snapshot blocks →
miscBlockChecks snapshot blocks = true →
consensusAccepts snapshot height blocks →
∃ post, executeBlocks params false snapshot blocks = inl post ∧
SnapshotConditions signers post.
Proof.
intros Hprotocol Hconditions Hmisc Haccept.
pose proof (consensus_correct_at_heights snapshot signers until height blocks []) as Hmain.
rewrite app_nil_r in Hmain. specialize (Hmain Hprotocol Hconditions Hmisc Haccept).
destruct (executeBlocks params false snapshot blocks) as [post|[blockError|txError]] eqn:Hrun.
- ∃ post. split; [reflexivity|].
exact (window_snapshot _ _ _ _ _ (proj1 (proj2 Hmain))).
- contradiction.
- contradiction.
Qed.
ProtocolConditions →
WindowConditions signers until false snapshot blocks →
miscBlockChecks snapshot blocks = true →
consensusAccepts snapshot height blocks →
∃ post, executeBlocks params false snapshot blocks = inl post ∧
SnapshotConditions signers post.
Proof.
intros Hprotocol Hconditions Hmisc Haccept.
pose proof (consensus_correct_at_heights snapshot signers until height blocks []) as Hmain.
rewrite app_nil_r in Hmain. specialize (Hmain Hprotocol Hconditions Hmisc Haccept).
destruct (executeBlocks params false snapshot blocks) as [post|[blockError|txError]] eqn:Hrun.
- ∃ post. split; [reflexivity|].
exact (window_snapshot _ _ _ _ _ (proj1 (proj2 Hmain))).
- contradiction.
- contradiction.
Qed.
The public theorem supplies both heights from the accepted blocks and
states execution success directly. No input or execution premise is added.
Theorem consensus_correct : consensusCorrect params.
Proof.
unfold consensusCorrect. intros snapshot signers prefix rest. cbv zeta.
intros Hprotocol Hconditions Hmisc Haccept.
pose proof (consensus_correct_at_heights snapshot signers
(lastBlockHeight (prefix ++ rest)) (N.pred (firstBlockHeight (prefix ++ rest)))
prefix rest Hprotocol Hconditions Hmisc Haccept) as Hmain.
destruct (executeBlocks params false snapshot prefix)
as [post|[blockError|txError]] eqn:Hrun; try contradiction.
∃ post. split; [reflexivity|].
destruct Hmain as [HacceptRest Hrest]. split; [|exact Hrest].
destruct rest as [|first rest].
- eexists. reflexivity.
- exact HacceptRest.
Qed.
Proof.
unfold consensusCorrect. intros snapshot signers prefix rest. cbv zeta.
intros Hprotocol Hconditions Hmisc Haccept.
pose proof (consensus_correct_at_heights snapshot signers
(lastBlockHeight (prefix ++ rest)) (N.pred (firstBlockHeight (prefix ++ rest)))
prefix rest Hprotocol Hconditions Hmisc Haccept) as Hmain.
destruct (executeBlocks params false snapshot prefix)
as [post|[blockError|txError]] eqn:Hrun; try contradiction.
∃ post. split; [reflexivity|].
destruct Hmain as [HacceptRest Hrest]. split; [|exact Hrest].
destruct rest as [|first rest].
- eexists. reflexivity.
- exact HacceptRest.
Qed.
Execute all blocks from snapshot. signers contains their transaction
senders; all heights are derived from blocks. There exists an actual
successful final state satisfying SnapshotConditions.
Corollary consensus_window_executes (snapshot : W.t) (signers : list Addr.t)
(blocks : list Block.t) :
ProtocolConditions →
WindowConditions signers (lastBlockHeight blocks) false snapshot blocks →
miscBlockChecks snapshot blocks = true →
consensusAccepts snapshot (N.pred (firstBlockHeight blocks)) blocks →
∃ post : W.t, executeBlocks params false snapshot blocks = inl post ∧
SnapshotConditions signers post.
Proof.
intros Hprotocol Hconditions Hmisc Haccept.
pose proof (consensus_correct snapshot signers blocks []) as Hmain.
cbv zeta in Hmain. rewrite app_nil_r in Hmain.
destruct (Hmain Hprotocol Hconditions Hmisc Haccept)
as [post [Hrun [_ [Hpost _]]]].
∃ post. split; [exact Hrun|].
exact (window_snapshot _ _ _ _ _ Hpost).
Qed.
(blocks : list Block.t) :
ProtocolConditions →
WindowConditions signers (lastBlockHeight blocks) false snapshot blocks →
miscBlockChecks snapshot blocks = true →
consensusAccepts snapshot (N.pred (firstBlockHeight blocks)) blocks →
∃ post : W.t, executeBlocks params false snapshot blocks = inl post ∧
SnapshotConditions signers post.
Proof.
intros Hprotocol Hconditions Hmisc Haccept.
pose proof (consensus_correct snapshot signers blocks []) as Hmain.
cbv zeta in Hmain. rewrite app_nil_r in Hmain.
destruct (Hmain Hprotocol Hconditions Hmisc Haccept)
as [post [Hrun [_ [Hpost _]]]].
∃ post. split; [exact Hrun|].
exact (window_snapshot _ _ _ _ _ Hpost).
Qed.
Validation-only property for params. snapshot is the initial state;
signers contains the window's transaction senders; until bounds its
heights; height initializes the reserve budgets; blocks is the ordered
list to execute. verify controls comparison with supplied block results.
No transaction-validation error is possible. Unlike consensusCorrect,
this requires no miscBlockChecks and covers either verify value;
it therefore is not just that theorem with rest = []. It permits block
errors and VM reverts. Kept here rather than on the main overview.
Definition windowValidationSafety : Prop :=
∀ snapshot signers until verify height blocks,
ProtocolConditions → WindowConditions signers until verify snapshot blocks →
consensusAccepts snapshot height blocks →
∀ details, executeBlocks params verify snapshot blocks ≠
inr (Execution.Error.Invalid_transaction details).
Corollary consensus_window_validates : windowValidationSafety.
Proof.
unfold windowValidationSafety.
intros snapshot signers until verify height blocks Hprotocol Hconditions Haccept details Herror.
exact (accepted_window_validates signers until verify snapshot blocks height
Hprotocol Hconditions Haccept details Herror).
Qed.
End ConcreteExecutor.
∀ snapshot signers until verify height blocks,
ProtocolConditions → WindowConditions signers until verify snapshot blocks →
consensusAccepts snapshot height blocks →
∀ details, executeBlocks params verify snapshot blocks ≠
inr (Execution.Error.Invalid_transaction details).
Corollary consensus_window_validates : windowValidationSafety.
Proof.
unfold windowValidationSafety.
intros snapshot signers until verify height blocks Hprotocol Hconditions Haccept details Herror.
exact (accepted_window_validates signers until verify snapshot blocks height
Hprotocol Hconditions Haccept details Herror).
Qed.
End ConcreteExecutor.