Library QedkConcrete.consensusblocks
Delayed-window induction through actual block execution
From Stdlib Require Import List String ZArith Lia Bool.
Require Import RocqOfOCaml.RocqOfOCaml.
Require Export QedkConcrete.consensusrequirements.
Require Import MonadVM.Execution QedkConcrete.consensushistory
QedkConcrete.consensushistoryproofs
QedkConcrete.transactionnonces QedkConcrete.authorizationnonces
QedkConcrete.transactionstage QedkConcrete.transactioncode
QedkConcrete.transactionhistory QedkConcrete.authorizationcode
QedkConcrete.transactionpersistentcode QedkConcrete.transactionchecked
QedkConcrete.publictransaction QedkConcrete.protectedstorageboundary.
Require Import QedkConcrete.consensuswindow QedkConcrete.consensuswindowproofs
QedkConcrete.consensusbudget QedkConcrete.transactionbudget
QedkConcrete.transactionhistoryprojection QedkConcrete.supply
QedkConcrete.assemblychecked QedkConcrete.hashwords QedkConcrete.wordrange
QedkConcrete.hostaccountformat.
Require Import QedkConcrete.consensustransaction QedkConcrete.consensusbacking
QedkConcrete.transactionformat.
Require Import QedkConcrete.blocktransactionentry QedkConcrete.consensusprefix
QedkConcrete.blockpersistentcode QedkConcrete.consensusboundaries QedkConcrete.credits.
Require Import QedkConcrete.consensusblock QedkConcrete.prefixdecisions
QedkConcrete.blockprefixstorage QedkConcrete.blocknumbers
QedkConcrete.reservewindowtrace QedkConcrete.hoststoragewords.
Require Import QedkConcrete.precompileoutputs QedkConcrete.dispatchoutputs.
Require Import QedkConcrete.reservehash.
Set Default Goal Selector "!".
#[local] Hint Extern 100 (Basics.Unreachable _) ⇒
(apply Opaque.legacy_witness; Opaque.opaque_inhabit 64%nat) : typeclass_instances.
Import ListNotations.
Local Open Scope Z_scope.
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.
Module Addr := Chain.Ethereum.Address.
Section Execution.
Context {F : E.FArgs}.
Local Abbreviation args := (@E.Instantiation_fargs F).
Local Abbreviation params := args.(Host.Instantiate.ChainParams).
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)}.
Local Abbreviation prefix := (@transactionPrefix F).
Local Abbreviation vmInput := (@transactionVmInput F).
Local Abbreviation callFromEoa := (@E.Host.call_from_eoa F).
Local Abbreviation processTransaction := (@E.process_transaction F).
Local Abbreviation dispatchTransaction := (@E.dispatch_transaction F).
Local Abbreviation readAccount := (fun world addr ⇒ State.op_pointcaretlparenrparen
world (@W.account None addr)).
Local Abbreviation native := (@Reserve_balance.precompile_address).
Local Abbreviation staking := (@MonadVM.Staking.staking_address).
Local Abbreviation systemSender := (@Chain.Monad.system_sender).
Local Abbreviation recoveredAuthority := (@Chain.Ethereum.Transaction.Authorization.authority).
Local Abbreviation blockNumber := (fun block ⇒ Chain.Ethereum.Block.Header.t.number
(Chain.Ethereum.Block.t.header (B.t.current_block block))).
Local Abbreviation emptying := (@Reserve_balance.is_emptying_tx).
Local Abbreviation configured := (@Reserve_balance.user_reserve_balance).
Local Abbreviation balance := (fun world a ⇒ Numeric.U256.to_z (A.t.balance (readAccount world a))).
Context {UBlock : Basics.Unreachable Chain.Ethereum.Block.t}
{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}.
Local Abbreviation processBlock := (@E.process_block F).
Local Abbreviation blockEntry := (@blockTransactionEntry F).
Local Abbreviation height := (fun block ⇒ Chain.Ethereum.Block.Header.t.number
(Chain.Ethereum.Block.t.header block)).
Local Abbreviation txCredits := (fun txs ⇒ Lists.List.fold_right
(fun tx subtotal ⇒ @systemTxCredit F tx + subtotal) 0 txs).
Local Abbreviation blockCredits := (fun block ⇒
txCredits (Chain.Ethereum.Block.t.transactions block) +
Lists.List.fold_right
(fun wd total ⇒ withdrawalWei wd + total) 0 (Chain.Ethereum.Block.t.withdrawals block)).
Local Abbreviation windowCredits := (@consensusconditions.windowCredits F).
Lemma input_window_credits_nonnegative signers until blocks :
Forall (blockInputs signers until) blocks → 0 ≤ windowCredits blocks.
Proof.
intro Hinputs. induction Hinputs as [|block blocks Hblock Hrest IH]; [cbn; lia|].
change (0 ≤ blockCredits block + windowCredits blocks).
destruct Hblock as [_ [_ [_ [Htxs Hwidth]]]].
assert (HtxNonneg : 0 ≤ txCredits (Chain.Ethereum.Block.t.transactions block)).
{ apply tx_credits_nonnegative. eapply Forall_impl; [|exact Htxs].
intros t [Hv _]; exact Hv. }
pose proof (withdrawal_sum_nonnegative _ Hwidth). lia.
Qed.
Local Abbreviation prefixSafe := (@prefixAvoidsSignerCreation F).
Local Abbreviation windowAvoidsSignerCreation := (@consensusrequirements.windowAvoidsSignerCreation F).
Local Abbreviation windowValidStakingSyscalls := (@consensusrequirements.windowValidStakingSyscalls F).
Lemma window_creation_safe_prefix signers verify world first last :
windowAvoidsSignerCreation signers verify world (first ++ last) →
windowAvoidsSignerCreation signers verify world first.
Proof.
intros Hsafe before block after reached Hsplit Hrun.
apply (Hsafe before block (after ++ last) reached).
- rewrite Hsplit, <- app_assoc. reflexivity.
- exact Hrun.
Qed.
Lemma window_creation_safe_tail signers verify world block rest reached :
windowAvoidsSignerCreation signers verify world (block :: rest) →
processBlock verify world block = inl reached →
windowAvoidsSignerCreation signers verify reached rest.
Proof.
intros Hsafe Hstep before next after state Hsplit Hrun.
apply (Hsafe (block :: before) next after state).
- cbn [app]. now rewrite <- Hsplit.
- change (Result.op_letdollar (processBlock verify world block)
(fun start ⇒ Result.List.fold_leftM (processBlock verify) start before) = inl state).
rewrite Hstep. exact Hrun.
Qed.
Lemma window_staking_valid_prefix verify world first last :
windowValidStakingSyscalls verify world (first ++ last) →
windowValidStakingSyscalls verify world first.
Proof.
intros Hvalid before block after reached Hsplit Hrun.
apply (Hvalid before block (after ++ last) reached).
- rewrite Hsplit, <- app_assoc. reflexivity.
- exact Hrun.
Qed.
Lemma window_staking_valid_tail verify world block rest reached :
windowValidStakingSyscalls verify world (block :: rest) →
processBlock verify world block = inl reached →
windowValidStakingSyscalls verify reached rest.
Proof.
intros Hvalid Hstep before next after state Hsplit Hrun.
apply (Hvalid (block :: before) next after state).
- cbn [app]. now rewrite <- Hsplit.
- change (Result.op_letdollar (processBlock verify world block)
(fun start ⇒ Result.List.fold_leftM (processBlock verify) start before) = inl state).
rewrite Hstep. exact Hrun.
Qed.
Theorem window_induction_under_configuration_agreement snapshot signers until verify blocks world :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → @nativeOutputBounds args →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify world blocks →
∀ previous next initialHeight,
balanceInvariant world → worldFormat world → @prescribedSystemCode F world →
BudgetBacking snapshot previous world signers initialHeight until →
totalBalance world + windowCredits blocks < 2^256 →
(∀ before block after reached,
blocks = before ++ block :: after →
Result.List.fold_leftM (processBlock verify) world before = inl reached →
∀ first last state,
Chain.Ethereum.Block.t.transactions block = first ++ last →
Result.List.fold_leftM dispatchTransaction (blockEntry reached block) first = inl state →
∀ a, List.In a signers → configured (B.t.world_state state) (height block) a =
configured snapshot (height block) a) →
checkBlocks snapshot previous blocks = Some next →
match Result.List.fold_leftM (processBlock verify) world blocks with
| inr error ⇒ ∀ reportedBlock tx details,
error ≠ Execution.Error.Invalid_transaction
{| Execution.Error.t.Invalid_transaction.block := reportedBlock;
Execution.Error.t.Invalid_transaction.transaction := tx;
Execution.Error.t.Invalid_transaction.reason := Execution.Error.Insufficient_balance details |}
| inl post ⇒ ∃ finalHeight,
BudgetBacking snapshot next post signers finalHeight until ∧
balanceInvariant post ∧ worldFormat post ∧ @prescribedSystemCode F post ∧
totalBalance post ≤ totalBalance world + windowCredits blocks
end.
Proof using F U8 UB UI0.
intros Hrevision Hhash Houtputs Hchain HsnapshotFormat Hsnapshot Hnative Hinputs Hsafe.
revert world Hsafe. induction Hinputs as [|block blocks Hblock Hinputs IH];
intros world Hsafe previous next initialHeight Hbalance Hformat Hsystem Hbacked Hsupply Hconfig Hcheck.
- cbn [checkBlocks] in Hcheck. injection Hcheck as <-.
change (∃ finalHeight, BudgetBacking snapshot previous world signers finalHeight until ∧
balanceInvariant world ∧ worldFormat world ∧ prescribedSystemCode world ∧
totalBalance world ≤ totalBalance world + 0).
∃ initialHeight. split; [exact Hbacked|]. split; [exact Hbalance|].
split; [exact Hformat|]. split; [exact Hsystem|lia].
- destruct Hblock as [Hheader [Hroot [Htime [Htxs Hwidth]]]].
set (atBlock := {| consensusHistory := consensusHistory previous;
consensusBudgets := fun a ⇒ Z.min (consensusBudgets previous a)
(Numeric.U256.to_z (configured snapshot (height block) a)) |}).
assert (Hclamped : BudgetBacking snapshot atBlock world signers (height block) until).
{ apply (backing_next_block snapshot previous world signers initialHeight (height block) until Hbacked).
intros a _. exact (proj1 (@configured_word_range
snapshot (height block) a HsnapshotFormat)). }
change (match checkTransactions snapshot (Chain.Ethereum.Block.t.header block) atBlock
(Chain.Ethereum.Block.t.transactions block) with
| Some middle ⇒ checkBlocks snapshot middle blocks | None ⇒ None end = Some next) in Hcheck.
destruct (checkTransactions snapshot (Chain.Ethereum.Block.t.header block) atBlock
(Chain.Ethereum.Block.t.transactions block)) as [middle|] eqn:Haccepted; [|discriminate Hcheck].
assert (HblockConfig : ∀ first last state,
Chain.Ethereum.Block.t.transactions block = first ++ last →
Result.List.fold_leftM dispatchTransaction (blockEntry world block) first = inl state →
∀ a, List.In a signers → configured (B.t.world_state state) (height block) a =
configured snapshot (height block) a).
{ exact (Hconfig [] block blocks world eq_refl eq_refl). }
assert (HblockSafe : @E.validate_block F world block = inl tt →
prefixSafe signers (blockEntry world block) (Chain.Ethereum.Block.t.transactions block)).
{ exact (Hsafe [] block blocks world eq_refl eq_refl). }
assert (HrestNonnegative : 0 ≤ windowCredits blocks).
{ exact (input_window_credits_nonnegative signers until blocks Hinputs). }
assert (HblockSupply : totalBalance world + blockCredits block < 2^256).
{ change (totalBalance world + (blockCredits block + windowCredits blocks) < 2^256) in Hsupply. lia. }
assert (HblockTxSupply : totalBalance world + txCredits (Chain.Ethereum.Block.t.transactions block) < 2^256).
{ pose proof (withdrawal_sum_nonnegative _ Hwidth). cbv beta in HblockSupply. lia. }
pose proof (@accepted_block_no_insufficient_balance F UI0 UB U8
snapshot signers until verify world block atBlock middle Hrevision Hhash Houtputs Hchain
Hsnapshot Hnative Htxs HblockSafe Hheader Hroot Hbalance HblockTxSupply Hformat Hsystem Hclamped Htime
HblockConfig Haccepted) as HnoFeeError.
change (match Result.op_letdollar (processBlock verify world block)
(fun reached ⇒ Result.List.fold_leftM (processBlock verify) reached blocks) with
| inr error ⇒ ∀ reportedBlock tx details,
error ≠ Execution.Error.Invalid_transaction
{| Execution.Error.t.Invalid_transaction.block := reportedBlock;
Execution.Error.t.Invalid_transaction.transaction := tx;
Execution.Error.t.Invalid_transaction.reason := Execution.Error.Insufficient_balance details |}
| inl post ⇒ ∃ finalHeight,
BudgetBacking snapshot next post signers finalHeight until ∧
balanceInvariant post ∧ worldFormat post ∧ prescribedSystemCode post ∧
totalBalance post ≤ totalBalance world + (blockCredits block + windowCredits blocks)
end).
destruct (processBlock verify world block) as [reached|error] eqn:Hstep.
2: { intros reportedBlock tx details Heq. apply (HnoFeeError reportedBlock tx details).
unfold E.invalid_transaction. now rewrite Heq. }
destruct (@accepted_block_preserves_backing F UI0 UB U8
snapshot signers until verify world block atBlock middle reached Hrevision Hhash Houtputs Hchain
Hsnapshot Hnative Htxs
(HblockSafe (@process_block_success_validated F
verify world block reached Hstep)) Hheader Hroot Hbalance Hformat Hsystem Hclamped Htime
HblockConfig Haccepted Hwidth HblockSupply Hstep)
as [HreachedBacked [HreachedBalance [HreachedFormat HreachedTotal]]].
pose proof (@process_block_preserves_system_code F
verify world block Hrevision (proj1 Hbalance) Hsystem) as HreachedCode.
rewrite Hstep in HreachedCode.
assert (HrestSupply : totalBalance reached + windowCredits blocks < 2^256).
{ change (totalBalance world + (blockCredits block + windowCredits blocks) < 2^256) in Hsupply. lia. }
assert (HrestConfig : ∀ before candidate after state,
blocks = before ++ candidate :: after →
Result.List.fold_leftM (processBlock verify) reached before = inl state →
∀ first last txstate,
Chain.Ethereum.Block.t.transactions candidate = first ++ last →
Result.List.fold_leftM dispatchTransaction (blockEntry state candidate) first = inl txstate →
∀ a, List.In a signers → configured (B.t.world_state txstate) (height candidate) a =
configured snapshot (height candidate) a).
{ intros before candidate after state Hsplit Hprefix.
apply (Hconfig (block :: before) candidate after state).
- cbn [app]. now rewrite <- Hsplit.
- change (Result.op_letdollar (processBlock verify world block)
(fun next ⇒ Result.List.fold_leftM (processBlock verify) next before) = inl state).
rewrite Hstep. exact Hprefix. }
specialize (IH reached (window_creation_safe_tail signers verify world block blocks reached Hsafe Hstep)
middle next (height block) HreachedBalance HreachedFormat (proj2 HreachedCode)
HreachedBacked HrestSupply HrestConfig Hcheck).
change (match Result.List.fold_leftM (processBlock verify) reached blocks with
| inr error ⇒ ∀ reportedBlock tx details,
error ≠ Execution.Error.Invalid_transaction
{| Execution.Error.t.Invalid_transaction.block := reportedBlock;
Execution.Error.t.Invalid_transaction.transaction := tx;
Execution.Error.t.Invalid_transaction.reason := Execution.Error.Insufficient_balance details |}
| inl post ⇒ ∃ finalHeight,
BudgetBacking snapshot next post signers finalHeight until ∧
balanceInvariant post ∧ worldFormat post ∧ prescribedSystemCode post ∧
totalBalance post ≤ totalBalance world + (blockCredits block + windowCredits blocks)
end).
destruct (Result.List.fold_leftM (processBlock verify) reached blocks) as [post|error]; [|exact IH].
destruct IH as [finalHeight [HfinalBacked [HfinalBalance [HfinalFormat [HfinalCode HfinalTotal]]]]].
∃ finalHeight. split; [exact HfinalBacked|]. split; [exact HfinalBalance|].
split; [exact HfinalFormat|]. split; [exact HfinalCode|]. lia.
Qed.
Lemma window_credits_app first last :
windowCredits (first ++ last) = windowCredits first + windowCredits last.
Proof.
induction first as [|block first IH]; [reflexivity|].
change (blockCredits block + windowCredits (first ++ last) =
blockCredits block + windowCredits first + windowCredits last).
cbv beta in IH |- ×. rewrite IH. lia.
Qed.
Require Import RocqOfOCaml.RocqOfOCaml.
Require Export QedkConcrete.consensusrequirements.
Require Import MonadVM.Execution QedkConcrete.consensushistory
QedkConcrete.consensushistoryproofs
QedkConcrete.transactionnonces QedkConcrete.authorizationnonces
QedkConcrete.transactionstage QedkConcrete.transactioncode
QedkConcrete.transactionhistory QedkConcrete.authorizationcode
QedkConcrete.transactionpersistentcode QedkConcrete.transactionchecked
QedkConcrete.publictransaction QedkConcrete.protectedstorageboundary.
Require Import QedkConcrete.consensuswindow QedkConcrete.consensuswindowproofs
QedkConcrete.consensusbudget QedkConcrete.transactionbudget
QedkConcrete.transactionhistoryprojection QedkConcrete.supply
QedkConcrete.assemblychecked QedkConcrete.hashwords QedkConcrete.wordrange
QedkConcrete.hostaccountformat.
Require Import QedkConcrete.consensustransaction QedkConcrete.consensusbacking
QedkConcrete.transactionformat.
Require Import QedkConcrete.blocktransactionentry QedkConcrete.consensusprefix
QedkConcrete.blockpersistentcode QedkConcrete.consensusboundaries QedkConcrete.credits.
Require Import QedkConcrete.consensusblock QedkConcrete.prefixdecisions
QedkConcrete.blockprefixstorage QedkConcrete.blocknumbers
QedkConcrete.reservewindowtrace QedkConcrete.hoststoragewords.
Require Import QedkConcrete.precompileoutputs QedkConcrete.dispatchoutputs.
Require Import QedkConcrete.reservehash.
Set Default Goal Selector "!".
#[local] Hint Extern 100 (Basics.Unreachable _) ⇒
(apply Opaque.legacy_witness; Opaque.opaque_inhabit 64%nat) : typeclass_instances.
Import ListNotations.
Local Open Scope Z_scope.
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.
Module Addr := Chain.Ethereum.Address.
Section Execution.
Context {F : E.FArgs}.
Local Abbreviation args := (@E.Instantiation_fargs F).
Local Abbreviation params := args.(Host.Instantiate.ChainParams).
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)}.
Local Abbreviation prefix := (@transactionPrefix F).
Local Abbreviation vmInput := (@transactionVmInput F).
Local Abbreviation callFromEoa := (@E.Host.call_from_eoa F).
Local Abbreviation processTransaction := (@E.process_transaction F).
Local Abbreviation dispatchTransaction := (@E.dispatch_transaction F).
Local Abbreviation readAccount := (fun world addr ⇒ State.op_pointcaretlparenrparen
world (@W.account None addr)).
Local Abbreviation native := (@Reserve_balance.precompile_address).
Local Abbreviation staking := (@MonadVM.Staking.staking_address).
Local Abbreviation systemSender := (@Chain.Monad.system_sender).
Local Abbreviation recoveredAuthority := (@Chain.Ethereum.Transaction.Authorization.authority).
Local Abbreviation blockNumber := (fun block ⇒ Chain.Ethereum.Block.Header.t.number
(Chain.Ethereum.Block.t.header (B.t.current_block block))).
Local Abbreviation emptying := (@Reserve_balance.is_emptying_tx).
Local Abbreviation configured := (@Reserve_balance.user_reserve_balance).
Local Abbreviation balance := (fun world a ⇒ Numeric.U256.to_z (A.t.balance (readAccount world a))).
Context {UBlock : Basics.Unreachable Chain.Ethereum.Block.t}
{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}.
Local Abbreviation processBlock := (@E.process_block F).
Local Abbreviation blockEntry := (@blockTransactionEntry F).
Local Abbreviation height := (fun block ⇒ Chain.Ethereum.Block.Header.t.number
(Chain.Ethereum.Block.t.header block)).
Local Abbreviation txCredits := (fun txs ⇒ Lists.List.fold_right
(fun tx subtotal ⇒ @systemTxCredit F tx + subtotal) 0 txs).
Local Abbreviation blockCredits := (fun block ⇒
txCredits (Chain.Ethereum.Block.t.transactions block) +
Lists.List.fold_right
(fun wd total ⇒ withdrawalWei wd + total) 0 (Chain.Ethereum.Block.t.withdrawals block)).
Local Abbreviation windowCredits := (@consensusconditions.windowCredits F).
Lemma input_window_credits_nonnegative signers until blocks :
Forall (blockInputs signers until) blocks → 0 ≤ windowCredits blocks.
Proof.
intro Hinputs. induction Hinputs as [|block blocks Hblock Hrest IH]; [cbn; lia|].
change (0 ≤ blockCredits block + windowCredits blocks).
destruct Hblock as [_ [_ [_ [Htxs Hwidth]]]].
assert (HtxNonneg : 0 ≤ txCredits (Chain.Ethereum.Block.t.transactions block)).
{ apply tx_credits_nonnegative. eapply Forall_impl; [|exact Htxs].
intros t [Hv _]; exact Hv. }
pose proof (withdrawal_sum_nonnegative _ Hwidth). lia.
Qed.
Local Abbreviation prefixSafe := (@prefixAvoidsSignerCreation F).
Local Abbreviation windowAvoidsSignerCreation := (@consensusrequirements.windowAvoidsSignerCreation F).
Local Abbreviation windowValidStakingSyscalls := (@consensusrequirements.windowValidStakingSyscalls F).
Lemma window_creation_safe_prefix signers verify world first last :
windowAvoidsSignerCreation signers verify world (first ++ last) →
windowAvoidsSignerCreation signers verify world first.
Proof.
intros Hsafe before block after reached Hsplit Hrun.
apply (Hsafe before block (after ++ last) reached).
- rewrite Hsplit, <- app_assoc. reflexivity.
- exact Hrun.
Qed.
Lemma window_creation_safe_tail signers verify world block rest reached :
windowAvoidsSignerCreation signers verify world (block :: rest) →
processBlock verify world block = inl reached →
windowAvoidsSignerCreation signers verify reached rest.
Proof.
intros Hsafe Hstep before next after state Hsplit Hrun.
apply (Hsafe (block :: before) next after state).
- cbn [app]. now rewrite <- Hsplit.
- change (Result.op_letdollar (processBlock verify world block)
(fun start ⇒ Result.List.fold_leftM (processBlock verify) start before) = inl state).
rewrite Hstep. exact Hrun.
Qed.
Lemma window_staking_valid_prefix verify world first last :
windowValidStakingSyscalls verify world (first ++ last) →
windowValidStakingSyscalls verify world first.
Proof.
intros Hvalid before block after reached Hsplit Hrun.
apply (Hvalid before block (after ++ last) reached).
- rewrite Hsplit, <- app_assoc. reflexivity.
- exact Hrun.
Qed.
Lemma window_staking_valid_tail verify world block rest reached :
windowValidStakingSyscalls verify world (block :: rest) →
processBlock verify world block = inl reached →
windowValidStakingSyscalls verify reached rest.
Proof.
intros Hvalid Hstep before next after state Hsplit Hrun.
apply (Hvalid (block :: before) next after state).
- cbn [app]. now rewrite <- Hsplit.
- change (Result.op_letdollar (processBlock verify world block)
(fun start ⇒ Result.List.fold_leftM (processBlock verify) start before) = inl state).
rewrite Hstep. exact Hrun.
Qed.
Theorem window_induction_under_configuration_agreement snapshot signers until verify blocks world :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → @nativeOutputBounds args →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify world blocks →
∀ previous next initialHeight,
balanceInvariant world → worldFormat world → @prescribedSystemCode F world →
BudgetBacking snapshot previous world signers initialHeight until →
totalBalance world + windowCredits blocks < 2^256 →
(∀ before block after reached,
blocks = before ++ block :: after →
Result.List.fold_leftM (processBlock verify) world before = inl reached →
∀ first last state,
Chain.Ethereum.Block.t.transactions block = first ++ last →
Result.List.fold_leftM dispatchTransaction (blockEntry reached block) first = inl state →
∀ a, List.In a signers → configured (B.t.world_state state) (height block) a =
configured snapshot (height block) a) →
checkBlocks snapshot previous blocks = Some next →
match Result.List.fold_leftM (processBlock verify) world blocks with
| inr error ⇒ ∀ reportedBlock tx details,
error ≠ Execution.Error.Invalid_transaction
{| Execution.Error.t.Invalid_transaction.block := reportedBlock;
Execution.Error.t.Invalid_transaction.transaction := tx;
Execution.Error.t.Invalid_transaction.reason := Execution.Error.Insufficient_balance details |}
| inl post ⇒ ∃ finalHeight,
BudgetBacking snapshot next post signers finalHeight until ∧
balanceInvariant post ∧ worldFormat post ∧ @prescribedSystemCode F post ∧
totalBalance post ≤ totalBalance world + windowCredits blocks
end.
Proof using F U8 UB UI0.
intros Hrevision Hhash Houtputs Hchain HsnapshotFormat Hsnapshot Hnative Hinputs Hsafe.
revert world Hsafe. induction Hinputs as [|block blocks Hblock Hinputs IH];
intros world Hsafe previous next initialHeight Hbalance Hformat Hsystem Hbacked Hsupply Hconfig Hcheck.
- cbn [checkBlocks] in Hcheck. injection Hcheck as <-.
change (∃ finalHeight, BudgetBacking snapshot previous world signers finalHeight until ∧
balanceInvariant world ∧ worldFormat world ∧ prescribedSystemCode world ∧
totalBalance world ≤ totalBalance world + 0).
∃ initialHeight. split; [exact Hbacked|]. split; [exact Hbalance|].
split; [exact Hformat|]. split; [exact Hsystem|lia].
- destruct Hblock as [Hheader [Hroot [Htime [Htxs Hwidth]]]].
set (atBlock := {| consensusHistory := consensusHistory previous;
consensusBudgets := fun a ⇒ Z.min (consensusBudgets previous a)
(Numeric.U256.to_z (configured snapshot (height block) a)) |}).
assert (Hclamped : BudgetBacking snapshot atBlock world signers (height block) until).
{ apply (backing_next_block snapshot previous world signers initialHeight (height block) until Hbacked).
intros a _. exact (proj1 (@configured_word_range
snapshot (height block) a HsnapshotFormat)). }
change (match checkTransactions snapshot (Chain.Ethereum.Block.t.header block) atBlock
(Chain.Ethereum.Block.t.transactions block) with
| Some middle ⇒ checkBlocks snapshot middle blocks | None ⇒ None end = Some next) in Hcheck.
destruct (checkTransactions snapshot (Chain.Ethereum.Block.t.header block) atBlock
(Chain.Ethereum.Block.t.transactions block)) as [middle|] eqn:Haccepted; [|discriminate Hcheck].
assert (HblockConfig : ∀ first last state,
Chain.Ethereum.Block.t.transactions block = first ++ last →
Result.List.fold_leftM dispatchTransaction (blockEntry world block) first = inl state →
∀ a, List.In a signers → configured (B.t.world_state state) (height block) a =
configured snapshot (height block) a).
{ exact (Hconfig [] block blocks world eq_refl eq_refl). }
assert (HblockSafe : @E.validate_block F world block = inl tt →
prefixSafe signers (blockEntry world block) (Chain.Ethereum.Block.t.transactions block)).
{ exact (Hsafe [] block blocks world eq_refl eq_refl). }
assert (HrestNonnegative : 0 ≤ windowCredits blocks).
{ exact (input_window_credits_nonnegative signers until blocks Hinputs). }
assert (HblockSupply : totalBalance world + blockCredits block < 2^256).
{ change (totalBalance world + (blockCredits block + windowCredits blocks) < 2^256) in Hsupply. lia. }
assert (HblockTxSupply : totalBalance world + txCredits (Chain.Ethereum.Block.t.transactions block) < 2^256).
{ pose proof (withdrawal_sum_nonnegative _ Hwidth). cbv beta in HblockSupply. lia. }
pose proof (@accepted_block_no_insufficient_balance F UI0 UB U8
snapshot signers until verify world block atBlock middle Hrevision Hhash Houtputs Hchain
Hsnapshot Hnative Htxs HblockSafe Hheader Hroot Hbalance HblockTxSupply Hformat Hsystem Hclamped Htime
HblockConfig Haccepted) as HnoFeeError.
change (match Result.op_letdollar (processBlock verify world block)
(fun reached ⇒ Result.List.fold_leftM (processBlock verify) reached blocks) with
| inr error ⇒ ∀ reportedBlock tx details,
error ≠ Execution.Error.Invalid_transaction
{| Execution.Error.t.Invalid_transaction.block := reportedBlock;
Execution.Error.t.Invalid_transaction.transaction := tx;
Execution.Error.t.Invalid_transaction.reason := Execution.Error.Insufficient_balance details |}
| inl post ⇒ ∃ finalHeight,
BudgetBacking snapshot next post signers finalHeight until ∧
balanceInvariant post ∧ worldFormat post ∧ prescribedSystemCode post ∧
totalBalance post ≤ totalBalance world + (blockCredits block + windowCredits blocks)
end).
destruct (processBlock verify world block) as [reached|error] eqn:Hstep.
2: { intros reportedBlock tx details Heq. apply (HnoFeeError reportedBlock tx details).
unfold E.invalid_transaction. now rewrite Heq. }
destruct (@accepted_block_preserves_backing F UI0 UB U8
snapshot signers until verify world block atBlock middle reached Hrevision Hhash Houtputs Hchain
Hsnapshot Hnative Htxs
(HblockSafe (@process_block_success_validated F
verify world block reached Hstep)) Hheader Hroot Hbalance Hformat Hsystem Hclamped Htime
HblockConfig Haccepted Hwidth HblockSupply Hstep)
as [HreachedBacked [HreachedBalance [HreachedFormat HreachedTotal]]].
pose proof (@process_block_preserves_system_code F
verify world block Hrevision (proj1 Hbalance) Hsystem) as HreachedCode.
rewrite Hstep in HreachedCode.
assert (HrestSupply : totalBalance reached + windowCredits blocks < 2^256).
{ change (totalBalance world + (blockCredits block + windowCredits blocks) < 2^256) in Hsupply. lia. }
assert (HrestConfig : ∀ before candidate after state,
blocks = before ++ candidate :: after →
Result.List.fold_leftM (processBlock verify) reached before = inl state →
∀ first last txstate,
Chain.Ethereum.Block.t.transactions candidate = first ++ last →
Result.List.fold_leftM dispatchTransaction (blockEntry state candidate) first = inl txstate →
∀ a, List.In a signers → configured (B.t.world_state txstate) (height candidate) a =
configured snapshot (height candidate) a).
{ intros before candidate after state Hsplit Hprefix.
apply (Hconfig (block :: before) candidate after state).
- cbn [app]. now rewrite <- Hsplit.
- change (Result.op_letdollar (processBlock verify world block)
(fun next ⇒ Result.List.fold_leftM (processBlock verify) next before) = inl state).
rewrite Hstep. exact Hprefix. }
specialize (IH reached (window_creation_safe_tail signers verify world block blocks reached Hsafe Hstep)
middle next (height block) HreachedBalance HreachedFormat (proj2 HreachedCode)
HreachedBacked HrestSupply HrestConfig Hcheck).
change (match Result.List.fold_leftM (processBlock verify) reached blocks with
| inr error ⇒ ∀ reportedBlock tx details,
error ≠ Execution.Error.Invalid_transaction
{| Execution.Error.t.Invalid_transaction.block := reportedBlock;
Execution.Error.t.Invalid_transaction.transaction := tx;
Execution.Error.t.Invalid_transaction.reason := Execution.Error.Insufficient_balance details |}
| inl post ⇒ ∃ finalHeight,
BudgetBacking snapshot next post signers finalHeight until ∧
balanceInvariant post ∧ worldFormat post ∧ prescribedSystemCode post ∧
totalBalance post ≤ totalBalance world + (blockCredits block + windowCredits blocks)
end).
destruct (Result.List.fold_leftM (processBlock verify) reached blocks) as [post|error]; [|exact IH].
destruct IH as [finalHeight [HfinalBacked [HfinalBalance [HfinalFormat [HfinalCode HfinalTotal]]]]].
∃ finalHeight. split; [exact HfinalBacked|]. split; [exact HfinalBalance|].
split; [exact HfinalFormat|]. split; [exact HfinalCode|]. lia.
Qed.
Lemma window_credits_app first last :
windowCredits (first ++ last) = windowCredits first + windowCredits last.
Proof.
induction first as [|block first IH]; [reflexivity|].
change (blockCredits block + windowCredits (first ++ last) =
blockCredits block + windowCredits first + windowCredits last).
cbv beta in IH |- ×. rewrite IH. lia.
Qed.
The actual sender balance, not just the absence of one error code.
Successful execution is required only before the candidate. Configuration
agreement is internal to this induction; the final theorem derives it
from the concrete setter and block-prefix execution.
Theorem accepted_window_reached_fee_under_configuration_agreement
snapshot signers until verify blocks initialHeight next before block after reached
first candidate last state :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → @nativeOutputBounds args →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
transactionSender candidate ≠ Some systemSender →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
totalBalance snapshot + windowCredits blocks < 2^256 →
(∀ earlier current later middle,
blocks = earlier ++ current :: later →
Result.List.fold_leftM (processBlock verify) snapshot earlier = inl middle →
∀ prefix suffix txstate,
Chain.Ethereum.Block.t.transactions current = prefix ++ suffix →
Result.List.fold_leftM dispatchTransaction (blockEntry middle current) prefix = inl txstate →
∀ a, List.In a signers → configured (B.t.world_state txstate) (height current) a =
configured snapshot (height current) a) →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
blocks = before ++ block :: after →
Result.List.fold_leftM (processBlock verify) snapshot before = inl reached →
@E.validate_block F reached block = inl tt →
Chain.Ethereum.Block.t.transactions block = first ++ candidate :: last →
Result.List.fold_leftM dispatchTransaction (blockEntry reached block) first = inl state →
∃ sender fee,
transactionQuote (Chain.Ethereum.Block.t.header (B.t.current_block state)) candidate = Some (sender, fee) ∧
Z.of_N fee ≤ balance (B.t.world_state state) sender ∧
(∃ validation, @E.validate_transaction F state candidate = inl validation).
Proof using F U8 UB UI0.
intros Hrevision Hhash Houtputs Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys
Hbalance Hcounters Hsystem Hsupply Hconfig Hcheck Hsplit Hrun Hvalid Htxsplit Htxrun.
assert (HbeforeInputs : Forall (blockInputs signers until) before).
{ rewrite Hsplit, Forall_app in Hinputs. exact (proj1 Hinputs). }
assert (HrestInputs : Forall (blockInputs signers until) (block :: after)).
{ rewrite Hsplit, Forall_app in Hinputs. exact (proj2 Hinputs). }
assert (HblockIn : List.In block blocks).
{ rewrite Hsplit. apply in_or_app. right. left. reflexivity. }
assert (HbeforeIn : ∀ b, List.In b before → List.In b blocks).
{ intros b Hb. rewrite Hsplit. apply in_or_app. left. exact Hb. }
assert (HprefixSupply : totalBalance snapshot + windowCredits before < 2^256).
{ rewrite Hsplit, window_credits_app in Hsupply.
pose proof (input_window_credits_nonnegative signers until _ HrestInputs). lia. }
assert (HbeforeConfig : ∀ earlier current later middle,
before = earlier ++ current :: later →
Result.List.fold_leftM (processBlock verify) snapshot earlier = inl middle →
∀ prefix suffix txstate,
Chain.Ethereum.Block.t.transactions current = prefix ++ suffix →
Result.List.fold_leftM dispatchTransaction (blockEntry middle current) prefix = inl txstate →
∀ a, List.In a signers → configured (B.t.world_state txstate) (height current) a =
configured snapshot (height current) a).
{ intros earlier current later middle Hparts Hprefix.
apply (Hconfig earlier current (later ++ block :: after) middle).
- rewrite Hsplit, Hparts. rewrite <- app_assoc. reflexivity.
- exact Hprefix. }
rewrite Hsplit, check_blocks_app in Hcheck.
destruct (checkBlocks snapshot (initialConsensusState snapshot initialHeight) before)
as [middle|] eqn:HbeforeCheck; [|discriminate].
pose proof (@initial_backing F
snapshot signers initialHeight until
Hbalance Hformat Hcounters Hsnapshot) as Hinitial.
pose proof (window_induction_under_configuration_agreement snapshot signers until verify before snapshot
Hrevision Hhash Houtputs Hchain Hformat Hsnapshot Hnative HbeforeInputs
ltac:(apply (window_creation_safe_prefix signers verify snapshot before (block :: after));
rewrite <- Hsplit; exact Hsafe)
(initialConsensusState snapshot initialHeight) middle initialHeight
Hbalance Hformat Hsystem Hinitial HprefixSupply HbeforeConfig HbeforeCheck) as Hbacking.
rewrite Hrun in Hbacking.
destruct Hbacking as [previousHeight [Hbacking [HreachedBalance [HreachedFormat [HreachedSystem HreachedTotal]]]]].
pose proof (proj1 (Forall_forall _ _) Hinputs block HblockIn) as Hinput.
destruct Hinput as [Hheader [Hroot [Htime [Htxs Hwidth]]]].
assert (HafterInputs : Forall (blockInputs signers until) after)
by (inversion HrestInputs; assumption).
assert (HblockTxSupply : totalBalance reached + txCredits (Chain.Ethereum.Block.t.transactions block) < 2^256).
{ rewrite Hsplit, window_credits_app in Hsupply.
change (windowCredits (block :: after)) with (blockCredits block + windowCredits after) in Hsupply.
pose proof (input_window_credits_nonnegative signers until after HafterInputs).
pose proof (withdrawal_sum_nonnegative _ Hwidth). lia. }
set (atBlock := {| consensusHistory := consensusHistory middle;
consensusBudgets := fun a ⇒ Z.min (consensusBudgets middle a)
(Numeric.U256.to_z (configured snapshot (height block) a)) |}).
assert (Hclamped : BudgetBacking snapshot atBlock reached signers (height block) until).
{ apply (backing_next_block snapshot middle reached signers previousHeight (height block) until Hbacking).
intros a _. exact (proj1 (@configured_word_range
snapshot (height block) a Hformat)). }
change (match checkTransactions snapshot (Chain.Ethereum.Block.t.header block) atBlock
(Chain.Ethereum.Block.t.transactions block) with
| Some nextBlock ⇒ checkBlocks snapshot nextBlock after | None ⇒ None end = Some next) in Hcheck.
destruct (checkTransactions snapshot (Chain.Ethereum.Block.t.header block) atBlock
(Chain.Ethereum.Block.t.transactions block)) as [nextBlock|] eqn:HblockCheck; [|discriminate].
destruct (@accepted_block_prefix_fee F UI0 UB U8
snapshot signers until reached block atBlock nextBlock
first candidate last state Hrevision Hhash Houtputs Hchain Hsnapshot Hnative Htxs
(Hsafe before block after reached Hsplit Hrun Hvalid) HnotSys
Hheader Hroot HreachedBalance HblockTxSupply HreachedFormat HreachedSystem Hclamped Htime
(Hconfig before block after reached Hsplit Hrun) HblockCheck Htxsplit Htxrun)
as [sender [fee [Hquote [Hfee [_ Hvalidation]]]]].
∃ sender, fee. split; [exact Hquote|]. split; assumption.
Qed.
snapshot signers until verify blocks initialHeight next before block after reached
first candidate last state :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → @nativeOutputBounds args →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
transactionSender candidate ≠ Some systemSender →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
totalBalance snapshot + windowCredits blocks < 2^256 →
(∀ earlier current later middle,
blocks = earlier ++ current :: later →
Result.List.fold_leftM (processBlock verify) snapshot earlier = inl middle →
∀ prefix suffix txstate,
Chain.Ethereum.Block.t.transactions current = prefix ++ suffix →
Result.List.fold_leftM dispatchTransaction (blockEntry middle current) prefix = inl txstate →
∀ a, List.In a signers → configured (B.t.world_state txstate) (height current) a =
configured snapshot (height current) a) →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
blocks = before ++ block :: after →
Result.List.fold_leftM (processBlock verify) snapshot before = inl reached →
@E.validate_block F reached block = inl tt →
Chain.Ethereum.Block.t.transactions block = first ++ candidate :: last →
Result.List.fold_leftM dispatchTransaction (blockEntry reached block) first = inl state →
∃ sender fee,
transactionQuote (Chain.Ethereum.Block.t.header (B.t.current_block state)) candidate = Some (sender, fee) ∧
Z.of_N fee ≤ balance (B.t.world_state state) sender ∧
(∃ validation, @E.validate_transaction F state candidate = inl validation).
Proof using F U8 UB UI0.
intros Hrevision Hhash Houtputs Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys
Hbalance Hcounters Hsystem Hsupply Hconfig Hcheck Hsplit Hrun Hvalid Htxsplit Htxrun.
assert (HbeforeInputs : Forall (blockInputs signers until) before).
{ rewrite Hsplit, Forall_app in Hinputs. exact (proj1 Hinputs). }
assert (HrestInputs : Forall (blockInputs signers until) (block :: after)).
{ rewrite Hsplit, Forall_app in Hinputs. exact (proj2 Hinputs). }
assert (HblockIn : List.In block blocks).
{ rewrite Hsplit. apply in_or_app. right. left. reflexivity. }
assert (HbeforeIn : ∀ b, List.In b before → List.In b blocks).
{ intros b Hb. rewrite Hsplit. apply in_or_app. left. exact Hb. }
assert (HprefixSupply : totalBalance snapshot + windowCredits before < 2^256).
{ rewrite Hsplit, window_credits_app in Hsupply.
pose proof (input_window_credits_nonnegative signers until _ HrestInputs). lia. }
assert (HbeforeConfig : ∀ earlier current later middle,
before = earlier ++ current :: later →
Result.List.fold_leftM (processBlock verify) snapshot earlier = inl middle →
∀ prefix suffix txstate,
Chain.Ethereum.Block.t.transactions current = prefix ++ suffix →
Result.List.fold_leftM dispatchTransaction (blockEntry middle current) prefix = inl txstate →
∀ a, List.In a signers → configured (B.t.world_state txstate) (height current) a =
configured snapshot (height current) a).
{ intros earlier current later middle Hparts Hprefix.
apply (Hconfig earlier current (later ++ block :: after) middle).
- rewrite Hsplit, Hparts. rewrite <- app_assoc. reflexivity.
- exact Hprefix. }
rewrite Hsplit, check_blocks_app in Hcheck.
destruct (checkBlocks snapshot (initialConsensusState snapshot initialHeight) before)
as [middle|] eqn:HbeforeCheck; [|discriminate].
pose proof (@initial_backing F
snapshot signers initialHeight until
Hbalance Hformat Hcounters Hsnapshot) as Hinitial.
pose proof (window_induction_under_configuration_agreement snapshot signers until verify before snapshot
Hrevision Hhash Houtputs Hchain Hformat Hsnapshot Hnative HbeforeInputs
ltac:(apply (window_creation_safe_prefix signers verify snapshot before (block :: after));
rewrite <- Hsplit; exact Hsafe)
(initialConsensusState snapshot initialHeight) middle initialHeight
Hbalance Hformat Hsystem Hinitial HprefixSupply HbeforeConfig HbeforeCheck) as Hbacking.
rewrite Hrun in Hbacking.
destruct Hbacking as [previousHeight [Hbacking [HreachedBalance [HreachedFormat [HreachedSystem HreachedTotal]]]]].
pose proof (proj1 (Forall_forall _ _) Hinputs block HblockIn) as Hinput.
destruct Hinput as [Hheader [Hroot [Htime [Htxs Hwidth]]]].
assert (HafterInputs : Forall (blockInputs signers until) after)
by (inversion HrestInputs; assumption).
assert (HblockTxSupply : totalBalance reached + txCredits (Chain.Ethereum.Block.t.transactions block) < 2^256).
{ rewrite Hsplit, window_credits_app in Hsupply.
change (windowCredits (block :: after)) with (blockCredits block + windowCredits after) in Hsupply.
pose proof (input_window_credits_nonnegative signers until after HafterInputs).
pose proof (withdrawal_sum_nonnegative _ Hwidth). lia. }
set (atBlock := {| consensusHistory := consensusHistory middle;
consensusBudgets := fun a ⇒ Z.min (consensusBudgets middle a)
(Numeric.U256.to_z (configured snapshot (height block) a)) |}).
assert (Hclamped : BudgetBacking snapshot atBlock reached signers (height block) until).
{ apply (backing_next_block snapshot middle reached signers previousHeight (height block) until Hbacking).
intros a _. exact (proj1 (@configured_word_range
snapshot (height block) a Hformat)). }
change (match checkTransactions snapshot (Chain.Ethereum.Block.t.header block) atBlock
(Chain.Ethereum.Block.t.transactions block) with
| Some nextBlock ⇒ checkBlocks snapshot nextBlock after | None ⇒ None end = Some next) in Hcheck.
destruct (checkTransactions snapshot (Chain.Ethereum.Block.t.header block) atBlock
(Chain.Ethereum.Block.t.transactions block)) as [nextBlock|] eqn:HblockCheck; [|discriminate].
destruct (@accepted_block_prefix_fee F UI0 UB U8
snapshot signers until reached block atBlock nextBlock
first candidate last state Hrevision Hhash Houtputs Hchain Hsnapshot Hnative Htxs
(Hsafe before block after reached Hsplit Hrun Hvalid) HnotSys
Hheader Hroot HreachedBalance HblockTxSupply HreachedFormat HreachedSystem Hclamped Htime
(Hconfig before block after reached Hsplit Hrun) HblockCheck Htxsplit Htxrun)
as [sender [fee [Hquote [Hfee [_ Hvalidation]]]]].
∃ sender, fee. split; [exact Hquote|]. split; assumption.
Qed.
Configuration agreement is decidable along this finite concrete run.
The negative case identifies a signer and a reached transaction prefix;
it is not an assumed failure of an abstract state relation.
Lemma configuration_prefix_decision snapshot signers verify blocks world :
{∀ before block after reached,
blocks = before ++ block :: after →
Result.List.fold_leftM (processBlock verify) world before = inl reached →
∀ first last state,
Chain.Ethereum.Block.t.transactions block = first ++ last →
Result.List.fold_leftM dispatchTransaction (blockEntry reached block) first = inl state →
∀ a, List.In a signers → configured (B.t.world_state state) (height block) a =
configured snapshot (height block) a} +
{∃ before block after reached first last state a,
blocks = before ++ block :: after ∧
Result.List.fold_leftM (processBlock verify) world before = inl reached ∧
Chain.Ethereum.Block.t.transactions block = first ++ last ∧
Result.List.fold_leftM dispatchTransaction (blockEntry reached block) first = inl state ∧
List.In a signers ∧ configured (B.t.world_state state) (height block) a ≠
configured snapshot (height block) a}.
Proof.
set (atState := fun block state ⇒ ∀ a, List.In a signers →
configured (B.t.world_state state) (height block) a = configured snapshot (height block) a).
assert (decState : ∀ block state, {atState block state} + {¬ atState block state}).
{ intros block state.
destruct (finite_forall_decision (fun a ⇒ configured (B.t.world_state state) (height block) a =
configured snapshot (height block) a) (fun a ⇒ Z.eq_dec _ _) signers) as [Hgood|Hbad].
- left. exact Hgood.
- right. intros Hgood. destruct Hbad as [a [Hin Hneq]]. exact (Hneq (Hgood a Hin)). }
set (atBlock := fun reached block ⇒ ∀ first last state,
Chain.Ethereum.Block.t.transactions block = first ++ last →
Result.List.fold_leftM dispatchTransaction (blockEntry reached block) first = inl state →
atState block state).
assert (decBlock : ∀ reached block, {atBlock reached block} + {¬ atBlock reached block}).
{ intros reached block.
destruct (reached_prefixes_decision dispatchTransaction (atState block) (decState block)
(Chain.Ethereum.Block.t.transactions block) (blockEntry reached block)) as [Hgood|Hbad].
- left. exact Hgood.
- right. intros Hgood. destruct Hbad as [first [last [state [Hsplit [Hrun Hneq]]]]].
exact (Hneq (Hgood first last state Hsplit Hrun)). }
destruct (reached_steps_decision (processBlock verify) atBlock decBlock blocks world) as [Hgood|Hbad].
- left. exact Hgood.
- right. destruct Hbad as [before [block [after [reached [Hsplit [Hrun Hneq]]]]]].
destruct (reached_prefixes_decision dispatchTransaction (atState block) (decState block)
(Chain.Ethereum.Block.t.transactions block) (blockEntry reached block)) as [Hgood|Hbad].
+ exfalso. exact (Hneq Hgood).
+ destruct Hbad as [first [last [state [Htxsplit [Htxrun Htxneq]]]]].
destruct (finite_forall_decision (fun a ⇒ configured (B.t.world_state state) (height block) a =
configured snapshot (height block) a) (fun a ⇒ Z.eq_dec _ _) signers) as [Hgood|Hbad].
× exfalso. exact (Htxneq Hgood).
× destruct Hbad as [a [Hin Hconfig]].
∃ before, block, after, reached, first, last, state, a.
split; [exact Hsplit|]. split; [exact Hrun|]. split; [exact Htxsplit|].
split; [exact Htxrun|]. split; assumption.
Qed.
{∀ before block after reached,
blocks = before ++ block :: after →
Result.List.fold_leftM (processBlock verify) world before = inl reached →
∀ first last state,
Chain.Ethereum.Block.t.transactions block = first ++ last →
Result.List.fold_leftM dispatchTransaction (blockEntry reached block) first = inl state →
∀ a, List.In a signers → configured (B.t.world_state state) (height block) a =
configured snapshot (height block) a} +
{∃ before block after reached first last state a,
blocks = before ++ block :: after ∧
Result.List.fold_leftM (processBlock verify) world before = inl reached ∧
Chain.Ethereum.Block.t.transactions block = first ++ last ∧
Result.List.fold_leftM dispatchTransaction (blockEntry reached block) first = inl state ∧
List.In a signers ∧ configured (B.t.world_state state) (height block) a ≠
configured snapshot (height block) a}.
Proof.
set (atState := fun block state ⇒ ∀ a, List.In a signers →
configured (B.t.world_state state) (height block) a = configured snapshot (height block) a).
assert (decState : ∀ block state, {atState block state} + {¬ atState block state}).
{ intros block state.
destruct (finite_forall_decision (fun a ⇒ configured (B.t.world_state state) (height block) a =
configured snapshot (height block) a) (fun a ⇒ Z.eq_dec _ _) signers) as [Hgood|Hbad].
- left. exact Hgood.
- right. intros Hgood. destruct Hbad as [a [Hin Hneq]]. exact (Hneq (Hgood a Hin)). }
set (atBlock := fun reached block ⇒ ∀ first last state,
Chain.Ethereum.Block.t.transactions block = first ++ last →
Result.List.fold_leftM dispatchTransaction (blockEntry reached block) first = inl state →
atState block state).
assert (decBlock : ∀ reached block, {atBlock reached block} + {¬ atBlock reached block}).
{ intros reached block.
destruct (reached_prefixes_decision dispatchTransaction (atState block) (decState block)
(Chain.Ethereum.Block.t.transactions block) (blockEntry reached block)) as [Hgood|Hbad].
- left. exact Hgood.
- right. intros Hgood. destruct Hbad as [first [last [state [Hsplit [Hrun Hneq]]]]].
exact (Hneq (Hgood first last state Hsplit Hrun)). }
destruct (reached_steps_decision (processBlock verify) atBlock decBlock blocks world) as [Hgood|Hbad].
- left. exact Hgood.
- right. destruct Hbad as [before [block [after [reached [Hsplit [Hrun Hneq]]]]]].
destruct (reached_prefixes_decision dispatchTransaction (atState block) (decState block)
(Chain.Ethereum.Block.t.transactions block) (blockEntry reached block)) as [Hgood|Hbad].
+ exfalso. exact (Hneq Hgood).
+ destruct Hbad as [first [last [state [Htxsplit [Htxrun Htxneq]]]]].
destruct (finite_forall_decision (fun a ⇒ configured (B.t.world_state state) (height block) a =
configured snapshot (height block) a) (fun a ⇒ Z.eq_dec _ _) signers) as [Hgood|Hbad].
× exfalso. exact (Htxneq Hgood).
× destruct Hbad as [a [Hin Hconfig]].
∃ before, block, after, reached, first, last, state, a.
split; [exact Hsplit|]. split; [exact Hrun|]. split; [exact Htxsplit|].
split; [exact Htxrun|]. split; assumption.
Qed.
This starts at the consensus snapshot. There is no assumed incoming
budget invariant, intermediate fee solvency, or configuration agreement.
An insufficient-fee error would instead expose a particular configuration
disagreement, to be ruled out by the concrete delayed-storage proof.
Theorem accepted_window_fee_error_requires_configuration_mismatch
snapshot signers until verify blocks initialHeight next reportedBlock tx details :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → @nativeOutputBounds args →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
totalBalance snapshot + windowCredits blocks < 2^256 →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
Result.List.fold_leftM (processBlock verify) snapshot blocks =
@E.invalid_transaction F W.t reportedBlock tx (Execution.Error.Insufficient_balance details) →
∃ before block after reached first last state a,
blocks = before ++ block :: after ∧
Result.List.fold_leftM (processBlock verify) snapshot before = inl reached ∧
Chain.Ethereum.Block.t.transactions block = first ++ last ∧
Result.List.fold_leftM dispatchTransaction (blockEntry reached block) first = inl state ∧
List.In a signers ∧ configured (B.t.world_state state) (height block) a ≠
configured snapshot (height block) a.
Proof using F U8 UB UI0.
intros Hrevision Hhash Houtputs Hchain Hformat Hsnapshot Hnative Hinputs Hsafe
Hbalance Hcounters Hsystem Hsupply Hcheck Herror.
destruct (configuration_prefix_decision snapshot signers verify blocks snapshot) as [Hconfig|Hbad].
2: exact Hbad.
pose proof (@initial_backing F
snapshot signers initialHeight until
Hbalance Hformat Hcounters Hsnapshot) as Hbacked.
pose proof (window_induction_under_configuration_agreement snapshot signers until verify blocks snapshot
Hrevision Hhash Houtputs Hchain Hformat Hsnapshot Hnative Hinputs Hsafe
(initialConsensusState snapshot initialHeight) next initialHeight
Hbalance Hformat Hsystem Hbacked Hsupply Hconfig Hcheck) as Hwindow.
rewrite Herror in Hwindow. exfalso. exact (Hwindow reportedBlock tx details eq_refl).
Qed.
Local Abbreviation traceRelation := (@reserveStorageTrace).
Local Abbreviation key := (fun addr offset ⇒ @Numeric.U256.to_repr (@Numeric.U256.op_plus (@Reserve_balance.config_slot addr)
(@Numeric.U256.of_int offset))).
snapshot signers until verify blocks initialHeight next reportedBlock tx details :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → @nativeOutputBounds args →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
totalBalance snapshot + windowCredits blocks < 2^256 →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
Result.List.fold_leftM (processBlock verify) snapshot blocks =
@E.invalid_transaction F W.t reportedBlock tx (Execution.Error.Insufficient_balance details) →
∃ before block after reached first last state a,
blocks = before ++ block :: after ∧
Result.List.fold_leftM (processBlock verify) snapshot before = inl reached ∧
Chain.Ethereum.Block.t.transactions block = first ++ last ∧
Result.List.fold_leftM dispatchTransaction (blockEntry reached block) first = inl state ∧
List.In a signers ∧ configured (B.t.world_state state) (height block) a ≠
configured snapshot (height block) a.
Proof using F U8 UB UI0.
intros Hrevision Hhash Houtputs Hchain Hformat Hsnapshot Hnative Hinputs Hsafe
Hbalance Hcounters Hsystem Hsupply Hcheck Herror.
destruct (configuration_prefix_decision snapshot signers verify blocks snapshot) as [Hconfig|Hbad].
2: exact Hbad.
pose proof (@initial_backing F
snapshot signers initialHeight until
Hbalance Hformat Hcounters Hsnapshot) as Hbacked.
pose proof (window_induction_under_configuration_agreement snapshot signers until verify blocks snapshot
Hrevision Hhash Houtputs Hchain Hformat Hsnapshot Hnative Hinputs Hsafe
(initialConsensusState snapshot initialHeight) next initialHeight
Hbalance Hformat Hsystem Hbacked Hsupply Hconfig Hcheck) as Hwindow.
rewrite Herror in Hwindow. exfalso. exact (Hwindow reportedBlock tx details eq_refl).
Qed.
Local Abbreviation traceRelation := (@reserveStorageTrace).
Local Abbreviation key := (fun addr offset ⇒ @Numeric.U256.to_repr (@Numeric.U256.op_plus (@Reserve_balance.config_slot addr)
(@Numeric.U256.of_int offset))).
An accepted window's insufficient-fee error would reveal overlapping
configuration slots for two distinct accounts in a finite native-setting
witness. The proof starts at the snapshot and derives all intermediate
budget, history and system-code invariants. Block order follows from the
executor's number validation. No configuration-agreement or cryptographic
slot-separation premise is assumed. All native output bounds except the
two BLS map-to-curve cases are discharged by the concrete dispatch proof;
those two cases are explicit premises reduced to the cofactor axioms in
blsmapbounds.
Theorem accepted_window_fee_error_has_slot_collision
snapshot signers until verify blocks initialHeight next reportedBlock tx details :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → sha256OutputSize → @blsMapOutputBounds args →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
A.t.code (readAccount snapshot native) = Byte_string.Bytes.empty →
stringmaps.WellFormed (A.t.storage (readAccount snapshot native)) →
totalBalance snapshot + windowCredits blocks < 2^256 →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
Result.List.fold_leftM (processBlock verify) snapshot blocks =
@E.invalid_transaction F W.t reportedBlock tx (Execution.Error.Insufficient_balance details) →
∃ before block after reached first last state query trace n updates addr value i j,
blocks = before ++ block :: after ∧
Result.List.fold_leftM (processBlock verify) snapshot before = inl reached ∧
Chain.Ethereum.Block.t.transactions block = first ++ last ∧
Result.List.fold_leftM dispatchTransaction (blockEntry reached block) first = inl state ∧
List.In query signers ∧
traceRelation (A.t.storage (readAccount snapshot native)) trace
(A.t.storage (readAccount (B.t.world_state state) native)) ∧
List.In (n, updates) trace ∧ List.In (addr,value) updates ∧ addr ≠ query ∧
(0 ≤ i < 3)%Z ∧ (0 ≤ j < 3)%Z ∧ key addr i = key query j.
Proof using F U8 UB UChar UI0 UNibbles.
intros Hrevision Hhash Hsha Hmaps Hchain Hformat Hsnapshot Hnative Hinputs Hsafe
Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Herror.
pose proof (@native_output_bounds_from_bls_maps args Hrevision Hsha Hmaps) as Houtputs.
destruct (accepted_window_fee_error_requires_configuration_mismatch snapshot signers until verify blocks
initialHeight next reportedBlock tx details Hrevision Hhash Houtputs Hchain Hformat Hsnapshot Hnative
Hinputs Hsafe Hbalance Hcounters Hsystem Hsupply Hcheck Herror)
as (before & block & after & reached & first & last & state & query &
Hsplit & Hprefix & Htxsplit & Htxprefix & Hquery & Hmismatch).
assert (HblockIn : List.In block blocks).
{ rewrite Hsplit. apply in_or_app. right. left. reflexivity. }
assert (HbeforeIn : ∀ earlier, List.In earlier before → List.In earlier blocks).
{ intros earlier Hin. rewrite Hsplit. apply in_or_app. left. exact Hin. }
assert (Hsignatures : ∀ b, List.In b blocks → Forall (fun t ⇒ @signaturesAvoidAddress F t native)
(Chain.Ethereum.Block.t.transactions b)).
{ intros b Hin. pose proof (proj1 (Forall_forall _ _) Hinputs b Hin) as Hinput.
destruct Hinput as [_ [_ [_ [Htxs _]]]].
eapply Forall_impl; [|exact Htxs]. intros t [_ [_ [Hauthorities Hsender]]].
change (transactionSender t ≠ Some native ∧
Forall (fun auth ⇒ recoveredAuthority auth ≠ Some native) (T.authorization_list t)).
split.
- intro Heq. exact (proj1 (Hnative native (Hsender native Heq)) eq_refl).
- exact Hauthorities. }
assert (HbeforeSignatures : Forall (fun b ⇒ Forall (fun t ⇒ @signaturesAvoidAddress F t native)
(Chain.Ethereum.Block.t.transactions b)) before).
{ apply Forall_forall. intros b Hin. apply Hsignatures, HbeforeIn. exact Hin. }
assert (HfirstSignatures : Forall (fun t ⇒ @signaturesAvoidAddress F t native) first).
{ pose proof (Hsignatures block HblockIn) as HblockSignatures.
rewrite Htxsplit, Forall_app in HblockSignatures. exact (proj1 HblockSignatures). }
pose proof (@reached_block_follows_previous F
verify blocks snapshot before block after reached _ Hrevision Hsplit Hprefix Herror) as Hordered.
assert (Htimes : Forall (fun b ⇒ (height b ≤ height block < height b + 3)%N) before).
{ pose proof (proj1 (Forall_forall _ _) Hinputs block HblockIn) as Hcurrent.
destruct Hcurrent as [_ [_ [Hcurrent _]]].
apply Forall_forall. intros b Hin.
pose proof (proj1 (Forall_forall _ _) Hinputs b (HbeforeIn b Hin)) as Hpast.
destruct Hpast as [_ [_ [Hpast _]]].
pose proof (proj1 (Forall_forall _ _) Hordered b Hin) as Hlt.
cbv beta in Hcurrent, Hpast, Hlt |- ×. lia. }
pose proof (@read_account_storage_words snapshot native
(proj1 (proj1 (world_format_components snapshot) Hformat))) as Hwords.
destruct (@window_prefix_configuration_or_collision F UChar UNibbles
verify before snapshot reached block first state query (height block) Hrevision (proj1 Hbalance)
Hcode Hstorage Hwords HbeforeSignatures HfirstSignatures Htimes ltac:(lia) Hprefix Htxprefix)
as [Heq|Hcollision].
- exfalso. exact (Hmismatch Heq).
- destruct Hcollision as [trace [n [updates [addr [value [i [j Hcollision]]]]]]].
∃ before, block, after, reached, first, last, state, query, trace, n, updates, addr, value, i, j.
split; [exact Hsplit|]. split; [exact Hprefix|]. split; [exact Htxsplit|].
split; [exact Htxprefix|]. split; [exact Hquery|exact Hcollision].
Qed.
snapshot signers until verify blocks initialHeight next reportedBlock tx details :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → sha256OutputSize → @blsMapOutputBounds args →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
A.t.code (readAccount snapshot native) = Byte_string.Bytes.empty →
stringmaps.WellFormed (A.t.storage (readAccount snapshot native)) →
totalBalance snapshot + windowCredits blocks < 2^256 →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
Result.List.fold_leftM (processBlock verify) snapshot blocks =
@E.invalid_transaction F W.t reportedBlock tx (Execution.Error.Insufficient_balance details) →
∃ before block after reached first last state query trace n updates addr value i j,
blocks = before ++ block :: after ∧
Result.List.fold_leftM (processBlock verify) snapshot before = inl reached ∧
Chain.Ethereum.Block.t.transactions block = first ++ last ∧
Result.List.fold_leftM dispatchTransaction (blockEntry reached block) first = inl state ∧
List.In query signers ∧
traceRelation (A.t.storage (readAccount snapshot native)) trace
(A.t.storage (readAccount (B.t.world_state state) native)) ∧
List.In (n, updates) trace ∧ List.In (addr,value) updates ∧ addr ≠ query ∧
(0 ≤ i < 3)%Z ∧ (0 ≤ j < 3)%Z ∧ key addr i = key query j.
Proof using F U8 UB UChar UI0 UNibbles.
intros Hrevision Hhash Hsha Hmaps Hchain Hformat Hsnapshot Hnative Hinputs Hsafe
Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Herror.
pose proof (@native_output_bounds_from_bls_maps args Hrevision Hsha Hmaps) as Houtputs.
destruct (accepted_window_fee_error_requires_configuration_mismatch snapshot signers until verify blocks
initialHeight next reportedBlock tx details Hrevision Hhash Houtputs Hchain Hformat Hsnapshot Hnative
Hinputs Hsafe Hbalance Hcounters Hsystem Hsupply Hcheck Herror)
as (before & block & after & reached & first & last & state & query &
Hsplit & Hprefix & Htxsplit & Htxprefix & Hquery & Hmismatch).
assert (HblockIn : List.In block blocks).
{ rewrite Hsplit. apply in_or_app. right. left. reflexivity. }
assert (HbeforeIn : ∀ earlier, List.In earlier before → List.In earlier blocks).
{ intros earlier Hin. rewrite Hsplit. apply in_or_app. left. exact Hin. }
assert (Hsignatures : ∀ b, List.In b blocks → Forall (fun t ⇒ @signaturesAvoidAddress F t native)
(Chain.Ethereum.Block.t.transactions b)).
{ intros b Hin. pose proof (proj1 (Forall_forall _ _) Hinputs b Hin) as Hinput.
destruct Hinput as [_ [_ [_ [Htxs _]]]].
eapply Forall_impl; [|exact Htxs]. intros t [_ [_ [Hauthorities Hsender]]].
change (transactionSender t ≠ Some native ∧
Forall (fun auth ⇒ recoveredAuthority auth ≠ Some native) (T.authorization_list t)).
split.
- intro Heq. exact (proj1 (Hnative native (Hsender native Heq)) eq_refl).
- exact Hauthorities. }
assert (HbeforeSignatures : Forall (fun b ⇒ Forall (fun t ⇒ @signaturesAvoidAddress F t native)
(Chain.Ethereum.Block.t.transactions b)) before).
{ apply Forall_forall. intros b Hin. apply Hsignatures, HbeforeIn. exact Hin. }
assert (HfirstSignatures : Forall (fun t ⇒ @signaturesAvoidAddress F t native) first).
{ pose proof (Hsignatures block HblockIn) as HblockSignatures.
rewrite Htxsplit, Forall_app in HblockSignatures. exact (proj1 HblockSignatures). }
pose proof (@reached_block_follows_previous F
verify blocks snapshot before block after reached _ Hrevision Hsplit Hprefix Herror) as Hordered.
assert (Htimes : Forall (fun b ⇒ (height b ≤ height block < height b + 3)%N) before).
{ pose proof (proj1 (Forall_forall _ _) Hinputs block HblockIn) as Hcurrent.
destruct Hcurrent as [_ [_ [Hcurrent _]]].
apply Forall_forall. intros b Hin.
pose proof (proj1 (Forall_forall _ _) Hinputs b (HbeforeIn b Hin)) as Hpast.
destruct Hpast as [_ [_ [Hpast _]]].
pose proof (proj1 (Forall_forall _ _) Hordered b Hin) as Hlt.
cbv beta in Hcurrent, Hpast, Hlt |- ×. lia. }
pose proof (@read_account_storage_words snapshot native
(proj1 (proj1 (world_format_components snapshot) Hformat))) as Hwords.
destruct (@window_prefix_configuration_or_collision F UChar UNibbles
verify before snapshot reached block first state query (height block) Hrevision (proj1 Hbalance)
Hcode Hstorage Hwords HbeforeSignatures HfirstSignatures Htimes ltac:(lia) Hprefix Htxprefix)
as [Heq|Hcollision].
- exfalso. exact (Hmismatch Heq).
- destruct Hcollision as [trace [n [updates [addr [value [i [j Hcollision]]]]]]].
∃ before, block, after, reached, first, last, state, query, trace, n, updates, addr, value, i, j.
split; [exact Hsplit|]. split; [exact Hprefix|]. split; [exact Htxsplit|].
split; [exact Htxprefix|]. split; [exact Hquery|exact Hcollision].
Qed.
Every reached candidate has enough balance for its quoted fee, unless
two distinct accounts' configuration slots collide in a finite setting
witness. This starts at the snapshot, not a supplied budget invariant.
Neither the candidate's nonce nor successful validation is assumed.
The block-header premise records that execution reached the transaction
phase; it is not a premise about any transaction's fee or VM effect.
Theorem accepted_window_reached_fee_or_slot_collision
snapshot signers until verify blocks initialHeight next past current entry
txprefix candidate txsuffix candidateState :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → sha256OutputSize → @blsMapOutputBounds args →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
transactionSender candidate ≠ Some systemSender →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
A.t.code (readAccount snapshot native) = Byte_string.Bytes.empty →
stringmaps.WellFormed (A.t.storage (readAccount snapshot native)) →
totalBalance snapshot + windowCredits blocks < 2^256 →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
blocks = past ++ [current] →
Result.List.fold_leftM (processBlock verify) snapshot past = inl entry →
@E.validate_block F entry current = inl tt →
Chain.Ethereum.Block.t.transactions current = txprefix ++ candidate :: txsuffix →
Result.List.fold_leftM dispatchTransaction (blockEntry entry current) txprefix = inl candidateState →
(∃ sender fee,
transactionQuote (Chain.Ethereum.Block.t.header (B.t.current_block candidateState)) candidate = Some (sender, fee) ∧
Z.of_N fee ≤ balance (B.t.world_state candidateState) sender) ∨
∃ before block after reached first last state query trace n updates addr value i j,
blocks = before ++ block :: after ∧
Result.List.fold_leftM (processBlock verify) snapshot before = inl reached ∧
Chain.Ethereum.Block.t.transactions block = first ++ last ∧
Result.List.fold_leftM dispatchTransaction (blockEntry reached block) first = inl state ∧
List.In query signers ∧
traceRelation (A.t.storage (readAccount snapshot native)) trace
(A.t.storage (readAccount (B.t.world_state state) native)) ∧
List.In (n, updates) trace ∧ List.In (addr,value) updates ∧ addr ≠ query ∧
(0 ≤ i < 3)%Z ∧ (0 ≤ j < 3)%Z ∧ key addr i = key query j.
Proof using F U8 UB UChar UI0 UNibbles.
intros Hrevision Hhash Hsha Hmaps Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys
Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Hwindow HactualRun Hvalid HactualSplit HactualPrefix.
pose proof (@native_output_bounds_from_bls_maps args Hrevision Hsha Hmaps) as Houtputs.
destruct (configuration_prefix_decision snapshot signers verify blocks snapshot) as [Hconfig|Hbad].
- left. destruct (accepted_window_reached_fee_under_configuration_agreement snapshot signers until verify
blocks initialHeight next past current [] entry txprefix candidate txsuffix candidateState
Hrevision Hhash Houtputs Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys Hbalance Hcounters
Hsystem Hsupply Hconfig Hcheck Hwindow HactualRun Hvalid HactualSplit HactualPrefix) as [sender [fee [Hquote [Hfee _]]]].
∃ sender, fee. split; assumption.
- right. destruct Hbad as (before & block & after & reached & first & last & state & query &
Hsplit & Hprefix & Htxsplit & Htxprefix & Hquery & Hmismatch).
assert (HblockIn : List.In block blocks).
{ rewrite Hsplit. apply in_or_app. right. left. reflexivity. }
assert (HbeforeIn : ∀ earlier, List.In earlier before → List.In earlier blocks).
{ intros earlier Hin. rewrite Hsplit. apply in_or_app. left. exact Hin. }
assert (Hsignatures : ∀ b, List.In b blocks → Forall (fun t ⇒ @signaturesAvoidAddress F t native)
(Chain.Ethereum.Block.t.transactions b)).
{ intros b Hin. pose proof (proj1 (Forall_forall _ _) Hinputs b Hin) as Hinput.
destruct Hinput as [_ [_ [_ [Htxs _]]]].
eapply Forall_impl; [|exact Htxs]. intros t [_ [_ [Hauthorities Hsender]]].
change (transactionSender t ≠ Some native ∧
Forall (fun auth ⇒ recoveredAuthority auth ≠ Some native) (T.authorization_list t)).
split.
- intro Heq. exact (proj1 (Hnative native (Hsender native Heq)) eq_refl).
- exact Hauthorities. }
assert (HbeforeSignatures : Forall (fun b ⇒ Forall (fun t ⇒ @signaturesAvoidAddress F t native)
(Chain.Ethereum.Block.t.transactions b)) before).
{ apply Forall_forall. intros b Hin. apply Hsignatures, HbeforeIn. exact Hin. }
assert (HfirstSignatures : Forall (fun t ⇒ @signaturesAvoidAddress F t native) first).
{ pose proof (Hsignatures block HblockIn) as HblockSignatures.
rewrite Htxsplit, Forall_app in HblockSignatures. exact (proj1 HblockSignatures). }
pose proof (@reached_window_block_follows_previous F
verify past snapshot entry current before block after reached Hrevision HactualRun Hvalid
ltac:(rewrite <- Hwindow; exact Hsplit) Hprefix) as Hordered.
assert (Htimes : Forall (fun b ⇒ (height b ≤ height block < height b + 3)%N) before).
{ pose proof (proj1 (Forall_forall _ _) Hinputs block HblockIn) as Hcurrent.
destruct Hcurrent as [_ [_ [Hcurrent _]]].
apply Forall_forall. intros b Hin.
pose proof (proj1 (Forall_forall _ _) Hinputs b (HbeforeIn b Hin)) as Hpast.
destruct Hpast as [_ [_ [Hpast _]]].
pose proof (proj1 (Forall_forall _ _) Hordered b Hin) as Hlt.
cbv beta in Hcurrent, Hpast, Hlt |- ×. lia. }
pose proof (@read_account_storage_words snapshot native
(proj1 (proj1 (world_format_components snapshot) Hformat))) as Hwords.
destruct (@window_prefix_configuration_or_collision F UChar UNibbles
verify before snapshot reached block first state query (height block) Hrevision (proj1 Hbalance)
Hcode Hstorage Hwords HbeforeSignatures HfirstSignatures Htimes ltac:(lia) Hprefix Htxprefix)
as [Heq|Hcollision].
+ exfalso. exact (Hmismatch Heq).
+ destruct Hcollision as [trace [n [updates [addr [value [i [j Hcollision]]]]]]].
∃ before, block, after, reached, first, last, state, query, trace, n, updates, addr, value, i, j.
split; [exact Hsplit|]. split; [exact Hprefix|]. split; [exact Htxsplit|].
split; [exact Htxprefix|]. split; [exact Hquery|exact Hcollision].
Qed.
snapshot signers until verify blocks initialHeight next past current entry
txprefix candidate txsuffix candidateState :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → sha256OutputSize → @blsMapOutputBounds args →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
transactionSender candidate ≠ Some systemSender →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
A.t.code (readAccount snapshot native) = Byte_string.Bytes.empty →
stringmaps.WellFormed (A.t.storage (readAccount snapshot native)) →
totalBalance snapshot + windowCredits blocks < 2^256 →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
blocks = past ++ [current] →
Result.List.fold_leftM (processBlock verify) snapshot past = inl entry →
@E.validate_block F entry current = inl tt →
Chain.Ethereum.Block.t.transactions current = txprefix ++ candidate :: txsuffix →
Result.List.fold_leftM dispatchTransaction (blockEntry entry current) txprefix = inl candidateState →
(∃ sender fee,
transactionQuote (Chain.Ethereum.Block.t.header (B.t.current_block candidateState)) candidate = Some (sender, fee) ∧
Z.of_N fee ≤ balance (B.t.world_state candidateState) sender) ∨
∃ before block after reached first last state query trace n updates addr value i j,
blocks = before ++ block :: after ∧
Result.List.fold_leftM (processBlock verify) snapshot before = inl reached ∧
Chain.Ethereum.Block.t.transactions block = first ++ last ∧
Result.List.fold_leftM dispatchTransaction (blockEntry reached block) first = inl state ∧
List.In query signers ∧
traceRelation (A.t.storage (readAccount snapshot native)) trace
(A.t.storage (readAccount (B.t.world_state state) native)) ∧
List.In (n, updates) trace ∧ List.In (addr,value) updates ∧ addr ≠ query ∧
(0 ≤ i < 3)%Z ∧ (0 ≤ j < 3)%Z ∧ key addr i = key query j.
Proof using F U8 UB UChar UI0 UNibbles.
intros Hrevision Hhash Hsha Hmaps Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys
Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Hwindow HactualRun Hvalid HactualSplit HactualPrefix.
pose proof (@native_output_bounds_from_bls_maps args Hrevision Hsha Hmaps) as Houtputs.
destruct (configuration_prefix_decision snapshot signers verify blocks snapshot) as [Hconfig|Hbad].
- left. destruct (accepted_window_reached_fee_under_configuration_agreement snapshot signers until verify
blocks initialHeight next past current [] entry txprefix candidate txsuffix candidateState
Hrevision Hhash Houtputs Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys Hbalance Hcounters
Hsystem Hsupply Hconfig Hcheck Hwindow HactualRun Hvalid HactualSplit HactualPrefix) as [sender [fee [Hquote [Hfee _]]]].
∃ sender, fee. split; assumption.
- right. destruct Hbad as (before & block & after & reached & first & last & state & query &
Hsplit & Hprefix & Htxsplit & Htxprefix & Hquery & Hmismatch).
assert (HblockIn : List.In block blocks).
{ rewrite Hsplit. apply in_or_app. right. left. reflexivity. }
assert (HbeforeIn : ∀ earlier, List.In earlier before → List.In earlier blocks).
{ intros earlier Hin. rewrite Hsplit. apply in_or_app. left. exact Hin. }
assert (Hsignatures : ∀ b, List.In b blocks → Forall (fun t ⇒ @signaturesAvoidAddress F t native)
(Chain.Ethereum.Block.t.transactions b)).
{ intros b Hin. pose proof (proj1 (Forall_forall _ _) Hinputs b Hin) as Hinput.
destruct Hinput as [_ [_ [_ [Htxs _]]]].
eapply Forall_impl; [|exact Htxs]. intros t [_ [_ [Hauthorities Hsender]]].
change (transactionSender t ≠ Some native ∧
Forall (fun auth ⇒ recoveredAuthority auth ≠ Some native) (T.authorization_list t)).
split.
- intro Heq. exact (proj1 (Hnative native (Hsender native Heq)) eq_refl).
- exact Hauthorities. }
assert (HbeforeSignatures : Forall (fun b ⇒ Forall (fun t ⇒ @signaturesAvoidAddress F t native)
(Chain.Ethereum.Block.t.transactions b)) before).
{ apply Forall_forall. intros b Hin. apply Hsignatures, HbeforeIn. exact Hin. }
assert (HfirstSignatures : Forall (fun t ⇒ @signaturesAvoidAddress F t native) first).
{ pose proof (Hsignatures block HblockIn) as HblockSignatures.
rewrite Htxsplit, Forall_app in HblockSignatures. exact (proj1 HblockSignatures). }
pose proof (@reached_window_block_follows_previous F
verify past snapshot entry current before block after reached Hrevision HactualRun Hvalid
ltac:(rewrite <- Hwindow; exact Hsplit) Hprefix) as Hordered.
assert (Htimes : Forall (fun b ⇒ (height b ≤ height block < height b + 3)%N) before).
{ pose proof (proj1 (Forall_forall _ _) Hinputs block HblockIn) as Hcurrent.
destruct Hcurrent as [_ [_ [Hcurrent _]]].
apply Forall_forall. intros b Hin.
pose proof (proj1 (Forall_forall _ _) Hinputs b (HbeforeIn b Hin)) as Hpast.
destruct Hpast as [_ [_ [Hpast _]]].
pose proof (proj1 (Forall_forall _ _) Hordered b Hin) as Hlt.
cbv beta in Hcurrent, Hpast, Hlt |- ×. lia. }
pose proof (@read_account_storage_words snapshot native
(proj1 (proj1 (world_format_components snapshot) Hformat))) as Hwords.
destruct (@window_prefix_configuration_or_collision F UChar UNibbles
verify before snapshot reached block first state query (height block) Hrevision (proj1 Hbalance)
Hcode Hstorage Hwords HbeforeSignatures HfirstSignatures Htimes ltac:(lia) Hprefix Htxprefix)
as [Heq|Hcollision].
+ exfalso. exact (Hmismatch Heq).
+ destruct Hcollision as [trace [n [updates [addr [value [i [j Hcollision]]]]]]].
∃ before, block, after, reached, first, last, state, query, trace, n, updates, addr, value, i, j.
split; [exact Hsplit|]. split; [exact Hprefix|]. split; [exact Htxsplit|].
split; [exact Htxprefix|]. split; [exact Hquery|exact Hcollision].
Qed.
The numerical result for any reached transaction of an accepted window,
including a window with further blocks after that transaction. Future
validation failures are irrelevant: acceptance and the external-credit
budget restrict to the prefix ending at the candidate's block.
Theorem accepted_transaction_fee_or_slot_collision
snapshot signers until verify blocks initialHeight next past current later entry
txprefix candidate txsuffix candidateState :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → sha256OutputSize → @blsMapOutputBounds args →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
transactionSender candidate ≠ Some systemSender →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
A.t.code (readAccount snapshot native) = Byte_string.Bytes.empty →
stringmaps.WellFormed (A.t.storage (readAccount snapshot native)) →
totalBalance snapshot + windowCredits blocks < 2^256 →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
blocks = past ++ current :: later →
Result.List.fold_leftM (processBlock verify) snapshot past = inl entry →
@E.validate_block F entry current = inl tt →
Chain.Ethereum.Block.t.transactions current = txprefix ++ candidate :: txsuffix →
Result.List.fold_leftM dispatchTransaction (blockEntry entry current) txprefix = inl candidateState →
(∃ sender fee,
transactionQuote (Chain.Ethereum.Block.t.header (B.t.current_block candidateState)) candidate = Some (sender, fee) ∧
Z.of_N fee ≤ balance (B.t.world_state candidateState) sender) ∨
∃ before block after reached first last state query trace n updates addr value i j,
blocks = before ++ block :: after ∧
Result.List.fold_leftM (processBlock verify) snapshot before = inl reached ∧
Chain.Ethereum.Block.t.transactions block = first ++ last ∧
Result.List.fold_leftM dispatchTransaction (blockEntry reached block) first = inl state ∧
List.In query signers ∧
traceRelation (A.t.storage (readAccount snapshot native)) trace
(A.t.storage (readAccount (B.t.world_state state) native)) ∧
List.In (n, updates) trace ∧ List.In (addr,value) updates ∧ addr ≠ query ∧
(0 ≤ i < 3)%Z ∧ (0 ≤ j < 3)%Z ∧ key addr i = key query j.
Proof using F U8 UB UChar UI0 UNibbles.
intros Hrevision Hhash Hsha Hmaps Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys
Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Hwindow HactualRun Hvalid HactualSplit HactualPrefix.
assert (Hsplit : blocks = (past ++ [current]) ++ later).
{ rewrite Hwindow, <- app_assoc. reflexivity. }
assert (HclipInputs : Forall (blockInputs signers until) (past ++ [current])).
{ rewrite Hsplit, Forall_app in Hinputs. exact (proj1 Hinputs). }
assert (HlaterInputs : Forall (blockInputs signers until) later).
{ rewrite Hsplit, Forall_app in Hinputs. exact (proj2 Hinputs). }
assert (HclipIn : ∀ b, List.In b (past ++ [current]) → List.In b blocks).
{ intros b Hin. rewrite Hsplit. apply in_or_app. left. exact Hin. }
assert (HclipSupply : totalBalance snapshot + windowCredits (past ++ [current]) < 2^256).
{ rewrite Hsplit, window_credits_app in Hsupply.
pose proof (input_window_credits_nonnegative signers until later HlaterInputs). lia. }
rewrite Hsplit, check_blocks_app in Hcheck.
destruct (checkBlocks snapshot (initialConsensusState snapshot initialHeight) (past ++ [current]))
as [clipped|] eqn:HclipCheck; [|discriminate].
destruct (accepted_window_reached_fee_or_slot_collision snapshot signers until verify
(past ++ [current]) initialHeight clipped past current entry txprefix candidate txsuffix candidateState
Hrevision Hhash Hsha Hmaps Hchain Hformat Hsnapshot Hnative HclipInputs
ltac:(apply (window_creation_safe_prefix signers verify snapshot (past ++ [current]) later);
rewrite <- Hsplit; exact Hsafe) HnotSys
Hbalance Hcounters Hsystem Hcode Hstorage HclipSupply HclipCheck eq_refl HactualRun Hvalid
HactualSplit HactualPrefix) as [Hfee|Hcollision].
- left. exact Hfee.
- right.
destruct Hcollision as (before & block & after & reached & first & last & state & query &
trace & n & updates & addr & value & i & j & Hparts & Hrest).
∃ before, block, (after ++ later), reached, first, last, state, query,
trace, n, updates, addr, value, i, j.
split; [|exact Hrest]. rewrite Hsplit, Hparts, <- app_assoc. reflexivity.
Qed.
Local Abbreviation hashInput := configHashInput.
Local Abbreviation hashPage := configHashPage.
snapshot signers until verify blocks initialHeight next past current later entry
txprefix candidate txsuffix candidateState :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → sha256OutputSize → @blsMapOutputBounds args →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
transactionSender candidate ≠ Some systemSender →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
A.t.code (readAccount snapshot native) = Byte_string.Bytes.empty →
stringmaps.WellFormed (A.t.storage (readAccount snapshot native)) →
totalBalance snapshot + windowCredits blocks < 2^256 →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
blocks = past ++ current :: later →
Result.List.fold_leftM (processBlock verify) snapshot past = inl entry →
@E.validate_block F entry current = inl tt →
Chain.Ethereum.Block.t.transactions current = txprefix ++ candidate :: txsuffix →
Result.List.fold_leftM dispatchTransaction (blockEntry entry current) txprefix = inl candidateState →
(∃ sender fee,
transactionQuote (Chain.Ethereum.Block.t.header (B.t.current_block candidateState)) candidate = Some (sender, fee) ∧
Z.of_N fee ≤ balance (B.t.world_state candidateState) sender) ∨
∃ before block after reached first last state query trace n updates addr value i j,
blocks = before ++ block :: after ∧
Result.List.fold_leftM (processBlock verify) snapshot before = inl reached ∧
Chain.Ethereum.Block.t.transactions block = first ++ last ∧
Result.List.fold_leftM dispatchTransaction (blockEntry reached block) first = inl state ∧
List.In query signers ∧
traceRelation (A.t.storage (readAccount snapshot native)) trace
(A.t.storage (readAccount (B.t.world_state state) native)) ∧
List.In (n, updates) trace ∧ List.In (addr,value) updates ∧ addr ≠ query ∧
(0 ≤ i < 3)%Z ∧ (0 ≤ j < 3)%Z ∧ key addr i = key query j.
Proof using F U8 UB UChar UI0 UNibbles.
intros Hrevision Hhash Hsha Hmaps Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys
Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Hwindow HactualRun Hvalid HactualSplit HactualPrefix.
assert (Hsplit : blocks = (past ++ [current]) ++ later).
{ rewrite Hwindow, <- app_assoc. reflexivity. }
assert (HclipInputs : Forall (blockInputs signers until) (past ++ [current])).
{ rewrite Hsplit, Forall_app in Hinputs. exact (proj1 Hinputs). }
assert (HlaterInputs : Forall (blockInputs signers until) later).
{ rewrite Hsplit, Forall_app in Hinputs. exact (proj2 Hinputs). }
assert (HclipIn : ∀ b, List.In b (past ++ [current]) → List.In b blocks).
{ intros b Hin. rewrite Hsplit. apply in_or_app. left. exact Hin. }
assert (HclipSupply : totalBalance snapshot + windowCredits (past ++ [current]) < 2^256).
{ rewrite Hsplit, window_credits_app in Hsupply.
pose proof (input_window_credits_nonnegative signers until later HlaterInputs). lia. }
rewrite Hsplit, check_blocks_app in Hcheck.
destruct (checkBlocks snapshot (initialConsensusState snapshot initialHeight) (past ++ [current]))
as [clipped|] eqn:HclipCheck; [|discriminate].
destruct (accepted_window_reached_fee_or_slot_collision snapshot signers until verify
(past ++ [current]) initialHeight clipped past current entry txprefix candidate txsuffix candidateState
Hrevision Hhash Hsha Hmaps Hchain Hformat Hsnapshot Hnative HclipInputs
ltac:(apply (window_creation_safe_prefix signers verify snapshot (past ++ [current]) later);
rewrite <- Hsplit; exact Hsafe) HnotSys
Hbalance Hcounters Hsystem Hcode Hstorage HclipSupply HclipCheck eq_refl HactualRun Hvalid
HactualSplit HactualPrefix) as [Hfee|Hcollision].
- left. exact Hfee.
- right.
destruct Hcollision as (before & block & after & reached & first & last & state & query &
trace & n & updates & addr & value & i & j & Hparts & Hrest).
∃ before, block, (after ++ later), reached, first, last, state, query,
trace, n, updates, addr, value, i, j.
split; [|exact Hrest]. rewrite Hsplit, Hparts, <- app_assoc. reflexivity.
Qed.
Local Abbreviation hashInput := configHashInput.
Local Abbreviation hashPage := configHashPage.
The slot-collision alternative is precisely a masked-hash equality for
a surviving setting and a different tracked account. No field-offset or
U256-wrap exception remains. For 20-byte addresses,
config_hash_input_injective also proves the hash inputs are distinct;
hash collision resistance itself is not assumed here.
Corollary accepted_transaction_fee_or_hash_collision
snapshot signers until verify blocks initialHeight next past current later entry
txprefix candidate txsuffix candidateState :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → sha256OutputSize → @blsMapOutputBounds args →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
transactionSender candidate ≠ Some systemSender →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
A.t.code (readAccount snapshot native) = Byte_string.Bytes.empty →
stringmaps.WellFormed (A.t.storage (readAccount snapshot native)) →
totalBalance snapshot + windowCredits blocks < 2^256 →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
blocks = past ++ current :: later →
Result.List.fold_leftM (processBlock verify) snapshot past = inl entry →
@E.validate_block F entry current = inl tt →
Chain.Ethereum.Block.t.transactions current = txprefix ++ candidate :: txsuffix →
Result.List.fold_leftM dispatchTransaction (blockEntry entry current) txprefix = inl candidateState →
(∃ sender fee,
transactionQuote (Chain.Ethereum.Block.t.header (B.t.current_block candidateState)) candidate = Some (sender, fee) ∧
Z.of_N fee ≤ balance (B.t.world_state candidateState) sender) ∨
∃ before block after reached first last state query trace n updates addr value,
blocks = before ++ block :: after ∧
Result.List.fold_leftM (processBlock verify) snapshot before = inl reached ∧
Chain.Ethereum.Block.t.transactions block = first ++ last ∧
Result.List.fold_leftM dispatchTransaction (blockEntry reached block) first = inl state ∧
List.In query signers ∧
traceRelation (A.t.storage (readAccount snapshot native)) trace
(A.t.storage (readAccount (B.t.world_state state) native)) ∧
List.In (n, updates) trace ∧ List.In (addr,value) updates ∧ addr ≠ query ∧
hashPage (hashInput addr) = hashPage (hashInput query).
Proof using F U8 UB UChar UI0 UNibbles.
intros Hrevision Hhash Hsha Hmaps Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys
Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Hwindow HactualRun Hvalid HactualSplit HactualPrefix.
destruct (accepted_transaction_fee_or_slot_collision snapshot signers until verify blocks
initialHeight next past current later entry txprefix candidate txsuffix candidateState
Hrevision Hhash Hsha Hmaps Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys
Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Hwindow HactualRun Hvalid
HactualSplit HactualPrefix) as [Hfee|Hcollision].
- left. exact Hfee.
- right. destruct Hcollision as (before & block & after & reached & first & last & state & query &
trace & n & updates & addr & value & i & j & Hparts & Hprefix & Htxs & Htxprefix &
Hquery & Htrace & Hin & Hupdate & Hneq & Hi & Hj & Hkeys).
∃ before, block, after, reached, first, last, state, query, trace, n, updates, addr, value.
repeat split; try assumption.
apply config_slot_collision_iff in Hkeys; [|lia|lia].
destruct Hkeys as [Hbase _]. rewrite !config_base_hash in Hbase by exact Hhash.
exact Hbase.
Qed.
snapshot signers until verify blocks initialHeight next past current later entry
txprefix candidate txsuffix candidateState :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → sha256OutputSize → @blsMapOutputBounds args →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
transactionSender candidate ≠ Some systemSender →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
A.t.code (readAccount snapshot native) = Byte_string.Bytes.empty →
stringmaps.WellFormed (A.t.storage (readAccount snapshot native)) →
totalBalance snapshot + windowCredits blocks < 2^256 →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
blocks = past ++ current :: later →
Result.List.fold_leftM (processBlock verify) snapshot past = inl entry →
@E.validate_block F entry current = inl tt →
Chain.Ethereum.Block.t.transactions current = txprefix ++ candidate :: txsuffix →
Result.List.fold_leftM dispatchTransaction (blockEntry entry current) txprefix = inl candidateState →
(∃ sender fee,
transactionQuote (Chain.Ethereum.Block.t.header (B.t.current_block candidateState)) candidate = Some (sender, fee) ∧
Z.of_N fee ≤ balance (B.t.world_state candidateState) sender) ∨
∃ before block after reached first last state query trace n updates addr value,
blocks = before ++ block :: after ∧
Result.List.fold_leftM (processBlock verify) snapshot before = inl reached ∧
Chain.Ethereum.Block.t.transactions block = first ++ last ∧
Result.List.fold_leftM dispatchTransaction (blockEntry reached block) first = inl state ∧
List.In query signers ∧
traceRelation (A.t.storage (readAccount snapshot native)) trace
(A.t.storage (readAccount (B.t.world_state state) native)) ∧
List.In (n, updates) trace ∧ List.In (addr,value) updates ∧ addr ≠ query ∧
hashPage (hashInput addr) = hashPage (hashInput query).
Proof using F U8 UB UChar UI0 UNibbles.
intros Hrevision Hhash Hsha Hmaps Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys
Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Hwindow HactualRun Hvalid HactualSplit HactualPrefix.
destruct (accepted_transaction_fee_or_slot_collision snapshot signers until verify blocks
initialHeight next past current later entry txprefix candidate txsuffix candidateState
Hrevision Hhash Hsha Hmaps Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys
Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Hwindow HactualRun Hvalid
HactualSplit HactualPrefix) as [Hfee|Hcollision].
- left. exact Hfee.
- right. destruct Hcollision as (before & block & after & reached & first & last & state & query &
trace & n & updates & addr & value & i & j & Hparts & Hprefix & Htxs & Htxprefix &
Hquery & Htrace & Hin & Hupdate & Hneq & Hi & Hj & Hkeys).
∃ before, block, after, reached, first, last, state, query, trace, n, updates, addr, value.
repeat split; try assumption.
apply config_slot_collision_iff in Hkeys; [|lia|lia].
destruct Hkeys as [Hbase _]. rewrite !config_base_hash in Hbase by exact Hhash.
exact Hbase.
Qed.
Configuration agreement now follows even for colliding records. The only
native execution obligation still exposed here is the two BLS map bounds;
the reserved-address signature exclusion also remains explicit for review.
Neither storage isolation nor intermediate fee solvency is a premise.
Theorem accepted_window_reached_fee_sufficient
snapshot signers until verify blocks initialHeight next past current entry
txprefix candidate txsuffix candidateState :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → sha256OutputSize → @blsMapOutputBounds args →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
transactionSender candidate ≠ Some systemSender →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
A.t.code (readAccount snapshot native) = Byte_string.Bytes.empty →
stringmaps.WellFormed (A.t.storage (readAccount snapshot native)) →
totalBalance snapshot + windowCredits blocks < 2^256 →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
blocks = past ++ [current] →
Result.List.fold_leftM (processBlock verify) snapshot past = inl entry →
@E.validate_block F entry current = inl tt →
Chain.Ethereum.Block.t.transactions current = txprefix ++ candidate :: txsuffix →
Result.List.fold_leftM dispatchTransaction (blockEntry entry current) txprefix = inl candidateState →
(∃ sender fee,
transactionQuote (Chain.Ethereum.Block.t.header (B.t.current_block candidateState)) candidate = Some (sender, fee) ∧
Z.of_N fee ≤ balance (B.t.world_state candidateState) sender ∧
(∃ validation, @E.validate_transaction F candidateState candidate = inl validation)).
Proof using F U8 UB UChar UI0 UNibbles.
intros Hrevision Hhash Hsha Hmaps Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys
Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Hwindow HactualRun Hvalid HactualSplit HactualPrefix.
pose proof (@native_output_bounds_from_bls_maps args Hrevision Hsha Hmaps) as Houtputs.
destruct (configuration_prefix_decision snapshot signers verify blocks snapshot) as [Hconfig|Hbad].
- exact (accepted_window_reached_fee_under_configuration_agreement snapshot signers until verify
blocks initialHeight next past current [] entry txprefix candidate txsuffix candidateState
Hrevision Hhash Houtputs Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys Hbalance Hcounters
Hsystem Hsupply Hconfig Hcheck Hwindow HactualRun Hvalid HactualSplit HactualPrefix).
- exfalso. destruct Hbad as (before & block & after & reached & first & last & state & query &
Hsplit & Hprefix & Htxsplit & Htxprefix & Hquery & Hmismatch).
assert (HblockIn : List.In block blocks).
{ rewrite Hsplit. apply in_or_app. right. left. reflexivity. }
assert (HbeforeIn : ∀ earlier, List.In earlier before → List.In earlier blocks).
{ intros earlier Hin. rewrite Hsplit. apply in_or_app. left. exact Hin. }
assert (Hsignatures : ∀ b, List.In b blocks → Forall (fun t ⇒ @signaturesAvoidAddress F t native)
(Chain.Ethereum.Block.t.transactions b)).
{ intros b Hin. pose proof (proj1 (Forall_forall _ _) Hinputs b Hin) as Hinput.
destruct Hinput as [_ [_ [_ [Htxs _]]]].
eapply Forall_impl; [|exact Htxs]. intros t [_ [_ [Hauthorities Hsender]]].
change (transactionSender t ≠ Some native ∧
Forall (fun auth ⇒ recoveredAuthority auth ≠ Some native) (T.authorization_list t)).
split.
- intro Heq. exact (proj1 (Hnative native (Hsender native Heq)) eq_refl).
- exact Hauthorities. }
assert (HbeforeSignatures : Forall (fun b ⇒ Forall (fun t ⇒ @signaturesAvoidAddress F t native)
(Chain.Ethereum.Block.t.transactions b)) before).
{ apply Forall_forall. intros b Hin. apply Hsignatures, HbeforeIn. exact Hin. }
assert (HfirstSignatures : Forall (fun t ⇒ @signaturesAvoidAddress F t native) first).
{ pose proof (Hsignatures block HblockIn) as HblockSignatures.
rewrite Htxsplit, Forall_app in HblockSignatures. exact (proj1 HblockSignatures). }
pose proof (@reached_window_block_follows_previous F
verify past snapshot entry current before block after reached Hrevision HactualRun Hvalid
ltac:(rewrite <- Hwindow; exact Hsplit) Hprefix) as Hordered.
assert (Htimes : Forall (fun b ⇒ (height b ≤ height block < height b + 3)%N) before).
{ pose proof (proj1 (Forall_forall _ _) Hinputs block HblockIn) as Hcurrent.
destruct Hcurrent as [_ [_ [Hcurrent _]]].
apply Forall_forall. intros b Hin.
pose proof (proj1 (Forall_forall _ _) Hinputs b (HbeforeIn b Hin)) as Hpast.
destruct Hpast as [_ [_ [Hpast _]]].
pose proof (proj1 (Forall_forall _ _) Hordered b Hin) as Hlt.
cbv beta in Hcurrent, Hpast, Hlt |- ×. lia. }
pose proof (@read_account_storage_words snapshot native
(proj1 (proj1 (world_format_components snapshot) Hformat))) as Hwords.
pose proof (@window_prefix_configuration F UChar UNibbles
verify before snapshot reached block first state query (height block) Hrevision (proj1 Hbalance)
Hcode Hstorage Hwords HbeforeSignatures HfirstSignatures Htimes ltac:(lia) Hprefix Htxprefix)
as Hstable.
exact (Hmismatch Hstable).
Qed.
snapshot signers until verify blocks initialHeight next past current entry
txprefix candidate txsuffix candidateState :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → sha256OutputSize → @blsMapOutputBounds args →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
transactionSender candidate ≠ Some systemSender →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
A.t.code (readAccount snapshot native) = Byte_string.Bytes.empty →
stringmaps.WellFormed (A.t.storage (readAccount snapshot native)) →
totalBalance snapshot + windowCredits blocks < 2^256 →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
blocks = past ++ [current] →
Result.List.fold_leftM (processBlock verify) snapshot past = inl entry →
@E.validate_block F entry current = inl tt →
Chain.Ethereum.Block.t.transactions current = txprefix ++ candidate :: txsuffix →
Result.List.fold_leftM dispatchTransaction (blockEntry entry current) txprefix = inl candidateState →
(∃ sender fee,
transactionQuote (Chain.Ethereum.Block.t.header (B.t.current_block candidateState)) candidate = Some (sender, fee) ∧
Z.of_N fee ≤ balance (B.t.world_state candidateState) sender ∧
(∃ validation, @E.validate_transaction F candidateState candidate = inl validation)).
Proof using F U8 UB UChar UI0 UNibbles.
intros Hrevision Hhash Hsha Hmaps Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys
Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Hwindow HactualRun Hvalid HactualSplit HactualPrefix.
pose proof (@native_output_bounds_from_bls_maps args Hrevision Hsha Hmaps) as Houtputs.
destruct (configuration_prefix_decision snapshot signers verify blocks snapshot) as [Hconfig|Hbad].
- exact (accepted_window_reached_fee_under_configuration_agreement snapshot signers until verify
blocks initialHeight next past current [] entry txprefix candidate txsuffix candidateState
Hrevision Hhash Houtputs Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys Hbalance Hcounters
Hsystem Hsupply Hconfig Hcheck Hwindow HactualRun Hvalid HactualSplit HactualPrefix).
- exfalso. destruct Hbad as (before & block & after & reached & first & last & state & query &
Hsplit & Hprefix & Htxsplit & Htxprefix & Hquery & Hmismatch).
assert (HblockIn : List.In block blocks).
{ rewrite Hsplit. apply in_or_app. right. left. reflexivity. }
assert (HbeforeIn : ∀ earlier, List.In earlier before → List.In earlier blocks).
{ intros earlier Hin. rewrite Hsplit. apply in_or_app. left. exact Hin. }
assert (Hsignatures : ∀ b, List.In b blocks → Forall (fun t ⇒ @signaturesAvoidAddress F t native)
(Chain.Ethereum.Block.t.transactions b)).
{ intros b Hin. pose proof (proj1 (Forall_forall _ _) Hinputs b Hin) as Hinput.
destruct Hinput as [_ [_ [_ [Htxs _]]]].
eapply Forall_impl; [|exact Htxs]. intros t [_ [_ [Hauthorities Hsender]]].
change (transactionSender t ≠ Some native ∧
Forall (fun auth ⇒ recoveredAuthority auth ≠ Some native) (T.authorization_list t)).
split.
- intro Heq. exact (proj1 (Hnative native (Hsender native Heq)) eq_refl).
- exact Hauthorities. }
assert (HbeforeSignatures : Forall (fun b ⇒ Forall (fun t ⇒ @signaturesAvoidAddress F t native)
(Chain.Ethereum.Block.t.transactions b)) before).
{ apply Forall_forall. intros b Hin. apply Hsignatures, HbeforeIn. exact Hin. }
assert (HfirstSignatures : Forall (fun t ⇒ @signaturesAvoidAddress F t native) first).
{ pose proof (Hsignatures block HblockIn) as HblockSignatures.
rewrite Htxsplit, Forall_app in HblockSignatures. exact (proj1 HblockSignatures). }
pose proof (@reached_window_block_follows_previous F
verify past snapshot entry current before block after reached Hrevision HactualRun Hvalid
ltac:(rewrite <- Hwindow; exact Hsplit) Hprefix) as Hordered.
assert (Htimes : Forall (fun b ⇒ (height b ≤ height block < height b + 3)%N) before).
{ pose proof (proj1 (Forall_forall _ _) Hinputs block HblockIn) as Hcurrent.
destruct Hcurrent as [_ [_ [Hcurrent _]]].
apply Forall_forall. intros b Hin.
pose proof (proj1 (Forall_forall _ _) Hinputs b (HbeforeIn b Hin)) as Hpast.
destruct Hpast as [_ [_ [Hpast _]]].
pose proof (proj1 (Forall_forall _ _) Hordered b Hin) as Hlt.
cbv beta in Hcurrent, Hpast, Hlt |- ×. lia. }
pose proof (@read_account_storage_words snapshot native
(proj1 (proj1 (world_format_components snapshot) Hformat))) as Hwords.
pose proof (@window_prefix_configuration F UChar UNibbles
verify before snapshot reached block first state query (height block) Hrevision (proj1 Hbalance)
Hcode Hstorage Hwords HbeforeSignatures HfirstSignatures Htimes ltac:(lia) Hprefix Htxprefix)
as Hstable.
exact (Hmismatch Hstable).
Qed.
The complete block fold cannot report the concrete insufficient-balance
validation error. Other validation errors are not excluded. The proof uses
the same explicit BLS and signature conditions as the numerical theorem.
Theorem accepted_window_no_insufficient_balance
snapshot signers until verify blocks initialHeight next reportedBlock tx details :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → sha256OutputSize → @blsMapOutputBounds args →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
A.t.code (readAccount snapshot native) = Byte_string.Bytes.empty →
stringmaps.WellFormed (A.t.storage (readAccount snapshot native)) →
totalBalance snapshot + windowCredits blocks < 2^256 →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
Result.List.fold_leftM (processBlock verify) snapshot blocks =
@E.invalid_transaction F W.t reportedBlock tx (Execution.Error.Insufficient_balance details) →
False.
Proof using F U8 UB UChar UI0 UNibbles.
intros Hrevision Hhash Hsha Hmaps Hchain Hformat Hsnapshot Hnative Hinputs Hsafe
Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Herror.
pose proof (@native_output_bounds_from_bls_maps args Hrevision Hsha Hmaps) as Houtputs.
destruct (accepted_window_fee_error_requires_configuration_mismatch snapshot signers until verify blocks
initialHeight next reportedBlock tx details Hrevision Hhash Houtputs Hchain Hformat Hsnapshot Hnative
Hinputs Hsafe Hbalance Hcounters Hsystem Hsupply Hcheck Herror)
as (before & block & after & reached & first & last & state & query &
Hsplit & Hprefix & Htxsplit & Htxprefix & Hquery & Hmismatch).
assert (HblockIn : List.In block blocks).
{ rewrite Hsplit. apply in_or_app. right. left. reflexivity. }
assert (HbeforeIn : ∀ earlier, List.In earlier before → List.In earlier blocks).
{ intros earlier Hin. rewrite Hsplit. apply in_or_app. left. exact Hin. }
assert (Hsignatures : ∀ b, List.In b blocks → Forall (fun t ⇒ @signaturesAvoidAddress F t native)
(Chain.Ethereum.Block.t.transactions b)).
{ intros b Hin. pose proof (proj1 (Forall_forall _ _) Hinputs b Hin) as Hinput.
destruct Hinput as [_ [_ [_ [Htxs _]]]].
eapply Forall_impl; [|exact Htxs]. intros t [_ [_ [Hauthorities Hsender]]].
change (transactionSender t ≠ Some native ∧
Forall (fun auth ⇒ recoveredAuthority auth ≠ Some native) (T.authorization_list t)).
split.
- intro Heq. exact (proj1 (Hnative native (Hsender native Heq)) eq_refl).
- exact Hauthorities. }
assert (HbeforeSignatures : Forall (fun b ⇒ Forall (fun t ⇒ @signaturesAvoidAddress F t native)
(Chain.Ethereum.Block.t.transactions b)) before).
{ apply Forall_forall. intros b Hin. apply Hsignatures, HbeforeIn. exact Hin. }
assert (HfirstSignatures : Forall (fun t ⇒ @signaturesAvoidAddress F t native) first).
{ pose proof (Hsignatures block HblockIn) as HblockSignatures.
rewrite Htxsplit, Forall_app in HblockSignatures. exact (proj1 HblockSignatures). }
pose proof (@reached_block_follows_previous F
verify blocks snapshot before block after reached _ Hrevision Hsplit Hprefix Herror) as Hordered.
assert (Htimes : Forall (fun b ⇒ (height b ≤ height block < height b + 3)%N) before).
{ pose proof (proj1 (Forall_forall _ _) Hinputs block HblockIn) as Hcurrent.
destruct Hcurrent as [_ [_ [Hcurrent _]]].
apply Forall_forall. intros b Hin.
pose proof (proj1 (Forall_forall _ _) Hinputs b (HbeforeIn b Hin)) as Hpast.
destruct Hpast as [_ [_ [Hpast _]]].
pose proof (proj1 (Forall_forall _ _) Hordered b Hin) as Hlt.
cbv beta in Hcurrent, Hpast, Hlt |- ×. lia. }
pose proof (@read_account_storage_words snapshot native
(proj1 (proj1 (world_format_components snapshot) Hformat))) as Hwords.
pose proof (@window_prefix_configuration F UChar UNibbles
verify before snapshot reached block first state query (height block) Hrevision (proj1 Hbalance)
Hcode Hstorage Hwords HbeforeSignatures HfirstSignatures Htimes ltac:(lia) Hprefix Htxprefix)
as Hstable.
exact (Hmismatch Hstable).
Qed.
snapshot signers until verify blocks initialHeight next reportedBlock tx details :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → sha256OutputSize → @blsMapOutputBounds args →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
A.t.code (readAccount snapshot native) = Byte_string.Bytes.empty →
stringmaps.WellFormed (A.t.storage (readAccount snapshot native)) →
totalBalance snapshot + windowCredits blocks < 2^256 →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
Result.List.fold_leftM (processBlock verify) snapshot blocks =
@E.invalid_transaction F W.t reportedBlock tx (Execution.Error.Insufficient_balance details) →
False.
Proof using F U8 UB UChar UI0 UNibbles.
intros Hrevision Hhash Hsha Hmaps Hchain Hformat Hsnapshot Hnative Hinputs Hsafe
Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Herror.
pose proof (@native_output_bounds_from_bls_maps args Hrevision Hsha Hmaps) as Houtputs.
destruct (accepted_window_fee_error_requires_configuration_mismatch snapshot signers until verify blocks
initialHeight next reportedBlock tx details Hrevision Hhash Houtputs Hchain Hformat Hsnapshot Hnative
Hinputs Hsafe Hbalance Hcounters Hsystem Hsupply Hcheck Herror)
as (before & block & after & reached & first & last & state & query &
Hsplit & Hprefix & Htxsplit & Htxprefix & Hquery & Hmismatch).
assert (HblockIn : List.In block blocks).
{ rewrite Hsplit. apply in_or_app. right. left. reflexivity. }
assert (HbeforeIn : ∀ earlier, List.In earlier before → List.In earlier blocks).
{ intros earlier Hin. rewrite Hsplit. apply in_or_app. left. exact Hin. }
assert (Hsignatures : ∀ b, List.In b blocks → Forall (fun t ⇒ @signaturesAvoidAddress F t native)
(Chain.Ethereum.Block.t.transactions b)).
{ intros b Hin. pose proof (proj1 (Forall_forall _ _) Hinputs b Hin) as Hinput.
destruct Hinput as [_ [_ [_ [Htxs _]]]].
eapply Forall_impl; [|exact Htxs]. intros t [_ [_ [Hauthorities Hsender]]].
change (transactionSender t ≠ Some native ∧
Forall (fun auth ⇒ recoveredAuthority auth ≠ Some native) (T.authorization_list t)).
split.
- intro Heq. exact (proj1 (Hnative native (Hsender native Heq)) eq_refl).
- exact Hauthorities. }
assert (HbeforeSignatures : Forall (fun b ⇒ Forall (fun t ⇒ @signaturesAvoidAddress F t native)
(Chain.Ethereum.Block.t.transactions b)) before).
{ apply Forall_forall. intros b Hin. apply Hsignatures, HbeforeIn. exact Hin. }
assert (HfirstSignatures : Forall (fun t ⇒ @signaturesAvoidAddress F t native) first).
{ pose proof (Hsignatures block HblockIn) as HblockSignatures.
rewrite Htxsplit, Forall_app in HblockSignatures. exact (proj1 HblockSignatures). }
pose proof (@reached_block_follows_previous F
verify blocks snapshot before block after reached _ Hrevision Hsplit Hprefix Herror) as Hordered.
assert (Htimes : Forall (fun b ⇒ (height b ≤ height block < height b + 3)%N) before).
{ pose proof (proj1 (Forall_forall _ _) Hinputs block HblockIn) as Hcurrent.
destruct Hcurrent as [_ [_ [Hcurrent _]]].
apply Forall_forall. intros b Hin.
pose proof (proj1 (Forall_forall _ _) Hinputs b (HbeforeIn b Hin)) as Hpast.
destruct Hpast as [_ [_ [Hpast _]]].
pose proof (proj1 (Forall_forall _ _) Hordered b Hin) as Hlt.
cbv beta in Hcurrent, Hpast, Hlt |- ×. lia. }
pose proof (@read_account_storage_words snapshot native
(proj1 (proj1 (world_format_components snapshot) Hformat))) as Hwords.
pose proof (@window_prefix_configuration F UChar UNibbles
verify before snapshot reached block first state query (height block) Hrevision (proj1 Hbalance)
Hcode Hstorage Hwords HbeforeSignatures HfirstSignatures Htimes ltac:(lia) Hprefix Htxprefix)
as Hstable.
exact (Hmismatch Hstable).
Qed.
The fee of every reached consensus-accepted user EOA candidate is covered
by its actual balance. Later blocks need not execute successfully, and the
candidate need not validate. This theorem has no hash-collision exception;
it retains the explicit BLS map-bound premise and reserved-address
exclusion described above.
Theorem accepted_transaction_fee_sufficient
snapshot signers until verify blocks initialHeight next past current later entry
txprefix candidate txsuffix candidateState :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → sha256OutputSize → @blsMapOutputBounds args →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
transactionSender candidate ≠ Some systemSender →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
A.t.code (readAccount snapshot native) = Byte_string.Bytes.empty →
stringmaps.WellFormed (A.t.storage (readAccount snapshot native)) →
totalBalance snapshot + windowCredits blocks < 2^256 →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
blocks = past ++ current :: later →
Result.List.fold_leftM (processBlock verify) snapshot past = inl entry →
@E.validate_block F entry current = inl tt →
Chain.Ethereum.Block.t.transactions current = txprefix ++ candidate :: txsuffix →
Result.List.fold_leftM dispatchTransaction (blockEntry entry current) txprefix = inl candidateState →
(∃ sender fee,
transactionQuote (Chain.Ethereum.Block.t.header (B.t.current_block candidateState)) candidate = Some (sender, fee) ∧
Z.of_N fee ≤ balance (B.t.world_state candidateState) sender ∧
(∃ validation, @E.validate_transaction F candidateState candidate = inl validation)).
Proof using F U8 UB UChar UI0 UNibbles.
intros Hrevision Hhash Hsha Hmaps Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys
Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Hwindow HactualRun Hvalid HactualSplit HactualPrefix.
assert (Hsplit : blocks = (past ++ [current]) ++ later).
{ rewrite Hwindow, <- app_assoc. reflexivity. }
assert (HclipInputs : Forall (blockInputs signers until) (past ++ [current])).
{ rewrite Hsplit, Forall_app in Hinputs. exact (proj1 Hinputs). }
assert (HlaterInputs : Forall (blockInputs signers until) later).
{ rewrite Hsplit, Forall_app in Hinputs. exact (proj2 Hinputs). }
assert (HclipIn : ∀ b, List.In b (past ++ [current]) → List.In b blocks).
{ intros b Hin. rewrite Hsplit. apply in_or_app. left. exact Hin. }
assert (HclipSupply : totalBalance snapshot + windowCredits (past ++ [current]) < 2^256).
{ rewrite Hsplit, window_credits_app in Hsupply.
pose proof (input_window_credits_nonnegative signers until later HlaterInputs). lia. }
rewrite Hsplit, check_blocks_app in Hcheck.
destruct (checkBlocks snapshot (initialConsensusState snapshot initialHeight) (past ++ [current]))
as [clipped|] eqn:HclipCheck; [|discriminate].
exact (accepted_window_reached_fee_sufficient snapshot signers until verify
(past ++ [current]) initialHeight clipped past current entry txprefix candidate txsuffix candidateState
Hrevision Hhash Hsha Hmaps Hchain Hformat Hsnapshot Hnative HclipInputs
ltac:(apply (window_creation_safe_prefix signers verify snapshot (past ++ [current]) later);
rewrite <- Hsplit; exact Hsafe) HnotSys
Hbalance Hcounters Hsystem Hcode Hstorage HclipSupply HclipCheck eq_refl HactualRun Hvalid
HactualSplit HactualPrefix).
Qed.
snapshot signers until verify blocks initialHeight next past current later entry
txprefix candidate txsuffix candidateState :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → sha256OutputSize → @blsMapOutputBounds args →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
transactionSender candidate ≠ Some systemSender →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
A.t.code (readAccount snapshot native) = Byte_string.Bytes.empty →
stringmaps.WellFormed (A.t.storage (readAccount snapshot native)) →
totalBalance snapshot + windowCredits blocks < 2^256 →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
blocks = past ++ current :: later →
Result.List.fold_leftM (processBlock verify) snapshot past = inl entry →
@E.validate_block F entry current = inl tt →
Chain.Ethereum.Block.t.transactions current = txprefix ++ candidate :: txsuffix →
Result.List.fold_leftM dispatchTransaction (blockEntry entry current) txprefix = inl candidateState →
(∃ sender fee,
transactionQuote (Chain.Ethereum.Block.t.header (B.t.current_block candidateState)) candidate = Some (sender, fee) ∧
Z.of_N fee ≤ balance (B.t.world_state candidateState) sender ∧
(∃ validation, @E.validate_transaction F candidateState candidate = inl validation)).
Proof using F U8 UB UChar UI0 UNibbles.
intros Hrevision Hhash Hsha Hmaps Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys
Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Hwindow HactualRun Hvalid HactualSplit HactualPrefix.
assert (Hsplit : blocks = (past ++ [current]) ++ later).
{ rewrite Hwindow, <- app_assoc. reflexivity. }
assert (HclipInputs : Forall (blockInputs signers until) (past ++ [current])).
{ rewrite Hsplit, Forall_app in Hinputs. exact (proj1 Hinputs). }
assert (HlaterInputs : Forall (blockInputs signers until) later).
{ rewrite Hsplit, Forall_app in Hinputs. exact (proj2 Hinputs). }
assert (HclipIn : ∀ b, List.In b (past ++ [current]) → List.In b blocks).
{ intros b Hin. rewrite Hsplit. apply in_or_app. left. exact Hin. }
assert (HclipSupply : totalBalance snapshot + windowCredits (past ++ [current]) < 2^256).
{ rewrite Hsplit, window_credits_app in Hsupply.
pose proof (input_window_credits_nonnegative signers until later HlaterInputs). lia. }
rewrite Hsplit, check_blocks_app in Hcheck.
destruct (checkBlocks snapshot (initialConsensusState snapshot initialHeight) (past ++ [current]))
as [clipped|] eqn:HclipCheck; [|discriminate].
exact (accepted_window_reached_fee_sufficient snapshot signers until verify
(past ++ [current]) initialHeight clipped past current entry txprefix candidate txsuffix candidateState
Hrevision Hhash Hsha Hmaps Hchain Hformat Hsnapshot Hnative HclipInputs
ltac:(apply (window_creation_safe_prefix signers verify snapshot (past ++ [current]) later);
rewrite <- Hsplit; exact Hsafe) HnotSys
Hbalance Hcounters Hsystem Hcode Hstorage HclipSupply HclipCheck eq_refl HactualRun Hvalid
HactualSplit HactualPrefix).
Qed.
End-to-end fee solvency with reviewed premises
Section ApprovedCofactorOrders.
Hypothesis bls_g1_cofactor_order : @blsmapbounds.blsG1CofactorOrder .
Hypothesis bls_g2_cofactor_order : @blsmapbounds.blsG2CofactorOrder .
Hypothesis bls_g1_cofactor_order : @blsmapbounds.blsG1CofactorOrder .
Hypothesis bls_g2_cofactor_order : @blsmapbounds.blsG2CofactorOrder .
Consensus accepted the whole window using only its starting snapshot.
Follow actual block execution to any reached user EOA candidate: its sender
can cover its quoted gas-limit fee. Successful preceding execution identifies
the reached state.
Candidate validation is proved separately below, not assumed here.
Initial representation/supply conditions, the prescribed system code,
signature/CREATE exclusions, primitive hash sizes and the two cofactor
identities are explicit. The protected list may contain exactly the
window's transaction senders: other recovered authorities need not be
non-contract or creation-safe. Their signatures must still avoid 0x1001.
The native storage, history and balance
invariants at intermediate points are consequences of the code.
Theorem consensus_fee_solvency
snapshot signers until verify blocks initialHeight next past current later entry
txprefix candidate txsuffix candidateState :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → sha256OutputSize →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
transactionSender candidate ≠ Some systemSender →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
A.t.code (readAccount snapshot native) = Byte_string.Bytes.empty →
stringmaps.WellFormed (A.t.storage (readAccount snapshot native)) →
totalBalance snapshot + windowCredits blocks < 2^256 →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
blocks = past ++ current :: later →
Result.List.fold_leftM (processBlock verify) snapshot past = inl entry →
@E.validate_block F entry current = inl tt →
Chain.Ethereum.Block.t.transactions current = txprefix ++ candidate :: txsuffix →
Result.List.fold_leftM dispatchTransaction (blockEntry entry current) txprefix = inl candidateState →
(∃ sender fee,
transactionQuote (Chain.Ethereum.Block.t.header (B.t.current_block candidateState)) candidate = Some (sender, fee) ∧
Z.of_N fee ≤ balance (B.t.world_state candidateState) sender).
Proof using All.
intros Hrevision Hhash Hsha Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys
Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Hwindow Hrun Hvalid Hsplit Hprefix.
destruct (accepted_transaction_fee_sufficient snapshot signers until verify blocks initialHeight
next past current later entry txprefix candidate txsuffix candidateState Hrevision Hhash Hsha
(@bls_map_output_bounds_from_cofactor_orders args bls_g1_cofactor_order bls_g2_cofactor_order)
Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys Hbalance Hcounters Hsystem Hcode Hstorage
Hsupply Hcheck Hwindow Hrun Hvalid Hsplit Hprefix) as [sender [fee [Hquote [Hfee _]]]].
∃ sender, fee. split; assumption.
Qed.
snapshot signers until verify blocks initialHeight next past current later entry
txprefix candidate txsuffix candidateState :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → sha256OutputSize →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
transactionSender candidate ≠ Some systemSender →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
A.t.code (readAccount snapshot native) = Byte_string.Bytes.empty →
stringmaps.WellFormed (A.t.storage (readAccount snapshot native)) →
totalBalance snapshot + windowCredits blocks < 2^256 →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
blocks = past ++ current :: later →
Result.List.fold_leftM (processBlock verify) snapshot past = inl entry →
@E.validate_block F entry current = inl tt →
Chain.Ethereum.Block.t.transactions current = txprefix ++ candidate :: txsuffix →
Result.List.fold_leftM dispatchTransaction (blockEntry entry current) txprefix = inl candidateState →
(∃ sender fee,
transactionQuote (Chain.Ethereum.Block.t.header (B.t.current_block candidateState)) candidate = Some (sender, fee) ∧
Z.of_N fee ≤ balance (B.t.world_state candidateState) sender).
Proof using All.
intros Hrevision Hhash Hsha Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys
Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Hwindow Hrun Hvalid Hsplit Hprefix.
destruct (accepted_transaction_fee_sufficient snapshot signers until verify blocks initialHeight
next past current later entry txprefix candidate txsuffix candidateState Hrevision Hhash Hsha
(@bls_map_output_bounds_from_cofactor_orders args bls_g1_cofactor_order bls_g2_cofactor_order)
Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys Hbalance Hcounters Hsystem Hcode Hstorage
Hsupply Hcheck Hwindow Hrun Hvalid Hsplit Hprefix) as [sender [fee [Hquote [Hfee _]]]].
∃ sender, fee. split; assumption.
Qed.
Every reached user EOA candidate passes all native transaction-validation
checks. Only preceding execution and the current block's header validation
are premises. VM success and block final-state-root checks are separate.
Theorem consensus_transaction_validation
snapshot signers until verify blocks initialHeight next past current later entry
txprefix candidate txsuffix candidateState :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → sha256OutputSize →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
transactionSender candidate ≠ Some systemSender →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
A.t.code (readAccount snapshot native) = Byte_string.Bytes.empty →
stringmaps.WellFormed (A.t.storage (readAccount snapshot native)) →
totalBalance snapshot + windowCredits blocks < 2^256 →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
blocks = past ++ current :: later →
Result.List.fold_leftM (processBlock verify) snapshot past = inl entry →
@E.validate_block F entry current = inl tt →
Chain.Ethereum.Block.t.transactions current = txprefix ++ candidate :: txsuffix →
Result.List.fold_leftM dispatchTransaction (blockEntry entry current) txprefix = inl candidateState →
∃ validation, @E.validate_transaction F candidateState candidate = inl validation.
Proof using All.
intros Hrevision Hhash Hsha Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys
Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Hwindow Hrun Hvalid Hsplit Hprefix.
destruct (accepted_transaction_fee_sufficient snapshot signers until verify blocks initialHeight
next past current later entry txprefix candidate txsuffix candidateState Hrevision Hhash Hsha
(@bls_map_output_bounds_from_cofactor_orders args bls_g1_cofactor_order bls_g2_cofactor_order)
Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys Hbalance Hcounters Hsystem Hcode Hstorage
Hsupply Hcheck Hwindow Hrun Hvalid Hsplit Hprefix) as [sender [fee [_ [_ Hvalidation]]]].
exact Hvalidation.
Qed.
snapshot signers until verify blocks initialHeight next past current later entry
txprefix candidate txsuffix candidateState :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → sha256OutputSize →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
transactionSender candidate ≠ Some systemSender →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
A.t.code (readAccount snapshot native) = Byte_string.Bytes.empty →
stringmaps.WellFormed (A.t.storage (readAccount snapshot native)) →
totalBalance snapshot + windowCredits blocks < 2^256 →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
blocks = past ++ current :: later →
Result.List.fold_leftM (processBlock verify) snapshot past = inl entry →
@E.validate_block F entry current = inl tt →
Chain.Ethereum.Block.t.transactions current = txprefix ++ candidate :: txsuffix →
Result.List.fold_leftM dispatchTransaction (blockEntry entry current) txprefix = inl candidateState →
∃ validation, @E.validate_transaction F candidateState candidate = inl validation.
Proof using All.
intros Hrevision Hhash Hsha Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys
Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Hwindow Hrun Hvalid Hsplit Hprefix.
destruct (accepted_transaction_fee_sufficient snapshot signers until verify blocks initialHeight
next past current later entry txprefix candidate txsuffix candidateState Hrevision Hhash Hsha
(@bls_map_output_bounds_from_cofactor_orders args bls_g1_cofactor_order bls_g2_cofactor_order)
Hchain Hformat Hsnapshot Hnative Hinputs Hsafe HnotSys Hbalance Hcounters Hsystem Hcode Hstorage
Hsupply Hcheck Hwindow Hrun Hvalid Hsplit Hprefix) as [sender [fee [_ [_ Hvalidation]]]].
exact Hvalidation.
Qed.
The whole generated block fold cannot fail with fee insolvency. This is
retained alongside the stronger no-transaction-validation-error corollary
below; the numerical theorem also exposes the candidate's actual balance.
Corollary consensus_no_insufficient_balance
snapshot signers until verify blocks initialHeight next reportedBlock tx details :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → sha256OutputSize →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
A.t.code (readAccount snapshot native) = Byte_string.Bytes.empty →
stringmaps.WellFormed (A.t.storage (readAccount snapshot native)) →
totalBalance snapshot + windowCredits blocks < 2^256 →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
Result.List.fold_leftM (processBlock verify) snapshot blocks =
@E.invalid_transaction F W.t reportedBlock tx (Execution.Error.Insufficient_balance details) →
False.
Proof using All.
intros Hrevision Hhash Hsha Hchain Hformat Hsnapshot Hnative Hinputs Hsafe
Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Herror.
exact (accepted_window_no_insufficient_balance snapshot signers until verify blocks initialHeight
next reportedBlock tx details Hrevision Hhash Hsha
(@bls_map_output_bounds_from_cofactor_orders args bls_g1_cofactor_order bls_g2_cofactor_order)
Hchain Hformat Hsnapshot Hnative Hinputs Hsafe Hbalance Hcounters Hsystem Hcode Hstorage
Hsupply Hcheck Herror).
Qed.
snapshot signers until verify blocks initialHeight next reportedBlock tx details :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → sha256OutputSize →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
A.t.code (readAccount snapshot native) = Byte_string.Bytes.empty →
stringmaps.WellFormed (A.t.storage (readAccount snapshot native)) →
totalBalance snapshot + windowCredits blocks < 2^256 →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
Result.List.fold_leftM (processBlock verify) snapshot blocks =
@E.invalid_transaction F W.t reportedBlock tx (Execution.Error.Insufficient_balance details) →
False.
Proof using All.
intros Hrevision Hhash Hsha Hchain Hformat Hsnapshot Hnative Hinputs Hsafe
Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Herror.
exact (accepted_window_no_insufficient_balance snapshot signers until verify blocks initialHeight
next reportedBlock tx details Hrevision Hhash Hsha
(@bls_map_output_bounds_from_cofactor_orders args bls_g1_cofactor_order bls_g2_cofactor_order)
Hchain Hformat Hsnapshot Hnative Hinputs Hsafe Hbalance Hcounters Hsystem Hcode Hstorage
Hsupply Hcheck Herror).
Qed.
No successful-prefix premise is needed for this whole-window corollary.
Any transaction-validation or system-transaction error would expose a first
rejected candidate, contradicting accepted_block_no_transaction_error.
Block-header/root errors remain possible.
Corollary consensus_no_transaction_validation_error
snapshot signers until verify blocks initialHeight next details :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → sha256OutputSize →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
windowValidStakingSyscalls verify snapshot blocks →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
A.t.code (readAccount snapshot native) = Byte_string.Bytes.empty →
stringmaps.WellFormed (A.t.storage (readAccount snapshot native)) →
totalBalance snapshot + windowCredits blocks < 2^256 →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
Result.List.fold_leftM (processBlock verify) snapshot blocks =
inr (Execution.Error.Invalid_transaction details) →
False.
Proof using All.
intros Hrevision Hhash Hsha Hchain Hformat Hsnapshot Hnative Hinputs Hsafe Hstaking
Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Herror.
pose proof (@native_output_bounds_from_bls_maps args Hrevision Hsha
(@bls_map_output_bounds_from_cofactor_orders args bls_g1_cofactor_order bls_g2_cofactor_order))
as Houtputs.
destruct (configuration_prefix_decision snapshot signers verify blocks snapshot) as [Hconfig|Hbad].
- destruct (fold_leftM_first_error _ _ _ _ Herror)
as [before [block [after [world [Hsplit [Hprefix Hfailed]]]]]].
assert (HbeforeInputs : Forall (blockInputs signers until) before).
{ rewrite Hsplit, Forall_app in Hinputs. exact (proj1 Hinputs). }
assert (HrestInputs : Forall (blockInputs signers until) (block :: after)).
{ rewrite Hsplit, Forall_app in Hinputs. exact (proj2 Hinputs). }
assert (HprefixSupply : totalBalance snapshot + windowCredits before < 2^256).
{ rewrite Hsplit, window_credits_app in Hsupply.
pose proof (input_window_credits_nonnegative signers until _ HrestInputs). lia. }
assert (HbeforeConfig : ∀ earlier current later middle,
before = earlier ++ current :: later →
Result.List.fold_leftM (processBlock verify) snapshot earlier = inl middle →
∀ prefix suffix txstate,
Chain.Ethereum.Block.t.transactions current = prefix ++ suffix →
Result.List.fold_leftM dispatchTransaction (blockEntry middle current) prefix = inl txstate →
∀ a, List.In a signers → configured (B.t.world_state txstate) (height current) a =
configured snapshot (height current) a).
{ intros earlier current later middle Hparts Hpre.
apply (Hconfig earlier current (later ++ block :: after) middle).
- rewrite Hsplit, Hparts, <- app_assoc. reflexivity.
- exact Hpre. }
pose proof Hcheck as Hchk.
rewrite Hsplit, check_blocks_app in Hchk.
destruct (checkBlocks snapshot (initialConsensusState snapshot initialHeight) before)
as [middle|] eqn:HbeforeCheck; [|discriminate Hchk].
pose proof (@initial_backing F snapshot signers initialHeight until
Hbalance Hformat Hcounters Hsnapshot) as Hinitial.
pose proof (window_induction_under_configuration_agreement snapshot signers until verify before snapshot
Hrevision Hhash Houtputs Hchain Hformat Hsnapshot Hnative HbeforeInputs
ltac:(apply (window_creation_safe_prefix signers verify snapshot before (block :: after));
rewrite <- Hsplit; exact Hsafe)
(initialConsensusState snapshot initialHeight) middle initialHeight
Hbalance Hformat Hsystem Hinitial HprefixSupply HbeforeConfig HbeforeCheck) as Hbacking.
rewrite Hprefix in Hbacking.
destruct Hbacking as [previousHeight [Hbacking [HworldBalance [HworldFormat [HworldSystem HworldTotal]]]]].
pose proof (Forall_inv HrestInputs) as [Hheader [Hroot [Htime [Htxs Hwidth]]]].
pose proof (Forall_inv_tail HrestInputs) as HafterInputs.
assert (HblockTxSupply : totalBalance world + txCredits (Chain.Ethereum.Block.t.transactions block) < 2^256).
{ rewrite Hsplit, window_credits_app in Hsupply.
change (windowCredits (block :: after)) with (blockCredits block + windowCredits after) in Hsupply.
pose proof (input_window_credits_nonnegative signers until after HafterInputs).
pose proof (withdrawal_sum_nonnegative _ Hwidth). lia. }
set (atBlock := {| consensusHistory := consensusHistory middle;
consensusBudgets := fun a ⇒ Z.min (consensusBudgets middle a)
(Numeric.U256.to_z (configured snapshot (height block) a)) |}).
assert (Hclamped : BudgetBacking snapshot atBlock world signers (height block) until).
{ apply (backing_next_block snapshot middle world signers previousHeight (height block) until Hbacking).
intros a _. exact (proj1 (@configured_word_range snapshot (height block) a Hformat)). }
change (match checkTransactions snapshot (Chain.Ethereum.Block.t.header block) atBlock
(Chain.Ethereum.Block.t.transactions block) with
| Some nextBlock ⇒ checkBlocks snapshot nextBlock after | None ⇒ None end = Some next) in Hchk.
destruct (checkTransactions snapshot (Chain.Ethereum.Block.t.header block) atBlock
(Chain.Ethereum.Block.t.transactions block)) as [nextBlock|] eqn:HblockCheck; [|discriminate Hchk].
exact (@accepted_block_no_transaction_error F UI0 UB U8
snapshot signers until verify world block atBlock nextBlock Hrevision Hhash Houtputs Hchain
Hsnapshot Hnative Htxs
(Hsafe before block after world Hsplit Hprefix)
(Hstaking before block after world Hsplit Hprefix)
Hheader Hroot HworldBalance HblockTxSupply HworldFormat HworldSystem Hclamped Htime
(Hconfig before block after world Hsplit Hprefix) HblockCheck details Hfailed).
- destruct Hbad as (before & block & after & reached & first & last & state & query &
Hsplit & Hprefix & Htxsplit & Htxprefix & Hquery & Hmismatch).
assert (HblockIn : List.In block blocks).
{ rewrite Hsplit. apply in_or_app. right. left. reflexivity. }
assert (HbeforeIn : ∀ earlier, List.In earlier before → List.In earlier blocks).
{ intros earlier Hin. rewrite Hsplit. apply in_or_app. left. exact Hin. }
assert (Hsignatures : ∀ b, List.In b blocks → Forall (fun t ⇒ @signaturesAvoidAddress F t native)
(Chain.Ethereum.Block.t.transactions b)).
{ intros b Hin. pose proof (proj1 (Forall_forall _ _) Hinputs b Hin) as Hinput.
destruct Hinput as [_ [_ [_ [Htxs _]]]].
eapply Forall_impl; [|exact Htxs]. intros t [_ [_ [Hauthorities Hsender]]].
change (transactionSender t ≠ Some native ∧
Forall (fun auth ⇒ recoveredAuthority auth ≠ Some native) (T.authorization_list t)).
split.
- intro Heq. exact (proj1 (Hnative native (Hsender native Heq)) eq_refl).
- exact Hauthorities. }
assert (HbeforeSignatures : Forall (fun b ⇒ Forall (fun t ⇒ @signaturesAvoidAddress F t native)
(Chain.Ethereum.Block.t.transactions b)) before).
{ apply Forall_forall. intros b Hin. apply Hsignatures, HbeforeIn. exact Hin. }
assert (HfirstSignatures : Forall (fun t ⇒ @signaturesAvoidAddress F t native) first).
{ pose proof (Hsignatures block HblockIn) as HblockSignatures.
rewrite Htxsplit, Forall_app in HblockSignatures. exact (proj1 HblockSignatures). }
pose proof (@reached_block_follows_previous F
verify blocks snapshot before block after reached _ Hrevision Hsplit Hprefix Herror) as Hordered.
assert (Htimes : Forall (fun b ⇒ (height b ≤ height block < height b + 3)%N) before).
{ pose proof (proj1 (Forall_forall _ _) Hinputs block HblockIn) as Hcurrent.
destruct Hcurrent as [_ [_ [Hcurrent _]]].
apply Forall_forall. intros b Hin.
pose proof (proj1 (Forall_forall _ _) Hinputs b (HbeforeIn b Hin)) as Hpast.
destruct Hpast as [_ [_ [Hpast _]]].
pose proof (proj1 (Forall_forall _ _) Hordered b Hin) as Hlt.
cbv beta in Hcurrent, Hpast, Hlt |- ×. lia. }
pose proof (@read_account_storage_words snapshot native
(proj1 (proj1 (world_format_components snapshot) Hformat))) as Hwords.
pose proof (@window_prefix_configuration F UChar UNibbles
verify before snapshot reached block first state query (height block) Hrevision (proj1 Hbalance)
Hcode Hstorage Hwords HbeforeSignatures HfirstSignatures Htimes ltac:(lia) Hprefix Htxprefix)
as Hstable.
exact (Hmismatch Hstable).
Qed.
End ApprovedCofactorOrders.
End Execution.
snapshot signers until verify blocks initialHeight next details :
(@E.Params F).(Execution.Make_Params_signature.revision) = Support.Variants.Revision.Eleven →
keccak256OutputSize → sha256OutputSize →
wordRange (Support.UintN.to_z (Chain.Monad.PARAMS.chain_id params)) →
worldFormat snapshot →
(∀ a, List.In a signers → @A.is_smart_contract (readAccount snapshot a) = false) →
(∀ a, List.In a signers → a ≠ native ∧ a ≠ staking) →
Forall (blockInputs signers until) blocks →
windowAvoidsSignerCreation signers verify snapshot blocks →
windowValidStakingSyscalls verify snapshot blocks →
balanceInvariant snapshot →
stringmaps.WellFormed (W.t.next_emptying_transaction_block snapshot) →
@prescribedSystemCode F snapshot →
A.t.code (readAccount snapshot native) = Byte_string.Bytes.empty →
stringmaps.WellFormed (A.t.storage (readAccount snapshot native)) →
totalBalance snapshot + windowCredits blocks < 2^256 →
checkBlocks snapshot (initialConsensusState snapshot initialHeight) blocks = Some next →
Result.List.fold_leftM (processBlock verify) snapshot blocks =
inr (Execution.Error.Invalid_transaction details) →
False.
Proof using All.
intros Hrevision Hhash Hsha Hchain Hformat Hsnapshot Hnative Hinputs Hsafe Hstaking
Hbalance Hcounters Hsystem Hcode Hstorage Hsupply Hcheck Herror.
pose proof (@native_output_bounds_from_bls_maps args Hrevision Hsha
(@bls_map_output_bounds_from_cofactor_orders args bls_g1_cofactor_order bls_g2_cofactor_order))
as Houtputs.
destruct (configuration_prefix_decision snapshot signers verify blocks snapshot) as [Hconfig|Hbad].
- destruct (fold_leftM_first_error _ _ _ _ Herror)
as [before [block [after [world [Hsplit [Hprefix Hfailed]]]]]].
assert (HbeforeInputs : Forall (blockInputs signers until) before).
{ rewrite Hsplit, Forall_app in Hinputs. exact (proj1 Hinputs). }
assert (HrestInputs : Forall (blockInputs signers until) (block :: after)).
{ rewrite Hsplit, Forall_app in Hinputs. exact (proj2 Hinputs). }
assert (HprefixSupply : totalBalance snapshot + windowCredits before < 2^256).
{ rewrite Hsplit, window_credits_app in Hsupply.
pose proof (input_window_credits_nonnegative signers until _ HrestInputs). lia. }
assert (HbeforeConfig : ∀ earlier current later middle,
before = earlier ++ current :: later →
Result.List.fold_leftM (processBlock verify) snapshot earlier = inl middle →
∀ prefix suffix txstate,
Chain.Ethereum.Block.t.transactions current = prefix ++ suffix →
Result.List.fold_leftM dispatchTransaction (blockEntry middle current) prefix = inl txstate →
∀ a, List.In a signers → configured (B.t.world_state txstate) (height current) a =
configured snapshot (height current) a).
{ intros earlier current later middle Hparts Hpre.
apply (Hconfig earlier current (later ++ block :: after) middle).
- rewrite Hsplit, Hparts, <- app_assoc. reflexivity.
- exact Hpre. }
pose proof Hcheck as Hchk.
rewrite Hsplit, check_blocks_app in Hchk.
destruct (checkBlocks snapshot (initialConsensusState snapshot initialHeight) before)
as [middle|] eqn:HbeforeCheck; [|discriminate Hchk].
pose proof (@initial_backing F snapshot signers initialHeight until
Hbalance Hformat Hcounters Hsnapshot) as Hinitial.
pose proof (window_induction_under_configuration_agreement snapshot signers until verify before snapshot
Hrevision Hhash Houtputs Hchain Hformat Hsnapshot Hnative HbeforeInputs
ltac:(apply (window_creation_safe_prefix signers verify snapshot before (block :: after));
rewrite <- Hsplit; exact Hsafe)
(initialConsensusState snapshot initialHeight) middle initialHeight
Hbalance Hformat Hsystem Hinitial HprefixSupply HbeforeConfig HbeforeCheck) as Hbacking.
rewrite Hprefix in Hbacking.
destruct Hbacking as [previousHeight [Hbacking [HworldBalance [HworldFormat [HworldSystem HworldTotal]]]]].
pose proof (Forall_inv HrestInputs) as [Hheader [Hroot [Htime [Htxs Hwidth]]]].
pose proof (Forall_inv_tail HrestInputs) as HafterInputs.
assert (HblockTxSupply : totalBalance world + txCredits (Chain.Ethereum.Block.t.transactions block) < 2^256).
{ rewrite Hsplit, window_credits_app in Hsupply.
change (windowCredits (block :: after)) with (blockCredits block + windowCredits after) in Hsupply.
pose proof (input_window_credits_nonnegative signers until after HafterInputs).
pose proof (withdrawal_sum_nonnegative _ Hwidth). lia. }
set (atBlock := {| consensusHistory := consensusHistory middle;
consensusBudgets := fun a ⇒ Z.min (consensusBudgets middle a)
(Numeric.U256.to_z (configured snapshot (height block) a)) |}).
assert (Hclamped : BudgetBacking snapshot atBlock world signers (height block) until).
{ apply (backing_next_block snapshot middle world signers previousHeight (height block) until Hbacking).
intros a _. exact (proj1 (@configured_word_range snapshot (height block) a Hformat)). }
change (match checkTransactions snapshot (Chain.Ethereum.Block.t.header block) atBlock
(Chain.Ethereum.Block.t.transactions block) with
| Some nextBlock ⇒ checkBlocks snapshot nextBlock after | None ⇒ None end = Some next) in Hchk.
destruct (checkTransactions snapshot (Chain.Ethereum.Block.t.header block) atBlock
(Chain.Ethereum.Block.t.transactions block)) as [nextBlock|] eqn:HblockCheck; [|discriminate Hchk].
exact (@accepted_block_no_transaction_error F UI0 UB U8
snapshot signers until verify world block atBlock nextBlock Hrevision Hhash Houtputs Hchain
Hsnapshot Hnative Htxs
(Hsafe before block after world Hsplit Hprefix)
(Hstaking before block after world Hsplit Hprefix)
Hheader Hroot HworldBalance HblockTxSupply HworldFormat HworldSystem Hclamped Htime
(Hconfig before block after world Hsplit Hprefix) HblockCheck details Hfailed).
- destruct Hbad as (before & block & after & reached & first & last & state & query &
Hsplit & Hprefix & Htxsplit & Htxprefix & Hquery & Hmismatch).
assert (HblockIn : List.In block blocks).
{ rewrite Hsplit. apply in_or_app. right. left. reflexivity. }
assert (HbeforeIn : ∀ earlier, List.In earlier before → List.In earlier blocks).
{ intros earlier Hin. rewrite Hsplit. apply in_or_app. left. exact Hin. }
assert (Hsignatures : ∀ b, List.In b blocks → Forall (fun t ⇒ @signaturesAvoidAddress F t native)
(Chain.Ethereum.Block.t.transactions b)).
{ intros b Hin. pose proof (proj1 (Forall_forall _ _) Hinputs b Hin) as Hinput.
destruct Hinput as [_ [_ [_ [Htxs _]]]].
eapply Forall_impl; [|exact Htxs]. intros t [_ [_ [Hauthorities Hsender]]].
change (transactionSender t ≠ Some native ∧
Forall (fun auth ⇒ recoveredAuthority auth ≠ Some native) (T.authorization_list t)).
split.
- intro Heq. exact (proj1 (Hnative native (Hsender native Heq)) eq_refl).
- exact Hauthorities. }
assert (HbeforeSignatures : Forall (fun b ⇒ Forall (fun t ⇒ @signaturesAvoidAddress F t native)
(Chain.Ethereum.Block.t.transactions b)) before).
{ apply Forall_forall. intros b Hin. apply Hsignatures, HbeforeIn. exact Hin. }
assert (HfirstSignatures : Forall (fun t ⇒ @signaturesAvoidAddress F t native) first).
{ pose proof (Hsignatures block HblockIn) as HblockSignatures.
rewrite Htxsplit, Forall_app in HblockSignatures. exact (proj1 HblockSignatures). }
pose proof (@reached_block_follows_previous F
verify blocks snapshot before block after reached _ Hrevision Hsplit Hprefix Herror) as Hordered.
assert (Htimes : Forall (fun b ⇒ (height b ≤ height block < height b + 3)%N) before).
{ pose proof (proj1 (Forall_forall _ _) Hinputs block HblockIn) as Hcurrent.
destruct Hcurrent as [_ [_ [Hcurrent _]]].
apply Forall_forall. intros b Hin.
pose proof (proj1 (Forall_forall _ _) Hinputs b (HbeforeIn b Hin)) as Hpast.
destruct Hpast as [_ [_ [Hpast _]]].
pose proof (proj1 (Forall_forall _ _) Hordered b Hin) as Hlt.
cbv beta in Hcurrent, Hpast, Hlt |- ×. lia. }
pose proof (@read_account_storage_words snapshot native
(proj1 (proj1 (world_format_components snapshot) Hformat))) as Hwords.
pose proof (@window_prefix_configuration F UChar UNibbles
verify before snapshot reached block first state query (height block) Hrevision (proj1 Hbalance)
Hcode Hstorage Hwords HbeforeSignatures HfirstSignatures Htimes ltac:(lia) Hprefix Htxprefix)
as Hstable.
exact (Hmismatch Hstable).
Qed.
End ApprovedCofactorOrders.
End Execution.