Library SetcodeConcrete.consensusresources

Initial bounds are preserved across an admitted block window

This component excludes nonce exhaustion and preserves total-supply bounds, representation invariants and system code. The separate main theorem additionally excludes insufficient balance and all validation/block errors.
Admission uses one designated snapshot. After SETCODE, a fresh check against the post-state can reject an already-admitted sender because it has regular code; regular_sender_prevents_fresh_admission proves that fact. The main theorem retains the original admission instead.
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.
Context {F : E.FArgs}.
Context (cold warm access write reserve : N).

Fixed execution configuration and the approved primitive-library facts. These are not properties assumed about VM execution.
Record ResourceProtocolConditions : Prop := {
  
Select this experimental implementation and its five gas prices.
Reading the source consumes positive gas on either access path.
  resource_cold : (0 < cold)%N;
  resource_warm : (0 < warm)%N;
  
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.
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)
}.

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.
Record RemainingResourceBounds senders post rest : Prop := {
  
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
}.

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.