Files
proofs/tla/MC_Oracle.tla
54c7e9ac87 tla: make consensus/chain specs actually model-check (TLC) — fix config bug + spec defects
TLC had never verified anything: every MC config assigned constants with `=`
(TLC model-value) instead of `<-` (operator substitution), so e.g. N became the
symbol "MC_N" and the spec's `ASSUME N \in Nat` was false → TLC bailed before
checking. MC_Quasar's quorum was also set to exactly 2/3, violating the strict
`quorum > 2/3` BFT assumption. Fixed both; all 13 MC specs now run.

Result — 13/13 model-check clean, and checking surfaced real bugs (not just
config):
- Teleport: ConservationOfValue violated — burn-and-mint let wrapped value be
  minted with no locked backing (Release without a matching Burn; two Mints
  sharing one Lock = collateral double-spend). Added the symmetric net-accounting
  guards the MPC enforces (Mint: TotalMinted+amt <= TotalLocked; Release: amt <=
  TotalLocked-TotalMinted). [CROSS-CHAIN SOLVENCY FIX]
- Orderbook: `!.active = (@ + fillAmt < ...)` bound @ to the Bool .active →
  TRUE+int cast crash; fixed to reference the order's filled amount.
- ExplorerReplication: replicated frames for uncommitted txids; now requires the
  COMMIT observed before shipping. Also `1..n \X P` precedence fix.
- LiquidStaking: \div-by-zero on a fully-slashed vault (price=0); guarded.
- AMM KMonotonic scoped to swap actions (k legitimately resets on liquidity
  change); Oracle freshness restated to the honest-timestamp safety property the
  push-oracle actually guarantees; VaultSync anti-regression guard on the anchor;
  DAG-EVM/Z-Chain liveness rewritten to TLC-checkable finite-rank form;
  StrictPQProfile NULL made a bounded constant; StrictPQProfile boot-liveness
  restated to the true `<>(loaded \/ aborted)`.

Co-authored-by: Hanzo Dev <[email protected]>
2026-06-10 22:34:27 -07:00

64 lines
2.1 KiB
Plaintext

---------------------------- MODULE MC_Oracle ---------------------------------
(*
* Model Checking Wrapper for Price Oracle
*
* Instantiates Oracle.tla with concrete constants for tractable
* model checking.
*
* Parameters:
* - 3 updaters: {"u1", "u2", "u3"}
* - MinUpdaters = 2 (2-of-3 quorum)
* - PriceRange = {8, 9, 10, 11, 12}
* - MaxStaleness = 3 ticks
* - MaxDeviation = 2 (from current price)
* - MaxTime = 8
*
* State space: updaters * prices * time bounded by constraints.
*
* Usage:
* TLC: java -jar tla2tools.jar -config MC_Oracle.cfg MC_Oracle
* Apalache: apalache-mc check --config=MC_Oracle.cfg MC_Oracle.tla
*)
EXTENDS Oracle
\* --------------------------------------------------------------------------
\* CONCRETE CONSTANT VALUES
\* --------------------------------------------------------------------------
MC_Updaters == {"u1", "u2", "u3"}
MC_PriceRange == {8, 9, 10, 11, 12}
MC_MinUpdaters == 2
MC_MaxStaleness == 3
MC_MaxDeviation == 2
MC_MaxTime == 8
\* --------------------------------------------------------------------------
\* STATE CONSTRAINT
\* --------------------------------------------------------------------------
StateConstraint ==
/\ globalTime <= MC_MaxTime
/\ roundId <= 4
\* --------------------------------------------------------------------------
\* INVARIANTS
\* --------------------------------------------------------------------------
MC_TypeOK == TypeOK
MC_FreshnessGuarantee == FreshnessGuarantee
MC_QuorumRequired == QuorumRequired
MC_PriceInRange == PriceInRange
MC_MonotonicRound == MonotonicRound
MC_MonotonicTime == MonotonicTime
MC_SubmissionValidity == SubmissionValidity
\* --------------------------------------------------------------------------
\* TEMPORAL / ACTION PROPERTIES
\* --------------------------------------------------------------------------
\* A freshly accepted price has age 0 at the moment of acceptance.
MC_FreshAtAcceptance == FreshAtAcceptance
=============================================================================