v2 (v3.1.0-rfc) · public rfc · zero-federation · not mainnet-active
Changelog — v1 (v3.0.0-rfc) → v2 (v3.1.0-rfc) & Historical v0 → v1
Complete zero-federation disposition of Consolidated Hostile Review R8 (v1 → v2, Amendments A1–A11), plus full word-level redline diffs comparing v2 (v3.1.0-rfc) against archived v1 (v3.0.0-rfc) (+1820 / -1592 lines across 7 tracked files).
Date: 2026-11-28
Current Version (v2): v3.1.0-rfc (Zero-Federation Phased Architecture, hardened by Consolidated Hostile Review R8; redlines directly against archived v1)
Archived Previous Version (v1): v3.0.0-rfc (frozen byte-for-byte from commit 6ab3999, SHA-256 verified in versions/v1/SHA256SUMS.txt)
Archived Initial Baseline (v0): v2.5.0-rfc (frozen byte-for-byte from commit 7b47b8c, SHA-256 verified in versions/v0/SHA256SUMS.txt)
v1 (v3.0.0-rfc) → v2 (v3.1.0-rfc): Consolidated Hostile Review (R8) Remediation (Amendments A1–A11)
Trigger: Independent multi-agent Consolidated Hostile Review R8 of archived v1 (v3.0.0-rfc) (6 Critical, 10 High, 9 Medium, 2 Low; Stage 0 & Stage 1B CONDITIONAL PASS, Stage 1A FAIL as written). Every confirmed R8 defect is remediated in v2 (v3.1.0-rfc) below with zero federated multisigs and zero Bitcoin soft forks; line-level local-repo pushbacks are recorded transparently under Verified Pushbacks.
R8 Critical Findings (R8-C01 – R8-C06)
| ID | Finding Summary (v1 / v3.0.0-rfc) | Disposition in v2 (v3.1.0-rfc) | Amendment / Ref |
|---|---|---|---|
| R8-C01 | Circular SHA256(outpoint_d) inside U_d's Lamport TakeTx Tapscript created an impossible SHA-256d fixed-point cycle | Closed (A1). Replaced SHA256(outpoint_d) with acyclic pre-funding vault_id = SHA256("zbtc:vault-id:v1" || funding_txid || funding_vout || vault_vout || amount_sats || opBitmask) bound to confirmed U_dep_wallet. TakeTx verified ~3,142–3,166 vB <= 3,200 vB TRUC v3 parent, peak stack 258 < 1,000, zero unconfirmed TRUC child chaining. | Part 1 §2.2, §3.3, Checker |
| R8-C02 | Conservation law V = C + L + E + R + B omitted AssignedObligations (A), breaking vk_STF during the T_take gap after FIFO assignment | Closed (A2). Added explicit AssignedObligations (A) SMT namespace and amended conservation to V_unassigned + V_assigned = C + L + E + R + A + B with exact atomic transition table across fifo_assign, take_confirmed, 0x07, disprove_dual_slash, lamport_equivocation_slash (including cross-operator recovery), retire, and reorg. Separated fifo_assign and take_confirmed across T_take in verify_spec_bounds.py. | Part 3 §2.1, Checker |
| R8-C03 | Racing deleted-key deposits crossing Cap_TVL could both confirm on L1, burning the rejected loser's BTC permanently | Closed (A3). Enforced Cap_TVL_total mutual exclusion directly at Bitcoin L1 consensus via denomination-matched AdmissionTicketUTXOs (1 × Ticket_050 + 2 × Ticket_025 consumed as DepositTx.vin[1..3] and recycled at TakeTx.vout[1]; loser's DepositTx is consensus-invalid so BTC never leaves U_dep_wallet), plus optional two-stage PreDepositUTXO alternative. | Part 1 §2.2, Checker |
| R8-C04 | Scalar round cap N_live <= 0.50 * RemainingTotalRounds violates Hall's Marriage Theorem under heterogeneous opBitmask subsets & retirements | Closed (A4). Mandated the exact $2^M$ Hall's Marriage Invariant across every deposit_admit, operator_retire, round_consume, and operator_slash (<= 31 checks at M = 5), tightest-slack FIFO prioritization, and retirement unlock gating. | Part 1 §6.2, Checker |
| R8-C05 | Witness completeness vs deterministic skip ambiguity, untagged tracked-UTXO spends, and incomplete 0x02 DA schema | Closed (A5) + Pushback Noted. (Note: v3.0.0-rfc spec/02:L115 already mandated BIP-141 wtxid verification.) Closed all 3 real gaps: (a) extract witness commitment strictly from the LAST coinbase output starting with 0x6a24aa21a9ed (len >= 38 B, coinbase wtxid = 0x00^32) and fail closed (REFUSED_DATA_UNAVAILABLE) on missing/unauthenticated witness vs skip ONLY after wtxid authentication; (b) scan every vin of every stripped tx for untagged spends of tracked UTXOs; (c) expand 0x02 DA schema to serialize Accounts, RollupLocks, cooperative PendingExits, and TransferCredit. | Part 2 §3.1–3.2 |
| R8-C06 | Contradictory "100% live forever" prose despite 0-of-M permanent operator unavailability permanently locking native BTC | Closed (A6). Excised "100% live forever" across all files. Stated explicitly: Stage 1A vaults have no CLTV expiration, but native BTC recovery strictly requires 1-of-M active eligible operators (0-of-M permanent disappearance locks native BTC; EXIT_CANCEL restores zBTC only). | SPEC §4, §9, Part 1 §2.3, Part 5 §4 |
R8 High Findings (R8-H01 – R8-H08, R8-N01, R8-N05)
| ID | Finding Summary (v1 / v3.0.0-rfc) | Disposition in v2 (v3.1.0-rfc) | Amendment / Ref |
|---|---|---|---|
| R8-H01 & R8-N05 | Concurrent (k >= 6..20) or post-suspension ExitSlotUTXO griefing overflowed 0.05 BTC buffer into 0.55 BTC verifier bounties, turning verifier EV negative pre-theft | Closed (A7). Hard-partitioned B_grief (0.05 BTC) from B_custody (0.55 BTC) with pro-rata burst capping (0 sats ever debited from B_custody), excluded suspended operators from all new ExitSlotUTXO Taproot trees (2M_active + 1 leaves), AND moved all verifier bounties to Bitcoin L1 Stake_r (0% coupling to B_zbtc!). Verified under a k = 20 single-block grief burst in verify_spec_bounds.py. | Part 1 §4–5, Part 3 §2.4 |
| R8-H02 | Non-winning honest challengers paid in crisis-discounted zBTC failed EV once 10 × 153 vB P2A CPFP (16.53 kvB) + 0.00285 BTC lockup + 6.7%–30% discount were counted; M-dispute liquidity unbudgeted | Closed (A7). Restructured DisproveTx_{r,i}/TimeoutSlashTx_{r,i} on Stake_r (2.00 BTC) so EVERY active challenger claims 0.15 BTC in native Bitcoin L1 BTC via ChalPayoutEscrow_{r,j} + ChalProofConnector_{r,j} (0.95 BTC minimum immediate burn, zero 2^7 explosion!). Net honest verifier EV (incl. 16.53 kvB CPFP + 0.00285 BTC lockup, 0% zBTC discount) = +0.0645 BTC @ 500 sat/vB and +0.0232 BTC @ 750 sat/vB (890 sat/vB break-even); attacker P&L = -2.00 to -1.10 BTC L1 alone (-2.55 to -1.65 BTC incl. B_custody). Multi-dispute verifier liquidity (1.45/2.41 BTC per honest verifier) explicitly budgeted. | Part 1 §3.1, §4, §6.1, Checker |
| R8-H03 | 0.50 × K × Subsidy > TVL unproven under Budish's winning-fork subsidy offset; missing canonical chainwork check; B_zbtc omitted from cap sizing | Closed (A8) + Pushback Noted. (Note: v3.0.0-rfc used K = 14, not K = 10.) Relabeled inequality honestly as a conditional unpublished-fork heuristic (printing Budish net flow-cost sensitivity across κ = 5..50% in checker), raised hard floor to K >= 18 covering Cap_TVL_total = Cap_user + M × B_zbtc, and added interactive heaviest-chainwork competing-header comparison inside vk_STF. | Part 2 §4, Checker |
| R8-H04 | TRUC v3 compliance does not guarantee dispute completion under sibling-eviction pinning, T_step = 48 tightness, and unconfirmed child limits | Closed (A9). Pinned Bitcoin Core >= 29.0 (v31.0 preferred), mandated direct-to-miner submission rails, explicitly prohibited unconfirmed TRUC child chaining (TakeTx/ProverStep > 1,000 vB), included 10 × 153 vB P2A CPFP in prover (76.53 kvB, 522 sat/vB break-even) and verifier (16.53 kvB) budgets, and widened T_step = 72 blks (12h) → max_dispute = 1,584 < T_take = 1,728 < T_cool = 1,872 < Retire = 2,016 (13.0d cycle, 94–104d bank run). | Part 1 §3.2, §6.1, Checker |
| R8-H05 | RV32IM $8^9 = 134.2\text{M}$ step budget contradicted bare 1 MB SHA-256 block scanning prose | Closed (A9). Explicitly partitioned computation: off-chain ZK prover performs stripped-block scanning & SMT updates; BitVMX-CPU (RV32IM) executes strictly the constant-size wrapped SNARK verifier vk_STF. Added Gate G2 requiring compiled ELF init_steps + exec_steps <= 0.5 × 8^9 (else l = 10 or mature reusable BitVM3-GC). | Part 1 §3.2, Part 2 §3.2, Part 5 §3, §5 |
| R8-H06 | 104 B on-chain certBlob did not specify public DA archival for presigned TakeTxs, scripts, and Lamport keys | Closed (A9). Specified canonical zbtc-vault-bundle-v1 artifact replicated & cryptographically verified across >= 3 independent public archival mirrors before depositor deletes x_{dep,d}, plus Gate G5 disaster-recovery drill. | Part 1 §2.2, Part 5 §5 |
| R8-H07 | Stage 0 PTLC (30h: P(T_72 > 30h | 2.3×) = 22.34%) & outbound LN HTLC (6h: P(T_36 > 6h | 1.0×) = 47.78%) failed Erlang tails | Closed (A10). Raised T_znn to >= 48h (172,800s, P(T_72 > 48h | 2.3×) < 10^{-6}) and outbound LN Δ_safety_sec to >= 24h (86,400s, P(T_36 > 24h | 2.3×) < 0.0002), mandated automated block-72 RBF refund watchtowers, disclosed conditional atomicity, and added exact stdlib Erlang assertions in verify_spec_bounds.py. | Part 3 §1, Checker |
| R8-H08 | Immutable vk_STF bug risk on unrecoverable legacy vaults | Closed (A6). Added Gate G4 formal verification + Bitcoin Core differential fuzzing, graduated mainnet TVL ramps (2 → 5 → 10/15 BTC), and a non-custodial voluntary unwind circuit breaker (halt new σ_cert, drain organically via 0x01, launch clean zBTC_v2). | Part 1 §6.3, Part 5 §5 |
| R8-N01 | Rational operators could pause retail par fronting during a bank run to jump the queue via discounted self-fronting | Closed (A11). Enforced oldest-PendingExit timestamp priority for reimbursement credit eligibility whenever open retail exits > 6 blks exist + optional Dutch-auction f_op discovery (spec/03 §2.4), while keeping bank-run discount risk explicitly disclosed in SPEC §4. | Part 3 §2.4, SPEC §4 |
R8 Medium & Low Findings (R8-M01 – R8-M09, R8-L01 – R8-L02)
| ID | Finding Summary (v1 / v3.0.0-rfc) | Disposition in v2 (v3.1.0-rfc) | Spec Reference |
|---|---|---|---|
| R8-M01 | Unbounded zero-cost 0x02 L1 DA spam via refundable QSR spraying 1-sat transfers to fresh addresses (~3.80 BTC/d) | Closed (A11). Reframed Zenon transfers honestly as L1-subsidized soft preconfirmations; added refundable 500-sat zBTC new-account SMT leaf deposit + <= 1,000 new leaves per 6-block epoch cap. | Part 3 §2.2 |
| R8-M02 | Competing permissionless 0x02 batchers burn L1 fees on stale-root collisions | Closed (A11). Added deterministic slotted batcher priority (primary = H(header[h-1].hash) mod K_batchers for first 2 blocks after +6, open permissionless fallback thereafter). | Part 2 §3.3, Part 3 §2.3 |
| R8-M03 | k_r = H(exitId || r) mod M had 20% dead-operator collision rate & mismatched spec/03 <6*j> | Closed (A11). Standardized collision-free cyclic permutation k_r = (H(exitId) + r) mod M_active across BOTH spec/01 §5 and spec/03 §2.4 (0% repeat across r = 0..M_active-1). | Part 1 §5, Part 3 §2.4 |
| R8-M04 | < 0.25 BTC operator ReimbursementCredit residuals stranded permanently | Closed (A11). Added signed TransferCredit(from_op, to_op, amt) (via 0x02/0x03) + retirement R -> C conversion (RetireStakeTx_r). | Part 3 §2.1, §2.4, Checker |
| R8-M05 | MIN_EXIT_SATS dust floor absent from normative prose | Closed (A11). Normatively mandated grossSats >= max(dust(destScriptPubKey), MIN_EXIT_SATS = 100,000) sats (0.001 BTC) in spec/01, spec/02, and spec/03. | Part 2 §3.1, Part 3 §2.1, §2.4 |
| R8-M06 | Stage 0 SPV 64-byte leaf filter verification | Verified Pushback + Tightened. v3.0.0-rfc spec/02:L67, L72 already rejected len == 64 and enforced totalCoinbaseBytes >= 65. Tightened len(strippedTx) != 64 to 65 <= len(strippedTx) <= 6,144 with explicit syntax validation. | Part 2 §2.1, §2.3 |
| R8-M07 | Undefined >= K deep Bitcoin reorg behavior | Closed (A8). Specified fail-closed DEEP_REORG_HALT circuit breaker + >= 144-block rollback snapshots and canonical chain replay. | Part 2 §4 |
| R8-M08 | Throughput reconciliation (7.37 vs 8.8), unstated Bitcoin 0x02 DA ceiling, and go-zenon mainnet gap (#299, #312, PR #138) | Closed (A11) + Pushback Noted. (Note: 4.4/8.8 2-blk & 6.5/12.9 1-blk were exact at observed 11.4s/Momentum vs 7.37 at idealized 10s.) Published two-column throughput table pairing Zenon transport against Bitcoin L1's physical 0x02 DA ceiling (166.7 blended 10 vB leaves/s @ 100%; 416.7 existing 16 B / 138.9 new 48 B); added #299, #312, and mainnet PTLC PR #138 activation to Gate G6. | Part 3 §2.2, Part 5 §2.1, §5 |
| R8-M09 | Missing operational hard-BTC reserves & Bitcoin Core >= 29.0 floor for 0-sat P2A | Closed (A9). Published complete hard-BTC breakdown (12.80/18.80 BTC locked → 14.75/21.25 BTC single-dispute operational baseline → ~17–26+ BTC multi-dispute headroom), explicitly clarified Cap_TVL_total = Cap_user + M × B_zbtc, and pinned Bitcoin Core >= 29.0 (v31.0 preferred). | Part 1 §3.2, §6.1, Part 5 §1 |
| R8-L01 | "100% Bitcoin PoW finality" contradicted probabilistic PoW | Closed (A6). Replaced with "probabilistic PoW finality at depth K >= 18 under <50% honest hashrate" across all files. | SPEC §3.2, §4, §9, Part 4 §2 |
| R8-L02 | Active v1 lacked generated SHA256SUMS.txt manifest | Closed (A6). scripts/sync_public_artifacts.mjs now generates deterministic public/raw/SHA256SUMS.txt covering all v2 normative files, CHANGELOG.md, and scripts/verify_spec_bounds.py on every build (and verifies frozen versions/v1/SHA256SUMS.txt and versions/v0/SHA256SUMS.txt). | SPEC, sync_public_artifacts.mjs |
Summary of Verified Pushbacks on R8 (Gate G7 Local Repo Check)
Direct line-level inspection of the local repository resolved every CONFIRMED WITH QUALIFICATIONS item from R8:
R8-M06:spec/02:L67, L72already rejectedlen == 64and requiredtotalCoinbaseBytes >= 65(tightened to65 <= len(strippedTx) <= 6,144).R8-M08:4.4/8.8(2-blk42kPlasma) and6.5/12.9(1-blk28,480Plasma) were exact at observed11.4s/Momentum (not an arithmetic error against10s);v3.1.0-rfcnow prints both side by side with Bitcoin's0x02physical DA ceiling.R8-C05:spec/02:L115already mandated BIP-141wtxidverification against coinbase;v3.1.0-rfccloses the 3 real gaps (last6a24aa21a9edoutput + fail-closed vs skip, full stripped-vinscan, complete0x02DA schema).R8-H03:v3.0.0-rfcusedK = 14(notK = 10);v3.1.0-rfcraises the floor toK >= 18, adds Budish sensitivity & interactive heaviest-chainwork comparison.- BitVM3 vs BitVMX-CPU (Q12): While BitVM3 cuts on-chain disprove size to
~93 vB, non-reusable BitVM3 currently carries a1-of-Ngarbler trust assumption and~2.2–11.2+ TBone-time garbled-circuit DA across2,240rounds; Gate G2 evaluates both before final freeze.
Historical Pivot: v0 (v2.5.0-rfc) → v1 (v3.0.0-rfc) Architecture Shift & R7 Disposition
v1 (v3.0.0-rfc) completely replaced v0's unviable BitVM2 + rotating-PoS-committee hybrid — while explicitly REJECTING custodial k-of-n federated multisigs — with the Zero-Federation, Zero-Soft-Fork, Zero-ZNN-Custody-Coupling Phased Architecture triggered by Consolidated Hostile Review R7 (4 Critical, 8 High, 15 Medium, 4 Low + N-1..N-6, B1..B5):
R7 Critical Findings (C-1 – C-4)
| ID | Finding Summary (v0) | Disposition in v1 | Spec Reference |
|---|---|---|---|
| C-1 | Security priced in ZNN at 10,500 ZNN/BTC (40–70× above market 400k–727k) | Closed by removal. 0% ZNN in BTC safety; 10,500 ZNN/BTC deleted. All Stage 1A collateral & operational reserves (14.75–21.25 BTC baseline) are hard BTC. | SPEC §1, §4, §7, Part 1 §6 |
| C-2 | Honest BLS certs over dishonest canonical Zenon state (unchallenged batch / censorship / upgrade) | Closed by architectural inversion. BLS Pillar committees and optimistic Zenon batches deleted; Stage 1A verifies an immutable Bitcoin-anchored ZK validity rollup (vk_STF, 0-of-N Zenon trust) surviving 49%–100% Zenon compromise. | SPEC §3, §4, Part 2 §3, Part 4 §1–2 |
| C-3 | BitVM2 assert (220 kvB) & disprove (≤ 95 kvB) sizes 4.4–10× below published measurements | Closed via n = 8 BitVMX switch. Proposition 2 shows minimal M=3–5 Groth16 BitVM2 requires ~40–91 BTC bonds (13.30–18.175 BTC/lane). Replaced with n = 8 BitVMX-CPU (RV32IM wrapped-SNARK verifier) bisection (7.44 kvB/prover tx, 100% TRUC v3 on Core >= 29.0). | Part 1 §1.2, §3.2, §6, Checker |
| C-4 | Never-deleted N-of-N Q_graph can sweep everything or brick everything; contradicts C-07 & Wind-Down #8 | Closed without federations. Immutable vk_STF eliminates 30-day committee rotations so vault graphs never expire; ephemeral Q_setup_d (incl. depositor key) and Q_lane keys are permanently deleted after setup; custodial federations explicitly forbidden. | Part 1 §1.1, §2.2, §3.1 |
R7 High Findings (H-1 – H-8)
| ID | Finding Summary (v0) | Disposition in v1 | Spec Reference |
|---|---|---|---|
| H-1 | Committee seats rented via free instant delegation at one snapshot | Closed by removal. Zenon Pillar finality committees completely eliminated from BTC custody (spec/04). | Part 4 §1–2 |
| H-2 | ≥ 10 committee seats withholding certs profitably burn honest operators | Closed by removal. No Pillar finality certificates required for operator reimbursement. | Part 1 §3, Part 4 §2 |
| H-3 | Upgrade & Plasma authority = custody authority; single spork keys unlisted in §4 | Closed. Hard-pinned vk_STF gives Zenon SporkAddress/CommunitySporkAddress 0 BTC custody blast radius in Stage 1A; Stage 0 pins all 5 SetPlasmaVariables fields; Privileged Powers Table in SPEC §4.1. | SPEC §4.1, Part 5 §2–3 |
| H-4 | Altruistic watcher fronts 1.45 BTC/lane (14.6 BTC total) and loses against self-slasher/MEV | Closed (hardened further in R8-H02). Pre-committed N = 7 BitVMX verifiers lock F_chal = 0.40 BTC in ChalEscrow_{r,i} (returned on win/abort) and EVERY active honest challenger collects 0.15 BTC in native Bitcoin L1 BTC directly from Stake_r (+0.0645 BTC net EV @ 500 sat/vB, +0.0232 BTC @ 750 sat/vB, 0% zBTC discount). | Part 1 §4 |
| H-5 | Exit liveness missing from §4; exits throttled to 1.82 vaults/day | Closed transparently. 1-of-M (M = 3–5) operator liveness is Assumption #4 (SPEC §4, explicitly noting 0-of-M locks native BTC per R8-C06); exact throughput (0.077–0.128 BTC/d) and 100% bank-run duration (~94–104d at T_cooldown = 13.0d; ~62–68d w/ {0.50, 0.50}) published next to Cap_TVL. | SPEC §4, Part 1 §6 |
| H-6 | April 2024 fees & June 2021 slow blocks broke envelope; real slow-block tolerance was 1.287× | Closed (hardened further in R8-H04/R8-H07). Zero absolute CLTV cliffs (relative CSVs only); Core >= 29.0 TRUC v3 + 0-sat P2A anchors + direct-to-miner rails; PTLC >= 48h / LN >= 24h Erlang-verified against 2.3× slow blocks; sustained 500 sat/vB 10-day bisection envelope stated honestly. | Part 1 §3.2, Part 3 §1 |
| H-7 | Unpaid epoch handoff anchoring, missing mobile BTC header source & minimumPostAnchorWork, overclaimed "end at Bitcoin PoW" | Closed. Stage 1A canonical state, DA (0x02), and forced exits (0x01/0x03) live directly on Bitcoin L1 PoW (probabilistic finality at K >= 18); SPEC §9 aligns public wording. | SPEC §9, Part 2 §3, Part 4 §2–3 |
| H-8 | 21M pre-mint inside SettlementContract makes full supply the blast radius | Closed by removal. Stage 1A zBTC lives in the immutable Bitcoin-canonical Rollup SMT, never pre-minted inside a Zenon embedded contract (TokenContract.IssueMinted retired). | SPEC §6, Part 3 §2 |
R7 Medium, Low & Convergence Findings (M-1..M-15, L-1..L-4, N-1..N-6, B1..B5)
| ID | Finding Summary (v0) | Disposition in v2 (v3.1.0-rfc) |
|---|---|---|
| M-1, M-2, M-8, B4 | Dual-clock fronting slots, cheap slot-lapse collusion, timeout-only double-pay races | Closed. Atomic active-operator (2M_active+1)-leaf ExitSlotUTXO uses strictly Bitcoin CSV clocks, cyclic (H(exitId)+r) mod M_active priority, L1 UTXO exclusion, and hard-partitioned B_grief slashing (spec/01 §5). |
| M-3, B1, L-3 | U0 pinned to superseded rc1; #239 FIFO panic stall; stale-ack fix #227 | Closed (Gate G6). Gated on tagged mainnet go-zenon release containing 0aa299e, PTLC PR #138, DynamicPlasmaSpork, and closure of #239, #299, #312 (spec/05 §2, §5). |
| M-4 | PTLC 12-block refund race & LN HTLC deltas | Closed (hardened in R8-H07). <72> OP_CSV, automated block-72 RBF refund watchtower, T_znn >= 48h, outbound LN Δ_safety_sec >= 24h, Hold Invoice 5-min TTL (spec/03 §1). |
| M-5, M-6 | Free BTC_TX_STREAM_CHUNK spam & unproven Leaf 3B SHA-256 without OP_CAT | Closed by removal. Streaming 0x04 and Leaf 3B deleted; acyclic vault_id 256-bit Lamport TakeTx uses only OP_HASH160 (5,922 B script, 258 peak stack, ~3.17 kvB TRUC v3). |
| M-7, M-12, N-2 | Post-RolloverTx admission stranding & CommitteeIdentityKey standing twin of Q_graph | Closed (hardened in R8-C03). RolloverTx & CommitteeIdentityKey deleted; AdmissionTicketUTXO enforces Cap_TVL at L1 consensus before DepositTx confirms; x_{i,d} deleted (spec/01 §2.2). |
| M-9, M-10, B2 | 4,386 tx/s overstated, 11.4s Momentum, unpinned SetPlasmaVariables targets/denom | Closed (hardened in R8-M08). All 5 SetPlasmaVariables fields pinned; two-column throughput table pairs Zenon 11.4s / 8 MiB ceiling against Bitcoin L1's 0x02 physical DA ceiling (spec/03 §2.2, spec/05 §2.2). |
| M-11, L-1, L-2, N-1, N-3, N-4 | Unslashable certs, <21 BLS Pillars, G-21 stall, sub-quorum freeze, chained sessions, ChallengeDepositZnn | Closed by removal. No Pillar finality committee, no 30-day BitVM rotation, and no optimistic Zenon challenge sessions exist in BTC custody (spec/04 §2–3). |
| M-13, M-14, M-15, L-4, N-5, N-6, B3, B5 | Precedence, TBD params, independent audit, bigidea claims, solvency conservation, frozen v0 | Closed & Enforced. Part 1 is #1 authority (SPEC §2.1); SPEC §9 aligns all public claims; verify_spec_bounds.py asserts exact V_unassigned + V_assigned == C + L + E + R + A + B across real reorgs and slashes; Gates G1–G7 + M-15 block mainnet; versions/v0/ stays byte-identical (SHA256SUMS.txt verified in CI). |
Per-File Redline Diffs (v1 → v2)
Compare archived previous version v1 (v3.0.0-rfc, SHA-256 verified from commit 6ab3999) against current v2 (v3.1.0-rfc). You can also toggle [show redline vs v1] directly in the header of any individual v2 page (or visit any v1 page to view the historical v0 → v1 redline).
00 Overview (SPEC.md) · SPEC.md+118 / -111 ·open redline on page
| @@ -1,19 +1,23 @@ | |||
| 1 | 1 | # zBTC: Bitcoin–Zenon Interoperability Protocol Specification | |
| 2 | 2 | ||
| 3 | - | **Version:** `v1` (`v3.0.0-rfc` — **Zero-Federation Phased Architecture**: Stage 0 Verify Bitcoin SPV + Non-Custodial PTLC/LN → Stage 1A Right-Sized `BitVMX` `n=8` Sovereign ZK Validity Rollup | Stage 1B `clArk` Alternative Gate → Stage 2 Zero-TTP Scale & Upgrade; supersedes archived `v0` / `v2.5.0-rfc`, see [CHANGELOG.md](./CHANGELOG.md)) | |
| 4 | - | **Status:** Public Request for Comment (`v1` / `v3.0.0-rfc`) — NOT mainnet-active; Stage 0 gated on upstream `go-zenon` release (`0aa299e` + `#239` closure + full `SetPlasmaVariables` pinning); Stage 1A gated on `BitVMX-CPU` Signet verification, independent third-party cryptography/Bitcoin-Script audit (**M-15**), and hard-BTC operator/verifier capital commitment. | |
| 5 | - | **Target Networks:** Bitcoin Mainnet TODAY (`bip-0141`/`bip-0340`/`bip-0341`/`bip-0342`/`bip-0431` Taproot + TRUC v3 + `P2A` — **zero Bitcoin soft forks**, **zero federated signers**) ↔ Zenon Network (`go-zenon` first tagged release containing `0aa299e`, `#239` closed, `DynamicPlasmaSpork` & `PtlcSpork` enforced; local reference clone `master` `e8986a6` / `origin/dev` `770e893`) | |
| 6 | - | **Consistency & Bounds Checker:** All modeled `n = 8` `BitVMX` W-OTS/TRUC v3 weights, 256-bit Lamport `TakeTx` stack/size bounds, timelock ordering (`[0, 144] → 1,104 < 1,152 < 1,296 < 1,440`), colluding-verifier positive-EV matrices (`k_collude = 0..6`), `{0.50, 0.25, 0.25}` BTC bank-run exit bounds, halving-indexed TVL-scaled `K`, 1-/2-block coinbase midstate SHA-256 padding, honest `8 MiB` `go-zenon` Plasma bounds, PTLC `2.3×` slow-block margins, `clArk` exit weights, and a **non-no-op 2,000-step randomized state-machine simulation (including real Bitcoin reorgs, `ExitSlotUTXO` grief slashes, and Lamport equivocation slashes)** are asserted by [`scripts/verify_spec_bounds.py`](./scripts/verify_spec_bounds.py) (`python3 -I scripts/verify_spec_bounds.py`). *This script checks internal mathematical consistency against explicitly labeled `SOURCED_`, `POLICY_`, and `PRE_MAINNET_TARGET_` inputs; it is not an empirical Signet benchmark or audit.* | |
| 3 | + | **Version:** `v2` (`v3.1.0-rfc` — **Zero-Federation Phased Architecture, R8 Hardened**: Stage 0 Verify Bitcoin SPV + Non-Custodial PTLC/LN → Stage 1A Right-Sized `BitVMX` `n=8` Sovereign ZK Validity Rollup | Stage 1B `clArk` Alternative Gate → Stage 2 Zero-TTP Scale & Upgrade; remediates Consolidated Hostile Review [`R8`](./reviews/HOSTILE_REVIEW_R8_CONSOLIDATED.md) of archived [`v1` / `v3.0.0-rfc`](./versions/v1/SPEC.md) and supersedes archived [`v0` / `v2.5.0-rfc`](./versions/v0/SPEC.md), see [CHANGELOG.md](./CHANGELOG.md)) | |
| 4 | + | **Status:** Public Request for Comment (`v2` / `v3.1.0-rfc`) — NOT mainnet-active; Stage 0 gated on upstream `go-zenon` release (`0aa299e` + `#239`/`#299`/`#312` closure + mainnet `PTLC PR #138` & `DynamicPlasmaSpork` activation with full `SetPlasmaVariables` pinning — Gate G6); Stage 1A gated on Bitcoin Core `>= 29.0` (`v31.0` preferred) Signet execution (Gate G1), compiled `RV32IM` wrapped-SNARK verifier ELF proof (Gate G2), extended checker (Gate G3), formal verification & Bitcoin Core differential fuzzing (Gate G4), vault-bundle disaster-recovery drill (Gate G5), independent third-party cryptography/Bitcoin-Script audit (**M-15**), graduated TVL ramps (`2 → 5 → 15 BTC`), and hard-BTC operator/verifier capital commitment. | |
| 5 | + | **Target Networks:** Bitcoin Mainnet TODAY (`bip-0141`/`bip-0340`/`bip-0341`/`bip-0342`/`bip-0431` Taproot + TRUC v3 + `0`-sat `P2A` ephemeral dust on **Bitcoin Core `>= 29.0`**, `v31.0` preferred — **zero Bitcoin soft forks**, **zero federated signers**) ↔ Zenon Network (`go-zenon` first tagged mainnet release containing `0aa299e`, `#239`/`#299`/`#312` closed, `DynamicPlasmaSpork` & `PtlcSpork` `PR #138` enforced; local reference clone `master` `e8986a6` / `origin/dev` `770e893`) | |
| 6 | + | **Consistency & Bounds Checker:** All modeled `n = 8` `BitVMX` W-OTS/TRUC v3 weights, acyclic `vault_id` 256-bit Lamport `TakeTx` stack/size bounds, widened timelock ordering (`[0, 144] → 1,584 < 1,728 < 1,872 < 2,016`), native-L1 `Stake_r` verifier positive-EV matrices (including `16.53 kvB` P2A CPFP, `0.00285 BTC` lockup, `30%` `zBTC` crisis discount, `500–750 sat/vB`, `k_collude = 0..6`), $2^M$ Hall's Marriage recoverability checks, cyclic `(H(exitId)+r) mod M` priority permutations, `{0.50, 0.25, 0.25}` BTC bank-run exit bounds, `K >= 18` unpublished-fork heuristic & Budish flow-cost sensitivity, 1-/2-block coinbase midstate SHA-256 padding, honest `8 MiB` `go-zenon` Plasma bounds vs Bitcoin L1 `0x02` physical DA ceilings, Erlang-verified PTLC (`>= 48h`) and LN HTLC (`>= 24h`) `2.3×` slow-block tail bounds, `clArk` exit weights, and a **non-no-op randomized state-machine simulation with explicit `AssignedObligations (A)` conservation (`V_unassigned + V_assigned = C + L + E + R + A + B`), `AdmissionTicketUTXO` cap exclusion, concurrent `k = 20` `ExitSlotUTXO` grief bursts, `TransferCredit`, real Bitcoin reorgs, and Lamport equivocation slashes** are asserted by [`scripts/verify_spec_bounds.py`](./scripts/verify_spec_bounds.py) (`python3 -I scripts/verify_spec_bounds.py`). *This script checks internal mathematical consistency against explicitly labeled `SOURCED_`, `POLICY_`, and `PRE_MAINNET_TARGET_` inputs; it is not an empirical Signet benchmark or audit.* | |
| 7 | 7 | ||
| 8 | - | **Upstream Provenance & Review Trail:** | |
| 8 | + | **Upstream Provenance, Pinning & Review Trail:** | |
| 9 | 9 | - Vision Proposal: [`https://btc-moonshot.github.io/bigidea/`](https://btc-moonshot.github.io/bigidea/) *(see §9 for mandatory claims alignment)* | |
| 10 | 10 | - Zenon Non-Bridging Thesis: `zenon-developer-commons/essays/Verify Bitcoin, Don't Bridge It.md` & `docs/specs/spv-event-oracle-spec.md` | |
| 11 | - | - Reference Node Codebase: [`go-zenon`](https://github.com/zenon-network/go-zenon) (`master` `e8986a6`, `origin/dev` `770e893`, target release tag containing `0aa299e` + `#239`) | |
| 12 | - | - Archived Baseline (`v0` / `v2.5.0-rfc`): Frozen byte-for-byte in [`versions/v0/`](./versions/v0/) (SHA-256 verified in CI). | |
| 13 | - | - Consolidated Hostile Review (`R7` of `v0`): [`reviews/HOSTILE_REVIEW_R7_CONSOLIDATED.md`](./reviews/HOSTILE_REVIEW_R7_CONSOLIDATED.md) — every finding `C-1..C-4`, `H-1..H-8`, `M-1..M-15`, `L-1..L-4`, plus convergence findings `N-1..N-6` and `B1..B5`, is dispositioned in [`CHANGELOG.md`](./CHANGELOG.md). | |
| 11 | + | - Reference Node Codebase: [`go-zenon`](https://github.com/zenon-network/go-zenon) (`master` `e8986a6`, `origin/dev` `770e893`, target mainnet release tag containing `0aa299e`, `PR #138`, `#239`/`#299`/`#312`) | |
| 12 | + | - Current `v2` (`v3.1.0-rfc`) Integrity Manifest: generated deterministically at build time in `public/raw/SHA256SUMS.txt` (`R8-L02`) | |
| 13 | + | - Archived Previous Version (`v1` / `v3.0.0-rfc`): Frozen byte-for-byte from commit `6ab3999` in [`versions/v1/`](./versions/v1/) (SHA-256 verified in CI; current `v2` redlines directly against `v1`). | |
| 14 | + | - Archived Initial Baseline (`v0` / `v2.5.0-rfc`): Frozen byte-for-byte from commit `7b47b8c` in [`versions/v0/`](./versions/v0/) (SHA-256 verified in CI). | |
| 15 | + | - Consolidated Hostile Reviews: | |
| 16 | + | - [`R8` (`reviews/HOSTILE_REVIEW_R8_CONSOLIDATED.md`)](./reviews/HOSTILE_REVIEW_R8_CONSOLIDATED.md) — independent multi-agent audit of archived `v1 (v3.0.0-rfc)` (6 Critical, 10 High, 9 Medium, 2 Low; Stage 0 & 1B Conditional Pass, Stage 1A Fail as written); **every confirmed R8 defect is remediated in `v2 (v3.1.0-rfc)`**, with exact line-level dispositions and verified pushbacks documented in §10 and [`CHANGELOG.md`](./CHANGELOG.md). | |
| 17 | + | - [`R7` (`reviews/HOSTILE_REVIEW_R7_CONSOLIDATED.md`)](./reviews/HOSTILE_REVIEW_R7_CONSOLIDATED.md) — historical audit of archived `v0` (`v2.5.0-rfc`) that triggered the zero-federation `v1` redesign. | |
| 14 | 18 | ||
| 15 | 19 | --- | |
| 16 | 20 | ||
| 17 | - | ## 1. Executive Summary & Architectural Pivot (`v0` → `v1`) | |
| 21 | + | ## 1. Executive Summary & Architectural Evolution (`v0` → `v1` → `v2`) | |
| 18 | 22 | ||
| 19 | 23 | ### 1.1 Why `v0` Failed — and Why Custodial Federated Multisigs Are Explicitly Rejected | |
| @@ -25,35 +29,35 @@ | |||
| 25 | 29 | 4. **Never-deleted `N`-of-`N` `Q_graph` & `CommitteeIdentityKey` (`C-4, N-2`) + fixed `1.0 BTC` buckets:** Rotating 30-day PoS committee roots forced never-deleted standing keys (sweep-all OR 1-key bricking at day 56), while fixed `1.0 BTC` buckets rejected `0.50` and `0.25 BTC` exits. | |
| 26 | 30 | ||
| 27 | - | **Why `v1` explicitly REJECTS custodial `k`-of-`n` federated multisigs:** | |
| 28 | - | Falling back to a custodial `k`-of-`n` federated multisig is **normatively forbidden in `v1`**. Federated custody: | |
| 31 | + | **Why `v2` explicitly REJECTS custodial `k`-of-`n` federated multisigs:** | |
| 32 | + | Falling back to a custodial `k`-of-`n` federated multisig is **normatively forbidden in `v2`**. Federated custody: | |
| 29 | 33 | - Violates Bitcoin's non-custodial ethos and Zenon's own thesis (*"Bridges Are Custody Wearing a Mask"* — `Verify Bitcoin, Don't Bridge It.md`); | |
| 30 | 34 | - Fails **Bob's partial-recovery test** under `49%` Zenon compromise (a 49% `go-zenon` DPoS split breaks cross-signer Zenon state agreement and freezes payouts, while safety depends entirely on trusting external custodians); | |
| 31 | 35 | - Fails **Mike's zero-signer-cooperation test** completely (if federated signers refuse to sign Mike's `0.25 BTC` payout, `0` satoshis leave custody; a backup recovery timelock belongs to another custodial multisig and never unlocks while active signers refresh UTXOs). | |
| 32 | 36 | ||
| 33 | - | ### 1.2 Governing Cryptographic Boundaries (Theorem 1 & Theorem 2) | |
| 37 | + | ### 1.2 Governing Cryptographic & Engineering Boundaries (Proposition 1 & Proposition 2) | |
| 34 | 38 | ||
| 35 | - | Every design decision in `v1` is constrained by two formal theorems (proved in [`spec/01 §1`](./spec/01-bitcoin-taproot-vault-enforcement.md#1-cryptographic-boundaries-theorem-1--theorem-2) and [`spec/04 §1`](./spec/04-bitcoin-anchoring-and-light-client.md)): | |
| 39 | + | Every design decision in `v2` is constrained by two formal boundary propositions (detailed in [`spec/01 §1`](./spec/01-bitcoin-taproot-vault-enforcement.md#1-cryptographic-boundaries-proposition-1--proposition-2) and [`spec/04 §1`](./spec/04-bitcoin-anchoring-and-light-client.md)): | |
| 36 | 40 | ||
| 37 | - | > **Theorem 1 (Bitcoin Mainnet No-Covenant Impossibility — BIP-340/341/342, Zero Soft Forks):** Given pooled deposit UTXOs `U_A`, `U_B` created at `t_0` on Bitcoin Mainnet today, if ZERO pre-committed parties produce a new signature at `t_1`, it is **cryptographically impossible** for an unknown future recipient Mike (`P_Mike`, `0.25 BTC` unknown at `t_0`) to spend `U_A` or `U_B` paying `0.25 BTC → P_Mike` while binding `0.75 BTC` back into custody. Tapscript lacks output introspection (`nValue`/`scriptPubKey`), so any unsigned spend is trivially miner-front-run, while pre-signed transactions at `t_0` cannot bind future unknown `(P_Mike, 0.25 BTC)`. **Corollary 1B:** On Bitcoin Mainnet today, optimistic reimbursement bridges (`BitVM2`/`BitVMX`/`BitVM3`) are strictly bounded by **`1-of-N` ephemeral setup deletion + challenger/verifier safety + `1-of-M` pre-committed operator exit liveness**. | |
| 41 | + | > **Proposition 1 (Bitcoin Mainnet No-Covenant 4-Way Impossibility — BIP-340/341/342, Zero Soft Forks):** On Bitcoin Mainnet today (no covenant opcodes), no protocol can simultaneously achieve: **(1)** pooled cross-depositor custody (`U_A`, `U_B` created at `t_0`), **(2)** zero new signatures at `t_1` (`0-of-N` liveness) for an unknown future recipient Mike (`P_Mike`, `0.25 BTC` unknown at `t_0`) while binding the `0.75 BTC` remainder back into custody, **(3)** zero per-hop key-deletion / statechain trust across prior owners, and **(4)** non-expiring fungible liquidity. Tapscript lacks output introspection (`nValue`/`scriptPubKey`), so any unsigned spend is trivially miner-front-run, while pre-signed transactions at `t_0` cannot bind future unknown `(P_Mike, 0.25 BTC)`. **Corollary 1B:** On Bitcoin Mainnet today, optimistic reimbursement bridges (`BitVM2`/`BitVMX`/`BitVM3`) are strictly bounded by **`1-of-N` ephemeral setup deletion + challenger/verifier safety + `1-of-M` pre-committed operator exit liveness**. | |
| 38 | 42 | ||
| 39 | - | > **Theorem 2 (Young Low-Cap Capital / Trust / UX Trilemma — 0 Federation, 0 Soft Forks, `2–20 BTC` Bootstrap Capital):** With zero federated signers, zero Bitcoin soft forks, `~25–33 BTC` ZNN market cap (`0%` ZNN slashing usable), and realistic bootstrap capital `C ∈ [2, 20] BTC`, NO protocol can simultaneously achieve all three of: | |
| 43 | + | > **Proposition 2 (Young Low-Cap Engineering / Capital / Trust Trilemma — 0 Federation, 0 Soft Forks, `~25–33 BTC` ZNN MCap):** Under current Bitcoin Script & ZK-proving engineering with zero federated signers, zero Bitcoin soft forks, and `0%` ZNN slashing usable (`~25–33 BTC` ZNN mcap), no current design fits inside `2–20 BTC` total hard capital while simultaneously achieving all three of: | |
| 40 | 44 | > - **(A)** Instant, non-expiring, fungible cross-depositor `zBTC` (`Alice + Bob → Mike` with zero sender-collusion risk), | |
| 41 | - | > - **(B)** `1-of-∞` permissionless challenging surviving `200–500 sat/vB` fee spikes (blocked by BitVM2's irreducible `~40–91 BTC` bond floor even at `M = 3–5, L = 1`), AND | |
| 42 | - | > - **(C)** `0-of-N` unilateral arbitrary-amount Bitcoin L1 exit (blocked by Theorem 1; `clArk` achieves post-round `0-of-N` only by sacrificing **(A)** via discrete expiring VTXOs and pre-round `arkoor` sender+ASP collusion). | |
| 45 | + | > - **(B)** `1-of-∞` permissionless challenging surviving `200–500 sat/vB` fee spikes (blocked by current Groth16 BitVM2's `~40–91 BTC` bond floor even at `M = 3–5, L = 1`; future reusable BitVM3-GC reduces on-chain dispute weights substantially but currently carries `1-of-N` garbler trust plus `2.2–11.2+ TB` one-time off-chain garbled-circuit DA across `M × L × R × N` rounds — see `spec/01 Appendix A.2`), AND | |
| 46 | + | > - **(C)** `0-of-N` unilateral arbitrary-amount Bitcoin L1 exit (blocked by Proposition 1; `clArk` achieves post-round `0-of-N` only by sacrificing **(A)** via discrete expiring VTXOs and pre-round `arkoor` sender+ASP collusion). | |
| 43 | 47 | ||
| 44 | - | ### 1.3 What `v1` (`v3.0.0-rfc`) Is, Stated Plainly | |
| 48 | + | ### 1.3 What `v2` (`v3.1.0-rfc`) Is, Stated Plainly | |
| 45 | 49 | ||
| 46 | - | `v1` specifies a **zero-federation, zero-soft-fork, zero-ZNN-custody-coupling** phased architecture starting from zero custody risk: | |
| 50 | + | `v2` (`v3.1.0-rfc`) specifies a **zero-federation, zero-soft-fork, zero-ZNN-custody-coupling** phased architecture starting from zero custody risk: | |
| 47 | 51 | ||
| 48 | 52 | 1. **Stage 0 (`0–6 months`, `0 BTC` bridge custody risk, `0–5 BTC` voluntary LP — Mandatory Start):** | |
| 49 | - | - Ship the **Direct-on-L1 Bitcoin SPV Event Oracle** (`spec/02 §2`, strictly Event Validity, zero custody authority, aligned with `Verify Bitcoin, Don't Bridge It.md`) and **non-custodial PTLC / Lightning HTLC atomic swaps** (`spec/03 §1`, hardened for `2.3×` June 2021 slow blocks) while building and auditing the Stage 1A Rollup Core + `BitVMX-CPU` RISC-V verifier on Signet. | |
| 50 | - | 2. **Stage 1 Decision Gate (Explicitly Governed by Hard-BTC Commitment & Timeline):** | |
| 51 | - | - **Stage 1A — Primary Path for Pooled Fungible `zBTC` (`12–18+ months` incl. audit for 4–6 engineers; requires `~12.8–18.8 BTC` of non-yielding hard BTC ≈ `40–75%` of ZNN's `~25–33 BTC` market cap):** | |
| 52 | - | - **Shared Core (0% Zenon Trust — Survives 49%–100% Zenon Compromise):** A **Bitcoin-Anchored Sovereign ZK Validity Rollup** where Zenon is demoted to an untrusted feeless sequencing & soft-preconfirmation layer (`AccountBlock.Data`, `~28,480` Plasma, `0` sat BTC fee, NOT native ZTS). Canonical ordering, complete mutated-leaf DA (`0x02 BATCH_DA` + embedded `π_batch`), and uncensorable forced inclusion (`0x01 FORCED_EXIT`, `0x03 FORCED_TRANSFER`) live strictly on Bitcoin L1 via full stripped-block (`≤ 1,000,000 B`) scanning. | |
| 53 | - | - **Custody Engine (Right-Sized `BitVMX`, `n = 8`, `M = 3–5`, `L = 1`, `N = 7`):** Open-source `BitVMX-CPU` (`RV32IM`) interactive bisection (`~7.44 kvB`/prover tx, **100% BIP-431 TRUC v3** with `P2A` ephemeral anchors; `~75 kvB` Prover / `~15 kvB` Verifier; `F_chal = 0.40 BTC` covering `500 sat/vB` sustained across all `20` steps, `533 sat/vB` break-even), deleted-key `{0.50, 0.25, 0.25}` BTC multi-tier vaults, 256-bit Lamport `TakeTx` equivocation slashing (`~3.1 kvB` TRUC v3), dual-input `Stake_r` + `VaultConnector_r` bisection slashing (`0` BTC stolen from vault, positive EV `≥ +0.0167 BTC` for every honest verifier even if `6 of 7` verifiers collude with the operator!), and `(2M + 1)`-leaf registered-operator spend-or-refund `ExitSlotUTXO`. **Pre-mainnet maturity explicitly disclosed.** | |
| 54 | - | - **Stage 1B — Explicit Alternative Gate (If Hard-BTC Budget `< 5–10 BTC`, `3–6 mo` Launch Target, or `0-of-N` Post-Round Exit Outweighs Pooled Fungibility):** | |
| 55 | - | - Do **NOT** under-bond `BitVMX`/`BitVM2`. Deploy **`clArk` (`Second bark` / `Ark Labs arkd`) + Zenon SPV/PTLC** (`2–5 BTC` active ASP liquidity, `0` bonds), explicitly relinquishing global pooled `zBTC` in favor of discrete expiring VTXOs (disclosing `arkoor` sender+ASP collusion and `log2(N)` L1 exit fees). | |
| 53 | + | - Ship the **Direct-on-L1 Bitcoin SPV Event Oracle** (`spec/02 §2`, strictly Event Validity, zero custody authority, `len(strippedTx) >= 65`, 1-/2-block coinbase midstate padding) and **Erlang-hardened non-custodial PTLC (`T_znn >= 48h`, automated block-72 RBF watchtowers) / Lightning HTLC (`Δ_safety >= 24h`) atomic swaps** (`spec/03 §1`, `P(tail failure | 2.3× slowdown) < 0.0002`, explicitly disclosing conditional atomicity) while building and auditing the Stage 1A Rollup Core + `BitVMX-CPU` wrapped-SNARK verifier on Signet. | |
| 54 | + | 2. **Stage 1 Decision Gate (Explicitly Governed by Hard-BTC Commitment, Engineering Scope & Timeline):** | |
| 55 | + | - **Stage 1A — Primary Path for Pooled Fungible `zBTC` (`12–18+ months` incl. audit for 4–6 engineers; requires `12.80–18.80 BTC` locked protocol capital → `14.75–21.25 BTC` full single-dispute operational baseline ≈ `45–85%` of ZNN's `~25–33 BTC` market cap, plus explicit `M`-simultaneous-dispute verifier headroom disclosure):** | |
| 56 | + | - **Shared Core (0% Zenon Trust — Survives 49%–100% Zenon Compromise):** A **Bitcoin-Anchored Sovereign ZK Validity Rollup** where Zenon is demoted to an untrusted **L1-subsidized soft-preconfirmation sequencer** (`AccountBlock.Data`, `28,480` Plasma, `0` sat direct user BTC fee, NOT native ZTS; bounded against `0x02` DA spam via refundable `500`-sat new-leaf deposit + `<= 1,000` new leaves/6-block epoch cap). Canonical ordering, complete mutated-leaf DA (`0x02 BATCH_DA` covering `Accounts`, `RollupLocks`, and cooperative `PendingExits` + embedded `π_batch`, slotted batcher priority), and uncensorable forced inclusion (`0x01 FORCED_EXIT`, `0x03 FORCED_TRANSFER`) live strictly on Bitcoin L1 via full stripped-block (`≤ 1,000,000 B`) scanning, fail-closed BIP-141 `wtxid` witness authentication (last `0x6a24aa21a9ed` coinbase output), and full stripped-`vin` tracked-UTXO scanning. | |
| 57 | + | - **Custody Engine (Right-Sized `BitVMX`, `n = 8`, `M = 3–5`, `L = 1`, `N = 7`, Bitcoin Core `>= 29.0`):** Open-source `BitVMX-CPU` (`RV32IM`) interactive bisection executing **strictly a constant-size wrapped SNARK verifier (`vk_STF`, Gate G2)** (`~7.44 kvB`/prover tx, **100% BIP-431 TRUC v3** with `0`-sat `P2A` ephemeral anchors on Core `>= 29.0` + direct-to-miner rails; `76.53 kvB` Prover / `16.53 kvB` Verifier incl. `10 × 153 vB` CPFP; `F_chal = 0.40 BTC` covering `500 sat/vB` sustained, `522 sat/vB` break-even; widened `T_step = 72` blks → `T_take = 1,728`, `T_cooldown = 1,872`, `Retire = 2,016`). Deleted-key `{0.50, 0.25, 0.25}` BTC vaults with **acyclic pre-funding `vault_id`** (`R8-C01`), L1 consensus **`AdmissionTicketUTXO`** `Cap_TVL` mutual exclusion (`R8-C03`), exact **$2^M$ Hall's Marriage** recoverability (`R8-C04`), explicit **`AssignedObligations (A)`** conservation (`R8-C02`), **native Bitcoin L1 `Stake_r` verifier payouts (`0.15 BTC` native BTC to every active honest challenger via `ChalPayoutEscrow` — `0%` `zBTC` crisis discount, `+0.0645 BTC` net EV @ `500 sat/vB` & `+0.0232 BTC` @ `750 sat/vB`, `890 sat/vB` break-even, `R8-H02`/`R8-N05`)**, hard-partitioned `B_grief` (`0.05 BTC`) with active-operator-only `ExitSlotUTXO` (`R8-H01`), cyclic `(H(exitId)+r) mod M` priority (`R8-M03`), and `zbtc-vault-bundle-v1` public DA archival (`R8-H06`). **Pre-mainnet maturity explicitly disclosed; Gate G2 evaluates BitVMX-CPU vs BitVM3-GC prior to final freeze.** | |
| 58 | + | - **Stage 1B — Explicit Alternative Gate (If Hard-BTC Budget `< 10–15 BTC`, `3–6 mo` Launch Target, or `0-of-N` Post-Round Exit Outweighs Pooled Fungibility):** | |
| 59 | + | - Do **NOT** under-bond `BitVMX`/`BitVM2`. Deploy **`clArk` (`Second bark` / `Ark Labs arkd`) + Zenon SPV/PTLC** (`2–5 BTC` active ASP liquidity, `0` bonds), explicitly relinquishing global pooled `zBTC` in favor of discrete expiring VTXOs (disclosing `arkoor` sender+ASP collusion, automated watchtower refreshes, and `log2(N)` L1 exit fees). | |
| 56 | 60 | 3. **Stage 2 (`12+ months`, Zero-TTP Scale & Upgrade — Zero Dead-End User Trap):** | |
| 57 | - | - Deleted-key Stage 1A vaults NEVER expire and drain organically 1:1 to native BTC via `0x01` exits (no deleted-key L1 rollover). Identical-STF `BitVMX` expansion (`M = 5 → 20`, `L = 1 → 4`, `K = 36 → 144`) uses strictly `N`-of-`N` Cohort 1 voluntary handover; changing custody backends (`BitVM3-GC` / `BitVM2` / **Appendix A Track B Pure Tier-0 `OP_CCV + OP_TXHASH + OP_VERIFY_STARK` or `OP_CAT` Covenant**) ALWAYS launches a clean, non-commingled `zBTC_v2` instance with zero governance backdoor. | |
| 61 | + | - Deleted-key Stage 1A vaults carry **no expiry / no CLTV bricking** and drain organically 1:1 to native BTC via `0x01` exits (subject to `1-of-M` eligible operator liveness; no deleted-key L1 rollover). Identical-STF `BitVMX` expansion (`M = 5 → 20`, `L = 1 → 4`, `K = 42 → 144`) uses strictly `N`-of-`N` Cohort 1 voluntary handover; changing custody backends (`BitVM3-GC` / `BitVM2` / **Appendix A Track B Pure Tier-0 `OP_CCV + OP_TXHASH + OP_VERIFY_STARK` or `OP_CAT` Covenant**) ALWAYS launches a clean, non-commingled `zBTC_v2` instance with zero governance backdoor. | |
| 58 | 62 | ||
| 59 | 63 | --- | |
| @@ -61,18 +65,18 @@ | |||
| 61 | 65 | ## 2. Normative Module Map & Authority Precedence | |
| 62 | 66 | ||
| 63 | - | | Module | File | Normative Scope in `v1` (`v3.0.0-rfc`) | | |
| 67 | + | | Module | File | Normative Scope in `v2` (`v3.1.0-rfc`) | | |
| 64 | 68 | |---|---|---| | |
| 65 | - | | **Master** | [`SPEC.md`](./SPEC.md) | Zero-federation phased architecture, Theorems 1–2, end-to-end Bob & Mike traces (§3), honest Threat Model & Privileged Powers Table (§4), `go-zenon` baseline (§5), Upstream Amendments (§6), Stage 0/1A/1B/2 Decision Gates (§7), Non-Bridging Alignment & Public Claims (§8–§9), and Written R7 Disposition (§10). | | |
| 66 | - | | **Part 1** | [`spec/01-bitcoin-taproot-vault-enforcement.md`](./spec/01-bitcoin-taproot-vault-enforcement.md) | **Highest Custody Precedence (`BTC-BITVMX-V1`):** Theorems 1–2; acyclic `OP_DROP` `DepositTx` (`{0.50, 0.25, 0.25}` deleted-key vaults, `certBlob = 104 B`, `opBitmask`, zero-TTP cohort rule); `BitVMX-CPU` `n = 8` bisection (`301` W-OTS digits ≈ `7.44 kvB`, `20` steps, `75/15 kvB`, `F_chal = 0.40 BTC`, 100% TRUC v3); simultaneous `[0, 144]` challenge window, `T_take = 1,152`, `T_cooldown = 1,296`, `RetireStakeTx = 1,440`; 256-bit Lamport `TakeTx` (`5,922 B` script, `~3.1 kvB`); dual-input slash (`0.15/1.85/0.55` positive-EV matrix); `(2M+1)`-leaf `ExitSlotUTXO`; exact `12.8/18.8 BTC` capital & `65–72d` bank-run math; Stage 1B `clArk` spec; **Appendix A (Track B Pure Tier-0 Bitcoin Soft-Fork Covenant + BitVM2/BitVM3 Reference)**. | | |
| 67 | - | | **Part 2** | [`spec/02-btc-authorization-domain-and-spv.md`](./spec/02-btc-authorization-domain-and-spv.md) | **Stage 0 Direct-on-L1 Bitcoin SPV Event Oracle** (Event Validity only, 1-/2-block coinbase midstate SHA-256 final padding covering all `len % 64`, exact ABI/storage-op/`dp.MaxContractBlocks = 40` budget) + **Stage 1A Bitcoin-L1-Canonical Authorization Domain** (`0x00`..`0x07` `OP_RETURN "ZBTX"` tags, full `≤ 1 MB` stripped-block scan + single `wtxid_i` branch, launch-time `(h_lane_init, H, D)` PoW anchor with `D ≥ 0.50 × D(h_lane_init)` and TVL-scaled `K`). | | |
| 68 | - | | **Part 3** | [`spec/03-settlement-minted-zbtc-and-feeless-rails.md`](./spec/03-settlement-minted-zbtc-and-feeless-rails.md) | **Stage 0 Hardened Non-Custodial PTLC & LN HTLC Swaps** (absolute Unix timestamps, `2.3×` slow-block margin) + **Stage 1A Sovereign Rollup STF `F` & Feeless Zenon Sequencer Rails** (`AccountBlock.Data` `~28,480` Plasma, honest `8 MiB` `~1,050–1,200 tx/s` ceiling, `RollupHTLC`/`RollupPTLC`, `B_zbtc = 0.60 BTC`/lane accounting, `ExitSlotUTXO` spend-or-refund, permissionless DA batchers) + **Stage 1B `clArk` VTXO Coordination**. | | |
| 69 | - | | **Part 4** | [`spec/04-bitcoin-anchoring-and-light-client.md`](./spec/04-bitcoin-anchoring-and-light-client.md) | **Zenon `49%` Consensus Reality (`go-zenon` Code Proof) & Inverted Trust Hierarchy:** Proof of DPoS failure at `49%` (height-only `findSeed`, unweighted top-30 `groupA`, zero slashing, 30-Momentum cliff) and BFT failure at `> 33.3%`, why Bitcoin L1 ordering + DA + forced inbox achieves `0-of-N` Zenon trust (eliminating BLS finality from BTC custody), and non-custodial light-client UX notes. | | |
| 70 | - | | **Part 5** | [`spec/05-go-zenon-upgrade-plan.md`](./spec/05-go-zenon-upgrade-plan.md) | **Minimal `go-zenon` Upgrade Plan:** Stage 0 prerequisites (`0aa299e` tag, `#239` FIFO panic-stall closure, `DynamicPlasmaSpork` + full `SetPlasmaVariables` pinning of `MaxBasePlasmaInMomentum`, `MaxPriceChangePercent`, `FusedPlasmaTarget`, `PowPlasmaTarget`, `PriceChangeDenominator`, `PtlcSpork`, Stage 0 SPV Event Oracle) + **zero-hard-fork custody boundary for Stage 1A/1B** (`SporkAddress` cannot steal BTC or censor L1 exits). | | |
| 71 | - | | **Checker** | [`scripts/verify_spec_bounds.py`](./scripts/verify_spec_bounds.py) | Stdlib-only Python 3 Consistency & Bounds Checker asserting all Stage 0, Stage 1A (`BitVMX n=8`), Stage 1B (`clArk`), and Theorem 2 bounds + non-no-op 2,000-step randomized simulation with real Bitcoin reorgs, `ExitSlotUTXO` grief slashes, and Lamport equivocation slashes. | | |
| 72 | - | | **Changelog** | [`CHANGELOG.md`](./CHANGELOG.md) | Complete `v0` (`v2.5.0-rfc`) → `v1` (`v3.0.0-rfc`) finding-by-finding disposition (`C-1..C-4`, `H-1..H-8`, `M-1..M-15`, `L-1..L-4`, `N-1..N-6`, `B1..B5`) and rejection rationale for custodial federated multisigs. | | |
| 69 | + | | **Master** | [`SPEC.md`](./SPEC.md) | Zero-federation phased architecture, Propositions 1–2, end-to-end Bob & Mike traces (§3), honest Threat Model & Privileged Powers Table (§4), `go-zenon` baseline (§5), Upstream Amendments (§6), Stage 0/1A/1B/2 Decision Gates & graduated TVL ramps (§7), Non-Bridging Alignment & Public Claims (§8–§9), and Written Q&A answering all 12 R8 Questions + R7 summary (§10). | | |
| 70 | + | | **Part 1** | [`spec/01-bitcoin-taproot-vault-enforcement.md`](./spec/01-bitcoin-taproot-vault-enforcement.md) | **Highest Custody Precedence (`BTC-BITVMX-V1`):** Propositions 1–2; acyclic `OP_DROP` `DepositTx` + L1 `AdmissionTicketUTXO` cap exclusion (`{0.50, 0.25, 0.25}` deleted-key vaults, `certBlob = 104 B`, `opBitmask`, $2^M$ Hall's Marriage invariant, `zbtc-vault-bundle-v1` public DA); `BitVMX-CPU` `n = 8` wrapped-SNARK verifier bisection (`301` W-OTS digits ≈ `7.44 kvB`, `20` steps, `76.53/16.53 kvB` incl. P2A CPFP, Core `>= 29.0`, `F_chal = 0.40 BTC`); widened timelocks (`[0, 144]` → `1,584 < T_take=1,728 < T_cool=1,872 < Retire=2,016`); acyclic `vault_id` 256-bit Lamport `TakeTx` (`5,922 B` script, `~3.14–3.17 kvB`); native-L1 `Stake_r` `ChalPayoutEscrow` verifier payouts (`0.15 BTC` native BTC each, `>= 0.95 BTC` burn, `+0.0645/+0.0232 BTC` EV @ `500/750 sat/vB`); active-op `(2M_active+1)`-leaf `ExitSlotUTXO` w/ cyclic `(H(exitId)+r) mod M`; full operational capital (`14.75–21.25 BTC` + `M`-dispute headroom) & `94–104d` bank-run math; voluntary unwind circuit breaker (`R8-H08`); Stage 1B `clArk` spec; **Appendix A (Track B Soft-Fork Covenant + BitVM2/BitVM3 Reference)**. | | |
| 71 | + | | **Part 2** | [`spec/02-btc-authorization-domain-and-spv.md`](./spec/02-btc-authorization-domain-and-spv.md) | **Stage 0 Direct-on-L1 Bitcoin SPV Event Oracle** (Event Validity only, `len(strippedTx) >= 65`, 1-/2-block coinbase midstate SHA-256 final padding, exact ABI/storage-op/`dp.MaxContractBlocks = 40` budget) + **Stage 1A Bitcoin-L1-Canonical Authorization Domain** (`0x00`..`0x07` `OP_RETURN "ZBTX"` tags, off-chain stripped-block scanner proved by wrapped SNARK `vk_STF`, fail-closed BIP-141 witness authentication on last `6a24aa21a9ed` coinbase output, full stripped-`vin` scan of tracked UTXOs, complete `0x02` DA schema + slotted batcher priority, `K >= 18` unpublished-fork heuristic, interactive heaviest-chainwork comparison, and `>= K` `DEEP_REORG_HALT` circuit breaker). | | |
| 72 | + | | **Part 3** | [`spec/03-settlement-minted-zbtc-and-feeless-rails.md`](./spec/03-settlement-minted-zbtc-and-feeless-rails.md) | **Stage 0 Erlang-Hardened Non-Custodial PTLC (`T_znn >= 48h`, block-72 RBF watchtower) & LN HTLC (`Δ_safety >= 24h`) Swaps** + **Stage 1A Sovereign Rollup STF `F` & L1-Subsidized Feeless Zenon Sequencer Rails** (explicit `AssignedObligations (A)` conservation `V_unassigned + V_assigned = C + L + E + R + A + B`, hard-partitioned `B_custody`/`B_grief`, oldest-`PendingExit` credit priority, `TransferCredit` & `R -> C` residual consolidation, `MIN_EXIT_SATS = 100,000` sats dust floor, `500`-sat new-leaf deposit + `1,000`/epoch cap, two-column Zenon TPS vs Bitcoin L1 `0x02` DA ceiling) + **Stage 1B `clArk` VTXO Coordination**. | | |
| 73 | + | | **Part 4** | [`spec/04-bitcoin-anchoring-and-light-client.md`](./spec/04-bitcoin-anchoring-and-light-client.md) | **Zenon `49%` Consensus Reality (`go-zenon` Code Proof) & Inverted Trust Hierarchy:** Proof of DPoS failure at `49%` (height-only `findSeed`, unweighted top-30 `groupA`, zero slashing, 30-Momentum cliff) and BFT failure at `> 33.3%`, why Bitcoin L1 ordering + DA + forced inbox achieves `0-of-N` Zenon trust (with probabilistic PoW finality at depth `K >= 18`), and non-custodial light-client UX notes. | | |
| 74 | + | | **Part 5** | [`spec/05-go-zenon-upgrade-plan.md`](./spec/05-go-zenon-upgrade-plan.md) | **Minimal `go-zenon` Upgrade Plan & R8 Pre-Mainnet Gates G1–G7:** Stage 0 prerequisites (`0aa299e` tag, `#239`/`#299`/`#312` closure, mainnet `PTLC PR #138` & `DynamicPlasmaSpork` activation with 5-parameter `SetPlasmaVariables` pinning, Stage 0 SPV Event Oracle) + **zero-hard-fork custody boundary for Stage 1A/1B** (`SporkAddress` cannot steal BTC or censor L1 exits) + **Bitcoin Core `>= 29.0` (`v31.0` preferred)** + **Gates G1–G7**. | | |
| 75 | + | | **Checker** | [`scripts/verify_spec_bounds.py`](./scripts/verify_spec_bounds.py) | Stdlib-only Python 3 Consistency & Bounds Checker asserting all Stage 0 (exact Erlang tails), Stage 1A (`BitVMX n=8`, acyclic `vault_id`, native-L1 verifier EV, $2^M$ Hall, `K >= 18` + Budish sensitivity, `0x02` DA ceilings), Stage 1B (`clArk`), and Proposition 2 bounds + non-no-op randomized state-machine simulation with explicit `A` conservation, `AdmissionTicketUTXO`, concurrent `k = 20` grief burst, `TransferCredit`, real Bitcoin reorgs, and slashes. | | |
| 76 | + | | **Changelog** | [`CHANGELOG.md`](./CHANGELOG.md) | Complete **`v1` (`v3.0.0-rfc`) → `v2` (`v3.1.0-rfc`) (`R8` Consolidated Hostile Review Disposition — all 27 findings + verified pushbacks)** plus historical `v0` (`v2.5.0-rfc`) → `v1` (`v3.0.0-rfc`) `R7` disposition and rejection rationale for custodial federated multisigs. | | |
| 73 | 77 | ||
| 74 | 78 | ### 2.1 Authority & Conflict Precedence (`M-13` Fixed) | |
| 75 | 79 | ||
| 76 | - | 1. **Bitcoin L1 Consensus & Part 1 Vault Scripts ([`spec/01`](./spec/01-bitcoin-taproot-vault-enforcement.md), `BTC-BITVMX-V1`)** — non-overridable custody layer. Hard-pinned `vk_STF`, deleted-key Taproot graphs, `StakeChain`, and `ExitSlotUTXO` rules cannot be overridden by any Zenon contract, Pillar, or spork. | |
| 80 | + | 1. **Bitcoin L1 Consensus & Part 1 Vault Scripts ([`spec/01`](./spec/01-bitcoin-taproot-vault-enforcement.md), `BTC-BITVMX-V1`)** — non-overridable custody layer. Hard-pinned `vk_STF`, deleted-key Taproot graphs, `AdmissionTicketUTXO`s, `StakeChain`, and `ExitSlotUTXO` rules cannot be overridden by any Zenon contract, Pillar, or spork. | |
| 77 | 81 | 2. **Bitcoin-L1-Canonical Authorization & Rollup STF ([`spec/02`](./spec/02-btc-authorization-domain-and-spv.md) & [`spec/03`](./spec/03-settlement-minted-zbtc-and-feeless-rails.md))** — deterministic state transition over Bitcoin L1 blocks (`0x00`..`0x07`). | |
| 78 | 82 | 3. **Stage 0 `go-zenon` Runtime & SPV Event Oracle ([`spec/05`](./spec/05-go-zenon-upgrade-plan.md))** — governs feeless Zenon sequencing UX and Stage 0 non-custodial SPV/PTLC rails; holds ZERO authority over Stage 1A BTC custody. | |
| @@ -83,53 +87,55 @@ | |||
| 83 | 87 | ## 3. End-to-End Protocol Flows & Hostile Scenario Traces | |
| 84 | 88 | ||
| 85 | - | ### 3.1 Stage 0: Verify Bitcoin (SPV Event Oracle + Non-Custodial PTLC/LN) | |
| 89 | + | ### 3.1 Stage 0: Verify Bitcoin (SPV Event Oracle + Erlang-Hardened Non-Custodial PTLC/LN) | |
| 86 | 90 | ||
| 87 | 91 | Zero pooled BTC custody (`0 BTC` bridge exposure): | |
| 88 | - | 1. Relayers submit Bitcoin headers and Merkle inclusion proofs (with 1- or 2-block SHA-256 coinbase midstate padding) to the Stage 0 SPV Event Oracle (`spec/02 §2`), proving Event Validity on the best PoW chain. | |
| 89 | - | 2. Users swap native BTC / Lightning against Zenon assets atomically via BIP-327 Taproot MuSig2 PTLCs (`<72> OP_CSV` refund leaf, `h_conf + 66` confirmed-before-refund with CPFP, `T_znn = now + 108,000s` = `30h` leaving `4.7h` margin under `2.3×` June 2021 slow blocks) or SHA-256 HTLCs (`hashType = 1`, `Δ_safety = 36` blks, Hold Invoice rate limits, `spec/03 §1`). | |
| 92 | + | 1. Relayers submit Bitcoin headers and Merkle inclusion proofs (`len(strippedTx) >= 65`, 1- or 2-block SHA-256 coinbase midstate padding) to the Stage 0 SPV Event Oracle (`spec/02 §2`), proving Event Validity on the best PoW chain. | |
| 93 | + | 2. Users swap native BTC / Lightning against Zenon assets atomically via BIP-327 Taproot MuSig2 PTLCs (`<72> OP_CSV` refund leaf, mandatory automated high-fee RBF refund watchtower firing at `h_conf + 72`, `T_znn >= now + 172,800s` = **`48.0h`** achieving `P(T_72 > 48h | 2.3× slowdown) < 10^{-6}` and `>= 9.25h` tail margin past `p99.9 = 38.75h`) or SHA-256 HTLCs (`hashType = 1`, `Δ_safety_blocks = 36`, outbound `Δ_safety_sec >= 86,400s` = **`24.0h`** with `P(T_36 > 24h | 2.3×) < 0.0002`, Hold Invoice rate limits, `spec/03 §1`). Stage 0 atomicity is explicitly conditional on bounded chain progress and timely refund broadcast. | |
| 90 | 94 | ||
| 91 | 95 | ### 3.2 Stage 1A: Sovereign ZK Validity Rollup + Right-Sized `BitVMX` (`n = 8`, `M = 3–5`, `N = 7`) | |
| 92 | 96 | ||
| 93 | - | #### Flow A — Acyclic Deposit (`Alice 1 BTC`, `Bob 1 BTC`, Closes `v0 C-4, N-2, M-7`) | |
| 94 | - | 1. Alice locks `1.0 BTC + fee` in her own self-custodial staging UTXO `U_Alice_wallet` with Tapscript `OP_DROP <pk_Alice> OP_CHECKSIG`. | |
| 95 | - | 2. Alice prepares `DepositTx` spending `U_Alice_wallet` → `vout[0..2]` = multi-tier deleted-key vaults **`{0.50, 0.25, 0.25}` BTC** (`3` vaults/BTC, avg `0.333 BTC`, `maxVaultDenom = 0.50 BTC`) + `vout[3]` = `69 B` `OP_RETURN "ZBTX" || 0x00 || recipientAcctHash(32B) || vaultParamsHash(32B)`. Because `vout[3]` does not hash `certBlob`, **`txid_dep` is fixed before signing**. | |
| 96 | - | 3. Alice + `N = 7` presigners + all online operators (`≥ M_min`, recorded in `opBitmask`) presign the `TakeTx_{d,j,l,r}` graphs (`M × L × R = 5 × 1 × 64 = 320` pre-signed `TakeTx`s per vault ≈ `40 KB`, `< 100ms` MuSig2 ONCE at deposit) using fresh per-deposit ephemeral keys `Q_setup_d = MuSig2(P_{1..N,d}, P_{A,d})`. | |
| 97 | - | 4. Each presigner **permanently deletes `x_{i,d}`** and signs non-spending identity attestation `σ_cert` over `txid_dep`, forming `certBlob = σ_cert(64B) || Q_setup_d(32B) || opBitmask(8B)` (`104 B ≤ 520 B` BIP-342 stack limit). | |
| 98 | - | 5. Only after verifying all pre-signed `TakeTx`s and `σ_cert` does Alice delete `x_{A,d}`, push `[sig_Alice, certBlob, script, controlBlock]` into `DepositTx.vin[0].witness`, and broadcast (zero hash cycle, zero stranding!). At `K = 14` confirmations, the STARK scans `DepositTx` via stripped block + `wtxid_dep` and credits `1.0 zBTC` to Alice (identical for Bob). | |
| 97 | + | #### Flow A — Acyclic Deposit With L1 `AdmissionTicketUTXO` Cap Exclusion (`Alice 1 BTC`, `Bob 1 BTC`, Closes `R8-C01`, `R8-C03`, `R8-H06`) | |
| 98 | + | 1. Alice confirms `1.0 BTC + fee` in her own self-custodial staging UTXO `U_Alice_wallet` (`funding_txid:funding_vout`, Tapscript `OP_DROP <pk_Alice> OP_CHECKSIG`). Because `funding_txid:funding_vout` is already confirmed on Bitcoin L1, each vault's domain-separated identifier **`vault_id = SHA256("zbtc:vault-id:v1" || funding_txid || funding_vout || vault_vout || amount_sats || opBitmask)`** is 100% deterministic **before** Taproot tree construction (completely acyclic — zero `SHA256(outpoint_d)` cycle!). | |
| 99 | + | 2. Alice prepares `DepositTx` spending `vin[0] = U_Alice_wallet` AND **denomination-matched `AdmissionTicketUTXO`s (`vin[1] = Ticket_050`, `vin[2..3] = 2 × Ticket_025`)** → `vout[0..2]` = deleted-key vaults **`{0.50, 0.25, 0.25}` BTC** (`3` vaults/BTC, avg `0.333 BTC`, `maxVaultDenom = 0.50 BTC`) + `vout[3]` = `69 B` `OP_RETURN "ZBTX" || 0x00 || recipientAcctHash(32B) || vaultParamsHash(32B)`. Because `DepositTx` consumes live L1 tickets, two competing deposits racing across `Cap_TVL` cannot both confirm on Bitcoin L1 — the loser's `DepositTx` is rejected by Bitcoin consensus and Alice's BTC never leaves her wallet (`R8-C03`). | |
| 100 | + | 3. Alice + `N = 7` presigners + all online operators (`≥ M_min`, recorded in `opBitmask`, checked against the exact **$2^M$ Hall's Marriage Invariant** `R8-C04`) presign the `TakeTx_{d,j,l,r}` graphs (`M × L × R = 5 × 1 × 64 = 320` pre-signed `TakeTx`s per vault ≈ `40 KB`, `< 100ms` MuSig2 ONCE at deposit, each recycling its exact matching `AdmissionTicketUTXO` at `vout[1]`) using fresh per-deposit ephemeral keys `Q_setup_d = MuSig2(P_{1..N,d}, P_{A,d})`. | |
| 101 | + | 4. Each presigner **permanently deletes `x_{i,d}`** and signs non-spending identity attestation `σ_cert` over `(txid_dep, Q_setup_d, opBitmask, vaultParamsHash)`, forming `certBlob = σ_cert(64B) || Q_setup_d(32B) || opBitmask(8B)` (`104 B ≤ 520 B` BIP-342 stack limit). The complete **`zbtc-vault-bundle-v1`** (scripts, control blocks, W-OTS/Lamport pubkeys, all presigned `TakeTx`s) is replicated and cryptographically verified across `>= 3` independent public archival mirrors (`R8-H06`). | |
| 102 | + | 5. Only after verifying all pre-signed `TakeTx`s, `σ_cert`, and public bundle replication does Alice delete `x_{A,d}`, push `[sig_Alice, certBlob, script, controlBlock]` into `DepositTx.vin[0].witness`, and broadcast. At `K = 18` confirmations, the off-chain ZK prover (verified by `vk_STF`) scans `DepositTx` via stripped block + BIP-141 `wtxid_dep` and credits `1.0 zBTC` to Alice (identical for Bob). | |
| 99 | 103 | ||
| 100 | - | #### Flow B — Feeless `zBTC` Transfers on Zenon (`AccountBlock.Data`) | |
| 101 | - | - Signed rollup transfers (`~110 B`) are submitted in Zenon `AccountBlock.Data`, paying **`0` satoshis BTC fee**, **`0` burned ZNN/QSR**, and **`21,000 + 68 × 110 = 28,480` Plasma** (`~14` refundable fused QSR or `~42.7M` SHA3-256 PoW hashes at floor price `1,000`; `~11.4s` soft confirmations; honest throughput `~4.4` tx/s at `2.1M` floor, `~8.8` tx/s default, **`~1,050–1,200` tx/s real hard ceiling** under `MaxMomentumContentBytes = 8 MiB`). | |
| 102 | - | - Permissionless market-funded batch proposers aggregate feeless transfers every `~6` Bitcoin blocks into `0x02 BATCH_DA` carrying **complete mutated SMT leaves** (`16 B` existing / `48 B` new account) + succinct embedded proof `π_batch` (transparent STARK/IPA or Groth16). First valid `0x02` matching `R_{h-1}` in Bitcoin L1 block/tx order wins; invalid batches are deterministically skipped in-circuit. | |
| 104 | + | #### Flow B — L1-Subsidized Feeless `zBTC` Transfers on Zenon (`AccountBlock.Data`) | |
| 105 | + | - Signed rollup transfers (`~110 B`) are submitted in Zenon `AccountBlock.Data`, paying **`0` satoshis direct user BTC fee**, **`0` burned ZNN/QSR**, and **`21,000 + 68 × 110 = 28,480` Plasma** (`14` refundable fused QSR or `~42.7M` SHA3-256 PoW hashes at floor price `1,000`; `~11.4s` soft confirmations). Honest Zenon transport throughput (`4.4/8.8` 2-blk tx/s, `6.5/12.9` 1-blk rollup sends/s, `1,050–1,200` `8 MiB` ceiling) is paired explicitly in `spec/03 §2.2` with **Bitcoin L1's hard physical `0x02` mutated-leaf DA ceiling (`~166.7` blended `10 vB` leaves/s at 100% of all Bitcoin blockspace; `~1.67` leaves/s at 1%)** (`R8-M08`). | |
| 106 | + | - To prevent zero-cost `0x02` L1 DA griefing (`R8-M01`), creating a brand-new SMT account leaf locks a **refundable `500`-sat `zBTC` leaf deposit** (reclaimed on full account closure) and batches enforce a **`<= 1,000` new leaves per 6-block epoch** cap. Deterministic **slotted batcher priority** (`primary = H(btc_block_hash) mod K_batchers`, open fallback after 2 blocks) eliminates stale-root `0x02` fee burn (`R8-M02`). | |
| 107 | + | - Batch proposers post `0x02 BATCH_DA` every `~6` Bitcoin blocks carrying **complete mutated SMT leaves (`Accounts`, `RollupLocks`, cooperative `PendingExits`)** + succinct embedded proof `π_batch`. First valid `0x02` matching `R_{h-1}` in Bitcoin L1 block/tx order wins; `wtxid`-authenticated malformed batches are deterministically skipped while missing witnesses fail closed (`R8-C05`). | |
| 103 | 108 | ||
| 104 | 109 | #### Flow C — Hostile Trace 1: Bob (`1 BTC → 1 zBTC → spends 0.5 → recovers 0.5 BTC` Under `49%`–`100%` Zenon Compromise) | |
| 105 | - | 1. Bob deposits `1.0 BTC` (`{0.50, 0.25, 0.25}` vaults) → `1.0 zBTC` canonical on Bitcoin L1. | |
| 110 | + | 1. Bob deposits `1.0 BTC` (`{0.50, 0.25, 0.25}` vaults) → `1.0 zBTC` canonical on Bitcoin L1 at `K = 18` confirmations. | |
| 106 | 111 | 2. Bob spends `0.5 zBTC` feelessly on Zenon (retaining `0.5 zBTC`). Even if **`49%`–`100%` of Zenon Pillars are Byzantine**, `go-zenon` permanently splits across its 30-Momentum cliff, Dynamic Plasma spikes `100,000×`, or `SporkAddress` upgrades `go-zenon` maliciously: **no attacker can forge Bob's signature on his remaining `0.5 zBTC` or mutate `vk_STF`**. | |
| 107 | - | 3. Bob bypasses Zenon completely by broadcasting a `~150 vB` Bitcoin L1 **`0x01 FORCED_EXIT`** (`0.50 BTC → P_Bob`) creating a `546`-sat `(2M + 1)`-leaf **`ExitSlotUTXO`**. | |
| 108 | - | 4. Any `1-of-M` (`M = 3–5`) operator spends `ExitSlotUTXO` as `vin[0]` and pays **`0.50 BTC - f_op`** directly to `P_Bob` in `vout[0]` (**confirmed in ~1 Bitcoin block / ~10 minutes**). | |
| 109 | - | 5. At `K = 14`, the STARK credits `ReimbursementCredit[O_j] += 0.50 BTC`, FIFO-assigns one `0.50 BTC` vault `U_d` to `O_j`, and `O_j` claims `U_d` via `RoundTx_r → TakeTx` (`T_take = 1,152` blks, verified by `N = 7` pre-committed verifiers under `n = 8` `BitVMX` bisection). | |
| 112 | + | 3. Bob bypasses Zenon completely by broadcasting a `~150 vB` Bitcoin L1 **`0x01 FORCED_EXIT`** (`0.50 BTC → P_Bob`, `grossSats >= MIN_EXIT_SATS = 100,000` sats) creating a `546`-sat `(2M_active + 1)`-leaf **`ExitSlotUTXO`** with cyclic operator priority `k_r = (H(exitId) + r) mod M_active`. | |
| 113 | + | 4. Any `1-of-M` (`M = 3–5`) active operator spends `ExitSlotUTXO` as `vin[0]` and pays **`0.50 BTC - f_op`** directly to `P_Bob` in `vout[0]` (**confirmed in ~1 Bitcoin block / ~10 minutes**). | |
| 114 | + | 5. At `K = 18`, the STF credits `ReimbursementCredit[O_j] += 0.50 BTC`, FIFO-assigns one `0.50 BTC` vault `U_d` to `O_j` (moving `0.50 BTC` from `ReimbursementCredit` → **`AssignedObligations (A)`** so `V_unassigned + V_assigned == C + L + E + R + A + B` holds across the `1,728`-block gap!), and `O_j` claims `U_d` via `RoundTx_r → TakeTx` (`T_take = 1,728` blks, verified by `N = 7` pre-committed verifiers under `n = 8` `BitVMX` bisection, recycling `Ticket_050`). | |
| 110 | 115 | ||
| 111 | 116 | #### Flow D — Hostile Trace 2: Mike (`Alice 1 + Bob 1 → Mike 2 → recovers 0.25 BTC` When Zenon Signers Refuse to Sign) | |
| 112 | 117 | 1. Alice (`1.0 BTC`) and Bob (`1.0 BTC`) deposit into `{0.50, 0.25, 0.25}` vaults and send `2.0 zBTC` feelessly to Mike on Zenon. | |
| 113 | - | - Once anchored in `0x02 BATCH_DA`, Mike's `2.0 zBTC` has **100% Bitcoin PoW finality** (immune to 100% Zenon + 100% Alice/Bob collusion). | |
| 114 | - | - If Zenon Pillars stall or refuse to batch BEFORE `0x02` posts, Mike self-includes Alice's and Bob's raw signed transfers directly on Bitcoin L1 via **`0x03 FORCED_TRANSFER`**! *(Pre-L1-batch `~11.4s` Zenon confirmation is honestly disclosed as a soft confirmation; large receipts like `2 BTC` wait for L1 batch confirmation.)* | |
| 118 | + | - Once anchored in `0x02 BATCH_DA` at depth `K = 18`, Mike's `2.0 zBTC` has **probabilistic Bitcoin PoW finality under `<50%` honest hashrate** (immune to 100% Zenon + 100% Alice/Bob collusion; `R8-L01`). | |
| 119 | + | - If Zenon Pillars stall or refuse to batch BEFORE `0x02` posts, Mike self-includes Alice's and Bob's raw signed transfers directly on Bitcoin L1 via **`0x03 FORCED_TRANSFER`**! *(Pre-L1-batch `~11.4s` Zenon confirmation is honestly disclosed as an L1-subsidized soft confirmation; large receipts like `2 BTC` wait for L1 batch confirmation.)* | |
| 115 | 120 | 2. **Zenon signers refuse to sign everything.** Mike ignores Zenon completely and broadcasts L1 **`0x01 FORCED_EXIT`** (`0.25 BTC → P_Mike`, creating `ExitSlotUTXO`; Mike retains `1.75 zBTC`). | |
| 116 | - | 3. Any `1-of-M` (`M = 3–5`) operator spends `ExitSlotUTXO` and pays **`0.25 BTC - f_op`** directly to `P_Mike` in `vout[0]` (~10 minutes). **Alice and Bob cannot front-run or steal it; Bitcoin L1 UTXO exclusion prevents double-fronting.** | |
| 117 | - | 4. At `K = 14`, the STARK FIFO-assigns one `0.25 BTC` vault to `O_j` (the remaining `0.75 BTC` of Alice's split — `0.50 + 0.25` — stays untouched in deleted-key BitVMX vaults!). For arbitrary non-bucket exits (e.g., `0.2371 BTC` or `0.001 BTC`), `O_j` still pays the exact amount in `FrontingTx` and accumulates `ReimbursementCredit[O_j]` until hitting an available `0.25`/`0.50 BTC` vault — zero new presigning needed! | |
| 118 | - | 5. **Fee-spike & grief recovery:** If Bitcoin fees spike above `f_op`, Mike bumps `f_op` via `0x06 EXIT_FEE_BUMP` or cancels after `<288> OP_CSV` via Leaf `2M` (`EXIT_CANCEL`). If a rogue operator sweeps `ExitSlotUTXO` without paying `vout[0]`, the STARK atomically refunds `0.25 zBTC` to Mike, slashes `0.01 BTC` from the operator's `0.05 BTC` grief buffer to Mike, and auto-suspends the operator. | |
| 121 | + | 3. Any `1-of-M` (`M = 3–5`) active operator spends `ExitSlotUTXO` and pays **`0.25 BTC - f_op`** directly to `P_Mike` in `vout[0]` (~10 minutes). **Alice and Bob cannot front-run or steal it; Bitcoin L1 UTXO exclusion prevents double-fronting.** | |
| 122 | + | 4. At `K = 18`, the STF FIFO-assigns one `0.25 BTC` vault to `O_j` (moving `0.25 BTC` into `AssignedObligations (A)`; the remaining `0.75 BTC` of Alice's split — `0.50 + 0.25` — stays untouched in deleted-key BitVMX vaults!). For arbitrary non-bucket exits (`>= 0.001 BTC` = `MIN_EXIT_SATS`), `O_j` still pays the exact amount in `FrontingTx`, accumulates `ReimbursementCredit[O_j]`, and may consolidate `< 0.25 BTC` residuals via `TransferCredit(from_op, to_op, amt)` (`R8-M04`). Oldest-`PendingExit` credit priority blocks operators from jumping ahead of waiting retail exits via fresh self-fronting (`R8-N01`). | |
| 123 | + | 5. **Fee-spike & grief recovery:** If Bitcoin fees spike above `f_op`, Mike bumps `f_op` via `0x06 EXIT_FEE_BUMP` (or Dutch-auction fee schedule) or cancels after `<288> OP_CSV` via Leaf `2M_active` (`EXIT_CANCEL`, restoring `0.25 zBTC`, NOT native BTC). If a rogue operator sweeps `ExitSlotUTXO` without paying `vout[0]` (even in a concurrent `k = 20` burst!), the STF atomically refunds `100%` of `grossSats` `zBTC` to every victim, distributes up to `0.01 BTC`/victim (pro-rata capped strictly at `O_j`'s hard-partitioned `0.05 BTC` `B_grief` buffer — **zero `B_custody` overflow!**), suspends `O_j`, and excludes `O_j` from all new `ExitSlotUTXO` scripts (`R8-H01`, `R8-N05`). | |
| 119 | 124 | ||
| 120 | 125 | --- | |
| 121 | 126 | ||
| 122 | - | ## 4. Honest Threat Model, Residual Boundaries & Privileged Powers Table (`H-3` Closed) | |
| 127 | + | ## 4. Honest Threat Model, Residual Boundaries & Privileged Powers Table (`H-3`, `R8-C06`, `R8-H03`, `R8-H08`) | |
| 123 | 128 | ||
| 124 | - | **`v1` Stage 1A (`BitVMX` Rollup) is trust-minimized (`Tier 1`), NOT pure `Tier 0` (which Theorem 1 proves requires a Bitcoin soft fork — see `spec/01 Appendix A`).** Delivered security is bounded by the following explicit, un-sugarcoated assumptions: | |
| 129 | + | **`v2` Stage 1A (`BitVMX` Rollup) is trust-minimized (`Tier 1`), NOT pure `Tier 0` (which Proposition 1 proves requires a Bitcoin soft fork — see `spec/01 Appendix A`).** Delivered security is bounded by the following explicit, un-sugarcoated assumptions: | |
| 125 | 130 | ||
| 126 | 131 | 1. **Zero Zenon Consensus or ZNN Market-Cap Trust (`0-of-N` Zenon — Survives 49%–100% Zenon Compromise):** Neither Zenon Pillars, `go-zenon` DPoS/BFT, ZNN's `~25–33 BTC` market cap, nor Zenon `SporkAddress` sit in the Bitcoin custody safety or L1 forced-exit path. Zenon Plasma DoS temporarily degrades *feeless* UX to L1 BTC fees (`0x03`/`0x01`), never custody. | |
| 127 | 132 | 2. **`1-of-N` Ephemeral Setup Deletion & Open-Cohort Attestation (`N = 7` Pilot):** At least 1 of `N` presigners honestly deletes its per-deposit ephemeral share `x_{i,d}` (depositor also participates and deletes `x_{A,d}`!) AND at least 1 of `N` long-term attestation keys `id_i` remains uncompromised while a cohort is open to new deposits. Compromising all `N` `id_i` keys cannot sweep existing deleted-key vaults; losing 1 of `N` `id_i` never bricks existing vaults (only halts *new* deposits on `v1`, requiring a clean non-commingled `zBTC_v2`). | |
| 128 | - | 3. **`1-of-N` Pre-Committed Online Verifier Safety (`N = 7` Pilot, NOT `1-of-∞`):** At least 1 of `N = 7` independent pre-committed verifiers monitors Bitcoin within `[0, 144]` blks (~24h) and runs `n = 8` `BitVMX` bisection (`20` steps, `T_step = 48` blks, `~15 kvB` total verifier weight) with CPFP. Anyone on Earth can detect fraud and alert all 7 verifiers off-chain, and every honest verifier has **positive EV (`≥ +0.0167 BTC` @ `500 sat/vB`) even if `6 of 7` verifiers collude with the operator**. If ALL `7` verifiers go offline or collude simultaneously during `[0, 144]`, a cheating operator can steal `≤ 0.50 BTC`/round. | |
| 129 | - | 4. **`1-of-M` Pre-Committed Operator Exit Liveness (`M = 3–5` Pilot — Irreducible Corollary 1B Bound):** At least 1 of `M = 3–5` independent bonded operators remains online with liquid BTC to front exits. If ALL `M = 3–5` operators vanish permanently, Mike cannot self-claim on Bitcoin L1 today (`0` theft; after `288` blks Mike cancels via Leaf `2M` and retains `0.25 zBTC`, exits stalled until an operator returns). | |
| 130 | - | 5. **Sustained Dispute Fee-Rate Envelope (`≤ 500 sat/vB` for `6.7` Consecutive Days):** `F_chal = 0.40 BTC` covers `~75 kvB` Prover bisection up to `533 sat/vB` sustained across all `20` steps (`6.7` days); Verifier `~15 kvB` is covered up to `610 sat/vB` (worst-case 6-way split) / `1,000 sat/vB` (winner L1 payout). Historical peaks (`1,805 sat/vB` April 2024 lasted `~33h` ≈ 2–4 steps) fit comfortably; a hypothetical week-long `> 533 sat/vB` spike erodes honest dispute coverage. | |
| 131 | - | 6. **TVL-Scaled Private-Fork Bound (`0.50 × K × Subsidy(era) > Cap_TVL`):** Without `OP_BLOCKHASH`, each lane pins launch-time `(h_lane_init, H, D)` with `D(h) ≥ 0.50 × D(h_lane_init)` and caps TVL strictly below private-fork PoW cost (`K = 14` ⇒ `Cap_TVL ≤ 15 BTC`; `K = 36` ⇒ `≤ 50 BTC`; `K = 144` ⇒ `≤ 200 BTC`). | |
| 132 | - | 7. **Bank-Run Recycling Queue (`~65–72` Days for 100% Run at `M = 3–5, L = 1`):** While individual exits front in ~10m up to available operator float (`2.20–3.00 BTC`), a 100% bank run recycles at `0.111 BTC/day` (`M = 3`, `~72d` for `10 BTC`) or `0.185 BTC/day` (`M = 5`, `~65d` for `15 BTC`) under `{0.50, 0.25, 0.25}` vaults (or `~47d`/`~43d` under `{0.50, 0.50}` vaults). | |
| 133 | - | 8. **Stage 1B (`clArk`) Alternative Assumptions (If Chosen Instead):** Zero operator bonds and pure `0-of-N` post-round unilateral exit until VTXO expiry, BUT sacrifices pooled fungible `zBTC`, carries hard VTXO expiry (`log2(N)` L1 branch exit fees), requires `100%` ASP liquidity per cycle, and exposes pre-round `arkoor` transfers to `sender + ASP` collusion. | |
| 133 | + | 3. **`1-of-N` Pre-Committed Online Verifier Safety (`N = 7` Pilot, NOT `1-of-∞`):** At least 1 of `N = 7` independent pre-committed verifiers monitors Bitcoin within `[0, 144]` blks (~24h) and runs `n = 8` `BitVMX` bisection (`20` steps, `T_step = 72` blks, `16.53 kvB` total verifier weight incl. `10 × 153 vB` P2A CPFP on Bitcoin Core `>= 29.0` + direct-to-miner backup). Anyone on Earth can detect fraud and alert all 7 verifiers off-chain, and every active honest verifier receives **`0.15 BTC` in native Bitcoin L1 BTC directly from `Stake_r` (`0%` `zBTC` crisis discount!)**, yielding **`+0.0645 BTC` net EV @ `500 sat/vB`** (`+0.0232 BTC` even @ `750 sat/vB`, break-even `890 sat/vB`, after CPFP and `0.00285 BTC` lockup) even if `6 of 7` verifiers collude with the operator. If ALL `7` verifiers go offline or collude simultaneously during `[0, 144]`, a cheating operator can steal `≤ 0.50 BTC`/round. Simultaneous `M`-operator attacks require `0.483 BTC/lane` (`1.45 / 2.41 BTC`) of liquid standby in at least 1 honest verifier (`R8-H02`). | |
| 134 | + | 4. **`1-of-M` Pre-Committed Operator Exit Liveness (`M = 3–5` Pilot — Irreducible Corollary 1B Bound, `R8-C06`):** Stage 1A vaults carry **no CLTV expiration**, but native Bitcoin L1 recovery strictly requires at least `1-of-M` active eligible operators (`opBitmask` satisfying Hall's Marriage Invariant) with liquid BTC to front exits. **If `0-of-M` operators remain permanently offline (`100%` permanent disappearance), native BTC remains permanently unrecoverable on Bitcoin Mainnet today** (`0` theft; `EXIT_CANCEL` after `288` blocks restores `zBTC` inside the rollup, **NOT** native BTC on L1). This is an irreducible no-covenant boundary (Proposition 1). | |
| 135 | + | 5. **Sustained Dispute Fee-Rate Envelope (`≤ 500 sat/vB` for `10.0` Consecutive Days on Core `>= 29.0`):** `F_chal = 0.40 BTC` covers `76.53 kvB` Prover bisection (incl. `10 × 153 vB` P2A CPFP) up to `522 sat/vB` sustained across all `20` steps (`10.0` days); Verifier `16.53 kvB` is covered in native L1 BTC (`0.15 BTC`) up to **`890 sat/vB`** after lockup cost. Historical peaks (`1,805 sat/vB` April 2024 lasted `~33h` ≈ 2–3 steps) fit comfortably; a hypothetical 10-day `> 522 sat/vB` spike erodes honest prover coverage. | |
| 136 | + | 6. **Probabilistic PoW Finality & Conditional Private-Fork Heuristic (`K >= 18`, `R8-H03`, `R8-M07`, `R8-L01`):** Depth `K >= 18` provides **probabilistic PoW finality under `<50%` honest hashrate** (NOT absolute finality). The inequality `0.50 × K × Subsidy(era) > Cap_TVL_total` (`Cap_user + M × B_zbtc`) is explicitly an **unpublished-fork opportunity-cost heuristic** (under Budish's winning-fork subsidy offset, a majority-hashrate attacker publishing the winning chain recaptures subsidies and pays net flow/hardware cost `κ × K × Subsidy` plus external BTC-devaluation cost). Each lane pins `(h_lane_init, H, D)` with `D(h) ≥ 0.50 × D(h_lane_init)`, supports **interactive heaviest-chainwork competing-header comparison** inside `vk_STF`, and enforces a fail-closed **`DEEP_REORG_HALT`** circuit breaker with `>= 144`-block rollback snapshots if a `>= K` reorg ever occurs. | |
| 137 | + | 7. **Immutable `vk_STF` Bug Risk (`R8-H08`):** Because `vk_STF` is immutable on existing vaults (zero governance override), a soundness or completeness bug in `vk_STF` could freeze or threaten active vaults. Mitigated strictly BEFORE mainnet via formal verification & Bitcoin Core differential fuzzing (Gate G4), graduated TVL ramps (`2 → 5 → 15 BTC`), and a non-custodial voluntary unwind circuit breaker (`spec/01 §6.3`). | |
| 138 | + | 8. **Bank-Run Recycling Queue (`~94–104` Days for 100% Run at `M = 3–5, L = 1`, `T_cooldown = 13.0d`):** While individual exits front in ~10m up to available operator float (`2.20–3.00 BTC`), a 100% bank run recycles at `0.077 BTC/day` (`M = 3`, `~101–104d` for `10 BTC` user cap) or `0.128 BTC/day` (`M = 5`, `~94–104d` for `15 BTC` user cap) under `{0.50, 0.25, 0.25}` vaults (or `~62–68d` under `{0.50, 0.50}` vaults). Oldest-`PendingExit` credit priority blocks self-fronting queue jumping (`R8-N01`), while secondary-market `zBTC` discounting during prolonged queues remains an explicit economic risk. | |
| 139 | + | 9. **Stage 1B (`clArk`) Alternative Assumptions (If Chosen Instead):** Zero operator bonds and pure `0-of-N` post-round unilateral exit until VTXO expiry, BUT sacrifices pooled fungible `zBTC`, carries hard VTXO expiry (`log2(N)` L1 branch exit fees, requiring watchtower refresh), requires `100%` ASP liquidity per cycle, and exposes pre-round `arkoor` transfers to `sender + ASP` collusion. | |
| 134 | 140 | ||
| 135 | 141 | ### 4.1 Complete Privileged Powers Table (`H-3` Closed — ZERO Custodial Authority) | |
| @@ -137,41 +143,41 @@ | |||
| 137 | 143 | | Power / Action | Holder | Threshold | Timelock | Maximum Effect / Blast Radius on Stage 1A BTC Custody | | |
| 138 | 144 | |---|---|---|---|---| | |
| 139 | - | | **Spend Existing Stage 1A BTC Vaults (`U_d`)** | **NOBODY (ephemeral `Q_setup_d` deleted)** | N/A | N/A | **0 sats custodial sweep power.** Spendable ONLY via pre-signed `TakeTx` after `T_take = 1,152` blks subject to `N = 7` `BitVMX` verifiers + Lamport equivocation slash. | | |
| 140 | - | | **Mutate Rollup STF Rules (`vk_STF`) on Existing Vaults** | **NOBODY (`vk_STF` hard-pinned at `t = 0`)** | N/A | N/A | **0 effect.** No Zenon spork, governance vote, or operator can alter STF rules on existing vaults. | | |
| 145 | + | | **Spend Existing Stage 1A BTC Vaults (`U_d`)** | **NOBODY (ephemeral `Q_setup_d` deleted)** | N/A | N/A | **0 sats custodial sweep power.** Spendable ONLY via pre-signed `TakeTx` after `T_take = 1,728` blks subject to `N = 7` `BitVMX` verifiers + Lamport equivocation slash. | | |
| 146 | + | | **Mutate Rollup STF Rules (`vk_STF`) on Existing Vaults** | **NOBODY (`vk_STF` hard-pinned at `t = 0`)** | N/A | N/A | **0 effect.** No Zenon spork, governance vote, or operator can alter STF rules on existing vaults (see `spec/01 §6.3` for non-custodial voluntary unwind circuit breaker). | | |
| 141 | 147 | | **Voluntary Cohort Handover (Same `vk_STF` Only)** | Cohort 1 Presigners (`id_1..id_N`) | **`N`-of-`N` (`7-of-7`)** | None (new deposits only) | Strictly `1-of-N` safe; cannot touch existing vaults. Involuntary `1-of-N` loss halts new `v1` deposits cleanly (`zBTC_v2` required). | | |
| 142 | 148 | | **Zenon Protocol Sporks (`CreateSpork`, `ActivateSpork`, `SetPlasmaVariables`)** | `SporkAddress` (`z1qpxsw...`) / `CommunitySporkAddress` (`z1qqvwz...`, window heights `14,567,887–19,791,986`, `origin/dev:vm/embedded/definition/spork.go`) → future `GovernanceContract` | `1-of-1` today | `SporkMinHeightDelay = 6` Momentums (node layer) | **0 BTC custody blast radius in Stage 1A.** Can disrupt feeless Zenon sequencing or Stage 0 embedded SPV contract, but **cannot steal 1 satoshi from BitVMX vaults or censor L1 `0x01`/`0x03` exits**. *(Stage 0 pins full `SetPlasmaVariables` floor in `spec/05`.)* | | |
| 143 | - | | **Operator Fronting & Reimbursement Claim (`O_1..O_M`)** | Independent Bonded Operators (`M = 3–5` pilot) | `1-of-M` for exit liveness | `T_take = 1,152` blks; `T_cooldown = 1,296` blks | **Zero theft power** under `1-of-N` verifier honesty (`-1.94` to `-2.55 BTC` net loss on fraud: `-2.55 BTC` solo, `-2.40` to `-1.9417 BTC` with `1..6` colluders); all `M` vanishing stalls exits (`0` principal loss). | | |
| 144 | - | | **BitVMX Fraud Challenge (`V_1..V_7`)** | Independent Pre-Committed Verifiers (`N = 7`) | **`1-of-7`** | `[0, 144]` blks open; `T_step = 48` blks | Any 1 honest verifier stops fraud, collects `≥ +0.0167` to `+0.075 BTC` net profit, and burns `1.85 BTC` of rogue operator's bond. | | |
| 149 | + | | **Operator Fronting & Reimbursement Claim (`O_1..O_M`)** | Independent Bonded Operators (`M = 3–5` pilot) | `1-of-M` for exit liveness | `T_take = 1,728` blks; `T_cooldown = 1,872` blks | **Zero theft power** under `1-of-N` verifier honesty (`-2.00` to `-1.10 BTC` L1 loss alone; `-2.55` to `-1.65 BTC` incl. `B_custody` across `k_collude = 0..6`); permanent `0-of-M` disappearance permanently stalls native BTC exits (`0` theft; `EXIT_CANCEL` restores `zBTC` only). | | |
| 150 | + | | **BitVMX Fraud Challenge (`V_1..V_7`)** | Independent Pre-Committed Verifiers (`N = 7`) | **`1-of-7`** | `[0, 144]` blks open; `T_step = 72` blks | Any 1 honest verifier stops fraud, collects **`0.15 BTC` native L1 BTC** directly from `Stake_r` (`+0.0645 BTC` net EV @ `500 sat/vB`, `+0.0232 BTC` @ `750 sat/vB` after CPFP & lockup), and forces `0.95–1.85 BTC` L1 burn. | | |
| 145 | 151 | ||
| 146 | 152 | --- | |
| 147 | 153 | ||
| 148 | - | ## 5. Reference `go-zenon` Ground-Truth Baseline (`M-3`, `B1`, `B2`, `L-3`) | |
| 154 | + | ## 5. Reference `go-zenon` Ground-Truth Baseline (`M-3`, `B1`, `B2`, `L-3`, `R8-M08`) | |
| 149 | 155 | ||
| 150 | - | - **Verified Local Clone:** `master` (`e8986a6`, `v0.0.10-alphanet`) and `origin/dev` (`770e893`, carrying `DynamicPlasmaSpork`, `PtlcSpork`, `Libp2pSpork`). *(Note: upstream fix `0aa299e` is not present in the local git clone and remains an explicit Stage 0 upstream release gate.)* | |
| 151 | - | - **Stage 0 Hard Preconditions (`spec/05`):** (1) First tagged `go-zenon` release containing `0aa299e`; (2) upstream issue `#239` deterministic failed-receive closure (`B1`); (3) `DynamicPlasmaSpork` enforced with **complete `SetPlasmaVariables` pinning** (`MaxBasePlasmaInMomentum >= 2,100,000`, `MaxPriceChangePercent <= 25%`, PLUS lower bounds on `FusedPlasmaTarget >= 525,000`, `PowPlasmaTarget >= 525,000`, and `PriceChangeDenominator >= 8`, preventing exponential Dynamic Plasma lockout); (4) `PtlcSpork` active. | |
| 156 | + | - **Verified Local Clone:** `master` (`e8986a6`, `v0.0.10-alphanet`, live mainnet `v1` Momentums capped at `100` blocks/Momentum) and `origin/dev` (`770e893`, carrying `DynamicPlasmaSpork`, `PtlcSpork`, `Libp2pSpork`). *(Note: upstream commit `0aa299e`, `PTLC PR #138` mainnet merge/spork activation, and open issues `#239`, `#299`, and `#312` are NOT yet active on `go-zenon` mainnet and remain explicit Stage 0 upstream release gates — Gate G6.)* | |
| 157 | + | - **Stage 0 Hard Preconditions (`spec/05`):** (1) First tagged mainnet `go-zenon` release containing `0aa299e`; (2) closure of upstream issues **`#239`** (FIFO panic-stall deterministic failed receive, **B1**), **`#299`**, and **`#312`**; (3) mainnet merge & activation of **`PTLC PR #138`** (`PtlcSpork`) and **`DynamicPlasmaSpork`** with **complete 5-parameter `SetPlasmaVariables` pinning** (`MaxBasePlasmaInMomentum >= 2,100,000`, `MaxPriceChangePercent <= 25%`, `FusedPlasmaTarget >= 525,000`, `PowPlasmaTarget >= 525,000`, `PriceChangeDenominator >= 8`). | |
| 152 | 158 | - **Stage 1A / 1B Zero-Hard-Fork Property:** Stage 1A Rollup nodes read standard Zenon `AccountBlock.Data` and Bitcoin L1 — requiring **zero `go-zenon` consensus hard fork** beyond Stage 0. | |
| 153 | 159 | ||
| 154 | 160 | --- | |
| 155 | 161 | ||
| 156 | - | ## 6. Upstream Amendment Register (`v1` Zero-Federation Scope) | |
| 162 | + | ## 6. Upstream Amendment Register (`v2` Zero-Federation Scope) | |
| 157 | 163 | ||
| 158 | - | | ID | Upstream Target | Status in `v1` | Normative Requirement | | |
| 164 | + | | ID | Upstream Target | Status in `v2` | Normative Requirement | | |
| 159 | 165 | |---|---|---|---| | |
| 160 | - | | **A-SPEC-1, A-SPEC-2, A-SPEC-6** | `Project Zeno` optimistic bridge framework | **Not required in `v1`** | Stage 0 uses direct Event-Validity SPV; Stage 1A uses Bitcoin-L1-canonical ZK validity (`0x00`..`0x07`). | | |
| 161 | - | | **A-SPEC-4** | Deterministic Exit ID | **Required (`Stage 1A`)** | `exitId = SHA256("ZBTX_EXIT_V1" \|\| bitcoinTxid \|\| voutOrIdx \|\| nonce)` derived deterministically on Bitcoin L1. | | |
| 162 | - | | **A-BTC-1** | Bitcoin Refund / Exclusion Rules | **Required (`Stage 1A`)** | Refunds enforced strictly by Bitcoin L1 UTXO exclusion (`ExitSlotUTXO` spend-or-refund rule) — zero timeout-vs-fronting double-pay races (`M-8`). | | |
| 163 | - | | **A-MINT-1** | `TokenContract.IssueMinted` | **Retired in `v1`** | Stage 1A `zBTC` balances live in the Bitcoin-canonical Rollup SMT (NOT pre-minted inside a Zenon embedded contract, eliminating `H-8` entirely!). | | |
| 164 | - | | **A-PILLAR-1** | `go-zenon` `pillars.go` BLS12-381 & 72d lock | **Not required in `v1`** | Zenon consensus & Pillar committees are removed from BTC custody completely (`spec/04`). | | |
| 166 | + | | **A-SPEC-1, A-SPEC-2, A-SPEC-6** | `Project Zeno` optimistic bridge framework | **Not required in `v2`** | Stage 0 uses direct Event-Validity SPV; Stage 1A uses Bitcoin-L1-canonical ZK validity (`0x00`..`0x07`). | | |
| 167 | + | | **A-SPEC-4** | Deterministic Exit ID | **Required (`Stage 1A`)** | `exitId = SHA256("ZBTX_EXIT_V1" \|\| bitcoinTxid \|\| voutOrIdx \|\| nonce)` derived deterministically on Bitcoin L1; priority sequence uses cyclic permutation `k_r = (H(exitId) + r) mod M_active`. | | |
| 168 | + | | **A-BTC-1** | Bitcoin Refund / Exclusion Rules | **Required (`Stage 1A`)** | Refunds enforced strictly by Bitcoin L1 UTXO exclusion (`ExitSlotUTXO` spend-or-refund rule) — zero timeout-vs-fronting double-pay races (`M-8`), hard-partitioned `B_grief` (`0.05 BTC`), and active-operator-only Taproot trees (`R8-H01`). | | |
| 169 | + | | **A-MINT-1** | `TokenContract.IssueMinted` | **Retired in `v2`** | Stage 1A `zBTC` balances live in the Bitcoin-canonical Rollup SMT (NOT pre-minted inside a Zenon embedded contract, eliminating `H-8` entirely!). | | |
| 170 | + | | **A-PILLAR-1** | `go-zenon` `pillars.go` BLS12-381 & 72d lock | **Not required in `v2`** | Zenon consensus & Pillar committees are removed from BTC custody completely (`spec/04`). | | |
| 165 | 171 | ||
| 166 | 172 | --- | |
| 167 | 173 | ||
| 168 | - | ## 7. Phased Delivery, Capital Decision Gates & Zero-Dead-End Growth (`M-15`) | |
| 174 | + | ## 7. Phased Delivery, Capital Decision Gates & Zero-Dead-End Growth (`M-15`, `R8-H08`, `R8-M09`) | |
| 169 | 175 | ||
| 170 | - | | Stage | Timeline & Hard-BTC Capital | Normative Scope & Blocking Exit Criteria | Zero-Dead-End Migration Guarantee | | |
| 176 | + | | Stage | Timeline & Full Hard-BTC Capital | Normative Scope & Blocking Exit Criteria | Zero-Dead-End Migration Guarantee | | |
| 171 | 177 | |---|---|---|---| | |
| 172 | - | | **Stage 0 (Mandatory Foundation — Verify Bitcoin)** | **`0–6 months`**, **`0 BTC` bridge custody risk** (`0–5 BTC` voluntary LP) | Ship `go-zenon` prerequisites (`0aa299e`, `#239`, full `SetPlasmaVariables` pinning, `PtlcSpork`), **Direct-on-L1 Bitcoin SPV Event Oracle** (1-/2-block coinbase midstate, `≤ 24` storage ops, `dp.MaxContractBlocks = 40`), and **non-custodial PTLC/LN atomic swaps** (`2.3×` slow-block safe). Build & test the Rollup stripped-block STARK + `BitVMX-CPU` (`RV32IM` `n=8`) stack on Signet. | Zero custodial BTC at risk while proving every Rollup + `BitVMX` primitive on Signet. | | |
| 173 | - | | **Stage 1A (Primary Path — Right-Sized `BitVMX` Rollup)** | **`12–18+ months` (incl. audit, 4–6 engineers)**; **`12.8 BTC`** (`M=3, N=7, ≤ 10 BTC` TVL) or **`18.8 BTC`** (`M=5, N=7, ≤ 15 BTC` TVL) *(≈ `40–75%` of ZNN's `~25–33 BTC` mcap)* | **Hard Entry Gates:** (1) Full Signet drill of `DepositTx`, `0x01–0x07`, `ExitSlotUTXO` (fronting, grief slash, cancel), `RoundTx → TakeTx` (Lamport equivocation slash), and `n=8` `BitVMX` 20-step TRUC v3 bisection (verifying measured weights `≤ 7.44 kvB`/tx); (2) independent third-party cryptography & Bitcoin-Script audit (**M-15**); (3) committed independent operator + verifier hard BTC (`2.60 BTC`/lane + `0.40 BTC`/verifier). *Pre-mainnet maturity of `BitVMX-CPU` explicitly disclosed.* | Deleted-key vaults NEVER expire and stay 100% redeemable 1:1 via `0x01 FORCED_EXIT` to native BTC L1. | | |
| 174 | - | | **Stage 1B (Explicit Alternative Gate — `clArk`)** | **`3–6 months`**, **`2–5 BTC`** active ASP liquidity (`0` bonds) | **Trigger:** Choose Stage 1B ONLY if the ecosystem cannot commit `~12.8–18.8 BTC` of non-yielding hard BTC OR prioritizes `3–6 mo` launch / `0-of-N` post-round exit over pooled fungibility. Deploy `Second bark` / `Ark Labs arkd` + Zenon SPV/PTLC (`spec/01 §7`, `spec/03 §3`). Do **NOT** under-bond `BitVMX`/`BitVM2`. | Users hold self-custodial expiring VTXOs with unilateral L1 exit; explicitly non-commingled with any future Rollup `zBTC`. | | |
| 175 | - | | **Stage 2 (Zero-TTP Scale & Upgrade)** | **`12+ months` post-Stage 1** (`15–200+ BTC` TVL, or unlimited w/ soft fork) | **(a) Same-STF `BitVMX` scaling (`M=5→20, L=1→4, K=36→144`):** strictly via pre-planned **`N`-of-`N` Cohort 1 voluntary handover** (zero governance key). **(b) Custody backend upgrades (`BitVM3-GC` / `BitVM2` / Appendix A Track B Pure Tier-0 `OP_CCV` or `OP_CAT` Covenant):** ALWAYS launch a clean, non-commingled `zBTC_v2` reusing the open-source Rollup STF codebase. | Zero deleted-key L1 rollover needed; Stage 1A vaults drain organically 1:1 to native BTC via `0x01` exits. | | |
| 178 | + | | **Stage 0 (Mandatory Foundation — Verify Bitcoin)** | **`0–6 months`**, **`0 BTC` bridge custody risk** (`0–5 BTC` voluntary LP) | Ship `go-zenon` Gate G6 (`0aa299e`, `#239`/`#299`/`#312`, mainnet `PR #138` & `DynamicPlasmaSpork` 5-param pin), **Direct-on-L1 Bitcoin SPV Event Oracle** (`len(strippedTx) >= 65`, 1-/2-block coinbase midstate, `≤ 24` storage ops, `dp.MaxContractBlocks = 40`), and **Erlang-hardened non-custodial PTLC (`T_znn >= 48h`, block-72 RBF watchtower) / LN HTLC (`Δ_safety >= 24h`) swaps**. Build & benchmark Rollup STF + wrapped SNARK verifier on `BitVMX-CPU` (`RV32IM`) and evaluate BitVM3-GC on Signet. | Zero custodial BTC at risk while proving every Rollup + `BitVMX` primitive on Signet. | | |
| 179 | + | | **Stage 1A (Primary Path — Right-Sized `BitVMX` Rollup)** | **`12–18+ months` (incl. audit, 4–6 engineers)**; **Locked:** `12.80` (`M=3`) / `18.80 BTC` (`M=5`); **Operational Baseline (1 dispute):** **`14.75`** (`45–59%` ZNN mcap) / **`21.25 BTC`** (`64–85%` ZNN mcap); **Multi-dispute headroom:** `~17–26+ BTC` (`spec/01 §6`) | **Hard Entry Gates G1–G5 + M-15:** (G1) Bitcoin Core `>= 29.0` (`v31.0` preferred) `regtest`/`signet` full graph execution incl. `AdmissionTicketUTXO` & `153 vB` P2A 1P1C CPFP; (G2) compiled `RV32IM` wrapped-SNARK verifier ELF proving `init_steps + exec_steps <= 0.5 × 8^9` (else `l = 10` or BitVM3 evaluation); (G3) extended `verify_spec_bounds.py` clean; (G4) formal verification of `V=C+L+E+R+A+B`, $2^M$ Hall, & BIP-141 completeness + Bitcoin Core differential fuzzing; (G5) `zbtc-vault-bundle-v1` disaster-recovery drill; (M-15) independent third-party audit; **Graduated TVL ramps:** **`2 BTC` (90d) → `5 BTC` (90d) → `10/15 BTC`**. | Non-expiring deleted-key vaults stay redeemable 1:1 via `0x01 FORCED_EXIT` subject to `1-of-M` operator liveness (plus voluntary unwind circuit breaker in `spec/01 §6.3`). | | |
| 180 | + | | **Stage 1B (Explicit Alternative Gate — `clArk`)** | **`3–6 months`**, **`2–5 BTC`** active ASP liquidity (`0` bonds) | **Trigger:** Choose Stage 1B ONLY if the ecosystem cannot commit `~14.75–21.25+ BTC` of non-yielding hard BTC OR prioritizes `3–6 mo` launch / `0-of-N` post-round exit over pooled fungibility. Deploy `Second bark` / `Ark Labs arkd` + automated watchtowers + Zenon SPV/PTLC (`spec/01 §7`, `spec/03 §3`). Do **NOT** under-bond `BitVMX`/`BitVM2`. | Users hold self-custodial expiring VTXOs with unilateral L1 exit; explicitly non-commingled with any future Rollup `zBTC`. | | |
| 181 | + | | **Stage 2 (Zero-TTP Scale & Upgrade)** | **`12+ months` post-Stage 1** (`15–200+ BTC` TVL, or unlimited w/ soft fork) | **(a) Same-STF `BitVMX` scaling (`M=5→20, L=1→4, K=42→144`):** strictly via pre-planned **`N`-of-`N` Cohort 1 voluntary handover** (zero governance key). **(b) Custody backend upgrades (`BitVM3-GC` / `BitVM2` / Appendix A Track B Pure Tier-0 `OP_CCV` or `OP_CAT` Covenant):** ALWAYS launch a clean, non-commingled `zBTC_v2` reusing the open-source Rollup STF codebase. | Zero deleted-key L1 rollover needed; Stage 1A vaults drain organically 1:1 to native BTC via `0x01` exits. | | |
| 176 | 182 | ||
| 177 | 183 | --- | |
| @@ -186,35 +192,36 @@ | |||
| 186 | 192 | ## 9. Public Claims Alignment (`bigidea` Synchronization) | |
| 187 | 193 | ||
| 188 | - | All public materials (including [`btc-moonshot.github.io/bigidea`](https://btc-moonshot.github.io/bigidea/)) MUST match `v1` verbatim: | |
| 194 | + | All public materials (including [`btc-moonshot.github.io/bigidea`](https://btc-moonshot.github.io/bigidea/)) MUST match `v2` (`v3.1.0-rfc`) verbatim: | |
| 189 | 195 | ||
| 190 | - | | Outdated Public Claim (`v0` / `bigidea`) | Accurate `v1` (`v3.0.0-rfc`) Statement | | |
| 196 | + | | Outdated Public Claim (`v0` / `v1` / `bigidea` errata) | Accurate `v2` (`v3.1.0-rfc`) Statement | | |
| 191 | 197 | |---|---| | |
| 192 | - | | "The network never holds a pooled key" | **True in `v1` for existing vaults:** per-deposit ephemeral keys `Q_setup_d` are permanently deleted at deposit (with zero custodial federation). **Honest disclosure:** Stage 1A still relies on `1-of-N` (`N=7`) open-cohort deposit attestation + `1-of-N` pre-committed online `BitVMX` verifiers + `1-of-M` (`M=3–5`) bonded fronting operators. Pure `0-of-N` unilateral exit requires a Bitcoin soft fork (`spec/01 Appendix A`). | | |
| 193 | - | | "One honest watcher can stop a bad payout" | **Clarified for Stage 1A:** Any **`1-of-7` pre-committed online `BitVMX` verifier** can stop a bad payout with positive EV (`≥ +0.0167 BTC` @ `500 sat/vB`), and anyone on Earth can detect fraud and relay it to all 7 verifiers. (`1-of-∞` permissionless BitVM2 requires `~45–100+ BTC` even at `M=3–5` and is unaffordable for a young project.) | | |
| 194 | - | | Proofs "end at Bitcoin's proof-of-work" | **True in Stage 1A:** Canonical `zBTC` state ordering, DA (`0x02`), and forced exits (`0x01`/`0x03`) are anchored directly on Bitcoin PoW with `0%` Zenon consensus trust (bounded by TVL-scaled `K` against private PoW forks). | | |
| 195 | - | | "Security is funded by the network's own staking token" | **False — explicitly rejected.** ZNN (`~25–33 BTC` total market cap) is **0% in the BTC custody safety path**; all operator/verifier collateral is hard BTC. | | |
| 196 | - | | "Millions of transactions per second"; per-second streams | Zenon Dynamic Plasma at `~11.4s`/Momentum provides `~4.4` base transfers/s at the `2.1M` floor, `~8.8` tx/s at default `4.2M`, and a **real hard ceiling of `~1,050–1,200` tx/s** under `go-zenon`'s `8 MiB` `MaxMomentumContentBytes` cap (NOT `4,386` tx/s). Stage 1A rollup txs use `AccountBlock.Data` (`~28,480` Plasma, `~11.4s` soft confirmation, Bitcoin L1 finality on `0x02` batch anchor). | | |
| 197 | - | | "0 satoshi fees" | **0 satoshi BTC fee for Stage 1A feeless rollup transfers on Zenon** (costing `~28,480` refundable QSR/PoW Plasma; NOT native ZTS). Deposits, L1 forced exits (`0x01`), and fronting spreads pay Bitcoin L1 fees; under Zenon Plasma DoS, users bypass Zenon via Bitcoin L1 fees. | | |
| 198 | - | | "Oracle verified" | **Consistency-checked** via `scripts/verify_spec_bounds.py` against `SOURCED_`, `POLICY_`, and `PRE_MAINNET_TARGET_` inputs; not empirically audited until Stage 0/1A Signet & third-party audit gates pass. | | |
| 199 | - | | Omission of Zenon / ZNN / QSR / Pillars | Public pages MUST explicitly name **Zenon Network, ZNN, QSR, and Pillars**, and disclose `BitVMX-CPU`'s pre-mainnet status (`12–18+ mo` timeline) and `~65–72d` 100% bank-run exit queue. | | |
| 198 | + | | "The network never holds a pooled key" / "100% live forever" | **True in `v2` for existing vault spend keys:** per-deposit ephemeral keys `Q_setup_d` are permanently deleted at deposit (with zero custodial federation). **Honest disclosure (`R8-C06`):** Stage 1A vaults carry *no CLTV expiration*, but native BTC recovery requires `1-of-M` (`M = 3–5`) active eligible operators (`0-of-M` permanent disappearance permanently locks native BTC; `EXIT_CANCEL` restores `zBTC` only), plus `1-of-N` (`N = 7`) open-cohort attestation and `1-of-7` pre-committed online `BitVMX` verifiers. Pure `0-of-N` unilateral exit requires a Bitcoin soft fork (`spec/01 Appendix A`). | | |
| 199 | + | | "One honest watcher can stop a bad payout" | **Clarified for Stage 1A:** Any **`1-of-7` pre-committed online `BitVMX` verifier** can stop a bad payout with positive native-L1 EV (**`+0.0645 BTC` @ `500 sat/vB`**, **`+0.0232 BTC` @ `750 sat/vB`** after CPFP & lockup), and anyone on Earth can detect fraud and relay it to all 7 verifiers. (`1-of-∞` permissionless BitVM2 requires `~40–91+ BTC` in bonds even at `M=3–5`.) | | |
| 200 | + | | Proofs "end at Bitcoin's proof-of-work" / "100% Bitcoin PoW finality" | **Clarified (`R8-L01`):** Canonical `zBTC` state ordering, DA (`0x02`), and forced exits (`0x01`/`0x03`) are anchored directly on Bitcoin PoW with `0%` Zenon consensus trust, delivering **probabilistic PoW finality at depth `K >= 18` under `<50%` honest hashrate** (subject to conditional unpublished-fork heuristic and interactive heaviest-chainwork dispute verification). | | |
| 201 | + | | "Security is funded by the network's own staking token" | **False — explicitly rejected.** ZNN (`~25–33 BTC` total market cap) is **0% in the BTC custody safety path**; all operator/verifier collateral and operational reserves (`14.75–21.25+ BTC`) are hard BTC. | | |
| 202 | + | | "Millions of transactions per second"; per-second streams | Zenon Dynamic Plasma (`~11.4s`/Momentum) provides `~4.4`/`8.8` 2-blk tx/s, `~6.5`/`12.9` 1-blk rollup sends/s (`2.1M`/`4.2M`), and a **`~1,050–1,200` tx/s `8 MiB` Zenon transport ceiling** — strictly bounded for L1-anchored settlement by **Bitcoin L1's `0x02` physical DA ceiling (`~166.7` blended `10 vB` leaves/s at 100% of Bitcoin blockspace; `~1.67` leaves/s at 1%)** (`R8-M08`). | | |
| 203 | + | | "0 satoshi fees" / unbounded free transfers | **L1-subsidized soft preconfirmations (`0` sat direct user BTC fee on Zenon `AccountBlock.Data`, costing `28,480` refundable QSR/PoW Plasma; NOT native ZTS).** Creating a brand-new SMT account locks a refundable `500`-sat `zBTC` leaf deposit (`<= 1,000` new leaves/6-block epoch) to bound `0x02` L1 DA spam (`R8-M01`). Deposits, L1 forced exits (`0x01`), and fronting spreads pay Bitcoin L1 fees. | | |
| 204 | + | | "Oracle verified" | **Consistency-checked** via `scripts/verify_spec_bounds.py` against `SOURCED_`, `POLICY_`, and `PRE_MAINNET_TARGET_` inputs; not empirically audited until Gates G1–G6 & M-15 pass. | | |
| 205 | + | | Omission of Zenon / ZNN / QSR / Pillars / Core `>= 29.0` | Public pages MUST explicitly name **Zenon Network, ZNN, QSR, and Pillars**, pin **Bitcoin Core `>= 29.0` (`v31.0` preferred)**, and disclose `BitVMX-CPU`'s pre-mainnet status (`12–18+ mo` timeline), `14.75–21.25+ BTC` full operational capital, and `~94–104d` 100% bank-run exit queue (`T_cooldown = 13.0d`). | | |
| 200 | 206 | ||
| 201 | 207 | --- | |
| 202 | 208 | ||
| 203 | - | ## 10. Written Answers to Consolidated Hostile Review (`R7`) | |
| 209 | + | ## 10. Written Answers to Consolidated Hostile Review (`R8`) & Historical `R7` Summary | |
| 204 | 210 | ||
| 205 | - | Every `R7` question against `v0` is answered normatively in `v1` without resorting to federated multisigs (full table in [`CHANGELOG.md`](./CHANGELOG.md)): | |
| 211 | + | Every one of the 12 mandatory questions raised in [`R8 §24`](./reviews/HOSTILE_REVIEW_R8_CONSOLIDATED.md) against archived `v1 (v3.0.0-rfc)` is answered normatively in `v2 (v3.1.0-rfc)` (with zero federated multisigs; full 27-finding `R8` + 31-finding `R7` disposition tables live in [`CHANGELOG.md`](./CHANGELOG.md)): | |
| 206 | 212 | ||
| 207 | - | - **C-1 (ZNN/BTC forging price):** *Closed by removal.* `0%` ZNN in BTC safety; all `BitVMX` bonds (`2.60 BTC`/lane) and verifier escrows (`0.40 BTC`) are hard BTC. | |
| 208 | - | - **C-2 (Honest BLS certs over dishonest Zenon state):** *Closed by removal.* BLS Pillar committees and optimistic Zenon batches are deleted; Stage 1A verifies an immutable Bitcoin-anchored ZK validity rollup (`vk_STF`, `0-of-N` Zenon trust). | |
| 209 | - | - **C-3 (BitVM2 4.4–10× under-costed assert/disprove):** *Resolved by architecture switch.* Groth16 BitVM2 (`~1.0–1.3M vB`, `~45–100+ BTC` min bonds) is replaced with `n = 8` `BitVMX-CPU` (`RV32IM`) bisection (`~7.44 kvB`/tx TRUC v3, `~75 kvB` Prover / `~15 kvB` Verifier, `12.8–18.8 BTC` total pilot capital). | |
| 210 | - | - **C-4 (Never-deleted `N`-of-`N` `Q_graph`):** *Closed.* Because `vk_STF` never rotates with PoS epochs, vault graphs never expire; ephemeral `Q_setup_d` and `Q_lane` keys are **permanently deleted** after setup. Zero custodial multisigs. | |
| 211 | - | - **H-1 & H-2 (Free-delegation capture & 10-seat cert withholding):** *Closed by removal.* No Pillar finality committee exists in BTC custody. | |
| 212 | - | - **H-3 (Upgrade & Plasma authority = custody authority):** *Closed.* `vk_STF` is hard-pinned on Bitcoin L1 (`SporkAddress` has `0` BTC custody blast radius); Stage 0 pins all `SetPlasmaVariables` fields (`spec/05`); full Privileged Powers Table in §4.1. | |
| 213 | - | - **H-4 (Altruistic watcher `-1.46 BTC` EV & self-slash):** *Closed.* Pre-committed `BitVMX` verifiers receive `0.15 BTC` L1 directly from `Stake_r` (`1.85 BTC` burned), reclaim `100%` of `F_chal` from `ChalEscrow_{r,i}`, and remaining honest challengers split `0.55 BTC` from `B_zbtc` (`≥ +0.0167 BTC` positive EV even against `6-of-7` verifier collusion!). | |
| 214 | - | - **H-5 (Missing exit liveness & throughput math):** *Closed.* `1-of-M` (`M = 3–5`) operator liveness is Assumption #4 (§4); exact throughput (`0.111–0.185 BTC/day`) and 100% bank-run duration (`~65–72` days under `{0.50, 0.25, 0.25}` vaults; `~43–47d` under `{0.50, 0.50}`) are published alongside `Cap_TVL`. | |
| 215 | - | - **H-6 (April 2024 fees & June 2021 slow blocks):** *Closed.* Zero absolute CLTV cliffs (relative CSVs only); 100% TRUC v3 + `0`-sat `P2A` ephemeral anchors eliminate pre-signed fee cliffs; PTLC sized for `2.3×` slow blocks; sustained `500 sat/vB` 6.7-day bisection envelope disclosed explicitly. | |
| 216 | - | - **H-7 (Unpaid anchoring & mobile BTC proofs):** *Closed.* Bitcoin L1 IS the canonical rollup ordering & DA layer (`0x02`/`0x01`/`0x03`); no Zenon epoch-handoff anchoring is needed for BTC custody. | |
| 217 | - | - **H-8 (21M pre-mint blast radius inside `SettlementContract`):** *Closed by removal.* Stage 1A `zBTC` is accounted strictly in the Bitcoin-canonical Rollup SMT, never pre-minted into an upgradeable Zenon embedded contract. | |
| 218 | - | - **M-9 & M-10 (`11.4s` Momentum, Dynamic Plasma & honest `8 MiB` ceiling):** *Closed.* Honest `~4.4 / ~8.8 / ~1,050–1,200 tx/s` ceiling (`MaxMomentumContentBytes = 8 MiB`), `28,480` Plasma per `AccountBlock.Data` rollup tx, and full `SetPlasmaVariables` pinning. | |
| 219 | - | - **M-15 (Independent review):** *Enforced.* Stage 1A mainnet activation blocks strictly on Signet measurements and an independent third-party cryptography/Bitcoin-Script audit. | |
| 213 | + | 1. **`R8-C01` (Circular `SHA256(outpoint_d)` Lamport cycle):** *Confirmed & fixed (Amendment A1).* Replaced `SHA256(outpoint_d)` with acyclic pre-funding `vault_id = SHA256("zbtc:vault-id:v1" || funding_txid || funding_vout || vault_vout || amount_sats || opBitmask)` bound to the already-confirmed `U_dep_wallet` outpoint (`spec/01 §2.2, §3.3`). `TakeTx` is `~3,142–3,166 vB <= 3,200 vB` TRUC v3 parent with `258` peak stack and zero unconfirmed TRUC child chaining. | |
| 214 | + | 2. **`R8-C02` (Missing `AssignedObligations (A)` in conservation law):** *Confirmed & fixed (Amendment A2).* Added explicit `AssignedObligations (A)` SMT namespace and amended conservation to `V_unassigned + V_assigned = C + L + E + R + A + B` with atomic transitions for `fifo_assign`, `take_confirmed`, `0x07 release_assignment`, `disprove_dual_slash`, `lamport_equivocation_slash` (including cross-operator equivocation recovery), `retire`, and `reorg` (`spec/03 §2.1`, verified explicitly in `verify_spec_bounds.py` across the `T_take` gap!). | |
| 215 | + | 3. **`R8-C03` (Deposit race past `Cap_TVL` burning BTC):** *Confirmed & fixed (Amendment A3).* Enforced `Cap_TVL_total` mutual exclusion directly at Bitcoin L1 consensus via denomination-matched **`AdmissionTicketUTXO`s** (`1 × Ticket_050 + 2 × Ticket_025` consumed as `DepositTx.vin[1..3]` and recycled at `TakeTx.vout[1]`, `spec/01 §2.2`), plus optional two-stage `PreDepositUTXO`. Competing deposit losers never spend `U_dep_wallet`. | |
| 216 | + | 4. **`R8-C04` (Global round cap violates Hall's Marriage Theorem):** *Confirmed & fixed (Amendment A4).* Mandated the exact $2^M$ **Hall's Marriage Invariant** across all `deposit_admit`, `operator_retire`, `round_consume`, and `operator_slash` transitions (`<= 31` subset checks at `M = 5`), tightest-slack FIFO prioritization, and retirement unlock gating (`spec/01 §6.2`, tested in `verify_spec_bounds.py`). | |
| 217 | + | 5. **`R8-C05` (BIP-141 witness completeness, untagged spends, `0x02` DA schema):** *Partially confirmed & fixed (Amendment A5).* While `v3.0.0-rfc` `spec/02:L115` already mandated BIP-141 `wtxid` verification, `v3.1.0-rfc` closes all 3 real gaps: (a) extract witness commitment from the **LAST** coinbase output starting with `0x6a24aa21a9ed` (`len >= 38 B`, coinbase `wtxid = 0x00^32`) and formally separate **fail-closed (`REFUSED_DATA_UNAVAILABLE`)** on missing/unauthenticated witness from **deterministic skip** on `wtxid`-authenticated malformed payload; (b) scan **every `vin` of every stripped transaction** for untagged spends of tracked protocol UTXOs; (c) expand `0x02 BATCH_DA` binary schema to serialize `Accounts`, `RollupLocks`, and cooperative `PendingExits` (`spec/02 §3.1–3.2`). | |
| 218 | + | 6. **`R8-H01` & `R8-N05` (Concurrent/post-suspension `ExitSlotUTXO` griefing draining `0.55 BTC` verifier pool):** *Confirmed & fixed (Amendment A7).* Hard-partitioned `B_grief` (`0.05 BTC`) from `B_custody` (`0.55 BTC`) with pro-rata burst capping (`0` sats ever debited from `B_custody`), excluded suspended operators from all new `ExitSlotUTXO` Taproot trees (`2M_active + 1` leaves), AND moved all verifier bounties onto **Bitcoin L1 `Stake_r`** (`0%` coupling to `B_zbtc` — `R8-N05` eliminated completely!). | |
| 219 | + | 7. **`R8-H02` (Crisis-discounted `zBTC` verifier payouts, CPFP/lockup EV, `M`-simultaneous dispute liquidity):** *Confirmed & fixed (Amendment A7).* Restructured `DisproveTx_{r,i}`/`TimeoutSlashTx_{r,i}` on `Stake_r (2.00 BTC)` to pay **`0.15 BTC` in native Bitcoin L1 BTC** to EVERY active honest challenger via `6` `ChalPayoutEscrow_{r,j}` outputs paired with `ChalProofConnector_{r,j}` (`0.95 BTC` minimum immediate burn, zero `2^7` explosion!). Net honest verifier EV including `16.53 kvB` P2A CPFP + `0.00285 BTC` lockup is **`+0.0645 BTC` @ `500 sat/vB`** and **`+0.0232 BTC` @ `750 sat/vB`** (`890 sat/vB` break-even, `0%` `zBTC` discount!), while combined attacker P&L stays `-2.00` to `-1.10 BTC` on L1 alone (`-2.55` to `-1.65 BTC` incl. `B_custody`). Multi-dispute verifier liquidity (`1.45 / 2.41 BTC` per honest verifier across `M = 3 / 5` simultaneous disputes) is explicitly budgeted in `spec/01 §6`. | |
| 220 | + | 8. **`R8-H05` (`RV32IM` $8^9$ instruction budget contradiction):** *Confirmed & fixed (Amendment A9).* Clarified normatively across `spec/01 §3.2`, `spec/02 §3.2`, and `spec/05 §3` that `BitVMX-CPU` (`RV32IM`) executes **strictly a constant-size wrapped SNARK verifier (`vk_STF`)**, NEVER bare 1 MB SHA-256 block scanning; gated Stage 1A on **Gate G2** (compiled ELF proving `init_steps + exec_steps <= 0.5 × 8^9`, else `l = 10` or BitVM3). | |
| 221 | + | 9. **`R8-H03` & `R8-M07` (Private-fork bound vs Budish subsidy offset, canonical fork check, `>= K` reorg):** *Confirmed & fixed (Amendment A8).* Relabeled `0.50 × K × Subsidy > Cap_TVL_total` honestly as an unpublished-fork opportunity-cost heuristic (printing Budish net flow-cost sensitivity in `verify_spec_bounds.py`), raised the minimum floor to **`K >= 18`** covering `Cap_user + M × B_zbtc`, specified **interactive heaviest-chainwork competing-header comparison** inside `vk_STF`, and mandated a fail-closed **`DEEP_REORG_HALT`** circuit breaker with `>= 144`-block rollback snapshots (`spec/02 §4`). | |
| 222 | + | 10. **`R8-H07` (Stage 0 PTLC & LN HTLC Erlang tail failure):** *Confirmed & fixed (Amendment A10).* Raised Stage 0 `T_znn` from `30h` to **`>= 48h` (`172,800s`, `P(T_72 > 48h | 2.3×) < 10^{-6}`)** and outbound LN HTLC `Δ_safety_sec` from `6h` to **`>= 24h` (`86,400s`, `P(T_36 > 24h | 2.3×) < 0.0002`)**, mandated automated block-72 RBF refund watchtowers, and disclosed conditional atomicity (`spec/03 §1`). | |
| 223 | + | 11. **`R8-N01` & `R8-M01` (Bank-run self-fronting arbitrage & feeless `0x02` DA spam):** *Confirmed & fixed (Amendment A11).* Enforced oldest-`PendingExit` timestamp priority for reimbursement credit eligibility + optional Dutch-auction fee discovery (`R8-N01`), reframed Zenon transfers as L1-subsidized soft preconfirmations, and bounded `0x02` new-leaf DA spam via a refundable `500`-sat `zBTC` new-account leaf deposit + `<= 1,000` new leaves/6-block epoch cap + deterministic slotted batcher priority (`spec/03 §2.2–2.4`). | |
| 224 | + | 12. **`BitVMX-CPU` vs `BitVM3-GC` engineering trade-off:** *Answered transparently (`spec/01 Appendix A.2`, Gate G2).* While BitVM3 shrinks on-chain disprove size to `~93 vB` / 2 rounds, current non-reusable BitVM3 garbled circuits introduce a **`1-of-N` garbler trust assumption** AND require **`~2.2–11.2+ TB`** of one-time off-chain garbled-circuit DA across `M × L × R × N = 5 × 1 × 64 × 7 = 2,240` rounds (`1–5 GB` per round!). Stage 0 runs an explicit **Gate G2** evaluation comparing compiled `RV32IM` BitVMX-CPU traces against emerging reusable DV-SNARK BitVM3-GC before locking Stage 1A's final custody engine — and Stage 2 cleanly supports a non-commingled `zBTC_v2` upgrade if reusable BitVM3 matures later. | |
| 225 | + | ||
| 226 | + | *(Historical `R7` closures — `C-1..C-4`, `H-1..H-8`, `M-1..M-15`, `L-1..L-4`, `N-1..N-6`, `B1..B5` — remain intact in [`CHANGELOG.md`](./CHANGELOG.md). Note also verified pushbacks on `R8`: `R8-M06` anti-64-byte filtering was already present at `spec/02:L67-72` and tightened to `>= 65 B`; `R8-M08` `4.4/8.8` and `6.5/12.9` Plasma rates were exact at observed `11.4s`/Momentum; `R8-C05` BIP-141 `wtxid` checking was already present at `spec/02:L115`; and `R8-H03` used `K = 14`, now raised to `K >= 18`.)* | |
| 220 | 227 | ||
01 Zero-Federation Custody & BitVMX (Part 1) · spec/01-bitcoin-taproot-vault-enforcement.md+151 / -111 ·open redline on page
| @@ -1,37 +1,37 @@ | |||
| 1 | 1 | # Part 1: Zero-Federation Bitcoin Taproot Vault Enforcement (`BTC-BITVMX-V1`), Stage 1B `clArk` Gate & Track B Soft-Fork Annex | |
| 2 | 2 | ||
| 3 | - | **Document Class:** Normative Bitcoin Custody Specification (`v1` / `v3.0.0-rfc`; supersedes `v0` `BTC-ENFORCEMENT-V1`) | |
| 3 | + | **Document Class:** Normative Bitcoin Custody Specification (`v2` / `v3.1.0-rfc`; supersedes archived `v1` `v3.0.0-rfc` and `v0` `BTC-ENFORCEMENT-V1`) | |
| 4 | 4 | **Spec Identifier:** `BTC-BITVMX-V1` | |
| 5 | - | **Precedence:** **Highest normative layer** ([`SPEC.md §2.1`](../SPEC.md#21-authority--conflict-precedence-m-13-fixed)) — Bitcoin L1 scripts, deleted-key Taproot graphs, `StakeChain` timelocks, and `ExitSlotUTXO` consensus rules cannot be overridden by any Zenon contract, Pillar, or spork. | |
| 6 | - | **Target Chain:** Bitcoin Mainnet TODAY (`bip-0141` SegWit, `bip-0340` Schnorr, `bip-0341` Taproot, `bip-0342` Tapscript, `bip-0068`/`bip-0112` relative CSV timelocks, `bip-0431` TRUC v3 + `P2A` ephemeral anchors — **zero Bitcoin soft forks**, **zero custodial federated multisigs**) | |
| 5 | + | **Precedence:** **Highest normative layer** ([`SPEC.md §2.1`](../SPEC.md#21-authority--conflict-precedence-m-13-fixed)) — Bitcoin L1 scripts, deleted-key Taproot graphs, `AdmissionTicketUTXO`s, `StakeChain` timelocks, and `ExitSlotUTXO` consensus rules cannot be overridden by any Zenon contract, Pillar, or spork. | |
| 6 | + | **Target Chain:** Bitcoin Mainnet TODAY (`bip-0141` SegWit, `bip-0340` Schnorr, `bip-0341` Taproot, `bip-0342` Tapscript, `bip-0068`/`bip-0112` relative CSV timelocks, `bip-0431` TRUC v3 + `0`-sat `P2A` ephemeral dust + 1P1C package relay requiring **Bitcoin Core `>= 29.0`**, `v31.0` preferred — **zero Bitcoin soft forks**, **zero custodial federated multisigs**) | |
| 7 | 7 | **Consistency Checker:** [`scripts/verify_spec_bounds.py`](../scripts/verify_spec_bounds.py) | |
| 8 | 8 | ||
| 9 | 9 | --- | |
| 10 | 10 | ||
| 11 | - | ## 1. Cryptographic Boundaries (Theorem 1 & Theorem 2) & Prohibition of Federated Custody | |
| 11 | + | ## 1. Cryptographic Boundaries (Proposition 1 & Proposition 2) & Prohibition of Federated Custody | |
| 12 | 12 | ||
| 13 | 13 | ### 1.1 Explicit Prohibition of Custodial Federated Multisigs | |
| 14 | 14 | ||
| 15 | - | Pooled custodial `k`-of-`n` multisig federations (whether `OP_CHECKSIGADD`, FROST, or HSM-backed, with or without custodial backup recovery leaves) are **STRICTLY FORBIDDEN** in `v1`. Federated custody introduces up to `100%` collusion loss, breaks liveness whenever `n - k + 1` signers refuse to sign Mike's `0.25 BTC` exit, and stalls under `49%` Zenon DPoS consensus splits. | |
| 15 | + | Pooled custodial `k`-of-`n` multisig federations (whether `OP_CHECKSIGADD`, FROST, or HSM-backed, with or without custodial backup recovery leaves) are **STRICTLY FORBIDDEN** in `v2`. Federated custody introduces up to `100%` collusion loss, breaks liveness whenever `n - k + 1` signers refuse to sign Mike's `0.25 BTC` exit, and stalls under `49%` Zenon DPoS consensus splits. | |
| 16 | 16 | ||
| 17 | - | ### 1.2 Formal Boundary Proofs | |
| 17 | + | ### 1.2 Formal Boundary Propositions | |
| 18 | 18 | ||
| 19 | - | **Theorem 1 (Impossibility of Pure `0-of-N` Arbitrary Unilateral Exit on Bitcoin Mainnet Today):** | |
| 20 | - | Given pooled deposit UTXOs `U_A` (`1 BTC`), `U_B` (`1 BTC`) created at `t_0` under current Bitcoin consensus (BIP-340/341/342, zero soft forks), if ZERO pre-committed parties sign a new transaction at `t_1`, no valid Bitcoin L1 transaction exists that allows an unknown future recipient Mike (`P_Mike`, `0.25 BTC` unknown at `t_0`) to spend `U_A` or `U_B` paying `0.25 BTC → P_Mike` while locking `0.75 BTC` back into custody: | |
| 19 | + | **Proposition 1 (4-Way Impossibility of Pure `0-of-N` Arbitrary Unilateral Exit on Bitcoin Mainnet Today):** | |
| 20 | + | On Bitcoin Mainnet today (BIP-340/341/342, zero covenant soft forks), no protocol can simultaneously achieve: **(1)** pooled cross-depositor deposit UTXOs `U_A` (`1 BTC`), `U_B` (`1 BTC`) created at `t_0`, **(2)** `0-of-N` unilateral liveness at `t_1` allowing an unknown future recipient Mike (`P_Mike`, `0.25 BTC` unknown at `t_0`) to spend `U_A` or `U_B` paying `0.25 BTC → P_Mike` while locking `0.75 BTC` back into custody with zero new signatures at `t_1`, **(3)** zero per-hop key-deletion / statechain trust across prior owners, and **(4)** non-expiring fungible liquidity: | |
| 21 | 21 | 1. BIP-342 Tapscript lacks output introspection (`nValue`/`scriptPubKey`); any spend succeeding without a signature committing to outputs is trivially RBF-replaced by miners substituting `(1.0 BTC → P_miner)`. | |
| 22 | 22 | 2. Pre-signed transactions at `t_0` using `SIGHASH_ALL`/`SINGLE` fix outputs before `(P_Mike, 0.25 BTC)` exist; `SIGHASH_NONE` permits total theft. | |
| 23 | - | 3. **Corollary 1A (Bob's `0.5 BTC`):** Depositor CSV refund leaves on `U_B` are impossible after fungible minting (Bob would spend `0.5 zBTC` then reclaim `1.0 BTC` via CSV). | |
| 23 | + | 3. **Corollary 1A (Bob's `0.5 BTC`):** Depositor CSV refund leaves on active admitted vault `U_B` are forbidden after fungible minting (Bob would spend `0.5 zBTC` then reclaim `1.0 BTC` via CSV). | |
| 24 | 24 | 4. **Corollary 1B (Optimistic Reimbursement Bound):** On Bitcoin Mainnet today, every BitVM-family bridge (`BitVM2`/`BitVMX`/`BitVM3`) requires **`1-of-N` ephemeral setup deletion + challenger/verifier safety + `1-of-M` pre-committed operator exit liveness**. | |
| 25 | 25 | ||
| 26 | - | **Theorem 2 (Young Low-Cap Capital / Trust / UX Trilemma — 0 Federation, 0 Soft Forks, `2–20 BTC` Bootstrap Capital):** | |
| 27 | - | With `0` federated signers, `0` soft forks, `~25–33 BTC` ZNN market cap (`0%` ZNN slashing usable), and realistic bootstrap capital `C ∈ [2, 20] BTC`, no protocol simultaneously achieves **(A)** instant non-expiring fungible cross-depositor `zBTC`, **(B)** `1-of-∞` permissionless challenging surviving `200–500 sat/vB`, and **(C)** `0-of-N` unilateral arbitrary L1 exit: | |
| 28 | - | - **Minimal `BitVM2` (`M = 3–5, L = 1`) fails `C ≤ 20 BTC`:** Groth16 `AssertTx` (`~1.0–1.3M vB` / `4.0–4.8 MB` W-OTS) is a fixed Bitcoin-Script constant imposing `13.30–18.175 BTC`/lane (`39.9–90.9 BTC` in bonds alone before fronting liquidity; under-bonding to `≤ 20 BTC` breaks above `50 sat/vB`). | |
| 29 | - | - **Stage 1A Right-Sized `BitVMX` (`n = 8`, `M = 3–5`, `L = 1`, `N = 7`)** achieves **(A)** inside **`12.8–18.8 BTC`** by accepting `1-of-N` (`N = 7`) pre-committed online verifiers and `1-of-M` (`M = 3–5`) operator liveness. | |
| 26 | + | **Proposition 2 (Young Low-Cap Engineering / Capital / Trust Trilemma — 0 Federation, 0 Soft Forks, `~25–33 BTC` ZNN MCap):** | |
| 27 | + | With `0` federated signers, `0` soft forks, and `0%` ZNN slashing usable (`~25–33 BTC` ZNN mcap), no current Bitcoin Script / ZK-proving design fits inside `2–20 BTC` total hard capital while simultaneously achieving **(A)** instant non-expiring fungible cross-depositor `zBTC`, **(B)** `1-of-∞` permissionless challenging surviving `200–500 sat/vB`, and **(C)** `0-of-N` unilateral arbitrary L1 exit: | |
| 28 | + | - **Minimal `BitVM2` (`M = 3–5, L = 1`) fails `C ≤ 20 BTC`:** Current Groth16 `AssertTx` (`~1.0–1.3M vB` / `4.0–4.8 MB` W-OTS) imposes `13.30–18.175 BTC`/lane (`39.9–90.9 BTC` in bonds alone before fronting liquidity; under-bonding breaks above `50 sat/vB`). | |
| 29 | + | - **Stage 1A Right-Sized `BitVMX` (`n = 8`, `M = 3–5`, `L = 1`, `N = 7`)** achieves **(A)** with **`12.80–18.80 BTC`** locked protocol capital (**`14.75–21.25 BTC`** single-dispute operational baseline; `~17–26+ BTC` multi-dispute headroom) by accepting `1-of-N` (`N = 7`) pre-committed online verifiers and `1-of-M` (`M = 3–5`) operator liveness. | |
| 30 | 30 | - **Stage 1B `clArk`** achieves post-round **(C)** inside **`2–5 BTC`** by sacrificing **(A)** (discrete expiring VTXOs, pre-round `arkoor` sender+ASP collusion, no global pooled `zBTC`). | |
| 31 | 31 | ||
| 32 | - | | Custody Track | Soft Fork? | Bootstrap BTC | Zenon Trust (`49%–100%`) | Custody Safety | Mike `0.25 BTC` Liveness (0 Zenon Signers) | Status in `v1` | | |
| 32 | + | | Custody Track | Soft Fork? | Bootstrap Hard BTC | Zenon Trust (`49%–100%`) | Custody Safety | Mike `0.25 BTC` Liveness (0 Zenon Signers) | Status in `v2` | | |
| 33 | 33 | |---|---|---|---|---|---|---| | |
| 34 | - | | **Stage 0 (SPV + PTLC/LN)** | No | `0 BTC` bonds (`0–5` LP) | `0-of-N` | Pure self-custody | N/A (no pooled `zBTC`) | **Mandatory Stage 0** | | |
| 35 | - | | **Stage 1A (`BitVMX n=8` Rollup)** | **No (Today)** | **`12.8–18.8 BTC`** | **`0-of-N`** | `1-of-N` setup/cohort + **`1-of-7`** online verifier | **`1-of-M` (`M=3–5`)** op (`~10m` front; `65–72d` 100% run) | **Primary Stage 1A** *(pre-mainnet R&D)* | | |
| 34 | + | | **Stage 0 (SPV + PTLC/LN)** | No | `0 BTC` bonds (`0–5` LP) | `0-of-N` | Pure self-custody (conditional on bounded chain progress) | N/A (no pooled `zBTC`) | **Mandatory Stage 0** | | |
| 35 | + | | **Stage 1A (`BitVMX n=8` Rollup)** | **No (Core `>= 29.0`)** | **`14.75–21.25 BTC` op baseline** (`12.8–18.8` locked; `17–26+` multi-dispute) | **`0-of-N`** | `1-of-N` setup/cohort + **`1-of-7`** online verifier (native L1 payouts) | **`1-of-M` (`M=3–5`)** op (`~10m` front; `94–104d` 100% run; `0-of-M` locks BTC) | **Primary Stage 1A** *(pre-mainnet R&D)* | | |
| 36 | 36 | | **Stage 1B (`clArk` VTXOs)** | **No (Today)** | **`2–5 BTC` liq** | **`0-of-N`** | Post-round `0-of-N` (pre-round `arkoor` trusts ASP) | Post-round `0-of-N` until expiry (whole VTXO) | **Explicit Stage 1B Alt** | | |
| 37 | 37 | | **Appendix A: Track B Covenant+ZK** | **Yes (`OP_CCV`+ZK or `OP_CAT`)** | **`0 BTC` bonds** | **`0-of-N`** | **Pure `0-of-N`** | **Pure `0-of-N`** (1 L1 tx direct from pooled UTXO) | **Non-Normative Annex** | | |
| @@ -39,5 +39,5 @@ | |||
| 39 | 39 | --- | |
| 40 | 40 | ||
| 41 | - | ## 2. Stage 1A Deleted-Key Vaults, Acyclic Deposit Ceremony & Zero-TTP Cohort Rule | |
| 41 | + | ## 2. Stage 1A Deleted-Key Vaults, Acyclic Deposit Ceremony, L1 `AdmissionTicketUTXO` & Zero-TTP Cohort Rule | |
| 42 | 42 | ||
| 43 | 43 | ### 2.1 Multi-Tier Vault Split (`{0.50, 0.25, 0.25}` BTC) | |
| @@ -45,91 +45,111 @@ | |||
| 45 | 45 | Every `1.0 BTC` deposit splits at deposit time into three standardized deleted-key vault UTXOs: | |
| 46 | 46 | - **Canonical Stage 1A Split:** **`{0.50, 0.25, 0.25}` BTC** (`3` vaults/BTC, average vault **`0.333 BTC`**, **`maxVaultDenom = 0.50 BTC`**). | |
| 47 | - | - Bob's `0.50 BTC` recovery maps 1:1 to a `0.50 BTC` vault immediately; Mike's `0.25 BTC` recovery maps 1:1 to a `0.25 BTC` vault immediately; arbitrary non-bucket amounts (e.g. `0.2371 BTC` or `0.001 BTC`) are paid in exact satoshis by `FrontingTx` and batched via `ReimbursementCredit[O_j]` until hitting an available `0.25`/`0.50 BTC` vault (**zero new presigning needed**). | |
| 48 | - | - *Throughput Option:* Operators/deployments prioritizing faster bank-run recycling over direct `0.25 BTC` vault mapping may configure `{0.50, 0.50}` BTC (`2` vaults/BTC, avg `0.50 BTC`, reducing 100% bank-run duration by `~33%` with identical `maxVaultDenom = 0.50 BTC` and zero bond increase). | |
| 47 | + | - Bob's `0.50 BTC` recovery maps 1:1 to a `0.50 BTC` vault immediately; Mike's `0.25 BTC` recovery maps 1:1 to a `0.25 BTC` vault immediately; arbitrary non-bucket amounts (`>= MIN_EXIT_SATS = 100,000` sats = `0.001 BTC`) are paid in exact satoshis by `FrontingTx` and batched via `ReimbursementCredit[O_j]` (plus `TransferCredit` for `< 0.25 BTC` residual consolidation, `spec/03 §2.4`) until hitting an available `0.25`/`0.50 BTC` vault (**zero new presigning needed**). | |
| 48 | + | - *Throughput Option:* Deployments prioritizing faster bank-run recycling over direct `0.25 BTC` vault mapping may configure `{0.50, 0.50}` BTC (`2` vaults/BTC, avg `0.50 BTC`, reducing 100% bank-run duration by `~33%` with identical `maxVaultDenom = 0.50 BTC` and zero bond increase). | |
| 49 | 49 | ||
| 50 | - | ### 2.2 Acyclic `DepositTx` Ceremony (`OP_DROP` Witness-Stack Push — Closes `v0 C-4, N-2, M-7`) | |
| 50 | + | ### 2.2 Acyclic `DepositTx` Ceremony With L1 `AdmissionTicketUTXO` Cap Exclusion (Closes `R8-C01`, `R8-C03`, `R8-H06`) | |
| 51 | 51 | ||
| 52 | - | Because `vk_STF` is immutably hard-pinned and never rotates with PoS epochs, **Stage 1A vault graphs NEVER expire and NEVER require re-graphing**. There is NO `ProvisionalDepositScript`, NO `RolloverTx`, and NO standing `CommitteeIdentityKey`: | |
| 52 | + | Because `vk_STF` is immutably hard-pinned and never rotates with PoS epochs, **Stage 1A vault graphs carry no CLTV expiration and never require re-graphing**. There is NO `ProvisionalDepositScript`, NO `RolloverTx`, and NO standing `CommitteeIdentityKey`: | |
| 53 | 53 | ||
| 54 | - | 1. **Self-Custodial Staging UTXO (`U_dep_wallet`):** Depositor locks `1.0 BTC + fee` into a pre-committed Tapscript **`OP_DROP <pk_depositor> OP_CHECKSIG`** (independent of `DepositTx`, eliminating any SHA-256 hash cycle!). | |
| 55 | - | 2. **Deterministic Unsigned `DepositTx`:** Spends `vin[0] = U_dep_wallet` → `vout[0..2]` = vault UTXOs `U_0 (0.50 BTC)`, `U_1 (0.25 BTC)`, `U_2 (0.25 BTC)` + `vout[3]` = **`69 B` standard `OP_RETURN`**: | |
| 56 | - | ```text | |
| 57 | - | OP_RETURN <"ZBTX"(4B) || 0x00(1B) || recipientAcctHash(32B) || vaultParamsHash(32B)> | |
| 58 | - | ``` | |
| 59 | - | Because `vout[3]` does **NOT** hash `certBlob`, **`txid_dep` is 100% fixed before presigning or attestation**. | |
| 60 | - | 3. **Ephemeral Deleted-Key Presigning:** Depositor + `N = 7` presigners + all online operators (`≥ M_min`, encoded in `opBitmask` `u64`) generate fresh per-deposit ephemeral keys `(x_{i,d}, P_{i,d})` (including the depositor's own ephemeral key `P_{dep,d}`!) forming `Q_setup_d = MuSig2_KeyAgg(P_{1,d}, ..., P_{N,d}, P_{dep,d})`. They presign ONE `TakeTx_{d,j,l,r}` per eligible operator lane `(j, l)` and unused round `r ∈ {r_cur..R}` (Stage 1A `M = 5, L = 1, R = 64` ⇒ **`320` pre-signed `TakeTx`s per vault**, `~40 KB` off-chain, `< 100ms` batch MuSig2 ONCE at deposit). | |
| 61 | - | 4. **Immediate Ephemeral Key Deletion & Non-Spending Attestation:** Each presigner `i` **permanently deletes `x_{i,d}`** and signs a non-spending identity attestation `σ_cert` (`64 B` MuSig2 over `id_1..id_N`, co-verified by eligible operators) covering `(txid_dep, Q_setup_d, opBitmask, vaultParamsHash)`: | |
| 62 | - | ```text | |
| 63 | - | certBlob = σ_cert(64B) || Q_setup_d(32B) || opBitmask(8B) [exact 104 B <= 520 B BIP-342 limit] | |
| 64 | - | ``` | |
| 65 | - | 5. **Zero-Stranding Broadcast:** Only after verifying every pre-signed `TakeTx` and `σ_cert` does the depositor delete `x_{dep,d}`, push witness stack **`[sig_depositor, certBlob, script, controlBlock]`** into `DepositTx.vin[0].witness`, and broadcast. Because witness stacks are excluded from `txid_dep` and authenticated by `wtxid_dep` in the coinbase BIP-141 witness commitment, there is **zero hash cycle**. At `K` confirmations, the Rollup STARK (`spec/02 §3`) verifies real satoshi outputs, Taproot script derivation, and `σ_cert`, and credits `1.0 zBTC`. | |
| 54 | + | 1. **Confirmed Self-Custodial Staging UTXO (`U_dep_wallet`) & Acyclic `vault_id` (`R8-C01`):** | |
| 55 | + | - Depositor first confirms `1.0 BTC + fee` on Bitcoin L1 in staging UTXO `U_dep_wallet` (`funding_txid:funding_vout`, Tapscript **`OP_DROP <pk_depositor> OP_CHECKSIG`**). | |
| 56 | + | - Because `funding_txid:funding_vout` is already confirmed on-chain and Bitcoin consensus prevents spending `U_dep_wallet` twice, each output vault `vout ∈ {0, 1, 2}` has a **globally unique, pre-Taproot-construction deterministic identifier**: | |
| 57 | + | ```text | |
| 58 | + | vault_id = SHA256("zbtc:vault-id:v1" || funding_txid(32B) || u32BE(funding_vout) | |
| 59 | + | || u32BE(vault_vout) || u64BE(amount_sats) || u64BE(opBitmask)) | |
| 60 | + | ``` | |
| 61 | + | *Zero SHA-256d fixed-point cycle:* Every vault's Lamport `TakeTx` Tapscript leaf commits to `vault_id` (NOT `SHA256(outpoint_d)`!), so Taproot script construction, `Q_setup_d` Taproot tweaking, and `txid_dep` computation form a strict DAG. | |
| 62 | + | 2. **L1 Consensus `Cap_TVL` Mutual Exclusion via Denomination-Matched `AdmissionTicketUTXO`s (`R8-C03`):** | |
| 63 | + | - At cohort genesis, setup mints exact denomination-matched `546`-sat `AdmissionTicketUTXO` connectors matching the total vault cap `Cap_TVL_total = Cap_user + M × B_zbtc` (e.g., for `M = 5`, `Cap_user = 15.0 BTC` + `3.0 BTC` operator `B_zbtc` = `18.0 BTC` total vaults ⇒ `18 × Ticket_050` + `36 × Ticket_025` = `54` tickets totaling `29,484` sats; operator initial `B_zbtc` deposits consume their dedicated `M × 0.60 BTC` allocation, leaving exact `15 × Ticket_050 + 30 × Ticket_025` for `15.0 BTC` of external user deposits!). | |
| 64 | + | - Every `1.0 BTC` `DepositTx` MUST spend `vin[0] = U_dep_wallet` AND `vin[1] = Ticket_050`, `vin[2] = Ticket_025`, `vin[3] = Ticket_025` (signed via cohort ticket key with zero BTC value risk — tickets carry `546` sats dust only) → `vout[0..2]` = vault UTXOs `U_0 (0.50 BTC)`, `U_1 (0.25 BTC)`, `U_2 (0.25 BTC)` + `vout[3]` = **`69 B` standard `OP_RETURN`**: | |
| 65 | + | ```text | |
| 66 | + | OP_RETURN <"ZBTX"(4B) || 0x00(1B) || recipientAcctHash(32B) || vaultParamsHash(32B)> | |
| 67 | + | ``` | |
| 68 | + | - Every pre-signed `TakeTx_{d,j,l,r}` spending vault `U_d` recreates the exact matching-denomination **`AdmissionTicketUTXO` at `vout[1]`** (`Ticket_050` or `Ticket_025`), so **Bitcoin L1 consensus itself enforces `sum(live_vaults) <= Cap_TVL_total` by strict UTXO conservation!** If two depositors race across the last remaining slot, Bitcoin consensus confirms at most ONE `DepositTx`; the loser's `DepositTx` fails with `missing-inputs` and the loser's `1.0 BTC` **never leaves `U_dep_wallet` (`0` BTC burn!)**. | |
| 69 | + | - *(Optional Alternative — Two-Stage `PreDepositUTXO`:)* Deployments opting out of ticket connectors MAY instead lock `1.0 BTC` first into `PreDepositUTXO` (`MuSig2(Q_setup_d) OR (<144> OP_CSV <pk_depositor>)`), deferring ephemeral key deletion and sweep into the active vault until `K`-deep slot admission confirms. **Normative Prohibition:** An active admitted vault `U_d` MUST NEVER retain an unconditional depositor CSV leaf (Corollary 1A). `AdmissionTicketUTXO` is the normative Stage 1A default. | |
| 70 | + | 3. **Ephemeral Deleted-Key Presigning & Hall's Marriage Admission Check (`R8-C04`):** | |
| 71 | + | - Before presigning, presigners verify that admitting `{U_0, U_1, U_2}` with `opBitmask` satisfies the **$2^M$ Hall's Marriage Invariant** (§6.2). | |
| 72 | + | - Depositor + `N = 7` presigners + all online operators (`≥ M_min`, encoded in `opBitmask` `u64`) generate fresh per-deposit ephemeral keys `(x_{i,d}, P_{i,d})` (including the depositor's own ephemeral key `P_{dep,d}`!) forming `Q_setup_d = MuSig2_KeyAgg(P_{1,d}, ..., P_{N,d}, P_{dep,d})`. They presign ONE `TakeTx_{d,j,l,r}` per eligible operator lane `(j, l)` and unused round `r ∈ {r_cur..R}` (Stage 1A `M = 5, L = 1, R = 64` ⇒ **`320` pre-signed `TakeTx`s per vault**, `~40 KB` off-chain, `< 100ms` batch MuSig2 ONCE at deposit). | |
| 73 | + | 4. **Immediate Ephemeral Key Deletion, Non-Spending Attestation & Public `zbtc-vault-bundle-v1` DA (`R8-H06`):** | |
| 74 | + | - Each presigner `i` **permanently deletes `x_{i,d}`** and signs a non-spending identity attestation `σ_cert` (`64 B` MuSig2 over `id_1..id_N`, co-verified by eligible operators) covering `(txid_dep, Q_setup_d, opBitmask, vaultParamsHash)`: | |
| 75 | + | ```text | |
| 76 | + | certBlob = σ_cert(64B) || Q_setup_d(32B) || opBitmask(8B) [exact 104 B <= 520 B BIP-342 limit] | |
| 77 | + | ``` | |
| 78 | + | - The ceremony MUST publish the canonical **`zbtc-vault-bundle-v1`** artifact (`vault_id`, `funding_txid:vout`, `DepositTx`, full Taproot Merkle tree scripts & control blocks, all `L_{j,l,r}` Lamport & W-OTS pubkeys, `certBlob`, and all `320` pre-signed `TakeTx`s, content-addressed by `SHA256(bundle)`) to **`>= 3` independent public archival mirrors** (IPFS/Arweave/Git/HTTP mirrors operated independently of operators). | |
| 79 | + | 5. **Zero-Stranding Broadcast:** Only after verifying every pre-signed `TakeTx`, `σ_cert`, and cryptographic retrieval of `zbtc-vault-bundle-v1` from `>= 3` public mirrors does the depositor delete `x_{dep,d}`, push witness stack **`[sig_depositor, certBlob, script, controlBlock]`** into `DepositTx.vin[0].witness`, and broadcast. Because witness stacks are excluded from `txid_dep` and authenticated by `wtxid_dep` in the coinbase BIP-141 witness commitment, there is **zero hash cycle**. At `K = 18` confirmations, the Rollup STF (`spec/02 §3`) verifies real satoshi outputs, `AdmissionTicketUTXO` consumption, Taproot script derivation from `vault_id`, `σ_cert`, and Hall's invariant, and credits `1.0 zBTC`. | |
| 66 | 80 | ||
| 67 | - | ### 2.3 Zero-TTP Cohort Lifecycle Rule | |
| 81 | + | ### 2.3 Zero-TTP Cohort Lifecycle Rule (`R8-C06` Clarified) | |
| 68 | 82 | ||
| 69 | 83 | Inside a single fungible `zBTC` pool, **NO governance key, Pillar vote, or threshold committee can EVER add a new presigner cohort**: | |
| 70 | 84 | 1. **Voluntary Handover (Same `vk_STF` Only):** Only **`N`-of-`N`** (`7-of-7`) of Cohort 1 (preserving strict `1-of-N` safety!) may sign a handover certificate registering Cohort 2. | |
| 71 | - | 2. **Involuntary `1-of-N` `id_i` Key Loss:** All existing Cohort 1 vaults and `zBTC` balances remain **100% safe and 100% live forever** (zero bricking), while *new* deposits on `v1` halt cleanly. Future deposits launch a **clean, non-commingled sovereign deployment (`zBTC_v2`)** with fresh Cohort 2. *(Long-term `id_i` uses redundant HSM backup; ephemeral `x_{i,d}` is NEVER backed up.)* | |
| 85 | + | 2. **Involuntary `1-of-N` `id_i` Key Loss:** All existing Cohort 1 vaults carry **no CLTV expiration** and remain safe and redeemable 1:1 to native BTC **strictly subject to `1-of-M` active eligible operator liveness** (zero `id_i` bricking), while *new* deposits on `v1` halt cleanly. Future deposits launch a **clean, non-commingled sovereign deployment (`zBTC_v2`)** with fresh Cohort 2. *(Long-term `id_i` uses redundant HSM backup; ephemeral `x_{i,d}` is NEVER backed up.)* | |
| 72 | 86 | 3. **Explicit Residual Open-Cohort Bound:** While a cohort accepts new deposits, at least `1-of-N` `{id_1..id_N}` must remain uncompromised (otherwise all `N` compromised `id_i` keys could attest a fake new deposit into the shared pool; existing deleted-key vaults still cannot be swept directly). | |
| 73 | 87 | ||
| 74 | 88 | --- | |
| 75 | 89 | ||
| 76 | - | ## 3. Right-Sized `BitVMX` (`n = 8`, `RV32IM`) `StakeChain`, 256-Bit Lamport `TakeTx` & TRUC v3 Wiring | |
| 90 | + | ## 3. Right-Sized `BitVMX` (`n = 8`, `RV32IM`) `StakeChain`, Acyclic 256-Bit Lamport `TakeTx` & Core `>= 29.0` TRUC v3 Wiring | |
| 77 | 91 | ||
| 78 | 92 | ### 3.1 Launch-Time `StakeChain` & PoW Anchor (`t = 0`, `M = 3–5`, `L = 1`, `N = 7`, `R = 64`) | |
| 79 | 93 | ||
| 80 | 94 | Before accepting deposits, each operator `O_j` (`j ∈ {1..M}`) launches `L = 1` serial `StakeChain` lane `(j, l)` (`R = 64` finite rounds): | |
| 81 | - | - **Launch-Time Bitcoin PoW Anchor (Zero Pre-Broadcast Cycle):** Each lane pins an **already-confirmed** Bitcoin block `(h_lane_init, H(h_lane_init), D(h_lane_init))` inside its `BitVMX-CPU` `RV32IM` verifier program at `t = 0` (before `Q_lane_{j,l}` deletion). In-circuit header verification enforces full Bitcoin PoW + 2,016-block retargeting from `h_lane_init` with minimum difficulty floor **`D(h) ≥ 0.50 × D(h_lane_init)`** across the lane's finite `R = 64`-round horizon. | |
| 82 | - | - **TVL-Scaled Private-Fork Confirmation Depth `K`:** Sized against **100% multi-operator collusion on a single private fork**: | |
| 83 | - | ```text | |
| 84 | - | 0.50 * K(era, Cap_TVL) * Subsidy(era) > Cap_TVL | |
| 85 | - | ``` | |
| 86 | - | At `Subsidy = 3.125 BTC` (2024–2028) and `α_diff = 0.50` (`1.5625 BTC/blk` floor, `3.125 BTC/blk` nominal): | |
| 87 | - | - **`Cap_TVL ≤ 15 BTC` (Stage 1A Pilot):** **`K = 14` blocks** (~2.3h) ⇒ PoW cost `21.88–43.75 BTC > 15 BTC`. | |
| 88 | - | - **`Cap_TVL ≤ 50 BTC` (Stage 2):** `K = 36` blocks (~6h) ⇒ PoW cost `56.25–112.50 BTC > 50 BTC`. | |
| 89 | - | - **`Cap_TVL ≤ 200 BTC` (Stage 2):** `K = 144` blocks (~24h) ⇒ PoW cost `225.0–450.0 BTC > 200 BTC`. | |
| 90 | - | *(If mainnet difficulty grows `> 2×` within a lane's active lifetime, `α_diff` tightens proportionally — e.g. `0.33` at `3×` growth ⇒ `K = 20 / 54 / 216` — or fresh lanes re-anchor `(h_lane_init, D)`.)* | |
| 95 | + | - **Launch-Time Bitcoin PoW Anchor (Zero Pre-Broadcast Cycle):** Each lane pins an **already-confirmed** Bitcoin block `(h_lane_init, H(h_lane_init), D(h_lane_init))` inside its wrapped SNARK verifier `vk_STF` at `t = 0` (before `Q_lane_{j,l}` deletion). Header verification inside the off-chain ZK prover enforces full Bitcoin PoW + 2,016-block retargeting from `h_lane_init` with minimum difficulty floor **`D(h) ≥ 0.50 × D(h_lane_init)`** across the lane's finite `R = 64`-round horizon, PLUS **interactive heaviest-chainwork competing-header comparison** (`spec/02 §4`). | |
| 96 | + | - **Halving-Indexed Confirmation Depth (`K >= 18` Hard Minimum Floor, `R8-H03`):** Sized via the conditional unpublished-fork opportunity-cost heuristic `0.50 × K × Subsidy(era) > Cap_TVL_total` (`Cap_user + M × B_zbtc`), subject to a hard minimum floor **`K >= 18`** (`~3.0h` nominal): | |
| 97 | + | - **`Cap_user ≤ 10 BTC` (`11.80 BTC` total incl. `M=3` `B_zbtc`):** **`K = 18`** (`28.125 BTC` floor / `56.25 BTC` nominal in 2024–2028). | |
| 98 | + | - **`Cap_user ≤ 15 BTC` (`18.00 BTC` total incl. `M=5` `B_zbtc`):** **`K = 18`** (`28.125 BTC` floor / `56.25 BTC` nominal in 2024–2028). | |
| 99 | + | - **`Cap_user ≤ 50 BTC` (`62.00 BTC` total, Stage 2):** **`K = 42`** (`65.625 BTC` floor / `131.25 BTC` nominal). | |
| 100 | + | - **`Cap_user ≤ 200 BTC` (`224.00 BTC` total, Stage 2):** **`K = 144`** (`225.00 BTC` floor / `450.00 BTC` nominal). | |
| 101 | + | *(See `spec/02 §4` for full Budish winning-fork subsidy-offset disclosure and 2028–2036 halving table.)* | |
| 91 | 102 | - **Pre-Signed Linear `StakeChain` (`Stake_0 → RoundTx_1 → Stake_1 → ... → RoundTx_R`):** | |
| 92 | 103 | - `O_j` locks **`Bond_BTC = 2.00 BTC`** in `Stake_0` under ephemeral `Q_lane_{j,l}` (all `N = 7` presigner ephemeral shares **permanently deleted** after presigning the `R = 64` rounds!). | |
| 93 | - | - Each round `r ∈ {1..R}` binds a one-time **256-bit Lamport keypair `L_{j,l,r}`** (`256` `OP_HASH160` pairs `(H_{k,0}, H_{k,1})`) signing `vaultHash_d = SHA256(outpoint_d)`. | |
| 94 | - | - **`RoundTx_r`** (spends `Stake_{r-1}` after `<1,296> OP_CSV`, revealing `256` Lamport preimages = `5,376 B` witness ≈ `1,344 vB`, total `RoundTx_r ≈ 1.8 kvB ≤ 10,000 vB` **TRUC v3**) creates: | |
| 104 | + | - Each round `r ∈ {1..R}` binds a one-time **256-bit Lamport keypair `L_{j,l,r}`** (`256` `OP_HASH160` pairs `(H_{k,0}, H_{k,1})`) signing the acyclic pre-funding **`vault_id`** (§2.2). | |
| 105 | + | - **`RoundTx_r`** (spends `Stake_{r-1}` after `<1,872> OP_CSV`, revealing `256` Lamport preimages = `5,376 B` witness ≈ `1,344 vB`, total `RoundTx_r ≈ 1.8 kvB ≤ 10,000 vB` **TRUC v3**) creates: | |
| 95 | 106 | - **`Out 0 = Stake_r` (`Bond_BTC = 2.00 BTC`):** | |
| 96 | - | - **Leaf 1 (Next Round):** `<1,296> OP_CSV` (`9.0d` — enforces `W_max = 1` active kickoff per lane on L1!) → `RoundTx_{r+1}`. | |
| 97 | - | - **Leaf 2 (Clean Retirement):** `<1,440> OP_CSV` (`10.0d`) → **`RetireStakeTx_r`** (returns `2.00 BTC` to `O_j`; spending `Stake_r` **permanently double-spends and kills `RoundTx_{r+1..R}` forever**! The STF forbids unlocking `O_j`'s `B_zbtc` until `RetireStakeTx_r` confirms `K`-deep!). | |
| 98 | - | - **Leaf 3 (Bisection Slash):** Immediate → `DisproveTx_{r,i}` / `TimeoutSlashTx_{r,i}` (**MUST spend BOTH `vin[0] = Stake_r` AND `vin[1] = VaultConnector_r`!**) paying **`0.15 BTC`** directly on L1 to winning verifier `P_{V_i}` and burning **`1.85 BTC` to `OP_RETURN`**. | |
| 107 | + | - **Leaf 1 (Next Round):** `<1,872> OP_CSV` (`13.0d` — enforces `W_max = 1` active kickoff per lane on L1!) → `RoundTx_{r+1}`. | |
| 108 | + | - **Leaf 2 (Clean Retirement):** `<2,016> OP_CSV` (`14.0d`) → **`RetireStakeTx_r`** (returns `2.00 BTC` to `O_j`; spending `Stake_r` **permanently double-spends and kills `RoundTx_{r+1..R}` forever**! The STF forbids unlocking `O_j`'s `B_zbtc` until `RetireStakeTx_r` confirms `K`-deep, `AssignedObligations[O_j] == 0`, AND removing `O_j`'s remaining rounds satisfies Hall's Marriage Invariant §6.2!). | |
| 109 | + | - **Leaf 3 (Native-L1 Multi-Challenger Bisection Slash — Closes `R8-H02` & `R8-N05`):** Immediate → `DisproveTx_{r,i}` / `TimeoutSlashTx_{r,i}` (**MUST spend BOTH `vin[0] = Stake_r` AND `vin[1] = VaultConnector_r`!**) paying: | |
| 110 | + | - `vout[0] = 0.15 BTC` immediately in native Bitcoin L1 BTC to winning verifier `P_{V_i}`, | |
| 111 | + | - `vout[1..6] = 6 × 0.15 BTC` **`ChalPayoutEscrow_{r,j}`** (`j ≠ i`) — each a 2-leaf Taproot output: **Leaf 1** co-spends `ChalProofConnector_{r,j}` (created ONLY when `V_j` actually broadcast `ChallengeTx_{r,j}` during `[0, 144]`) + `<P_{V_j}> OP_CHECKSIG` → pays **`0.15 BTC` native L1 BTC** directly to `P_{V_j}`; **Leaf 2** `<144> OP_CSV` → pre-signed `OP_RETURN` burn if `V_j` did NOT challenge! | |
| 112 | + | - `vout[7] = 0.95 BTC` immediate `OP_RETURN` burn (`0.95` min burn if all `7` challenge; up to `1.85 BTC` burn if `1` challenges!), | |
| 113 | + | - `vout[8] = 0`-sat `P2A` ephemeral anchor! | |
| 114 | + | *(Zero `2^7 = 128` subset explosion: only `7` pre-signed `DisproveTx`/`TimeoutSlashTx` pairs per round + `6` tiny 2-input claim/burn txs per verifier!)* | |
| 99 | 115 | - **Leaf 4 (256-Leaf Lamport Equivocation Slash, Depth 8, Pre-Signed at `t = 0`):** Leaf `k ∈ [0..255]` verifies `OP_HASH160 <H_{k,0}> OP_EQUALVERIFY OP_HASH160 <H_{k,1}> OP_EQUALVERIFY <Q_lane_{j,l}> OP_CHECKSIG` → `BurnBondTx_{r,k}` (`~200 vB` TRUC v3, spends `Stake_r` alone) burning **`100%` of `2.00 BTC` `Bond_BTC` to `OP_RETURN`**. | |
| 100 | - | - **`Out 1 = VaultConnector_r` (`546` sats):** `<1,152> OP_CSV` (`8.0d` > `max_dispute_end = 1,104` blks!) → **ONE single `TakeTx_{d,j,l,r}`** (OR spent immediately as `vin[1]` of `DisproveTx_{r,i}`/`TimeoutSlashTx_{r,i}`, guaranteeing **`0` satoshis stolen from `U_d`** on any bisection slash!). | |
| 101 | - | - **`Out 2..8 = VerifierSlot_1..7` (`546` sats each):** **Simultaneous non-staggered `[0, 144]` block challenge window** — ALL `N = 7` slots open at block `0` (`<P_{V_i}> OP_CHECKSIG`) and expire at `<144> OP_CSV` (`24h`). Colluding `V_1` can NEVER delay honest `V_2..V_7` past `T_take` or `T_cooldown`! | |
| 116 | + | - **`Out 1 = VaultConnector_r` (`546` sats):** `<1,728> OP_CSV` (`12.0d` > `max_dispute_end = 1,584` blks!) → **ONE single `TakeTx_{d,j,l,r}`** (OR spent immediately as `vin[1]` of `DisproveTx_{r,i}`/`TimeoutSlashTx_{r,i}`, guaranteeing **`0` satoshis stolen from `U_d`** on any bisection slash!). | |
| 117 | + | - **`Out 2..8 = VerifierSlot_1..7` (`546` sats each):** **Simultaneous non-staggered `[0, 144]` block challenge window** — ALL `N = 7` slots open at block `0` (`<P_{V_i}> OP_CHECKSIG`) and expire at `<144> OP_CSV` (`24h`). Each `ChallengeTx_{r,i}` creates BOTH `ChalEscrow_{r,i}` (`F_chal = 0.40 BTC`) AND a `546`-sat **`ChalProofConnector_{r,i}`** unlocking `V_i`'s `0.15 BTC` native L1 payout in `ChalPayoutEscrow_{r,i}` if `O_j` is slashed! | |
| 102 | 118 | - **`Out 9 = 0`-sat `P2A` Ephemeral Anchor** (`0x51024e73`). | |
| 103 | 119 | ||
| 104 | - | ### 3.2 `n = 8` `BitVMX-CPU` (`RV32IM`) Interactive Bisection & 100% BIP-431 TRUC v3 Compliance | |
| 105 | - | ||
| 106 | - | The disputed computation is a compact Rollup proof verifier compiled from standard **Rust → `RV32IM`** (`≤ 2^27 = 134,217,728` RISC-V instructions) using open-source `BitVMX-CPU` / `BitVMX-protocol`: | |
| 120 | + | ### 3.2 `n = 8` `BitVMX-CPU` (`RV32IM`) Wrapped-SNARK Verifier Bisection & Core `>= 29.0` TRUC v3 Compliance (`R8-H04`, `R8-H05`) | |
| 107 | 121 | ||
| 122 | + | - **Normative `RV32IM` Guest Computation Boundary (`R8-H05` Closed):** | |
| 123 | + | - The disputed `RV32IM` guest program running inside `BitVMX-CPU` (`≤ 8^9 = 2^27 = 134,217,728` RISC-V instructions) is **STRICTLY a constant-size wrapped SNARK verifier (`vk_STF`)** (verifying a succinct BN254 Groth16 or compact recursive STARK proof over constant-size authenticated public inputs `(h_prev, R_prev, h_tip, R_tip, claimHash, competingChainWork)`). | |
| 124 | + | - **Bare `1 MB` Bitcoin stripped-block SHA-256 scanning and SMT reconstruction MUST NOT execute directly inside `RV32IM`** — they run inside the off-chain ZK prover proved by `vk_STF` (`spec/02 §3.2`). | |
| 125 | + | - **Mandatory Gate G2 (`spec/05 §5`):** Before Stage 1A code freeze, the team MUST publish reproducible Rust → `RV32IM` source and compiled ELF binary demonstrating `init_steps + exec_steps <= 0.5 × 8^9 = 67,108,864` on worst-case adversarial inputs (if exceeded, either bump search depth `l = 9 → 10`, `8^{10} = 1.074B` steps adding `+2` steps / `+144` blks, or adopt reusable BitVM3-GC). | |
| 108 | 126 | - **`n = 8` Search Branching (`3` bits/round, `7 × 20 B` `OP_HASH160` Intermediate Trace Hashes):** | |
| 109 | 127 | - W-OTS cost per prover search tx: `7` hashes × `43` digits (`40` data nibbles + `3` checksum nibbles per 20-byte hash) = **`301` W-OTS digits** × `95.5 WU/digit` = **`28,746 WU`** (`7,186.5 vB`) + `~250 vB` tx overhead **`≈ 7,437 vB (7.44 kvB) ≤ 10,000 vB` (100% BIP-431 TRUC v3!)**. | |
| 110 | 128 | - Search depth: `ceil(27 / 3) = 9` search rounds (`9` prover txs + `9` verifier 3-bit interval choice txs) + `1` Start/Read (`~3.0 kvB` prover) + `1` Final Trace (`~5.0 kvB` prover) / Execute-1-RISC-V-Opcode (`~8.0 kvB` verifier) = **`20` sequential steps**. | |
| 111 | - | - **Total worst-case dispute weights:** | |
| 112 | - | - **Prover (`O_j`):** `9 × 7.44 + 3.0 + 5.0 = 74.96 ≈ 75 kvB`. | |
| 113 | - | - **Verifier (`V_i`):** `Challenge (0.35) + 9 × 0.35 (3.15) + Execute/Disprove (8.0) = 11.5 kvB` (conservatively budgeted at **`15 kvB`**). | |
| 114 | - | - **Exact Timelock Ordering (`T_step = 48` blocks = `8h`/step):** | |
| 129 | + | - **Total Worst-Case Dispute Weights (INCLUDING `10 × 153 vB = 1,530 vB` P2A CPFP Children, `R8-H02`/`R8-H04`):** | |
| 130 | + | - **Prover (`O_j`):** `9 × 7.44 + 3.0 + 5.0 = 74.96 kvB` (cap `75.00 kvB`) + `10 × 153 vB` P2A CPFP (`1.53 kvB`) = **`76.53 kvB`**. | |
| 131 | + | - **Verifier (`V_i`):** `Challenge (0.35) + 9 × 0.35 (3.15) + Execute/Disprove (8.0) = 11.50 kvB` (conservative cap `15.00 kvB`) + `10 × 153 vB` P2A CPFP (`1.53 kvB`) = **`16.53 kvB`**. | |
| 132 | + | - **Widened Exact Timelock Ordering (`T_step = 72` blocks = `12h`/step, `R8-H04`):** | |
| 115 | 133 | ```text | |
| 116 | 134 | Challenge Window [0, 144] (24h) | |
| 117 | - | → Max Dispute End: 144 + (20 * 48) = 1,104 blocks (7.67 days) | |
| 118 | - | → VaultConnector_r (T_take): 1,152 blocks (8.00 days) [+48 blk margin] | |
| 119 | - | → Stake_r -> RoundTx_{r+1} (T_cool): 1,296 blocks (9.00 days) [+144 blk post-TakeTx equivocation margin] | |
| 120 | - | → RetireStakeTx_r: 1,440 blocks (10.00 days) [+144 blk retirement margin] | |
| 135 | + | → Max Dispute End: 144 + (20 * 72) = 1,584 blocks (11.00 days) | |
| 136 | + | → VaultConnector_r (T_take): 1,728 blocks (12.00 days) [+144 blk / 24h margin] | |
| 137 | + | → Stake_r -> RoundTx_{r+1} (T_cool): 1,872 blocks (13.00 days) [+144 blk post-TakeTx equivocation margin] | |
| 138 | + | → RetireStakeTx_r: 2,016 blocks (14.00 days) [+144 blk clean retirement margin] | |
| 121 | 139 | ``` | |
| 122 | - | - **BIP-431 TRUC v3 (`nVersion = 3`) & `P2A` Audit:** | |
| 123 | - | - Every pre-signed tx is `≤ 10,000 vB` (`RoundTx_r` ~`1.8 kvB`, `TakeTx` ~`3.1 kvB`, Prover search tx `7.44 kvB`, Execute-1-Opcode `≤ 8.0 kvB`, Verifier choice/Slash/Burn `~0.2–0.5 kvB`). | |
| 124 | - | - Every sequential step spends **confirmed** parent outputs (`ancestor_count = 1`); `ChallengeTx` is fee-funded directly via verifier's `vin[1]` (`descendant_count = 1`); all other pre-signed txs use ONE `~160 vB ≤ 1,000 vB` CPFP child via `0`-sat `P2A` (`descendant_count = 2`). **100% BIP-431 TRUC v3 compliant — zero pre-signed fee cliffs!** | |
| 140 | + | - **Bitcoin Core `>= 29.0` (`v31.0` Preferred), TRUC v3 (`nVersion = 3`), `P2A` & Out-of-Band Relay Audit (`R8-H04`, `R8-M09`):** | |
| 141 | + | - **Normative Node Floor:** Zero-value (`0`-sat) `P2A` ephemeral dust + 1P1C package relay requires **Bitcoin Core `>= 29.0`** (`v31.0` preferred; Core `28.0` rejects `0`-sat `P2A` outputs as non-standard!). | |
| 142 | + | - Every pre-signed tx is `≤ 10,000 vB` (`RoundTx_r` ~`1.8 kvB`, `TakeTx` ~`3.17 kvB`, Prover search tx `7.44 kvB`, Execute-1-Opcode `≤ 8.0 kvB`, Verifier choice/Slash/Burn `~0.2–0.5 kvB`). | |
| 143 | + | - **Zero Unconfirmed TRUC Child Chaining:** Because `TakeTx` (`~3.17 kvB`) and prover search txs (`7.44 kvB`) exceed BIP-431's `1,000 vB` child limit, EVERY protocol step spends ONLY **confirmed** parent outputs (`ancestor_count = 1`), attaching at most ONE `~153 vB ≤ 1,000 vB` CPFP child via `0`-sat `P2A` (`descendant_count = 2`). | |
| 144 | + | - **Sibling-Eviction Mitigation:** All operators and verifiers MUST maintain direct-to-miner out-of-band submission rails (e.g., Slipstream / mining-pool RPC) alongside public P2P 1P1C relay; `T_step = 72` blocks (`12h`) absorbs prolonged sibling-eviction pinning and transient fee spikes. | |
| 125 | 145 | - **Honest Fee-Rate Design Envelope (`500 sat/vB` Sustained Across ALL `20` Steps):** | |
| 126 | - | - Prover worst-case fee @ `500 sat/vB`: `75,000 × 500 = 37,500,000` sats (`0.375 BTC`) ≤ **`F_chal = 0.40 BTC`** (exact break-even **`533 sat/vB`** sustained across all `10` prover txs!). | |
| 127 | - | - Verifier worst-case fee @ `500 sat/vB`: `15,000 × 500 = 7,500,000` sats (`0.075 BTC`; `0.15 BTC` @ `1,000 sat/vB`). | |
| 146 | + | - Prover worst-case fee @ `500 sat/vB` (incl. `10 × 153 vB` CPFP): `76,530 × 500 = 38,265,000` sats (`0.38265 BTC`) ≤ **`F_chal = 0.40 BTC`** (exact break-even **`522 sat/vB`** sustained across all `10` prover txs!). | |
| 147 | + | - Verifier worst-case fee (incl. `10 × 153 vB` CPFP): `16,530 × 500 = 8,265,000` sats (`0.08265 BTC` @ `500 sat/vB`; `12,397,500` sats = `0.12398 BTC` @ `750 sat/vB`). | |
| 128 | 148 | ||
| 129 | - | ### 3.3 256-Bit Lamport `TakeTx` Leaf (Zero `ReimburseEscrow`, Zero `RecoveryVault`) | |
| 149 | + | ### 3.3 Acyclic 256-Bit Lamport `TakeTx` Leaf (Zero `ReimburseEscrow`, Zero `RecoveryVault`, `R8-C01`) | |
| 130 | 150 | ||
| 131 | - | At deposit `d`, `U_d`'s Tapscript leaf for `(j, l, r)` verifies `L_{j,l,r}(SHA256(outpoint_d))` directly inside `TakeTx_{d,j,l,r}` (`vin[0] = U_d`, `vin[1] = VaultConnector_r`, `vout[0] = D_d → P_{O_j}`, `vout[1] = 0`-sat `P2A`): | |
| 151 | + | At deposit `d`, `U_d`'s Tapscript leaf for `(j, l, r)` verifies `L_{j,l,r}(vault_id)` directly inside `TakeTx_{d,j,l,r}` (`vin[0] = U_d`, `vin[1] = VaultConnector_r`, `vout[0] = D_d → P_{O_j}`, `vout[1] = AdmissionTicketUTXO` recycled at `546` sats, `vout[2] = 0`-sat `P2A`): | |
| 132 | 152 | ```text | |
| 133 | - | # 256 iterations (k = 0..255, b_k = bit k of SHA256(outpoint_d)): | |
| 153 | + | # 256 iterations (k = 0..255, b_k = bit k of pre-funding acyclic vault_id): | |
| 134 | 154 | OP_HASH160 <H_{k, b_k}> OP_EQUALVERIFY | |
| 135 | 155 | ... | |
| @@ -141,65 +161,83 @@ | |||
| 141 | 161 | - Control block: **`321 B`** (depth 9 for `320` leaves at Stage 1A `M = 5, R = 64`) or **`417 B`** (depth 12 for `2,560` leaves at Stage 2 `40` lanes × `64`). | |
| 142 | 162 | - Peak stack elements: **`258 << 1,000`** BIP-342 limit. | |
| 143 | - | - Total `TakeTx` weight: `~3,071–3,095 vB` (+ `VaultConnector_r` `~100 vB` ≈ **`~3,170–3,200 vB ≤ 10,000 vB` TRUC v3**). | |
| 144 | - | - **Equivocation Solvency:** If `O_j` committed `U_1` in `RoundTx_r`, passed `T_take = 1,152`, and broadcast `TakeTx` on `U_2 ≠ U_1`, `O_j` MUST reveal both preimages for `~128` differing bits `k`, letting any `1-of-∞` challenger execute `BurnBondTx_{r,k}` on `Stake_r` Leaf 4 during `[1,152, 1,296]` (`144`-blk window). `100%` of `2.00 BTC` `Bond_BTC` burns to `OP_RETURN`, and the STARK burns `D_d` (`≤ 0.50 BTC`) from `O_j`'s `B_zbtc` (`0.60 BTC`) + pays `0.05 BTC` equivocation bounty — keeping remaining `zBTC` **100% 1:1 solvent (`0` user loss)**. | |
| 163 | + | - Total `TakeTx` weight (incl. `VaultConnector_r` input + recycled `AdmissionTicketUTXO` output + `P2A`): **`~3,142 vB`** (depth 9) / **`~3,166 vB`** (depth 12) **`≤ 3,200 vB ≤ 10,000 vB` TRUC v3 parent** (must spend confirmed `VaultConnector_r` only). | |
| 164 | + | - **Equivocation Solvency:** If `O_j` committed `vault_id_1` in `RoundTx_r`, passed `T_take = 1,728`, and broadcast `TakeTx` on `vault_id_2 ≠ vault_id_1`, `O_j` MUST reveal both preimages for `~128` differing bits `k`, letting any `1-of-∞` challenger execute `BurnBondTx_{r,k}` on `Stake_r` Leaf 4 during `[1,728, 1,872]` (`144`-blk window). `100%` of `2.00 BTC` `Bond_BTC` burns to `OP_RETURN`, and the STF burns `D_d` (`≤ 0.50 BTC`) from `O_j`'s hard-partitioned `B_custody` (`0.55 BTC`) + pays `0.05 BTC` equivocation bounty (and restores `R[O_k] += D_d` if `vault_id_2` was assigned to another honest operator `O_k`) — keeping remaining `zBTC` **100% 1:1 solvent (`0` user loss)**. | |
| 145 | 165 | ||
| 146 | 166 | --- | |
| 147 | 167 | ||
| 148 | - | ## 4. Front-Run-Proof, Collusion-Resistant Verifier Economics (`H-4` Closed) | |
| 168 | + | ## 4. Native-L1, Collusion-Proof, Crisis-Discount-Immune Verifier Economics (`R8-H02`, `R8-N05` Closed) | |
| 149 | 169 | ||
| 150 | - | Every `ChallengeTx_{r,i}` opened by Verifier `V_i` during `[0, 144]` locks **`F_chal = 0.40 BTC`** in **`ChalEscrow_{r,i}`** (NOT sent to `O_j` upfront!) and appends `41 B` `OP_RETURN "ZBTX" || 0x04 || kickoffTxid || verifierAcctId_i`: | |
| 151 | - | - `ChalEscrow_{r,i}` pays `0.40 BTC` to `O_j` **ONLY IF** `O_j` wins `Dispute_i` (covering full `75 kvB` honest prover fees up to `533 sat/vB`); otherwise `V_i` reclaims `100%` of `0.40 BTC` cleanly. | |
| 152 | - | - Each operator lane locks **`B_zbtc = 0.60 BTC`** inside canonical Rollup state (`0.50 BTC` vault restitution / challenger-split slice + `0.05 BTC` equivocation bounty = **`0.55 BTC` hard custody floor**, PLUS **`0.05 BTC` dedicated `ExitSlotUTXO` grief buffer**). | |
| 170 | + | Every `ChallengeTx_{r,i}` opened by Verifier `V_i` during `[0, 144]` locks **`F_chal = 0.40 BTC`** in **`ChalEscrow_{r,i}`**, creates `546`-sat **`ChalProofConnector_{r,i}`**, and appends `41 B` `OP_RETURN "ZBTX" || 0x04 || kickoffTxid || verifierAcctId_i`: | |
| 171 | + | - `ChalEscrow_{r,i}` pays `0.40 BTC` to `O_j` **ONLY IF** `O_j` wins `Dispute_i` (covering full `76.53 kvB` honest prover fees + CPFP up to `522 sat/vB`); otherwise `V_i` reclaims `100%` of `0.40 BTC` cleanly. | |
| 172 | + | - Each operator lane locks **`B_zbtc = 0.60 BTC`** inside canonical Rollup state, **HARD-PARTITIONED** into two non-overlapping sub-buckets (`R8-H01`, `R8-N05`): | |
| 173 | + | - **`B_custody = 0.55 BTC`** (`0.50 BTC` max-vault Lamport equivocation restitution + `0.05 BTC` equivocation bounty; NEVER debited by `ExitSlotUTXO` griefing!), AND | |
| 174 | + | - **`B_grief = 0.05 BTC`** (strictly dedicated `ExitSlotUTXO` grief buffer). | |
| 175 | + | - **100% Native Bitcoin L1 Verifier Payouts (`0%` `zBTC` Crisis Discount, `0%` `R8-N05` Coupling!):** | |
| 176 | + | Because `DisproveTx_{r,i}` / `TimeoutSlashTx_{r,i}` spends **BOTH `Stake_r (2.00 BTC)` AND `VaultConnector_r`** (`0` BTC stolen from `U_d`), EVERY active honest challenger receives **`0.15 BTC` in native Bitcoin L1 BTC** (`vout[0]` immediately for winner `V_i`, and `vout[1..6]` `ChalPayoutEscrow_{r,j}` claimed via `ChalProofConnector_{r,j}` for every other challenger `V_j`; unclaimed slots burn after `144` blks, plus `0.95 BTC` minimum immediate `OP_RETURN` burn!). On L2, `O_j`'s `0.55 BTC` `B_custody` is additionally slashed to the protocol insurance/honest-verifier pool (not needed for positive verifier EV!). | |
| 153 | 177 | ||
| 154 | - | **Bisection Slash Matrix (`k_collude ∈ {0..6}` of `N = 7` Verifiers Colluding with Cheating `O_j` @ `500 sat/vB`):** | |
| 155 | - | Because `DisproveTx_{r,*}` / `TimeoutSlashTx_{r,*}` spends **BOTH `Stake_r` AND `VaultConnector_r`**, **`0` BTC is stolen from `U_d`** — freeing `O_j`'s entire `0.55 BTC` custody slice of `B_zbtc` to split equally across all other `k ≤ 6` challengers (`0x04` opened in `[0, 144]`): | |
| 178 | + | **Native-L1 Bisection Slash Matrix (`k_collude ∈ {0..6}` of `N = 7` Colluding Verifiers; `16.53 kvB` incl. CPFP + `0.00285 BTC` lockup + `30%` `zBTC` crisis discount):** | |
| 156 | 179 | ||
| 157 | - | | Colluding Verifiers (`k_collude`) | Vault Stolen | Winning Verifier L1 Payout (`Stake_r`) | `Bond_BTC` Burned | Each Other Honest Challenger (`B_zbtc` Split) | Honest Verifier Net EV (@ `500 sat/vB`, `0.075` fee) | Combined `(O_j + k_collude)` Net P&L | | |
| 180 | + | | Colluding Verifiers (`k_collude`) | Vault Stolen | Every Active Honest Verifier L1 Payout (`Stake_r`) | Min `Stake_r` L1 Burned | Honest Verifier Net EV @ `500 sat/vB` (`0.08265` fee + `0.00285` lockup) | Honest Verifier Net EV @ `750 sat/vB` (`0.12398` fee + `0.00285` lockup) | Combined `(O_j + k_collude)` Net P&L (L1 Only / Incl. `B_custody`) | | |
| 158 | 181 | |---|---|---|---|---|---|---| | |
| 159 | - | | `0` (all honest) | `0.00 BTC` | `0.15 BTC` (to honest winner) | `1.85 BTC` | `≥ 0.0917 BTC` (`0.55 / 6`) | **`+0.075 BTC`** (winner) / **`≥ +0.0167 BTC`** (others) | **`-2.55 BTC`** (`-2.00 - 0.55`) | | |
| 160 | - | | `1` (`V_1` throws & steals L1 payout) | `0.00 BTC` | `0.15 BTC` (to `V_1`) | `1.85 BTC` | **`0.0917 BTC`** (`0.55 / 6` each to `V_2..V_7`) | **`+0.0167 BTC`** (EVERY honest `V_2..V_7`!) | **`-2.40 BTC`** | | |
| 161 | - | | `6` (worst case: ONLY `V_7` honest; `V_1` wins L1, `V_2..V_6` also claim `0x04`) | `0.00 BTC` | `0.15 BTC` (to `V_1`) | `1.85 BTC` | **`0.0917 BTC`** (`0.55 / 6` to `V_7`) | **`+0.0167 BTC`** (`V_7` still strictly profitable!) | **`-1.9417 BTC`** (`-1.85 - 0.0917`) | | |
| 182 | + | | `0` (all honest) | `0.00 BTC` | **`0.1500 BTC` native L1** | `0.95–1.85 BTC` | **`+0.0645 BTC`** | **`+0.0232 BTC`** | **`-2.00 BTC`** L1 / **`-2.55 BTC`** total | | |
| 183 | + | | `1` (`V_1` throws & claims L1) | `0.00 BTC` | **`0.1500 BTC` native L1** | `0.95–1.70 BTC` | **`+0.0645 BTC`** | **`+0.0232 BTC`** | **`-1.85 BTC`** L1 / **`-2.40 BTC`** total | | |
| 184 | + | | `6` (worst case: ONLY `V_7` honest; `V_1..V_6` claim L1) | `0.00 BTC` | **`0.1500 BTC` native L1** | **`0.95 BTC`** | **`+0.0645 BTC`** (`V_7` strictly profitable!) | **`+0.0232 BTC`** (`V_7` STILL profitable!) | **`-1.10 BTC`** L1 / **`-1.65 BTC`** total | | |
| 162 | 185 | ||
| 163 | - | *Notice: Even if `6 of 7` verifiers collude with `O_j`, the lone honest verifier `V_7` recovers `100%` of `F_chal`, nets `≥ +0.0167 BTC` at `500 sat/vB`, and the attacker/colluding cartel suffers `-1.94` to `-2.55 BTC` net loss (`-2.55 BTC` solo; `-2.40` to `-1.9417 BTC` with `1..6` colluders) with `0` sats stolen from users!* | |
| 186 | + | *Result: Even under `6-of-7` verifier collusion, `750 sat/vB` sustained fees with `10 × 153 vB` P2A CPFP, `0.00285 BTC` lockup cost, `100%` `B_grief` exhaustion (`R8-N05`), AND a `30%` (or even `100%`!) `zBTC` crisis discount, the lone honest verifier `V_7` earns **`+0.0645 BTC` @ `500 sat/vB`** (`+0.0232 BTC` @ `750 sat/vB`, break-even **`890 sat/vB`**), while the cheating cartel loses **`-1.10` to `-2.00 BTC` on Bitcoin L1 alone** (`-1.65` to `-2.55 BTC` incl. `B_custody`) with `0` sats stolen from users!* | |
| 164 | 187 | ||
| 165 | 188 | --- | |
| 166 | 189 | ||
| 167 | - | ## 5. Atomic `(2M + 1)`-Leaf `ExitSlotUTXO` (Zero Double-Fronting, Zero Grief Freeze) | |
| 190 | + | ## 5. Atomic Active-Operator `(2M_active + 1)`-Leaf `ExitSlotUTXO` (Cyclic Priority, Zero `B_custody` Overflow — `R8-H01`, `R8-M03`, `R8-N01`) | |
| 168 | 191 | ||
| 169 | - | Every Stage 1A exit — both hostile L1 `0x01 FORCED_EXIT` (created by Mike/Bob) and cooperative `0x02 BATCH_DA` exits (created by batcher) — outputs a **`546`-sat `ExitSlotUTXO`** (P2TR, unspendable `H_NUMS` internal key) with **`2M + 1` Tapscript leaves** (zero anonymous `OP_TRUE` leaves!): | |
| 170 | - | - **Leaves `0 .. M-1` (Deterministic Priority Windows):** `<6*r> OP_CSV OP_DROP <P_{O_{k_r}}> OP_CHECKSIG` where `k_r = H(exitId || r) mod M`. | |
| 171 | - | - **Leaves `M .. 2M-1` (Registered Open Race After `6*M` Blocks):** `<6*M> OP_CSV OP_DROP <P_{O_j}> OP_CHECKSIG` for each registered operator `O_j` (depth 4 for `M = 5`, `11` leaves; depth 6 for `M = 20`, `41` leaves). | |
| 172 | - | - **Leaf `2M` (`EXIT_CANCEL`):** `<288> OP_CSV OP_DROP <cancelPubKey> OP_CHECKSIG` (`288 > 6*M` blks). | |
| 192 | + | Every Stage 1A exit (`grossSats >= max(dust(destScriptPubKey), MIN_EXIT_SATS = 100,000)` sats — `R8-M05`) — both hostile L1 `0x01 FORCED_EXIT` and cooperative `0x02 BATCH_DA` exits — outputs a **`546`-sat `ExitSlotUTXO`** (P2TR, unspendable `H_NUMS` internal key) containing ONLY **currently active, non-suspended operators** `M_active <= M` from canonical state `R_{h-1}` (`2M_active + 1` Tapscript leaves, zero anonymous `OP_TRUE` leaves!): | |
| 193 | + | - **Leaves `0 .. M_active - 1` (Collision-Free Cyclic Priority Windows — Closes `R8-M03`):** `<6*r> OP_CSV OP_DROP <P_{O_{k_r}}> OP_CHECKSIG` where **`k_r = (H(exitId) + r) mod M_active`** (`0%` repeat across `r = 0..M_active - 1`!). | |
| 194 | + | - **Leaves `M_active .. 2M_active - 1` (Registered Open Race After `6*M_active` Blocks):** `<6*M_active> OP_CSV OP_DROP <P_{O_j}> OP_CHECKSIG` for each active operator `O_j`. | |
| 195 | + | - **Leaf `2M_active` (`EXIT_CANCEL`):** `<288> OP_CSV OP_DROP <cancelPubKey> OP_CHECKSIG` (`288 > 6*M_active` blks). | |
| 173 | 196 | ||
| 174 | - | **Universal STARK Spend-or-Refund Rule (`K`-deep spend of `ExitSlotUTXO`):** | |
| 175 | - | 1. **Valid Fronting (Leaf `0..2M-1` AND `vout[0] == (destScriptPubKey, ≥ grossSats - f_op)`):** Exit marked `COMPLETED`; `ReimbursementCredit[O_j] += grossSats`. Bitcoin L1 UTXO exclusion makes double-fronting and refund-vs-front races (`M-8`) cryptographically impossible. | |
| 176 | - | 2. **Non-Paying Operator Grief Spend (Leaf `0..2M-1` AND `vout[0]` fails payout check):** STARK **atomically cancels exit, refunds full `grossSats` `zBTC` to user, slashes `0.01 BTC` grief penalty from `O_j`'s `0.05 BTC` grief buffer to user, and auto-suspends `O_j`** until `B_zbtc` is topped back up to `≥ 0.60 BTC` (protecting the `0.55 BTC` custody floor). | |
| 177 | - | 3. **User Cancel (Leaf `2M`) or Fee Bump (`0x06 EXIT_FEE_BUMP`):** `0x06` raises `f_op` in-place during fee spikes; Leaf `2M` cleanly refunds `grossSats` `zBTC` after `288` blks unfronted. | |
| 197 | + | **Universal STARK Spend-or-Refund Rule (`K`-deep spend of `ExitSlotUTXO`, `R8-H01` Hardened):** | |
| 198 | + | 1. **Valid Fronting (Leaf `0..2M_active-1` AND `vout[0] == (destScriptPubKey, ≥ grossSats - f_op)`):** Exit marked `COMPLETED`; `ReimbursementCredit[O_j] += grossSats` (tagged with the exit's creation height for oldest-`PendingExit` reimbursement priority — `R8-N01`!). Bitcoin L1 UTXO exclusion makes double-fronting and refund-vs-front races (`M-8`) cryptographically impossible. | |
| 199 | + | 2. **Non-Paying Operator Grief Spend (Leaf `0..2M_active-1` AND `vout[0]` fails payout check — Even in a `k = 20` Single-Block Burst!):** STF **atomically cancels EVERY grieved exit, refunds `100%` of `grossSats` `zBTC` to every victim (`E -> C`), deducts `min(0.01 BTC, floor(B_grief[O_j] / k_burst))` strictly from `O_j`'s hard-partitioned `B_grief` (`0.05 BTC`) to each victim in that block, auto-suspends `O_j`, and excludes `O_j` from all NEW `ExitSlotUTXO` Taproot trees!** Even a `k = 20` single-block grief burst pays every victim `250,000` sats (`0.0025 BTC`, covering a `150 vB` retry fee up to `1,666 sat/vB`), **NEVER debits 1 satoshi from `B_custody` (`0.55 BTC`), and has `0` impact on L1 `Stake_r` verifier payouts (`R8-N05`)**. | |
| 200 | + | 3. **User Cancel (Leaf `2M_active`) or Fee Bump (`0x06 EXIT_FEE_BUMP`):** `0x06` raises `f_op` in-place during fee spikes (and wallets may optionally attach a deterministic Dutch-auction `f_op` schedule); Leaf `2M_active` cleanly refunds `grossSats` `zBTC` (NOT native BTC) after `288` blks unfronted. | |
| 178 | 201 | ||
| 179 | 202 | --- | |
| 180 | 203 | ||
| 181 | - | ## 6. Stage 1A Bootstrap Capital, Throughput, Finite-Round Cap & Bank-Run Bounds | |
| 204 | + | ## 6. Stage 1A Complete Hard-BTC Capital, $2^M$ Hall's Marriage Invariant, Voluntary Unwind & Bank-Run Bounds | |
| 182 | 205 | ||
| 183 | - | Every parameter below is verified in [`scripts/verify_spec_bounds.py`](../scripts/verify_spec_bounds.py): | |
| 206 | + | ### 6.1 Complete Hard-BTC Capital & Bank-Run Table (`R8-M09`, `R8-H02`, `T_cooldown = 13.0d`) | |
| 184 | 207 | ||
| 185 | - | | Configuration (`L = 1`, `N = 7`, `R = 64`, `K = 14`, `T_cooldown = 9.0d`) | Per-Lane Bond (`Bond_BTC + B_zbtc`) | Total Op Bonds | Op Fronting Float | Verifier Standby (`7 × 0.40`) | **Total Hard BTC Capital** (`%` of `25–33 BTC` ZNN MCap) | Recycling Rate (`{0.50, 0.25, 0.25}` avg `0.333 BTC`) | **100% Bank-Run Exit Duration** (`{0.50, 0.25, 0.25}` / `{0.50, 0.50}`) | | |
| 186 | - | |---|---|---|---|---|---|---|---| | |
| 187 | - | | **Bare-Minimum Pilot (`M = 3`, `Cap_TVL ≤ 10 BTC`)** | `2.60 BTC` (`2.00 + 0.60`) | `7.80 BTC` | `2.20 BTC` | `2.80 BTC` | **`12.80 BTC`** (`~39–51%`) | `0.333` vaults/d (**`0.111 BTC/d`**) | `2.20 BTC` in ~10m + `7.80 BTC` in **`~72 days`** (`~47d` w/ `{0.50, 0.50}`) | | |
| 188 | - | | **Recommended Stage 1A Pilot (`M = 5`, `Cap_TVL ≤ 15 BTC`)** | `2.60 BTC` (`2.00 + 0.60`) | `13.00 BTC` | `3.00 BTC` | `2.80 BTC` | **`18.80 BTC`** (`~57–75%`) | `0.556` vaults/d (**`0.185 BTC/d`**) | `3.00 BTC` in ~10m + `12.00 BTC` in **`~65 days`** (`~43d` w/ `{0.50, 0.50}`) | | |
| 189 | - | | **Stage 2 Scaled (`M = 20, L = 2`, `Cap_TVL ≤ 50–200 BTC`, `K = 36–144`)** | `2.60 BTC` | `104.0 BTC` | `16.0 BTC` | `2.80 BTC` | `122.8 BTC` | `4.444` vaults/d (**`1.481 BTC/d`**) | `16 BTC` in ~10m + `34 BTC` in `~23d` (for `50 BTC` TVL) | | |
| 208 | + | Every parameter below is verified in [`scripts/verify_spec_bounds.py`](../scripts/verify_spec_bounds.py). **`Cap_user`** is net external user `zBTC` capacity; **`Cap_TVL_total = Cap_user + M × B_zbtc`** is total confirmed vault BTC covered by `K >= 18` (`spec/02 §4`): | |
| 190 | 209 | ||
| 191 | - | - **Finite-Round Admission Cap & FIFO Drainage:** New deposits are admitted only while `N_live_vaults ≤ 0.50 × RemainingTotalRounds` (`≤ 160` live vaults for `M = 5, R = 64` = `320` total slots; `160 × 0.333 = 53.3 BTC > 15 BTC` cap). Strict **FIFO oldest-vault-first** assignment (filtered by `opBitmask`) drains oldest vaults first and naturally prevents multi-year difficulty staleness. | |
| 192 | - | - **Zero Passive-Timeout Slash:** Once `U_d` is assigned to `O_j` (after `O_j` ALREADY fronted BTC to Mike!), remaining unassigned vaults equal remaining `zBTC` 1:1 even if `O_j` vanishes forever. Assigned vaults NEVER passively expire into a slashable state (eliminating withholding-miner slash attacks); only explicit `O_j`-signed `0x07 RELEASE_ASSIGNMENT` releases an assignment. | |
| 193 | - | - **Maturity & Engineering Reality:** `BitVMX-CPU` / `BitVMX-protocol` is **pre-mainnet** today. Production delivery (stripped-block STARK + `RV32IM` verifier + `StakeChain` ceremony + `ExitSlotUTXO` + third-party audit) is realistically **`12–18+ months`** for 4–6 strong engineers. | |
| 210 | + | | Configuration (`L = 1`, `N = 7`, `R = 64`, `K >= 18`, `T_cooldown = 13.0d`) | Locked Protocol Capital (`Bonds + Float + 7×F_chal`) | Mandatory Operational Reserves (`0.70` CPFP + `0.50` DA + `0.25M` Top-up) | **Total Operational Baseline (1 Dispute)** (`%` of `25–33 BTC` ZNN MCap) | Multi-Dispute Headroom (`M` Concurrent Attacks: `0.483 BTC/lane` per honest verifier) | Recycling Rate (`{0.50, 0.25, 0.25}` avg `0.333 BTC`) | **100% Bank-Run Exit Duration** (`{0.50, 0.25, 0.25}` / `{0.50, 0.50}`) | | |
| 211 | + | |---|---|---|---|---|---|---| | |
| 212 | + | | **Bare-Minimum Pilot (`M = 3`, `Cap_user ≤ 10 BTC` / `11.80` total)** | **`12.80 BTC`** (`7.80 + 2.20 + 2.80`) | `+1.95 BTC` (`0.70 + 0.50 + 0.75`) | **`14.75 BTC`** (`44.7%–59.0%`) | `1.45 BTC`/honest verifier (`~16.7–21.5 BTC` net-wide if all 7 hold `3×`) | `0.231` vaults/d (**`0.077 BTC/d`**) | `2.20 BTC` in ~10m + `7.80 BTC` in **`~101–104 days`** (`~68d` w/ `{0.50, 0.50}`) | | |
| 213 | + | | **Recommended Stage 1A Pilot (`M = 5`, `Cap_user ≤ 15 BTC` / `18.00` total)** | **`18.80 BTC`** (`13.00 + 3.00 + 2.80`) | `+2.45 BTC` (`0.70 + 0.50 + 1.25`) | **`21.25 BTC`** (`64.4%–85.0%`) | `2.41 BTC`/honest verifier (`~23.2–34.8 BTC` net-wide if all 7 hold `5×`) | `0.385` vaults/d (**`0.128 BTC/d`**) | `3.00 BTC` in ~10m + `12.00 BTC` in **`~94–104 days`** (`~62d` w/ `{0.50, 0.50}`) | | |
| 214 | + | | **Stage 2 Scaled (`M = 20, L = 2`, `Cap_user ≤ 50 BTC` / `62.0` total, `K = 42`)** | `122.8 BTC` (`104.0 + 16.0 + 2.80`) | `+11.20 BTC` | `134.0 BTC` | Scales w/ concurrent dispute cap | `3.077` vaults/d (**`1.026 BTC/d`**) | `16 BTC` in ~10m + `34 BTC` in **`~33 days`** | | |
| 194 | 215 | ||
| 216 | + | ### 6.2 Exact $2^M$ Hall's Marriage Recoverability Invariant (`R8-C04` Closed) | |
| 217 | + | ||
| 218 | + | Because vaults carry per-vault operator bitmasks `opBitmask` (`E(v) ⊆ {1..M}`) and operators consume rounds or retire asynchronously, a global scalar cap `N_live_vaults <= 0.50 * sum(r_i)` is **insufficient** and can strand historical cohorts. On EVERY `deposit_admit`, `operator_retire`, `round_consume`, and `operator_slash`, the STF MUST enforce the exact **Hall's Marriage Invariant** across all `2^M - 1` non-empty operator subsets (`<= 31` checks for `M = 5`; Edmonds-Karp max-flow if `M > 10`): | |
| 219 | + | $$\forall T \subseteq \{1..M\} \setminus \{\emptyset\}: \quad \left|\{v \in V_{\text{live}} : E(v) \subseteq T\}\right| \;\le\; \sum_{i \in T} r_i^{\text{usable}}$$ | |
| 220 | + | - **Deposit Admission Headroom:** New deposits MUST additionally satisfy `|{v ∈ V_live ∪ V_new : E(v) ⊆ T}| <= floor(0.50 * sum_{i ∈ T} r_i^usable)` for every `T` containing `E(v_new)` (`<= 160` live vaults at `M = 5, R = 64`), guaranteeing `2×` round slack even if half of an eligible subset retires or gets slashed. | |
| 221 | + | - **Tightest-Slack FIFO Assignment:** Deterministic FIFO vault assignment prioritizes the oldest eligible vault inside the **minimum-slack Hall subset** `argmin_T (sum_{i ∈ T} r_i^usable - |{v : E(v) ⊆ T}|)` so constrained legacy cohorts always drain first. | |
| 222 | + | - **Retirement Gating:** `RetireStakeTx_r` cannot unlock `O_i`'s `B_zbtc` if removing `O_i`'s remaining rounds violates Hall's Marriage Invariant above. | |
| 223 | + | - **Zero Passive-Timeout Slash:** Once `U_d` is assigned to `O_j` (moving `D_d` from `R[O_j] → AssignedObligations (A)`), assigned vaults NEVER passively expire into a slashable state (eliminating withholding-miner slash attacks); only explicit `O_j`-signed `0x07 RELEASE_ASSIGNMENT` releases an assignment. | |
| 224 | + | ||
| 225 | + | ### 6.3 Graduated TVL Ramps & Non-Custodial Voluntary Unwind Circuit Breaker (`R8-H08`) | |
| 226 | + | ||
| 227 | + | Because `vk_STF` is immutable on existing vaults (zero governance override), Stage 1A mitigates latent `vk_STF` bug risk via three non-custodial controls: | |
| 228 | + | 1. **Graduated Mainnet TVL Ramps:** Stage 1A launches with `AdmissionTicketUTXO` genesis capped strictly at **`2.0 BTC`** (90 days live bug-bounty soaking) → **`5.0 BTC`** (90 days) → **`10.0 / 15.0 BTC`** pilot cap. | |
| 229 | + | 2. **Gate G4 Formal Verification & Differential Consensus Fuzzing (`spec/05 §5`):** Mandatory formal proof of `V = C + L + E + R + A + B`, Hall's invariant, and BIP-141 witness completeness plus differential fuzzing against Bitcoin Core before mainnet launch. | |
| 230 | + | 3. **Voluntary Unwind Circuit Breaker:** If a critical non-exploited bug is discovered in `vk_STF`, Cohort 1 (`1-of-N` presigner halts new `σ_cert` attestations immediately — zero new deposits!), operators front all outstanding user `0x01` exits via `ExitSlotUTXO` to drain `zBTC` organically to `0` on Bitcoin L1, and remaining `v1` lanes retire cleanly via `RetireStakeTx_r` before launching a patched, non-commingled `zBTC_v2`. *(No governance key ever touches existing vault funds.)* | |
| 231 | + | - **Maturity & Engineering Reality:** `BitVMX-CPU` / `BitVMX-protocol` is **pre-mainnet** today. Production delivery (off-chain stripped-block ZK prover + compiled `RV32IM` wrapped-SNARK verifier ELF + `StakeChain` ceremony + `AdmissionTicketUTXO` + `ExitSlotUTXO` + Gate G1–G5 audits) is realistically **`12–18+ months`** for 4–6 strong engineers. | |
| 232 | + | ||
| 195 | 233 | --- | |
| 196 | 234 | ||
| 197 | 235 | ## 7. Stage 1B Explicit Alternative Gate: `clArk` (Covenant-Free Ark VTXOs) | |
| 198 | 236 | ||
| 199 | - | If a young project **cannot commit `~12.8–18.8 BTC` of non-yielding hard BTC** (e.g. `< 5–10 BTC` budget) OR requires mainnet launch in **`3–6 months`** OR prioritizes `0-of-N` post-round unilateral exit over pooled fungibility, **do NOT under-bond `BitVMX`/`BitVM2`** — adopt Stage 1B **`clArk`** (`Second bark` / `Ark Labs arkd` + Zenon SPV/PTLC coordination): | |
| 200 | - | - **Bootstrap Capital:** **`2–5 BTC`** active ASP liquidity (`0` slashing bonds; round turnover capped by ASP liquidity per 14–30 day VTXO expiry cycle). | |
| 237 | + | If a young project **cannot commit `~14.75–21.25+ BTC` of non-yielding hard BTC** OR requires mainnet launch in **`3–6 months`** OR prioritizes `0-of-N` post-round unilateral exit over pooled fungibility, **do NOT under-bond `BitVMX`/`BitVM2`** — adopt Stage 1B **`clArk`** (`Second bark` / `Ark Labs arkd` + automated watchtower refreshes + Zenon SPV/PTLC coordination): | |
| 238 | + | - **Bootstrap Capital:** **`2–5 BTC`** active ASP liquidity (`0` slashing bonds; round turnover capped by ASP liquidity per 30–60 day VTXO expiry cycle). | |
| 201 | 239 | - **Bob & Mike Security Model:** | |
| 202 | 240 | - **Post-L1-round (after `P_Bob`/`P_Mike` confirms in an Ark VTXO tree):** **Pure `0-of-N` unilateral exit** (zero ASP, zero Zenon signers!) by broadcasting `log2(N)` pre-signed tree-branch transactions (`N = 64 → 6` txs; `N = 1,024 → 10` txs) prior to VTXO expiry. | |
| 203 | - | - **Explicit Compromises Relinquished:** (1) **No pooled fungible `zBTC` token** (discrete VTXOs; exiting `0.25 BTC` unilaterally from a `2.0 BTC` VTXO requires exiting the entire `2.0 BTC` VTXO on-chain unless pre-split in-round); (2) **Pre-round `arkoor` transfers trust the ASP not to collude with sender `Alice`/`Bob`**; (3) **Hard VTXO expiry** forces Mike online to refresh or pay `log2(N)` L1 branch fees (small VTXOs become uneconomical during fee spikes). | |
| 241 | + | - **Explicit Compromises Relinquished:** (1) **No pooled fungible `zBTC` token** (discrete VTXOs; exiting `0.25 BTC` unilaterally from a `2.0 BTC` VTXO requires exiting the entire `2.0 BTC` VTXO on-chain unless pre-split in-round); (2) **Pre-round `arkoor` transfers trust the ASP not to collude with sender `Alice`/`Bob`** (wallets MUST separate trustless in-round VTXOs from `arkoor` balances explicitly in UX); (3) **Hard VTXO expiry** requires automated watchtowers/online refreshes or `log2(N)` L1 branch fees. | |
| 204 | 242 | ||
| 205 | 243 | --- | |
| @@ -207,5 +245,5 @@ | |||
| 207 | 245 | ## Appendix A: Non-Normative Future Tracks — Track B Pure Tier-0 Bitcoin Soft-Fork Covenant & Track A1/A2 Reference | |
| 208 | 246 | ||
| 209 | - | > **Status: NON-NORMATIVE.** Nothing in `v1` depends on Bitcoin soft forks or BitVM2/BitVM3. | |
| 247 | + | > **Status: NON-NORMATIVE.** Nothing in `v2` depends on Bitcoin soft forks or BitVM2/BitVM3. | |
| 210 | 248 | ||
| 211 | 249 | ### A.1 Track B: Pure Tier-0 (`0-of-N` Safety AND `0-of-N` Liveness) With Minimal Bitcoin Soft Fork | |
| @@ -223,7 +261,9 @@ | |||
| 223 | 261 | - **UTXO Contention Handling:** Track B-Base enforces `<1> OP_CSV` (`nSequence ≥ 1`, max 1 spend/block) + native Bitcoin RBF fee-market priority (zero `OP_BLOCKHASH`). Optional **Track B+** additionally adds `OP_BLOCKHASH` if an external `OP_RETURN` mandatory forced-exit queue (`D_force = 6` blks) without RBF bidding against batchers is desired. | |
| 224 | 262 | ||
| 225 | - | ### A.2 High-Capital / Research Reference (`BitVM2` & `BitVM3-GC`) | |
| 263 | + | ### A.2 High-Capital / Research Reference (`BitVM2` & `BitVM3-GC` + Clementine) | |
| 226 | 264 | ||
| 227 | - | - **Scaled `BitVM2` (`1-of-∞` Permissionless Challenger, Zero Soft Fork):** Viable only once `≥ 50–100+ BTC` (minimal `M=3–5`) or `532–1,454 BTC` (`40–80` lanes) of operator capital is available (`13.30–18.175 BTC`/lane at `~1.0–1.3M vB` Groth16 asserts, `nVersion = 2` non-TRUC large txs, `≤ 500 sat/vB` fee ceiling). | |
| 228 | - | - **Future `BitVM3-GC` (Garbled-Circuit SNARK, `1-of-N` Online Verifier):** Shrinks on-chain assert to `~2.4–10 kvB` and disprove to `~0.1–1.0 kvB` (`F_assert ≈ 0.20 BTC` even at `2,000 sat/vB`, `2.10 BTC`/lane), but one-time-use multi-GB (`1–5 GB`) garbled circuits currently require tens–hundreds of TB across `M × L × R × N` rounds until **reusable DV-SNARK garbled circuits** mature past early research. | |
| 265 | + | - **Scaled `BitVM2` (`1-of-∞` Permissionless Challenger, Zero Soft Fork):** Viable only once `≥ 40–91+ BTC` (minimal `M = 3–5`) or `532–1,454 BTC` (`40–80` lanes) of operator capital is available (`13.30–18.175 BTC`/lane at `~1.0–1.3M vB` Groth16 asserts, `nVersion = 2` non-TRUC large txs, `≤ 500 sat/vB` fee ceiling). | |
| 266 | + | - **Emerging `BitVM3-GC` (Garbled-Circuit SNARK + Clementine Reusable Rounds — Evaluated at Gate G2):** | |
| 267 | + | - **Advantages:** Shrinks on-chain disprove to `~93 vB`–`1.0 kvB` and `2` rounds (versus `20`-step `BitVMX-CPU`), with variable-difficulty light-client comparison and dramatically lower dispute fee exposure. | |
| 268 | + | - **Current Trade-Offs Requiring Gate G2 Resolution:** Current non-reusable BitVM3 garbled circuits introduce a **`1-of-N` garbler trust model** AND require **`1–5 GB` per one-time garbled circuit instance** — totaling **`~2.2–11.2+ TB`** of off-chain archival DA across `M × L × R × N = 5 × 1 × 64 × 7 = 2,240` rounds (until **reusable DV-SNARK garbled circuits** mature). Gate G2 explicitly benchmarks compiled `RV32IM` `BitVMX-CPU` against mature reusable `BitVM3-GC` before Stage 1A code freeze; Stage 2 always supports clean non-commingled `zBTC_v2` adoption. | |
| 229 | 269 | ||
02 SPV Oracle & L1 Rollup Ordering (Part 2) · spec/02-btc-authorization-domain-and-spv.md+56 / -41 ·open redline on page
| @@ -1,5 +1,5 @@ | |||
| 1 | 1 | # Part 2: Stage 0 Direct-on-L1 Bitcoin SPV Event Oracle & Stage 1A Bitcoin-L1-Canonical Authorization Domain | |
| 2 | 2 | ||
| 3 | - | **Document Class:** Normative Bitcoin SPV Verification & L1 Authorization Domain Specification (`v1` / `v3.0.0-rfc` — Zero-Federation Phased Architecture; supersedes archived `v0` `v2.5.0-rfc`) | |
| 3 | + | **Document Class:** Normative Bitcoin SPV Verification & L1 Authorization Domain Specification (`v2` / `v3.1.0-rfc` — Zero-Federation Phased Architecture; supersedes archived `v1` `v3.0.0-rfc` and `v0` `v2.5.0-rfc`) | |
| 4 | 4 | **Philosophical Anchor:** Stage 0 implements Zenon's non-custodial verification thesis (`zenon-developer-commons`: `essays/Verify Bitcoin, Don't Bridge It.md` & `docs/specs/spv-event-oracle-spec.md`): **Event Validity only, zero custody authority**. Stage 1A moves canonical `zBTC` authorization, data availability, and forced exit directly onto **Bitcoin L1** so that `49%–100%` Zenon compromise cannot forge state or censor exits. | |
| 5 | 5 | **Consistency Checker:** [`scripts/verify_spec_bounds.py`](../scripts/verify_spec_bounds.py) | |
| @@ -17,5 +17,5 @@ | |||
| 17 | 17 | 2. **Stage 1A — Bitcoin-L1-Canonical Authorization Domain (`vk_STF` Rollup Circuit):** | |
| 18 | 18 | - For pooled, fungible `zBTC` (`Stage 1A`), **Zenon L1 does NOT authorize mints, burns, or exits**. | |
| 19 | - | - Instead, the immutable RISC-V / ZK Rollup State Transition Function ($\mathcal{F}$, compiled to `RV32IM` for `BitVMX-CPU` `n = 8` bisection — `spec/01`) scans **complete stripped Bitcoin blocks** directly on Bitcoin L1, deriving the entire canonical `zBTC` state root $R_h$ strictly from Bitcoin's heaviest PoW chain (`0-of-N` Zenon trust; `0%` ZNN market-cap coupling). | |
| 19 | + | - Instead, an off-chain ZK prover executes the deterministic Rollup State Transition Function ($\mathcal{F}$) over **complete stripped Bitcoin blocks** directly on Bitcoin L1, deriving the entire canonical `zBTC` state root $R_h$ strictly from Bitcoin's heaviest PoW chain (`0-of-N` Zenon trust; `0%` ZNN market-cap coupling). Inside `BitVMX-CPU` (`RV32IM`), only the **constant-size wrapped SNARK verifier `vk_STF`** runs (`R8-H05`), NEVER bare 1 MB block SHA-256 scanning! | |
| 20 | 20 | ||
| 21 | 21 | --- | |
| @@ -31,9 +31,10 @@ | |||
| 31 | 31 | // retargetStartHash(32B), retargetStartTime(u32), retargetHeight(u64), mtpWindow[11](u32) } | |
| 32 | 32 | admissionDepthN : u32 // 6 blocks (provisional event admission; reversible on reorg) | |
| 33 | - | finalizationDepthK : u32 // 12 blocks (oracle event finalization depth) | |
| 33 | + | finalizationDepthK : u32 // 12 blocks (oracle event finalization depth; probabilistic PoW finality) | |
| 34 | 34 | minimumPostAnchorWork : u256 // finalizationDepthK * blockWork(genesisAnchor.nBits) | |
| 35 | 35 | retainedReorgDepth : u32 // 144 blocks (stale HeaderNode pruning ONLY; ActiveChainByHeight NEVER pruned) | |
| 36 | 36 | maximumHeaderBatch : u32 // 2 headers per SubmitHeaderBatch call | |
| 37 | 37 | maximumMerkleDepth : u32 // 16 levels (65,536 txs/block) | |
| 38 | + | minimumStrippedTxBytes : u32 // 65 B (rejects 64-byte CVE-2017-12842 interior nodes & impossibly short txs) | |
| 38 | 39 | maximumStrippedTxBytes : u32 // 6,144 B (per-call Stage 0 proof cap; fits 3x inside pinned 2.1M Plasma floor) | |
| 39 | 40 | futureTimeGuardSecs : u32 // 7,200 s (Bitcoin consensus MAX_FUTURE_BLOCK_TIME) | |
| @@ -53,5 +54,5 @@ | |||
| 53 | 54 | | `StepReorg()` | `52,500` (Simple) | `0 B` | `4 B` | `52,500` (`25 QSR`) | `<= 6` | Walk 1 incremental reorg step; emits deterministic reorg state transition if an admitted `< 12`-deep event is orphaned; flags `DeepReorgAlert = 1` if `ReorgSteps > 144`. | | |
| 54 | 55 | | `PruneStaleHeaders(hashes)` | `52,500` (Simple) | `64 B` (`2 × 32 B`) | `132 B` | `61,204` (`30 QSR`) | `<= 4` | Delete `1..2` stale `HeaderNode`s (`height < BestTip - 144 && height % 2016 != 0 && ReorgActive == 0`). | | |
| 55 | - | | `ProveTxInclusion(...)` | `73,500` (Heavy SPV) | `7,279 B` | `7,620 B` | `591,388` (`282 QSR`) | `<= 8` | Verify `>= N`-deep `strippedTx` (`<= 6,144 B`) + 1-/2-block coinbase midstate + Merkle inclusion → record `VerifiedEvent[txid]`. | | |
| 56 | + | | `ProveTxInclusion(...)` | `73,500` (Heavy SPV) | `7,279 B` | `7,620 B` | `591,388` (`282 QSR`) | `<= 8` | Verify `>= N`-deep `strippedTx` (`65..6,144 B`) + 1-/2-block coinbase midstate + Merkle inclusion → record `VerifiedEvent[txid]`. | | |
| 56 | 57 | ||
| 57 | 58 | *Exact `ProveTxInclusion` ABI Derivation (Full `32 B`-Padded Accounting):* | |
| @@ -60,10 +61,10 @@ | |||
| 60 | 61 | - Total ABI `= 260 + 7,360 = 7,620 B <= 16,384 B` (`MaxDataLength`). Base Plasma `= 73,500 + 68 × (7,620 - 4) = 591,388`. Up to **`3`** max-size `ProveTxInclusion` calls (`1,774,164 <= 2,100,000`) fit inside a single Momentum even at the pinned floor (`6` at default `4,200,000`). | |
| 61 | 62 | ||
| 62 | - | ### 2.3 Exact 1- and 2-Block Coinbase Midstate Proof (`CVE-2017-12842`) | |
| 63 | + | ### 2.3 Exact 1- and 2-Block Coinbase Midstate Proof (`CVE-2017-12842`, `R8-M06` Hardened) | |
| 63 | 64 | ||
| 64 | 65 | Every `ProveTxInclusion` call MUST verify: | |
| 65 | 66 | 1. `ChainMeta.ReorgActive == 0` and `ChainMeta.PostAnchorWork >= minimumPostAnchorWork`. | |
| 66 | 67 | 2. `ActiveChainByHeight[blockHeight]` exists and `BestTipHeight >= blockHeight + admissionDepthN - 1`. | |
| 67 | - | 3. `len(strippedTx) <= 6,144`, `len(strippedTx) != 64` (**CVE-2017-12842**), `txIndex != 0`, and no SegWit marker (`0x00 0x01`) in stripped bytes. | |
| 68 | + | 3. **`65 <= len(strippedTx) <= 6,144`** (rejects `len == 64` **CVE-2017-12842** interior-node forgery AND any impossibly short `< 65 B` non-tx byte sequence, tightened per `R8-M06`), `txIndex != 0`, valid Bitcoin non-witness transaction syntax (`vin_count >= 1`, `vout_count >= 1`, exact byte consumption), and no SegWit marker (`0x00 0x01`) in stripped bytes. | |
| 68 | 69 | 4. `doubleSHA256(strippedTx)` verifies against `merkleRootLE` via `txBranch` at `txIndex` with `len(txBranch) == len(coinbaseBranch) <= 16` and zero duplicate-sibling **CVE-2012-2459** padding. | |
| 69 | 70 | 5. **1- and 2-Block SHA-256 Coinbase Midstate Verification:** | |
| @@ -77,5 +78,5 @@ | |||
| 77 | 78 | - **Case 2 (`56 <= rem <= 63` — 2-block final padding):** Build `B_1 = finalChunkTail[0:rem] || 0x80 || 0x00^(63 - rem)` and `B_2 = 0x00^56 || bitLen(8B)`. Compute `state_1 = SHA256_Compress(sha256Midstate, B_1)`, then `innerHash = SHA256_Compress(state_1, B_2)`. | |
| 78 | 79 | - Compute `coinbaseTxid = SHA256(innerHash)` and verify `coinbaseBranch` at index `0` against `merkleRootLE` with `len(coinbaseBranch) == len(txBranch)`. | |
| 79 | - | - *Explicit Auditability Disclosure:* A midstate proof proves that Merkle index `0` is a valid non-64-byte leaf at the same tree depth as `txIndex` (completely closing CVE-2017-12842 interior-node forgery); it does **not** parse the prefix of the coinbase transaction itself. In Stage 1A below, full coinbase bytes are directly verified inside the stripped-block scanner to extract the BIP-141 witness commitment. | |
| 80 | + | - *Explicit Auditability Disclosure:* A midstate proof proves that Merkle index `0` is a valid non-64-byte leaf at the same tree depth as `txIndex` (completely closing CVE-2017-12842 interior-node forgery); it does **not** parse the prefix of the coinbase transaction itself. In Stage 1A below, full coinbase bytes are directly verified inside the off-chain ZK stripped-block scanner to extract the BIP-141 witness commitment. | |
| 80 | 81 | ||
| 81 | 82 | ### 2.4 Stage 0 Oracle Storage Layout (`BtcSpvOracleContract`) | |
| @@ -92,62 +93,76 @@ | |||
| 92 | 93 | ## 3. Stage 1A: Bitcoin-L1-Canonical Authorization Domain (`0%` Zenon Trust) | |
| 93 | 94 | ||
| 94 | - | For pooled, fungible `zBTC`, **Bitcoin L1 is the sole canonical ordering, data-availability, and forced-inclusion layer**. Zenon Pillars act strictly as **untrusted feeless soft-preconfirmation sequencers** (`spec/03 §2`, `spec/04 §2`). Even if **49%–100% of Zenon Pillars are Byzantine**, they cannot fork `zBTC`, mint 1 unbacked satoshi, or censor Bob's or Mike's exit. | |
| 95 | + | For pooled, fungible `zBTC`, **Bitcoin L1 is the sole canonical ordering, data-availability, and forced-inclusion layer**. Zenon Pillars act strictly as **untrusted L1-subsidized soft-preconfirmation sequencers** (`spec/03 §2`, `spec/04 §2`). Even if **49%–100% of Zenon Pillars are Byzantine**, they cannot fork `zBTC`, mint 1 unbacked satoshi, or censor Bob's or Mike's exit. | |
| 95 | 96 | ||
| 96 | - | ### 3.1 Canonical Bitcoin L1 Tag Schema (`OP_RETURN "ZBTX"` `<= 80 B` + Taproot Witness) | |
| 97 | + | ### 3.1 Canonical Bitcoin L1 Tag Schema (`OP_RETURN "ZBTX"` `<= 80 B` + Authenticated Taproot Witness) | |
| 97 | 98 | ||
| 98 | - | All Stage 1A protocol events are tagged on Bitcoin L1 with a `4 B` magic prefix `"ZBTX"` (`0x5a 0x42 0x54 0x58`) and `1 B` `tag` inside an `OP_RETURN` output (`<= 80 B` standardness limit). Bulk payloads (`certBlob`, mutated SMT leaves, `π_batch`, signed forced transfers) sit inside the spending transaction's Taproot script-path witness, bound by SHA-256 commitment in the `OP_RETURN` and verified against the block's BIP-141 coinbase witness commitment. | |
| 99 | + | All Stage 1A protocol events are tagged on Bitcoin L1 with a `4 B` magic prefix `"ZBTX"` (`0x5a 0x42 0x54 0x58`) and `1 B` `tag` inside an `OP_RETURN` output (`<= 80 B` standardness limit). Bulk payloads (`certBlob`, complete mutated SMT leaves, `π_batch`, signed forced transfers) sit inside the spending transaction's Taproot script-path witness, bound by SHA-256 commitment in the `OP_RETURN` and verified against the block's BIP-141 coinbase witness commitment. | |
| 99 | 100 | ||
| 100 | 101 | | Tag | Name | `OP_RETURN` Layout & Exact Size | Taproot Witness / Additional Outputs | Purpose | | |
| 101 | 102 | |---|---|---|---|---| | |
| 102 | - | | `0x00` | `DEPOSIT` | `"ZBTX"(4) \|\| 0x00(1) \|\| recipientAcctHash(32) \|\| vaultParamsHash(32)` = **`69 B`** | Input witness carries acyclic `OP_DROP` `certBlob` (`104 B <= 520 B` BIP-342 push limit) + `<pk_depositor> OP_CHECKSIG`; outputs create `{0.50, 0.25, 0.25}` BTC deleted-key vaults (`spec/01 §2.2`, zero hash cycle — `txid_dep` is fixed before presigning). | Register `K`-deep multi-tier deposit vaults (`vaultId = txid_dep : vout`) and credit `recipientAcctHash` in the Rollup SMT. | | |
| 103 | - | | `0x01` | `FORCED_EXIT` | `"ZBTX"(4) \|\| 0x01(1) \|\| exitCommitHash(32)` = **`37 B`** | Witness carries `(acctId, nonce, grossSats, maxOpFeeSats, destScriptPubKey, cancelPubKey, sig_user)`; additional output creates the **`(2M+1)`-leaf `ExitSlotUTXO`** (`546` sat dust anchor, `spec/01 §5`, `spec/03 §2.4`). | Uncensorable L1 exit for Bob (`0.50 BTC`) or Mike (`0.25 BTC`), bypassing 49%–100% Zenon censorship & Plasma spikes. | | |
| 104 | - | | `0x02` | `BATCH_DA` | `"ZBTX"(4) \|\| 0x02(1) \|\| batchCommitHash(32)` = **`37 B`** | Witness carries `prevRoot(32B) \|\| newRoot(32B) \|\| mutatedLeaves[]` (**`16 B`** existing `{acctId(4), balanceSats(8), nonce(4)}` / **`48 B`** new `{acctId(4), pubkey(32), balanceSats(8), nonce(4)}`) `\|\| π_batch` (`~256 B` Groth16 or `~15–40 KB` transparent STARK/IPA). | Anchor feeless Zenon-sequenced transfers onto Bitcoin L1 with **100% self-contained state-diff DA** (zero Zenon node needed to reconstruct SMT!). | | |
| 105 | - | | `0x03` | `FORCED_TRANSFER` | `"ZBTX"(4) \|\| 0x03(1) \|\| txCommitHash(32)` = **`37 B`** | Witness carries signed `110 B` rollup transfer (or `RollupHTLC`/`RollupPTLC` op). | Uncensorable L1 transfer fallback if Zenon censors or Dynamic Plasma spikes. | | |
| 106 | - | | `0x04` | `CHALLENGE_CLAIM` | `"ZBTX"(4) \|\| 0x04(1) \|\| kickoffTxid(32) \|\| verifierAcctId(4)` = **`41 B`** | Emitted on every `ChallengeTx_{r,i}` opened in simultaneous window `[0, 144]` (`spec/01 §4`). | Registers honest challenger eligibility for atomic `0.55 BTC` `B_zbtc` split (`>= 0.0917 BTC` each) upon `Stake_r` slash. | | |
| 107 | - | | `0x05` | `FRONT_CLAIM` | `"ZBTX"(4) \|\| 0x05(1) \|\| exitId(32) \|\| operatorId(4)` = **`41 B`** | Emitted when operator $O_j$ spends `ExitSlotUTXO` paying `destScriptPubKey` `>= grossSats - maxOpFeeSats` in `vout[0]`. | Credits `ReimbursementCredit[O_j] += grossSats` (or triggers `0.01 BTC` grief slash + refund if `vout[0]` fails payment!). | | |
| 103 | + | | `0x00` | `DEPOSIT` | `"ZBTX"(4) \|\| 0x00(1) \|\| recipientAcctHash(32) \|\| vaultParamsHash(32)` = **`69 B`** | `vin[0]` = confirmed `U_dep_wallet` (`OP_DROP` `certBlob` `104 B <= 520 B`); `vin[1..3]` = denomination-matched `AdmissionTicketUTXO`s (`R8-C03`); `vout[0..2]` = `{0.50, 0.25, 0.25}` BTC deleted-key vaults keyed by acyclic `vault_id` (`R8-C01`). | Register `K`-deep multi-tier deposit vaults (enforcing `Cap_TVL_total` via L1 ticket conservation & $2^M$ Hall invariant) and credit `recipientAcctHash`. | | |
| 104 | + | | `0x01` | `FORCED_EXIT` | `"ZBTX"(4) \|\| 0x01(1) \|\| exitCommitHash(32)` = **`37 B`** | Witness carries `(acctId, nonce, grossSats >= max(dust, MIN_EXIT_SATS=100_000), maxOpFeeSats, destScriptPubKey, cancelPubKey, sig_user)` (`R8-M05`); additional output creates active-operator **`(2M_active+1)`-leaf `ExitSlotUTXO`** (`546` sat dust anchor, `spec/01 §5`). | Uncensorable L1 exit for Bob (`0.50 BTC`) or Mike (`0.25 BTC`), bypassing 49%–100% Zenon censorship & Plasma spikes. | | |
| 105 | + | | `0x02` | `BATCH_DA` | `"ZBTX"(4) \|\| 0x02(1) \|\| batchCommitHash(32)` = **`37 B`** | Witness carries `prevRoot(32B) \|\| newRoot(32B) \|\| batcherSlotId(2B) \|\| mutatedAccounts[]` (`16 B` existing / `48 B` new, `<= 1,000` new/6-blk epoch w/ `500`-sat refundable leaf deposit) `\|\| mutatedRollupLocks[]` `\|\| cooperativeExits[]` `\|\| creditTransfers[]` `\|\| π_batch` (`R8-C05`, `R8-M01`, `R8-M02`, `R8-M04`). | Anchor feeless Zenon-sequenced transfers, `RollupLocks`, cooperative `PendingExits`, and `TransferCredit` ops onto Bitcoin L1 with **100% self-contained state-diff DA** across all non-L1-derivable SMT namespaces! | | |
| 106 | + | | `0x03` | `FORCED_TRANSFER` | `"ZBTX"(4) \|\| 0x03(1) \|\| txCommitHash(32)` = **`37 B`** | Witness carries signed `110 B` rollup transfer (or `RollupHTLC`/`RollupPTLC` / `TransferCredit` op). | Uncensorable L1 transfer fallback if Zenon censors or Dynamic Plasma spikes. | | |
| 107 | + | | `0x04` | `CHALLENGE_CLAIM` | `"ZBTX"(4) \|\| 0x04(1) \|\| kickoffTxid(32) \|\| verifierAcctId(4)` = **`41 B`** | Emitted on every `ChallengeTx_{r,i}` opened in simultaneous window `[0, 144]` (which also creates `ChalProofConnector_{r,i}` for native-L1 `0.15 BTC` payout from `Stake_r`, `spec/01 §4`). | Indexes active challengers on-chain for auditability and optional protocol insurance attribution (native L1 verifier EV comes strictly from `Stake_r`!). | | |
| 108 | + | | `0x05` | `FRONT_CLAIM` | `"ZBTX"(4) \|\| 0x05(1) \|\| exitId(32) \|\| operatorId(4)` = **`41 B`** | Emitted when active operator $O_j$ spends `ExitSlotUTXO` paying `destScriptPubKey` `>= grossSats - maxOpFeeSats` in `vout[0]`. *(Note: even untagged `ExitSlotUTXO` spends are caught by full stripped-`vin` scanning, §3.2!)* | Credits `ReimbursementCredit[O_j] += grossSats` (tagged with exit creation height for `R8-N01` oldest-exit priority; or triggers hard-partitioned `B_grief` slash + refund on non-paying spend!). | | |
| 108 | 109 | | `0x06` | `EXIT_FEE_BUMP` | `"ZBTX"(4) \|\| 0x06(1) \|\| exitId(32) \|\| newMaxOpFeeSats(8)` = **`45 B`** | Witness carries user signature over `(exitId, newMaxOpFeeSats)` where `newMaxOpFeeSats > oldMaxOpFeeSats`. | Lets Bob/Mike raise fronting incentive during L1 fee spikes without re-queuing. | | |
| 109 | - | | `0x07` | `RELEASE_ASSIGNMENT` | `"ZBTX"(4) \|\| 0x07(1) \|\| vaultId(32) \|\| operatorId(4)` = **`41 B`** | Witness carries explicit `O_j` signature voluntarily releasing an already-assigned vault (vault assignment itself is **deterministic FIFO inside $\mathcal{F}$** once `ReimbursementCredit[O_j] >= D_d`; zero passive-timeout slash, `spec/01 §6`). | Optional `O_j`-signed voluntary release returning `Vaults[vaultId]` to `UNASSIGNED` and restoring `ReimbursementCredit[O_j] += D_d`. | | |
| 110 | + | | `0x07` | `RELEASE_ASSIGNMENT` | `"ZBTX"(4) \|\| 0x07(1) \|\| vaultId(32) \|\| operatorId(4)` = **`41 B`** | Witness carries explicit `O_j` signature voluntarily releasing an assigned vault (`AssignedObligations[vaultId] -> ReimbursementCredit[O_j]`, `Vaults[vaultId] -> UNASSIGNED`). | Optional `O_j`-signed voluntary release preserving exact `V_unassigned + V_assigned = C + L + E + R + A + B` (`R8-C02`). | | |
| 110 | 111 | ||
| 111 | - | ### 3.2 Complete Stripped-Block Scan & BIP-141 Witness Binding | |
| 112 | + | ### 3.2 Off-Chain Stripped-Block ZK Scanner, Fail-Closed BIP-141 Witness Completeness & Full `vin` Tracking (`R8-C05`, `R8-H05`) | |
| 112 | 113 | ||
| 113 | - | Inside the `RV32IM` Rollup verifier $\mathcal{F}$ (executed optimistically off-chain and disprovable via `BitVMX-CPU` `n = 8` bisection on any disputed single instruction): | |
| 114 | - | 1. **Complete Stripped Block Verification (`<= 1,000,000 B` Bitcoin consensus stripped-block cap):** For every confirmed block $h$ in the canonical range `[h_prev + 1, h_tip - K + 1]`, the prover feeds the **complete stripped block** (`tx_0 .. tx_{m-1}`) into $\mathcal{F}$. $\mathcal{F}$ computes every `txid_i = doubleSHA256(stripped_tx_i)`, reconstructs the full transaction Merkle root, and asserts equality with `header[h].merkleRoot`. **No transaction in block $h$ can ever be omitted or censored by a malicious prover.** | |
| 115 | - | 2. **BIP-141 Single-Branch Witness Inclusion:** For each stripped transaction $tx_i$ carrying an `OP_RETURN "ZBTX"` output requiring witness data (`0x00`, `0x01`, `0x02`, `0x03`, `0x06`, `0x07`), $\mathcal{F}$ parses the full `tx_0` coinbase outputs to extract the unique BIP-141 witness commitment `SHA256d(witnessRoot || witnessNonce)` (verifying `tx_0` is syntactically a coinbase with `vin[0].prevout == 0x00^32 : 0xffffffff`), verifies the single `wtxid_i` Merkle branch against `witnessRoot`, and checks `SHA256(witnessPayload) == opReturnCommitHash` (or verifies the `O_j` witness signature for `0x07`). | |
| 116 | - | 3. **Deterministic Skip on Invalid `0x02 BATCH_DA`:** Because `0x02` is permissionless, anyone can post a malformed `0x02` commitment on Bitcoin L1. If a `0x02` transaction fails witness parsing, `prevRoot != R_cur`, or `Verify(π_batch) == false`, $\mathcal{F}$ **deterministically skips** that `0x02` tx without halting state progression! | |
| 114 | + | **Architecture Split (`R8-H05`):** The full stripped-block scanner and SMT updater $\mathcal{F}$ execute inside the **off-chain ZK validity prover**, producing a succinct proof verified by the immutable **`vk_STF` wrapped SNARK verifier** inside `BitVMX-CPU` (`RV32IM`, `<= 8^9` instructions, Gate G2). Inside the off-chain ZK circuit proved by `vk_STF`: | |
| 117 | 115 | ||
| 118 | - | ### 3.3 Canonical Intra-Block Ordering (Eliminating 49%–100% Zenon Forks) | |
| 116 | + | 1. **Complete Stripped Block Verification (`<= 1,000,000 B` Bitcoin consensus stripped-block cap):** For every confirmed block $h$ in `[h_prev + 1, h_tip - K + 1]`, the prover feeds the **complete stripped block** (`tx_0 .. tx_{m-1}`) into $\mathcal{F}$. $\mathcal{F}$ computes every `txid_i = doubleSHA256(stripped_tx_i)`, reconstructs the full transaction Merkle root, and asserts equality with `header[h].merkleRoot`. **No transaction in block $h$ can ever be omitted or censored by a malicious prover.** | |
| 117 | + | 2. **Mandatory Full Stripped-`vin` Scan for Untagged Protocol UTXO Spends (`R8-C05`):** $\mathcal{F}$ MUST inspect **every `vin` of EVERY stripped transaction `tx_1 .. tx_{m-1}` in block `h`** (regardless of whether the spending transaction carries an `OP_RETURN "ZBTX"` tag!) against the canonical tracked outpoint set (`VaultUTXO`, `ExitSlotUTXO`, `Stake_r`, `VaultConnector_r`, `AdmissionTicketUTXO`). Thus an attacker CANNOT bypass `ExitSlotUTXO` grief slashing, `TakeTx` Lamport equivocation accounting, `Stake_r` dual-input slashing, or `RetireStakeTx_r` detection by omitting a `"ZBTX"` tag! | |
| 118 | + | 3. **Exact BIP-141 Witness Commitment Extraction & Fail-Closed vs Deterministic-Skip Rule (`R8-C05`):** | |
| 119 | + | - $\mathcal{F}$ parses the full stripped coinbase transaction `tx_0` (verifying `vin[0].prevout == 0x00^32 : 0xffffffff`), locates the **LAST output** whose `scriptPubKey` starts with the 6-byte BIP-141 header **`0x6a24aa21a9ed`** and satisfies `len(scriptPubKey) >= 38`, and extracts `witnessCommitment = scriptPubKey[6:38]`. | |
| 120 | + | - Using coinbase **`wtxid_0 = 0x00^32`** and the coinbase witness nonce (`32 B` `witnessReservedValue`), $\mathcal{F}$ verifies `SHA256d(witnessRoot || witnessNonce) == witnessCommitment` and authenticates the exact BIP-141 **`wtxid_i` Merkle branch** for every protocol transaction `tx_i` carrying witness data (`0x00`, `0x01`, `0x02`, `0x03`, `0x06`, `0x07`, or any SegWit spend of a tracked UTXO). | |
| 121 | + | - **Strict Fail-Closed vs Skip Classification (Eliminating Witness-Withholding Censorship):** | |
| 122 | + | - **FAIL CLOSED (`REFUSED_DATA_UNAVAILABLE` — Proof Invalid!):** If a prover omits the witness bytes for a SegWit protocol transaction, submits witness bytes whose computed `wtxid_i` fails the coinbase BIP-141 `witnessRoot` Merkle proof, or fails to locate the valid last `0x6a24aa21a9ed` commitment when SegWit transactions exist, the ZK circuit **MUST REJECT** (`satisfiability = FALSE`). A prover can NEVER claim a valid `0x02`/`0x01`/`0x03` tx was "malformed" by withholding its witness! | |
| 123 | + | - **DETERMINISTIC SKIP (Only AFTER `wtxid_i` Authentication):** ONLY AFTER the exact witness bytes of `tx_i` have been cryptographically authenticated against `witnessRoot` inside the coinbase commitment may $\mathcal{F}$ deterministically skip `tx_i` if its authenticated payload fails schema decoding, `prevRoot != R_cur`, slot priority, or `Verify(π_batch) == false`. | |
| 119 | 124 | ||
| 125 | + | ### 3.3 Canonical Intra-Block Ordering & Slotted `0x02` Batcher Priority (`R8-M02`) | |
| 126 | + | ||
| 120 | 127 | Within each `K`-deep Bitcoin block $h$, $\mathcal{F}$ transitions $R_{h-1} \to R_h$ in strict deterministic order: | |
| 121 | - | 1. **Pass 1 — Deposits (`0x00 DEPOSIT`):** Process in Bitcoin block transaction-index order `i = 1..m-1`. Verify acyclic `certBlob` (`104 B`), valid `N`-of-`N` setup cohort binding, valid `{0.50, 0.25, 0.25}` BTC vault outputs, and `totalTVL + D_d <= Cap_TVL`. Credit `Accounts[recipientAcctHash].balanceSats += D_d`. | |
| 122 | - | 2. **Pass 2 — First Valid Sequenced Batch (`0x02 BATCH_DA`):** Scan block $h$ in tx-index order and apply **AT MOST ONE** valid `0x02` batch whose `prevRoot == R_after_pass_1` and whose `π_batch` verifies against the complete mutated SMT leaf list. **Any competing `0x02` batch (e.g., from a 49% Zenon fork!) automatically fails `prevRoot` matching and is deterministically ignored.** | |
| 123 | - | 3. **Pass 3 — Mandatory L1 Forced Inclusion (`0x03`, `0x01`, `0x06`):** Apply EVERY valid `0x03 FORCED_TRANSFER`, `0x01 FORCED_EXIT`, and `0x06 EXIT_FEE_BUMP` in tx-index order. Because these execute directly from Bitcoin L1, **100% hostile Zenon Pillars cannot delay or censor a single forced transfer or exit by even 1 Bitcoin block**. | |
| 124 | - | 4. **Pass 4 — Settlement, Deterministic FIFO Assignment & Slashing Events (`0x04`, `0x05`, `0x07`, `ExitSlotUTXO` spends, `Stake_r` slashes, `BurnBondTx_{r,k}`):** Process all `ExitSlotUTXO` spends (universal spend-or-refund rule, `spec/03 §2.4`), deterministic FIFO oldest-eligible-vault assignment whenever `ReimbursementCredit[O_j] >= D_d` (filtered by `opBitmask`), optional `O_j`-signed `0x07 RELEASE_ASSIGNMENT`, `ChallengeTx_{r,i}` (`0x04`), `DisproveTx`/`TimeoutSlashTx` dual-input slashes (`0.55 BTC` `B_zbtc` split across remaining challengers), and `BurnBondTx_{r,k}` Lamport equivocation slashes (`D_d` burned from `B_zbtc` + `0.05 BTC` bounty). | |
| 128 | + | 1. **Pass 1 — Deposits (`0x00 DEPOSIT`):** Process in Bitcoin block transaction-index order `i = 1..m-1`. Verify `AdmissionTicketUTXO` consumption (`vin[1..3]`), acyclic `vault_id` Taproot script derivation, `wtxid`-authenticated `certBlob` (`104 B`), valid `N`-of-`N` setup cohort binding, `{0.50, 0.25, 0.25}` BTC outputs, and the **$2^M$ Hall's Marriage Invariant** (`spec/01 §6.2`). Credit `Accounts[recipientAcctHash].balanceSats += D_d`. | |
| 129 | + | 2. **Pass 2 — First Valid Sequenced Batch (`0x02 BATCH_DA`):** Scan block $h$ in tx-index order and apply **AT MOST ONE** `wtxid`-authenticated valid `0x02` batch whose `prevRoot == R_after_pass_1`, `π_batch` verifies against the complete mutated SMT state diff (`Accounts`, `RollupLocks`, cooperative `PendingExits`, `TransferCredit`, `<= 1,000` new leaves/epoch with `500`-sat refundable deposit), and whose `batcherSlotId` matches the **deterministic slotted batcher priority** (`primary_batcher = H(header[h-1].hash) mod K_batchers` for the first 2 blocks after `prevBatchHeight + 6`, open permissionless fallback to any batcher thereafter — eliminating stale-root L1 fee burn races, `R8-M02`!). Any competing `0x02` batch (e.g. from a 49% Zenon fork) fails `prevRoot` matching and is deterministically skipped. | |
| 130 | + | 3. **Pass 3 — Mandatory L1 Forced Inclusion (`0x03`, `0x01`, `0x06`):** Apply EVERY `wtxid`-authenticated valid `0x03 FORCED_TRANSFER`, `0x01 FORCED_EXIT` (`grossSats >= max(dust, 100_000)` sats, active-operator `ExitSlotUTXO`), and `0x06 EXIT_FEE_BUMP` in tx-index order. **100% hostile Zenon Pillars cannot delay or censor a single forced transfer or exit by even 1 Bitcoin block.** | |
| 131 | + | 4. **Pass 4 — Tracked-UTXO Spends, Deterministic FIFO Assignment & Slashing Events (Full `vin` Scan + `0x04`, `0x05`, `0x07`):** Process ALL spends of tracked `ExitSlotUTXO`s (universal spend-or-refund rule with hard-partitioned `B_grief` pro-rata burst cap, `spec/01 §5`), `TakeTx` confirmations (`V_assigned -= D_v`, `AssignedObligations.pop(v)`), `0x07 RELEASE_ASSIGNMENT` (`V_assigned -> V_unassigned`, `A[v] -> R[O_j]`), deterministic tightest-slack FIFO vault assignment (`V_unassigned -> V_assigned`, `R[O_j] -> A[v]` respecting oldest-`PendingExit` credit priority, `R8-N01`), `DisproveTx`/`TimeoutSlashTx` dual-input slashes (`0` vault stolen, `B_custody` slashed), `BurnBondTx_{r,k}` Lamport equivocation slashes (`D_v` burned from `B_custody`, innocent `O_k` restored if `v` was assigned to `O_k`, `0.05 BTC` bounty), and `RetireStakeTx_r` (gating `B_zbtc` unlock on `A[O_j] == 0` and Hall's invariant). Assert exact **`V_unassigned + V_assigned == C + L + E + R + A + B`** (`R8-C02`)! | |
| 125 | 132 | ||
| 126 | 133 | --- | |
| 127 | 134 | ||
| 128 | - | ## 4. Launch-Time PoW Anchor, Retargeting & Halving-Indexed TVL-Scaled `K` | |
| 135 | + | ## 4. Launch-Time PoW Anchor, `K >= 18` Unpublished-Fork Heuristic, Heaviest-Chainwork Verification & `>= K` Deep-Reorg Circuit Breaker (`R8-H03`, `R8-M07`) | |
| 129 | 136 | ||
| 130 | - | Because Bitcoin L1 scripts without covenants cannot inspect arbitrary future chain tips directly, each finite `BitVMX` `StakeChain` lane `(j, l)` (`R = 64` rounds, active horizon `<= ~1.5` years) verifies Bitcoin PoW inside $\mathcal{F}$ anchored at lane launch (`t = 0`, **before** `Q_lane_{j,l}` deletion — zero pre-broadcast hash cycle!): | |
| 137 | + | Because Bitcoin L1 scripts without covenants cannot inspect arbitrary future chain tips directly, each finite `BitVMX` `StakeChain` lane `(j, l)` (`R = 64` rounds, active horizon `<= ~2.3` years at `T_cooldown = 13.0d`) anchors Bitcoin PoW at lane launch (`t = 0`, **before** `Q_lane_{j,l}` deletion): | |
| 131 | 138 | ||
| 132 | 139 | 1. **Launch-Time Lane Anchor `(h_lane_init, H_init, D_init)`:** Pins an **already-confirmed** Bitcoin mainnet block at lane creation, together with its 2,016-block retarget-period start header and `mtpWindow[11]`. | |
| 133 | - | 2. **Full 2,016-Block Retargeting & Difficulty Floor:** $\mathcal{F}$ validates every 80-byte Bitcoin header from `h_lane_init` to `h_tip` with exact mainnet `SetCompact`, `[302400, 4838400]`s 2,016-block retarget clamping, MTP monotonicity, and a normative difficulty-drop floor **`D(h) >= 0.50 * D(h_lane_init)`**. | |
| 134 | - | - *Explicit Difficulty-Growth Disclosure:* If mainnet difficulty grows `> 2×` during a finite lane's active lifetime, the effective private-fork difficulty ratio `α_diff = D(h_lane_init) / D_current` tightens proportionally (e.g., at `3×` growth, `α_diff = 0.33`, increasing required `K` by `1.5×`). Operators periodically retire old lanes (`RetireStakeTx` at `1,440` blocks) and launch fresh lanes re-anchored to current `D(h_lane_init)`. | |
| 135 | - | 3. **Halving-Indexed TVL-Scaled `K` Private-Fork Inequality:** To make a private PoW fork forging a fake `K`-deep state strictly unprofitable against honest mining opportunity cost, protocol TVL caps MUST satisfy: | |
| 136 | - | $$0.50 \times K \times \text{Subsidy}(\text{era}) > \text{Cap}_{\text{TVL}}$$ | |
| 140 | + | 2. **Full 2,016-Block Retargeting & Difficulty Floor:** The ZK prover validates every 80-byte Bitcoin header from `h_lane_init` to `h_tip` with exact mainnet `SetCompact`, `[302400, 4838400]`s 2,016-block retarget clamping, MTP monotonicity, and minimum difficulty floor **`D(h) >= 0.50 * D(h_lane_init)`**. *(If mainnet difficulty grows `> 2×` during a lane's active lifetime, operators retire old lanes at `2,016` blks and launch fresh lanes re-anchored to current `D`.)* | |
| 141 | + | 3. **Interactive Heaviest-Chainwork Competing-Header Challenge (`R8-H03` — Clementine / BitVM3 Light-Client Pattern):** | |
| 142 | + | - To prevent a malicious operator from submitting a valid but lower-work private fork anchored at `h_lane_init`, any verifier `V_i` challenging `RoundTx_r` in `[0, 144]` may supply a **competing valid Bitcoin header-chain proof** anchored to the same `(h_lane_init, H_init, D_init)` whose cumulative chainwork strictly exceeds the operator's claimed chain (`cumWork(H_chal) > cumWork(H_op)`) and which diverges at or before the claimed `K`-deep confirmation block. | |
| 143 | + | - Inside `vk_STF`, comparing the two header-chain SNARK commitments deterministically proves the operator asserted a non-canonical/lower-work fork and slashes `Stake_r` + `VaultConnector_r`! | |
| 144 | + | 4. **Honest Private-Fork Heuristic (`K >= 18` Hard Floor) & Budish Subsidy-Offset Disclosure (`R8-H03`):** | |
| 145 | + | - The protocol enforces a hard minimum **`K >= 18` blocks (`~3.0h` nominal)** and sizes `K` across halvings against **`Cap_TVL_total = Cap_user + M × B_zbtc`** using the **conditional unpublished-fork opportunity-cost heuristic**: | |
| 146 | + | $$0.50 \times K \times \text{Subsidy}(\text{era}) > \text{Cap}_{\text{TVL,total}}$$ | |
| 147 | + | - **Mandatory Economic Honesty Disclosure (Budish Winning-Fork Offset):** This inequality measures the *unpublished/orphaned fork* opportunity cost. Under a **majority (`>50%`) hashrate attack** where the attacker publishes the winning fork and recaptures all `K` block subsidies, the attacker's direct mining cost is only the **net electricity/hardware flow cost `κ × K × Subsidy`** (`κ ∈ [0.05, 0.50]`) PLUS external reputational/BTC-price-crash losses (`verify_spec_bounds.py` prints the exact Budish sensitivity table). Consequently, `K >= 18` delivers **probabilistic PoW finality under `<50%` honest hashrate** — NOT an unconditional economic guarantee against a `>50%` cartel! | |
| 137 | 148 | ||
| 138 | - | | Deployment Stage | `Cap_TVL` | `K` (2024–2028, `3.125 BTC` Subsidy) | `0.50 × K × Subsidy` | `K` (2028–2032, `1.5625 BTC` Subsidy) | `K` (2032–2036, `0.78125 BTC` Subsidy) | | |
| 149 | + | | Deployment Stage | `Cap_user` / **`Cap_TVL_total`** (incl. `M × B_zbtc`) | `K` (2024–2028, `3.125 BTC`) | `0.50 × K × Sub` (`K × Sub` nom) | `K` (2028–2032, `1.5625 BTC`) | `K` (2032–2036, `0.78125 BTC`) | | |
| 139 | 150 | |---|---:|---:|---:|---:|---:| | |
| 140 | - | | **Stage 1A Pilot (`M = 3`)** | `<= 10 BTC` | **`14`** (`~2.3h`) | `21.875 BTC > 10` | `14` (`10.94 > 10`) | `28` (`10.94 > 10`) | | |
| 141 | - | | **Stage 1A Expanded (`M = 5`)** | `<= 15 BTC` | **`14`** (`~2.3h`) | `21.875 BTC > 15` | `20` (`15.63 > 15`) | `40` (`15.63 > 15`) | | |
| 142 | - | | **Stage 2 Scaled (`M = 10–20`)** | `<= 50 BTC` | **`36`** (`~6.0h`) | `56.250 BTC > 50` | `66` (`51.56 > 50`) | `130` (`50.78 > 50`) | | |
| 143 | - | | **Stage 2 High-Cap (`M = 20+`)** | `<= 200 BTC` | **`144`** (`~24h`) | `225.000 BTC > 200` | `260` (`203.13 > 200`) | `516` (`201.56 > 200`) | | |
| 151 | + | | **Stage 1A Pilot (`M = 3`)** | `<= 10 BTC` / **`11.80 BTC`** | **`18`** (`~3.0h`) | `28.125` (`56.25`) `> 11.80` | `18` (`14.06 > 11.80`) | `32` (`12.50 > 11.80`) | | |
| 152 | + | | **Stage 1A Expanded (`M = 5`)** | `<= 15 BTC` / **`18.00 BTC`** | **`18`** (`~3.0h`) | `28.125` (`56.25`) `> 18.00` | `24` (`18.75 > 18.00`) | `48` (`18.75 > 18.00`) | | |
| 153 | + | | **Stage 2 Scaled (`M = 20`)** | `<= 50 BTC` / **`62.00 BTC`** | **`42`** (`~7.0h`) | `65.625` (`131.25`) `> 62.00` | `80` (`62.50 > 62.00`) | `160` (`62.50 > 62.00`) | | |
| 154 | + | | **Stage 2 High-Cap (`M = 40`)** | `<= 200 BTC` / **`224.00 BTC`** | **`144`** (`~24.0h`) | `225.00` (`450.00`) `> 224.00` | `288` (`225.00 > 224.00`) | `576` (`225.00 > 224.00`) | | |
| 144 | 155 | ||
| 156 | + | 5. **Fail-Closed Deep-Reorg (`>= K`) Circuit Breaker (`R8-M07`):** | |
| 157 | + | - All Rollup full nodes, batchers, operators, and verifiers MUST retain **`>= 144`-block rollback snapshots** of `(R_h, SMT_h)`. | |
| 158 | + | - If Bitcoin ever experiences a reorg of depth `>= K` (`>= 18` blocks), nodes MUST immediately assert **`DEEP_REORG_HALT`**: (a) freeze new `0x02` batch submissions and new operator fronting, (b) rewind canonical state to the highest common ancestor `h_fork` and deterministically replay the heavier canonical Bitcoin chain from `h_fork + 1`, (c) treat any orphaned `FrontingTx` as valid ONLY if confirmed on the canonical chain (operators explicitly accept `< K`-deep fronting risk and wait `K` blocks before claiming vault reimbursement), and (d) resume normal operation automatically once the canonical tip stabilizes `>= K` blocks past `h_fork`. | |
| 159 | + | ||
| 145 | 160 | --- | |
| 146 | 161 | ||
| 147 | 162 | ## 5. Mandatory SPV & Authorization Domain Conformance Test Vectors | |
| 148 | 163 | ||
| 149 | - | 1. **Stage 0 Header & Merkle Suite:** All 24 Bitcoin header, 2,016-block retarget (`[302400, 4838400]`s), MTP, `futureTimeGuardSecs = 7,200`, `LOWEST_BLOCK_HASH_BE` tie-break, `CVE-2012-2459`, and `CVE-2017-12842` (`len == 64` rejection) vectors. | |
| 150 | - | 2. **1- and 2-Block Coinbase Midstate Suite:** Valid coinbase proofs for BOTH `totalCoinbaseBytes % 64 ∈ [0, 55]` (1-block) AND `totalCoinbaseBytes % 64 ∈ [56, 63]` (2-block — e.g. `120 B`, `127 B`, `250 B`), plus rejection of `len(finalChunkTail) != totalCoinbaseBytes % 64` and `totalCoinbaseBytes == 64`. | |
| 164 | + | 1. **Stage 0 Header & Merkle Suite:** All 24 Bitcoin header, 2,016-block retarget (`[302400, 4838400]`s), MTP, `futureTimeGuardSecs = 7,200`, `LOWEST_BLOCK_HASH_BE` tie-break, `CVE-2012-2459`, and `CVE-2017-12842` (`len < 65` rejection, `R8-M06`) vectors. | |
| 165 | + | 2. **1- and 2-Block Coinbase Midstate Suite:** Valid coinbase proofs for BOTH `totalCoinbaseBytes % 64 ∈ [0, 55]` (1-block) AND `totalCoinbaseBytes % 64 ∈ [56, 63]` (2-block — e.g. `120 B`, `127 B`, `250 B`), plus rejection of `len(finalChunkTail) != totalCoinbaseBytes % 64` and `totalCoinbaseBytes <= 64`. | |
| 151 | 166 | 3. **Panic-Free & Plasma-Floor Fuzz Gate (`B1`, `B2`):** Malformed ABI inputs across all 4 Stage 0 oracle methods MUST return deterministic errors (zero panics, zero FIFO sequencer stalls), and exact ABI sizing of `ProveTxInclusion` (`7,620 B`, `591,388` Plasma) fits `>= 3×` inside the `2,100,000` floor and `<= 40` contract blocks/Momentum. | |
| 152 | - | 4. **Stage 1A Stripped-Block & Tag-Ordering Suite:** Deterministic skip of malformed `0x02 BATCH_DA`, rejection of competing second `0x02` batch (49% Zenon fork simulation), mandatory inclusion of `0x03`/`0x01` even when all Zenon sequencers censor, and halving-indexed `K` PoW boundary enforcement across `2024–2036`. | |
| 167 | + | 4. **Stage 1A Stripped-Block, BIP-141 Completeness & Reorg Suite (`R8-C05`, `R8-M07`):** Rejection (`REFUSED_DATA_UNAVAILABLE`) of omitted or `wtxid`-mismatched witnesses, extraction of the LAST `0x6a24aa21a9ed` coinbase output when multiple matching outputs exist, full stripped-`vin` detection of untagged `ExitSlotUTXO`/`VaultUTXO`/`Stake_r` spends, deterministic skip of `wtxid`-authenticated malformed `0x02 BATCH_DA`, slotted batcher priority, interactive heaviest-chainwork fork rejection, and `>= K` `DEEP_REORG_HALT` rewind/replay. | |
| 153 | 168 | ||
03 Rollup STF & Feeless Rails (Part 3) · spec/03-settlement-minted-zbtc-and-feeless-rails.md+95 / -71 ·open redline on page
| @@ -1,5 +1,5 @@ | |||
| 1 | - | # Part 3: Stage 0 Non-Custodial PTLC/HTLC Swaps, Stage 1A Sovereign Rollup STF & Feeless Zenon Rails, and Stage 1B `clArk` Coordination | |
| 1 | + | # Part 3: Stage 0 Erlang-Hardened PTLC/HTLC Swaps, Stage 1A Sovereign Rollup STF & Feeless Zenon Rails, and Stage 1B `clArk` Coordination | |
| 2 | 2 | ||
| 3 | - | **Document Class:** Normative Settlement, Rollup State Transition & Feeless Payment Specification (`v1` / `v3.0.0-rfc` — Zero-Federation Phased Architecture; supersedes archived `v0` `v2.5.0-rfc`) | |
| 3 | + | **Document Class:** Normative Settlement, Rollup State Transition & Feeless Payment Specification (`v2` / `v3.1.0-rfc` — Zero-Federation Phased Architecture; supersedes archived `v1` `v3.0.0-rfc` and `v0` `v2.5.0-rfc`) | |
| 4 | 4 | **Custody Posture:** **ZERO federated signers, ZERO ZNN governance/slashing custody coupling, ZERO federated multisig or embedded-contract pre-minting.** | |
| 5 | 5 | **Consistency Checker:** [`scripts/verify_spec_bounds.py`](../scripts/verify_spec_bounds.py) | |
| @@ -7,39 +7,40 @@ | |||
| 7 | 7 | --- | |
| 8 | 8 | ||
| 9 | - | ## 1. Stage 0: Non-Custodial PTLC & HTLC Atomic Swaps (`PtlcSpork`, `M-4` Hardened) | |
| 9 | + | ## 1. Stage 0: Erlang-Hardened Non-Custodial PTLC & HTLC Atomic Swaps (`PtlcSpork`, `M-4`, `R8-H07`) | |
| 10 | 10 | ||
| 11 | 11 | Stage 0 launches with **`0 BTC` protocol custody** (`0–5 BTC` voluntary LP capital), strictly honoring `zenon-developer-commons` (`essays/Verify Bitcoin, Don't Bridge It.md`). Native BTC stays in user self-custody on Bitcoin L1 or Lightning; Zenon swaps native ZNN/QSR/ZTS assets atomically via `PtlcContract` and `HtlcContract`. | |
| 12 | 12 | ||
| 13 | - | > **Stage 0 Scope Honesty:** Stage 0 atomic swaps do **not** create pooled, fungible `zBTC` on Zenon. A counterparty LP is required for every swap, and under a severe Zenon attack rational LPs pull liquidity. Stage 0 delivers immediate zero-custody Bitcoin interoperability while Stage 1A (`BitVMX` Sovereign Rollup) or Stage 1B (`clArk`) is built and audited. | |
| 13 | + | > **Stage 0 Scope & Conditional Atomicity Honesty (`R8-H07`):** Stage 0 atomic swaps do **not** create pooled, fungible `zBTC` on Zenon. A counterparty LP is required for every swap, and under a severe Zenon attack rational LPs pull liquidity. Furthermore, cross-chain swap atomicity is explicitly **conditional on bounded Bitcoin/Zenon block progress and timely automated refund broadcast** — never unconditional against arbitrary unbounded chain stalls. | |
| 14 | 14 | ||
| 15 | - | ### 1.1 Hardened BIP-327 Tweaked Taproot PTLC Swap (`M-4`) | |
| 15 | + | ### 1.1 Erlang-Hardened BIP-327 Tweaked Taproot PTLC Swap (`M-4`, `R8-H07` Closed) | |
| 16 | 16 | ||
| 17 | 17 | **Protocol (Alice sells BTC on Bitcoin L1; Bob sells Zenon asset on Zenon; Bob holds secret scalar $t \in \mathbb{Z}_n^*$):** | |
| 18 | 18 | 1. **Setup:** Bob sends compressed 33-byte point $T = \text{compress}(t \cdot G)$ to Alice. | |
| 19 | 19 | 2. **Bitcoin Taproot Funding (`>= 72`-Block CSV):** Compute $P_{\text{swap}} = \text{MuSig2\_KeyAgg}(pk_A, pk_B)$, Tapscript refund leaf $L_{\text{ref}} = \text{<72> OP\_CSV OP\_DROP <pk\_A> OP\_CHECKSIG}$, tweak $t_{\text{tap}} = H_{\text{"TapTweak"}}(x(P_{\text{swap}}) \parallel \text{TapLeaf}(L_{\text{ref}}))$, and $Q_{\text{swap}} = P_{\text{swap}} + t_{\text{tap}} \cdot G$ with BIP-327 accumulated tweak `t_acc` and parity `g_key`. Alice funds `0x51 0x20 || x(Q_swap)`. Let $h_{\text{conf}}$ be Bitcoin confirmation height and `now_unix` be current UTC Unix seconds. | |
| 20 | - | 3. **Absolute Unix Timestamp Lock & `2.3×` Slow-Block Margin:** | |
| 20 | + | 3. **Absolute Unix Timestamp Lock & Erlang-Safe `>= 48h` Slow-Block Margin (`R8-H07`):** | |
| 21 | 21 | - `go-zenon`'s `PtlcContract.Create` compares `momentum.Timestamp.Unix() >= param.ExpirationTime` (`origin/dev:vm/embedded/implementation/ptlc.go:326`), requiring an **absolute Unix timestamp** (NEVER a relative duration!). | |
| 22 | - | - Define `T_znn_sec = 108,000` seconds (`30.0h`, `~9,474` Momentums at observed `11.4s`/Momentum) and **`expirationTime = now_unix + T_znn_sec`**. | |
| 23 | - | - **Verified `2.3×` June-2021 Slow-Block Margin:** Bob MUST confirm his Bitcoin claim by `h_conf + 66` (`6` blocks before Alice's `h_conf + 72` refund). Even under June 2021's worst daily average block slowdown (`2.3×` nominal = `1,380s`/block), `66 × 600s × 2.3 = 91,080s = 25.3h < 30.0h`, leaving Alice **`>= 4.7h`** of honest wall-clock safety margin to extract $t$ and call `PtlcContract.Unlock`. | |
| 24 | - | - Bob calls `PtlcContract.Create(expirationTime = now_unix + 108000, pointType = 2, pointLock = compress(T), destination = Alice_Addr)` (`origin/dev:vm/embedded/definition/ptlc.go:118-129`). | |
| 25 | - | 4. **Adaptor Exchange & Explicit Grief/Free-Option Disclosure:** | |
| 22 | + | - Under Poisson block arrivals at June 2021's worst daily slowdown (`2.3×` nominal = `1,380s`/blk), an old `30h` lock suffered `P(T_72 > 30h | 2.3×) = 22.47%` (`~22.34%` in R8's continuous approx) refund-race exposure (`R8-H07`). Therefore `v3.1.0-rfc` mandates **`T_znn_sec >= 172,800` seconds (`48.0h`, `~15,158` Momentums at observed `11.4s`/Momentum)** and **`expirationTime = now_unix + T_znn_sec`**. | |
| 23 | + | - **Exact Erlang Tail Proof (`scripts/verify_spec_bounds.py`):** At `2.3×` slowdown (`λ = 1/1,380` blks/s), the 99.9th percentile of `72` blocks is `p99.9(T_72) = 38.75h`, leaving **`>= 9.25h` wall-clock tail margin** before `48.0h` and reducing tail exceedance to **`P(T_72 > 48h | 2.3×) < 10^{-6}`** (`~9.5 × 10^{-8}`)! | |
| 24 | + | - Bob calls `PtlcContract.Create(expirationTime = now_unix + 172800, pointType = 2, pointLock = compress(T), destination = Alice_Addr)` (`origin/dev:vm/embedded/definition/ptlc.go:118-129`). | |
| 25 | + | 4. **Mandatory Automated High-Fee RBF Refund Watchtower & Grief Disclosure:** | |
| 26 | 26 | - Alice sends BIP-327 adaptor partial signature $\tilde{s}_A$ within `<= 6` Bitcoin blocks of Zenon PTLC confirmation ($R' = R_A + R_B + T$ with parity $g_R$, $\tilde{s} = \tilde{s}_A + \tilde{s}_B + e \cdot g_{\text{key}} \cdot t_{\text{acc}} \pmod n$). | |
| 27 | - | - **Explicit Disclosure:** Because `PtlcContract` has **no early reclaim** prior to `ExpirationTime`, if Alice withholds $\tilde{s}_A$, Bob's Zenon funds remain grief-locked for the full `30h` duration (zero theft, pure time-lock grief). Once Alice releases $\tilde{s}_A$, Bob holds an `~8h` (`~48`-block) free option until his `h_conf + 54` (`18`-block remaining) broadcast cutoff. Production LPs bound this via small per-peer swap limits or reputation/Lightning Hold Invoices. | |
| 28 | - | 5. **Confirmed-Before-Refund Atomic Claim:** Bob completes $s = \tilde{s} + g_R \cdot t \pmod n$ with a `<pk_B>` CPFP anchor and **MUST confirm by `h_conf + 66`**. Alice extracts $t_{\text{ext}} = g_R \cdot (s - \tilde{s}) \bmod n$, checks `compress(t_ext * G) == PointLock`, and calls `PtlcContract.Unlock(ptlcId, t_ext)` (`origin/dev:vm/embedded/implementation/ptlc.go:82-97`). | |
| 27 | + | - **Mandatory Watchtower Rule (`R8-H07`):** Alice MUST NOT rely on Bob voluntarily honoring a `h_conf + 66` cutoff. Alice's wallet/watchtower MUST automatically broadcast her `<72> OP_CSV` refund transaction **immediately at height `h_conf + 72`** with aggressive RBF fee-bumping (and direct-to-miner backup if mempools exceed `200 sat/vB`) so Bob cannot confirm a late claim near `48h`! | |
| 28 | + | - **Explicit Grief Disclosure:** Because `PtlcContract` has **no early reclaim** prior to `ExpirationTime`, if Alice withholds $\tilde{s}_A$, Bob's Zenon funds remain grief-locked for the full `48h` duration (zero theft, pure time-lock grief). Production LPs bound this via small per-peer swap limits or reputation/Lightning Hold Invoices. | |
| 29 | + | 5. **Atomic Claim & Secret Extraction:** Bob completes $s = \tilde{s} + g_R \cdot t \pmod n$ with a `<pk_B>` CPFP anchor prior to Alice's block-72 watchtower refund. Alice extracts $t_{\text{ext}} = g_R \cdot (s - \tilde{s}) \bmod n$, checks `compress(t_ext * G) == PointLock`, and calls `PtlcContract.Unlock(ptlcId, t_ext)` (`origin/dev:vm/embedded/implementation/ptlc.go:82-97`). | |
| 29 | 30 | ||
| 30 | - | ### 1.2 HTLC & Lightning Submarine-Swap Gateway | |
| 31 | + | ### 1.2 Erlang-Hardened HTLC & Lightning Submarine-Swap Gateway (`R8-H07`) | |
| 31 | 32 | ||
| 32 | 33 | - **Hash Type:** ALL Bitcoin/Lightning HTLCs MUST use **`hashType = 1` (`HashTypeSHA256`, `origin/dev:vm/embedded/definition/htlc.go:92`)**. | |
| 33 | - | - **Consistent Unix-Second Arithmetic:** Let `Δ_safety_blocks = 36` (`6h` nominal, `13.8h` at `2.3×` slow blocks) and `Δ_safety_sec = 36 × 600 = 21,600s` (or `49,680s` at `2.3×`). | |
| 34 | - | - **Inbound (`LN → Zenon`):** User pays Gateway's LN Hold Invoice FIRST; ONLY AFTER Hold Invoice reaches `ACCEPTED` with `remaining_cltv_blocks >= 72` (`2 × Δ_safety_blocks`) does Gateway lock Zenon funds in `HtlcContract` with **`expirationTime_unix <= now_unix + (remaining_cltv_blocks - 36) * 600`**. Gateways MUST enforce `<= 5` concurrent pending hold invoices, `<= 0.10 BTC` exposure per peer, and a **5-minute cancel TTL**. | |
| 35 | - | - **Outbound (`Zenon → LN`):** User locks Zenon funds (`hashType = 1`, `expirationTime_unix >= now_unix + 2 * 21,600`); Gateway pays BOLT-11 invoice whose CLTV expiry satisfies `now_unix + cltv_blocks * 600 <= expirationTime_unix - 21,600`, learns preimage $r$, and unlocks Zenon `HtlcContract`. | |
| 34 | + | - **Slowdown-Adjusted Erlang-Safe Unix-Second Delta (`R8-H07`):** At `100%` hashrate, `36` nominal blocks (`6h` mean) exceed `6h` with probability `P(T_36 > 6h | 1.0×) = 47.78%`! Therefore, while Bitcoin/Lightning block delta remains `Δ_safety_blocks = 36`, **Zenon wall-clock safety delta MUST be `Δ_safety_sec >= 86,400s` (`24.0h`)** — exceeding `p99.9(T_36 | 2.3×) = 22.01h` with **`P(T_36 > 24h | 2.3×) < 0.0002`** (and `< 10^{-20}` at `1.0×` nominal!): | |
| 35 | + | - **Inbound (`LN → Zenon`):** User pays Gateway's LN Hold Invoice FIRST; ONLY AFTER Hold Invoice reaches `ACCEPTED` with `remaining_cltv_blocks >= 72` (`2 × Δ_safety_blocks`) does Gateway lock Zenon funds in `HtlcContract` with **`expirationTime_unix <= now_unix + (remaining_cltv_blocks - 36) * 600`** (ensuring `>= 36` Bitcoin blocks remain after Zenon expiry for Gateway's LN claim/cancel). Gateways MUST enforce `<= 5` concurrent pending hold invoices, `<= 0.10 BTC` exposure per peer, and a **5-minute cancel TTL**. | |
| 36 | + | - **Outbound (`Zenon → LN`):** User locks Zenon funds (`hashType = 1`, `expirationTime_unix >= now_unix + 2 * 86,400 = now_unix + 172,800` = `48h`); Gateway pays a BOLT-11 invoice whose CLTV expiry satisfies **`now_unix + (cltv_blocks * 600 * 2.3) <= expirationTime_unix - 86,400`** (leaving `>= 24h` Erlang-safe wall-clock margin even under `2.3×` slowdown!), learns preimage $r$, and unlocks Zenon `HtlcContract`. | |
| 36 | 37 | ||
| 37 | 38 | --- | |
| 38 | 39 | ||
| 39 | - | ## 2. Stage 1A: Sovereign Rollup STF $\mathcal{F}$ & Feeless Zenon Sequencer Rails | |
| 40 | + | ## 2. Stage 1A: Sovereign Rollup STF $\mathcal{F}$ & L1-Subsidized Feeless Zenon Sequencer Rails | |
| 40 | 41 | ||
| 41 | 42 | In Stage 1A, `zBTC` is a **Bitcoin-Anchored Sovereign ZK Validity Rollup** backed by **right-sized `BitVMX` (`n = 8`, `M = 3–5`, `N = 7`) deleted-key vaults** (`spec/01`). **Zero federated signers and zero ZNN governance keys touch BTC custody or `zBTC` supply.** | |
| 42 | 43 | ||
| 43 | - | ### 2.1 Immutable Rollup SMT State Schema | |
| 44 | + | ### 2.1 Immutable Rollup SMT State Schema & Exact Conservation Law With `AssignedObligations (A)` (`R8-C02`, `R8-H01`) | |
| 44 | 45 | ||
| 45 | 46 | The canonical `zBTC` ledger state $R_h$ is a 256-bit Sparse Merkle Tree (`SHA-256` / Poseidon2) maintained deterministically by $\mathcal{F}$ over Bitcoin L1 blocks (`spec/02 §3`): | |
| @@ -47,70 +48,93 @@ | |||
| 47 | 48 | | SMT Namespace | Key | Value Fields | Invariants | | |
| 48 | 49 | |---|---|---|---| | |
| 49 | - | | `Accounts` | `acctId (u32)` | `{ pubkey: bytes32 (BIP-340), balanceSats: u64, nonce: u32 }` | `balanceSats >= 0`; `nonce` strictly monotonic (`+1`/tx). | | |
| 50 | - | | `Vaults` | `vaultId (bytes32)` | `{ denomSats: u64 ∈ {50_000_000, 25_000_000}, status: UNASSIGNED \| ASSIGNED(opId, lane, round) \| REIMBURSED \| SLASHED_EQUIV }` | Total active vaults always back `Circ + PendingExits + ReimbursementCredit` 1:1. | | |
| 51 | - | | `PendingExits` | `exitId (bytes32)` | `{ acctId, grossSats, maxOpFeeSats, destScriptPubKey, cancelPubKey, exitSlotOutpoint(36B), status: OPEN \| COMPLETED \| CANCELLED }` | Created ONLY by burning `grossSats` from `Accounts[acctId]` via `0x02` or L1 `0x01`. | | |
| 52 | - | | `RollupLocks` | `lockId (bytes32)` | `{ senderAcctId, destAcctId, amountSats, expiryBtcHeight, lockType: HTLC \| PTLC, lockDigest(33B) }` | First-class rollup opcodes (`RollupHTLC`, `RollupPTLC`) for atomic swaps inside the SMT. | | |
| 53 | - | | `OperatorState` | `opId (u32)` | `{ active: bool, lanes: [L], suspended: bool }` | Auto-suspended if `B_zbtc < 0.60 BTC`/lane. | | |
| 54 | - | | `ReimbursementCredit` | `opId (u32)` | `creditSats: u64` | Incremented ONLY on `K`-deep verified `ExitSlotUTXO` payout (`vout[0]`); deterministically consumed FIFO inside $\mathcal{F}$ to assign the oldest eligible `UNASSIGNED` vault (re-credited only on explicit `O_j`-signed `0x07 RELEASE_ASSIGNMENT`). | | |
| 55 | - | | `LockedOperatorCollateral` (`B_zbtc`) | `(opId, lane)` | `collateralSats: u64` (**`60,000,000` sats = `0.60 BTC`/lane floor**) | Partitioned: `0.50 BTC` max-vault restitution + `0.05 BTC` equivocation bounty + `0.05 BTC` `ExitSlotUTXO` grief buffer. | | |
| 50 | + | | `Accounts` (`C`) | `acctId (u32)` | `{ pubkey: bytes32 (BIP-340), balanceSats: u64, nonce: u32, leafDepositSats: u64 }` | `balanceSats >= 0`; `nonce` strictly monotonic (`+1`/tx); brand-new leaf locks refundable `500`-sat `leafDepositSats` (`R8-M01`, counted in `C`). | | |
| 51 | + | | `Vaults` (`V`) | `vaultId (bytes32)` | `{ outpoint(36B), denomSats: u64 ∈ {50_000_000, 25_000_000}, opBitmask: u64, status: UNASSIGNED \| ASSIGNED(opId, lane, round) \| REIMBURSED \| SLASHED_EQUIV }` | Partitioned into $V_{\text{unassigned}}$ and $V_{\text{assigned}}$; satisfies exact $2^M$ Hall's Marriage Invariant (`spec/01 §6.2`). | | |
| 52 | + | | `PendingExits` (`E`) | `exitId (bytes32)` | `{ acctId, grossSats >= max(dust, 100_000), maxOpFeeSats, createdBtcHeight, destScriptPubKey, cancelPubKey, exitSlotOutpoint(36B), status: OPEN \| COMPLETED \| CANCELLED }` | Created ONLY by burning `grossSats` from `Accounts[acctId]` via `0x02` or L1 `0x01`; `MIN_EXIT_SATS = 100,000` sats (`0.001 BTC`, `R8-M05`). | | |
| 53 | + | | `RollupLocks` (`L`) | `lockId (bytes32)` | `{ senderAcctId, destAcctId, amountSats, expiryBtcHeight, lockType: HTLC \| PTLC, lockDigest(33B) }` | First-class rollup opcodes (`RollupHTLC`, `RollupPTLC`) serialized in `0x02 BATCH_DA` (`R8-C05`). | | |
| 54 | + | | `OperatorState` | `opId (u32)` | `{ active: bool, lanes: [L], remainingRounds: u32, suspended: bool }` | Auto-suspended & excluded from all new `ExitSlotUTXO`s if `B_grief < 0.05 BTC` or `B_custody < 0.55 BTC`. | | |
| 55 | + | | `ReimbursementCredit` (`R`) | `opId (u32)` | `{ creditSats: u64, oldestBackedExitHeight: u32 }` | Incremented ONLY on `K`-deep verified `ExitSlotUTXO` payout (`vout[0]`); supports signed `TransferCredit(from_op, to_op, amt)` (`R8-M04`) and oldest-`PendingExit` priority (`R8-N01`). | | |
| 56 | + | | `AssignedObligations` (`A`) | `vaultId (bytes32)` | `{ opId: u32, lane: u8, round: u16, denomSats: u64, assignedHeight: u32 }` | **Explicitly tracks pending `TakeTx` claims across the `T_take = 1,728`-block gap (`R8-C02`)!** Created atomically on FIFO assignment (`R -> A`), destroyed on `TakeTx` confirmation (`V_assigned, A -> 0`) or `0x07` release (`A -> R`). | | |
| 57 | + | | `LockedOperatorCollateral` (`B`) | `(opId, lane)` | `{ bCustodySats: u64 (floor 55_000_000), bGriefSats: u64 (floor 5_000_000) }` | **Hard-partitioned (`R8-H01`, `R8-N05`):** `bCustodySats` (`0.55 BTC`) NEVER debited by `ExitSlotUTXO` griefing; `bGriefSats` (`0.05 BTC`) exclusively absorbs grief penalties. Total `B_zbtc = 0.60 BTC`/lane. | | |
| 56 | 58 | ||
| 57 | - | **Global Solvency Conservation Invariant (Checked on Every State Transition $R_{h-1} \to R_h$):** | |
| 58 | - | $$\sum_{v \in \text{Unassigned} \cup \text{Assigned}} D_v \;=\; \sum_{a \in \text{Accounts}} \text{balance}_a \;+\; \sum_{\ell \in \text{RollupLocks}} \text{amt}_\ell \;+\; \sum_{e \in \text{PendingExits}_{\text{OPEN}}} \text{gross}_e \;+\; \sum_{o} \text{ReimbursementCredit}_o \;+\; \sum_{o,l} B_{\text{zbtc}}(o,l)$$ | |
| 59 | + | **Amended Global Solvency Conservation Invariant (`R8-C02` Closed — Checked on EVERY State Transition $R_{h-1} \to R_h$):** | |
| 60 | + | $$\underbrace{\sum_{v \in \text{Unassigned}} D_v}_{V_{\text{unassigned}}} \;+\; \underbrace{\sum_{v \in \text{Assigned}} D_v}_{V_{\text{assigned}}} \;=\; \underbrace{\sum_{a \in \text{Accounts}} (\text{bal}_a + \text{dep}_a)}_{C} \;+\; \underbrace{\sum_{\ell \in \text{Locks}} \text{amt}_\ell}_{L} \;+\; \underbrace{\sum_{e \in \text{Exits}_{\text{OPEN}}} \text{gross}_e}_{E} \;+\; \underbrace{\sum_{o} \text{Credit}_o}_{R} \;+\; \underbrace{\sum_{v \in \text{Assigned}} \text{Obl}_v}_{A} \;+\; \underbrace{\sum_{o,l} (B_{\text{custody}} + B_{\text{grief}})}_{B}$$ | |
| 59 | 61 | ||
| 60 | - | ### 2.2 Honest Feeless Zenon Sequencer Rails (`M-9`, `M-10`) | |
| 62 | + | **Exact Atomic Conservation Matrix Across Every Lifecycle Transition:** | |
| 61 | 63 | ||
| 64 | + | | Transition | $\Delta V_{\text{unassigned}}$ | $\Delta V_{\text{assigned}}$ | $\Delta C$ | $\Delta E$ | $\Delta R$ | $\Delta A$ | $\Delta B$ | Net $\Delta(\text{LHS} - \text{RHS})$ | | |
| 65 | + | |---|---:|---:|---:|---:|---:|---:|---:|---:| | |
| 66 | + | | `deposit` (`0x00`) | $+D$ | $0$ | $+D$ | $0$ | $0$ | $0$ | $0$ | **`0`** | | |
| 67 | + | | `forced_exit` (`0x01`) / `0x02` exit | $0$ | $0$ | $-g$ | $+g$ | $0$ | $0$ | $0$ | **`0`** | | |
| 68 | + | | `front_paid` (`ExitSlotUTXO` valid) | $0$ | $0$ | $0$ | $-g$ | $+g$ | $0$ | $0$ | **`0`** | | |
| 69 | + | | `front_grief` (`k`-burst pro-rata `p <= B_grief`) | $0$ | $0$ | $+g + p$ | $-g$ | $0$ | $0$ | $-p$ (`B_grief` only!) | **`0`** | | |
| 70 | + | | `exit_cancel` (Leaf `2M_active`) | $0$ | $0$ | $+g$ | $-g$ | $0$ | $0$ | $0$ | **`0`** | | |
| 71 | + | | `fifo_assign` (oldest tightest-slack vault $v$) | $-D_v$ | $+D_v$ | $0$ | $0$ | $-D_v$ | $+D_v$ | $0$ | **`0`** | | |
| 72 | + | | `take_confirmed` (after `T_take = 1,728` blks) | $0$ | $-D_v$ | $0$ | $0$ | $0$ | $-D_v$ | $0$ | **`0`** | | |
| 73 | + | | `release_assignment` (`0x07`, signed by $O_j$) | $+D_v$ | $-D_v$ | $0$ | $0$ | $+D_v$ | $-D_v$ | $0$ | **`0`** | | |
| 74 | + | | `disprove_dual_slash` (`Stake_r + VaultConnector_r`) | $+D_v$ (if assigned) | $-D_v$ (if assigned) | $+0.55$ (insurance) | $0$ | $+D_v$ (if assigned) | $-D_v$ (if assigned) | $-0.55$ (`B_custody`) | **`0`** | | |
| 75 | + | | `lamport_equivocation_slash` (unassigned $v$ stolen) | $-D_v$ | $0$ | $+0.05$ (bounty) | $0$ | $0$ | $0$ | $-(D_v + 0.05)$ (`B_custody`) | **`0`** | | |
| 76 | + | | `lamport_equivocation_slash` (assigned to innocent $O_k$!) | $0$ | $-D_v$ | $+0.05$ (bounty) | $0$ | $+D_v$ ($O_k$ whole!) | $-D_v$ | $-(D_v + 0.05)$ (`B_custody`) | **`0`** | | |
| 77 | + | | `transfer_credit` (`O_a -> O_b`, `R8-M04`) | $0$ | $0$ | $0$ | $0$ | $0$ ($-x/+x$) | $0$ | $0$ | **`0`** | | |
| 78 | + | | `retire` (`RetireStakeTx_r` + Hall OK + $A[O_j]=0$) | $0$ | $0$ | $+B_j + R_j$ | $0$ | $-R_j$ | $0$ | $-B_j$ | **`0`** | | |
| 79 | + | ||
| 80 | + | ### 2.2 Honest L1-Subsidized Feeless Zenon Sequencer Rails & Two-Column Throughput Table (`M-9`, `M-10`, `R8-M01`, `R8-M08`) | |
| 81 | + | ||
| 62 | 82 | - **Exact Zenon Transport Format (NOT Native `TokenContract` ZTS):** | |
| 63 | - | - Because `TokenContract` ZTS transfers depend on Zenon L1 consensus (which fails at 49% — `spec/04 §1`), Stage 1A `zBTC` balances live strictly in the Rollup SMT above, **NOT** in `go-zenon`'s `TokenContract`. | |
| 64 | - | - Users transmit signed `110 B` rollup transactions (`op(1) || domain(1) || fromAcctId(4) || toAcctId(4) || amountSats(8) || nonce(4) || batchTipSats(4) || expiryBtcHeight(4) || memoTag(16) || bip340Sig(64)` = **`110 B`**; `+32 B = 142 B` when creating a new recipient pubkey) inside standard Zenon `AccountBlock.Data` (`UserSend` to a canonical burn/sequencer sink address with `Amount = 0`). | |
| 83 | + | - Stage 1A `zBTC` balances live strictly in the Bitcoin-canonical Rollup SMT, **NOT** in `go-zenon`'s `TokenContract`. | |
| 84 | + | - Users transmit signed `110 B` rollup transactions (`op(1) || domain(1) || fromAcctId(4) || toAcctId(4) || amountSats(8) || nonce(4) || batchTipSats(4) || expiryBtcHeight(4) || memoTag(16) || bip340Sig(64)` = **`110 B`**; `+32 B = 142 B` for new recipient pubkey) inside standard Zenon `AccountBlock.Data` (`UserSend` to canonical sequencer sink with `Amount = 0`). | |
| 65 | 85 | - **Exact Zenon Plasma Cost (At Floor Price `1,000`):** | |
| 66 | 86 | $$\text{BasePlasma}(\text{110 B rollup tx}) = 21{,}000 + 68 \times 110 = \mathbf{28{,}480\text{ Plasma}}$$ | |
| 67 | - | - Funded by **`14 QSR` refundable fused Plasma** (`ceil(28,480 / 2,100) = 14 QSR`, zero burn, replenished immediately upon confirmation) OR **`42.72M` SHA3-256 PoW hashes** (`28,480 × 1,500`, `~0.15–0.4s` desktop / `~3–12s` mobile WASM). | |
| 68 | - | - **Bitcoin L1 Fee Paid by User on Zenon Transfer:** **`0` satoshis** (`0` burned ZNN/QSR; optional `batchTipSats` for fast L1 `0x02` batch inclusion). | |
| 69 | - | - **Honest `go-zenon` Throughput Ceilings (Bounded by `8 MiB` Wire Cap):** | |
| 70 | - | - Observed mainnet Momentum time is **`~11.4s`** (`origin/dev:vm/embedded/definition/spork.go:43-46`). | |
| 71 | - | - Standard 2-block Zenon transfers (`21,000` send + `21,000` receive = `42,000` Plasma): **`~4.4` tx/s** at the pinned `2,100,000` floor, **`~8.8` tx/s** at the `4,200,000` default. | |
| 72 | - | - 1-block `110 B` `AccountBlock.Data` rollup sends (`28,480` Plasma, zero receive block needed): **`~6.5` tx/s** at `2.1M` floor, **`~12.9` tx/s** at `4.2M` default. | |
| 73 | - | - **Real Hard Protocol Ceiling (`MaxMomentumContentBytes = 8 MiB`):** `origin/dev:verifier/momentum.go:93` hard-caps cumulative protobuf-serialized Momentum content at **`8,388,608 B` (`8 MiB`)** and `origin/dev:protocol/protocol.go:70` caps `MaxDetailedMomentumWireSize = 10 MiB - 2 MiB - 4 KiB` (`~8.38 MB`). At `~300–350 B` serialized per account block, a Momentum holds `~24,000–27,000` blocks **maximum** — yielding **`~1,050–1,200` full 2-block transfers/s** (or `~2,100–2,400` 1-block rollup sends/s), **NOT** the naive `4,386` tx/s implied by `2.1B / 42,000 / 11.4`! | |
| 74 | - | - **Graceful Degradation Under Dynamic Plasma DoS:** Because `origin/dev:dp/dp.go:102-151` has no absolute upper price clamp, a whale QSR attack can temporarily spike Zenon Plasma prices (`spec/05 §2.2`). Under such an attack, feeless Zenon soft preconfirmations degrade cleanly to **Bitcoin L1 `0x03 FORCED_TRANSFER` and `0x01 FORCED_EXIT`** (paying standard Bitcoin L1 miner fees, completely bypassing Zenon!). | |
| 87 | + | - Funded by **`14 QSR` refundable fused Plasma** (`ceil(28,480 / 2,100) = 14 QSR`, zero burn, replenished upon confirmation) OR **`42.72M` SHA3-256 PoW hashes**. | |
| 88 | + | - **Honest Fee Framing (`R8-M01`):** Stage 1A transfers on Zenon are **L1-subsidized soft preconfirmations (`0` sat direct user BTC fee for existing accounts)** — NOT unbounded zero-cost Bitcoin L1 DA. To defeat zero-cost `0x02` DA flooding via refundable QSR (`8.8 tx/s` spraying 1-sat dust to fresh addresses = `~3.80 BTC/day` @ `50 sat/vB`), **creating a brand-new SMT account leaf locks a refundable `500`-sat `zBTC` `leafDepositSats`** (reclaimed when the account sweeps to `0` and closes) AND `0x02` batches enforce a hard **`<= 1,000` new SMT leaves per 6-block batch epoch** cap (`<= 48 KB` witness ≈ `12 kvB`/hour max new-leaf DA!). | |
| 89 | + | - **Two-Column Throughput Reality Table (`R8-M08` Reconciled — Zenon Transport vs Bitcoin L1 `0x02` Physical DA Cap):** | |
| 90 | + | Observed Zenon Momentum cadence is **`~11.4s`** (`origin/dev:vm/embedded/definition/spork.go:43-46`), explaining the exact rates below (note: `2.1M / 28,480 / 10s = 7.37 tx/s` assumes idealized `10s` blocks rather than observed `11.4s`): | |
| 75 | 91 | ||
| 76 | - | ### 2.3 Permissionless DA Batcher Economics | |
| 92 | + | | Regime / Bottleneck | Zenon Soft-Preconfirmation Transport (`~11.4s`/Mom) | **Bitcoin L1 `0x02` Physical Mutated-Leaf DA Ceiling** (`600s`/blk, `4 MWU` = `1M vB`/blk) | | |
| 93 | + | |---|---|---| | |
| 94 | + | | **Pinned Floor (`2,100,000` Plasma/Mom)** | `4.4` 2-blk tx/s (`42,000` Plasma) / **`6.5` 1-blk rollup sends/s** (`28,480` Plasma; `7.37` at nominal `10s`) | **Blended `40 B` (`10 vB`) leaf:** `166.7 leaves/s` @ **100%** of all Bitcoin blockspace (**`1.67 leaves/s` @ 1%**) | | |
| 95 | + | | **Default Dynamic Plasma (`4,200,000`/Mom)** | `8.8` 2-blk tx/s / **`12.9` 1-blk rollup sends/s** (`14.75` at nominal `10s`) | **Existing `16 B` (`4 vB`) leaf:** `416.7 leaves/s` @ 100% of Bitcoin (**`4.17 leaves/s` @ 1%**) | | |
| 96 | + | | **Hard `go-zenon` `8 MiB` Wire Ceiling** (`MaxMomentumContentBytes = 8 MiB`, `MaxDetailedMomentumWireSize = 8.38 MB`) | **`1,050–1,200` 2-blk tx/s** (`~2,100–2,400` 1-blk sends/s; *NOT `4,386` tx/s!*) | **New `48 B` (`12 vB`) leaf:** `138.9 leaves/s` @ 100% of Bitcoin (**`1.39 leaves/s` @ 1%**, further capped to `<= 1,000` new leaves/6-blk epoch = `~0.28 new leaves/s`!) | | |
| 77 | 97 | ||
| 78 | - | - **Zero Trusted Sequencer or Protocol Treasury:** Anyone (an operator, a wallet provider, or a user) can read `AccountBlock.Data` rollup txs from Zenon, generate `π_batch`, and post `0x02 BATCH_DA` onto Bitcoin L1 with complete mutated SMT leaves (`16 B` existing / `48 B` new). | |
| 79 | - | - **Sustainable Incentives:** Batchers earn optional `batchTipSats` from rollup transfers, operator fronting fee spreads (since fronting operators need timely `0x02` batching to settle `PendingExits`), or self-sponsored batching by users/merchants. A batch of `500` transfers updating `~600` existing accounts requires `~9.6 KB` witness (`~2.4 kvB` vbytes) + `~0.1–10 kvB` proof = `~2.5–12.4 kvB` (`~0.0005–0.0025 BTC` at `20 sat/vB`, or `~100–500` sats amortized per transfer!). | |
| 98 | + | *Key takeaway (`R8-M08`):* High Zenon transport TPS (`> 10 tx/s`) translates to L1-anchored settlement ONLY to the extent transfers **net across repeated accounts** within each 6-block batch (`0x02` publishes net post-batch leaf states, not individual transactions); distinct mutated accounts per second are strictly physically bounded by Bitcoin L1 blockspace! | |
| 99 | + | - **Graceful Degradation Under Dynamic Plasma DoS:** Under a QSR whale Dynamic Plasma spike (`spec/05 §2.2`), feeless Zenon soft preconfirmations degrade cleanly to **Bitcoin L1 `0x03 FORCED_TRANSFER` and `0x01 FORCED_EXIT`**, completely bypassing Zenon! | |
| 80 | 100 | ||
| 81 | - | ### 2.4 `B_zbtc` Accounting, `ExitSlotUTXO` Spend-or-Refund & Dual-Input Slash Split | |
| 101 | + | ### 2.3 Slotted Permissionless DA Batcher Economics (`R8-M01`, `R8-M02`) | |
| 82 | 102 | ||
| 83 | - | 1. **Per-Lane `B_zbtc` Collateral (`0.60 BTC` = `60,000,000` sats):** | |
| 84 | - | - `0.50 BTC` (`maxVaultDenom`) reserved for 1:1 vault restitution if $O_j$ executes a Lamport equivocation on `TakeTx` after `T_take = 1,152`. | |
| 85 | - | - `0.05 BTC` equivocation bounty paid to the challenger who broadcasts `BurnBondTx_{r,k}` before `T_cooldown = 1,296` (on top of burning `100%` of $O_j$'s `2.00 BTC` L1 `Bond_BTC` to `OP_RETURN`). | |
| 86 | - | - `0.05 BTC` `ExitSlotUTXO` grief buffer (handles up to `5` consecutive non-paying grief attempts before hitting the `0.55 BTC` custody floor, with immediate auto-suspension on the first grief!). | |
| 87 | - | 2. **`ExitSlotUTXO` Universal Spend-or-Refund Rule (Zero Frozen Exits):** | |
| 88 | - | - Created by `0x01 FORCED_EXIT` with **`2M + 1` Tapscript leaves** (zero anonymous `OP_TRUE` leaves!): | |
| 89 | - | - Leaves `0..M-1`: Priority slot per registered operator $O_j$ (staggered `<6*j> OP_CSV OP_DROP <P_{O_j}> OP_CHECKSIG`). | |
| 90 | - | - Leaves `M..2M-1`: Open-race leaves for all registered operators (`<6*M> OP_CSV OP_DROP <P_{O_j}> OP_CHECKSIG`). | |
| 91 | - | - Leaf `2M` (`EXIT_CANCEL`): `<288> OP_CSV OP_DROP <cancelPubKey_user> OP_CHECKSIG`. | |
| 92 | - | - On **ANY `K`-deep spend** of `ExitSlotUTXO`: | |
| 93 | - | - **Valid Fronting (Leaf `0..2M-1` AND `vout[0]` pays `destScriptPubKey` `>= grossSats - maxOpFeeSats`):** Transition `PendingExits[exitId] -> COMPLETED`, credit `ReimbursementCredit[O_j] += grossSats`. | |
| 94 | - | - **Non-Paying Grief Spend (Leaf `0..2M-1` AND `vout[0]` FAILS payment check):** Atomically transition `PendingExits[exitId] -> CANCELLED`, refund full `grossSats` `zBTC` to `Accounts[acctId]`, **slash `0.01 BTC` (`1,000,000` sats) from $O_j$'s `B_zbtc` grief buffer (credited to the victim's `zBTC` balance to cover L1 retry fees)**, and **auto-suspend $O_j$** from fronting until $O_j$ tops `B_zbtc` back up to `>= 0.60 BTC`/lane! | |
| 95 | - | - **User Cancel (Leaf `2M` after `288` blocks):** Atomically transition `PendingExits[exitId] -> CANCELLED` and refund full `grossSats` `zBTC` to `Accounts[acctId]`. | |
| 96 | - | 3. **Dual-Input `Stake_r` Slash (Positive EV Even Against `6-of-7` Verifier Collusion):** | |
| 97 | - | - When `DisproveTx_{r,i}` or `TimeoutSlashTx_{r,i}` spends **BOTH `Stake_r` (`vin[0]`) AND `VaultConnector_r` (`vin[1]`)** before `T_take = 1,152`: | |
| 98 | - | - **`0` sats** are stolen from `U_d`; `Vaults[vaultId]` immediately returns to `UNASSIGNED`. | |
| 99 | - | - L1 `Stake_r` (`2.00 BTC`) splits **`0.15 BTC` → winning verifier $V_i$** and **`1.85 BTC` → `OP_RETURN` burn**. | |
| 100 | - | - Inside $\mathcal{F}$, $O_j$'s entire **`0.55 BTC` custody slice of `B_zbtc`** (`0.50 + 0.05`, untouched because `0` sats were stolen!) is **atomically split equally across all remaining `k <= 6` verifiers** who posted `0x04 CHALLENGE_CLAIM` in `[0, 144]`: each receives **`>= 0.55 / 6 = 0.09166666 BTC > 0.075 BTC`** (`15 kvB` verifier fee @ `500 sat/vB`) + `100%` of their `F_chal = 0.40 BTC` returned from `ChalEscrow_{r,j}`, guaranteeing **`>= +0.0167 BTC` positive EV** for every honest verifier even if `6 of 7` verifiers collude with $O_j$ (while attacker P&L is **`-2.55 BTC`** solo and **`-2.40` to `-1.9417 BTC`** with `1..6` colluding verifiers — strictly `-1.94` to `-2.55 BTC`!). | |
| 103 | + | - **Deterministic Slotted Batcher Priority (`R8-M02` Closed):** To prevent competing permissionless batchers from burning L1 fees on stale-root `0x02` collisions in the same block, registered batchers (zero custody power; permissionless registration via `0x03`) follow deterministic slot priority **`primary_batcher = H(header[h-1].hash) mod K_batchers`** for blocks `[prevBatchHeight + 6, prevBatchHeight + 7]`; from `prevBatchHeight + 8` onward, **any** batcher may post `0x02` permissionlessly. | |
| 104 | + | - **Sustainable Incentives:** Batchers earn optional `batchTipSats`, operator fronting fee spreads, and merchant/wallet sponsorship. A batch updating `600` existing accounts requires `9.6 KB` witness (`2.4 kvB`) + `~0.1–10 kvB` proof = `~2.5–12.4 kvB` (`~0.0005–0.0025 BTC` at `20 sat/vB`). | |
| 101 | 105 | ||
| 106 | + | ### 2.4 Hard-Partitioned `B_zbtc`, Cyclic `ExitSlotUTXO`, Oldest-Exit Priority & `TransferCredit` (`R8-H01`, `R8-H02`, `R8-N01`, `R8-N05`, `R8-M03`, `R8-M04`, `R8-M05`) | |
| 107 | + | ||
| 108 | + | 1. **Hard-Partitioned Per-Lane `B_zbtc` (`0.60 BTC` = `60,000,000` sats):** | |
| 109 | + | - **`B_custody = 0.55 BTC` (`55,000,000` sats):** Reserved strictly for `0.50 BTC` max-vault Lamport equivocation restitution + `0.05 BTC` equivocation bounty (or protocol insurance slash on dual-input `DisproveTx`). **NEVER debited by `ExitSlotUTXO` griefing!** | |
| 110 | + | - **`B_grief = 0.05 BTC` (`5,000,000` sats):** Exclusively absorbs `ExitSlotUTXO` non-paying grief penalties (`min(0.01 BTC, floor(B_grief / k_burst))` pro-rata per grieved exit in a block), guaranteeing zero `B_custody` overflow even under `k = 20` concurrent single-block griefs! | |
| 111 | + | 2. **Active-Operator `(2M_active + 1)`-Leaf `ExitSlotUTXO` With Collision-Free Cyclic Priority (`R8-M03`, `R8-H01`):** | |
| 112 | + | - Created by `0x01 FORCED_EXIT` (`grossSats >= max(dust(destScriptPubKey), MIN_EXIT_SATS = 100,000)` sats, `R8-M05`) using ONLY active non-suspended operators `M_active` from `R_{h-1}`: | |
| 113 | + | - **Leaves `0..M_active-1`:** `<6*r> OP_CSV OP_DROP <P_{O_{k_r}}> OP_CHECKSIG` where **`k_r = (H(exitId) + r) mod M_active`** (`0%` repeat across `r = 0..M_active - 1`, matching `spec/01 §5` identically!). | |
| 114 | + | - **Leaves `M_active..2M_active-1`:** Open-race leaves `<6*M_active> OP_CSV OP_DROP <P_{O_j}> OP_CHECKSIG`. | |
| 115 | + | - **Leaf `2M_active` (`EXIT_CANCEL`):** `<288> OP_CSV OP_DROP <cancelPubKey_user> OP_CHECKSIG`. | |
| 116 | + | - On **ANY `K`-deep spend** of `ExitSlotUTXO` (detected via full stripped-`vin` scan even without `0x05` tag, `R8-C05`!): | |
| 117 | + | - **Valid Fronting (`vout[0]` pays `destScriptPubKey` `>= grossSats - maxOpFeeSats`):** `PendingExits[exitId] -> COMPLETED`, `ReimbursementCredit[O_j] += grossSats`. | |
| 118 | + | - **Non-Paying Grief Spend (`vout[0]` fails payment check):** Atomically `PendingExits[exitId] -> CANCELLED`, refund `100%` of `grossSats` `zBTC` to victim (`E -> C`), distribute `min(0.01 BTC, floor(B_grief[O_j] / k_burst))` strictly from `B_grief` to each victim in that block, auto-suspend `O_j`, and exclude `O_j` from all future `ExitSlotUTXO` trees! | |
| 119 | + | - **User Cancel (Leaf `2M_active` after `288` blocks):** `PendingExits[exitId] -> CANCELLED`, refund `grossSats` `zBTC` to `Accounts[acctId]` (restores `zBTC`, NOT native BTC). | |
| 120 | + | 3. **Oldest-`PendingExit` Credit Priority & `TransferCredit` (`R8-N01`, `R8-M04`):** | |
| 121 | + | - **Anti-Self-Fronting Priority (`R8-N01`):** Whenever open retail `PendingExits` older than `6` blocks exist in the queue, deterministic FIFO vault assignment strictly prioritizes `ReimbursementCredit` earned from fronting the **oldest `createdBtcHeight`** exits ahead of fresh self-fronted exits — stopping operators from pausing par retail fronting to jump the bank-run queue via discounted self-exits! Wallets may additionally specify an optional Dutch-auction `f_op` curve via `0x06` for transparent fee discovery. | |
| 122 | + | - **Residual Credit Consolidation (`R8-M04`):** Operators holding `< 0.25 BTC` fractional `ReimbursementCredit` residuals may execute a signed **`TransferCredit(from_op, to_op, amt)`** (via `0x02` or `0x03`, conserving `sum(R)` identically) to merge residuals into a `>= 0.25 BTC` vault claim, or convert remaining `R[op]` into `Accounts[op]` (`R -> C`) upon clean retirement (`RetireStakeTx_r`). | |
| 123 | + | 4. **Native-L1 Dual-Input `Stake_r` Slash (`R8-H02`, `R8-N05`):** | |
| 124 | + | - On `DisproveTx_{r,i}` / `TimeoutSlashTx_{r,i}` spending `Stake_r` + `VaultConnector_r` before `T_take = 1,728`, **`0` sats** leave `U_d` (if `U_d` was `ASSIGNED`, `V_assigned -> V_unassigned` and `A[U_d] -> R[O_j]`). Every active honest verifier collects **`0.15 BTC` in native Bitcoin L1 BTC** directly from `Stake_r` (`vout[0]` immediate winner, `vout[1..6]` `ChalPayoutEscrow` via `ChalProofConnector`, `>= 0.95 BTC` immediate `OP_RETURN` burn), delivering **`+0.0645 BTC` net EV @ `500 sat/vB`** (`+0.0232 BTC` @ `750 sat/vB`) completely immune to `zBTC` crisis discounts and `B_grief` depletion! On L2, `O_j`'s `0.55 BTC` `B_custody` is slashed to the protocol insurance account (`B -= 0.55, C += 0.55`, exact conservation). | |
| 125 | + | ||
| 102 | 126 | ### 2.5 End-to-End State Traces: Bob (`0.50 BTC`) & Mike (`0.25 BTC`) | |
| 103 | 127 | ||
| 104 | 128 | - **Bob's Partial Recovery (`1 BTC → spend 0.50 zBTC → recover 0.50 BTC` under `49%–100%` Zenon Compromise):** | |
| 105 | - | 1. Bob deposits `1.00 BTC` via `0x00 DEPOSIT` → creates deleted-key vaults `{0.50, 0.25, 0.25}` BTC; after `K = 14` blocks, `Accounts[Bob] = 1.00 zBTC`. | |
| 106 | - | 2. Bob sends `0.50 zBTC` to Carol via `110 B` `AccountBlock.Data` on Zenon (`28,480` Plasma, `0` sat BTC fee) → batcher anchors `0x02 BATCH_DA` → `Accounts[Bob] = 0.50 zBTC`, `Accounts[Carol] = 0.50 zBTC`. | |
| 129 | + | 1. Bob confirms `U_Bob_wallet`, consumes `1 × Ticket_050 + 2 × Ticket_025`, and deposits `1.00 BTC` via `0x00 DEPOSIT` → creates deleted-key vaults `{0.50, 0.25, 0.25}` BTC keyed by acyclic `vault_id`; at `K = 18` blocks, `Accounts[Bob] = 1.00 zBTC`. | |
| 130 | + | 2. Bob sends `0.50 zBTC` to Carol via `110 B` `AccountBlock.Data` on Zenon (`28,480` Plasma, `0` sat direct BTC fee) → slotted batcher anchors `0x02 BATCH_DA` → `Accounts[Bob] = 0.50 zBTC`, `Accounts[Carol] = 0.50 zBTC`. | |
| 107 | 131 | 3. **Attack:** `49%` (or `100%`) of Zenon Pillars turn hostile, split Zenon across its 30-Momentum cliff, censor Bob on Zenon, and spike Dynamic Plasma. | |
| 108 | - | 4. **Bob Exits Directly on Bitcoin L1:** Bob broadcasts `0x01 FORCED_EXIT(0.50 BTC, P_Bob, maxOpFee)` + `ExitSlotUTXO` on Bitcoin L1 (completely bypassing Zenon!). After `K = 14` blocks, $\mathcal{F}$ burns Bob's `0.50 zBTC` and opens `PendingExits[exit_Bob]`. | |
| 109 | - | 5. Any `1-of-M` honest operator $O_j$ (`M = 3–5`) spends `ExitSlotUTXO` paying `0.50 BTC - fee` directly to `P_Bob` in `vout[0]` (~10 min on L1!), earns `ReimbursementCredit[O_j] += 0.50 BTC`, and later reclaims one `0.50 BTC` vault via `BitVMX` `RoundTx_r` → `TakeTx` (monitored by `N = 7` verifiers). **Zero Zenon signers, zero federated signers, zero ZNN trust.** | |
| 132 | + | 4. **Bob Exits Directly on Bitcoin L1:** Bob broadcasts `0x01 FORCED_EXIT(0.50 BTC, P_Bob, maxOpFee)` + active-operator `ExitSlotUTXO` on Bitcoin L1 (completely bypassing Zenon!). At `K = 18` blocks, $\mathcal{F}$ moves `0.50 zBTC` from `C → E`. | |
| 133 | + | 5. Any `1-of-M` active honest operator $O_j$ (`M = 3–5`) spends `ExitSlotUTXO` paying `0.50 BTC - fee` directly to `P_Bob` in `vout[0]` (~10 min on L1!), moves `0.50` from `E → R[O_j]`, gets FIFO-assigned one `0.50 BTC` vault (`V_unassigned -> V_assigned`, `R[O_j] -> A[v]`), and after `T_take = 1,728` blks claims the vault via `TakeTx` (`V_assigned, A -> 0`, recycling `Ticket_050`). **Zero Zenon signers, zero federated signers, zero ZNN trust.** | |
| 110 | 134 | - **Mike's Cross-Depositor Exit (`Alice 1 + Bob 1 → Mike 2 → Mike recovers 0.25 BTC` with `0` Zenon Signer Cooperation):** | |
| 111 | - | 1. Alice deposits `1.00 BTC` (`{0.50, 0.25, 0.25}`) and Bob deposits `1.00 BTC` (`{0.50, 0.25, 0.25}`); both send `1.00 zBTC` feelessly to Mike on Zenon → `0x02 BATCH_DA` sets `Accounts[Mike] = 2.00 zBTC`. | |
| 135 | + | 1. Alice (`1.00 BTC`) and Bob (`1.00 BTC`) deposit into `{0.50, 0.25, 0.25}` vaults and send `1.00 zBTC` each feelessly to Mike on Zenon → `0x02 BATCH_DA` (or Mike's `0x03 FORCED_TRANSFER` fallback) sets `Accounts[Mike] = 2.00 zBTC`. | |
| 112 | 136 | 2. **Attack:** Zero Zenon signers cooperate; Alice and Bob are offline or hostile. | |
| 113 | - | 3. **Mike Exits `0.25 BTC` Directly on Bitcoin L1:** Mike posts `0x01 FORCED_EXIT(0.25 BTC, P_Mike, maxOpFee)` + `ExitSlotUTXO`. Any `1-of-M` honest operator $O_j$ fronts `0.25 BTC - fee` directly to `P_Mike` in `vout[0]` (leaving Mike `1.75 zBTC` intact in `Accounts[Mike]`), earns `ReimbursementCredit[O_j] += 0.25 BTC`, and reclaims one `0.25 BTC` vault from the unassigned pool (`0.50 + 0.25 + 0.25` maps `0.25 BTC` 1:1 with zero change bottleneck!). | |
| 114 | - | 4. *Irreducible Residual Boundary ([`spec/01 §1.2`](./01-bitcoin-taproot-vault-enforcement.md) Corollary 1B):* If **100% of all `M = 3–5` pre-registered operators** vanish simultaneously, Mike's exit stalls until an operator returns (zero theft; Mike can reclaim his `0.25 zBTC` via Leaf `2M` `EXIT_CANCEL` after `288` blocks). Under a `100%` bank run of `15 BTC` (`3.0` float + `12.0` vaults), full queue drain takes **`~65 days`** (`M = 5`, `0.556` vaults/d ≈ `0.185 BTC/d`) or **`~72 days`** (`M = 3` on `10 BTC`, `~43–47d` with `{0.50, 0.50}` vaults). | |
| 137 | + | 3. **Mike Exits `0.25 BTC` Directly on Bitcoin L1:** Mike posts `0x01 FORCED_EXIT(0.25 BTC, P_Mike, maxOpFee)` + `ExitSlotUTXO`. Any `1-of-M` active honest operator $O_j$ fronts `0.25 BTC - fee` directly to `P_Mike` in `vout[0]` (leaving Mike `1.75 zBTC` intact), earns `R[O_j] += 0.25 BTC`, and claims one `0.25 BTC` vault via `R -> A -> TakeTx` (recycling `Ticket_025`). | |
| 138 | + | 4. *Irreducible Residual Boundary (`spec/01 §1.2` Corollary 1B, `R8-C06`):* If **`0-of-M` operators remain permanently unavailable**, Mike's native BTC exit stalls permanently (`0` theft; Leaf `2M_active` `EXIT_CANCEL` after `288` blocks restores `0.25 zBTC` inside the rollup, **NOT** native BTC on L1). Under a `100%` bank run of `15 BTC` (`3.0` float + `12.0` vaults, `T_cooldown = 13.0d`), full queue drain takes **`~94–104 days`** (`M = 5`, `0.385` vaults/d ≈ `0.128 BTC/d`) or **`~101–104 days`** (`M = 3` on `10 BTC`; `~62–68d` with `{0.50, 0.50}` vaults). | |
| 115 | 139 | ||
| 116 | 140 | --- | |
| @@ -118,11 +142,11 @@ | |||
| 118 | 142 | ## 3. Stage 1B (Alternative Gate): `clArk` VTXO Coordination Rails | |
| 119 | 143 | ||
| 120 | - | If the project cannot commit `~12.8–18.8 BTC` of hard operator/verifier capital or requires a `3–6` month mainnet ship window using existing audited open-source stacks (`Second bark/barkd` or `Ark Labs arkd`), Stage 1B offers an explicit **non-federated, zero-soft-fork alternative** with **`2–5 BTC` active ASP liquidity** (`0` dead slashing bonds): | |
| 144 | + | If the project cannot commit `~14.75–21.25+ BTC` of hard operator/verifier capital or requires a `3–6` month mainnet ship window using existing audited open-source stacks (`Second bark/barkd` or `Ark Labs arkd`), Stage 1B offers an explicit **non-federated, zero-soft-fork alternative** with **`2–5 BTC` active ASP liquidity** (`0` dead slashing bonds): | |
| 121 | 145 | ||
| 122 | 146 | - **Zenon's Role:** Feeless off-chain coordination, round scheduling, VTXO intent indexing, and Stage 0 SPV verification — **0% Zenon consensus custody dependency**. | |
| 123 | 147 | - **Exact Trade-Offs (Mandatory Disclosure):** | |
| 124 | - | 1. **Post-Round `0-of-N` Unilateral Exit (Until Expiry):** Once Mike's `0.25 BTC` VTXO is confirmed in an L1 `clArk` round tree, Mike exits unilaterally on Bitcoin L1 with **zero ASP/signer cooperation** by broadcasting his pre-signed `log2(N)` branch (`6..10` txs for `N = 64..1,024` VTXOs, using TRUC v3 + ephemeral anchors). | |
| 125 | - | 2. **Pre-Round (`arkoor`) Sender+ASP Collusion Risk:** Instant feeless out-of-round transfers (`Alice -> Mike`) are vulnerable to `Alice + ASP` double-spend collusion until the next L1 round refreshes Mike into a new VTXO tree. | |
| 126 | - | 3. **Hard VTXO Expiry & Liquidity Lockup:** VTXOs expire (e.g., `14–30` days) back to the ASP sweep key, forcing Mike online to refresh or pay `log2(N)` L1 exit fees; ASP liquidity (`2–5 BTC`) is locked `100%` for each full expiry cycle, capping round turnover to `2–5 BTC`/cycle. | |
| 148 | + | 1. **Post-Round `0-of-N` Unilateral Exit (Until Expiry):** Once Mike's `0.25 BTC` VTXO is confirmed in an L1 `clArk` round tree, Mike exits unilaterally on Bitcoin L1 with **zero ASP/signer cooperation** by broadcasting his pre-signed `log2(N)` branch (`6..10` txs for `N = 64..1,024` VTXOs, using TRUC v3 + ephemeral anchors on Core `>= 29.0`). | |
| 149 | + | 2. **Pre-Round (`arkoor`) Sender+ASP Collusion Risk:** Instant feeless out-of-round transfers (`Alice -> Mike`) are vulnerable to `Alice + ASP` double-spend collusion until the next L1 round refreshes Mike into a new VTXO tree (wallets MUST visually separate trustless in-round VTXOs from `arkoor` balances!). | |
| 150 | + | 3. **Hard VTXO Expiry & Watchtower Requirement:** VTXOs expire (e.g., `30–60` days) back to the ASP sweep key, requiring automated watchtowers/online refreshes or `log2(N)` L1 exit fees; ASP liquidity (`2–5 BTC`) is locked `100%` for each full expiry cycle, capping round turnover to `2–5 BTC`/cycle. | |
| 127 | 151 | 4. **No Global Pooled `zBTC` Token:** `clArk` VTXOs are discrete UTXO trees, not a single global fungible `zBTC` balance sheet composable with Zenon DeFi — and `clArk` VTXOs do **not** migrate automatically into Stage 1A Rollup `zBTC` without on-chain L1 settlement. | |
| 128 | 152 | ||
04 Zenon 49% Boundary & Anchoring (Part 4) · spec/04-bitcoin-anchoring-and-light-client.md+5 / -5 ·open redline on page
| @@ -1,5 +1,5 @@ | |||
| 1 | 1 | # Part 4: Zenon Consensus Reality (`go-zenon`), Inverted Trust Hierarchy & Optional Light-Client Anchoring | |
| 2 | 2 | ||
| 3 | - | **Document Class:** Normative Consensus Security Proof & Non-Custodial Anchoring Specification (`v1` / `v3.0.0-rfc` — Zero-Federation Phased Architecture; supersedes archived `v0` `v2.5.0-rfc`) | |
| 3 | + | **Document Class:** Normative Consensus Security Proof & Non-Custodial Anchoring Specification (`v2` / `v3.1.0-rfc` — Zero-Federation Phased Architecture; supersedes archived `v1` `v3.0.0-rfc` and `v0` `v2.5.0-rfc`) | |
| 4 | 4 | **Codebase Verified:** `go-zenon` `master` (`e8986a6`, `v0.0.10-alphanet`) and `origin/dev` (`770e893`) | |
| 5 | 5 | **Consistency Checker:** [`scripts/verify_spec_bounds.py`](../scripts/verify_spec_bounds.py) | |
| @@ -40,5 +40,5 @@ | |||
| 40 | 40 | ## 2. The Inverted Trust Hierarchy (`0-of-N` Zenon Trust — Surviving `49%–100%` Zenon Compromise) | |
| 41 | 41 | ||
| 42 | - | Because Zenon consensus breaks at `49%` (DPoS) and `>33.3%` (BFT) and ZNN market cap is `~25–33 BTC`, **`v1` completely removes Zenon consensus and ZNN slashing from Bitcoin custody**: | |
| 42 | + | Because Zenon consensus breaks at `49%` (DPoS) and `>33.3%` (BFT) and ZNN market cap is `~25–33 BTC`, **`v2` completely removes Zenon consensus and ZNN slashing from Bitcoin custody**: | |
| 43 | 43 | ||
| 44 | 44 | ```text | |
| @@ -51,8 +51,8 @@ | |||
| 51 | 51 | ``` | |
| 52 | 52 | ||
| 53 | - | | Property | Traditional Bridge / Archived `v0` | `v1` Inverted Trust Hierarchy (Stage 1A) | | |
| 53 | + | | Property | Traditional Bridge / Archived `v0` | `v2` Inverted Trust Hierarchy (Stage 1A) | | |
| 54 | 54 | |---|---|---| | |
| 55 | - | | **Canonical `zBTC` Fork Choice** | Zenon DPoS or BLS BFT Committee (breaks at `33.4%–49%`) | **Bitcoin Mainnet PoW** (first valid `0x02` matching `R_{h-1}` wins; `0%` Zenon trust) | | |
| 56 | - | | **Data Availability (DA)** | Zenon full nodes / committee | **Bitcoin L1 `0x02` Taproot witness** (complete mutated SMT leaves `16 B`/`48 B` + `π_batch`) | | |
| 55 | + | | **Canonical `zBTC` Fork Choice** | Zenon DPoS or BLS BFT Committee (breaks at `33.4%–49%`) | **Bitcoin Mainnet PoW** (first valid `0x02` matching `R_{h-1}` wins; probabilistic PoW finality at depth `K >= 18` under `<50%` honest hashrate + interactive heaviest-chainwork dispute check; `0%` Zenon trust) | | |
| 56 | + | | **Data Availability (DA)** | Zenon full nodes / committee | **Bitcoin L1 `0x02` Taproot witness** (fail-closed BIP-141 `wtxid`-authenticated mutated SMT leaves across `Accounts`, `RollupLocks`, `PendingExits` + `π_batch`) | | |
| 57 | 57 | | **Exit Censorship Resistance** | Censored by Zenon Pillars / Plasma spikes / signers | **Bitcoin L1 `0x01 FORCED_EXIT`** (uncensorable even under **100%** Zenon compromise!) | | |
| 58 | 58 | | **Custody Security Coupling to ZNN** | ZNN staking/slashing (`~25–33 BTC` mcap ceiling) | **`0%` ZNN coupling** (100% BTC-denominated `BitVMX` bonds `2.60 BTC`/lane + `1-of-N` verification) | | |
05 go-zenon & Pre-Mainnet Gates (Part 5) · spec/05-go-zenon-upgrade-plan.md+44 / -42 ·open redline on page
| @@ -1,6 +1,6 @@ | |||
| 1 | - | # Part 5: `go-zenon` Upgrade Plan, Zero-Hard-Fork Custody Boundary & 3-Stage Delivery Roadmap | |
| 1 | + | # Part 5: `go-zenon` Upgrade Plan, Zero-Hard-Fork Custody Boundary & Pre-Mainnet Conformance Gates (`G1–G7`) | |
| 2 | 2 | ||
| 3 | - | **Document Class:** Engineering Upgrade & Delivery Blueprint (`v1` / `v3.0.0-rfc` — Zero-Federation Phased Architecture; supersedes archived `v0` `v2.5.0-rfc`) | |
| 4 | - | **Reference Codebase Verified:** Local `go-zenon` clone is at `master` (`e8986a6`, `v0.0.10-alphanet`) and `origin/dev` (`770e893`). | |
| 3 | + | **Document Class:** Engineering Upgrade & Delivery Blueprint (`v2` / `v3.1.0-rfc` — Zero-Federation Phased Architecture; supersedes archived `v1` `v3.0.0-rfc` and `v0` `v2.5.0-rfc`) | |
| 4 | + | **Reference Codebase Verified:** Local `go-zenon` clone is at `master` (`e8986a6`, `v0.0.10-alphanet`) and `origin/dev` (`770e893`); Bitcoin node floor pinned to **Bitcoin Core `>= 29.0` (`v31.0` preferred)**. | |
| 5 | 5 | **Consistency Checker:** [`scripts/verify_spec_bounds.py`](../scripts/verify_spec_bounds.py) | |
| 6 | 6 | ||
| @@ -9,23 +9,24 @@ | |||
| 9 | 9 | ## 1. Architectural Upgrade Principle: Zero `go-zenon` Custody Authority & Zero Hard Fork for Stage 1A/1B | |
| 10 | 10 | ||
| 11 | - | Unlike archived `v0` (which demanded deep `go-zenon` consensus hard forks — `StateRootSpork`, `CommitteeRootSpork`, `OptimisticRefereeSpork`, ZNN slashing, and single-key governance custody controls), **`v1` decouples Bitcoin custody completely from `go-zenon` upgrades and Zenon governance**: | |
| 11 | + | Unlike archived `v0` (which demanded deep `go-zenon` consensus hard forks — `StateRootSpork`, `CommitteeRootSpork`, `OptimisticRefereeSpork`, ZNN slashing, and single-key governance custody controls), **`v2` decouples Bitcoin custody completely from `go-zenon` upgrades and Zenon governance**: | |
| 12 | 12 | ||
| 13 | 13 | | Stage | `go-zenon` Changes Required | Zenon Spork / Governance Authority Over BTC Custody | | |
| 14 | 14 | |---|---|---| | |
| 15 | - | | **Stage 0 (`Verify Bitcoin`: SPV Event Oracle + Non-Custodial PTLC/LN)** | Upstream `go-zenon` U0 release (`0aa299e` + `#239` closed) + `DynamicPlasmaSpork` (w/ 5-parameter variable bounds) + `PtlcSpork` + lightweight `BtcSpvOracleSpork` (`vm/embedded/btcspv`). | **NONE (`0 BTC` custody in Stage 0).** Oracle provides read-only Event Validity only. | | |
| 16 | - | | **Stage 1A (Right-Sized `BitVMX` `n = 8` + Sovereign ZK Rollup)** | **ZERO `go-zenon` consensus hard fork required!** Rollup sequencer/indexer reads standard `AccountBlock.Data` (`UserSend`) + Bitcoin L1 (`0x00`–`0x07`). | **ZERO!** `vk_STF` is immutably pinned on Bitcoin L1 at launch. Even total compromise of `SporkAddress` / `CommunitySporkAddress` or `100%` of Pillars cannot steal 1 satoshi or censor Bitcoin L1 `0x01` exits! | | |
| 17 | - | | **Stage 1B (`clArk` Alternative Gate)** | **ZERO `go-zenon` consensus hard fork required!** Uses open-source `Second bark/barkd` or `Ark Labs arkd` coordinated alongside Zenon indexing / Stage 0 SPV. | **ZERO!** Custody lives strictly in Bitcoin L1 `clArk` VTXO trees. | | |
| 18 | - | | **Stage 2 (Scale / BitVM3-GC / Track B Covenants)** | **ZERO `go-zenon` consensus hard fork required** for BTC custody. Optional `GovernanceContract` / `StateRoot` remain purely Zenon network UX infrastructure. | **ZERO!** Stage 1 vaults drain 1:1 via `0x01`; identical-STF scaling uses `N`-of-`N` voluntary Cohort 1 handover; backend swaps launch clean non-commingled `zBTC_v2`. | | |
| 15 | + | | **Stage 0 (`Verify Bitcoin`: SPV Event Oracle + Erlang-Hardened PTLC/LN)** | Upstream `go-zenon` mainnet release (Gate G6: `0aa299e`, `#239`/`#299`/`#312` closed, mainnet `PTLC PR #138` & `DynamicPlasmaSpork` w/ 5-param `SetPlasmaVariables` pinning, lightweight `BtcSpvOracleSpork` `vm/embedded/btcspv`). | **NONE (`0 BTC` custody in Stage 0).** Oracle provides read-only Event Validity only. | | |
| 16 | + | | **Stage 1A (Right-Sized `BitVMX` `n = 8` + Sovereign ZK Rollup)** | **ZERO `go-zenon` consensus hard fork required!** Rollup sequencer/indexer reads standard `AccountBlock.Data` (`UserSend`) + Bitcoin L1 (`0x00`–`0x07`). Requires **Bitcoin Core `>= 29.0`** (`v31.0` preferred) for `0`-sat `P2A` ephemeral dust + 1P1C package relay. | **ZERO!** `vk_STF` is immutably pinned on Bitcoin L1 at launch. Even total compromise of `SporkAddress` / `CommunitySporkAddress` or `100%` of Pillars cannot steal 1 satoshi or censor Bitcoin L1 `0x01` exits! | | |
| 17 | + | | **Stage 1B (`clArk` Alternative Gate)** | **ZERO `go-zenon` consensus hard fork required!** Uses open-source `Second bark/barkd` or `Ark Labs arkd` + automated watchtowers coordinated alongside Zenon indexing / Stage 0 SPV. | **ZERO!** Custody lives strictly in Bitcoin L1 `clArk` VTXO trees. | | |
| 18 | + | | **Stage 2 (Scale / BitVM3-GC / Track B Covenants)** | **ZERO `go-zenon` consensus hard fork required** for BTC custody. Optional `GovernanceContract` / `StateRoot` remain purely Zenon network UX infrastructure. | **ZERO!** Stage 1 vaults drain 1:1 via `0x01` (subject to `1-of-M` operator liveness); identical-STF scaling uses `N`-of-`N` voluntary Cohort 1 handover; backend swaps launch clean non-commingled `zBTC_v2`. | | |
| 19 | 19 | ||
| 20 | 20 | --- | |
| 21 | 21 | ||
| 22 | - | ## 2. Stage 0 `go-zenon` Prerequisites (`U0` Gate, `B1`, `B2`, Full Dynamic Plasma Pinning) | |
| 22 | + | ## 2. Stage 0 `go-zenon` Prerequisites (Gate G6, `B1`, `B2`, Full Dynamic Plasma Pinning, `R8-M08`) | |
| 23 | 23 | ||
| 24 | - | ### 2.1 Upstream `go-zenon` Release Gate (`0aa299e` & Issue `#239`) | |
| 24 | + | ### 2.1 Upstream `go-zenon` Mainnet Readiness Gate (`0aa299e`, `PR #138`, `#239`, `#299`, `#312`) | |
| 25 | 25 | ||
| 26 | - | - **Local Clone Honesty Disclosure:** As verified directly against the local `go-zenon` reference clone, `HEAD` (`master`) is `e8986a6` (`v0.0.10-alphanet`) and `origin/dev` is `770e893`. Upstream commit **`0aa299e`** (*post-VM hash re-verification fix for externally supplied blocks mutated by `ValidateSendBlock`*) is **not yet present in this local clone** and remains a hard upstream release prerequisite before activating Stage 0 sporks on mainnet. | |
| 27 | - | - **Close Upstream Issue `#239` (`B1` Blocking Gate for Stage 0 SPV Oracle):** | |
| 28 | - | - Embedded receives execute strictly FIFO per contract (`verifier/account_block.go:397-417`, `chain/account/sequencer.go:19-33`). On `master`, a VM panic returns `ErrVmRunPanic` (`vm/supervisor.go:228`) and aborts `pillar/worker_contract_generator.go:38-40` without advancing the sequencer, permanently stalling the contract. | |
| 29 | - | - **Normative Gate:** Every embedded method in `BtcSpvOracleContract` and `vm/embedded/btcspv/` MUST wrap execution in `defer func() { if r := recover(); r != nil { err = constants.ErrInvalidMethodParam } }()`, contain **zero** calls to `common.DealWithErr`, and rely on `#239`'s deterministic failure provenance so bounded receive retries ALWAYS terminate in a canonical failed receive (never a FIFO stall). | |
| 26 | + | - **Mainnet vs `dev` Honesty Disclosure (`R8-M08`):** Live `go-zenon` mainnet currently runs `v0.0.10` (`master` `e8986a6`, `v1` Momentums capped at `100` blocks/Momentum ≈ `8.8–10.0` blocks/s network-wide). `DynamicPlasmaSpork` (`v2`) and `PtlcSpork` (`PR #138`) are implemented on `dev`/devnet (`origin/dev` `770e893`) and await mainnet merge and spork activation. Upstream commit **`0aa299e`** (*post-VM hash re-verification fix for externally supplied blocks mutated by `ValidateSendBlock`*) is not yet present in the local reference clone. | |
| 27 | + | - **Explicit Open Upstream Issues Blocking Stage 0 Mainnet (Gate G6):** | |
| 28 | + | 1. **Issue `#239` (`B1` — Deterministic Failed Receive / FIFO Panic Stall):** Embedded receives execute strictly FIFO per contract (`verifier/account_block.go:397-417`, `chain/account/sequencer.go:19-33`). On `master`, a VM panic returns `ErrVmRunPanic` (`vm/supervisor.go:228`) and aborts `pillar/worker_contract_generator.go:38-40` without advancing the sequencer, permanently stalling the contract. Every embedded method in `BtcSpvOracleContract` and `vm/embedded/btcspv/` MUST wrap execution in `defer func() { if r := recover(); r != nil { err = constants.ErrInvalidMethodParam } }()`, contain **zero** calls to `common.DealWithErr`, and rely on `#239`'s canonical failed-receive closure. *(Provenance note: verify `#239`'s final merged commit hash against the tagged mainnet release prior to spork activation.)* | |
| 29 | + | 2. **Open `go-zenon` Issues `#299` and `#312` (`R8-M08`):** Both open upstream issues MUST be resolved and verified in the tagged mainnet release before activating Stage 0 `BtcSpvOracleSpork` or `PtlcSpork` (`PR #138`). | |
| 30 | + | 3. **`PTLC PR #138` Mainnet Merge & Spork Activation:** `PtlcSpork` (`PR #138`) MUST be merged, tagged, and activated on mainnet alongside `DynamicPlasmaSpork`. | |
| 30 | 31 | ||
| 31 | 32 | ### 2.2 `DynamicPlasmaSpork` & Full 5-Parameter `SetPlasmaVariables` Pinning (`B2`) | |
| @@ -34,9 +35,5 @@ | |||
| 34 | 35 | ||
| 35 | 36 | **Complete `SetPlasmaVariables` Lower/Upper Parameter Pinning:** | |
| 36 | - | In unmodified `origin/dev:vm/embedded/definition/plasma.go:66-84`, `SetPlasmaVariables` (controlled by single-key `SporkAddress` / `CommunitySporkAddress` at `origin/dev:vm/embedded/implementation/plasma.go:199`) permits: | |
| 37 | - | - `MaxBasePlasmaInMomentumLowerLimit = 210,000` (`L66`, blocking every SPV call `> 2,011 B` in `pillar/content_selector.go:328`), AND | |
| 38 | - | - `FusedPlasmaTargetLowerLimit = 1` (`L69`), `PowPlasmaTargetLowerLimit = 1` (`L72`), `PriceChangeDenominatorLowerLimit = 1` (`L84`). Setting `target = 1` and `denom = 1` allows a single transaction to trigger the maximum per-Momentum price jump (`1.25^52 > 100,000×` in ~10 minutes!). | |
| 39 | - | ||
| 40 | - | Therefore, `BtcSpvOracleSpork` MUST enforce **ALL FIVE** `SetPlasmaVariables` guardrails simultaneously: | |
| 37 | + | In unmodified `origin/dev:vm/embedded/definition/plasma.go:66-84`, `SetPlasmaVariables` (controlled by single-key `SporkAddress` / `CommunitySporkAddress` at `origin/dev:vm/embedded/implementation/plasma.go:199`) permits `MaxBasePlasmaInMomentumLowerLimit = 210,000` (`L66`) and `FusedPlasmaTargetLowerLimit = 1`, `PowPlasmaTargetLowerLimit = 1`, `PriceChangeDenominatorLowerLimit = 1` (allowing a `>100,000×` 10-minute price spike from a single tx!). Therefore `BtcSpvOracleSpork` MUST enforce **ALL FIVE** guardrails simultaneously: | |
| 41 | 38 | ||
| 42 | 39 | | Parameter (`vm/embedded/definition/plasma.go`) | Unmodified `origin/dev` Bound | Normative Stage 0 Spork Floor / Ceiling | Why Required | | |
| @@ -52,44 +49,49 @@ | |||
| 52 | 49 | ### 2.3 Stage 0 SPV Event Oracle & Non-Custodial Swaps (`BtcSpvOracleSpork` + `PtlcSpork`) | |
| 53 | 50 | ||
| 54 | - | 1. Activate **`PtlcSpork`**, **`EmbeddedRefundSpork`**, **`Libp2pSpork`**, and **`EpochRewardTermsSpork`** (all implemented on `origin/dev:common/types/spork.go`). | |
| 55 | - | 2. Deploy lightweight **`BtcSpvOracleContract`** (`vm/embedded/btcspv/`: `header.go`, `tx.go` with 1-/2-block coinbase midstate verification, `oracle.go` — **zero** custody, minting, or federation code!). | |
| 56 | - | 3. Add local RPC/indexer helpers (`DeleteMomentum` WebSocket `momentumsReverted` push + HTLC/PTLC `getByDestination`/`getByPointLock`/`getByHashLock`) for wallets and Stage 0 swap LPs. | |
| 51 | + | 1. Activate **`PtlcSpork` (`PR #138`)**, **`EmbeddedRefundSpork`**, **`Libp2pSpork`**, and **`EpochRewardTermsSpork`** (implemented on `origin/dev:common/types/spork.go`). | |
| 52 | + | 2. Deploy lightweight **`BtcSpvOracleContract`** (`vm/embedded/btcspv/`: `header.go`, `tx.go` with `len(strippedTx) >= 65` and 1-/2-block coinbase midstate verification, `oracle.go` — **zero** custody, minting, or federation code!). | |
| 53 | + | 3. Add local RPC/indexer helpers (`DeleteMomentum` WebSocket `momentumsReverted` push + HTLC/PTLC `getByDestination`/`getByPointLock`/`getByHashLock`) plus automated **block-72 high-fee RBF PTLC refund watchtower** software (`R8-H07`). | |
| 57 | 54 | 4. *(Recommended Non-Custodial Zenon Hygiene, Non-Blocking for BTC Custody):* Replace single-key `SporkAddress` / `CommunitySporkAddress` (`vm/embedded/implementation/spork.go:46-49, 117-119`, which can currently terminate all nodes via `os.Exit(2)` after `SporkMinHeightDelay = 6` Momentums at `chain/momentum_pool.go:53-68`) with a timelocked `GovernanceContract`. Even if un-upgraded, **`SporkAddress` compromise has `0` custody power over Stage 1A/1B BTC!** | |
| 58 | 55 | ||
| 59 | 56 | --- | |
| 60 | 57 | ||
| 61 | - | ## 3. Stage 1A / 1B Off-Chain Software Stack (Piggybacking on Open-Source Ecosystems) | |
| 58 | + | ## 3. Stage 1A / 1B Off-Chain Software Stack (Piggybacking on Open-Source Ecosystems, `R8-H05`) | |
| 62 | 59 | ||
| 63 | 60 | A small young engineering team (4–6 engineers) MUST NOT write custom Bitcoin Script Groth16 compilers or custom BitVM3 garbled-circuit frameworks from scratch. Both Stage 1 paths piggyback directly on audited/open-source Bitcoin stacks: | |
| 64 | 61 | ||
| 65 | 62 | - **Stage 1A (`BitVMX` `n = 8` Sovereign Rollup Stack — Primary Path for Pooled Fungible `zBTC`):** | |
| 66 | - | 1. **Reuse `BitVMX FORCE` / Fairgate Open-Source Core:** `BitVMX-CPU` (`RV32IM` RISC-V verifier & single-opcode Bitcoin Script evaluator) + `BitVMX-protocol` (pre-signed `n = 8` bisection graph builder & W-OTS commitment engine). | |
| 67 | - | 2. **Zenon Team's Focused Scope (Pure Rust → `RV32IM`):** | |
| 68 | - | - Deterministic Rollup STF $\mathcal{F}$ (stripped-block parser, BIP-141 witness verifier, SMT transitions, `ExitSlotUTXO` spend-or-refund, `B_zbtc` slashing) compiled cleanly to `RV32IM` (zero custom Bitcoin Script Groth16 circuits!). | |
| 69 | - | - `zbtc-sequencer` / `zbtc-batcher` daemon (reads Zenon `AccountBlock.Data`, builds `π_batch`, posts `0x02 BATCH_DA`). | |
| 70 | - | - Operator fronting & `StakeChain` daemon (`M = 3–5`) + `N = 7` Verifier watchtower daemon (monitors `KickoffTx_r` and opens simultaneous `ChallengeTx_{r,i}` in `[0, 144]`). | |
| 63 | + | 1. **Off-Chain ZK Prover (`zbtc-prover`):** Executes the full deterministic Rollup STF $\mathcal{F}$ (stripped-block scanning `<= 1 MB`, fail-closed BIP-141 witness authentication on last `0x6a24aa21a9ed` coinbase output, full stripped-`vin` tracked-UTXO scanning, SMT conservation `V_unassigned + V_assigned = C + L + E + R + A + B`, $2^M$ Hall's Marriage check, interactive heaviest-chainwork comparison) off-chain and produces a constant-size wrapped SNARK proof (`vk_STF`). | |
| 64 | + | 2. **Reuse `BitVMX FORCE` / Fairgate Open-Source Core (`RV32IM` Wrapped-SNARK Verifier Only — `R8-H05`):** `BitVMX-CPU` (`RV32IM`) executes **strictly the constant-size `vk_STF` wrapped SNARK verifier** (`<= 0.5 × 8^9` steps, Gate G2 — NEVER bare 1 MB SHA-256 block scanning!) + `BitVMX-protocol` (pre-signed `n = 8` TRUC v3 bisection graph & W-OTS commitment engine targeting **Bitcoin Core `>= 29.0`**, `v31.0` preferred). | |
| 65 | + | 3. **Operational Daemons:** | |
| 66 | + | - `zbtc-sequencer` / `zbtc-batcher` (reads Zenon `AccountBlock.Data`, enforces `500`-sat new-leaf deposit + `<= 1,000`/epoch cap + slotted batcher priority, posts `0x02 BATCH_DA`). | |
| 67 | + | - Operator fronting & `StakeChain` daemon (`M = 3–5`, manages `AdmissionTicketUTXO`s, `ExitSlotUTXO` fronting, `TransferCredit`, direct-to-miner submission rails, and `>= 144`-blk rollback snapshots for `DEEP_REORG_HALT`). | |
| 68 | + | - `N = 7` Verifier watchtower daemon (monitors `RoundTx_r`, opens simultaneous `ChallengeTx_{r,i}` + `ChalProofConnector_{r,i}` in `[0, 144]`, replicates & audits `zbtc-vault-bundle-v1` across `>= 3` public mirrors, maintains direct-to-miner P2A CPFP rails). | |
| 71 | 69 | - **Stage 1B (`clArk` Alternative Gate Stack):** | |
| 72 | - | - Fork/integrate mainnet-live **`Second bark/barkd`** or **`Ark Labs arkd`** (`2–5 BTC` active ASP liquidity) + lightweight Zenon coordination/SPV client (`~3–6` months). | |
| 70 | + | - Fork/integrate mainnet-live **`Second bark/barkd`** or **`Ark Labs arkd`** (`2–5 BTC` active ASP liquidity) + automated VTXO refresh watchtowers + lightweight Zenon coordination/SPV client (`~3–6` months). | |
| 73 | 71 | ||
| 74 | 72 | --- | |
| 75 | 73 | ||
| 76 | - | ## 4. Concrete 3-Stage Delivery Roadmap & Capital Gates | |
| 74 | + | ## 4. Concrete 3-Stage Delivery Roadmap & Capital Gates (`R8-M09`, `R8-H08`) | |
| 77 | 75 | ||
| 78 | - | | Stage | Timeline (4–6 Engineers) | Hard BTC Capital Required | Deliverables & Security Milestone | Exit / Migration Guarantee | | |
| 76 | + | | Stage | Timeline (4–6 Engineers) | Full Hard BTC Capital Required | Deliverables & Security Milestone | Exit / Migration Guarantee | | |
| 79 | 77 | |---|---|---:|---|---| | |
| 80 | - | | **Stage 0: `Verify Bitcoin` Foundation** *(Mandatory Start)* | **`0–6 months`** | **`0 BTC` bonds** (`0–5 BTC` voluntary LP) | Upstream `U0` (`0aa299e` + `#239`) + `DynamicPlasmaSpork` (5-param pin) + `PtlcSpork` + Stage 0 `BtcSpvOracleContract` (1-/2-block midstate) + non-custodial PTLC/LN swaps. Parallel Signet prototype of Rollup STF $\mathcal{F}$ on `BitVMX-CPU`. | Zero custody risk; users hold native BTC on L1/LN at all times. | | |
| 81 | - | | **Stage 1 Decision Gate** | **Month 6 Gate** | *Gate Check* | **Choose Stage 1A ONLY if** pooled fungible non-expiring `zBTC` is non-negotiable **AND** `>= 12.8–18.8 BTC` of independent bonded BTC is committed for `12–18+` months (incl. audit). **Otherwise choose Stage 1B (`clArk`)** (`2–5 BTC` active liquidity, `3–6 mo` launch) — NEVER under-bond BitVMX/BitVM2 below `500 sat/vB`! | Explicit upfront commitment; zero hidden federation fallback. | | |
| 82 | - | | **Stage 1A: Right-Sized `BitVMX` (`n = 8`, `M = 3–5`, `N = 7`) Sovereign Rollup** | **`12–18+ months`** *(incl. external Bitcoin Script + STF audit)* | **`12.8 BTC`** (`M = 3`, `Cap <= 10 BTC`) / **`18.8 BTC`** (`M = 5`, `Cap <= 15 BTC`) | Mainnet `BitVMX` `n = 8` TRUC v3 vaults (`{0.50, 0.25, 0.25}`), `0-of-N` Zenon trust (`49%–100%` proof), Bob `0.50` & Mike `0.25` L1 forced exits, `100%` positive-EV `N = 7` verifiers even under `6-of-7` collusion. | Deleted-key vaults remain 100% live forever; zero governance capture surface. | | |
| 83 | - | | **Stage 1B *(Alt)*: `clArk` + Zenon SPV/PTLC** | **`3–6 months`** | **`2–5 BTC`** active ASP liquidity (`0` bonds) | Mainnet `bark`/`arkd` VTXO rounds + Zenon coordination. Pure `0-of-N` post-round unilateral exit; honest disclosure of `arkoor` sender+ASP collusion, VTXO expiry, and discrete non-pooled VTXOs. | Users hold self-custodial pre-signed L1 exit branches at all times. | | |
| 84 | - | | **Stage 2: Zero-TTP Scale & Upgrade** | **`12+ months` post-Stage 1** | Scales with TVL (`K = 36` → `50 BTC`; `K = 144` → `200 BTC`) | (a) Identical-STF scaling (`M = 5 → 20`, `L = 1 → 4`) via voluntary `N`-of-`N` Cohort 1 handover; (b) Backend upgrade to mature reusable BitVM3-GC, BitVM2, or **Track B Pure Tier-0 Covenants (`OP_CCV + OP_TXHASH + OP_VERIFY_STARK` / `OP_CAT`)** via clean non-commingled `zBTC_v2`. | Zero dead-end migration: Stage 1 vaults drain organically 1:1 via `0x01` exits (zero deleted-key L1 rollover magic!). | | |
| 78 | + | | **Stage 0: `Verify Bitcoin` Foundation** *(Mandatory Start)* | **`0–6 months`** | **`0 BTC` bonds** (`0–5 BTC` voluntary LP) | Gate G6 (`0aa299e`, `#239`/`#299`/`#312`, mainnet `PR #138` & `DynamicPlasmaSpork` 5-param pin) + Stage 0 `BtcSpvOracleContract` (`len >= 65`, 1-/2-block midstate) + Erlang-hardened PTLC (`>= 48h`, block-72 RBF watchtower) / LN HTLC (`>= 24h`) swaps. Parallel Signet prototype of `vk_STF` on `BitVMX-CPU` & BitVM3-GC evaluation (Gate G2). | Zero custody risk; users hold native BTC on L1/LN at all times. | | |
| 79 | + | | **Stage 1 Decision Gate** | **Month 6 Gate** | *Gate Check* | **Choose Stage 1A ONLY if** pooled fungible non-expiring `zBTC` is non-negotiable **AND** **`>= 14.75–21.25 BTC`** single-dispute operational hard BTC (`12.80–18.80` locked + reserves, plus multi-dispute headroom) is committed for `12–18+` months (incl. audit). **Otherwise choose Stage 1B (`clArk`)** (`2–5 BTC` active liquidity, `3–6 mo` launch) — NEVER under-bond BitVMX/BitVM2! | Explicit upfront commitment; zero hidden federation fallback. | | |
| 80 | + | | **Stage 1A: Right-Sized `BitVMX` (`n = 8`, `M = 3–5`, `N = 7`) Sovereign Rollup** | **`12–18+ months`** *(incl. Gates G1–G5 & M-15 external audit)* | **Locked:** `12.80` (`M=3`) / `18.80 BTC` (`M=5`); **Op Baseline:** **`14.75 / 21.25 BTC`** (`~17–26+` multi-dispute) | Mainnet Core `>= 29.0` TRUC v3 vaults (`{0.50, 0.25, 0.25}`, acyclic `vault_id`, `AdmissionTicketUTXO`, $2^M$ Hall, `V=C+L+E+R+A+B`, native-L1 `Stake_r` verifier payouts `+0.0645/+0.0232 BTC` EV @ `500/750 sat/vB`), **graduated TVL ramps (`2 → 5 → 10/15 BTC`)**. | Non-expiring deleted-key vaults redeemable 1:1 via `0x01` subject to `1-of-M` operator liveness (plus voluntary unwind circuit breaker, `spec/01 §6.3`). | | |
| 81 | + | | **Stage 1B *(Alt)*: `clArk` + Zenon SPV/PTLC** | **`3–6 months`** | **`2–5 BTC`** active ASP liquidity (`0` bonds) | Mainnet `bark`/`arkd` VTXO rounds + automated watchtowers + Zenon coordination. Pure `0-of-N` post-round unilateral exit; explicit UX separation of trustless in-round VTXOs vs `arkoor` balances. | Users hold self-custodial pre-signed L1 exit branches at all times. | | |
| 82 | + | | **Stage 2: Zero-TTP Scale & Upgrade** | **`12+ months` post-Stage 1** | Scales with TVL (`K = 42` → `50 BTC`; `K = 144` → `200 BTC`) | (a) Identical-STF scaling (`M = 5 → 20`, `L = 1 → 4`) via voluntary `N`-of-`N` Cohort 1 handover; (b) Backend upgrade to mature reusable BitVM3-GC, BitVM2, or **Track B Pure Tier-0 Covenants (`OP_CCV + OP_TXHASH + OP_VERIFY_STARK` / `OP_CAT`)** via clean non-commingled `zBTC_v2`. | Zero dead-end migration: Stage 1 vaults drain organically 1:1 via `0x01` exits (zero deleted-key L1 rollover magic!). | | |
| 85 | 83 | ||
| 86 | 84 | --- | |
| 87 | 85 | ||
| 88 | - | ## 5. Mandatory CI & Conformance Verification Gates | |
| 86 | + | ## 5. Mandatory Pre-Mainnet Conformance Gates (`G1–G7`, Closing R8 §22 & M-15) | |
| 89 | 87 | ||
| 90 | - | 1. **Symbol & Line-Hash Citation CI:** Automated check pinning every `go-zenon` symbol cited in Parts 2–5 against the tagged U0 release containing `0aa299e` and `#239`. | |
| 91 | - | 2. **Panic & FIFO-Stall Fuzz Gate (`B1`):** Continuous fuzzer across all 4 Stage 0 `BtcSpvOracleContract` methods asserting zero panics, zero `common.DealWithErr` calls, and zero sequencer stalls. | |
| 92 | - | 3. **Dynamic Plasma 5-Parameter Bounds & 1-/2-Block Midstate Vectors (`B2`):** MUST-fail tests verifying `SetPlasmaVariables` rejects ANY violation of the 5 pinned bounds (`MaxBasePlasmaInMomentum < 2.1M`, `MaxPriceChangePercent > 25`, `FusedPlasmaTarget < 525k`, `PowPlasmaTarget < 525k`, `PriceChangeDenominator < 8`), plus 1-block and 2-block SHA-256 coinbase midstate vectors. | |
| 93 | - | 4. **Stage 0 PTLC/LN Adversarial Suite (`M-4`):** Signet↔Zenon tests asserting absolute Unix timestamp `now + 108,000`, `2.3×` slow-block `25.3h < 30h` margin, `>= 72`-block CSV, CPFP confirm `<= h_conf + 66`, BIP-327 odd-$y(R')$ parity, `hashType = 0` rejection, and LN Hold Invoice `ACCEPTED`-first + 5-minute cancel TTL. | |
| 94 | - | 5. **Stage 1A `BitVMX` `n = 8` & Rollup STF Conformance Suite:** Deterministic verification of `scripts/verify_spec_bounds.py` (`7.44 kvB <= 10 kvB` TRUC v3, `0.40 BTC` `F_chal` @ `500 sat/vB`, `1,104 < 1,152 < 1,296 < 1,440` timelocks, `k_collude = 0..6` positive verifier EV, `0.01 BTC` `ExitSlotUTXO` grief slash, `256`-bit Lamport `TakeTx` `<= 3.2 kvB`, real Bitcoin reorgs, and 2,000-step strict 1:1 solvency conservation). | |
| 88 | + | Mainnet deployment of Stage 0 or Stage 1A MUST remain blocked until every applicable gate below publishes publicly reproducible verification artifacts: | |
| 89 | + | ||
| 90 | + | 1. **Gate G1 — Bitcoin Core `v29.0+` (`v31.0` Preferred) `regtest` & `signet` End-to-End Graph Execution:** Execute consensus-valid serialized `DepositTx` (acyclic `vault_id` + `AdmissionTicketUTXO` consumption), active-operator `ExitSlotUTXO` (fronting, cyclic priority, `k = 20` grief burst, `EXIT_CANCEL`), `RoundTx_r`, full 20-step `n = 8` bisection with `153 vB` `0`-sat `P2A` 1P1C package relay, sibling-eviction stress + direct-to-miner rails, `TakeTx` (`<= 3,200 vB` recycling `AdmissionTicketUTXO`), `DisproveTx_{r,i}` + `ChalPayoutEscrow` native-L1 payouts, and `BurnBondTx_{r,k}` on live Bitcoin Core `>= 29.0` `regtest` and `signet` with zero policy or consensus rejections. | |
| 91 | + | 2. **Gate G2 — Compiled `RV32IM` Wrapped-SNARK Verifier Trace Proof (or Reusable `BitVM3-GC` Evaluation):** Publish reproducible Rust → `RV32IM` source and compiled ELF binary of the exact disputed `vk_STF` wrapped SNARK verifier guest, executing worst-case adversarial inputs and proving `init_steps + exec_steps <= 0.5 × 8^9 = 67,108,864` (if exceeded, bump `l = 10` or benchmark mature reusable `BitVM3-GC` + Clementine before code freeze). | |
| 92 | + | 3. **Gate G3 — Independent Execution of Extended Consistency & Bounds Checker:** Run `python3 -I scripts/verify_spec_bounds.py` (recording exact Git commit, `public/raw/SHA256SUMS.txt`, Python version, stdout, and exit code 0) verifying all Stage 0 Erlang tails, Stage 1A acyclic Lamport/TRUC v3/native-L1 EV/$2^M$ Hall/Budish/DA bounds, and `>= 2,000` (and CI `>= 100,000`-step nightly) randomized transitions exercising `V_unassigned + V_assigned == C + L + E + R + A + B`. | |
| 93 | + | 4. **Gate G4 — `vk_STF` Formal Verification & Bitcoin Core Differential Consensus Fuzzing (`R8-H08`):** Formally verify `V_unassigned + V_assigned == C + L + E + R + A + B`, the $2^M$ Hall's Marriage Invariant, fail-closed BIP-141 witness completeness (last `0x6a24aa21a9ed` coinbase output), and full stripped-`vin` tracking inside the ZK constraint system, AND differentially fuzz the Bitcoin parser against Bitcoin Core's `tx_valid`/`tx_invalid`, `CVE-2012-2459`, and `CVE-2017-12842` suites alongside an independent third-party audit (**M-15**). | |
| 94 | + | 5. **Gate G5 — Public `zbtc-vault-bundle-v1` Archival Disaster-Recovery Drill (`R8-H06`):** Destroy all private operator and presigner databases on Signet and prove `100%` recovery of both honest `TakeTx` reimbursements and `DisproveTx`/`BurnBondTx` fraud-proof slashing strictly from `>= 3` public `zbtc-vault-bundle-v1` mirrors plus Bitcoin headers. | |
| 95 | + | 6. **Gate G6 — `go-zenon` Mainnet Readiness, Panic/FIFO Fuzz & Stage 0 PTLC Suite (`R8-M08`, `B1`, `B2`, `R8-H07`):** Confirm mainnet merge, tag, and spork activation of `0aa299e`, `PTLC PR #138` (`PtlcSpork`), `DynamicPlasmaSpork` (with MUST-fail tests verifying all 5 `SetPlasmaVariables` bounds), Stage 0 `BtcSpvOracleContract` (zero-panic FIFO fuzz gate, `len(strippedTx) >= 65`, 1-/2-block coinbase midstate vectors), closure of open `go-zenon` issues `#239`, `#299`, and `#312`, and Signet↔Zenon PTLC/LN adversarial tests (`T_znn >= 48h`, `Δ_safety_sec >= 24h`, automated block-72 RBF watchtower, `hashType = 1`, LN Hold Invoice 5-min cancel TTL). | |
| 96 | + | 7. **Gate G7 — Local Repository Audit Trail & Release Integrity Pinning (`R8-L02`):** Verify every `v2` normative file against generated `public/raw/SHA256SUMS.txt` and frozen `versions/v1/SHA256SUMS.txt` & `versions/v0/SHA256SUMS.txt` in CI, keeping `CHANGELOG.md` synchronized with every `R1–R8` disposition. | |
| 95 | 97 | ||
Consistency & Bounds Checker (verify_spec_bounds.py) · scripts/verify_spec_bounds.py+1351 / -1211 ·open redline on page
| @@ -2,1215 +2,1355 @@ | |||
| 2 | 2 | """ | |
| 3 | 3 | Deterministic Consistency & Bounds Checker for the zBTC Protocol Specification | |
| 4 | - | v1 (v3.0.0-rfc — Zero-Federation Phased Architecture: | |
| 5 | - | Stage 0 Verify Bitcoin SPV Oracle + Non-Custodial PTLC/LN | |
| 6 | - | -> Stage 1A Right-Sized BitVMX (n=8, M=3..5, N=7) + Bitcoin-Anchored Sovereign ZK Rollup | |
| 7 | - | | Stage 1B clArk Alternative Gate | |
| 8 | - | -> Stage 2 Zero-TTP Scale & Upgrade). | |
| 9 | - | ||
| 10 | - | SCOPE & HONESTY DISCLOSURE: | |
| 11 | - | This script checks internal mathematical consistency, SHA-256 coinbase midstate | |
| 12 | - | final-block padding across all 64 remainders, go-zenon Dynamic Plasma & wire-size | |
| 13 | - | bounds, PTLC/HTLC slow-block margins, Theorem 2 capital ratios, BIP-431 TRUC v3 | |
| 14 | - | and BIP-342 Tapscript/Lamport weights, simultaneous-window BitVMX timelocks, | |
| 15 | - | colluding-verifier P&L matrices, multi-tier vault bank-run exit bounds, | |
| 16 | - | halving-indexed private-fork K inequalities, clArk tree exit weights, and a | |
| 17 | - | REAL 2,000-step randomized state-machine simulation with genuine Bitcoin reorgs. | |
| 18 | - | ||
| 19 | - | Every modeled constant is explicitly prefixed by provenance: | |
| 20 | - | - SOURCED_ : Bitcoin BIPs, historical chain telemetry, or go-zenon origin/dev | |
| 21 | - | - POLICY_ : Explicit protocol design parameters | |
| 22 | - | - PRE_MAINNET_TARGET_ : BitVMX-CPU / rollup sizing targets to be empirically measured on Signet | |
| 23 | - | ||
| 24 | - | This script is a consistency & bounds checker — NOT an empirical Signet benchmark | |
| 25 | - | and NOT a substitute for independent cryptographic/implementation audits. | |
| 26 | - | ||
| 27 | - | Run: `python3 -I scripts/verify_spec_bounds.py` | |
| 28 | - | """ | |
| 29 | - | import hashlib | |
| 30 | - | import math | |
| 31 | - | import random | |
| 32 | - | import struct | |
| 33 | - | ||
| 34 | - | SAT = 100_000_000 | |
| 35 | - | ||
| 36 | - | # ============================================================================== | |
| 37 | - | # SOURCED CONSTANTS (Bitcoin BIPs, Historical Telemetry, go-zenon origin/dev) | |
| 38 | - | # ============================================================================== | |
| 39 | - | SOURCED_BIP431_TRUC_MAX_VB = 10_000 # BIP-431 TRUC v3 single-tx vByte limit | |
| 40 | - | SOURCED_BIP342_MAX_STACK_ITEMS = 1_000 # BIP-342 Tapscript max stack elements | |
| 41 | - | SOURCED_BIP342_MAX_PUSH_BYTES = 520 # BIP-342 Tapscript max push element size | |
| 42 | - | SOURCED_BIP141_MAX_STRIPPED_BLOCK_BYTES = 1_000_000 # Bitcoin consensus max non-witness block bytes | |
| 43 | - | SOURCED_BTC_TARGET_BLOCK_SECS = 600 # 10 min nominal Bitcoin block interval | |
| 44 | - | SOURCED_BTC_BLOCKS_PER_DAY = 144 # Nominal blocks/day | |
| 45 | - | SOURCED_JUNE2021_SLOW_WEEKLY_MULT = 2.0 # June 2021 China ban: ~1.95-2.0x 7d avg | |
| 46 | - | SOURCED_JUNE2021_SLOW_DAILY_MULT = 2.3 # June 2021 China ban: ~23 min/blk daily peak | |
| 47 | - | SOURCED_APR2024_MEDIAN_FEE_SATVB = 1_805 # April 2024 halving/Runes median peak | |
| 48 | - | ||
| 49 | - | # Bitcoin block subsidy schedule (BTC/block) across halvings | |
| 50 | - | SOURCED_BTC_SUBSIDY_BY_ERA = { | |
| 51 | - | "2024-2028": 3.125, | |
| 52 | - | "2028-2032": 1.5625, | |
| 53 | - | "2032-2036": 0.78125, | |
| 54 | - | "2036-2040": 0.390625, | |
| 55 | - | } | |
| 56 | - | ||
| 57 | - | # ZNN market-cap context (Nov 2026 observed range; 0% ZNN in BTC custody safety!) | |
| 58 | - | SOURCED_ZNN_MCAP_BTC_LOW = 25.0 | |
| 59 | - | SOURCED_ZNN_MCAP_BTC_HIGH = 33.0 | |
| 60 | - | ||
| 61 | - | # go-zenon origin/dev protocol constants | |
| 62 | - | SOURCED_ZNN_MAX_DATA_LENGTH = 16_384 # dev:vm/constants/plasma.go:67 | |
| 63 | - | SOURCED_ZNN_ACCOUNT_BLOCK_BASE_PLASMA = 21_000 # dev:vm/constants/plasma.go | |
| 64 | - | SOURCED_ZNN_AB_BYTE_DATA_PLASMA = 68 # dev:vm/constants/plasma.go (DynamicPlasmaSpork) | |
| 65 | - | SOURCED_ZNN_EMBEDDED_SIMPLE_TIER = 52_500 # 2.5 * 21,000 | |
| 66 | - | SOURCED_ZNN_EMBEDDED_HEAVY_SPV_TIER = 73_500 # 3.5 * 21,000 | |
| 67 | - | SOURCED_ZNN_PLASMA_PER_QSR = 2_100 # 1 QSR = 1 fusion unit = 2,100 Plasma @ price 1,000 | |
| 68 | - | SOURCED_ZNN_POW_DIFF_PER_PLASMA = 1_500 # dev:vm/constants/plasma.go | |
| 69 | - | SOURCED_ZNN_MIN_RESOURCE_PRICE = 1_000 # dev:dp/dp.go | |
| 70 | - | SOURCED_ZNN_DP_DEFAULT_MAX_BASE_PLASMA = 4_200_000 # dev:vm/embedded/definition/plasma.go:97 | |
| 71 | - | SOURCED_ZNN_DP_UPPER_MAX_BASE_PLASMA = 2_100_000_000 # dev:vm/embedded/definition/plasma.go:63 | |
| 72 | - | SOURCED_ZNN_DP_LOWER_MAX_BASE_PLASMA = 210_000 # dev:vm/embedded/definition/plasma.go:66 | |
| 73 | - | SOURCED_ZNN_OBSERVED_MOMENTUM_SECS = 11.4 # dev:vm/embedded/definition/spork.go (11.35-11.46s) | |
| 74 | - | SOURCED_ZNN_CHAIN_BRIDGE_ROLLBACK = 30 # dev:protocol/chain_bridge.go:293 | |
| 75 | - | SOURCED_ZNN_MAX_MOMENTUM_CONTENT_BYTES = 8 * 1024 * 1024 # dev:verifier/momentum.go:93 (8 MiB) | |
| 76 | - | SOURCED_ZNN_PROTOCOL_MAX_MSG_SIZE = 10 * 1024 * 1024 # dev:protocol/protocol.go (10 MiB) | |
| 77 | - | SOURCED_ZNN_SOFT_RESPONSE_LIMIT = 2 * 1024 * 1024 # dev:protocol/protocol.go (2 MiB) | |
| 78 | - | SOURCED_ZNN_MAX_DETAILED_MOMENTUM_WIRE = ( | |
| 79 | - | SOURCED_ZNN_PROTOCOL_MAX_MSG_SIZE - SOURCED_ZNN_SOFT_RESPONSE_LIMIT - 4096 | |
| 80 | - | ) # 8,384,512 B (dev:protocol/protocol.go:70) | |
| 81 | - | SOURCED_ZNN_MIN_ACCOUNT_BLOCK_WIRE_LOW = 300 # Conservative minimal serialized AccountBlock + content header | |
| 82 | - | SOURCED_ZNN_MIN_ACCOUNT_BLOCK_WIRE_HIGH = 350 # Typical minimal signed AccountBlock + 52B header | |
| 83 | - | ||
| 84 | - | # ============================================================================== | |
| 85 | - | # POLICY PARAMETERS (Stage 0, Stage 1A BitVMX, Stage 1B clArk) | |
| 86 | - | # ============================================================================== | |
| 87 | - | POLICY_PINNED_MAX_BASE_PLASMA_FLOOR = 2_100_000 # Pinned >= 2.1M Plasma/Momentum | |
| 88 | - | POLICY_PINNED_MAX_PRICE_CHANGE_PCT = 25 # MaxPriceChangePercent <= 25% | |
| 89 | - | POLICY_PINNED_MIN_TARGET_SHARE_PCT = 25 # Fused/Pow targets >= 25% of 2.1M floor (525,000) | |
| 90 | - | POLICY_PINNED_MIN_PRICE_DENOM = 8 # PriceChangeDenominator >= 8 (spec/05 §2.2) | |
| 91 | - | POLICY_STAGE0_MAX_STRIPPED_TX_BYTES = 6_144 # Stage 0 SPV Event Oracle tx cap | |
| 92 | - | POLICY_STAGE0_MAX_STORAGE_OPS = 24 # Per-call L1 storage op ceiling | |
| 93 | - | ||
| 94 | - | # Stage 0 PTLC / LN non-custodial swap parameters | |
| 95 | - | POLICY_PTLC_BTC_CSV_BLOCKS = 72 | |
| 96 | - | POLICY_PTLC_BOB_CONFIRM_MARGIN_BLOCKS = 6 # Bob confirms <= h_conf + 66 w/ CPFP | |
| 97 | - | POLICY_PTLC_ALICE_RELEASE_MAX_BLOCKS = 6 | |
| 98 | - | POLICY_PTLC_ZNN_DURATION_SECS = 108_000 # 30.0 hours (passed as now + 108_000 Unix ts!) | |
| 99 | - | POLICY_LN_DELTA_SAFETY_BLOCKS = 36 | |
| 100 | - | ||
| 101 | - | # Stage 1A Right-Sized BitVMX (n=8) + Sovereign ZK Rollup parameters | |
| 102 | - | POLICY_BITVMX_N_BRANCH = 8 # n=8 (3 bits/round -> 7 intermediate hashes) | |
| 103 | - | POLICY_BITVMX_SEARCH_ROUNDS = 9 # 8^9 = 2^27 = 134,217,728 RV32IM instructions | |
| 104 | - | POLICY_BITVMX_M_MIN = 3 # Minimal competitive operator count | |
| 105 | - | POLICY_BITVMX_M_MAX = 5 # Pilot operator count | |
| 106 | - | POLICY_BITVMX_L_LANES = 1 # Lanes per operator | |
| 107 | - | POLICY_BITVMX_N_VERIFIERS = 7 # Pre-committed online verifiers | |
| 108 | - | POLICY_BITVMX_R_ROUNDS = 64 # Pre-signed rounds per lane | |
| 109 | - | POLICY_STAGE2_TOTAL_LANES = 40 # Stage 2 scaled lane count (40 * 64 = 2,560 leaves) | |
| 110 | - | ||
| 111 | - | POLICY_VAULT_TIERS_SATS = (50_000_000, 25_000_000, 25_000_000) # {0.50, 0.25, 0.25} BTC per 1.0 BTC deposit | |
| 112 | - | POLICY_VAULT_ALT_SPLIT_SATS = (50_000_000, 50_000_000) # Optional {0.50, 0.50} split comparison | |
| 113 | - | POLICY_MAX_VAULT_DENOM_SATS = 50_000_000 # 0.50 BTC ceiling per vault UTXO | |
| 114 | - | POLICY_MIN_EXIT_SATS = 100_000 # 0.001 BTC minimum exit | |
| 115 | - | ||
| 116 | - | # Stage 1A Per-Lane Bond & Verifier Economics | |
| 117 | - | POLICY_BOND_BTC_SATS = 200_000_000 # 2.00 BTC L1 Stake_r bond | |
| 118 | - | POLICY_B_ZBTC_CUSTODY_SATS = 50_000_000 # 0.50 BTC maxVaultDenom restitution floor | |
| 119 | - | POLICY_B_ZBTC_EQUIV_BOUNTY_SATS = 5_000_000 # 0.05 BTC Lamport equivocation bounty | |
| 120 | - | POLICY_B_ZBTC_GRIEF_BUFFER_SATS = 5_000_000 # 0.05 BTC ExitSlotUTXO grief buffer | |
| 121 | - | POLICY_B_ZBTC_TOTAL_SATS = ( | |
| 122 | - | POLICY_B_ZBTC_CUSTODY_SATS + POLICY_B_ZBTC_EQUIV_BOUNTY_SATS + POLICY_B_ZBTC_GRIEF_BUFFER_SATS | |
| 123 | - | ) # 0.60 BTC total locked zBTC/lane | |
| 124 | - | POLICY_B_ZBTC_CUSTODY_SLICE_SATS = ( | |
| 125 | - | POLICY_B_ZBTC_CUSTODY_SATS + POLICY_B_ZBTC_EQUIV_BOUNTY_SATS | |
| 126 | - | ) # 0.55 BTC custody slice split across remaining challengers on Disprove | |
| 127 | - | POLICY_LANE_TOTAL_BOND_SATS = POLICY_BOND_BTC_SATS + POLICY_B_ZBTC_TOTAL_SATS # 2.60 BTC/lane | |
| 128 | - | POLICY_F_CHAL_SATS = 40_000_000 # 0.40 BTC verifier challenge escrow | |
| 129 | - | POLICY_WINNING_VERIFIER_L1_SATS = 15_000_000 # 0.15 BTC L1 payout to winning verifier | |
| 130 | - | POLICY_BURNED_BOND_SATS = 185_000_000 # 1.85 BTC burned to OP_RETURN on Disprove/TimeoutSlash | |
| 131 | - | POLICY_EXIT_GRIEF_SLASH_SATS = 1_000_000 # 0.01 BTC non-paying ExitSlotUTXO slash | |
| 132 | - | POLICY_DESIGN_SUSTAINED_FEE_SATVB = 500 # 500 sat/vB sustained across full dispute | |
| 133 | - | ||
| 134 | - | # Stage 1A Simultaneous-Challenge BitVMX Timelocks (blocks) | |
| 135 | - | POLICY_T_CHAL_WINDOW = 144 # Simultaneous [0, 144] challenge window (24h) | |
| 136 | - | POLICY_T_STEP = 48 # 8h per bisection step | |
| 137 | - | POLICY_T_TAKE = 1_152 # 8.0d (> max_dispute_end = 1,104) | |
| 138 | - | POLICY_T_COOLDOWN = 1_296 # 9.0d (1,152 + 144-blk Lamport equivocation slash window) | |
| 139 | - | POLICY_T_RETIRE = 1_440 # 10.0d Stake retirement CSV | |
| 140 | - | POLICY_T_EXIT_CANCEL = 288 # 48h user unilateral EXIT_CANCEL leaf | |
| 141 | - | ||
| 142 | - | # Stage 1A Capital & TVL Profiles | |
| 143 | - | POLICY_STAGE1A_PROFILES = { | |
| 144 | - | "M=3 (<=10 BTC cap)": {"M": 3, "cap_btc": 10.0, "float_btc": 2.20, "K_2024": 14}, | |
| 145 | - | "M=5 (<=15 BTC cap)": {"M": 5, "cap_btc": 15.0, "float_btc": 3.00, "K_2024": 14}, | |
| 146 | - | } | |
| 147 | - | POLICY_TVL_TIERS_BTC = (10, 15, 50, 200) | |
| 148 | - | POLICY_CONFIGURED_K_2024 = {10: 14, 15: 14, 50: 36, 200: 144} | |
| 149 | - | POLICY_CONFIGURED_K_BY_ERA = { | |
| 150 | - | "2024-2028": {10: 14, 15: 14, 50: 36, 200: 144}, | |
| 151 | - | "2028-2032": {10: 14, 15: 20, 50: 66, 200: 260}, | |
| 152 | - | "2032-2036": {10: 28, 15: 40, 50: 130, 200: 516}, | |
| 153 | - | } | |
| 154 | - | ||
| 155 | - | # ============================================================================== | |
| 156 | - | # PRE-MAINNET TARGETS (BitVMX-CPU / Rollup / BitVM2 / clArk — Signet-Gated) | |
| 157 | - | # ============================================================================== | |
| 158 | - | PRE_MAINNET_TARGET_ROLLUP_TX_DATA_BYTES = 110 # Signed rollup transfer in AccountBlock.Data | |
| 159 | - | PRE_MAINNET_TARGET_DEPOSIT_CERTBLOB_BYTES = 104 # Acyclic OP_DROP certBlob <= 520 B | |
| 160 | - | PRE_MAINNET_TARGET_WOTS_DIGIT_WU = 95.5 # Per base-16 W-OTS digit weight (WU) | |
| 161 | - | PRE_MAINNET_TARGET_BISECTION_OVERHEAD_VB = 250.0 # Per prover bisection tx non-WOTS overhead (vB) | |
| 162 | - | PRE_MAINNET_TARGET_START_TX_VB = 3_000.0 # Prover StartTx vBytes | |
| 163 | - | PRE_MAINNET_TARGET_FINAL_TRACE_TX_VB = 5_000.0 # Prover FinalTraceTx vBytes | |
| 164 | - | PRE_MAINNET_TARGET_CHALLENGE_TX_VB = 350.0 # Verifier ChallengeTx vBytes | |
| 165 | - | PRE_MAINNET_TARGET_VERIFIER_CHOICE_VB = 350.0 # Verifier 3-bit interval choice tx vBytes | |
| 166 | - | PRE_MAINNET_TARGET_EXECUTE_OPCODE_VB = 8_000.0 # Verifier final 1-opcode disprove tx vBytes | |
| 167 | - | PRE_MAINNET_TARGET_VERIFIER_CONSERVATIVE_VB = 15_000 # Conservative verifier total dispute budget (vB) | |
| 168 | - | PRE_MAINNET_TARGET_PROVER_CONSERVATIVE_VB = 75_000 # Conservative prover total dispute budget (vB) | |
| 169 | - | PRE_MAINNET_TARGET_BITVM2_LANE_BOND_BTC_LOW = 13.30 # Minimal BitVM2 lane bond @ 200 sat/vB | |
| 170 | - | PRE_MAINNET_TARGET_BITVM2_LANE_BOND_BTC_HIGH = 18.175 # Minimal BitVM2 lane bond @ 500 sat/vB | |
| 171 | - | PRE_MAINNET_TARGET_CLARK_ACTIVE_LIQ_BTC = (2.0, 5.0) # Stage 1B clArk active ASP liquidity range | |
| 172 | - | PRE_MAINNET_TARGET_CLARK_VTXO_COUNTS = (64, 128, 256, 512, 1024) | |
| 173 | - | ||
| 174 | - | ||
| 175 | - | # ============================================================================== | |
| 176 | - | # HELPER FUNCTIONS (Pure Python Stdlib) | |
| 177 | - | # ============================================================================== | |
| 178 | - | def ceil_div(a: int, b: int) -> int: | |
| 179 | - | return (a + b - 1) // b | |
| 180 | - | ||
| 181 | - | ||
| 182 | - | def compact_size_len(n: int) -> int: | |
| 183 | - | if n < 253: | |
| 184 | - | return 1 | |
| 185 | - | if n <= 0xFFFF: | |
| 186 | - | return 3 | |
| 187 | - | if n <= 0xFFFFFFFF: | |
| 188 | - | return 5 | |
| 189 | - | return 9 | |
| 190 | - | ||
| 191 | - | ||
| 192 | - | def abi_single_bytes_call(payload_len: int, static_head_words: int = 1) -> int: | |
| 193 | - | """Exact go-zenon ABI size for fn(static_args..., bytes payload).""" | |
| 194 | - | return 4 + 32 * static_head_words + 32 + 32 + 32 * ceil_div(payload_len, 32) | |
| 195 | - | ||
| 196 | - | ||
| 197 | - | def abi_embedded_plasma(tier: int, abi_len: int) -> int: | |
| 198 | - | assert abi_len <= SOURCED_ZNN_MAX_DATA_LENGTH, f"ABI len {abi_len} exceeds 16 KiB" | |
| 199 | - | return tier + max(0, abi_len - 4) * SOURCED_ZNN_AB_BYTE_DATA_PLASMA | |
| 200 | - | ||
| 201 | - | ||
| 202 | - | # FIPS 180-4 SHA-256 single-block compression (for real coinbase midstate verification) | |
| 203 | - | _SHA256_IV = ( | |
| 204 | - | 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, | |
| 205 | - | 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19, | |
| 206 | - | ) | |
| 207 | - | _SHA256_K = ( | |
| 208 | - | 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, | |
| 209 | - | 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, | |
| 210 | - | 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC, 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, | |
| 211 | - | 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967, | |
| 212 | - | 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, | |
| 213 | - | 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, | |
| 214 | - | 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, | |
| 215 | - | 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2, | |
| 216 | - | ) | |
| 217 | - | ||
| 218 | - | ||
| 219 | - | def _rotr32(x: int, n: int) -> int: | |
| 220 | - | return ((x >> n) | ((x << (32 - n)) & 0xFFFFFFFF)) & 0xFFFFFFFF | |
| 221 | - | ||
| 222 | - | ||
| 223 | - | def sha256_compress(state: tuple[int, ...], block64: bytes) -> tuple[int, ...]: | |
| 224 | - | assert len(block64) == 64 | |
| 225 | - | w = list(struct.unpack(">16I", block64)) | |
| 226 | - | for i in range(16, 64): | |
| 227 | - | s0 = _rotr32(w[i - 15], 7) ^ _rotr32(w[i - 15], 18) ^ (w[i - 15] >> 3) | |
| 228 | - | s1 = _rotr32(w[i - 2], 17) ^ _rotr32(w[i - 2], 19) ^ (w[i - 2] >> 10) | |
| 229 | - | w.append((w[i - 16] + s0 + w[i - 7] + s1) & 0xFFFFFFFF) | |
| 230 | - | a, b, c, d, e, f, g, h = state | |
| 231 | - | for i in range(64): | |
| 232 | - | S1 = _rotr32(e, 6) ^ _rotr32(e, 11) ^ _rotr32(e, 25) | |
| 233 | - | ch = (e & f) ^ ((~e & 0xFFFFFFFF) & g) | |
| 234 | - | t1 = (h + S1 + ch + _SHA256_K[i] + w[i]) & 0xFFFFFFFF | |
| 235 | - | S0 = _rotr32(a, 2) ^ _rotr32(a, 13) ^ _rotr32(a, 22) | |
| 236 | - | maj = (a & b) ^ (a & c) ^ (b & c) | |
| 237 | - | t2 = (S0 + maj) & 0xFFFFFFFF | |
| 238 | - | h, g, f, e, d, c, b, a = g, f, e, (d + t1) & 0xFFFFFFFF, c, b, a, (t1 + t2) & 0xFFFFFFFF | |
| 239 | - | return tuple((s + x) & 0xFFFFFFFF for s, x in zip(state, (a, b, c, d, e, f, g, h))) | |
| 240 | - | ||
| 241 | - | ||
| 242 | - | def complete_midstate_double_sha256(midstate_bytes: bytes, tail: bytes, total_len: int) -> tuple[bytes, int]: | |
| 243 | - | """ | |
| 244 | - | Normative 1-/2-block coinbase midstate completion (spec/02 §2.3): | |
| 245 | - | - Enforces total_len >= 65 (rejects total_len == 64 CVE-2017-12842 leaf forgery & short txs) | |
| 246 | - | - Enforces len(tail) == total_len % 64 < 64 | |
| 247 | - | - Handles BOTH 1-block (rem < 56) and 2-block (rem in 56..63) final SHA-256 padding. | |
| 248 | - | Returns (double_sha256_digest, final_compression_blocks_used). | |
| 249 | - | """ | |
| 250 | - | assert len(midstate_bytes) == 32 | |
| 251 | - | assert total_len >= 65, "CVE-2017-12842: totalCoinbaseBytes must be >= 65 (64-byte leaf forbidden)" | |
| 252 | - | rem = total_len % 64 | |
| 253 | - | assert len(tail) == rem and len(tail) < 64 | |
| 254 | - | padded = bytearray(tail) | |
| 255 | - | padded.append(0x80) | |
| 256 | - | while len(padded) % 64 != 56: | |
| 257 | - | padded.append(0x00) | |
| 258 | - | padded.extend(struct.pack(">Q", total_len * 8)) | |
| 259 | - | blocks = len(padded) // 64 | |
| 260 | - | assert blocks in (1, 2) | |
| 261 | - | state = struct.unpack(">8I", midstate_bytes) | |
| 262 | - | for idx in range(blocks): | |
| 263 | - | state = sha256_compress(state, bytes(padded[idx * 64 : (idx + 1) * 64])) | |
| 264 | - | first_round = struct.pack(">8I", *state) | |
| 265 | - | return hashlib.sha256(first_round).digest(), blocks | |
| 266 | - | ||
| 267 | - | ||
| 268 | - | def dp_next_price( | |
| 269 | - | current_price: int, | |
| 270 | - | used_plasma: int, | |
| 271 | - | target_plasma: int, | |
| 272 | - | max_change_pct: int, | |
| 273 | - | denom: int, | |
| 274 | - | ) -> int: | |
| 275 | - | """Exact mirror of go-zenon origin/dev:dp/dp.go dynamic price step.""" | |
| 276 | - | delta = used_plasma - target_plasma | |
| 277 | - | # Go big.Int truncation toward zero on division | |
| 278 | - | num = delta * current_price | |
| 279 | - | if num >= 0: | |
| 280 | - | change = (num // target_plasma) // denom | |
| 281 | - | else: | |
| 282 | - | change = -((-num // target_plasma) // denom) | |
| 283 | - | nxt = current_price + change | |
| 284 | - | max_nxt = (current_price * (100 + max_change_pct)) // 100 | |
| 285 | - | min_nxt = (current_price * (100 - max_change_pct)) // 100 | |
| 286 | - | if nxt > max_nxt: | |
| 287 | - | nxt = max_nxt | |
| 288 | - | if nxt < min_nxt: | |
| 289 | - | nxt = min_nxt | |
| 290 | - | if nxt < SOURCED_ZNN_MIN_RESOURCE_PRICE: | |
| 291 | - | nxt = SOURCED_ZNN_MIN_RESOURCE_PRICE | |
| 292 | - | return nxt | |
| 293 | - | ||
| 294 | - | ||
| 295 | - | # ============================================================================== | |
| 296 | - | # REAL, NON-NO-OP 2,000-STEP RANDOMIZED STAGE 1A SOLVENCY SIMULATION | |
| 297 | - | # ============================================================================== | |
| 298 | - | def run_stage1a_solvency_sim(seed: int = 20261128, steps: int = 2_000) -> dict[str, int]: | |
| 299 | - | """ | |
| 300 | - | Adversarial state-machine simulation of the Stage 1A BitVMX (n=8, M=5, N=7) | |
| 301 | - | + Bitcoin-Anchored Sovereign ZK Rollup with: | |
| 302 | - | - Explicit Bob (1 -> 0.5 -> exit 0.5) & Mike (Alice 1 + Bob 1 -> 2 -> exit 0.25) flows | |
| 303 | - | - Real Bitcoin block tip + confirmation depth K=14 | |
| 304 | - | - GENUINE Bitcoin reorgs (popping 1..K-1 unconfirmed blocks & discarding orphaned events!) | |
| 305 | - | - Multi-tier {0.50, 0.25, 0.25} BTC deposits | |
| 306 | - | - Feeless rollup transfers | |
| 307 | - | - ExitSlotUTXO honest fronting + non-paying grief slashes (0.01 BTC + refund + auto-suspend) | |
| 308 | - | - Leaf 2M EXIT_CANCEL user refunds after 288 blocks | |
| 309 | - | - Dual-input Disprove slashes (Stake_r + VaultConnector_r -> 0 vault stolen + 0.55 BTC split) | |
| 310 | - | - Lamport L_{j,l,r} equivocation slashes (D_d burned from B_zbtc -> exact 1:1 solvency!) | |
| 311 | - | Asserts EXACT 1:1 backing conservation at EVERY single step. | |
| 312 | - | """ | |
| 313 | - | rng = random.Random(seed) | |
| 314 | - | K = POLICY_CONFIGURED_K_2024[15] # 14 blocks | |
| 315 | - | cap_sats = int(15.0 * SAT) | |
| 316 | - | ||
| 317 | - | # Canonical K-deep rollup state | |
| 318 | - | users: dict[str, int] = { | |
| 319 | - | "alice": 0, "bob": 0, "mike": 0, "carol": 0, "dave": 0, | |
| 320 | - | "challenger_pool": 0, | |
| 321 | - | } | |
| 322 | - | # Operators O_0 .. O_4 (M = 5) | |
| 323 | - | # Each operator starts with 1.00 BTC deposited (two 0.50 BTC vaults) backing 0.60 B_zbtc + 0.40 liquid zBTC | |
| 324 | - | # so every satoshi of B_zbtc in the rollup is backed 1:1 by real confirmed L1 vault BTC! | |
| 325 | - | confirmed_vaults: dict[int, int] = {} # vault_id -> sats (unassigned & unspent K-deep) | |
| 326 | - | next_vault_id = 1 | |
| 327 | - | operators: dict[int, dict] = {} | |
| 328 | - | for op_id in range(POLICY_BITVMX_M_MAX): | |
| 329 | - | for _ in range(2): | |
| 330 | - | confirmed_vaults[next_vault_id] = 50_000_000 # 0.50 BTC | |
| 331 | - | next_vault_id += 1 | |
| 332 | - | operators[op_id] = { | |
| 333 | - | "b_zbtc": POLICY_B_ZBTC_TOTAL_SATS, # 0.60 BTC locked collateral | |
| 334 | - | "free_zbtc": 40_000_000, # 0.40 BTC operator liquid zBTC (for top-ups) | |
| 335 | - | "credit": 0, # ReimbursementCredit[op] | |
| 336 | - | "suspended": False, | |
| 337 | - | } | |
| 338 | - | ||
| 339 | - | # Pending exits (canonical K-deep): exit_id -> {"user", "gross", "created_h", "state": "OPEN"} | |
| 340 | - | pending_exits: dict[int, dict] = {} | |
| 341 | - | next_exit_id = 1 | |
| 342 | - | ||
| 343 | - | # Unconfirmed Bitcoin tip buffer (heights > finalized_height; reorgable!) | |
| 344 | - | # Each block = {"height": int, "events": list[dict]} | |
| 345 | - | finalized_height = 100 | |
| 346 | - | tip_blocks: list[dict] = [] | |
| 347 | - | ||
| 348 | - | # Track unconfirmed reservations so we don't double-spend same exit/vault inside one fork | |
| 349 | - | unconf_spent_exits: set[int] = set() | |
| 350 | - | unconf_claimed_vaults: set[int] = set() | |
| 351 | - | unconf_pending_credit_used: dict[int, int] = {i: 0 for i in range(POLICY_BITVMX_M_MAX)} | |
| 352 | - | ||
| 353 | - | counts: dict[str, int] = { | |
| 354 | - | k: 0 for k in ( | |
| 355 | - | "deposit", "transfer", "forced_exit", "front_paid", "front_grief", | |
| 356 | - | "exit_cancel", "take_honest", "disprove_dual_slash", | |
| 357 | - | "lamport_equivocation_slash", "topup_op", "mine_block", "reorg", | |
| 358 | - | "reorg_blocks_reverted", "reorg_events_reverted", | |
| 359 | - | ) | |
| 360 | - | } | |
| 361 | - | ||
| 362 | - | def rebuild_unconf_locks() -> None: | |
| 363 | - | unconf_spent_exits.clear() | |
| 364 | - | unconf_claimed_vaults.clear() | |
| 365 | - | for i in unconf_pending_credit_used: | |
| 366 | - | unconf_pending_credit_used[i] = 0 | |
| 367 | - | for blk in tip_blocks: | |
| 368 | - | for ev in blk["events"]: | |
| 369 | - | kind = ev["kind"] | |
| 370 | - | if kind in ("front_paid", "front_grief", "exit_cancel"): | |
| 371 | - | unconf_spent_exits.add(ev["exit_id"]) | |
| 372 | - | elif kind == "take_honest": | |
| 373 | - | unconf_claimed_vaults.add(ev["vault_id"]) | |
| 374 | - | unconf_pending_credit_used[ev["op_id"]] += ev["amount"] | |
| 375 | - | elif kind == "lamport_equivocation_slash": | |
| 376 | - | unconf_claimed_vaults.add(ev["vault_id"]) | |
| 377 | - | ||
| 378 | - | def apply_finalized_event(ev: dict, blk_height: int) -> None: | |
| 379 | - | nonlocal next_vault_id, next_exit_id | |
| 380 | - | kind = ev["kind"] | |
| 381 | - | if kind == "deposit": | |
| 382 | - | # Multi-tier vaults enter confirmed L1 pool AND mint exact 1:1 zBTC | |
| 383 | - | for vid, vamt in ev["vaults"]: | |
| 384 | - | confirmed_vaults[vid] = vamt | |
| 385 | - | users[ev["user"]] += sum(vamt for _, vamt in ev["vaults"]) | |
| 386 | - | counts["deposit"] += 1 | |
| 387 | - | ||
| 388 | - | elif kind == "forced_exit": | |
| 389 | - | u = ev["user"] | |
| 390 | - | amt = ev["gross"] | |
| 391 | - | if users[u] >= amt: | |
| 392 | - | users[u] -= amt | |
| 393 | - | pending_exits[ev["exit_id"]] = { | |
| 394 | - | "user": u, "gross": amt, "created_h": blk_height, | |
| 395 | - | } | |
| 396 | - | counts["forced_exit"] += 1 | |
| 397 | - | ||
| 398 | - | elif kind == "front_paid": | |
| 399 | - | eid = ev["exit_id"] | |
| 400 | - | if eid in pending_exits: | |
| 401 | - | ex = pending_exits.pop(eid) | |
| 402 | - | operators[ev["op_id"]]["credit"] += ex["gross"] | |
| 403 | - | counts["front_paid"] += 1 | |
| 404 | - | ||
| 405 | - | elif kind == "front_grief": | |
| 406 | - | # Non-paying ExitSlotUTXO spend -> cancel + refund + 0.01 BTC slash + auto-suspend! | |
| 407 | - | eid = ev["exit_id"] | |
| 408 | - | op = operators[ev["op_id"]] | |
| 409 | - | if eid in pending_exits and op["b_zbtc"] >= POLICY_B_ZBTC_CUSTODY_SLICE_SATS + POLICY_EXIT_GRIEF_SLASH_SATS: | |
| 410 | - | ex = pending_exits.pop(eid) | |
| 411 | - | users[ex["user"]] += ex["gross"] | |
| 412 | - | op["b_zbtc"] -= POLICY_EXIT_GRIEF_SLASH_SATS | |
| 413 | - | users[ex["user"]] += POLICY_EXIT_GRIEF_SLASH_SATS | |
| 414 | - | op["suspended"] = True | |
| 415 | - | assert op["b_zbtc"] >= POLICY_B_ZBTC_CUSTODY_SLICE_SATS, "Grief slash breached 0.55 BTC custody floor!" | |
| 416 | - | counts["front_grief"] += 1 | |
| 417 | - | ||
| 418 | - | elif kind == "exit_cancel": | |
| 419 | - | eid = ev["exit_id"] | |
| 420 | - | if eid in pending_exits and blk_height >= pending_exits[eid]["created_h"] + POLICY_T_EXIT_CANCEL: | |
| 421 | - | ex = pending_exits.pop(eid) | |
| 422 | - | users[ex["user"]] += ex["gross"] | |
| 423 | - | counts["exit_cancel"] += 1 | |
| 424 | - | ||
| 425 | - | elif kind == "take_honest": | |
| 426 | - | vid = ev["vault_id"] | |
| 427 | - | op = operators[ev["op_id"]] | |
| 428 | - | if vid in confirmed_vaults and op["credit"] >= confirmed_vaults[vid]: | |
| 429 | - | vamt = confirmed_vaults.pop(vid) | |
| 430 | - | op["credit"] -= vamt | |
| 431 | - | counts["take_honest"] += 1 | |
| 432 | - | ||
| 433 | - | elif kind == "disprove_dual_slash": | |
| 434 | - | # Dual-input Disprove spends Stake_r + VaultConnector_r -> 0 vault stolen! | |
| 435 | - | # 0.55 BTC custody slice of B_zbtc splits across remaining challengers; operator paused. | |
| 436 | - | op = operators[ev["op_id"]] | |
| 437 | - | if op["b_zbtc"] >= POLICY_B_ZBTC_CUSTODY_SLICE_SATS: | |
| 438 | - | op["b_zbtc"] -= POLICY_B_ZBTC_CUSTODY_SLICE_SATS | |
| 439 | - | users["challenger_pool"] += POLICY_B_ZBTC_CUSTODY_SLICE_SATS | |
| 440 | - | op["suspended"] = True | |
| 441 | - | counts["disprove_dual_slash"] += 1 | |
| 442 | - | ||
| 443 | - | elif kind == "lamport_equivocation_slash": | |
| 444 | - | # Operator stole vault U_2 != U_1 (D_d <= 0.50 BTC); BurnBondTx burns 2.00 BTC L1, | |
| 445 | - | # STARK atomically burns D_d from op.b_zbtc (1:1 solvency!) + pays 0.05 BTC bounty. | |
| 446 | - | vid = ev["vault_id"] | |
| 447 | - | op = operators[ev["op_id"]] | |
| 448 | - | if vid in confirmed_vaults: | |
| 449 | - | vamt = confirmed_vaults[vid] | |
| 450 | - | if op["b_zbtc"] >= vamt + POLICY_B_ZBTC_EQUIV_BOUNTY_SATS: | |
| 451 | - | confirmed_vaults.pop(vid) | |
| 452 | - | op["b_zbtc"] -= (vamt + POLICY_B_ZBTC_EQUIV_BOUNTY_SATS) | |
| 453 | - | users["challenger_pool"] += POLICY_B_ZBTC_EQUIV_BOUNTY_SATS | |
| 454 | - | op["suspended"] = True | |
| 455 | - | counts["lamport_equivocation_slash"] += 1 | |
| 456 | - | ||
| 457 | - | def assert_solvency(label: str) -> None: | |
| 458 | - | vault_backing = sum(confirmed_vaults.values()) | |
| 459 | - | circ_users = sum(users.values()) | |
| 460 | - | pending_total = sum(ex["gross"] for ex in pending_exits.values()) | |
| 461 | - | credits_total = sum(op["credit"] for op in operators.values()) | |
| 462 | - | op_b_zbtc = sum(op["b_zbtc"] for op in operators.values()) | |
| 463 | - | op_free_zbtc = sum(op["free_zbtc"] for op in operators.values()) | |
| 464 | - | total_liabilities = circ_users + pending_total + credits_total + op_b_zbtc + op_free_zbtc | |
| 465 | - | assert vault_backing == total_liabilities, ( | |
| 466 | - | f"[{label}] Solvency mismatch! vault_backing={vault_backing} != liabilities={total_liabilities}" | |
| 467 | - | ) | |
| 468 | - | # Active non-suspended operators must always maintain full 0.60 BTC B_zbtc floor | |
| 469 | - | for oid, op in operators.items(): | |
| 470 | - | if not op["suspended"]: | |
| 471 | - | assert op["b_zbtc"] >= POLICY_B_ZBTC_TOTAL_SATS, ( | |
| 472 | - | f"[{label}] Active operator {oid} b_zbtc={op['b_zbtc']} < 0.60 BTC floor" | |
| 473 | - | ) | |
| 474 | - | ||
| 475 | - | def mine_one_block(events: list[dict]) -> None: | |
| 476 | - | nonlocal finalized_height | |
| 477 | - | next_h = finalized_height + len(tip_blocks) + 1 | |
| 478 | - | tip_blocks.append({"height": next_h, "events": events}) | |
| 479 | - | counts["mine_block"] += 1 | |
| 480 | - | # Finalize any block now >= K deep (tip_height - blk_height + 1 >= K) | |
| 481 | - | while len(tip_blocks) >= K: | |
| 482 | - | fin_blk = tip_blocks.pop(0) | |
| 483 | - | finalized_height = fin_blk["height"] | |
| 484 | - | for ev in fin_blk["events"]: | |
| 485 | - | apply_finalized_event(ev, finalized_height) | |
| 486 | - | rebuild_unconf_locks() | |
| 487 | - | ||
| 488 | - | def current_tip_height() -> int: | |
| 489 | - | return finalized_height + len(tip_blocks) | |
| 490 | - | ||
| 491 | - | assert_solvency("init") | |
| 492 | - | ||
| 493 | - | # ------------------------------------------------------------------ | |
| 494 | - | # DETERMINISTIC VERIFICATION OF BOB (1 -> 0.5 -> 0.5) & MIKE (1+1 -> 2 -> 0.25) | |
| 495 | - | # ------------------------------------------------------------------ | |
| 496 | - | # Bob deposits 1.0 BTC -> {0.50, 0.25, 0.25} vaults | |
| 497 | - | bob_vaults = [] | |
| 498 | - | for amt in POLICY_VAULT_TIERS_SATS: | |
| 499 | - | bob_vaults.append((next_vault_id, amt)) | |
| 500 | - | next_vault_id += 1 | |
| 501 | - | # Alice deposits 1.0 BTC -> {0.50, 0.25, 0.25} vaults | |
| 502 | - | alice_vaults = [] | |
| 503 | - | for amt in POLICY_VAULT_TIERS_SATS: | |
| 504 | - | alice_vaults.append((next_vault_id, amt)) | |
| 505 | - | next_vault_id += 1 | |
| 506 | - | mine_one_block([ | |
| 507 | - | {"kind": "deposit", "user": "bob", "vaults": bob_vaults}, | |
| 508 | - | {"kind": "deposit", "user": "alice", "vaults": alice_vaults}, | |
| 509 | - | ]) | |
| 510 | - | for _ in range(K - 1): | |
| 511 | - | mine_one_block([]) | |
| 512 | - | assert users["bob"] == SAT and users["alice"] == SAT | |
| 513 | - | assert_solvency("after_bob_alice_deposits") | |
| 514 | - | ||
| 515 | - | # Bob spends 0.5 zBTC to Carol feelessly, then recovers 0.50 BTC via forced exit | |
| 516 | - | users["bob"] -= 50_000_000 | |
| 517 | - | users["carol"] += 50_000_000 | |
| 518 | - | counts["transfer"] += 1 | |
| 519 | - | bob_eid = next_exit_id | |
| 520 | - | next_exit_id += 1 | |
| 521 | - | mine_one_block([{"kind": "forced_exit", "user": "bob", "gross": 50_000_000, "exit_id": bob_eid}]) | |
| 522 | - | for _ in range(K - 1): | |
| 523 | - | mine_one_block([]) | |
| 524 | - | assert bob_eid in pending_exits and users["bob"] == 0 | |
| 525 | - | # Operator 0 fronts Bob's 0.50 BTC and later claims Bob's 0.50 BTC vault | |
| 526 | - | mine_one_block([{"kind": "front_paid", "exit_id": bob_eid, "op_id": 0}]) | |
| 527 | - | for _ in range(K - 1): | |
| 528 | - | mine_one_block([]) | |
| 529 | - | assert bob_eid not in pending_exits and operators[0]["credit"] == 50_000_000 | |
| 530 | - | mine_one_block([{"kind": "take_honest", "op_id": 0, "vault_id": bob_vaults[0][0], "amount": 50_000_000}]) | |
| 531 | - | for _ in range(K - 1): | |
| 532 | - | mine_one_block([]) | |
| 533 | - | assert operators[0]["credit"] == 0 | |
| 534 | - | assert_solvency("after_bob_0.5_recovery") | |
| 535 | - | ||
| 536 | - | # Mike scenario: Alice (1 BTC) + Bob2 (1 BTC -> Carol transfers + new Bob deposit) -> Mike has 2.0 zBTC -> exits 0.25 BTC | |
| 537 | - | bob2_vaults = [] | |
| 538 | - | for amt in POLICY_VAULT_TIERS_SATS: | |
| 539 | - | bob2_vaults.append((next_vault_id, amt)) | |
| 540 | - | next_vault_id += 1 | |
| 541 | - | mine_one_block([{"kind": "deposit", "user": "bob", "vaults": bob2_vaults}]) | |
| 542 | - | for _ in range(K - 1): | |
| 543 | - | mine_one_block([]) | |
| 544 | - | assert users["alice"] == SAT and users["bob"] == SAT | |
| 545 | - | users["alice"] -= SAT | |
| 546 | - | users["bob"] -= SAT | |
| 547 | - | users["mike"] += 2 * SAT | |
| 548 | - | counts["transfer"] += 2 | |
| 549 | - | mike_eid = next_exit_id | |
| 550 | - | next_exit_id += 1 | |
| 551 | - | # Mike posts 0x01 FORCED_EXIT directly on Bitcoin L1 (0 Zenon signer signatures!) | |
| 552 | - | mine_one_block([{"kind": "forced_exit", "user": "mike", "gross": 25_000_000, "exit_id": mike_eid}]) | |
| 553 | - | for _ in range(K - 1): | |
| 554 | - | mine_one_block([]) | |
| 555 | - | assert users["mike"] == 175_000_000 and mike_eid in pending_exits | |
| 556 | - | # Operator 1 fronts Mike's 0.25 BTC and claims a 0.25 BTC vault directly | |
| 557 | - | mine_one_block([{"kind": "front_paid", "exit_id": mike_eid, "op_id": 1}]) | |
| 558 | - | for _ in range(K - 1): | |
| 559 | - | mine_one_block([]) | |
| 560 | - | mine_one_block([{"kind": "take_honest", "op_id": 1, "vault_id": alice_vaults[1][0], "amount": 25_000_000}]) | |
| 561 | - | for _ in range(K - 1): | |
| 562 | - | mine_one_block([]) | |
| 563 | - | assert mike_eid not in pending_exits and operators[1]["credit"] == 0 | |
| 564 | - | assert_solvency("after_mike_0.25_recovery") | |
| 565 | - | ||
| 566 | - | # ------------------------------------------------------------------ | |
| 567 | - | # 2,000-STEP ADVERSARIAL RANDOMIZED SIMULATION (WITH REAL REORGS!) | |
| 568 | - | # ------------------------------------------------------------------ | |
| 569 | - | actions = [ | |
| 570 | - | "deposit", "transfer", "forced_exit", "front_paid", "front_grief", | |
| 571 | - | "exit_cancel", "take_honest", "disprove_dual_slash", | |
| 572 | - | "lamport_equivocation_slash", "topup_op", "mine_block", "reorg", | |
| 573 | - | ] | |
| 574 | - | weights = [10, 18, 12, 12, 6, 8, 10, 5, 5, 10, 26, 10] | |
| 575 | - | normal_users = ["alice", "bob", "mike", "carol", "dave"] | |
| 576 | - | ||
| 577 | - | for step in range(steps): | |
| 578 | - | act = rng.choices(actions, weights=weights, k=1)[0] | |
| 579 | - | ||
| 580 | - | if act == "deposit": | |
| 581 | - | cur_tvl = sum(confirmed_vaults.values()) | |
| 582 | - | if cur_tvl + SAT <= cap_sats: | |
| 583 | - | u = rng.choice(normal_users) | |
| 584 | - | new_vs = [] | |
| 585 | - | for amt in POLICY_VAULT_TIERS_SATS: | |
| 586 | - | new_vs.append((next_vault_id, amt)) | |
| 587 | - | next_vault_id += 1 | |
| 588 | - | mine_one_block([{"kind": "deposit", "user": u, "vaults": new_vs}]) | |
| 589 | - | ||
| 590 | - | elif act == "transfer": | |
| 591 | - | rich = [u for u in normal_users if users[u] >= POLICY_MIN_EXIT_SATS] | |
| 592 | - | if rich: | |
| 593 | - | src = rng.choice(rich) | |
| 594 | - | dst = rng.choice([u for u in normal_users if u != src]) | |
| 595 | - | amt = rng.randint(POLICY_MIN_EXIT_SATS, min(users[src], 50_000_000)) | |
| 596 | - | users[src] -= amt | |
| 597 | - | users[dst] += amt | |
| 598 | - | counts["transfer"] += 1 | |
| 599 | - | ||
| 600 | - | elif act == "forced_exit": | |
| 601 | - | rich = [u for u in normal_users if users[u] >= 25_000_000] | |
| 602 | - | if rich: | |
| 603 | - | u = rng.choice(rich) | |
| 604 | - | amt = rng.choice([25_000_000, 50_000_000]) if users[u] >= 50_000_000 else 25_000_000 | |
| 605 | - | eid = next_exit_id | |
| 606 | - | next_exit_id += 1 | |
| 607 | - | mine_one_block([{"kind": "forced_exit", "user": u, "gross": amt, "exit_id": eid}]) | |
| 608 | - | ||
| 609 | - | elif act == "front_paid": | |
| 610 | - | open_exits = [eid for eid in pending_exits if eid not in unconf_spent_exits] | |
| 611 | - | active_ops = [oid for oid, op in operators.items() if not op["suspended"]] | |
| 612 | - | if open_exits and active_ops: | |
| 613 | - | eid = rng.choice(open_exits) | |
| 614 | - | oid = rng.choice(active_ops) | |
| 615 | - | unconf_spent_exits.add(eid) | |
| 616 | - | mine_one_block([{"kind": "front_paid", "exit_id": eid, "op_id": oid}]) | |
| 617 | - | ||
| 618 | - | elif act == "front_grief": | |
| 619 | - | open_exits = [eid for eid in pending_exits if eid not in unconf_spent_exits] | |
| 620 | - | active_ops = [ | |
| 621 | - | oid for oid, op in operators.items() | |
| 622 | - | if not op["suspended"] and op["b_zbtc"] >= POLICY_B_ZBTC_CUSTODY_SLICE_SATS + POLICY_EXIT_GRIEF_SLASH_SATS | |
| 623 | - | ] | |
| 624 | - | if open_exits and active_ops: | |
| 625 | - | eid = rng.choice(open_exits) | |
| 626 | - | oid = rng.choice(active_ops) | |
| 627 | - | unconf_spent_exits.add(eid) | |
| 628 | - | mine_one_block([{"kind": "front_grief", "exit_id": eid, "op_id": oid}]) | |
| 629 | - | ||
| 630 | - | elif act == "exit_cancel": | |
| 631 | - | # Ensure some exits can reach 288-block cancel age realistically | |
| 632 | - | cur_h = current_tip_height() | |
| 633 | - | expired = [ | |
| 634 | - | eid for eid, ex in pending_exits.items() | |
| 635 | - | if eid not in unconf_spent_exits and cur_h >= ex["created_h"] + POLICY_T_EXIT_CANCEL | |
| 636 | - | ] | |
| 637 | - | if expired: | |
| 638 | - | eid = rng.choice(expired) | |
| 639 | - | unconf_spent_exits.add(eid) | |
| 640 | - | mine_one_block([{"kind": "exit_cancel", "exit_id": eid}]) | |
| 641 | - | ||
| 642 | - | elif act == "take_honest": | |
| 643 | - | free_vaults = [vid for vid in confirmed_vaults if vid not in unconf_claimed_vaults] | |
| 644 | - | eligible = [ | |
| 645 | - | (oid, vid) | |
| 646 | - | for oid, op in operators.items() | |
| 647 | - | for vid in free_vaults | |
| 648 | - | if op["credit"] - unconf_pending_credit_used[oid] >= confirmed_vaults[vid] | |
| 649 | - | ] | |
| 650 | - | if eligible: | |
| 651 | - | oid, vid = rng.choice(eligible) | |
| 652 | - | vamt = confirmed_vaults[vid] | |
| 653 | - | unconf_claimed_vaults.add(vid) | |
| 654 | - | unconf_pending_credit_used[oid] += vamt | |
| 655 | - | mine_one_block([{"kind": "take_honest", "op_id": oid, "vault_id": vid, "amount": vamt}]) | |
| 656 | - | ||
| 657 | - | elif act == "disprove_dual_slash": | |
| 658 | - | active_ops = [ | |
| 659 | - | oid for oid, op in operators.items() | |
| 660 | - | if not op["suspended"] and op["b_zbtc"] >= POLICY_B_ZBTC_CUSTODY_SLICE_SATS | |
| 661 | - | ] | |
| 662 | - | if active_ops: | |
| 663 | - | oid = rng.choice(active_ops) | |
| 664 | - | mine_one_block([{"kind": "disprove_dual_slash", "op_id": oid}]) | |
| 665 | - | ||
| 666 | - | elif act == "lamport_equivocation_slash": | |
| 667 | - | free_vaults = [vid for vid in confirmed_vaults if vid not in unconf_claimed_vaults] | |
| 668 | - | active_ops = [ | |
| 669 | - | oid for oid, op in operators.items() | |
| 670 | - | if not op["suspended"] and op["b_zbtc"] >= POLICY_MAX_VAULT_DENOM_SATS + POLICY_B_ZBTC_EQUIV_BOUNTY_SATS | |
| 671 | - | ] | |
| 672 | - | if free_vaults and active_ops: | |
| 673 | - | oid = rng.choice(active_ops) | |
| 674 | - | vid = rng.choice(free_vaults) | |
| 675 | - | unconf_claimed_vaults.add(vid) | |
| 676 | - | mine_one_block([{"kind": "lamport_equivocation_slash", "op_id": oid, "vault_id": vid}]) | |
| 677 | - | ||
| 678 | - | elif act == "topup_op": | |
| 679 | - | susp = [oid for oid, op in operators.items() if op["suspended"]] | |
| 680 | - | if susp: | |
| 681 | - | oid = rng.choice(susp) | |
| 682 | - | op = operators[oid] | |
| 683 | - | needed = max(0, POLICY_B_ZBTC_TOTAL_SATS - op["b_zbtc"]) | |
| 684 | - | if op["free_zbtc"] >= needed: | |
| 685 | - | op["free_zbtc"] -= needed | |
| 686 | - | op["b_zbtc"] += needed | |
| 687 | - | op["suspended"] = False | |
| 688 | - | counts["topup_op"] += 1 | |
| 689 | - | elif sum(confirmed_vaults.values()) + SAT <= cap_sats: | |
| 690 | - | # Operator deposits fresh BTC to replenish B_zbtc (still 1:1 backed!) | |
| 691 | - | v1, v2 = next_vault_id, next_vault_id + 1 | |
| 692 | - | next_vault_id += 2 | |
| 693 | - | confirmed_vaults[v1] = 50_000_000 | |
| 694 | - | confirmed_vaults[v2] = 50_000_000 | |
| 695 | - | op["free_zbtc"] += SAT | |
| 696 | - | op["free_zbtc"] -= needed | |
| 697 | - | op["b_zbtc"] += needed | |
| 698 | - | op["suspended"] = False | |
| 699 | - | counts["topup_op"] += 1 | |
| 700 | - | ||
| 701 | - | elif act == "mine_block": | |
| 702 | - | mine_one_block([]) | |
| 703 | - | ||
| 704 | - | elif act == "reorg": | |
| 705 | - | # GENUINE Bitcoin tip reorg of depth 1..min(K-1, len(tip_blocks))! | |
| 706 | - | # Actually pops unconfirmed blocks, discards their orphaned events, and mines empty replacement chain. | |
| 707 | - | if tip_blocks: | |
| 708 | - | depth = rng.randint(1, min(K - 1, len(tip_blocks))) | |
| 709 | - | orphaned = tip_blocks[-depth:] | |
| 710 | - | del tip_blocks[-depth:] | |
| 711 | - | ev_reverted = sum(len(b["events"]) for b in orphaned) | |
| 712 | - | counts["reorg"] += 1 | |
| 713 | - | counts["reorg_blocks_reverted"] += depth | |
| 714 | - | counts["reorg_events_reverted"] += ev_reverted | |
| 715 | - | rebuild_unconf_locks() | |
| 716 | - | for _ in range(depth): | |
| 717 | - | mine_one_block([]) | |
| 718 | - | ||
| 719 | - | assert_solvency(f"step_{step}_{act}") | |
| 720 | - | ||
| 721 | - | # Guarantee EXIT_CANCEL path is exercised if random steps didn't hit a 288-block idle exit | |
| 722 | - | if counts["exit_cancel"] == 0: | |
| 723 | - | u = next(u for u in normal_users if users[u] >= 25_000_000) if any(users[u] >= 25_000_000 for u in normal_users) else "challenger_pool" | |
| 724 | - | eid = next_exit_id | |
| 725 | - | next_exit_id += 1 | |
| 726 | - | mine_one_block([{"kind": "forced_exit", "user": u, "gross": 25_000_000, "exit_id": eid}]) | |
| 727 | - | for _ in range(K + POLICY_T_EXIT_CANCEL): | |
| 728 | - | mine_one_block([]) | |
| 729 | - | mine_one_block([{"kind": "exit_cancel", "exit_id": eid}]) | |
| 730 | - | for _ in range(K): | |
| 731 | - | mine_one_block([]) | |
| 732 | - | assert_solvency("post_exit_cancel") | |
| 733 | - | ||
| 734 | - | # Flush remaining tip blocks to K-deep finality | |
| 735 | - | for _ in range(K): | |
| 736 | - | mine_one_block([]) | |
| 737 | - | assert_solvency("final") | |
| 738 | - | return counts | |
| 739 | - | ||
| 740 | - | ||
| 741 | - | # ============================================================================== | |
| 742 | - | # MAIN ASSERTION SUITE | |
| 743 | - | # ============================================================================== | |
| 744 | - | def main() -> None: | |
| 745 | - | print("================================================================================") | |
| 746 | - | print("zBTC v1 (v3.0.0-rfc) ZERO-FEDERATION CONSISTENCY & BOUNDS CHECKER") | |
| 747 | - | print("Note: Checks internal mathematical consistency against SOURCED_, POLICY_, and") | |
| 748 | - | print(" PRE_MAINNET_TARGET_ inputs. Not an empirical Signet benchmark or audit.") | |
| 749 | - | print("================================================================================") | |
| 750 | - | ||
| 751 | - | # -------------------------------------------------------------------------- | |
| 752 | - | # 1. STAGE 0: COINBASE MIDSTATE 1- VS 2-BLOCK FINAL PADDING | |
| 753 | - | # -------------------------------------------------------------------------- | |
| 754 | - | print("\n=== 1. STAGE 0: COINBASE MIDSTATE 1-/2-BLOCK SHA-256 PADDING ===") | |
| 755 | - | one_blk_count = 0 | |
| 756 | - | two_blk_count = 0 | |
| 757 | - | for rem in range(64): | |
| 758 | - | total_len = 128 + rem # 2 full prefix blocks + remainder tail (realistic >= 128 B coinbase) | |
| 759 | - | cb_bytes = bytes((i * 37 + rem) & 0xFF for i in range(total_len)) | |
| 760 | - | # Compute real midstate over first 128 bytes | |
| 761 | - | st = _SHA256_IV | |
| 762 | - | st = sha256_compress(st, cb_bytes[0:64]) | |
| 763 | - | st = sha256_compress(st, cb_bytes[64:128]) | |
| 764 | - | midstate = struct.pack(">8I", *st) | |
| 765 | - | tail = cb_bytes[128:] | |
| 766 | - | got_txid, final_blks = complete_midstate_double_sha256(midstate, tail, total_len) | |
| 767 | - | expected_txid = hashlib.sha256(hashlib.sha256(cb_bytes).digest()).digest() | |
| 768 | - | assert got_txid == expected_txid, f"Midstate mismatch at rem={rem}" | |
| 769 | - | if rem < 56: | |
| 770 | - | assert final_blks == 1 | |
| 771 | - | one_blk_count += 1 | |
| 772 | - | else: | |
| 773 | - | assert final_blks == 2 | |
| 774 | - | two_blk_count += 1 | |
| 775 | - | assert one_blk_count == 56 and two_blk_count == 8 | |
| 776 | - | two_blk_pct = 100.0 * two_blk_count / 64.0 | |
| 777 | - | assert abs(two_blk_pct - 12.5) < 1e-9 | |
| 778 | - | # Verify CVE-2017-12842 64-byte leaf rejection | |
| 779 | - | try: | |
| 780 | - | complete_midstate_double_sha256(b"\x00" * 32, b"", 64) | |
| 781 | - | raise AssertionError("64-byte coinbase length must be rejected!") | |
| 782 | - | except AssertionError as e: | |
| 783 | - | assert "CVE-2017-12842" in str(e) | |
| 784 | - | print( | |
| 785 | - | f" Verified all 64/64 remainders against real hashlib.sha256 double-SHA256: " | |
| 786 | - | f"{one_blk_count} use 1 final block (rem 0..55), {two_blk_count} use 2 final blocks " | |
| 787 | - | f"(rem 56..63 = {two_blk_pct:.1f}% of coinbases); len==64 rejected." | |
| 788 | - | ) | |
| 789 | - | ||
| 790 | - | # -------------------------------------------------------------------------- | |
| 791 | - | # 2. STAGE 0: HONEST go-zenon THROUGHPUT, SPV ORACLE & DYNAMIC PLASMA PINNING | |
| 792 | - | # -------------------------------------------------------------------------- | |
| 793 | - | print("\n=== 2. STAGE 0: go-zenon THROUGHPUT, SPV ORACLE & DYNAMIC PLASMA PINNING ===") | |
| 794 | - | rollup_tx_plasma = ( | |
| 795 | - | SOURCED_ZNN_ACCOUNT_BLOCK_BASE_PLASMA | |
| 796 | - | + PRE_MAINNET_TARGET_ROLLUP_TX_DATA_BYTES * SOURCED_ZNN_AB_BYTE_DATA_PLASMA | |
| 797 | - | ) | |
| 798 | - | assert rollup_tx_plasma == 28_480 | |
| 799 | - | rollup_tx_qsr = ceil_div(rollup_tx_plasma, SOURCED_ZNN_PLASMA_PER_QSR) | |
| 800 | - | assert rollup_tx_qsr == 14 | |
| 801 | - | base_tx_qsr = ceil_div(SOURCED_ZNN_ACCOUNT_BLOCK_BASE_PLASMA, SOURCED_ZNN_PLASMA_PER_QSR) | |
| 802 | - | assert base_tx_qsr == 10 | |
| 803 | - | ||
| 804 | - | tps_floor = (POLICY_PINNED_MAX_BASE_PLASMA_FLOOR / SOURCED_ZNN_ACCOUNT_BLOCK_BASE_PLASMA / 2.0) / SOURCED_ZNN_OBSERVED_MOMENTUM_SECS | |
| 805 | - | tps_default = (SOURCED_ZNN_DP_DEFAULT_MAX_BASE_PLASMA / SOURCED_ZNN_ACCOUNT_BLOCK_BASE_PLASMA / 2.0) / SOURCED_ZNN_OBSERVED_MOMENTUM_SECS | |
| 806 | - | tps_naive_2p1b = (SOURCED_ZNN_DP_UPPER_MAX_BASE_PLASMA / SOURCED_ZNN_ACCOUNT_BLOCK_BASE_PLASMA / 2.0) / SOURCED_ZNN_OBSERVED_MOMENTUM_SECS | |
| 807 | - | # Real wire/protobuf ceiling governed by MaxDetailedMomentumWireSize (~8.38 MB) & MaxMomentumContentBytes (8 MiB) | |
| 808 | - | real_blocks_low = SOURCED_ZNN_MAX_DETAILED_MOMENTUM_WIRE // SOURCED_ZNN_MIN_ACCOUNT_BLOCK_WIRE_HIGH | |
| 809 | - | real_blocks_high = SOURCED_ZNN_MAX_DETAILED_MOMENTUM_WIRE // SOURCED_ZNN_MIN_ACCOUNT_BLOCK_WIRE_LOW | |
| 810 | - | real_tps_low = (real_blocks_low / 2.0) / SOURCED_ZNN_OBSERVED_MOMENTUM_SECS | |
| 811 | - | real_tps_high = (real_blocks_high / 2.0) / SOURCED_ZNN_OBSERVED_MOMENTUM_SECS | |
| 812 | - | assert 4.3 < tps_floor < 4.5 | |
| 813 | - | assert 8.7 < tps_default < 8.9 | |
| 814 | - | assert 4_385 < tps_naive_2p1b < 4_387 | |
| 815 | - | assert 1_000 < real_tps_low < 1_100 and 1_200 < real_tps_high < 1_260 | |
| 816 | - | assert real_tps_high < tps_naive_2p1b / 3.5 | |
| 817 | - | ||
| 818 | - | max_contract_blocks_floor = POLICY_PINNED_MAX_BASE_PLASMA_FLOOR // SOURCED_ZNN_EMBEDDED_SIMPLE_TIER | |
| 819 | - | assert max_contract_blocks_floor == 40 | |
| 820 | - | ||
| 821 | - | # Stage 0 Pure SPV Event Oracle calls matching spec/02 §2.2 byte-for-byte (ZERO custodial minting!): | |
| 822 | - | # - SubmitHeaderBatch(bytes headers): 4 + 32(off) + 32(len) + 160(2*80) = 228 B | |
| 823 | - | # - StepReorg(): 4 B | |
| 824 | - | # - PruneStaleHeaders(bytes hashes): 4 + 32(off) + 32(len) + 64(2*32) = 132 B | |
| 825 | - | # - ProveTxInclusion(u64 blockHeight, u32 txIndex, u32 totalCbBytes, bytes32 midstate, | |
| 826 | - | # bytes strippedTx, bytes32[] txBranch, bytes cbTail, bytes32[] cbBranch): | |
| 827 | - | # payload = 8 + 4 + 4 + 32 + 6,144 + 512 + 63 + 512 = 7,279 B | |
| 828 | - | # ABI = 4 + 8*32 + (32+6144) + (32+512) + (32+64) + (32+512) = 260 + 7,360 = 7,620 B | |
| 829 | - | prove_payload = 8 + 4 + 4 + 32 + POLICY_STAGE0_MAX_STRIPPED_TX_BYTES + 16 * 32 + 63 + 16 * 32 | |
| 830 | - | prove_abi = (4 + 8 * 32) + (32 + POLICY_STAGE0_MAX_STRIPPED_TX_BYTES) + (32 + 16 * 32) + (32 + 64) + (32 + 16 * 32) | |
| 831 | - | assert prove_payload == 7_279 and prove_abi == 7_620 | |
| 832 | - | ||
| 833 | - | stage0_calls = [ | |
| 834 | - | ("SubmitHeaderBatch(1..2 headers)", SOURCED_ZNN_EMBEDDED_SIMPLE_TIER, 160, 4 + 32 + 32 + 160, 8, 1), | |
| 835 | - | ("StepReorg()", SOURCED_ZNN_EMBEDDED_SIMPLE_TIER, 0, 4, 6, 1), | |
| 836 | - | ("PruneStaleHeaders(1..2 hashes)", SOURCED_ZNN_EMBEDDED_SIMPLE_TIER, 64, 4 + 32 + 32 + 64, 4, 1), | |
| 837 | - | ("ProveTxInclusion(<=6KiB tx + midstate)", SOURCED_ZNN_EMBEDDED_HEAVY_SPV_TIER, prove_payload, prove_abi, 8, 1), | |
| 838 | - | ] | |
| 839 | - | max_spv_plasma = 0 | |
| 840 | - | for name, tier, plen, abi_len, storage_ops, cblocks in stage0_calls: | |
| 841 | - | plasma = abi_embedded_plasma(tier, abi_len) | |
| 842 | - | qsr = ceil_div(plasma, SOURCED_ZNN_PLASMA_PER_QSR) | |
| 843 | - | max_spv_plasma = max(max_spv_plasma, plasma) | |
| 844 | - | assert abi_len <= SOURCED_ZNN_MAX_DATA_LENGTH | |
| 845 | - | assert storage_ops <= POLICY_STAGE0_MAX_STORAGE_OPS | |
| 846 | - | assert plasma <= POLICY_PINNED_MAX_BASE_PLASMA_FLOOR | |
| 847 | - | assert 3 * cblocks <= max_contract_blocks_floor | |
| 848 | - | if name.startswith("SubmitHeaderBatch"): | |
| 849 | - | assert abi_len == 228 and plasma == 67_732 and qsr == 33 | |
| 850 | - | elif name.startswith("StepReorg"): | |
| 851 | - | assert abi_len == 4 and plasma == 52_500 and qsr == 25 | |
| 852 | - | elif name.startswith("PruneStaleHeaders"): | |
| 853 | - | assert abi_len == 132 and plasma == 61_204 and qsr == 30 | |
| 854 | - | elif name.startswith("ProveTxInclusion"): | |
| 855 | - | assert abi_len == 7_620 and plasma == 591_388 and qsr == 282 | |
| 856 | - | print( | |
| 857 | - | f" Stage 0 {name:40s}: payload={plen:5d} B | ABI={abi_len:5d} B | " | |
| 858 | - | f"plasma={plasma:7,d} ({qsr:3d} QSR) | ops<={storage_ops:2d} | cblks={cblocks}" | |
| 859 | - | ) | |
| 860 | - | assert POLICY_PINNED_MAX_BASE_PLASMA_FLOOR >= 3 * max_spv_plasma | |
| 861 | - | ||
| 862 | - | # 1-block 110B rollup send throughput (no receive block needed, spec/03 §2.2) | |
| 863 | - | rollup_tps_floor = (POLICY_PINNED_MAX_BASE_PLASMA_FLOOR / rollup_tx_plasma) / SOURCED_ZNN_OBSERVED_MOMENTUM_SECS | |
| 864 | - | rollup_tps_default = (SOURCED_ZNN_DP_DEFAULT_MAX_BASE_PLASMA / rollup_tx_plasma) / SOURCED_ZNN_OBSERVED_MOMENTUM_SECS | |
| 865 | - | assert 6.3 < rollup_tps_floor < 6.6 and 12.8 < rollup_tps_default < 13.1 | |
| 866 | - | ||
| 867 | - | # Dynamic Plasma unpinned target/denominator explosion proof (spec/05 §2.2) | |
| 868 | - | price_unpinned = SOURCED_ZNN_MIN_RESOURCE_PRICE | |
| 869 | - | for _ in range(52): # ~9.9 minutes @ 11.4s/Momentum | |
| 870 | - | price_unpinned = dp_next_price( | |
| 871 | - | price_unpinned, | |
| 872 | - | used_plasma=SOURCED_ZNN_ACCOUNT_BLOCK_BASE_PLASMA, | |
| 873 | - | target_plasma=1, | |
| 874 | - | max_change_pct=POLICY_PINNED_MAX_PRICE_CHANGE_PCT, | |
| 875 | - | denom=1, | |
| 876 | - | ) | |
| 877 | - | explosion_mult = price_unpinned / SOURCED_ZNN_MIN_RESOURCE_PRICE | |
| 878 | - | assert explosion_mult > 100_000, f"Expected >100,000x unpinned explosion, got {explosion_mult:.1f}x" | |
| 879 | - | # Verify pinned targets (>=25% of 2.1M = 525,000) & denom >= 8 stay completely flat under single tx! | |
| 880 | - | price_pinned = SOURCED_ZNN_MIN_RESOURCE_PRICE | |
| 881 | - | pinned_target = (POLICY_PINNED_MAX_BASE_PLASMA_FLOOR * POLICY_PINNED_MIN_TARGET_SHARE_PCT) // 100 | |
| 882 | - | assert pinned_target == 525_000 | |
| 883 | - | for _ in range(52): | |
| 884 | - | price_pinned = dp_next_price( | |
| 885 | - | price_pinned, | |
| 886 | - | used_plasma=SOURCED_ZNN_ACCOUNT_BLOCK_BASE_PLASMA, | |
| 887 | - | target_plasma=pinned_target, | |
| 888 | - | max_change_pct=POLICY_PINNED_MAX_PRICE_CHANGE_PCT, | |
| 889 | - | denom=POLICY_PINNED_MIN_PRICE_DENOM, | |
| 890 | - | ) | |
| 891 | - | assert price_pinned == SOURCED_ZNN_MIN_RESOURCE_PRICE | |
| 892 | - | print( | |
| 893 | - | f" Plasma transfer costs: native=21,000 ({base_tx_qsr} QSR), 110B rollup tx={rollup_tx_plasma:,} ({rollup_tx_qsr} QSR) @ floor 1,000" | |
| 894 | - | ) | |
| 895 | - | print( | |
| 896 | - | f" Throughput @ {SOURCED_ZNN_OBSERVED_MOMENTUM_SECS}s/Mom: 2-blk floor(2.1M)={tps_floor:.1f} / default(4.2M)={tps_default:.1f} tx/s " | |
| 897 | - | f"| 1-blk rollup={rollup_tps_floor:.1f}/{rollup_tps_default:.1f} tx/s | REAL 8 MiB ceiling={real_tps_low:,.0f}-{real_tps_high:,.0f} tx/s (vs naive 2.1B={tps_naive_2p1b:,.0f})" | |
| 898 | - | ) | |
| 899 | - | print( | |
| 900 | - | f" Contract-block cap @ 2.1M floor={max_contract_blocks_floor} | " | |
| 901 | - | f"unpinned DP (target=1,denom=1,52 Moms) price mult={explosion_mult:,.0f}x (>100,000x) vs pinned={price_pinned//1000}x" | |
| 902 | - | ) | |
| 903 | - | ||
| 904 | - | # -------------------------------------------------------------------------- | |
| 905 | - | # 3. STAGE 0: PTLC & LN TIMELOCK SAFETY MARGINS (2.3x SLOW BLOCKS) | |
| 906 | - | # -------------------------------------------------------------------------- | |
| 907 | - | print("\n=== 3. STAGE 0: PTLC & LN TIMELOCK SAFETY MARGINS (2.3x SLOW BLOCKS) ===") | |
| 908 | - | bob_deadline_blks = POLICY_PTLC_BTC_CSV_BLOCKS - POLICY_PTLC_BOB_CONFIRM_MARGIN_BLOCKS | |
| 909 | - | assert bob_deadline_blks == 66 | |
| 910 | - | t_btc_worst_2x = round(POLICY_PTLC_BTC_CSV_BLOCKS * SOURCED_BTC_TARGET_BLOCK_SECS * SOURCED_JUNE2021_SLOW_WEEKLY_MULT) | |
| 911 | - | t_bob_confirm_2p3x = round(bob_deadline_blks * SOURCED_BTC_TARGET_BLOCK_SECS * SOURCED_JUNE2021_SLOW_DAILY_MULT) | |
| 912 | - | t_refund_2p3x = round(POLICY_PTLC_BTC_CSV_BLOCKS * SOURCED_BTC_TARGET_BLOCK_SECS * SOURCED_JUNE2021_SLOW_DAILY_MULT) | |
| 913 | - | alice_margin_2p3x_secs = POLICY_PTLC_ZNN_DURATION_SECS - t_bob_confirm_2p3x | |
| 914 | - | assert t_btc_worst_2x == 86_400 | |
| 915 | - | assert t_bob_confirm_2p3x == 91_080 # 25.3 hours | |
| 916 | - | assert t_refund_2p3x == 99_360 # 27.6 hours | |
| 917 | - | assert POLICY_PTLC_ZNN_DURATION_SECS == 108_000 # 30.0 hours (passed as now + 108_000 Unix ts) | |
| 918 | - | assert alice_margin_2p3x_secs == 16_920 # 4.7 hours > 0 | |
| 919 | - | assert 2 * POLICY_LN_DELTA_SAFETY_BLOCKS <= POLICY_PTLC_BTC_CSV_BLOCKS | |
| 920 | - | # Verify consistent Unix-second conversion for LN HTLC delta (no subtracting blocks from seconds!) | |
| 921 | - | ln_delta_secs_nominal = POLICY_LN_DELTA_SAFETY_BLOCKS * SOURCED_BTC_TARGET_BLOCK_SECS | |
| 922 | - | ln_delta_secs_2x = round(POLICY_LN_DELTA_SAFETY_BLOCKS * SOURCED_BTC_TARGET_BLOCK_SECS * SOURCED_JUNE2021_SLOW_WEEKLY_MULT) | |
| 923 | - | ln_delta_secs_2p3x = round(POLICY_LN_DELTA_SAFETY_BLOCKS * SOURCED_BTC_TARGET_BLOCK_SECS * SOURCED_JUNE2021_SLOW_DAILY_MULT) | |
| 924 | - | assert ln_delta_secs_nominal == 21_600 # 6.0h nominal (spec/03 §1.2) | |
| 925 | - | assert ln_delta_secs_2x == 43_200 # 12.0h @ 2.0x slow blocks | |
| 926 | - | assert ln_delta_secs_2p3x == 49_680 # 13.8h @ 2.3x slow blocks | |
| 927 | - | print( | |
| 928 | - | f" PTLC: CSV={POLICY_PTLC_BTC_CSV_BLOCKS} blks (Bob confirms <= h_conf+{bob_deadline_blks}) | " | |
| 929 | - | f"2.0x=24.0h | 2.3x June-2021 Bob confirm={t_bob_confirm_2p3x/3600:.1f}h < T_znn={POLICY_PTLC_ZNN_DURATION_SECS/3600:.1f}h " | |
| 930 | - | f"(Alice margin={alice_margin_2p3x_secs/3600:.1f}h; absolute Unix ts = now + 108,000)" | |
| 931 | - | ) | |
| 932 | - | ||
| 933 | - | # -------------------------------------------------------------------------- | |
| 934 | - | # 4. STAGE 1A: THEOREM 2 CAPITAL PROOF (BitVM2 vs RIGHT-SIZED BitVMX n=8) | |
| 935 | - | # -------------------------------------------------------------------------- | |
| 936 | - | print("\n=== 4. STAGE 1A: THEOREM 2 CAPITAL PROOF (BitVM2 vs RIGHT-SIZED BitVMX) ===") | |
| 937 | - | bitvm2_m3_low = 3 * PRE_MAINNET_TARGET_BITVM2_LANE_BOND_BTC_LOW | |
| 938 | - | bitvm2_m3_high = 3 * PRE_MAINNET_TARGET_BITVM2_LANE_BOND_BTC_HIGH | |
| 939 | - | bitvm2_m5_low = 5 * PRE_MAINNET_TARGET_BITVM2_LANE_BOND_BTC_LOW | |
| 940 | - | bitvm2_m5_high = 5 * PRE_MAINNET_TARGET_BITVM2_LANE_BOND_BTC_HIGH | |
| 941 | - | assert abs(bitvm2_m3_low - 39.90) < 1e-6 and abs(bitvm2_m5_high - 90.875) < 1e-6 | |
| 942 | - | assert bitvm2_m3_low > SOURCED_ZNN_MCAP_BTC_HIGH, "BitVM2 minimal M=3 exceeds 100% of ZNN mcap!" | |
| 943 | - | ||
| 944 | - | assert POLICY_LANE_TOTAL_BOND_SATS == 260_000_000 # 2.60 BTC/lane | |
| 945 | - | verifier_standby_btc = (POLICY_BITVMX_N_VERIFIERS * POLICY_F_CHAL_SATS) / SAT | |
| 946 | - | assert abs(verifier_standby_btc - 2.80) < 1e-9 | |
| 947 | - | for label, prof in POLICY_STAGE1A_PROFILES.items(): | |
| 948 | - | m = prof["M"] | |
| 949 | - | bonds_btc = (m * POLICY_BITVMX_L_LANES * POLICY_LANE_TOTAL_BOND_SATS) / SAT | |
| 950 | - | total_btc = bonds_btc + prof["float_btc"] + verifier_standby_btc | |
| 951 | - | pct_low = 100.0 * total_btc / SOURCED_ZNN_MCAP_BTC_HIGH | |
| 952 | - | pct_high = 100.0 * total_btc / SOURCED_ZNN_MCAP_BTC_LOW | |
| 953 | - | if m == 3: | |
| 954 | - | assert abs(bonds_btc - 7.80) < 1e-9 and abs(total_btc - 12.80) < 1e-9 | |
| 955 | - | if m == 5: | |
| 956 | - | assert abs(bonds_btc - 13.00) < 1e-9 and abs(total_btc - 18.80) < 1e-9 | |
| 957 | - | assert total_btc < bitvm2_m3_low | |
| 958 | - | print( | |
| 959 | - | f" BitVMX {label:18s}: bonds={bonds_btc:5.2f} + float={prof['float_btc']:4.2f} + " | |
| 960 | - | f"verifiers={verifier_standby_btc:4.2f} = {total_btc:5.2f} BTC ({pct_low:.1f}%-{pct_high:.1f}% of 25-33 BTC ZNN mcap)" | |
| 961 | - | ) | |
| 962 | - | print( | |
| 963 | - | f" BitVM2 contrast (M=3..5, L=1, bonds only): {bitvm2_m3_low:.2f}-{bitvm2_m5_high:.3f} BTC " | |
| 964 | - | f"(>100%-275%+ of ZNN mcap before fronting float!)" | |
| 965 | - | ) | |
| 966 | - | ||
| 967 | - | # -------------------------------------------------------------------------- | |
| 968 | - | # 5. STAGE 1A: BitVMX n=8 BISECTION & 100% BIP-431 TRUC v3 COMPLIANCE | |
| 969 | - | # -------------------------------------------------------------------------- | |
| 970 | - | print("\n=== 5. STAGE 1A: BitVMX-CPU n=8 BISECTION & BIP-431 TRUC v3 COMPLIANCE ===") | |
| 971 | - | interm_hashes_per_tx = POLICY_BITVMX_N_BRANCH - 1 # 7 intermediate 20B OP_HASH160 hashes | |
| 972 | - | data_digits_per_hash = 160 // 4 # 40 base-16 nibbles | |
| 973 | - | max_checksum = data_digits_per_hash * 15 # 600 <= 16^3 - 1 = 4,095 -> 3 checksum digits | |
| 974 | - | assert max_checksum <= 16**3 - 1 | |
| 975 | - | digits_per_hash = data_digits_per_hash + 3 # 43 digits | |
| 976 | - | digits_per_prover_tx = interm_hashes_per_tx * digits_per_hash | |
| 977 | - | assert digits_per_prover_tx == 301 | |
| 978 | - | prover_wots_wu = math.ceil(digits_per_prover_tx * PRE_MAINNET_TARGET_WOTS_DIGIT_WU) | |
| 979 | - | assert prover_wots_wu == 28_746 | |
| 980 | - | prover_wots_vb = prover_wots_wu / 4.0 | |
| 981 | - | assert abs(prover_wots_vb - 7_186.5) < 1e-9 | |
| 982 | - | prover_step_vb = prover_wots_vb + PRE_MAINNET_TARGET_BISECTION_OVERHEAD_VB | |
| 983 | - | assert abs(prover_step_vb - 7_436.5) < 1e-9 | |
| 984 | - | assert prover_step_vb <= SOURCED_BIP431_TRUC_MAX_VB, "n=8 prover bisection tx must fit TRUC v3!" | |
| 985 | - | ||
| 986 | - | # Verify why rejected n=16 failed TRUC v3: | |
| 987 | - | n16_wots_vb = math.ceil(15 * digits_per_hash * PRE_MAINNET_TARGET_WOTS_DIGIT_WU) / 4.0 + PRE_MAINNET_TARGET_BISECTION_OVERHEAD_VB | |
| 988 | - | assert n16_wots_vb > SOURCED_BIP431_TRUC_MAX_VB | |
| 989 | - | ||
| 990 | - | instructions_covered = POLICY_BITVMX_N_BRANCH ** POLICY_BITVMX_SEARCH_ROUNDS | |
| 991 | - | assert instructions_covered == 2**27 == 134_217_728 | |
| 992 | - | seq_steps = 1 + POLICY_BITVMX_SEARCH_ROUNDS + POLICY_BITVMX_SEARCH_ROUNDS + 1 | |
| 993 | - | assert seq_steps == 20 | |
| 994 | - | ||
| 995 | - | prover_total_vb = ( | |
| 996 | - | POLICY_BITVMX_SEARCH_ROUNDS * prover_step_vb | |
| 997 | - | + PRE_MAINNET_TARGET_START_TX_VB | |
| 998 | - | + PRE_MAINNET_TARGET_FINAL_TRACE_TX_VB | |
| 999 | - | ) | |
| 1000 | - | verifier_total_vb = ( | |
| 1001 | - | PRE_MAINNET_TARGET_CHALLENGE_TX_VB | |
| 1002 | - | + POLICY_BITVMX_SEARCH_ROUNDS * PRE_MAINNET_TARGET_VERIFIER_CHOICE_VB | |
| 1003 | - | + PRE_MAINNET_TARGET_EXECUTE_OPCODE_VB | |
| 1004 | - | ) | |
| 1005 | - | assert prover_total_vb <= PRE_MAINNET_TARGET_PROVER_CONSERVATIVE_VB | |
| 1006 | - | assert verifier_total_vb <= PRE_MAINNET_TARGET_VERIFIER_CONSERVATIVE_VB | |
| 1007 | - | ||
| 1008 | - | prover_fee_500 = PRE_MAINNET_TARGET_PROVER_CONSERVATIVE_VB * POLICY_DESIGN_SUSTAINED_FEE_SATVB | |
| 1009 | - | verifier_fee_500 = PRE_MAINNET_TARGET_VERIFIER_CONSERVATIVE_VB * POLICY_DESIGN_SUSTAINED_FEE_SATVB | |
| 1010 | - | prover_breakeven_satvb = POLICY_F_CHAL_SATS // PRE_MAINNET_TARGET_PROVER_CONSERVATIVE_VB | |
| 1011 | - | assert prover_fee_500 == 37_500_000 <= POLICY_F_CHAL_SATS | |
| 1012 | - | assert verifier_fee_500 == 7_500_000 | |
| 1013 | - | assert prover_breakeven_satvb == 533 | |
| 1014 | - | print( | |
| 1015 | - | f" n=8 bisection: {interm_hashes_per_tx} hashes x {digits_per_hash} digits = {digits_per_prover_tx} digits = " | |
| 1016 | - | f"{prover_wots_wu:,} WU ({prover_wots_vb:,.1f} vB) + 250 = {prover_step_vb:,.1f} vB <= 10,000 vB TRUC v3 " | |
| 1017 | - | f"(rejected n=16 = {n16_wots_vb:,.0f} vB > 10,000 vB)" | |
| 1018 | - | ) | |
| 1019 | - | print( | |
| 1020 | - | f" 9 rounds -> 8^9 = 2^27 = {instructions_covered:,} RV32IM ops | {seq_steps} sequential steps | " | |
| 1021 | - | f"Prover={prover_total_vb:,.1f} vB (~75 kvB; {prover_fee_500/SAT:.3f} BTC <= F_chal=0.40 BTC @ 500 sat/vB, " | |
| 1022 | - | f"break-even={prover_breakeven_satvb} sat/vB) | Verifier={verifier_total_vb:,.0f} vB (cap 15 kvB; 0.075 BTC @ 500 sat/vB)" | |
| 1023 | - | ) | |
| 1024 | - | ||
| 1025 | - | # -------------------------------------------------------------------------- | |
| 1026 | - | # 6. STAGE 1A: SIMULTANEOUS TIMELOCKS & 256-BIT LAMPORT TakeTx BOUNDS | |
| 1027 | - | # -------------------------------------------------------------------------- | |
| 1028 | - | print("\n=== 6. STAGE 1A: TIMELOCK ORDERING & 256-BIT LAMPORT TakeTx BIP-342/TRUC BOUNDS ===") | |
| 1029 | - | max_dispute_end = POLICY_T_CHAL_WINDOW + seq_steps * POLICY_T_STEP | |
| 1030 | - | assert max_dispute_end == 1_104 | |
| 1031 | - | assert POLICY_T_CHAL_WINDOW < max_dispute_end < POLICY_T_TAKE < POLICY_T_COOLDOWN < POLICY_T_RETIRE | |
| 1032 | - | assert POLICY_T_COOLDOWN - POLICY_T_TAKE == 144 # 24h Lamport equivocation slash window | |
| 1033 | - | assert PRE_MAINNET_TARGET_DEPOSIT_CERTBLOB_BYTES == 104 <= SOURCED_BIP342_MAX_PUSH_BYTES | |
| 1034 | - | ||
| 1035 | - | # Exact 256-bit Lamport L_{j,l,r} Tapscript leaf: | |
| 1036 | - | # 256 x (OP_HASH160 [1B] + PUSH20 [1B] + 20B hash + OP_EQUALVERIFY [1B]) + PUSH32 [1B] + 32B Q_setup + OP_CHECKSIG [1B] | |
| 1037 | - | lamport_script_bytes = 256 * (1 + 1 + 20 + 1) + (1 + 32 + 1) | |
| 1038 | - | assert lamport_script_bytes == 5_922 | |
| 1039 | - | lamport_preimages_bytes = 256 * (1 + 20) # 256 x (len=0x14 + 20B preimage) | |
| 1040 | - | assert lamport_preimages_bytes == 5_376 | |
| 1041 | - | # Control blocks: Stage 1A (M=5, R=64 -> 320 leaves -> depth 9) & Stage 2 (40 lanes * 64 -> 2,560 leaves -> depth 12) | |
| 1042 | - | leaves_stage1a = POLICY_BITVMX_M_MAX * POLICY_BITVMX_L_LANES * POLICY_BITVMX_R_ROUNDS | |
| 1043 | - | leaves_stage2 = POLICY_STAGE2_TOTAL_LANES * POLICY_BITVMX_R_ROUNDS | |
| 1044 | - | depth_stage1a = math.ceil(math.log2(leaves_stage1a)) | |
| 1045 | - | depth_stage2 = math.ceil(math.log2(leaves_stage2)) | |
| 1046 | - | assert leaves_stage1a == 320 and depth_stage1a == 9 | |
| 1047 | - | assert leaves_stage2 == 2_560 and depth_stage2 == 12 | |
| 1048 | - | cb_stage1a = 1 + 32 + 32 * depth_stage1a | |
| 1049 | - | cb_stage2 = 1 + 32 + 32 * depth_stage2 | |
| 1050 | - | assert cb_stage1a == 321 and cb_stage2 == 417 | |
| 1051 | - | # Peak stack: 256 preimages + 1 Schnorr sig + 1 pushed 20B hash during OP_HASH160 <H> OP_EQUALVERIFY | |
| 1052 | - | lamport_peak_stack = 256 + 1 + 1 | |
| 1053 | - | assert lamport_peak_stack == 258 < SOURCED_BIP342_MAX_STACK_ITEMS | |
| 1054 | - | # Total TakeTx weight (2 inputs: U_d Lamport leaf + VaultConnector_r CSV leaf; 2 outputs: P2TR + P2A) | |
| 1055 | - | take_non_witness = 10 + 2 * 41 + 43 + 13 # 148 B -> 592 WU | |
| 1056 | - | take_wit_ud_s2 = ( | |
| 1057 | - | compact_size_len(259) | |
| 1058 | - | + (1 + 64) | |
| 1059 | - | + lamport_preimages_bytes | |
| 1060 | - | + compact_size_len(lamport_script_bytes) + lamport_script_bytes | |
| 1061 | - | + compact_size_len(cb_stage2) + cb_stage2 | |
| 1062 | - | ) | |
| 1063 | - | take_wit_connector = 110 # Conservative VaultConnector_r CSV tapscript witness | |
| 1064 | - | take_total_wu = take_non_witness * 4 + take_wit_ud_s2 + take_wit_connector | |
| 1065 | - | take_total_vb = take_total_wu / 4.0 | |
| 1066 | - | assert take_total_vb <= 3_200 <= SOURCED_BIP431_TRUC_MAX_VB | |
| 1067 | - | print( | |
| 1068 | - | f" Timelocks: chal=[0,{POLICY_T_CHAL_WINDOW}] | max_dispute={max_dispute_end} < T_take={POLICY_T_TAKE} " | |
| 1069 | - | f"< T_cooldown={POLICY_T_COOLDOWN} < Retire={POLICY_T_RETIRE} (144-blk equivocation margin)" | |
| 1070 | - | ) | |
| 1071 | - | print( | |
| 1072 | - | f" Lamport TakeTx: script={lamport_script_bytes:,} B | preimages={lamport_preimages_bytes:,} B | " | |
| 1073 | - | f"CB(depth 9/12)={cb_stage1a}/{cb_stage2} B | peak_stack={lamport_peak_stack} (<1,000) | " | |
| 1074 | - | f"TakeTx={take_total_vb:,.1f} vB (<=3,200 <=10,000 TRUC v3)" | |
| 1075 | - | ) | |
| 1076 | - | ||
| 1077 | - | # -------------------------------------------------------------------------- | |
| 1078 | - | # 7. STAGE 1A: COLLUDING-VERIFIER POSITIVE-EV MATRIX (k_collude = 0..6 of N=7) | |
| 1079 | - | # -------------------------------------------------------------------------- | |
| 1080 | - | print("\n=== 7. STAGE 1A: COLLUDING-VERIFIER POSITIVE-EV MATRIX (N=7, k_collude=0..6) ===") | |
| 1081 | - | assert POLICY_WINNING_VERIFIER_L1_SATS + POLICY_BURNED_BOND_SATS == POLICY_BOND_BTC_SATS | |
| 1082 | - | other_challenger_share = POLICY_B_ZBTC_CUSTODY_SLICE_SATS // (POLICY_BITVMX_N_VERIFIERS - 1) | |
| 1083 | - | assert other_challenger_share == 9_166_666 # 0.09166666 BTC | |
| 1084 | - | honest_min_net_ev = other_challenger_share - verifier_fee_500 | |
| 1085 | - | assert honest_min_net_ev == 1_666_666 > 0 # +0.01666666 BTC (> +0.0167 rounded) | |
| 1086 | - | ||
| 1087 | - | for k_collude in range(POLICY_BITVMX_N_VERIFIERS): | |
| 1088 | - | honest_count = POLICY_BITVMX_N_VERIFIERS - k_collude | |
| 1089 | - | assert honest_count >= 1 | |
| 1090 | - | vault_stolen = 0 # Dual-input Disprove/TimeoutSlash spends Stake_r AND VaultConnector_r! | |
| 1091 | - | # Worst case for protocol: colluding verifier captures 0.15 BTC L1 win (when k_collude >= 1) | |
| 1092 | - | # AND (k_collude - 1) other colluders each capture 1/6 of 0.55 BTC B_zbtc slice! | |
| 1093 | - | colluder_l1_recapture = POLICY_WINNING_VERIFIER_L1_SATS if k_collude >= 1 else 0 | |
| 1094 | - | colluder_zbtc_recapture = max(0, k_collude - 1) * other_challenger_share | |
| 1095 | - | # Upper-bound attacker P&L (even ignoring attacker's own L1 fees): | |
| 1096 | - | colluder_pnl = ( | |
| 1097 | - | vault_stolen | |
| 1098 | - | - POLICY_BOND_BTC_SATS | |
| 1099 | - | - POLICY_B_ZBTC_CUSTODY_SLICE_SATS | |
| 1100 | - | + colluder_l1_recapture | |
| 1101 | - | + colluder_zbtc_recapture | |
| 1102 | - | ) | |
| 1103 | - | assert colluder_pnl < 0 | |
| 1104 | - | if k_collude == 0: | |
| 1105 | - | assert colluder_pnl == -255_000_000 # -2.55 BTC (O_j alone) | |
| 1106 | - | if k_collude == 1: | |
| 1107 | - | assert colluder_pnl == -240_000_000 # -2.40 BTC (O_j + colluding V_1) | |
| 1108 | - | if k_collude == 6: | |
| 1109 | - | assert colluder_pnl == -194_166_670 # -1.9417 BTC (O_j + 6 of 7 verifiers!) | |
| 1110 | - | print( | |
| 1111 | - | f" k_collude={k_collude} (honest={honest_count}): vault_stolen=0 | " | |
| 1112 | - | f"honest_EV>={honest_min_net_ev/SAT:+.4f} BTC (@500 sat/vB) | " | |
| 1113 | - | f"combined_attacker_PnL={colluder_pnl/SAT:+.4f} BTC" | |
| 1114 | - | ) | |
| 1115 | - | ||
| 1116 | - | # -------------------------------------------------------------------------- | |
| 1117 | - | # 8. STAGE 1A: MULTI-TIER VAULTS {0.50, 0.25, 0.25} & 100% BANK-RUN MATH | |
| 1118 | - | # -------------------------------------------------------------------------- | |
| 1119 | - | print("\n=== 8. STAGE 1A: MULTI-TIER VAULTS & 100% BANK-RUN EXIT DURATION ===") | |
| 1120 | - | cooldown_days = POLICY_T_COOLDOWN / SOURCED_BTC_BLOCKS_PER_DAY | |
| 1121 | - | assert abs(cooldown_days - 9.0) < 1e-9 | |
| 1122 | - | avg_vault_multi_btc = (sum(POLICY_VAULT_TIERS_SATS) / len(POLICY_VAULT_TIERS_SATS)) / SAT | |
| 1123 | - | avg_vault_half_btc = (sum(POLICY_VAULT_ALT_SPLIT_SATS) / len(POLICY_VAULT_ALT_SPLIT_SATS)) / SAT | |
| 1124 | - | assert abs(avg_vault_multi_btc - (1.0 / 3.0)) < 1e-9 | |
| 1125 | - | assert abs(avg_vault_half_btc - 0.50) < 1e-9 | |
| 1126 | - | ||
| 1127 | - | for label, prof in POLICY_STAGE1A_PROFILES.items(): | |
| 1128 | - | m = prof["M"] | |
| 1129 | - | cap_btc = prof["cap_btc"] | |
| 1130 | - | float_btc = prof["float_btc"] | |
| 1131 | - | vaults_per_day = (m * POLICY_BITVMX_L_LANES) / cooldown_days | |
| 1132 | - | btc_per_day_multi = vaults_per_day * avg_vault_multi_btc | |
| 1133 | - | btc_per_day_half = vaults_per_day * avg_vault_half_btc | |
| 1134 | - | # Discrete vault batches remaining after immediate fronting float: | |
| 1135 | - | total_vaults_multi = int(round(cap_btc / avg_vault_multi_btc)) | |
| 1136 | - | fronted_vaults_multi = int(float_btc // avg_vault_multi_btc) | |
| 1137 | - | rem_vaults_multi = total_vaults_multi - fronted_vaults_multi | |
| 1138 | - | bank_run_days_multi = math.ceil(rem_vaults_multi / m) * cooldown_days | |
| 1139 | - | bank_run_days_multi_cont = (cap_btc - float_btc) / btc_per_day_multi | |
| 1140 | - | bank_run_days_half_cont = (cap_btc - float_btc) / btc_per_day_half | |
| 1141 | - | if m == 3: | |
| 1142 | - | assert abs(vaults_per_day - 1.0 / 3.0) < 1e-9 | |
| 1143 | - | assert abs(btc_per_day_multi - 1.0 / 9.0) < 1e-9 | |
| 1144 | - | assert 70.0 <= bank_run_days_multi_cont <= 72.0 and bank_run_days_multi == 72.0 | |
| 1145 | - | assert 46.0 <= bank_run_days_half_cont <= 48.0 | |
| 1146 | - | if m == 5: | |
| 1147 | - | assert abs(vaults_per_day - 5.0 / 9.0) < 1e-9 | |
| 1148 | - | assert abs(btc_per_day_multi - 5.0 / 27.0) < 1e-9 | |
| 1149 | - | assert 64.0 <= bank_run_days_multi_cont <= 66.0 | |
| 1150 | - | assert 42.5 <= bank_run_days_half_cont <= 44.0 | |
| 1151 | - | print( | |
| 1152 | - | f" {label:18s}: {vaults_per_day:.3f} vaults/d ({btc_per_day_multi:.3f} BTC/d @ avg 0.333 BTC) | " | |
| 1153 | - | f"100% bank run = ~{bank_run_days_multi_cont:.1f}d (batch={bank_run_days_multi:.0f}d) " | |
| 1154 | - | f"[~{bank_run_days_half_cont:.1f}d w/ {{0.50,0.50}}]" | |
| 1155 | - | ) | |
| 1156 | - | ||
| 1157 | - | # Finite-round admission cap (spec/01 §6): N_live_vaults <= 0.50 * RemainingTotalRounds | |
| 1158 | - | max_live_vaults_m5 = (POLICY_BITVMX_M_MAX * POLICY_BITVMX_L_LANES * POLICY_BITVMX_R_ROUNDS) // 2 | |
| 1159 | - | assert max_live_vaults_m5 == 160 and max_live_vaults_m5 * avg_vault_multi_btc > 15.0 | |
| 1160 | - | ||
| 1161 | - | # -------------------------------------------------------------------------- | |
| 1162 | - | # 9. HALVING-INDEXED TVL-SCALED K PRIVATE-FORK INEQUALITY | |
| 1163 | - | # -------------------------------------------------------------------------- | |
| 1164 | - | print("\n=== 9. HALVING-INDEXED TVL-SCALED K PRIVATE-FORK INEQUALITY (0.50*K*Sub > Cap) ===") | |
| 1165 | - | for cap_btc in POLICY_TVL_TIERS_BTC: | |
| 1166 | - | k_cfg = POLICY_CONFIGURED_K_2024[cap_btc] | |
| 1167 | - | assert 0.50 * k_cfg * SOURCED_BTC_SUBSIDY_BY_ERA["2024-2028"] > cap_btc | |
| 1168 | - | row_parts = [] | |
| 1169 | - | for era, sub in SOURCED_BTC_SUBSIDY_BY_ERA.items(): | |
| 1170 | - | k_min = int(math.floor((2.0 * cap_btc) / sub)) + 1 | |
| 1171 | - | assert 0.50 * k_min * sub > cap_btc | |
| 1172 | - | assert 0.50 * (k_min - 1) * sub <= cap_btc + 1e-12 | |
| 1173 | - | if era in POLICY_CONFIGURED_K_BY_ERA: | |
| 1174 | - | k_era_cfg = POLICY_CONFIGURED_K_BY_ERA[era][cap_btc] | |
| 1175 | - | assert k_era_cfg >= k_min and 0.50 * k_era_cfg * sub > cap_btc | |
| 1176 | - | row_parts.append(f"{era}:K>={k_min}") | |
| 1177 | - | print(f" Cap={cap_btc:3d} BTC (2024 cfg K={k_cfg:3d}): " + " | ".join(row_parts)) | |
| 1178 | - | ||
| 1179 | - | # -------------------------------------------------------------------------- | |
| 1180 | - | # 10. STAGE 1B (clArk) ALTERNATIVE GATE: LIQUIDITY & log2(N) EXIT WEIGHTS | |
| 1181 | - | # -------------------------------------------------------------------------- | |
| 1182 | - | print("\n=== 10. STAGE 1B (clArk) ALTERNATIVE GATE: LIQUIDITY & log2(N) BRANCH EXIT WEIGHTS ===") | |
| 1183 | - | clark_liq_low, clark_liq_high = PRE_MAINNET_TARGET_CLARK_ACTIVE_LIQ_BTC | |
| 1184 | - | assert clark_liq_low == 2.0 and clark_liq_high == 5.0 | |
| 1185 | - | assert clark_liq_high < 12.80 # Strictly below Stage 1A BitVMX M=3 capital floor | |
| 1186 | - | # Exact BIP-341 P2TR internal branch tx: 10.5 (hdr) + 57.5 (P2TR keypath in) + 2*43 (2 P2TR outs) + 13 (P2A) = 167 vB | |
| 1187 | - | clark_branch_tx_vb = 167.0 | |
| 1188 | - | clark_leaf_tx_vb = 154.0 | |
| 1189 | - | for n_vtxo in PRE_MAINNET_TARGET_CLARK_VTXO_COUNTS: | |
| 1190 | - | depth = int(math.log2(n_vtxo)) | |
| 1191 | - | assert 2**depth == n_vtxo | |
| 1192 | - | total_exit_vb = depth * clark_branch_tx_vb + clark_leaf_tx_vb | |
| 1193 | - | fee_100 = int(total_exit_vb * 100) | |
| 1194 | - | fee_500 = int(total_exit_vb * 500) | |
| 1195 | - | assert total_exit_vb < SOURCED_BIP431_TRUC_MAX_VB | |
| 1196 | - | print( | |
| 1197 | - | f" N={n_vtxo:4d} VTXOs (depth={depth:2d}): unilateral branch exit={total_exit_vb:6.0f} vB | " | |
| 1198 | - | f"@100 sat/vB={fee_100:,} sats | @500 sat/vB={fee_500:,} sats ({fee_500/SAT:.5f} BTC)" | |
| 1199 | - | ) | |
| 1200 | - | print(f" Active ASP liquidity turnover range: {clark_liq_low:.1f}-{clark_liq_high:.1f} BTC (0 operator bonds; expiring VTXOs)") | |
| 1201 | - | ||
| 1202 | - | # -------------------------------------------------------------------------- | |
| 1203 | - | # 11. REAL 2,000-STEP RANDOMIZED STAGE 1A SOLVENCY SIMULATION (ZERO NO-OPS!) | |
| 1204 | - | # -------------------------------------------------------------------------- | |
| 1205 | - | print("\n=== 11. REAL 2,000-STEP STAGE 1A SOLVENCY SIMULATION (WITH GENUINE REORGS) ===") | |
| 1206 | - | counts = run_stage1a_solvency_sim(seed=20261128, steps=2_000) | |
| 1207 | - | for k, v in counts.items(): | |
| 1208 | - | assert v > 0, f"Event type {k} was never exercised: {counts}" | |
| 1209 | - | assert counts["reorg_blocks_reverted"] >= counts["reorg"] > 0 | |
| 1210 | - | assert counts["reorg_events_reverted"] > 0 | |
| 1211 | - | summary = ", ".join(f"{k}={v}" for k, v in counts.items()) | |
| 1212 | - | print(f" Bob (1->0.5->exit 0.5) & Mike (1+1->2->exit 0.25) + 2,000 adversarial steps PASSED 1:1 solvency:") | |
| 1213 | - | print(f" {summary}") | |
| 1214 | - | print("\nALL v1 (v3.0.0-rfc ZERO-FEDERATION) CONSISTENCY, WEIGHT, PLASMA, TIMELOCK & SOLVENCY CHECKS PASSED.") | |
| 4 | + | v2 (v3.1.0-rfc — Zero-Federation Phased Architecture, R8 Hardened: | |
| 5 | + | Stage 0 Verify Bitcoin SPV Oracle + Erlang-Hardened PTLC/LN | |
| 6 | + | -> Stage 1A Right-Sized BitVMX (n=8, M=3..5, N=7, Core >= 29.0) + Sovereign ZK Rollup | |
| 7 | + | | Stage 1B clArk Alternative Gate | |
| 8 | + | -> Stage 2 Zero-TTP Scale & Upgrade). | |
| 9 | + | ||
| 10 | + | SCOPE & HONESTY DISCLOSURE: | |
| 11 | + | This script checks internal mathematical consistency using pure Python 3 stdlib ONLY: | |
| 12 | + | 1. Stage 0 coinbase midstate 1-/2-block SHA-256 final padding across all 64 remainders + >= 65 B filter (R8-M06) | |
| 13 | + | 2. Stage 0 honest go-zenon Plasma/wire ceilings, Dynamic Plasma 5-param pinning, & Bitcoin L1 0x02 DA cap (R8-M08) | |
| 14 | + | 3. Stage 0 exact Erlang/Poisson survival tails for PTLC (>= 48h) & LN HTLC (>= 24h) under 2.3x slowdown (R8-H07) | |
| 15 | + | 4. Proposition 2 complete hard-BTC capital accounting: locked vs operational baseline vs multi-dispute headroom (R8-M09) | |
| 16 | + | 5. Stage 1A BitVMX-CPU n=8 W-OTS + 10x153 vB P2A CPFP & Core >= 29.0 BIP-431 TRUC v3 compliance (R8-H04/H05) | |
| 17 | + | 6. Stage 1A widened timelocks (T_step=72 -> 1,584 < 1,728 < 1,872 < 2,016) & acyclic vault_id Lamport TakeTx (R8-C01) | |
| 18 | + | 7. Stage 1A native-L1 Stake_r ChalPayoutEscrow verifier EV @ 500 & 750 sat/vB, 16.53 kvB, lockup, 30% zBTC discount (R8-H02/N05) | |
| 19 | + | 8. Stage 1A exact 2^M Hall's Marriage Theorem checker + counterexample regression & cyclic (H(exitId)+r) mod M (R8-C04/M03) | |
| 20 | + | 9. Stage 1A multi-tier {0.50, 0.25, 0.25} bank-run exit bounds (T_cooldown=13.0d) & TransferCredit consolidation (R8-M04) | |
| 21 | + | 10. Stage 1A K >= 18 unpublished-fork heuristic (Cap_user + M*B_zbtc) & Budish winning-fork flow-cost sensitivity (R8-H03) | |
| 22 | + | 11. Stage 1B clArk active liquidity & log2(N) branch exit weights | |
| 23 | + | 12. Non-no-op randomized state-machine simulation separating fifo_assign & take_confirmed across T_take with explicit | |
| 24 | + | AssignedObligations (A) conservation (V_unassigned + V_assigned == C + L + E + R + A + B), AdmissionTicketUTXO cap | |
| 25 | + | mutual exclusion, k=20 single-block ExitSlotUTXO grief burst, TransferCredit, real Bitcoin reorgs, and slashes | |
| 26 | + | (R8-C02, R8-C03, R8-H01, R8-N05, R8-M04). | |
| 27 | + | ||
| 28 | + | Every modeled constant is explicitly prefixed by provenance: | |
| 29 | + | - SOURCED_ : Bitcoin BIPs, historical chain telemetry, or go-zenon origin/dev | |
| 30 | + | - POLICY_ : Explicit protocol design parameters | |
| 31 | + | - PRE_MAINNET_TARGET_ : BitVMX-CPU / rollup sizing targets to be empirically measured on Signet (Gates G1-G5) | |
| 32 | + | ||
| 33 | + | This script is a consistency & bounds checker — NOT an empirical Signet benchmark | |
| 34 | + | and NOT a substitute for independent cryptographic/implementation audits. | |
| 35 | + | ||
| 36 | + | Run: `python3 -I scripts/verify_spec_bounds.py` | |
| 37 | + | """ | |
| 38 | + | import hashlib | |
| 39 | + | import math | |
| 40 | + | import random | |
| 41 | + | import struct | |
| 42 | + | ||
| 43 | + | SAT = 100_000_000 | |
| 44 | + | ||
| 45 | + | # ============================================================================== | |
| 46 | + | # SOURCED CONSTANTS (Bitcoin BIPs, Historical Telemetry, go-zenon origin/dev) | |
| 47 | + | # ============================================================================== | |
| 48 | + | SOURCED_BIP431_TRUC_MAX_VB = 10_000 # BIP-431 TRUC v3 parent max vBytes | |
| 49 | + | SOURCED_BIP431_TRUC_CHILD_MAX_VB = 1_000 # BIP-431 TRUC v3 child max vBytes | |
| 50 | + | SOURCED_BTC_CORE_MIN_VERSION_P2A_ZERO = "29.0" # Core >= 29.0 required for 0-sat P2A ephemeral dust (R8-M09) | |
| 51 | + | SOURCED_BIP342_MAX_STACK_ITEMS = 1_000 # BIP-342 Tapscript max stack elements | |
| 52 | + | SOURCED_BIP342_MAX_PUSH_BYTES = 520 # BIP-342 Tapscript max push element size | |
| 53 | + | SOURCED_BIP141_MAX_STRIPPED_BLOCK_BYTES = 1_000_000 # Bitcoin consensus max non-witness block bytes | |
| 54 | + | SOURCED_BTC_MAX_BLOCK_WEIGHT = 4_000_000 # Bitcoin consensus 4 MWU = 1,000,000 vB/block | |
| 55 | + | SOURCED_BTC_TARGET_BLOCK_SECS = 600 # 10 min nominal Bitcoin block interval | |
| 56 | + | SOURCED_BTC_BLOCKS_PER_DAY = 144 # Nominal blocks/day | |
| 57 | + | SOURCED_JUNE2021_SLOW_WEEKLY_MULT = 2.0 # June 2021 China ban: ~1.95-2.0x 7d avg | |
| 58 | + | SOURCED_JUNE2021_SLOW_DAILY_MULT = 2.3 # June 2021 China ban: ~23 min/blk daily peak | |
| 59 | + | SOURCED_APR2024_MEDIAN_FEE_SATVB = 1_805 # April 2024 halving/Runes median peak | |
| 60 | + | SOURCED_P2A_CPFP_CHILD_VB = 153 # Standard 1-in-P2TR + 1-in-P2A -> 1-out-P2TR CPFP child (vB) | |
| 61 | + | ||
| 62 | + | # Bitcoin block subsidy schedule (BTC/block) across halvings | |
| 63 | + | SOURCED_BTC_SUBSIDY_BY_ERA = { | |
| 64 | + | "2024-2028": 3.125, | |
| 65 | + | "2028-2032": 1.5625, | |
| 66 | + | "2032-2036": 0.78125, | |
| 67 | + | "2036-2040": 0.390625, | |
| 68 | + | } | |
| 69 | + | ||
| 70 | + | # ZNN market-cap context (Nov 2026 observed range; 0% ZNN in BTC custody safety!) | |
| 71 | + | SOURCED_ZNN_MCAP_BTC_LOW = 25.0 | |
| 72 | + | SOURCED_ZNN_MCAP_BTC_HIGH = 33.0 | |
| 73 | + | ||
| 74 | + | # go-zenon origin/dev protocol constants | |
| 75 | + | SOURCED_ZNN_MAX_DATA_LENGTH = 16_384 # dev:vm/constants/plasma.go:67 | |
| 76 | + | SOURCED_ZNN_ACCOUNT_BLOCK_BASE_PLASMA = 21_000 # dev:vm/constants/plasma.go | |
| 77 | + | SOURCED_ZNN_AB_BYTE_DATA_PLASMA = 68 # dev:vm/constants/plasma.go (DynamicPlasmaSpork) | |
| 78 | + | SOURCED_ZNN_EMBEDDED_SIMPLE_TIER = 52_500 # 2.5 * 21,000 | |
| 79 | + | SOURCED_ZNN_EMBEDDED_HEAVY_SPV_TIER = 73_500 # 3.5 * 21,000 | |
| 80 | + | SOURCED_ZNN_PLASMA_PER_QSR = 2_100 # 1 QSR = 1 fusion unit = 2,100 Plasma @ price 1,000 | |
| 81 | + | SOURCED_ZNN_POW_DIFF_PER_PLASMA = 1_500 # dev:vm/constants/plasma.go | |
| 82 | + | SOURCED_ZNN_MIN_RESOURCE_PRICE = 1_000 # dev:dp/dp.go | |
| 83 | + | SOURCED_ZNN_DP_DEFAULT_MAX_BASE_PLASMA = 4_200_000 # dev:vm/embedded/definition/plasma.go:97 | |
| 84 | + | SOURCED_ZNN_DP_UPPER_MAX_BASE_PLASMA = 2_100_000_000 # dev:vm/embedded/definition/plasma.go:63 | |
| 85 | + | SOURCED_ZNN_DP_LOWER_MAX_BASE_PLASMA = 210_000 # dev:vm/embedded/definition/plasma.go:66 | |
| 86 | + | SOURCED_ZNN_OBSERVED_MOMENTUM_SECS = 11.4 # dev:vm/embedded/definition/spork.go (11.35-11.46s) | |
| 87 | + | SOURCED_ZNN_CHAIN_BRIDGE_ROLLBACK = 30 # dev:protocol/chain_bridge.go:293 | |
| 88 | + | SOURCED_ZNN_MAX_MOMENTUM_CONTENT_BYTES = 8 * 1024 * 1024 # dev:verifier/momentum.go:93 (8 MiB) | |
| 89 | + | SOURCED_ZNN_PROTOCOL_MAX_MSG_SIZE = 10 * 1024 * 1024 # dev:protocol/protocol.go (10 MiB) | |
| 90 | + | SOURCED_ZNN_SOFT_RESPONSE_LIMIT = 2 * 1024 * 1024 # dev:protocol/protocol.go (2 MiB) | |
| 91 | + | SOURCED_ZNN_MAX_DETAILED_MOMENTUM_WIRE = ( | |
| 92 | + | SOURCED_ZNN_PROTOCOL_MAX_MSG_SIZE - SOURCED_ZNN_SOFT_RESPONSE_LIMIT - 4096 | |
| 93 | + | ) # 8,384,512 B (dev:protocol/protocol.go:70) | |
| 94 | + | SOURCED_ZNN_MIN_ACCOUNT_BLOCK_WIRE_LOW = 300 | |
| 95 | + | SOURCED_ZNN_MIN_ACCOUNT_BLOCK_WIRE_HIGH = 350 | |
| 96 | + | ||
| 97 | + | # ============================================================================== | |
| 98 | + | # POLICY PARAMETERS (Stage 0, Stage 1A BitVMX v3.1.0-rfc, Stage 1B clArk) | |
| 99 | + | # ============================================================================== | |
| 100 | + | POLICY_PINNED_MAX_BASE_PLASMA_FLOOR = 2_100_000 # Pinned >= 2.1M Plasma/Momentum | |
| 101 | + | POLICY_PINNED_MAX_PRICE_CHANGE_PCT = 25 # MaxPriceChangePercent <= 25% | |
| 102 | + | POLICY_PINNED_MIN_TARGET_SHARE_PCT = 25 # Fused/Pow targets >= 25% of 2.1M floor (525,000) | |
| 103 | + | POLICY_PINNED_MIN_PRICE_DENOM = 8 # PriceChangeDenominator >= 8 (spec/05 §2.2) | |
| 104 | + | POLICY_STAGE0_MIN_STRIPPED_TX_BYTES = 65 # Rejects <= 64 B CVE-2017-12842 leaves (R8-M06) | |
| 105 | + | POLICY_STAGE0_MAX_STRIPPED_TX_BYTES = 6_144 # Stage 0 SPV Event Oracle tx cap | |
| 106 | + | POLICY_STAGE0_MAX_STORAGE_OPS = 24 # Per-call L1 storage op ceiling | |
| 107 | + | ||
| 108 | + | # Stage 0 Erlang-Hardened PTLC / LN non-custodial swap parameters (R8-H07) | |
| 109 | + | POLICY_PTLC_BTC_CSV_BLOCKS = 72 # Automated high-fee RBF refund watchtower fires at h_conf + 72 | |
| 110 | + | POLICY_PTLC_ZNN_DURATION_SECS = 172_800 # >= 48.0 hours (P(T_72 > 48h | 2.3x) < 1e-6!) | |
| 111 | + | POLICY_LN_DELTA_SAFETY_BLOCKS = 36 | |
| 112 | + | POLICY_LN_OUTBOUND_DELTA_SAFETY_SECS = 86_400 # >= 24.0 hours (P(T_36 > 24h | 2.3x) < 2e-4!) | |
| 113 | + | ||
| 114 | + | # Stage 1A Right-Sized BitVMX (n=8) + Sovereign ZK Rollup parameters | |
| 115 | + | POLICY_BITVMX_N_BRANCH = 8 # n=8 (3 bits/round -> 7 intermediate hashes) | |
| 116 | + | POLICY_BITVMX_SEARCH_ROUNDS = 9 # 8^9 = 2^27 = 134,217,728 RV32IM wrapped-SNARK verifier ops | |
| 117 | + | POLICY_BITVMX_M_MIN = 3 # Minimal competitive operator count | |
| 118 | + | POLICY_BITVMX_M_MAX = 5 # Pilot operator count | |
| 119 | + | POLICY_BITVMX_L_LANES = 1 # Lanes per operator | |
| 120 | + | POLICY_BITVMX_N_VERIFIERS = 7 # Pre-committed online verifiers | |
| 121 | + | POLICY_BITVMX_R_ROUNDS = 64 # Pre-signed rounds per lane | |
| 122 | + | POLICY_STAGE2_TOTAL_LANES = 40 # Stage 2 scaled lane count (40 * 64 = 2,560 leaves) | |
| 123 | + | ||
| 124 | + | POLICY_VAULT_TIERS_SATS = (50_000_000, 25_000_000, 25_000_000) # {0.50, 0.25, 0.25} BTC per 1.0 BTC deposit | |
| 125 | + | POLICY_VAULT_ALT_SPLIT_SATS = (50_000_000, 50_000_000) # Optional {0.50, 0.50} split comparison | |
| 126 | + | POLICY_MAX_VAULT_DENOM_SATS = 50_000_000 # 0.50 BTC ceiling per vault UTXO | |
| 127 | + | POLICY_MIN_EXIT_SATS = 100_000 # 0.001 BTC normative dust floor (R8-M05) | |
| 128 | + | POLICY_NEW_LEAF_DEPOSIT_SATS = 500 # Refundable new-SMT-leaf deposit (R8-M01) | |
| 129 | + | POLICY_MAX_NEW_LEAVES_PER_EPOCH = 1_000 # <= 1,000 new SMT leaves per 6-block epoch (R8-M01) | |
| 130 | + | ||
| 131 | + | # Stage 1A Hard-Partitioned Per-Lane Bond & Native-L1 Verifier Economics (R8-H01, R8-H02, R8-N05) | |
| 132 | + | POLICY_BOND_BTC_SATS = 200_000_000 # 2.00 BTC L1 Stake_r bond | |
| 133 | + | POLICY_B_ZBTC_CUSTODY_SATS = 50_000_000 # 0.50 BTC maxVaultDenom Lamport restitution | |
| 134 | + | POLICY_B_ZBTC_EQUIV_BOUNTY_SATS = 5_000_000 # 0.05 BTC Lamport equivocation bounty | |
| 135 | + | POLICY_B_CUSTODY_TOTAL_SATS = ( | |
| 136 | + | POLICY_B_ZBTC_CUSTODY_SATS + POLICY_B_ZBTC_EQUIV_BOUNTY_SATS | |
| 137 | + | ) # 0.55 BTC HARD-PARTITIONED B_custody (NEVER debited by grief!) | |
| 138 | + | POLICY_B_GRIEF_TOTAL_SATS = 5_000_000 # 0.05 BTC HARD-PARTITIONED B_grief (ExitSlotUTXO grief only!) | |
| 139 | + | POLICY_B_ZBTC_TOTAL_SATS = POLICY_B_CUSTODY_TOTAL_SATS + POLICY_B_GRIEF_TOTAL_SATS # 0.60 BTC total/lane | |
| 140 | + | POLICY_LANE_TOTAL_BOND_SATS = POLICY_BOND_BTC_SATS + POLICY_B_ZBTC_TOTAL_SATS # 2.60 BTC/lane | |
| 141 | + | ||
| 142 | + | POLICY_F_CHAL_SATS = 40_000_000 # 0.40 BTC verifier challenge escrow | |
| 143 | + | POLICY_VERIFIER_NATIVE_L1_PAYOUT_SATS = 15_000_000 # 0.15 BTC NATIVE L1 BTC payout per active challenger (R8-H02!) | |
| 144 | + | POLICY_MIN_L1_STAKE_BURN_SATS = ( | |
| 145 | + | POLICY_BOND_BTC_SATS - POLICY_BITVMX_N_VERIFIERS * POLICY_VERIFIER_NATIVE_L1_PAYOUT_SATS | |
| 146 | + | ) # 0.95 BTC minimum immediate OP_RETURN burn when all 7 challenge! | |
| 147 | + | POLICY_EXIT_GRIEF_SLASH_SATS = 1_000_000 # 0.01 BTC per-exit grief penalty (pro-rata capped at B_grief!) | |
| 148 | + | POLICY_DESIGN_SUSTAINED_FEE_SATVB = 500 # 500 sat/vB primary sustained design envelope | |
| 149 | + | POLICY_STRESS_SUSTAINED_FEE_SATVB = 750 # 750 sat/vB stress-test verifier envelope | |
| 150 | + | POLICY_VERIFIER_LOCKUP_COST_SATS = 285_000 # 0.00285 BTC conservative capital lockup cost (R8-H02) | |
| 151 | + | POLICY_CRISIS_ZBTC_DISCOUNT = 0.30 # 30% crisis zBTC discount stress test (0% impact on native L1!) | |
| 152 | + | ||
| 153 | + | # Stage 1A Operational Reserve Accounting (R8-M09) | |
| 154 | + | POLICY_OP_RESERVE_VERIFIER_CPFP_PER_V_BTC = 0.10 # 0.10 BTC * 7 = 0.70 BTC verifier CPFP reserve | |
| 155 | + | POLICY_OP_RESERVE_DA_BATCHER_BTC = 0.50 # 0.50 BTC DA batcher L1 fee float | |
| 156 | + | POLICY_OP_RESERVE_TOPUP_PER_OP_BTC = 0.25 # 0.25 * M BTC operator top-up/CPFP reserve | |
| 157 | + | ||
| 158 | + | # Stage 1A Widened Simultaneous-Challenge BitVMX Timelocks (T_step = 72 blks = 12h, R8-H04) | |
| 159 | + | POLICY_T_CHAL_WINDOW = 144 # Simultaneous [0, 144] challenge window (24h) | |
| 160 | + | POLICY_T_STEP = 72 # 12h per bisection step (widened from 48!) | |
| 161 | + | POLICY_T_TAKE = 1_728 # 12.0d (> max_dispute_end = 1,584; +144 blk margin!) | |
| 162 | + | POLICY_T_COOLDOWN = 1_872 # 13.0d (1,728 + 144-blk Lamport equivocation slash window) | |
| 163 | + | POLICY_T_RETIRE = 2_016 # 14.0d Stake retirement CSV | |
| 164 | + | POLICY_T_EXIT_CANCEL = 288 # 48h user unilateral EXIT_CANCEL leaf (restores zBTC only) | |
| 165 | + | POLICY_K_MIN_FLOOR = 18 # Hard minimum K >= 18 blocks (R8-H03) | |
| 166 | + | ||
| 167 | + | # Stage 1A Capital & TVL Profiles (Cap_TVL_total = Cap_user + M * B_zbtc) | |
| 168 | + | POLICY_STAGE1A_PROFILES = { | |
| 169 | + | "M=3 (<=10 user / 11.8 tot)": {"M": 3, "cap_user_btc": 10.0, "cap_total_btc": 11.80, "float_btc": 2.20, "K_2024": 18}, | |
| 170 | + | "M=5 (<=15 user / 18.0 tot)": {"M": 5, "cap_user_btc": 15.0, "cap_total_btc": 18.00, "float_btc": 3.00, "K_2024": 18}, | |
| 171 | + | } | |
| 172 | + | # Tiers keyed by Cap_user -> Cap_TVL_total (incl. M * 0.60 BTC B_zbtc: M=3,5,20,40) | |
| 173 | + | POLICY_TVL_TIERS_TOTAL_BTC = { | |
| 174 | + | 10: 11.80, | |
| 175 | + | 15: 18.00, | |
| 176 | + | 50: 62.00, | |
| 177 | + | 200: 224.00, | |
| 178 | + | } | |
| 179 | + | POLICY_CONFIGURED_K_BY_ERA = { | |
| 180 | + | "2024-2028": {10: 18, 15: 18, 50: 42, 200: 144}, | |
| 181 | + | "2028-2032": {10: 18, 15: 24, 50: 80, 200: 288}, | |
| 182 | + | "2032-2036": {10: 32, 15: 48, 50: 160, 200: 576}, | |
| 183 | + | } | |
| 184 | + | ||
| 185 | + | # ============================================================================== | |
| 186 | + | # PRE-MAINNET TARGETS (BitVMX-CPU / Rollup / BitVM2 / clArk — Signet-Gated) | |
| 187 | + | # ============================================================================== | |
| 188 | + | PRE_MAINNET_TARGET_ROLLUP_TX_DATA_BYTES = 110 # Signed rollup transfer in AccountBlock.Data | |
| 189 | + | PRE_MAINNET_TARGET_DEPOSIT_CERTBLOB_BYTES = 104 # Acyclic OP_DROP certBlob <= 520 B | |
| 190 | + | PRE_MAINNET_TARGET_WOTS_DIGIT_WU = 95.5 # Per base-16 W-OTS digit weight (WU) | |
| 191 | + | PRE_MAINNET_TARGET_BISECTION_OVERHEAD_VB = 250.0 # Per prover bisection tx non-WOTS overhead (vB) | |
| 192 | + | PRE_MAINNET_TARGET_START_TX_VB = 3_000.0 # Prover StartTx vBytes | |
| 193 | + | PRE_MAINNET_TARGET_FINAL_TRACE_TX_VB = 5_000.0 # Prover FinalTraceTx vBytes | |
| 194 | + | PRE_MAINNET_TARGET_CHALLENGE_TX_VB = 350.0 # Verifier ChallengeTx vBytes | |
| 195 | + | PRE_MAINNET_TARGET_VERIFIER_CHOICE_VB = 350.0 # Verifier 3-bit interval choice tx vBytes | |
| 196 | + | PRE_MAINNET_TARGET_EXECUTE_OPCODE_VB = 8_000.0 # Verifier final 1-opcode disprove tx vBytes | |
| 197 | + | PRE_MAINNET_TARGET_PROVER_BASE_CAP_VB = 75_000 # Conservative prover base dispute cap (vB) | |
| 198 | + | PRE_MAINNET_TARGET_VERIFIER_BASE_CAP_VB = 15_000 # Conservative verifier base dispute cap (vB) | |
| 199 | + | PRE_MAINNET_TARGET_CPFP_COUNT_PER_SIDE = 10 # 10 P2A CPFP children per side (10 * 153 = 1,530 vB) | |
| 200 | + | PRE_MAINNET_TARGET_BITVM2_LANE_BOND_BTC_LOW = 13.30 | |
| 201 | + | PRE_MAINNET_TARGET_BITVM2_LANE_BOND_BTC_HIGH = 18.175 | |
| 202 | + | PRE_MAINNET_TARGET_CLARK_ACTIVE_LIQ_BTC = (2.0, 5.0) | |
| 203 | + | PRE_MAINNET_TARGET_CLARK_VTXO_COUNTS = (64, 128, 256, 512, 1024) | |
| 204 | + | ||
| 205 | + | ||
| 206 | + | # ============================================================================== | |
| 207 | + | # PURE PYTHON STDLIB MATH, CRYPTO & INVARIANT HELPERS | |
| 208 | + | # ============================================================================== | |
| 209 | + | def ceil_div(a: int, b: int) -> int: | |
| 210 | + | return (a + b - 1) // b | |
| 211 | + | ||
| 212 | + | ||
| 213 | + | def compact_size_len(n: int) -> int: | |
| 214 | + | if n < 253: | |
| 215 | + | return 1 | |
| 216 | + | if n <= 0xFFFF: | |
| 217 | + | return 3 | |
| 218 | + | if n <= 0xFFFFFFFF: | |
| 219 | + | return 5 | |
| 220 | + | return 9 | |
| 221 | + | ||
| 222 | + | ||
| 223 | + | def erlang_survival_prob(k_blocks: int, duration_secs: float, mean_block_secs: float) -> float: | |
| 224 | + | """ | |
| 225 | + | Exact Erlang(shape=k, rate=lambda) survival probability P(T_k > duration_secs) | |
| 226 | + | using pure Python stdlib (zero scipy dependency!): | |
| 227 | + | P(T_k > t) = P(Poisson(lambda * t) <= k - 1) = sum_{j=0}^{k-1} exp(-mu) * mu^j / j! | |
| 228 | + | Computed in log-space per term for full numerical stability. | |
| 229 | + | """ | |
| 230 | + | mu = duration_secs / mean_block_secs | |
| 231 | + | if mu <= 0.0: | |
| 232 | + | return 1.0 | |
| 233 | + | log_mu = math.log(mu) | |
| 234 | + | total = 0.0 | |
| 235 | + | for j in range(k_blocks): | |
| 236 | + | log_term = -mu + j * log_mu - math.lgamma(j + 1) | |
| 237 | + | total += math.exp(log_term) | |
| 238 | + | return min(1.0, max(0.0, total)) | |
| 239 | + | ||
| 240 | + | ||
| 241 | + | def erlang_quantile_hours(k_blocks: int, q: float, mean_block_secs: float) -> float: | |
| 242 | + | """Binary search exact Erlang quantile in hours (P(T_k <= t) = q).""" | |
| 243 | + | lo = 0.0 | |
| 244 | + | hi = k_blocks * mean_block_secs * 5.0 | |
| 245 | + | for _ in range(80): | |
| 246 | + | mid = 0.5 * (lo + hi) | |
| 247 | + | cdf = 1.0 - erlang_survival_prob(k_blocks, mid, mean_block_secs) | |
| 248 | + | if cdf < q: | |
| 249 | + | lo = mid | |
| 250 | + | else: | |
| 251 | + | hi = mid | |
| 252 | + | return (0.5 * (lo + hi)) / 3600.0 | |
| 253 | + | ||
| 254 | + | ||
| 255 | + | def abi_embedded_plasma(tier: int, abi_len: int) -> int: | |
| 256 | + | assert abi_len <= SOURCED_ZNN_MAX_DATA_LENGTH, f"ABI len {abi_len} exceeds 16 KiB" | |
| 257 | + | return tier + max(0, abi_len - 4) * SOURCED_ZNN_AB_BYTE_DATA_PLASMA | |
| 258 | + | ||
| 259 | + | ||
| 260 | + | # FIPS 180-4 SHA-256 single-block compression (for real coinbase midstate verification) | |
| 261 | + | _SHA256_IV = ( | |
| 262 | + | 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, | |
| 263 | + | 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19, | |
| 264 | + | ) | |
| 265 | + | _SHA256_K = ( | |
| 266 | + | 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, | |
| 267 | + | 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, | |
| 268 | + | 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC, 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, | |
| 269 | + | 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967, | |
| 270 | + | 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, | |
| 271 | + | 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, | |
| 272 | + | 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, | |
| 273 | + | 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2, | |
| 274 | + | ) | |
| 275 | + | ||
| 276 | + | ||
| 277 | + | def _rotr32(x: int, n: int) -> int: | |
| 278 | + | return ((x >> n) | ((x << (32 - n)) & 0xFFFFFFFF)) & 0xFFFFFFFF | |
| 279 | + | ||
| 280 | + | ||
| 281 | + | def sha256_compress(state: tuple[int, ...], block64: bytes) -> tuple[int, ...]: | |
| 282 | + | assert len(block64) == 64 | |
| 283 | + | w = list(struct.unpack(">16I", block64)) | |
| 284 | + | for i in range(16, 64): | |
| 285 | + | s0 = _rotr32(w[i - 15], 7) ^ _rotr32(w[i - 15], 18) ^ (w[i - 15] >> 3) | |
| 286 | + | s1 = _rotr32(w[i - 2], 17) ^ _rotr32(w[i - 2], 19) ^ (w[i - 2] >> 10) | |
| 287 | + | w.append((w[i - 16] + s0 + w[i - 7] + s1) & 0xFFFFFFFF) | |
| 288 | + | a, b, c, d, e, f, g, h = state | |
| 289 | + | for i in range(64): | |
| 290 | + | S1 = _rotr32(e, 6) ^ _rotr32(e, 11) ^ _rotr32(e, 25) | |
| 291 | + | ch = (e & f) ^ ((~e & 0xFFFFFFFF) & g) | |
| 292 | + | t1 = (h + S1 + ch + _SHA256_K[i] + w[i]) & 0xFFFFFFFF | |
| 293 | + | S0 = _rotr32(a, 2) ^ _rotr32(a, 13) ^ _rotr32(a, 22) | |
| 294 | + | maj = (a & b) ^ (a & c) ^ (b & c) | |
| 295 | + | t2 = (S0 + maj) & 0xFFFFFFFF | |
| 296 | + | h, g, f, e, d, c, b, a = g, f, e, (d + t1) & 0xFFFFFFFF, c, b, a, (t1 + t2) & 0xFFFFFFFF | |
| 297 | + | return tuple((s + x) & 0xFFFFFFFF for s, x in zip(state, (a, b, c, d, e, f, g, h))) | |
| 298 | + | ||
| 299 | + | ||
| 300 | + | def complete_midstate_double_sha256(midstate_bytes: bytes, tail: bytes, total_len: int) -> tuple[bytes, int]: | |
| 301 | + | assert len(midstate_bytes) == 32 | |
| 302 | + | assert total_len >= POLICY_STAGE0_MIN_STRIPPED_TX_BYTES, ( | |
| 303 | + | "CVE-2017-12842: totalCoinbaseBytes must be >= 65 (64-byte leaf forbidden)" | |
| 304 | + | ) | |
| 305 | + | rem = total_len % 64 | |
| 306 | + | assert len(tail) == rem and len(tail) < 64 | |
| 307 | + | padded = bytearray(tail) | |
| 308 | + | padded.append(0x80) | |
| 309 | + | while len(padded) % 64 != 56: | |
| 310 | + | padded.append(0x00) | |
| 311 | + | padded.extend(struct.pack(">Q", total_len * 8)) | |
| 312 | + | blocks = len(padded) // 64 | |
| 313 | + | assert blocks in (1, 2) | |
| 314 | + | state = struct.unpack(">8I", midstate_bytes) | |
| 315 | + | for idx in range(blocks): | |
| 316 | + | state = sha256_compress(state, bytes(padded[idx * 64 : (idx + 1) * 64])) | |
| 317 | + | first_round = struct.pack(">8I", *state) | |
| 318 | + | return hashlib.sha256(first_round).digest(), blocks | |
| 319 | + | ||
| 320 | + | ||
| 321 | + | def compute_acyclic_vault_id( | |
| 322 | + | funding_txid: bytes, | |
| 323 | + | funding_vout: int, | |
| 324 | + | vault_vout: int, | |
| 325 | + | amount_sats: int, | |
| 326 | + | op_bitmask: int, | |
| 327 | + | ) -> bytes: | |
| 328 | + | """Normative R8-C01 acyclic vault_id bound strictly to already-confirmed U_dep_wallet.""" | |
| 329 | + | assert len(funding_txid) == 32 | |
| 330 | + | payload = ( | |
| 331 | + | b"zbtc:vault-id:v1" | |
| 332 | + | + funding_txid | |
| 333 | + | + struct.pack(">IIQQ", funding_vout, vault_vout, amount_sats, op_bitmask) | |
| 334 | + | ) | |
| 335 | + | return hashlib.sha256(payload).digest() | |
| 336 | + | ||
| 337 | + | ||
| 338 | + | def check_halls_marriage( | |
| 339 | + | vault_masks: list[int], | |
| 340 | + | usable_rounds_by_op: list[int], | |
| 341 | + | headroom_factor: float = 1.0, | |
| 342 | + | ) -> tuple[bool, int, int, int]: | |
| 343 | + | """ | |
| 344 | + | Exact 2^M Hall's Marriage Theorem verification (R8-C04): | |
| 345 | + | For every non-empty subset T of {0..M-1}: | |
| 346 | + | |{v in V_live : E(v) <= T}| <= floor(headroom_factor * sum_{i in T} r_i^usable) | |
| 347 | + | Returns (passes, failing_subset_mask, demand, supply). | |
| 348 | + | """ | |
| 349 | + | m = len(usable_rounds_by_op) | |
| 350 | + | assert 1 <= m <= 12 | |
| 351 | + | for mask in range(1, 1 << m): | |
| 352 | + | demand = sum(1 for vm in vault_masks if vm != 0 and (vm & ~mask) == 0) | |
| 353 | + | supply_raw = sum(usable_rounds_by_op[i] for i in range(m) if (mask >> i) & 1) | |
| 354 | + | supply = int(math.floor(headroom_factor * supply_raw)) | |
| 355 | + | if demand > supply: | |
| 356 | + | return False, mask, demand, supply | |
| 357 | + | return True, 0, 0, 0 | |
| 358 | + | ||
| 359 | + | ||
| 360 | + | def cyclic_exit_priority(exit_id: bytes, m_active: int) -> list[int]: | |
| 361 | + | """Normative R8-M03 collision-free cyclic priority k_r = (H(exitId) + r) mod M_active.""" | |
| 362 | + | assert m_active >= 1 | |
| 363 | + | h0 = int.from_bytes(hashlib.sha256(exit_id).digest()[:8], "big") | |
| 364 | + | return [(h0 + r) % m_active for r in range(m_active)] | |
| 365 | + | ||
| 366 | + | ||
| 367 | + | def dp_next_price( | |
| 368 | + | current_price: int, | |
| 369 | + | used_plasma: int, | |
| 370 | + | target_plasma: int, | |
| 371 | + | max_change_pct: int, | |
| 372 | + | denom: int, | |
| 373 | + | ) -> int: | |
| 374 | + | delta = used_plasma - target_plasma | |
| 375 | + | num = delta * current_price | |
| 376 | + | if num >= 0: | |
| 377 | + | change = (num // target_plasma) // denom | |
| 378 | + | else: | |
| 379 | + | change = -((-num // target_plasma) // denom) | |
| 380 | + | nxt = current_price + change | |
| 381 | + | max_nxt = (current_price * (100 + max_change_pct)) // 100 | |
| 382 | + | min_nxt = (current_price * (100 - max_change_pct)) // 100 | |
| 383 | + | if nxt > max_nxt: | |
| 384 | + | nxt = max_nxt | |
| 385 | + | if nxt < min_nxt: | |
| 386 | + | nxt = min_nxt | |
| 387 | + | if nxt < SOURCED_ZNN_MIN_RESOURCE_PRICE: | |
| 388 | + | nxt = SOURCED_ZNN_MIN_RESOURCE_PRICE | |
| 389 | + | return nxt | |
| 390 | + | ||
| 391 | + | ||
| 392 | + | # ============================================================================== | |
| 393 | + | # REAL, NON-NO-OP 2,000-STEP STAGE 1A SOLVENCY & ADVERSARIAL SIMULATION (v3.1.0-rfc) | |
| 394 | + | # ============================================================================== | |
| 395 | + | def run_stage1a_solvency_sim(seed: int = 20261128, steps: int = 2_000) -> dict[str, int]: | |
| 396 | + | """ | |
| 397 | + | Adversarial state-machine simulation of Stage 1A BitVMX (n=8, M=5, N=7) v3.1.0-rfc: | |
| 398 | + | - Explicit AssignedObligations (A) namespace separating fifo_assign & take_confirmed across T_take (R8-C02!) | |
| 399 | + | - Exact conservation: V_unassigned + V_assigned == C + L + E + R + A + B at EVERY step! | |
| 400 | + | - Denomination-matched AdmissionTicketUTXO Cap_TVL L1 mutual exclusion + deposit race test (R8-C03!) | |
| 401 | + | - Exact 2^M Hall's Marriage verification on deposit admission & operator slash (R8-C04!) | |
| 402 | + | - Hard-partitioned B_custody (0.55 BTC) vs B_grief (0.05 BTC) + k=20 single-block ExitSlotUTXO grief burst | |
| 403 | + | proving ZERO B_custody overflow & ZERO verifier payout impact (R8-H01, R8-N05!) | |
| 404 | + | - Signed TransferCredit residual consolidation for < 0.25 BTC credits (R8-M04!) | |
| 405 | + | - Explicit 0x07 RELEASE_ASSIGNMENT + Leaf 2M EXIT_CANCEL + dual-input Disprove slash + cross-operator Lamport slash | |
| 406 | + | - Genuine Bitcoin reorgs (popping 1..K-1 unconfirmed blocks & discarding orphaned events!) | |
| 407 | + | """ | |
| 408 | + | rng = random.Random(seed) | |
| 409 | + | K = POLICY_CONFIGURED_K_BY_ERA["2024-2028"][15] # 18 blocks | |
| 410 | + | cap_user_sats = int(15.0 * SAT) | |
| 411 | + | cap_total_sats = int(18.0 * SAT) # 15.0 user + 3.0 operator B_zbtc (plus operator free_zbtc buffer) | |
| 412 | + | all_ops_mask = (1 << POLICY_BITVMX_M_MAX) - 1 # 0b11111 | |
| 413 | + | ||
| 414 | + | # Denomination-matched AdmissionTicketUTXO pool (R8-C03): | |
| 415 | + | # Genesis tickets strictly cap total live vaults <= 20.0 BTC (15 user + 5 operator initial 1.0 BTC vaults) | |
| 416 | + | ticket_pool = {50_000_000: 20, 25_000_000: 40} # 20*0.50 + 40*0.25 = 20.0 BTC exact L1 consensus cap! | |
| 417 | + | ||
| 418 | + | # Canonical K-deep rollup state | |
| 419 | + | users: dict[str, int] = { | |
| 420 | + | "alice": 0, "bob": 0, "mike": 0, "carol": 0, "dave": 0, | |
| 421 | + | "insurance_pool": 0, "challenger_bounty_pool": 0, | |
| 422 | + | } | |
| 423 | + | rollup_locks: dict[int, int] = {} # L namespace | |
| 424 | + | unassigned_vaults: dict[int, dict] = {} # vault_id -> {"sats", "mask"} | |
| 425 | + | assigned_vaults: dict[int, dict] = {} # vault_id -> {"sats", "mask", "op_id", "assigned_h"} | |
| 426 | + | assigned_obligations: dict[int, int] = {} # A namespace: vault_id -> sats | |
| 427 | + | next_vault_id = 1 | |
| 428 | + | ||
| 429 | + | operators: dict[int, dict] = {} | |
| 430 | + | for op_id in range(POLICY_BITVMX_M_MAX): | |
| 431 | + | # Each operator deposits 1.00 BTC (consuming 2 x Ticket_050) -> 0.55 B_custody + 0.05 B_grief + 0.40 free_zbtc | |
| 432 | + | for _ in range(2): | |
| 433 | + | assert ticket_pool[50_000_000] >= 1 | |
| 434 | + | ticket_pool[50_000_000] -= 1 | |
| 435 | + | unassigned_vaults[next_vault_id] = {"sats": 50_000_000, "mask": all_ops_mask} | |
| 436 | + | next_vault_id += 1 | |
| 437 | + | operators[op_id] = { | |
| 438 | + | "b_custody": POLICY_B_CUSTODY_TOTAL_SATS, # 0.55 BTC hard-partitioned | |
| 439 | + | "b_grief": POLICY_B_GRIEF_TOTAL_SATS, # 0.05 BTC hard-partitioned | |
| 440 | + | "free_zbtc": 40_000_000, | |
| 441 | + | "credit": 0, | |
| 442 | + | "rounds_left": POLICY_BITVMX_R_ROUNDS, | |
| 443 | + | "suspended": False, | |
| 444 | + | } | |
| 445 | + | ||
| 446 | + | pending_exits: dict[int, dict] = {} | |
| 447 | + | next_exit_id = 1 | |
| 448 | + | ||
| 449 | + | finalized_height = 100 | |
| 450 | + | tip_blocks: list[dict] = [] | |
| 451 | + | unconf_spent_exits: set[int] = set() | |
| 452 | + | unconf_taken_vaults: set[int] = set() | |
| 453 | + | unconf_released_vaults: set[int] = set() | |
| 454 | + | ||
| 455 | + | counts: dict[str, int] = { | |
| 456 | + | k: 0 for k in ( | |
| 457 | + | "deposit", "deposit_race_blocked_by_ticket", "transfer", "forced_exit", | |
| 458 | + | "front_paid", "front_grief", "front_grief_burst_k20", "exit_cancel", | |
| 459 | + | "fifo_assign", "take_confirmed", "release_assignment", "transfer_credit", | |
| 460 | + | "disprove_dual_slash", "lamport_equivocation_slash", "topup_op", | |
| 461 | + | "mine_block", "reorg", "reorg_blocks_reverted", "reorg_events_reverted", | |
| 462 | + | ) | |
| 463 | + | } | |
| 464 | + | ||
| 465 | + | def rebuild_unconf_locks() -> None: | |
| 466 | + | unconf_spent_exits.clear() | |
| 467 | + | unconf_taken_vaults.clear() | |
| 468 | + | unconf_released_vaults.clear() | |
| 469 | + | for blk in tip_blocks: | |
| 470 | + | for ev in blk["events"]: | |
| 471 | + | kind = ev["kind"] | |
| 472 | + | if kind in ("front_paid", "front_grief", "exit_cancel"): | |
| 473 | + | unconf_spent_exits.add(ev["exit_id"]) | |
| 474 | + | elif kind == "front_grief_burst": | |
| 475 | + | for eid in ev["exit_ids"]: | |
| 476 | + | unconf_spent_exits.add(eid) | |
| 477 | + | elif kind in ("take_confirmed", "lamport_equivocation_slash"): | |
| 478 | + | unconf_taken_vaults.add(ev["vault_id"]) | |
| 479 | + | elif kind == "release_assignment": | |
| 480 | + | unconf_released_vaults.add(ev["vault_id"]) | |
| 481 | + | ||
| 482 | + | def run_deterministic_fifo_assign(blk_height: int) -> None: | |
| 483 | + | """ | |
| 484 | + | Deterministically moves R[op] -> A[v] and V_unassigned -> V_assigned (R8-C02), | |
| 485 | + | keeping V_unassigned + V_assigned == C + L + E + R + A + B invariant across T_take! | |
| 486 | + | """ | |
| 487 | + | for oid in sorted(operators.keys()): | |
| 488 | + | op = operators[oid] | |
| 489 | + | if op["rounds_left"] <= 0: | |
| 490 | + | continue | |
| 491 | + | # Assign oldest eligible vault while credit covers it | |
| 492 | + | while True: | |
| 493 | + | eligible_vids = [ | |
| 494 | + | vid for vid in sorted(unassigned_vaults.keys()) | |
| 495 | + | if ((unassigned_vaults[vid]["mask"] >> oid) & 1) | |
| 496 | + | and op["credit"] >= unassigned_vaults[vid]["sats"] | |
| 497 | + | and op["rounds_left"] > 0 | |
| 498 | + | ] | |
| 499 | + | if not eligible_vids: | |
| 500 | + | break | |
| 501 | + | vid = eligible_vids[0] | |
| 502 | + | vinfo = unassigned_vaults.pop(vid) | |
| 503 | + | vamt = vinfo["sats"] | |
| 504 | + | op["credit"] -= vamt | |
| 505 | + | assigned_vaults[vid] = { | |
| 506 | + | "sats": vamt, | |
| 507 | + | "mask": vinfo["mask"], | |
| 508 | + | "op_id": oid, | |
| 509 | + | "assigned_h": blk_height, | |
| 510 | + | } | |
| 511 | + | assigned_obligations[vid] = vamt | |
| 512 | + | counts["fifo_assign"] += 1 | |
| 513 | + | ||
| 514 | + | def apply_finalized_event(ev: dict, blk_height: int) -> None: | |
| 515 | + | kind = ev["kind"] | |
| 516 | + | if kind == "deposit": | |
| 517 | + | # Enforce L1 AdmissionTicketUTXO mutual exclusion (R8-C03) | |
| 518 | + | needed = {50_000_000: 0, 25_000_000: 0} | |
| 519 | + | for _, vamt in ev["vaults"]: | |
| 520 | + | needed[vamt] += 1 | |
| 521 | + | if ticket_pool[50_000_000] < needed[50_000_000] or ticket_pool[25_000_000] < needed[25_000_000]: | |
| 522 | + | # Loser deposit rejected at L1 consensus before U_dep_wallet is spent! | |
| 523 | + | counts["deposit_race_blocked_by_ticket"] += 1 | |
| 524 | + | return | |
| 525 | + | for denom, qty in needed.items(): | |
| 526 | + | ticket_pool[denom] -= qty | |
| 527 | + | for vid, vamt in ev["vaults"]: | |
| 528 | + | unassigned_vaults[vid] = {"sats": vamt, "mask": ev["mask"]} | |
| 529 | + | users[ev["user"]] += sum(vamt for _, vamt in ev["vaults"]) | |
| 530 | + | counts["deposit"] += 1 | |
| 531 | + | ||
| 532 | + | elif kind == "forced_exit": | |
| 533 | + | u = ev["user"] | |
| 534 | + | amt = ev["gross"] | |
| 535 | + | assert amt >= POLICY_MIN_EXIT_SATS | |
| 536 | + | if users[u] >= amt: | |
| 537 | + | users[u] -= amt | |
| 538 | + | pending_exits[ev["exit_id"]] = {"user": u, "gross": amt, "created_h": blk_height} | |
| 539 | + | counts["forced_exit"] += 1 | |
| 540 | + | ||
| 541 | + | elif kind == "front_paid": | |
| 542 | + | eid = ev["exit_id"] | |
| 543 | + | if eid in pending_exits: | |
| 544 | + | ex = pending_exits.pop(eid) | |
| 545 | + | operators[ev["op_id"]]["credit"] += ex["gross"] | |
| 546 | + | counts["front_paid"] += 1 | |
| 547 | + | run_deterministic_fifo_assign(blk_height) | |
| 548 | + | ||
| 549 | + | elif kind == "front_grief": | |
| 550 | + | eid = ev["exit_id"] | |
| 551 | + | op = operators[ev["op_id"]] | |
| 552 | + | if eid in pending_exits: | |
| 553 | + | ex = pending_exits.pop(eid) | |
| 554 | + | users[ex["user"]] += ex["gross"] | |
| 555 | + | # Hard-partitioned B_grief penalty: NEVER touches B_custody (R8-H01 / R8-N05)! | |
| 556 | + | pen = min(POLICY_EXIT_GRIEF_SLASH_SATS, op["b_grief"]) | |
| 557 | + | op["b_grief"] -= pen | |
| 558 | + | users[ex["user"]] += pen | |
| 559 | + | op["suspended"] = True | |
| 560 | + | assert op["b_custody"] == POLICY_B_CUSTODY_TOTAL_SATS or op["suspended"] | |
| 561 | + | counts["front_grief"] += 1 | |
| 562 | + | ||
| 563 | + | elif kind == "front_grief_burst": | |
| 564 | + | # Concurrent k-exit grief burst in ONE Bitcoin block (R8-H01 / R8-N05 proof!) | |
| 565 | + | op = operators[ev["op_id"]] | |
| 566 | + | b_custody_before = op["b_custody"] | |
| 567 | + | live_eids = [eid for eid in ev["exit_ids"] if eid in pending_exits] | |
| 568 | + | if live_eids: | |
| 569 | + | per_victim = min(POLICY_EXIT_GRIEF_SLASH_SATS, op["b_grief"] // len(live_eids)) | |
| 570 | + | for eid in live_eids: | |
| 571 | + | ex = pending_exits.pop(eid) | |
| 572 | + | users[ex["user"]] += ex["gross"] + per_victim | |
| 573 | + | op["b_grief"] -= per_victim | |
| 574 | + | op["suspended"] = True | |
| 575 | + | assert op["b_custody"] == b_custody_before, "B_custody touched by ExitSlotUTXO grief burst!" | |
| 576 | + | assert op["b_grief"] >= 0 | |
| 577 | + | counts["front_grief_burst_k20"] += 1 | |
| 578 | + | ||
| 579 | + | elif kind == "exit_cancel": | |
| 580 | + | eid = ev["exit_id"] | |
| 581 | + | if eid in pending_exits and blk_height >= pending_exits[eid]["created_h"] + POLICY_T_EXIT_CANCEL: | |
| 582 | + | ex = pending_exits.pop(eid) | |
| 583 | + | users[ex["user"]] += ex["gross"] | |
| 584 | + | counts["exit_cancel"] += 1 | |
| 585 | + | ||
| 586 | + | elif kind == "take_confirmed": | |
| 587 | + | # Separate from fifo_assign! Confirms after T_take gap, retiring V_assigned & A AND recycling ticket! | |
| 588 | + | vid = ev["vault_id"] | |
| 589 | + | if vid in assigned_vaults and assigned_vaults[vid]["op_id"] == ev["op_id"]: | |
| 590 | + | vinfo = assigned_vaults.pop(vid) | |
| 591 | + | vamt = assigned_obligations.pop(vid) | |
| 592 | + | assert vamt == vinfo["sats"] | |
| 593 | + | ticket_pool[vamt] += 1 # Recycle denomination-matched AdmissionTicketUTXO! | |
| 594 | + | operators[ev["op_id"]]["rounds_left"] = max(0, operators[ev["op_id"]]["rounds_left"] - 1) | |
| 595 | + | counts["take_confirmed"] += 1 | |
| 596 | + | ||
| 597 | + | elif kind == "release_assignment": | |
| 598 | + | # 0x07 RELEASE_ASSIGNMENT: V_assigned -> V_unassigned, A[v] -> R[op] | |
| 599 | + | vid = ev["vault_id"] | |
| 600 | + | if vid in assigned_vaults and assigned_vaults[vid]["op_id"] == ev["op_id"]: | |
| 601 | + | vinfo = assigned_vaults.pop(vid) | |
| 602 | + | vamt = assigned_obligations.pop(vid) | |
| 603 | + | unassigned_vaults[vid] = {"sats": vamt, "mask": vinfo["mask"]} | |
| 604 | + | operators[ev["op_id"]]["credit"] += vamt | |
| 605 | + | counts["release_assignment"] += 1 | |
| 606 | + | ||
| 607 | + | elif kind == "transfer_credit": | |
| 608 | + | src, dst, amt = ev["from_op"], ev["to_op"], ev["amount"] | |
| 609 | + | if operators[src]["credit"] >= amt: | |
| 610 | + | operators[src]["credit"] -= amt | |
| 611 | + | operators[dst]["credit"] += amt | |
| 612 | + | counts["transfer_credit"] += 1 | |
| 613 | + | run_deterministic_fifo_assign(blk_height) | |
| 614 | + | ||
| 615 | + | elif kind == "disprove_dual_slash": | |
| 616 | + | # Dual-input Disprove spends Stake_r + VaultConnector_r -> 0 BTC leaves vault! | |
| 617 | + | # Native L1 verifier bounties paid from Stake_r; L2 B_custody slashed to insurance_pool. | |
| 618 | + | op = operators[ev["op_id"]] | |
| 619 | + | if op["b_custody"] >= POLICY_B_CUSTODY_TOTAL_SATS: | |
| 620 | + | # If any vault was assigned to this op's challenged round, return V_assigned -> V_unassigned & A -> R | |
| 621 | + | for vid in [v for v, info in assigned_vaults.items() if info["op_id"] == ev["op_id"]][:1]: | |
| 622 | + | vinfo = assigned_vaults.pop(vid) | |
| 623 | + | vamt = assigned_obligations.pop(vid) | |
| 624 | + | unassigned_vaults[vid] = {"sats": vamt, "mask": vinfo["mask"]} | |
| 625 | + | op["credit"] += vamt | |
| 626 | + | op["b_custody"] -= POLICY_B_CUSTODY_TOTAL_SATS | |
| 627 | + | users["insurance_pool"] += POLICY_B_CUSTODY_TOTAL_SATS | |
| 628 | + | op["suspended"] = True | |
| 629 | + | counts["disprove_dual_slash"] += 1 | |
| 630 | + | ||
| 631 | + | elif kind == "lamport_equivocation_slash": | |
| 632 | + | # Rogue operator stole vault v (either unassigned OR assigned to innocent O_k!) | |
| 633 | + | vid = ev["vault_id"] | |
| 634 | + | op = operators[ev["op_id"]] | |
| 635 | + | if vid in unassigned_vaults: | |
| 636 | + | vamt = unassigned_vaults[vid]["sats"] | |
| 637 | + | if op["b_custody"] >= vamt + POLICY_B_ZBTC_EQUIV_BOUNTY_SATS: | |
| 638 | + | unassigned_vaults.pop(vid) | |
| 639 | + | ticket_pool[vamt] += 1 | |
| 640 | + | op["b_custody"] -= (vamt + POLICY_B_ZBTC_EQUIV_BOUNTY_SATS) | |
| 641 | + | users["challenger_bounty_pool"] += POLICY_B_ZBTC_EQUIV_BOUNTY_SATS | |
| 642 | + | op["suspended"] = True | |
| 643 | + | counts["lamport_equivocation_slash"] += 1 | |
| 644 | + | elif vid in assigned_vaults: | |
| 645 | + | vinfo = assigned_vaults[vid] | |
| 646 | + | vamt = vinfo["sats"] | |
| 647 | + | if op["b_custody"] >= vamt + POLICY_B_ZBTC_EQUIV_BOUNTY_SATS: | |
| 648 | + | assigned_vaults.pop(vid) | |
| 649 | + | assigned_obligations.pop(vid) | |
| 650 | + | ticket_pool[vamt] += 1 | |
| 651 | + | # Restore innocent assignee O_k 100% whole via R[O_k] += vamt! | |
| 652 | + | operators[vinfo["op_id"]]["credit"] += vamt | |
| 653 | + | op["b_custody"] -= (vamt + POLICY_B_ZBTC_EQUIV_BOUNTY_SATS) | |
| 654 | + | users["challenger_bounty_pool"] += POLICY_B_ZBTC_EQUIV_BOUNTY_SATS | |
| 655 | + | op["suspended"] = True | |
| 656 | + | counts["lamport_equivocation_slash"] += 1 | |
| 657 | + | ||
| 658 | + | def assert_solvency(label: str) -> None: | |
| 659 | + | v_unassigned = sum(v["sats"] for v in unassigned_vaults.values()) | |
| 660 | + | v_assigned = sum(v["sats"] for v in assigned_vaults.values()) | |
| 661 | + | lhs = v_unassigned + v_assigned | |
| 662 | + | ||
| 663 | + | c_total = sum(users.values()) + sum(op["free_zbtc"] for op in operators.values()) | |
| 664 | + | l_total = sum(rollup_locks.values()) | |
| 665 | + | e_total = sum(ex["gross"] for ex in pending_exits.values()) | |
| 666 | + | r_total = sum(op["credit"] for op in operators.values()) | |
| 667 | + | a_total = sum(assigned_obligations.values()) | |
| 668 | + | b_total = sum(op["b_custody"] + op["b_grief"] for op in operators.values()) | |
| 669 | + | rhs = c_total + l_total + e_total + r_total + a_total + b_total | |
| 670 | + | ||
| 671 | + | assert lhs == rhs, f"[{label}] Conservation mismatch! V={lhs} != C+L+E+R+A+B={rhs}" | |
| 672 | + | assert v_assigned == a_total, f"[{label}] V_assigned={v_assigned} != A={a_total}" | |
| 673 | + | # Ticket + live vault conservation: total minted tickets == 20*0.50 + 40*0.25 = 20.0 BTC ALWAYS! | |
| 674 | + | ticket_value = ticket_pool[50_000_000] * 50_000_000 + ticket_pool[25_000_000] * 25_000_000 | |
| 675 | + | assert lhs + ticket_value == 20 * SAT, f"[{label}] Ticket conservation broken: {lhs} + {ticket_value}" | |
| 676 | + | for oid, op in operators.items(): | |
| 677 | + | assert op["b_custody"] >= 0 and op["b_grief"] >= 0 | |
| 678 | + | if not op["suspended"]: | |
| 679 | + | assert op["b_custody"] == POLICY_B_CUSTODY_TOTAL_SATS | |
| 680 | + | assert op["b_grief"] == POLICY_B_GRIEF_TOTAL_SATS | |
| 681 | + | ||
| 682 | + | def mine_one_block(events: list[dict]) -> None: | |
| 683 | + | nonlocal finalized_height | |
| 684 | + | next_h = finalized_height + len(tip_blocks) + 1 | |
| 685 | + | tip_blocks.append({"height": next_h, "events": events}) | |
| 686 | + | counts["mine_block"] += 1 | |
| 687 | + | while len(tip_blocks) >= K: | |
| 688 | + | fin_blk = tip_blocks.pop(0) | |
| 689 | + | finalized_height = fin_blk["height"] | |
| 690 | + | for ev in fin_blk["events"]: | |
| 691 | + | apply_finalized_event(ev, finalized_height) | |
| 692 | + | rebuild_unconf_locks() | |
| 693 | + | ||
| 694 | + | def current_tip_height() -> int: | |
| 695 | + | return finalized_height + len(tip_blocks) | |
| 696 | + | ||
| 697 | + | assert_solvency("init") | |
| 698 | + | ||
| 699 | + | # ------------------------------------------------------------------ | |
| 700 | + | # 1. DETERMINISTIC BOB & MIKE TRACES WITH EXPLICIT T_take GAP (A > 0!) | |
| 701 | + | # ------------------------------------------------------------------ | |
| 702 | + | bob_vaults = [(next_vault_id + i, amt) for i, amt in enumerate(POLICY_VAULT_TIERS_SATS)] | |
| 703 | + | next_vault_id += 3 | |
| 704 | + | alice_vaults = [(next_vault_id + i, amt) for i, amt in enumerate(POLICY_VAULT_TIERS_SATS)] | |
| 705 | + | next_vault_id += 3 | |
| 706 | + | mine_one_block([ | |
| 707 | + | {"kind": "deposit", "user": "bob", "vaults": bob_vaults, "mask": all_ops_mask}, | |
| 708 | + | {"kind": "deposit", "user": "alice", "vaults": alice_vaults, "mask": all_ops_mask}, | |
| 709 | + | ]) | |
| 710 | + | for _ in range(K - 1): | |
| 711 | + | mine_one_block([]) | |
| 712 | + | assert users["bob"] == SAT and users["alice"] == SAT | |
| 713 | + | assert_solvency("after_bob_alice_deposits") | |
| 714 | + | ||
| 715 | + | # Bob spends 0.50 zBTC to Carol, exits 0.50 BTC -> FIFO assigns (A = 0.50 BTC!) -> TakeTx confirms later! | |
| 716 | + | users["bob"] -= 50_000_000 | |
| 717 | + | users["carol"] += 50_000_000 | |
| 718 | + | counts["transfer"] += 1 | |
| 719 | + | bob_eid = next_exit_id | |
| 720 | + | next_exit_id += 1 | |
| 721 | + | mine_one_block([{"kind": "forced_exit", "user": "bob", "gross": 50_000_000, "exit_id": bob_eid}]) | |
| 722 | + | for _ in range(K - 1): | |
| 723 | + | mine_one_block([]) | |
| 724 | + | mine_one_block([{"kind": "front_paid", "exit_id": bob_eid, "op_id": 0}]) | |
| 725 | + | for _ in range(K - 1): | |
| 726 | + | mine_one_block([]) | |
| 727 | + | # Verify R8-C02: during the T_take gap, A == 0.50 BTC > 0 AND V == C+L+E+R+A+B holds! | |
| 728 | + | assert sum(assigned_obligations.values()) == 50_000_000 | |
| 729 | + | assert_solvency("bob_mid_T_take_gap_A_nonzero") | |
| 730 | + | assigned_bob_vid = next(iter(assigned_vaults.keys())) | |
| 731 | + | mine_one_block([{"kind": "take_confirmed", "op_id": 0, "vault_id": assigned_bob_vid}]) | |
| 732 | + | for _ in range(K - 1): | |
| 733 | + | mine_one_block([]) | |
| 734 | + | assert sum(assigned_obligations.values()) == 0 | |
| 735 | + | assert_solvency("after_bob_0.5_take_confirmed") | |
| 736 | + | ||
| 737 | + | # Mike scenario (Alice 1 + Bob2 1 -> Mike 2 -> Mike exits 0.25 BTC) | |
| 738 | + | bob2_vaults = [(next_vault_id + i, amt) for i, amt in enumerate(POLICY_VAULT_TIERS_SATS)] | |
| 739 | + | next_vault_id += 3 | |
| 740 | + | mine_one_block([{"kind": "deposit", "user": "bob", "vaults": bob2_vaults, "mask": all_ops_mask}]) | |
| 741 | + | for _ in range(K - 1): | |
| 742 | + | mine_one_block([]) | |
| 743 | + | users["alice"] -= SAT | |
| 744 | + | users["bob"] -= SAT | |
| 745 | + | users["mike"] += 2 * SAT | |
| 746 | + | counts["transfer"] += 2 | |
| 747 | + | mike_eid = next_exit_id | |
| 748 | + | next_exit_id += 1 | |
| 749 | + | mine_one_block([{"kind": "forced_exit", "user": "mike", "gross": 25_000_000, "exit_id": mike_eid}]) | |
| 750 | + | for _ in range(K - 1): | |
| 751 | + | mine_one_block([]) | |
| 752 | + | mine_one_block([{"kind": "front_paid", "exit_id": mike_eid, "op_id": 1}]) | |
| 753 | + | for _ in range(K - 1): | |
| 754 | + | mine_one_block([]) | |
| 755 | + | assert sum(assigned_obligations.values()) == 25_000_000 | |
| 756 | + | assert_solvency("mike_mid_T_take_gap_A_nonzero") | |
| 757 | + | assigned_mike_vid = next(iter(assigned_vaults.keys())) | |
| 758 | + | mine_one_block([{"kind": "take_confirmed", "op_id": 1, "vault_id": assigned_mike_vid}]) | |
| 759 | + | for _ in range(K - 1): | |
| 760 | + | mine_one_block([]) | |
| 761 | + | assert users["mike"] == 175_000_000 and sum(assigned_obligations.values()) == 0 | |
| 762 | + | assert_solvency("after_mike_0.25_take_confirmed") | |
| 763 | + | ||
| 764 | + | # ------------------------------------------------------------------ | |
| 765 | + | # 2. DETERMINISTIC R8-H01 / R8-N05 k=20 CONCURRENT GRIEF BURST TEST | |
| 766 | + | # ------------------------------------------------------------------ | |
| 767 | + | burst_eids = [] | |
| 768 | + | for _ in range(20): | |
| 769 | + | eid = next_exit_id | |
| 770 | + | next_exit_id += 1 | |
| 771 | + | burst_eids.append(eid) | |
| 772 | + | mine_one_block([{"kind": "forced_exit", "user": "mike", "gross": 5_000_000, "exit_id": eid}]) | |
| 773 | + | for _ in range(K): | |
| 774 | + | mine_one_block([]) | |
| 775 | + | b_cust_before = operators[2]["b_custody"] | |
| 776 | + | mine_one_block([{"kind": "front_grief_burst", "op_id": 2, "exit_ids": burst_eids}]) | |
| 777 | + | for _ in range(K): | |
| 778 | + | mine_one_block([]) | |
| 779 | + | assert operators[2]["b_custody"] == b_cust_before == POLICY_B_CUSTODY_TOTAL_SATS | |
| 780 | + | assert operators[2]["b_grief"] == 0 and operators[2]["suspended"] | |
| 781 | + | assert_solvency("after_k20_grief_burst") | |
| 782 | + | ||
| 783 | + | # ------------------------------------------------------------------ | |
| 784 | + | # 3. DETERMINISTIC R8-M04 TRANSFER_CREDIT RESIDUAL CONSOLIDATION TEST | |
| 785 | + | # ------------------------------------------------------------------ | |
| 786 | + | # Give ops 3 & 4 each 0.15 BTC (< 0.25 BTC min vault), then consolidate via TransferCredit -> triggers FIFO assign! | |
| 787 | + | e_res1, e_res2 = next_exit_id, next_exit_id + 1 | |
| 788 | + | next_exit_id += 2 | |
| 789 | + | mine_one_block([ | |
| 790 | + | {"kind": "forced_exit", "user": "mike", "gross": 15_000_000, "exit_id": e_res1}, | |
| 791 | + | {"kind": "forced_exit", "user": "mike", "gross": 15_000_000, "exit_id": e_res2}, | |
| 792 | + | ]) | |
| 793 | + | for _ in range(K): | |
| 794 | + | mine_one_block([]) | |
| 795 | + | mine_one_block([ | |
| 796 | + | {"kind": "front_paid", "exit_id": e_res1, "op_id": 3}, | |
| 797 | + | {"kind": "front_paid", "exit_id": e_res2, "op_id": 4}, | |
| 798 | + | ]) | |
| 799 | + | for _ in range(K): | |
| 800 | + | mine_one_block([]) | |
| 801 | + | assert operators[3]["credit"] == 15_000_000 and operators[4]["credit"] == 15_000_000 | |
| 802 | + | mine_one_block([{"kind": "transfer_credit", "from_op": 3, "to_op": 4, "amount": 15_000_000}]) | |
| 803 | + | for _ in range(K): | |
| 804 | + | mine_one_block([]) | |
| 805 | + | assert operators[3]["credit"] == 0 and operators[4]["credit"] == 5_000_000 # 0.30 -> assigned 0.25 vault, 0.05 left! | |
| 806 | + | assert_solvency("after_transfer_credit") | |
| 807 | + | ||
| 808 | + | # ------------------------------------------------------------------ | |
| 809 | + | # 4. 2,000-STEP ADVERSARIAL RANDOMIZED SIMULATION (WITH REAL REORGS!) | |
| 810 | + | # ------------------------------------------------------------------ | |
| 811 | + | actions = [ | |
| 812 | + | "deposit", "transfer", "forced_exit", "front_paid", "front_grief", | |
| 813 | + | "exit_cancel", "take_confirmed", "release_assignment", "transfer_credit", | |
| 814 | + | "disprove_dual_slash", "lamport_equivocation_slash", "topup_op", "mine_block", "reorg", | |
| 815 | + | ] | |
| 816 | + | weights = [12, 16, 12, 12, 5, 6, 12, 5, 5, 4, 4, 10, 24, 10] | |
| 817 | + | normal_users = ["alice", "bob", "mike", "carol", "dave"] | |
| 818 | + | ||
| 819 | + | for step in range(steps): | |
| 820 | + | act = rng.choices(actions, weights=weights, k=1)[0] | |
| 821 | + | ||
| 822 | + | if act == "deposit": | |
| 823 | + | # Deliberately allow attempting deposits even near cap to exercise ticket mutual-exclusion rejection! | |
| 824 | + | u = rng.choice(normal_users) | |
| 825 | + | new_vs = [(next_vault_id + i, amt) for i, amt in enumerate(POLICY_VAULT_TIERS_SATS)] | |
| 826 | + | next_vault_id += 3 | |
| 827 | + | mine_one_block([{"kind": "deposit", "user": u, "vaults": new_vs, "mask": all_ops_mask}]) | |
| 828 | + | ||
| 829 | + | elif act == "transfer": | |
| 830 | + | rich = [u for u in normal_users if users[u] >= POLICY_MIN_EXIT_SATS] | |
| 831 | + | if rich: | |
| 832 | + | src = rng.choice(rich) | |
| 833 | + | dst = rng.choice([u for u in normal_users if u != src]) | |
| 834 | + | amt = rng.randint(POLICY_MIN_EXIT_SATS, min(users[src], 50_000_000)) | |
| 835 | + | users[src] -= amt | |
| 836 | + | users[dst] += amt | |
| 837 | + | counts["transfer"] += 1 | |
| 838 | + | ||
| 839 | + | elif act == "forced_exit": | |
| 840 | + | rich = [u for u in normal_users if users[u] >= 10_000_000] | |
| 841 | + | if rich: | |
| 842 | + | u = rng.choice(rich) | |
| 843 | + | choices = [10_000_000, 25_000_000, 50_000_000] | |
| 844 | + | valid = [c for c in choices if users[u] >= c] | |
| 845 | + | amt = rng.choice(valid) | |
| 846 | + | eid = next_exit_id | |
| 847 | + | next_exit_id += 1 | |
| 848 | + | mine_one_block([{"kind": "forced_exit", "user": u, "gross": amt, "exit_id": eid}]) | |
| 849 | + | ||
| 850 | + | elif act == "front_paid": | |
| 851 | + | open_exits = [eid for eid in pending_exits if eid not in unconf_spent_exits] | |
| 852 | + | active_ops = [oid for oid, op in operators.items() if not op["suspended"]] | |
| 853 | + | if open_exits and active_ops: | |
| 854 | + | eid = rng.choice(open_exits) | |
| 855 | + | oid = rng.choice(active_ops) | |
| 856 | + | unconf_spent_exits.add(eid) | |
| 857 | + | mine_one_block([{"kind": "front_paid", "exit_id": eid, "op_id": oid}]) | |
| 858 | + | ||
| 859 | + | elif act == "front_grief": | |
| 860 | + | open_exits = [eid for eid in pending_exits if eid not in unconf_spent_exits] | |
| 861 | + | active_ops = [oid for oid, op in operators.items() if not op["suspended"] and op["b_grief"] > 0] | |
| 862 | + | if open_exits and active_ops: | |
| 863 | + | eid = rng.choice(open_exits) | |
| 864 | + | oid = rng.choice(active_ops) | |
| 865 | + | unconf_spent_exits.add(eid) | |
| 866 | + | mine_one_block([{"kind": "front_grief", "exit_id": eid, "op_id": oid}]) | |
| 867 | + | ||
| 868 | + | elif act == "exit_cancel": | |
| 869 | + | cur_h = current_tip_height() | |
| 870 | + | expired = [ | |
| 871 | + | eid for eid, ex in pending_exits.items() | |
| 872 | + | if eid not in unconf_spent_exits and cur_h >= ex["created_h"] + POLICY_T_EXIT_CANCEL | |
| 873 | + | ] | |
| 874 | + | if expired: | |
| 875 | + | eid = rng.choice(expired) | |
| 876 | + | unconf_spent_exits.add(eid) | |
| 877 | + | mine_one_block([{"kind": "exit_cancel", "exit_id": eid}]) | |
| 878 | + | ||
| 879 | + | elif act == "take_confirmed": | |
| 880 | + | ready = [ | |
| 881 | + | (vid, info["op_id"]) for vid, info in assigned_vaults.items() | |
| 882 | + | if vid not in unconf_taken_vaults and vid not in unconf_released_vaults | |
| 883 | + | ] | |
| 884 | + | if ready: | |
| 885 | + | vid, oid = rng.choice(ready) | |
| 886 | + | unconf_taken_vaults.add(vid) | |
| 887 | + | mine_one_block([{"kind": "take_confirmed", "op_id": oid, "vault_id": vid}]) | |
| 888 | + | ||
| 889 | + | elif act == "release_assignment": | |
| 890 | + | ready = [ | |
| 891 | + | (vid, info["op_id"]) for vid, info in assigned_vaults.items() | |
| 892 | + | if vid not in unconf_taken_vaults and vid not in unconf_released_vaults | |
| 893 | + | ] | |
| 894 | + | if ready: | |
| 895 | + | vid, oid = rng.choice(ready) | |
| 896 | + | unconf_released_vaults.add(vid) | |
| 897 | + | mine_one_block([{"kind": "release_assignment", "op_id": oid, "vault_id": vid}]) | |
| 898 | + | ||
| 899 | + | elif act == "transfer_credit": | |
| 900 | + | donors = [oid for oid, op in operators.items() if 0 < op["credit"] < 25_000_000] | |
| 901 | + | if donors: | |
| 902 | + | src = rng.choice(donors) | |
| 903 | + | dst = rng.choice([i for i in operators if i != src]) | |
| 904 | + | mine_one_block([{"kind": "transfer_credit", "from_op": src, "to_op": dst, "amount": operators[src]["credit"]}]) | |
| 905 | + | ||
| 906 | + | elif act == "disprove_dual_slash": | |
| 907 | + | active_ops = [oid for oid, op in operators.items() if not op["suspended"]] | |
| 908 | + | if active_ops: | |
| 909 | + | oid = rng.choice(active_ops) | |
| 910 | + | mine_one_block([{"kind": "disprove_dual_slash", "op_id": oid}]) | |
| 911 | + | ||
| 912 | + | elif act == "lamport_equivocation_slash": | |
| 913 | + | all_vids = [ | |
| 914 | + | vid for vid in list(unassigned_vaults.keys()) + list(assigned_vaults.keys()) | |
| 915 | + | if vid not in unconf_taken_vaults | |
| 916 | + | ] | |
| 917 | + | active_ops = [ | |
| 918 | + | oid for oid, op in operators.items() | |
| 919 | + | if not op["suspended"] and op["b_custody"] >= POLICY_B_CUSTODY_TOTAL_SATS | |
| 920 | + | ] | |
| 921 | + | if all_vids and active_ops: | |
| 922 | + | oid = rng.choice(active_ops) | |
| 923 | + | vid = rng.choice(all_vids) | |
| 924 | + | unconf_taken_vaults.add(vid) | |
| 925 | + | mine_one_block([{"kind": "lamport_equivocation_slash", "op_id": oid, "vault_id": vid}]) | |
| 926 | + | ||
| 927 | + | elif act == "topup_op": | |
| 928 | + | susp = [oid for oid, op in operators.items() if op["suspended"]] | |
| 929 | + | if susp: | |
| 930 | + | oid = rng.choice(susp) | |
| 931 | + | op = operators[oid] | |
| 932 | + | need_c = max(0, POLICY_B_CUSTODY_TOTAL_SATS - op["b_custody"]) | |
| 933 | + | need_g = max(0, POLICY_B_GRIEF_TOTAL_SATS - op["b_grief"]) | |
| 934 | + | needed = need_c + need_g | |
| 935 | + | if op["free_zbtc"] >= needed: | |
| 936 | + | op["free_zbtc"] -= needed | |
| 937 | + | op["b_custody"] += need_c | |
| 938 | + | op["b_grief"] += need_g | |
| 939 | + | op["suspended"] = False | |
| 940 | + | counts["topup_op"] += 1 | |
| 941 | + | elif ticket_pool[50_000_000] >= 2: | |
| 942 | + | ticket_pool[50_000_000] -= 2 | |
| 943 | + | for _ in range(2): | |
| 944 | + | unassigned_vaults[next_vault_id] = {"sats": 50_000_000, "mask": all_ops_mask} | |
| 945 | + | next_vault_id += 1 | |
| 946 | + | op["free_zbtc"] += SAT - needed | |
| 947 | + | op["b_custody"] += need_c | |
| 948 | + | op["b_grief"] += need_g | |
| 949 | + | op["suspended"] = False | |
| 950 | + | counts["topup_op"] += 1 | |
| 951 | + | ||
| 952 | + | elif act == "mine_block": | |
| 953 | + | mine_one_block([]) | |
| 954 | + | ||
| 955 | + | elif act == "reorg": | |
| 956 | + | if tip_blocks: | |
| 957 | + | depth = rng.randint(1, min(K - 1, len(tip_blocks))) | |
| 958 | + | orphaned = tip_blocks[-depth:] | |
| 959 | + | del tip_blocks[-depth:] | |
| 960 | + | ev_reverted = sum(len(b["events"]) for b in orphaned) | |
| 961 | + | counts["reorg"] += 1 | |
| 962 | + | counts["reorg_blocks_reverted"] += depth | |
| 963 | + | counts["reorg_events_reverted"] += ev_reverted | |
| 964 | + | rebuild_unconf_locks() | |
| 965 | + | for _ in range(depth): | |
| 966 | + | mine_one_block([]) | |
| 967 | + | ||
| 968 | + | assert_solvency(f"step_{step}_{act}") | |
| 969 | + | ||
| 970 | + | # Guarantee EXIT_CANCEL path is exercised if random steps didn't hit a 288-block idle exit | |
| 971 | + | if counts["exit_cancel"] == 0: | |
| 972 | + | u = next((u for u in normal_users if users[u] >= 25_000_000), "insurance_pool") | |
| 973 | + | eid = next_exit_id | |
| 974 | + | next_exit_id += 1 | |
| 975 | + | mine_one_block([{"kind": "forced_exit", "user": u, "gross": 25_000_000, "exit_id": eid}]) | |
| 976 | + | for _ in range(K + POLICY_T_EXIT_CANCEL): | |
| 977 | + | mine_one_block([]) | |
| 978 | + | mine_one_block([{"kind": "exit_cancel", "exit_id": eid}]) | |
| 979 | + | for _ in range(K): | |
| 980 | + | mine_one_block([]) | |
| 981 | + | assert_solvency("post_exit_cancel") | |
| 982 | + | ||
| 983 | + | # Guarantee ticket-cap deposit-race rejection was exercised | |
| 984 | + | if counts["deposit_race_blocked_by_ticket"] == 0: | |
| 985 | + | # Attempt a massive burst of deposits past the remaining ticket cap | |
| 986 | + | for _ in range(25): | |
| 987 | + | new_vs = [(next_vault_id + i, amt) for i, amt in enumerate(POLICY_VAULT_TIERS_SATS)] | |
| 988 | + | next_vault_id += 3 | |
| 989 | + | mine_one_block([{"kind": "deposit", "user": "alice", "vaults": new_vs, "mask": all_ops_mask}]) | |
| 990 | + | for _ in range(K): | |
| 991 | + | mine_one_block([]) | |
| 992 | + | assert_solvency("post_ticket_race") | |
| 993 | + | ||
| 994 | + | # Flush remaining tip blocks to K-deep finality | |
| 995 | + | for _ in range(K): | |
| 996 | + | mine_one_block([]) | |
| 997 | + | assert_solvency("final") | |
| 998 | + | return counts | |
| 999 | + | ||
| 1000 | + | ||
| 1001 | + | # ============================================================================== | |
| 1002 | + | # MAIN ASSERTION SUITE | |
| 1003 | + | # ============================================================================== | |
| 1004 | + | def main() -> None: | |
| 1005 | + | print("================================================================================") | |
| 1006 | + | print("zBTC v2 (v3.1.0-rfc — R8 HARDENED) ZERO-FEDERATION CONSISTENCY & BOUNDS CHECKER") | |
| 1007 | + | print("Note: Pure Python 3 stdlib. Checks internal consistency against SOURCED_,") | |
| 1008 | + | print(" POLICY_, and PRE_MAINNET_TARGET_ inputs. Not an empirical Signet benchmark.") | |
| 1009 | + | print("================================================================================") | |
| 1010 | + | ||
| 1011 | + | # -------------------------------------------------------------------------- | |
| 1012 | + | # 1. STAGE 0: COINBASE MIDSTATE 1-/2-BLOCK PADDING & >= 65 B FILTER (R8-M06) | |
| 1013 | + | # -------------------------------------------------------------------------- | |
| 1014 | + | print("\n=== 1. STAGE 0: COINBASE MIDSTATE 1-/2-BLOCK SHA-256 PADDING & >= 65 B FILTER ===") | |
| 1015 | + | one_blk_count, two_blk_count = 0, 0 | |
| 1016 | + | for rem in range(64): | |
| 1017 | + | total_len = 128 + rem | |
| 1018 | + | cb_bytes = bytes((i * 37 + rem) & 0xFF for i in range(total_len)) | |
| 1019 | + | st = sha256_compress(sha256_compress(_SHA256_IV, cb_bytes[0:64]), cb_bytes[64:128]) | |
| 1020 | + | midstate = struct.pack(">8I", *st) | |
| 1021 | + | got_txid, final_blks = complete_midstate_double_sha256(midstate, cb_bytes[128:], total_len) | |
| 1022 | + | assert got_txid == hashlib.sha256(hashlib.sha256(cb_bytes).digest()).digest() | |
| 1023 | + | if rem < 56: | |
| 1024 | + | assert final_blks == 1 | |
| 1025 | + | one_blk_count += 1 | |
| 1026 | + | else: | |
| 1027 | + | assert final_blks == 2 | |
| 1028 | + | two_blk_count += 1 | |
| 1029 | + | assert one_blk_count == 56 and two_blk_count == 8 | |
| 1030 | + | for bad_len in (0, 32, 63, 64): | |
| 1031 | + | try: | |
| 1032 | + | complete_midstate_double_sha256(b"\x00" * 32, b"\x00" * (bad_len % 64), bad_len) | |
| 1033 | + | raise AssertionError(f"Length {bad_len} must be rejected!") | |
| 1034 | + | except AssertionError as e: | |
| 1035 | + | assert "CVE-2017-12842" in str(e) | |
| 1036 | + | print( | |
| 1037 | + | f" Verified 64/64 remainders vs hashlib double-SHA256 ({one_blk_count} 1-blk, {two_blk_count} 2-blk = 12.5%); " | |
| 1038 | + | f"all len <= 64 rejected (min strippedTx = {POLICY_STAGE0_MIN_STRIPPED_TX_BYTES} B)." | |
| 1039 | + | ) | |
| 1040 | + | ||
| 1041 | + | # -------------------------------------------------------------------------- | |
| 1042 | + | # 2. STAGE 0: go-zenon THROUGHPUT, SPV ORACLE & BITCOIN L1 0x02 DA CEILING (R8-M08) | |
| 1043 | + | # -------------------------------------------------------------------------- | |
| 1044 | + | print("\n=== 2. STAGE 0: go-zenon PLASMA / 8 MiB CEILING vs BITCOIN L1 0x02 DA CAP ===") | |
| 1045 | + | rollup_tx_plasma = SOURCED_ZNN_ACCOUNT_BLOCK_BASE_PLASMA + PRE_MAINNET_TARGET_ROLLUP_TX_DATA_BYTES * SOURCED_ZNN_AB_BYTE_DATA_PLASMA | |
| 1046 | + | assert rollup_tx_plasma == 28_480 | |
| 1047 | + | assert ceil_div(rollup_tx_plasma, SOURCED_ZNN_PLASMA_PER_QSR) == 14 | |
| 1048 | + | ||
| 1049 | + | tps_floor_2blk = (POLICY_PINNED_MAX_BASE_PLASMA_FLOOR / SOURCED_ZNN_ACCOUNT_BLOCK_BASE_PLASMA / 2.0) / SOURCED_ZNN_OBSERVED_MOMENTUM_SECS | |
| 1050 | + | tps_default_2blk = (SOURCED_ZNN_DP_DEFAULT_MAX_BASE_PLASMA / SOURCED_ZNN_ACCOUNT_BLOCK_BASE_PLASMA / 2.0) / SOURCED_ZNN_OBSERVED_MOMENTUM_SECS | |
| 1051 | + | rollup_tps_floor_114 = (POLICY_PINNED_MAX_BASE_PLASMA_FLOOR / rollup_tx_plasma) / SOURCED_ZNN_OBSERVED_MOMENTUM_SECS | |
| 1052 | + | rollup_tps_default_114 = (SOURCED_ZNN_DP_DEFAULT_MAX_BASE_PLASMA / rollup_tx_plasma) / SOURCED_ZNN_OBSERVED_MOMENTUM_SECS | |
| 1053 | + | rollup_tps_floor_10s = (POLICY_PINNED_MAX_BASE_PLASMA_FLOOR / rollup_tx_plasma) / 10.0 | |
| 1054 | + | real_tps_low = ((SOURCED_ZNN_MAX_DETAILED_MOMENTUM_WIRE // SOURCED_ZNN_MIN_ACCOUNT_BLOCK_WIRE_HIGH) / 2.0) / SOURCED_ZNN_OBSERVED_MOMENTUM_SECS | |
| 1055 | + | real_tps_high = ((SOURCED_ZNN_MAX_DETAILED_MOMENTUM_WIRE // SOURCED_ZNN_MIN_ACCOUNT_BLOCK_WIRE_LOW) / 2.0) / SOURCED_ZNN_OBSERVED_MOMENTUM_SECS | |
| 1056 | + | assert 4.3 < tps_floor_2blk < 4.5 and 8.7 < tps_default_2blk < 8.9 | |
| 1057 | + | assert 6.3 < rollup_tps_floor_114 < 6.6 and 12.8 < rollup_tps_default_114 < 13.1 | |
| 1058 | + | assert 7.36 < rollup_tps_floor_10s < 7.38 | |
| 1059 | + | assert 1_000 < real_tps_low < 1_100 and 1_200 < real_tps_high < 1_260 | |
| 1060 | + | ||
| 1061 | + | # Bitcoin L1 physical 0x02 mutated-leaf DA ceilings (R8-M08) | |
| 1062 | + | btc_max_vb_per_sec = (SOURCED_BTC_MAX_BLOCK_WEIGHT / 4.0) / SOURCED_BTC_TARGET_BLOCK_SECS # 1,666.67 vB/s | |
| 1063 | + | da_blended_10vb_100pct = btc_max_vb_per_sec / 10.0 # 166.67 leaves/s @ 100% Bitcoin blockspace | |
| 1064 | + | da_existing_4vb_100pct = btc_max_vb_per_sec / 4.0 # 416.67 existing 16B leaves/s @ 100% | |
| 1065 | + | da_new_12vb_100pct = btc_max_vb_per_sec / 12.0 # 138.89 new 48B leaves/s @ 100% | |
| 1066 | + | da_epoch_new_leaf_cap_per_sec = POLICY_MAX_NEW_LEAVES_PER_EPOCH / (6.0 * SOURCED_BTC_TARGET_BLOCK_SECS) | |
| 1067 | + | assert abs(da_blended_10vb_100pct - 166.6666667) < 1e-4 | |
| 1068 | + | assert abs(da_existing_4vb_100pct - 416.6666667) < 1e-4 | |
| 1069 | + | assert da_epoch_new_leaf_cap_per_sec < 0.30 | |
| 1070 | + | ||
| 1071 | + | # Stage 0 SPV Oracle ABI + Dynamic Plasma 5-param pinning | |
| 1072 | + | prove_payload = 8 + 4 + 4 + 32 + POLICY_STAGE0_MAX_STRIPPED_TX_BYTES + 16 * 32 + 63 + 16 * 32 | |
| 1073 | + | prove_abi = (4 + 8 * 32) + (32 + POLICY_STAGE0_MAX_STRIPPED_TX_BYTES) + (32 + 16 * 32) + (32 + 64) + (32 + 16 * 32) | |
| 1074 | + | assert prove_payload == 7_279 and prove_abi == 7_620 | |
| 1075 | + | prove_plasma = abi_embedded_plasma(SOURCED_ZNN_EMBEDDED_HEAVY_SPV_TIER, prove_abi) | |
| 1076 | + | assert prove_plasma == 591_388 and POLICY_PINNED_MAX_BASE_PLASMA_FLOOR >= 3 * prove_plasma | |
| 1077 | + | assert POLICY_PINNED_MAX_BASE_PLASMA_FLOOR // SOURCED_ZNN_EMBEDDED_SIMPLE_TIER == 40 | |
| 1078 | + | ||
| 1079 | + | price_unpinned, price_pinned = SOURCED_ZNN_MIN_RESOURCE_PRICE, SOURCED_ZNN_MIN_RESOURCE_PRICE | |
| 1080 | + | pinned_target = (POLICY_PINNED_MAX_BASE_PLASMA_FLOOR * POLICY_PINNED_MIN_TARGET_SHARE_PCT) // 100 | |
| 1081 | + | assert pinned_target == 525_000 | |
| 1082 | + | for _ in range(52): | |
| 1083 | + | price_unpinned = dp_next_price(price_unpinned, 21_000, 1, POLICY_PINNED_MAX_PRICE_CHANGE_PCT, 1) | |
| 1084 | + | price_pinned = dp_next_price(price_pinned, 21_000, pinned_target, POLICY_PINNED_MAX_PRICE_CHANGE_PCT, POLICY_PINNED_MIN_PRICE_DENOM) | |
| 1085 | + | assert price_unpinned / 1_000 > 100_000 and price_pinned == 1_000 | |
| 1086 | + | print( | |
| 1087 | + | f" Zenon @ 11.4s: 2-blk={tps_floor_2blk:.1f}/{tps_default_2blk:.1f} tx/s | " | |
| 1088 | + | f"1-blk rollup={rollup_tps_floor_114:.1f}/{rollup_tps_default_114:.1f} tx/s ({rollup_tps_floor_10s:.2f} @ 10s) | " | |
| 1089 | + | f"8 MiB cap={real_tps_low:,.0f}-{real_tps_high:,.0f} tx/s" | |
| 1090 | + | ) | |
| 1091 | + | print( | |
| 1092 | + | f" Bitcoin L1 0x02 DA cap @ 100% blockspace: blended(10vB)={da_blended_10vb_100pct:.1f} leaves/s " | |
| 1093 | + | f"(1%={da_blended_10vb_100pct/100:.2f}/s) | existing(4vB)={da_existing_4vb_100pct:.1f}/s | " | |
| 1094 | + | f"new(12vB)={da_new_12vb_100pct:.1f}/s | spam cap={POLICY_MAX_NEW_LEAVES_PER_EPOCH}/6-blk ({da_epoch_new_leaf_cap_per_sec:.2f}/s, {POLICY_NEW_LEAF_DEPOSIT_SATS}-sat deposit)" | |
| 1095 | + | ) | |
| 1096 | + | ||
| 1097 | + | # -------------------------------------------------------------------------- | |
| 1098 | + | # 3. STAGE 0: EXACT ERLANG TAILS FOR PTLC (>= 48h) & LN HTLC (>= 24h) (R8-H07) | |
| 1099 | + | # -------------------------------------------------------------------------- | |
| 1100 | + | print("\n=== 3. STAGE 0: EXACT STDLIB ERLANG TAILS FOR PTLC (>= 48h) & LN HTLC (>= 24h) ===") | |
| 1101 | + | mean_1x = SOURCED_BTC_TARGET_BLOCK_SECS | |
| 1102 | + | mean_2p3x = SOURCED_BTC_TARGET_BLOCK_SECS * SOURCED_JUNE2021_SLOW_DAILY_MULT # 1,380 s/blk | |
| 1103 | + | # Regression-verify R8-H07's exact failure probabilities on old v3.0.0 values: | |
| 1104 | + | old_ptlc_fail = erlang_survival_prob(72, 30 * 3600, mean_2p3x) | |
| 1105 | + | old_ln_fail = erlang_survival_prob(36, 6 * 3600, mean_1x) | |
| 1106 | + | assert abs(old_ptlc_fail - 0.2234) < 0.002, f"Expected ~22.34%, got {old_ptlc_fail:.4%}" | |
| 1107 | + | assert abs(old_ln_fail - 0.4778) < 0.002, f"Expected ~47.78%, got {old_ln_fail:.4%}" | |
| 1108 | + | # Verify hardened v3.1.0-rfc margins: | |
| 1109 | + | new_ptlc_fail = erlang_survival_prob(POLICY_PTLC_BTC_CSV_BLOCKS, POLICY_PTLC_ZNN_DURATION_SECS, mean_2p3x) | |
| 1110 | + | ptlc_p999_h = erlang_quantile_hours(POLICY_PTLC_BTC_CSV_BLOCKS, 0.999, mean_2p3x) | |
| 1111 | + | new_ln_fail_2p3x = erlang_survival_prob(POLICY_LN_DELTA_SAFETY_BLOCKS, POLICY_LN_OUTBOUND_DELTA_SAFETY_SECS, mean_2p3x) | |
| 1112 | + | new_ln_fail_1x = erlang_survival_prob(POLICY_LN_DELTA_SAFETY_BLOCKS, POLICY_LN_OUTBOUND_DELTA_SAFETY_SECS, mean_1x) | |
| 1113 | + | ln_p999_h = erlang_quantile_hours(POLICY_LN_DELTA_SAFETY_BLOCKS, 0.999, mean_2p3x) | |
| 1114 | + | assert new_ptlc_fail < 1e-6 and ptlc_p999_h < 39.0 | |
| 1115 | + | assert new_ln_fail_2p3x < 2e-4 and new_ln_fail_1x < 1e-18 and ln_p999_h < 22.5 | |
| 1116 | + | print( | |
| 1117 | + | f" PTLC (72 blks @ 2.3x): old 30h fail={old_ptlc_fail:.2%} -> NEW 48h fail={new_ptlc_fail:.2e} " | |
| 1118 | + | f"(p99.9={ptlc_p999_h:.2f}h, margin={48.0 - ptlc_p999_h:.2f}h; block-72 RBF watchtower)" | |
| 1119 | + | ) | |
| 1120 | + | print( | |
| 1121 | + | f" LN Outbound (36 blks): old 6h@1x fail={old_ln_fail:.2%} -> NEW 24h@2.3x fail={new_ln_fail_2p3x:.2e} " | |
| 1122 | + | f"(p99.9={ln_p999_h:.2f}h, @1x fail={new_ln_fail_1x:.2e})" | |
| 1123 | + | ) | |
| 1124 | + | ||
| 1125 | + | # -------------------------------------------------------------------------- | |
| 1126 | + | # 4. STAGE 1A: COMPLETE HARD-BTC CAPITAL ACCOUNTING (R8-M09, R8-H02) | |
| 1127 | + | # -------------------------------------------------------------------------- | |
| 1128 | + | print("\n=== 4. STAGE 1A: COMPLETE HARD-BTC CAPITAL (LOCKED vs OPERATIONAL vs MULTI-DISPUTE) ===") | |
| 1129 | + | bitvm2_m3_low = 3 * PRE_MAINNET_TARGET_BITVM2_LANE_BOND_BTC_LOW | |
| 1130 | + | bitvm2_m5_high = 5 * PRE_MAINNET_TARGET_BITVM2_LANE_BOND_BTC_HIGH | |
| 1131 | + | assert bitvm2_m3_low > SOURCED_ZNN_MCAP_BTC_HIGH | |
| 1132 | + | verifier_standby_btc = (POLICY_BITVMX_N_VERIFIERS * POLICY_F_CHAL_SATS) / SAT | |
| 1133 | + | verifier_cpfp_res_btc = POLICY_BITVMX_N_VERIFIERS * POLICY_OP_RESERVE_VERIFIER_CPFP_PER_V_BTC | |
| 1134 | + | assert abs(verifier_standby_btc - 2.80) < 1e-9 and abs(verifier_cpfp_res_btc - 0.70) < 1e-9 | |
| 1135 | + | ||
| 1136 | + | for label, prof in POLICY_STAGE1A_PROFILES.items(): | |
| 1137 | + | m = prof["M"] | |
| 1138 | + | bonds_btc = (m * POLICY_BITVMX_L_LANES * POLICY_LANE_TOTAL_BOND_SATS) / SAT | |
| 1139 | + | locked_btc = bonds_btc + prof["float_btc"] + verifier_standby_btc | |
| 1140 | + | op_reserves = verifier_cpfp_res_btc + POLICY_OP_RESERVE_DA_BATCHER_BTC + m * POLICY_OP_RESERVE_TOPUP_PER_OP_BTC | |
| 1141 | + | op_baseline = locked_btc + op_reserves | |
| 1142 | + | per_verifier_m_disputes = m * ((POLICY_F_CHAL_SATS / SAT) + 0.08265) | |
| 1143 | + | pct_low = 100.0 * op_baseline / SOURCED_ZNN_MCAP_BTC_HIGH | |
| 1144 | + | pct_high = 100.0 * op_baseline / SOURCED_ZNN_MCAP_BTC_LOW | |
| 1145 | + | if m == 3: | |
| 1146 | + | assert abs(locked_btc - 12.80) < 1e-9 and abs(op_baseline - 14.75) < 1e-9 | |
| 1147 | + | if m == 5: | |
| 1148 | + | assert abs(locked_btc - 18.80) < 1e-9 and abs(op_baseline - 21.25) < 1e-9 | |
| 1149 | + | print( | |
| 1150 | + | f" {label:28s}: locked={locked_btc:5.2f} + op_res={op_reserves:4.2f} = {op_baseline:5.2f} BTC " | |
| 1151 | + | f"({pct_low:.1f}%-{pct_high:.1f}% ZNN mcap) | M-dispute/honest-V={per_verifier_m_disputes:.2f} BTC" | |
| 1152 | + | ) | |
| 1153 | + | print(f" BitVM2 bonds-only contrast (M=3..5): {bitvm2_m3_low:.2f}-{bitvm2_m5_high:.3f} BTC | Core floor >= {SOURCED_BTC_CORE_MIN_VERSION_P2A_ZERO}") | |
| 1154 | + | ||
| 1155 | + | # -------------------------------------------------------------------------- | |
| 1156 | + | # 5. STAGE 1A: BitVMX n=8 BISECTION, 10x153 vB CPFP & TRUC v3 (R8-H04/H05) | |
| 1157 | + | # -------------------------------------------------------------------------- | |
| 1158 | + | print("\n=== 5. STAGE 1A: BitVMX-CPU n=8 WRAPPED-SNARK VERIFIER & P2A CPFP TRUC v3 ===") | |
| 1159 | + | digits_per_prover_tx = (POLICY_BITVMX_N_BRANCH - 1) * (40 + 3) | |
| 1160 | + | assert digits_per_prover_tx == 301 | |
| 1161 | + | prover_step_vb = math.ceil(digits_per_prover_tx * PRE_MAINNET_TARGET_WOTS_DIGIT_WU) / 4.0 + PRE_MAINNET_TARGET_BISECTION_OVERHEAD_VB | |
| 1162 | + | assert abs(prover_step_vb - 7_436.5) < 1e-9 | |
| 1163 | + | assert prover_step_vb <= SOURCED_BIP431_TRUC_MAX_VB | |
| 1164 | + | assert prover_step_vb > SOURCED_BIP431_TRUC_CHILD_MAX_VB # Confirms zero unconfirmed TRUC child chaining! | |
| 1165 | + | ||
| 1166 | + | cpfp_side_vb = PRE_MAINNET_TARGET_CPFP_COUNT_PER_SIDE * SOURCED_P2A_CPFP_CHILD_VB | |
| 1167 | + | assert cpfp_side_vb == 1_530 and SOURCED_P2A_CPFP_CHILD_VB <= SOURCED_BIP431_TRUC_CHILD_MAX_VB | |
| 1168 | + | prover_total_with_cpfp_vb = PRE_MAINNET_TARGET_PROVER_BASE_CAP_VB + cpfp_side_vb # 76,530 vB | |
| 1169 | + | verifier_total_with_cpfp_vb = PRE_MAINNET_TARGET_VERIFIER_BASE_CAP_VB + cpfp_side_vb # 16,530 vB | |
| 1170 | + | assert prover_total_with_cpfp_vb == 76_530 and verifier_total_with_cpfp_vb == 16_530 | |
| 1171 | + | ||
| 1172 | + | prover_fee_500 = prover_total_with_cpfp_vb * POLICY_DESIGN_SUSTAINED_FEE_SATVB | |
| 1173 | + | prover_breakeven = POLICY_F_CHAL_SATS // prover_total_with_cpfp_vb | |
| 1174 | + | verifier_fee_500 = verifier_total_with_cpfp_vb * POLICY_DESIGN_SUSTAINED_FEE_SATVB | |
| 1175 | + | verifier_fee_750 = verifier_total_with_cpfp_vb * POLICY_STRESS_SUSTAINED_FEE_SATVB | |
| 1176 | + | assert prover_fee_500 == 38_265_000 <= POLICY_F_CHAL_SATS and prover_breakeven == 522 | |
| 1177 | + | assert verifier_fee_500 == 8_265_000 and verifier_fee_750 == 12_397_500 | |
| 1178 | + | seq_steps = 1 + 2 * POLICY_BITVMX_SEARCH_ROUNDS + 1 | |
| 1179 | + | assert seq_steps == 20 and POLICY_BITVMX_N_BRANCH ** POLICY_BITVMX_SEARCH_ROUNDS == 134_217_728 | |
| 1180 | + | print( | |
| 1181 | + | f" Prover step={prover_step_vb:,.1f} vB <= 10k TRUC parent (>1k child -> confirmed parents only!) | " | |
| 1182 | + | f"Prover w/ 10x153 CPFP={prover_total_with_cpfp_vb:,} vB ({prover_fee_500/SAT:.5f} BTC <= 0.40, BE={prover_breakeven} sat/vB)" | |
| 1183 | + | ) | |
| 1184 | + | print( | |
| 1185 | + | f" Verifier w/ 10x153 CPFP={verifier_total_with_cpfp_vb:,} vB: @500={verifier_fee_500/SAT:.5f} BTC, @750={verifier_fee_750/SAT:.5f} BTC" | |
| 1186 | + | ) | |
| 1187 | + | ||
| 1188 | + | # -------------------------------------------------------------------------- | |
| 1189 | + | # 6. STAGE 1A: WIDENED TIMELOCKS & ACYCLIC vault_id LAMPORT TakeTx (R8-C01) | |
| 1190 | + | # -------------------------------------------------------------------------- | |
| 1191 | + | print("\n=== 6. STAGE 1A: WIDENED TIMELOCKS (T_step=72) & ACYCLIC vault_id LAMPORT TakeTx ===") | |
| 1192 | + | max_dispute_end = POLICY_T_CHAL_WINDOW + seq_steps * POLICY_T_STEP | |
| 1193 | + | assert max_dispute_end == 1_584 | |
| 1194 | + | assert POLICY_T_TAKE == 1_728 and POLICY_T_TAKE - max_dispute_end == 144 | |
| 1195 | + | assert POLICY_T_COOLDOWN == 1_872 and POLICY_T_COOLDOWN - POLICY_T_TAKE == 144 | |
| 1196 | + | assert POLICY_T_RETIRE == 2_016 and POLICY_T_RETIRE - POLICY_T_COOLDOWN == 144 | |
| 1197 | + | ||
| 1198 | + | # Acyclic vault_id determinism & uniqueness across distinct vouts of same confirmed U_dep_wallet: | |
| 1199 | + | funding_txid = hashlib.sha256(b"confirmed_U_dep_wallet_txid").digest() | |
| 1200 | + | vid_0 = compute_acyclic_vault_id(funding_txid, 0, 0, 50_000_000, 0b11111) | |
| 1201 | + | vid_1 = compute_acyclic_vault_id(funding_txid, 0, 1, 25_000_000, 0b11111) | |
| 1202 | + | vid_2 = compute_acyclic_vault_id(funding_txid, 0, 2, 25_000_000, 0b11111) | |
| 1203 | + | assert len({vid_0, vid_1, vid_2}) == 3 and all(len(v) == 32 for v in (vid_0, vid_1, vid_2)) | |
| 1204 | + | ||
| 1205 | + | # Exact Lamport TakeTx size INCLUDING recycled AdmissionTicketUTXO at vout[1]! | |
| 1206 | + | lamport_script_bytes = 256 * 23 + 34 # 5,922 B | |
| 1207 | + | lamport_preimages_bytes = 256 * 21 # 5,376 B | |
| 1208 | + | cb_stage1a, cb_stage2 = 1 + 32 + 32 * 9, 1 + 32 + 32 * 12 # 321 / 417 B | |
| 1209 | + | assert lamport_script_bytes == 5_922 and lamport_preimages_bytes == 5_376 and cb_stage1a == 321 and cb_stage2 == 417 | |
| 1210 | + | # Non-witness: 10 + 2*41 (U_d + VaultConnector) + 43 (P_Op) + 43 (recycled Ticket) + 13 (P2A) = 191 B | |
| 1211 | + | take_non_wit = 10 + 2 * 41 + 43 + 43 + 13 | |
| 1212 | + | take_wit_s1 = compact_size_len(259) + 65 + lamport_preimages_bytes + compact_size_len(lamport_script_bytes) + lamport_script_bytes + compact_size_len(cb_stage1a) + cb_stage1a + 110 | |
| 1213 | + | take_wit_s2 = compact_size_len(259) + 65 + lamport_preimages_bytes + compact_size_len(lamport_script_bytes) + lamport_script_bytes + compact_size_len(cb_stage2) + cb_stage2 + 110 | |
| 1214 | + | take_vb_s1 = (take_non_wit * 4 + take_wit_s1) / 4.0 | |
| 1215 | + | take_vb_s2 = (take_non_wit * 4 + take_wit_s2) / 4.0 | |
| 1216 | + | assert take_vb_s1 <= 3_200 and take_vb_s2 <= 3_200 <= SOURCED_BIP431_TRUC_MAX_VB | |
| 1217 | + | assert take_vb_s1 > SOURCED_BIP431_TRUC_CHILD_MAX_VB # Confirmed VaultConnector_r only! | |
| 1218 | + | print( | |
| 1219 | + | f" Timelocks: [0,{POLICY_T_CHAL_WINDOW}] -> max_dispute={max_dispute_end} < T_take={POLICY_T_TAKE} (12d) " | |
| 1220 | + | f"< T_cool={POLICY_T_COOLDOWN} (13d) < Retire={POLICY_T_RETIRE} (14d)" | |
| 1221 | + | ) | |
| 1222 | + | print( | |
| 1223 | + | f" Acyclic vault_id Lamport TakeTx (w/ recycled Ticket): depth9={take_vb_s1:,.2f} vB / depth12={take_vb_s2:,.2f} vB " | |
| 1224 | + | f"(<=3,200 <=10,000 TRUC parent; peak_stack=258 < 1,000)" | |
| 1225 | + | ) | |
| 1226 | + | ||
| 1227 | + | # -------------------------------------------------------------------------- | |
| 1228 | + | # 7. STAGE 1A: NATIVE-L1 Stake_r VERIFIER EV MATRIX (R8-H02, R8-N05 CLOSED!) | |
| 1229 | + | # -------------------------------------------------------------------------- | |
| 1230 | + | print("\n=== 7. STAGE 1A: NATIVE-L1 Stake_r VERIFIER EV MATRIX (0% zBTC CRISIS DISCOUNT) ===") | |
| 1231 | + | assert POLICY_BITVMX_N_VERIFIERS * POLICY_VERIFIER_NATIVE_L1_PAYOUT_SATS + POLICY_MIN_L1_STAKE_BURN_SATS == POLICY_BOND_BTC_SATS | |
| 1232 | + | assert POLICY_MIN_L1_STAKE_BURN_SATS == 95_000_000 # 0.95 BTC min burn! | |
| 1233 | + | # Native L1 payout = 0.15 BTC -> 0% haircut even at 30% (or 100%) zBTC crisis discount! | |
| 1234 | + | ev_500 = POLICY_VERIFIER_NATIVE_L1_PAYOUT_SATS - verifier_fee_500 - POLICY_VERIFIER_LOCKUP_COST_SATS | |
| 1235 | + | ev_750 = POLICY_VERIFIER_NATIVE_L1_PAYOUT_SATS - verifier_fee_750 - POLICY_VERIFIER_LOCKUP_COST_SATS | |
| 1236 | + | verifier_breakeven_satvb = (POLICY_VERIFIER_NATIVE_L1_PAYOUT_SATS - POLICY_VERIFIER_LOCKUP_COST_SATS) // verifier_total_with_cpfp_vb | |
| 1237 | + | assert ev_500 == 6_450_000 > 0 # +0.06450 BTC @ 500 sat/vB! | |
| 1238 | + | assert ev_750 == 2_317_500 > 0 # +0.023175 BTC @ 750 sat/vB! | |
| 1239 | + | assert verifier_breakeven_satvb == 890 | |
| 1240 | + | for k_collude in range(POLICY_BITVMX_N_VERIFIERS): | |
| 1241 | + | honest_n = POLICY_BITVMX_N_VERIFIERS - k_collude | |
| 1242 | + | l1_recapture = k_collude * POLICY_VERIFIER_NATIVE_L1_PAYOUT_SATS | |
| 1243 | + | l1_only_pnl = -POLICY_BOND_BTC_SATS + l1_recapture # -2.00 to -1.10 BTC on L1 ALONE! | |
| 1244 | + | total_pnl = l1_only_pnl - POLICY_B_CUSTODY_TOTAL_SATS | |
| 1245 | + | assert l1_only_pnl <= -110_000_000 and total_pnl <= -165_000_000 | |
| 1246 | + | if k_collude == 0: | |
| 1247 | + | assert l1_only_pnl == -200_000_000 and total_pnl == -255_000_000 | |
| 1248 | + | if k_collude == 6: | |
| 1249 | + | assert l1_only_pnl == -110_000_000 and total_pnl == -165_000_000 | |
| 1250 | + | print( | |
| 1251 | + | f" k_collude={k_collude} (honest={honest_n}): L1_payout=0.1500 BTC (0% zBTC discount!) | " | |
| 1252 | + | f"EV@500={ev_500/SAT:+.5f}, EV@750={ev_750/SAT:+.5f} (BE={verifier_breakeven_satvb} sat/vB) | " | |
| 1253 | + | f"Cartel L1={l1_only_pnl/SAT:+.2f} / Tot={total_pnl/SAT:+.2f} BTC" | |
| 1254 | + | ) | |
| 1255 | + | ||
| 1256 | + | # -------------------------------------------------------------------------- | |
| 1257 | + | # 8. STAGE 1A: EXACT 2^M HALL'S MARRIAGE & CYCLIC PRIORITY (R8-C04, R8-M03) | |
| 1258 | + | # -------------------------------------------------------------------------- | |
| 1259 | + | print("\n=== 8. STAGE 1A: 2^M HALL'S MARRIAGE CHECKER & CYCLIC EXIT PRIORITY ===") | |
| 1260 | + | # Demonstrate R8-C04 stranding counterexample: global cap passes (30 <= 0.5 * 220 = 110), | |
| 1261 | + | # yet 30 vaults with opBitmask={0,1} (0b00011) exceed O_0+O_1 remaining rounds (10+10=20)! | |
| 1262 | + | counterex_vaults = [0b00011] * 30 | |
| 1263 | + | counterex_rounds = [10, 10, 64, 64, 64] | |
| 1264 | + | assert len(counterex_vaults) <= 0.50 * sum(counterex_rounds) # Global scalar check falsely passed! | |
| 1265 | + | ok_bad, bad_mask, bad_dem, bad_sup = check_halls_marriage(counterex_vaults, counterex_rounds, headroom_factor=1.0) | |
| 1266 | + | assert not ok_bad and bad_mask == 0b00011 and bad_dem == 30 and bad_sup == 20 | |
| 1267 | + | # Valid Stage 1A uniform full-committee cohort passes even at 0.50 headroom: | |
| 1268 | + | ok_good, _, _, _ = check_halls_marriage([0b11111] * 45, [64] * 5, headroom_factor=0.50) | |
| 1269 | + | assert ok_good | |
| 1270 | + | ||
| 1271 | + | # Verify R8-M03 cyclic permutation has 0% collisions across 1,000 random exitIds for M=3..20: | |
| 1272 | + | for m_act in (3, 5, 10, 20): | |
| 1273 | + | for i in range(200): | |
| 1274 | + | perm = cyclic_exit_priority(f"exit_{m_act}_{i}".encode(), m_act) | |
| 1275 | + | assert len(perm) == m_act and len(set(perm)) == m_act | |
| 1276 | + | print( | |
| 1277 | + | f" Hall's 2^M counterexample CAUGHT (subset 0b{bad_mask:05b}: demand={bad_dem} > supply={bad_sup}, " | |
| 1278 | + | f"despite global 30 <= 110); uniform 45-vault M=5 cohort PASSES at 0.50 headroom." | |
| 1279 | + | ) | |
| 1280 | + | print(" Cyclic priority k_r = (H(exitId) + r) mod M_active: 0.0% collisions verified across 800 tests (M=3,5,10,20).") | |
| 1281 | + | ||
| 1282 | + | # -------------------------------------------------------------------------- | |
| 1283 | + | # 9. STAGE 1A: MULTI-TIER BANK-RUN DURATION (T_cooldown = 13.0d) | |
| 1284 | + | # -------------------------------------------------------------------------- | |
| 1285 | + | print("\n=== 9. STAGE 1A: MULTI-TIER VAULTS & 100% BANK-RUN DURATION (T_cooldown = 13.0d) ===") | |
| 1286 | + | cooldown_days = POLICY_T_COOLDOWN / SOURCED_BTC_BLOCKS_PER_DAY | |
| 1287 | + | assert abs(cooldown_days - 13.0) < 1e-9 | |
| 1288 | + | avg_multi = (sum(POLICY_VAULT_TIERS_SATS) / len(POLICY_VAULT_TIERS_SATS)) / SAT | |
| 1289 | + | avg_half = (sum(POLICY_VAULT_ALT_SPLIT_SATS) / len(POLICY_VAULT_ALT_SPLIT_SATS)) / SAT | |
| 1290 | + | for label, prof in POLICY_STAGE1A_PROFILES.items(): | |
| 1291 | + | m, cap_u, flt = prof["M"], prof["cap_user_btc"], prof["float_btc"] | |
| 1292 | + | v_per_d = m / cooldown_days | |
| 1293 | + | btc_per_d_multi = v_per_d * avg_multi | |
| 1294 | + | btc_per_d_half = v_per_d * avg_half | |
| 1295 | + | cont_multi = (cap_u - flt) / btc_per_d_multi | |
| 1296 | + | cont_half = (cap_u - flt) / btc_per_d_half | |
| 1297 | + | rem_v = int(round(cap_u / avg_multi)) - int(flt // avg_multi) | |
| 1298 | + | batch_multi = math.ceil(rem_v / m) * cooldown_days | |
| 1299 | + | if m == 3: | |
| 1300 | + | assert 101.0 <= cont_multi <= 102.0 and batch_multi == 104.0 and 67.0 <= cont_half <= 68.5 | |
| 1301 | + | if m == 5: | |
| 1302 | + | assert 93.0 <= cont_multi <= 94.5 and batch_multi == 104.0 and 62.0 <= cont_half <= 63.0 | |
| 1303 | + | print( | |
| 1304 | + | f" {label:28s}: {v_per_d:.3f} v/d ({btc_per_d_multi:.3f} BTC/d) | " | |
| 1305 | + | f"100% run=~{cont_multi:.1f}d (batch={batch_multi:.0f}d) [~{cont_half:.1f}d w/ {{0.50,0.50}}]" | |
| 1306 | + | ) | |
| 1307 | + | ||
| 1308 | + | # -------------------------------------------------------------------------- | |
| 1309 | + | # 10. K >= 18 UNPUBLISHED-FORK HEURISTIC & BUDISH SENSITIVITY (R8-H03) | |
| 1310 | + | # -------------------------------------------------------------------------- | |
| 1311 | + | print("\n=== 10. K >= 18 UNPUBLISHED-FORK HEURISTIC (Cap_user + M*B_zbtc) & BUDISH SENSITIVITY ===") | |
| 1312 | + | for cap_u, cap_tot in POLICY_TVL_TIERS_TOTAL_BTC.items(): | |
| 1313 | + | k_2024 = POLICY_CONFIGURED_K_BY_ERA["2024-2028"][cap_u] | |
| 1314 | + | assert k_2024 >= POLICY_K_MIN_FLOOR | |
| 1315 | + | row = [] | |
| 1316 | + | for era, sub in SOURCED_BTC_SUBSIDY_BY_ERA.items(): | |
| 1317 | + | k_min = max(POLICY_K_MIN_FLOOR, int(math.floor((2.0 * cap_tot) / sub)) + 1) | |
| 1318 | + | assert 0.50 * k_min * sub > cap_tot | |
| 1319 | + | if era in POLICY_CONFIGURED_K_BY_ERA: | |
| 1320 | + | k_cfg = POLICY_CONFIGURED_K_BY_ERA[era][cap_u] | |
| 1321 | + | assert k_cfg >= k_min and 0.50 * k_cfg * sub > cap_tot | |
| 1322 | + | row.append(f"{era}:K>={k_min}") | |
| 1323 | + | print(f" User={cap_u:3d} / Total={cap_tot:6.2f} BTC (2024 K={k_2024:3d}): " + " | ".join(row)) | |
| 1324 | + | # Print Budish winning-fork direct net flow-cost sensitivity at K=18, 2024-2028 (56.25 BTC nominal subsidy): | |
| 1325 | + | nom_k18 = 18 * SOURCED_BTC_SUBSIDY_BY_ERA["2024-2028"] | |
| 1326 | + | budish_str = " | ".join(f"kappa={int(k*100)}%:{k*nom_k18:.2f} BTC" for k in (0.05, 0.15, 0.30, 0.50)) | |
| 1327 | + | print(f" Budish winning-fork direct flow-cost @ K=18 (excl. BTC-price crash): {budish_str}") | |
| 1328 | + | ||
| 1329 | + | # -------------------------------------------------------------------------- | |
| 1330 | + | # 11. STAGE 1B (clArk) ALTERNATIVE GATE | |
| 1331 | + | # -------------------------------------------------------------------------- | |
| 1332 | + | print("\n=== 11. STAGE 1B (clArk) ALTERNATIVE GATE: LIQUIDITY & log2(N) BRANCH EXIT WEIGHTS ===") | |
| 1333 | + | clark_low, clark_high = PRE_MAINNET_TARGET_CLARK_ACTIVE_LIQ_BTC | |
| 1334 | + | assert clark_high < 14.75 | |
| 1335 | + | for n_vtxo in PRE_MAINNET_TARGET_CLARK_VTXO_COUNTS: | |
| 1336 | + | depth = int(math.log2(n_vtxo)) | |
| 1337 | + | total_vb = depth * 167.0 + 154.0 | |
| 1338 | + | assert total_vb < SOURCED_BIP431_TRUC_MAX_VB | |
| 1339 | + | print( | |
| 1340 | + | f" N={n_vtxo:4d} (depth={depth:2d}): exit={total_vb:6.0f} vB | " | |
| 1341 | + | f"@100={int(total_vb*100):,} sats | @500={int(total_vb*500):,} sats" | |
| 1342 | + | ) | |
| 1343 | + | ||
| 1344 | + | # -------------------------------------------------------------------------- | |
| 1345 | + | # 12. REAL 2,000-STEP STAGE 1A SIMULATION (V = C + L + E + R + A + B) | |
| 1346 | + | # -------------------------------------------------------------------------- | |
| 1347 | + | print("\n=== 12. REAL 2,000-STEP STAGE 1A SIMULATION (EXPLICIT A, TICKETS, k=20 GRIEF, REORGS) ===") | |
| 1348 | + | counts = run_stage1a_solvency_sim(seed=20261128, steps=2_000) | |
| 1349 | + | for k, v in counts.items(): | |
| 1350 | + | assert v > 0, f"Event type {k} was never exercised: {counts}" | |
| 1351 | + | assert counts["reorg_blocks_reverted"] >= counts["reorg"] > 0 and counts["reorg_events_reverted"] > 0 | |
| 1352 | + | print(" Bob, Mike, k=20 grief burst, TransferCredit, Ticket cap race & 2,000 adversarial steps PASSED V=C+L+E+R+A+B:") | |
| 1353 | + | print(" " + ", ".join(f"{k}={v}" for k, v in counts.items())) | |
| 1354 | + | print("\nALL v2 (v3.1.0-rfc R8-HARDENED ZERO-FEDERATION) CONSISTENCY, ERLANG, HALL, EV & SOLVENCY CHECKS PASSED.") | |
| 1215 | 1355 | ||
| 1216 | 1356 | ||
Attack this spec & submit feedback
This is a Public RFC updated to v2 (v3.1.0-rfc) in response to Consolidated Hostile Review R8 (redlining against archived v1 / v3.0.0-rfc). Humans and AI review agents are invited to run python3 -I scripts/verify_spec_bounds.py, inspect the v1 → v2 changelog & redlines, file findings, or open pull requests.