Library QedkConcrete.consensusrequirements

Input bounds and reachable-state exclusions

These definitions were extracted from the block and transaction proofs. They name native execution operations; they do not assume those operations preserve balances or that any transaction validates.
From Stdlib Require Import List String ZArith Bool.
Require Import RocqOfOCaml.RocqOfOCaml MonadVM.Execution
  QedkConcrete.transactionstage QedkConcrete.transactionchecked
  QedkConcrete.publictransaction QedkConcrete.wordrange.
Require Import QedkConcrete.nativeinputs.
Require Export QedkConcrete.stakingsystem.
Set Default Goal Selector "!".
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.

The staking precompile's address, using the same construction as the OCaml staking module. It is protected from CREATE/CREATE2 separately from transaction senders; this does not give it a sender's reserve protection.
world is the execution state before block. Return the transaction processing state after activating the reserve precompile, initializing this block and running its EIP-4788/EIP-2935 system messages, but before any transaction or withdrawal. This is a BlockState, not a block.
accountAt snapshot a reads account a from the designated execution snapshot S_h. Return its account record (nonce, balance, storage and code); no transactions after block h are applied.
Definition accountAt := readAccount.
snapshot is S_h and addr is the address to test. Return true for ordinary contract code there, false for empty code or an EIP-7702 delegation marker. True means ineligible as a transaction sender, not "is delegated".
reserveAt snapshot b a is R_h(a,b) in the draft: account a's reserve for block b, using only the configuration recorded in snapshot S_h. The result is a U256 amount in wei, not an updated configuration. The lookup compares the pending activation height with b to choose the settled or pending reserve, or the default reserve for an unconfigured account. It is not G_a, the remaining gas budget, and does not change storage.
Conditions on one block's inputs, not an admission or execution check.
  • signers: the list which must contain each recovered transaction sender.
  • until: upper window height, requiring b <= until < b+3 for this block.
  • block: the candidate block, supplying its header, transactions and withdrawals.
Result: a proposition requiring the representation/height bounds below, sender membership, and no recovered authorization signer equal to 0x1001. Other authorization signers need not belong to signers. No assertion here requires a transaction's nonce or balance check to pass.
State the CREATE/CREATE2 exclusion for one transaction list.
  • signers: transaction-sender addresses covered by this exclusion; the staking address 0x1000 is additionally covered.
  • block: the BlockState immediately before txs, not a block header.
  • txs: the ordered transactions to execute from that state.
Result: a proposition about each successfully executed prefix and the next transaction, if that transaction validates. A listed address or 0x1000 which then has no ordinary contract code must not appear in the VM result's created-accounts list. Delegation is allowed. This is a cryptographic premise about this run, not about arbitrary starting states.
Definition prefixAvoidsSignerCreation signers block txs :=
  ∀ first tx last before,
    txs = first ++ tx :: last →
    Result.List.fold_leftM (@E.dispatch_transaction F) block first = inl before →
    ∀ validation a, (List.In a signers ∨ a = stakingAddress) →
    @E.validate_transaction F before tx = inl validation →
    @A.is_smart_contract (readAccount (B.t.world_state before) a) = false →
    let '(msg, entry) := vmInput before tx validation in
    ¬ List.In a (S.t.accounts_created_in_current_transaction (snd (callFromEoa tx msg entry))).

signers lists the transaction-sender addresses; verify is the block-result verification flag; world is the initial execution state; blocks is the ordered list to execute.
Result: a proposition requiring prefixAvoidsSignerCreation in every block reached after a successfully executed block prefix, provided that block's header validation passes. Its starting transaction state includes the system messages, via blockTransactionEntry. It does not assume that the block prefix succeeds; it restricts whichever prefixes do succeed.
State the concrete staking-syscall validity requirement for one transaction list. Each Monad system transaction reached after a dispatched prefix must carry valid calldata for one of the three staking syscalls (syscall_snapshot, syscall_on_epoch_change, syscall_reward) and satisfy its staking-storage preconditions (validStakingSyscall). User EOA transactions are unrestricted.
Definition prefixValidStakingSyscalls (block : B.t) (txs : list T.t) : Prop :=
  ∀ first tx last before,
    txs = first ++ tx :: last →
    Result.List.fold_leftM (@E.dispatch_transaction F) block first = inl before →
    @E.is_system_transaction F tx = true →
    validStakingSyscall (B.t.world_state before) tx.

Require prefixValidStakingSyscalls in every block reached after a successfully executed block prefix whose header validates.
blocks is the supplied block list. Return the proposition that its header heights are nondecreasing: every earlier height is <= each later height. This permits equal heights and gaps; it does not establish header validity, consensus acceptance or successful execution.
Definition orderedBlockNumbers (blocks : list Chain.Ethereum.Block.t) :=
  ∀ before block after, blocks = before ++ block :: after →
    Forall (fun earlier ⇒ (height earlier ≤ height block)%N) before.

End Execution.