Library SetcodeConcrete.consensusresources
Initial bounds are preserved across an admitted block window
From Stdlib Require Import List ZArith.
Require Import RocqOfOCaml.RocqOfOCaml MonadVM.Execution.
Require Import QedkConcrete.supply QedkConcrete.hostaccountformat
QedkConcrete.wordrange QedkConcrete.hashwords QedkConcrete.precompileoutputs
QedkConcrete.blsmapbounds.
Require Import SetcodeConcrete.consensusnonce SetcodeConcrete.windowsupply
SetcodeConcrete.rechecking SetcodeConcrete.consensuschecks
SetcodeConcrete.noncebudget SetcodeConcrete.noncesequence
SetcodeConcrete.blockcode SetcodeConcrete.windownonce.
Set Default Goal Selector "!".
Import ListNotations.
Local Open Scope Z_scope.
Section Consensus.
Require Import RocqOfOCaml.RocqOfOCaml MonadVM.Execution.
Require Import QedkConcrete.supply QedkConcrete.hostaccountformat
QedkConcrete.wordrange QedkConcrete.hashwords QedkConcrete.precompileoutputs
QedkConcrete.blsmapbounds.
Require Import SetcodeConcrete.consensusnonce SetcodeConcrete.windowsupply
SetcodeConcrete.rechecking SetcodeConcrete.consensuschecks
SetcodeConcrete.noncebudget SetcodeConcrete.noncesequence
SetcodeConcrete.blockcode SetcodeConcrete.windownonce.
Set Default Goal Selector "!".
Import ListNotations.
Local Open Scope Z_scope.
Section Consensus.
F supplies the executor's chain ID, experimental revision and tracing
setting. The five named prices are gas costs for source access (cold or
warm), current-account access, code writing and reserve lookup.
Fixed execution configuration and the approved primitive-library facts.
These are not properties assumed about VM execution.
Select this experimental implementation and its five gas prices.
resource_revision : E.Params.(Execution.Make_Params_signature.revision) =
Support.Variants.Revision.Setcode (cold, warm, access, write, reserve);
Support.Variants.Revision.Setcode (cold, warm, access, write, reserve);
Reading the source consumes positive gas on either access path.
Approved output-size contracts, not assumptions about hash contents.
Approved BLS cofactor identities; their proofs remain separate.
The configured chain ID fits an EVM word.
resource_chain : wordRange (Support.UintN.to_z E.Params.(Execution.Make_Params_signature.chain_id))
}.
}.
snapshot is the only state constrained initially; blocks is the
whole ordered window, including the suffix not yet executed. senders
includes all recovered transaction senders, not all authority signers.
The nonce allowance is transaction count + authorization count + the
sum of transaction gas limits.
Native bounds on decoded headers, transaction data and withdrawals.
Initial account-map validity, nonnegative balances and bounded total.
Initial storage-value widths and code-length bounds.
Initial balance plus all external credits fits a 256-bit balance.
The two system accounts initially have their prescribed bytecode.
Protected nonces and the total increment allowance are below 2^63.
Transaction senders exclude the reserve precompile's address.
Every recovered transaction sender is covered by the nonce bound.
resource_senders : Forall (fun tx ⇒ ∀ a,
T.sender E.Params.(Execution.Make_Params_signature.chain_id) tx = Some a → In a senders)
(windowTransactions blocks)
}.
T.sender E.Params.(Execution.Make_Params_signature.chain_id) tx = Some a → In a senders)
(windowTransactions blocks)
}.
A returned state post remains well formed, retains the prescribed
system code, and has capacity for all remaining external credits and
nonce increments in rest. In particular, we do not require its nonces
to remain below 2^63; that half-range restriction is initial only.
Actual returned balances and their account map satisfy the invariant.
Actual returned storage values and code lengths remain representable.
All external credits still to execute fit without balance overflow.
Both system programs remain unchanged.
Each protected sender has capacity for every remaining nonce change.
remaining_nonces : ∀ a, In a senders →
0 ≤ nonceAt post a ∧ nonceAt post a + windowNonceBudget rest < 2^64-1
}.
0 ≤ nonceAt post a ∧ nonceAt post a + windowNonceBudget rest < 2^64-1
}.
past ++ rest is admitted using snapshot and reserve height height.
Execute past with the real generated executor. On success the returned
state satisfies RemainingResourceBounds. On error, the error is not
Nonce_overflow. No successful-prefix premise is assumed.
verify controls comparison with supplied block results. The theorem
applies to both values, but it does not claim that those comparisons or
other validation checks pass.
Definition consensusResourceSafety : Prop :=
∀ snapshot senders verify height past rest,
ResourceProtocolConditions →
ResourceWindowConditions senders snapshot (past ++ rest) →
consensusAccepts snapshot height (past ++ rest) →
match Result.List.fold_leftM (E.process_block verify) snapshot past with
| inl post ⇒ RemainingResourceBounds senders post rest
| inr error ⇒ ¬ nonceOverflowError error
end.
End Consensus.
∀ snapshot senders verify height past rest,
ResourceProtocolConditions →
ResourceWindowConditions senders snapshot (past ++ rest) →
consensusAccepts snapshot height (past ++ rest) →
match Result.List.fold_leftM (E.process_block verify) snapshot past with
| inl post ⇒ RemainingResourceBounds senders post rest
| inr error ⇒ ¬ nonceOverflowError error
end.
End Consensus.