diff --git a/README.md b/README.md
index 128368d..437fb76 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@ Bulkhead is a small Solana program that holds a protocol's token accounts on the
**[The attack](#what-it-does-to-an-attack)** · **[How it works](#how-it-works)** · **[Verify it](#verify-it-yourself)** · **[Devnet](#live-on-devnet)** · **[FAQ](docs/FAQ.md)** · **[Docs](#documentation)**
-[](https://github.com/shuv-amp/bulkhead/actions/workflows/ci.yml) [](#live-on-devnet) [](docs/09-VERIFICATION.md) [](docs/09-VERIFICATION.md) [](SECURITY.md) [](LICENSE)
+[](https://github.com/shuv-amp/bulkhead/actions/workflows/ci.yml) [](#live-on-devnet) [](docs/09-VERIFICATION.md) [](docs/09-VERIFICATION.md) [](SECURITY.md) [](LICENSE)
@@ -165,7 +165,7 @@ These scripts install nothing. The core has zero dependencies, and Cloud and the
| Check | Result (latest run of each) |
|---|---|
-| **Programs on the real runtime**
LiteSVM, mainnet feature set, mainnet token program | **165/165**: every scenario (S1 Drift, S4 bank run, S7, S8, S9, S10 Floor), the negative tests, measured compute, and an account-substitution sweep of every instruction (7,075 swaps refused, 16 Oct) |
+| **Programs on the real runtime**
LiteSVM, mainnet feature set, mainnet token program | **172/172**: every scenario (S1 Drift, S4 bank run, S7, S8, S9, S10 Floor), the negative tests, measured compute, and an account-substitution sweep of every instruction (7,075 swaps refused, 16 Oct) |
| **Bounded proofs**
Kani, and exhaustive checks | **19/19 harnesses verified** on 16 Oct (16 for every value of their types), 240 s of verification ([`09 §5`](docs/09-VERIFICATION.md#5-bounded-proofs-kani-and-exhaustive-checks)). 6 exhaustive tests over ~584M inputs |
| **Differential**
an independent Python reference vs the Rust core | **6,943,561 lines identical** (6 seeds × 200k cases, 27 Sep); 33 commands now, 300k cases on every pull request and 3M weekly in CI |
| **Program vs model** | Random steps on-chain, every outcome equal to the core's prediction: 12,000 (Vault), 300,000 with random limits and every brake (Vault), 200,000 (Floor) |
@@ -175,7 +175,7 @@ These scripts install nothing. The core has zero dependencies, and Cloud and the
| **Golden vectors**
every worked example in the docs, exact boundaries, the abort binaries' bytes, loader layouts | 119/119 identical, Rust = Python |
| **End to end** | [Above](#what-it-does-to-an-attack) |
| **On devnet** | All three programs run the build of PR #85 (15 Oct; this tree's Floor and Vault add finding 107, not deployed yet), matched byte for byte against CI's build of that commit, upgrade authority checked. **S1 ran there on 1 Oct**: the admin key ordered 1.2M, 100,000 left, the guardian froze and cancelled the other 11. Floor S10 with real transactions: one guardian stops, two restore byte-identical, 17/17 forbidden actions refused ([below](#live-on-devnet)) |
-| **What this process found**
in our own code and docs | **109 findings**: real bugs, two overclaimed guarantees, test gaps, deploy-tooling hazards, and the attacks of adversarial reviews and audits. Each is fixed or stated ([`09 §4`](docs/09-VERIFICATION.md#4-what-this-process-found-every-item-fixed-or-stated)); 96–109 were recorded after the submission (107 is the engagement's AUD-2, decided 16 Oct): 96–99, 101 and 103 are fixed and run on devnet since 15 Oct; 105 (CI tooling), 106 and 108 (Vault tests), 107 (the guardian margin, not yet on devnet) and 109 (fuzz targets) are fixed; 100, 102 and 104 are stated. The Rust core and the Python reference shared one bug; only a third, independent statement of the rule caught it. |
+| **What this process found**
in our own code and docs | **110 findings**: real bugs, two overclaimed guarantees, test gaps, deploy-tooling hazards, and the attacks of adversarial reviews and audits. Each is fixed or stated ([`09 §4`](docs/09-VERIFICATION.md#4-what-this-process-found-every-item-fixed-or-stated)); 96–110 were recorded after the submission (107 is the engagement's AUD-2, decided 16 Oct): 96–99, 101 and 103 are fixed and run on devnet since 15 Oct; 105 (CI tooling), 106 and 108 (Vault tests), 107 (the guardian margin, not yet on devnet), 109 (fuzz targets) and 110 (Floor tests) are fixed; 100, 102 and 104 are stated. The Rust core and the Python reference shared one bug; only a third, independent statement of the rule caught it. |
## Live on devnet
diff --git a/docs/04-THREAT-MODEL.md b/docs/04-THREAT-MODEL.md
index c4d2f36..47915d8 100644
--- a/docs/04-THREAT-MODEL.md
+++ b/docs/04-THREAT-MODEL.md
@@ -71,7 +71,7 @@ A security product with a bug is worse than no product. This file lists every ad
| I12 | No token leaves a vault except release, settle, lifeboat | program-vs-model differential (vault balance equals the model after every step) |
| I13 | Releases fail before the seal | program `nothing_can_be_released_before_the_seal…` |
| I14 | `vault.queued_amount == Σ pending tickets` | program-vs-model differential, after every step |
-| I15 | Floor: no new binary before 72h unless a quorum approved that exact frozen buffer during a restore, or the snapshot is restored | 50 Floor tests on the real loader (`programs/tests/tests/floor.rs`) |
+| I15 | Floor: no new binary before 72h unless a quorum approved that exact frozen buffer during a restore, or the snapshot is restored | 57 Floor tests on the real loader (`programs/tests/tests/floor.rs`) |
| I16 | Python reference and Rust core agree on every input | diff (6,943,561 identical lines in the final 6-seed run; 36 fixtures with expected outputs) |
## 4. The #1 risk: a bug in Bulkhead itself
diff --git a/docs/09-VERIFICATION.md b/docs/09-VERIFICATION.md
index 63e3440..e4d56c5 100644
--- a/docs/09-VERIFICATION.md
+++ b/docs/09-VERIFICATION.md
@@ -31,7 +31,7 @@ The programs are checked against the core as a model (§7). Two implementations
| **Bounded proofs (Kani)** | 19 harnesses: logic at full width, 3 at small width (§5) | **19/19 verified** (16 Oct) |
| **Coverage-guided fuzzing** | 9 libFuzzer targets (`fuzz/`, cargo-fuzz, overflow checks and AddressSanitizer on): the Token-2022 mint policy, the token-account reader and the guardian-set parser Floor and the Vault share against independent statements of them; the Pyth `PriceUpdateV2` parser against the documented layout; load-store-load round trips of every Vault and Floor account; the loader-v3 parsers and snapshot identity; the limiter at full width (exact `available_now`, instant and queue rules, errors change nothing, window changes keep the used fraction); the ledger (backed ≤ requested, the same amount on a re-ask, `debit_backed` accepts it). Line coverage is measured (`cargo fuzz coverage`); seeds in `fuzz/seeds/` reach what a mutator rarely builds | 6 Oct: 10 min per target, 36M–277M executions each; one harness-oracle crash (finding 40), no program bug; every targeted parser at 100% of lines after the seeds (finding 41; but the same loader target never got past `elf_info`'s magic check in 417M runs on 17 Oct, below). That run had 8 targets; the guardian-set target came on 14 Oct. 17 Oct (`SECONDS_PER=1800 scripts/fuzz.sh`, all 9 targets at once): 30 min per target, 125M–440M executions each (the guardian-set target's 259M), no crash; the two targets changed after it (below) have run 120 s each since, no crash. Region coverage of that corpus (`llvm-cov`, measured by hand) found, among other missed regions, two parsers that their own target never fully ran. Line coverage hid one: the guardian-set target could not build an empty set (every line, 60 of 61 regions). The other is in the loader-parser target, which finding 41's change left decoding its input with `arbitrary` (that finding's cause) and without seeds: no input got past `elf_info`'s ELF magic check. After a fix to the guardian-set target, and the loader target moved to raw bytes with four ELF-header seeds, their corpora and seeds run `GuardianSet::parse` and `elf_info` at every line and region (`llvm-cov` after 120 s runs, 17 Oct); the loader target now catches a mutant (`elf_info` reading past a short header) within seconds, even unseeded, that 45M runs of the old one missed. It checks only `snapshot_matches`' result and runs the other parsers for panics only (`elf_info`'s values are checked by golden G-13 and the property and unit tests). The other regions the targets miss in the functions they call are not listed here in full: some are unreachable, and some are refusals no harness asks for, which the fuzzing does not test (a closed limiter lane: the target makes every capacity at least 1; a full ledger: the ledger target uses at most 4 distinct mints). No target calls `elf_extent`, `snapshot_restorable` (finding 88's length rule) or `is_canonical_abort`: unit tests and the core's mutation testing (§6) check them (`is_canonical_abort` also the differential's `FC` command), the fuzzer does not. CI: 60 s per target (25 min weekly, §8) |
| **Mutation testing** | `cargo-mutants` on the core: 797 mutants (run 10, §6), and in CI on every pull request's changed lines | Every non-equivalent mutant killed; 22 equivalents, each explained and excluded by exact pattern |
-| **Program tests** | Floor (50) and Vault (115) on the real agave runtime: LiteSVM, mainnet feature set, the mainnet token program | 165/165 |
+| **Program tests** | Floor (57) and Vault (115) on the real agave runtime: LiteSVM, mainnet feature set, the mainnet token program | 172/172 |
| **Account substitution** (`programs/tests/tests/common/sweep.rs`) | For every Vault and Floor instruction (all 30 of the Vault's, tags 0–29, including the read-only views `attest` and `quote_release` and both scopes of `unfreeze`; registration both by the caller PDA and by the upgrade authority; the Floor lifecycle end to end): a transaction that succeeds, then each account swapped in turn for a fresh address, every other account of the transaction, a second market's or a second protected program's accounts, a stranger's token accounts and buffers, other tickets, programs and sysvars, and for a signer every other known key; then each key that signs at any slot (a free one included) and stands at a checked slot: unsigned at every checked slot (a free slot where it signed gets the payer, once a control shows the payer is accepted there; not for the fee payer, which signs anyway), since signing is per key and unsigning one slot of a key that signs at another proves nothing. A key at several slots is otherwise swapped one slot at a time, so a check that only compares those slots with each other is not tested by a consistent attacker key at all of them. Every swap must fail, except at the positions each program leaves free on purpose, each listed with its reason (a rent payer, a ticket account only used when part of a release queues, another guardian of the same set). The first version missed two of four bugs planted to test it (a settle that pays anyone, a cancel of another vault's ticket): it had no look-alike token account or ticket to offer. With them, all four are caught | 16 Oct, with four guardians in the test sets (finding 107; an eject's signers may now be any two of the three others, so each of those slots is free for the third, never for the target or the other signer again; with a guardian listed twice counted as two, the sweep fails): 5,365 Vault and 1,710 Floor substitutions (37 and 18 transactions), refused. 16 Oct, with `attest`, `quote_release` (read-only accounts, quoting an owner's own deposit; as in every release here, the price slot is left free) and the vault-scope `unfreeze`: 5,308 Vault and 1,683 Floor substitutions (37 and 18 transactions), refused. Each of three one-site mutants fails the sweep and passes without those three runs: `attest` not checking its token account, a quote skipping the vault-account check a release makes, and the vault-scope `unfreeze` loading a vault without checking its protocol. 16 Oct, with signing keys tried per key (before, a key that signs at two slots was never tried unsigned: the user of Harbor's deposit and withdraw; with the withdraw's signer check deleted, the sweep now fails): 4,887 Vault and 1,683 Floor substitutions (34 and 18 transactions; one of the 34, "withdraw (signed at the free slot only)", repeats Harbor's withdrawal with the user signing only at a free slot, which adds no program coverage; the test checks that the user was tried unsigned there, so it fails if the sweep stops picking such a key), refused. 10 Oct, with a release to none signed by the owner (finding 95; with that check deleted, the sweep accepts the owner unsigned and fails): 4,499 Vault and 1,683 Floor substitutions (33 and 18 transactions), refused (9 Oct, with `close_buffer`, the signing release and the exit's account 6: 4,508 and 1,549; 8 Oct: 4,474 and 1,472). Found finding 53. Accepted and explained: a veto of a lifeboat exit where none is pending changes nothing (the next proposal clears it) |
| **Program ↔ model differential** | Random operation sequences on-chain vs a host model built only from the core; invariants after every step (§7) | 12,000 steps across 24 seeds, identical; 24,000 steps across 24 seeds after the A1 fix (29 Sep), identical |
| **Wide program differential** | The same, with a limit configuration drawn per seed (floors and caps far above the balance, a closed lane, a queue delay past the horizon) and every instruction that changes what can leave: protocol and vault freezes, quorum unfreezes, ticket extensions, backlog resets, lifeboat moves both ways, limit changes; `quote_release` against the release, every `attest` field against the core (§7) | 5 Oct: 200,000 steps across 400 configurations, then 100,000 with limit changes after finding 30, identical |
@@ -84,7 +84,7 @@ scripts/mutants.sh # mutation testing, release profile (~45
scripts/fuzz.sh # libFuzzer, every target 60 s in parallel (SECONDS_PER=600 for longer)
(cd fuzz && cargo clippy --all-targets -- -D warnings) # lint the fuzz crate (its own workspace; CI's fuzz job)
scripts/build-programs.sh # Floor, Vault, Harbor for sBPF v3; checks e_flags == 3
-(cd programs/tests && cargo test --release) # 165 program tests + the program-vs-model differentials
+(cd programs/tests && cargo test --release) # 172 program tests + the program-vs-model differentials
(cd programs/tests && BULKHEAD_PROGRAM_SEEDS=24 BULKHEAD_PROGRAM_STEPS=500 cargo test --release --test differential)
cloud/e2e/run.sh # validator + guardian + attacker
node --test cloud/test/*.test.mjs # client, policy, JS vs Python vs Rust differential (needs the worker)
@@ -213,6 +213,7 @@ cloud/e2e/s1.sh # S1 with the guardian on any
| 107 | 9 Oct | `16` AUD-2 (the pre-audit engagement; stated in finding 89 as a decision left to the team), researched on 15 Oct with an exhaustive model of the eject and veto rules and LiteSVM runs of the lock (scratch, not kept), decided by the owner on 16 Oct (`16` §4.4) | **One lost key and one rogue guardian locked a 2-of-3 set for good.** A set is live while its honest live guardians reach the threshold: they then eject every rogue in turn, and the owner's new set passes, since dead guardians cannot veto. Finding 96 required one key beyond the threshold, so a 2-of-3 (or 3-of-4) set survived one fault but not a lost key plus a rogue: the honest guardian left was no quorum, nobody could be ejected, and the rogue kept Floor stopped (or the Vault frozen, renewed daily) and vetoed every RESTORE, SetGuardians and release as it was proposed. Own deposits still left (G2). The same held after an ejection had used up the one spare key. No rule that lets the owner override a veto avoids this without also handing a stolen owner key plus one rogue guardian the set (`16` §4.4). | Fixed (on-chain, Floor and Vault; not yet on devnet). `guardian_set_ok` now needs `count ≥ threshold + GUARDIAN_MARGIN` with a margin of 2: at least 4 keys, 2 ≤ threshold ≤ count − 2. Both programs check every new set with it, at registration and when a SetGuardians is proposed and again when it executes; a stored set is never checked again, so existing 2-of-3 sets keep working (and keep their exposure) until their owner replaces them, and an ejection may still shrink a set. Ejection is unchanged. Kani: `accepted_sets_survive_any_two_faults` (any two faulty keys in any slots leave a live honest quorum, which ejects each rogue, and the rogues alone eject no honest guardian; short of a rogue quorum, since two rogues in a 2-of-n set are one, out of scope by `04` T7, and without that assumption the harness fails), `an_honest_live_quorum_ejects_any_rogue` (such a quorum ejects every rogue, wherever the slots sit), and `accepted_sets_can_eject_anyone` restated (ejection reachable exactly when count > threshold, so a shrunk set still ejects; the margin is at least 2, and 2 is accepted). Mutants of the rule (margin 1 or 3, `>`, threshold ≥ 1, count ≤ 9, and refusing an eject that leaves count ≤ threshold + 1, an option `16` §4.4 rejects) and an eject one vote short each fail a harness; an eject that ignores liveness fails none of these three. Tests: `a_guardian_set_without_two_spare_keys_is_refused` (Floor and Vault; the execution check on a stored proposal), `registration_rejects_weak_settings` (Floor); the recovery on 2-of-4: `a_lost_key_and_a_rogue_do_not_lock_a_two_of_four_set`, `two_rogues_in_turn_are_both_ejected_from_a_two_of_four_set`, `a_lost_key_and_a_rogue_do_not_lock_a_two_of_four_vault`. The Python model and the `guardian_set` fuzz target state the new rule; with the model's margin put back to 1, the `GP` differential diverges on each of seeds 11–13 (20,000 cases). |
| 108 | 16 Oct | Finding 106's follow-up: 38 Vault refusals, across 14 of the 18 codes no program test asserted by value, deleted one at a time with the whole program suite run against each, on the AUD-2 build (§3, "Vault refusals deleted one at a time"; `Overflow` and `LedgerCorrupt` not deleted) | **25 of 38 Vault refusals survived deletion.** Finding 106's class: rules enforced but untested. Among them: another protocol's guardian extending a ticket, a seal that leaves a vault out, invalid limits and assets in a proposed change, an import into a ninth mint, and a quote to an account no token program owns. The run missed two codes; the review deleted one check of each, and both also survived: the 7-day total on a ticket's extensions (`brakes.rs:86`, `05` row 11) and a closed lane's code (`custody.rs:240`). | Fixed (tests; the programs are unchanged). 18 of the 25 and the review's two now fail a test that asserts the Vault's own code (among them `an_import_into_a_ninth_mint_is_refused`, `invalid_limits_and_assets_are_refused_wherever_they_enter`, `a_ticket_is_extended_later_by_at_most_a_day_a_call_and_seven_in_total`, `a_closed_lane_refuses_an_unbacked_payout`). Stated: six of the other 7 guard states no transaction is known to reach; the seventh (`custody.rs:399`) is not shown unreachable, only argued from a property test. Each is in the §3 row. |
| 109 | 17 Oct | Region coverage (`cargo fuzz coverage`, `llvm-cov`) of the corpus of a 30-minute run of every fuzz target, measured by hand (§2) | **Two fuzz targets never fully ran the parser they exist for.** The guardian-set target skipped inputs under 66 bytes, so it never parsed an empty set: `GuardianSet::parse` ran at every line but 60 of 61 regions, and a mutant of its empty-set error (`governance.rs:192`) passed 23M runs. The loader-parser target, which finding 41's change left decoding its input with `arbitrary` (that finding's cause) and without seeds, never got past `elf_info`'s ELF magic check in 417M runs, and missed a mutant reading past a short header in 45M. Line coverage hid the first; the second sits under §2's 6 Oct "every targeted parser at 100% of lines" (that corpus is not kept, so whether the 6 Oct run got past the check is not known). No target calls `elf_extent`, `snapshot_restorable` or `is_canonical_abort`. | Fixed (fuzz targets; the core and programs are unchanged). The guardian-set target accepts a 65-byte input, the flags and two forbidden keys with an empty set after them (and has a seed of one); the loader target takes raw bytes with four ELF-header seeds. Both parsers now run at every line and region, and each mutant fails within seconds (the short-header one unseeded too). Stated: `elf_extent`, `snapshot_restorable` and `is_canonical_abort` stay unfuzzed; unit tests and the core's mutation testing check them (§2). |
+| 110 | 16 Oct | Finding 108's sibling for Floor: every place that returns one of the 14 Floor codes no program test asserted by value, 34 in all, deleted one at a time with the whole program suite run against each, on the AUD-2 build (§3, "Floor refusals deleted one at a time") | **24 of 34 Floor refusals survived deletion.** Finding 106's class: rules enforced but untested. Among them: a copy of a program's config under another owner, which would let a stranger close the real abort buffer and take its rent, so that every stop fails until a live quorum stages another (`lib.rs:179`); an account Floor owns but never wrote, which anyone can create (`state.rs:132`); a pin of a buffer the loader does not own (`loader.rs:14`); and a registration of another team's program with the registrant's own programdata (`register.rs:63`). The other 10 failed only the substitution sweep or the random differential, which do not check the code. | Fixed (tests; the programs are unchanged). 15 of the 24 now fail a test that asserts Floor's own code (among them `floor_reads_only_a_config_it_wrote_and_a_buffer_the_loader_owns` and `registration_reads_only_the_programs_own_programdata`), and so do the 10 that failed only the sweep or the differential. Stated: the other 9 of the 24 guard states no transaction is known to reach, and the programdata clause of `register.rs:57` is covered only jointly with `:63`. Each is in the §3 row. |
Same review, not changed then: the guardian-set checks were written once in each program. Since PR #83 (finding 103), both use one `GuardianSet` in the core, covered by the `guardian_set` fuzz target, the `GP` differential and unit tests (its bitmaps are Kani-proved; a Kani proof of the parser did not finish, §5.3). `Change` payloads are now copied in one slice instead of byte by byte (fewer compute units), and the Ticket layout comment names the real seeds.
@@ -367,6 +368,7 @@ The overflow guards stay in the code as defense in depth; the tests document why
| **Scenarios** | S1 (G-1 second-for-second, including the EMA reference), S4 (a 20-depositor bank run during a freeze, 100% instant, no prices), S7, S8 (ten payouts in one transaction), S9 (backed exactly as the core computes), S10 (Floor lifecycle) | Pass |
| **Negative tests** | Wrong caller, missing or foreign asset account, wrong feed, frozen settlement, early settlement, wrong recipient, tickets pending, not sealed, import exceeding balance, seal veto, permanent-delegate mint, delay below 72h, abdicated kind, freeze too long, no quorum, admin unfreeze, eject below threshold, and Floor's full set (`06 §6`) | Pass |
| **Vault refusals deleted one at a time** | 16 Oct, on the AUD-2 build: 38 refusals, across 14 of the 18 Vault codes no test asserted by value, deleted one at a time with the whole program suite run against each. Not deleted: the two places that map a core error to `ChangeExecuted` and `ZeroAmount`, `token.rs:233`, and two of the codes, `Overflow` and `LedgerCorrupt` (checked arithmetic, decoding). The other two, `ExtensionTooLong` and `LaneClosed`, the run missed; the review deleted one check of each: the 7-day total on a ticket's extensions (`brakes.rs:86`) and the mapping of a closed lane (`custody.rs:240`) | 13 failed a test, 25 survived. 18 of the 25 survivors now fail a test that asserts the Vault's own code. Among them: another protocol's guardian extending a ticket, a seal that leaves a vault out, invalid limits and assets in a proposed change, an import into a ninth mint, and a quote to an account no token program owns. The review's two also survived, and both now fail such a test: the 7-day total (docs/05 row 11), which the wide differential modelled but whose default run never extended one ticket that far (later the same day the default run was changed to push tickets to the total and 1 s past it), and a closed lane's code; the same tests pin an extension that moves the ETA earlier, one over 24h, and a lane closed by either bucket. Of the 25's other 7, six are guards no transaction is known to reach: the vault PDA address (`lib.rs:324`; `create_vault` creates a vault only at its PDA), the seal's checks of a lifeboat's owner, mint and authority (`genesis.rs:519`, `:523`; at the seal no lifeboat holds data: only `lifeboat_move` creates one, `move_in` requires the seal (`lifeboat.rs:53`), and the seal happens once), a pending-ticket count below zero (`brakes.rs:50`, `custody.rs:541`; each ticket adds one when created and is closed once), and `GetAccountDataSize`'s return data from an already-checked token program (`token.rs:235`). The seventh, `custody.rs:399` (`debit_backed` of what `backed_amount` allowed, or less after the consent and freeze caps), is **not shown unreachable**: the core property test debits `backed_amount` itself and one more on random ledgers; less is debited only on a one-mint ledger with no liability (`crates/bulkhead-core/tests/units.rs:375`). `backed_amount_is_monotone_in_request` (`properties.rs:606`) asserts `backed(a) == min(a, backed(MAX))` on random ledgers and requests below 2^52 (`:613`), so any amount up to what `backed_amount` allowed is itself backed, and `debit_backed(b)` refuses only when `backed_amount(b) != b` (`ledger.rs:289`) or a new slot would be needed on a full ledger, which `backed_amount` refuses first (`ledger.rs:237`). That is an argument from a property test, not a proof. The one known exception is a collateral value that overflows u128 (`ledger.rs:262`): there the valid amounts need not form an interval, so the consent or freeze cap (`custody.rs:337`, `:347`) can lower the amount to one that is not valid, and `:399` refuses the release (fail closed). The search's own result is always valid: it keeps only amounts it has checked. Five codes no test asserts by value remain: `NotRegistrar` (its one check fails another test), `TicketNotPending` and `LedgerUnsound` (the survivors above), `Overflow` and `LedgerCorrupt` |
+| **Floor refusals deleted one at a time** | 16 Oct, on the AUD-2 build: every place that returns one of the 14 Floor codes no test asserted by value, 34 in all, each removed on its own with the whole program suite run against it: a `return Err` dropped, a checked value's `?` replaced by a default (`proposals.rs:120`, `:443`), a match arm's error made a success (`:245`), and where the code is a value that cannot be dropped (`register.rs:69`, the interval mapping `guardians.rs:49`), changed to another code. Not deleted: the calls of the two shared checks, `check_program_accounts` and `check_authority`; only their returns were (`loader.rs:141`, `lib.rs:200`) | 10 failed a test, but only the substitution sweep or the random differential, which check that a step fails and not with which code; each now also fails a test that asserts it. 24 survived, and 15 of those now fail a test that asserts Floor's own code. Among them: a copy of a config under another owner, which would let a stranger close the real abort buffer (`lib.rs:179`), an account Floor owns but never wrote, which anyone can create (`state.rs:132`), a pin of a buffer the loader does not own (`loader.rs:14`), and a registration of another team's program with the registrant's own programdata, which would take that program's config address (`register.rs:63`). A programdata without a header (`register.rs:69`) is reached in one transaction by the program's upgrade authority: a loader Close of the programdata, then the registration, while the closed programdata is still the loader's and the program still names it. Of `register.rs:57`, only the program clause is pinned alone: the programdata clause is covered jointly with `:63`, since a program the loader owns names its own programdata. The other 9 are guards no transaction is known to reach: a config's stored bounds (`state.rs:174`) and its length when stored (`:181`; Floor creates an account only at registration, at the config's length, and stores only checked values), a second registration (`register.rs:88`; Floor holds the upgrade key, so `:70` refuses it first, and a release closes the config as it hands the key back), the proposal id and a lamport sum overflowing (`proposals.rs:120`, `:443`), an unknown kind at execution (`:245`, `:496`; `propose` refuses it, `:104`), and an upgrade executed while stopped or a restore while live (`:273`, `:278`; each is proposed only in the other state, `:68`, `:73`, and every change of state clears the owner's proposal, `stop.rs:176`, `:252`, `proposals.rs:317`; the recovery key proposes only a new owner or recovery key, `proposals.rs:28`). Two codes no test asserts by value remain, each returned only by one of these 9: `AlreadyRegistered` (`register.rs:88`) and `Overflow` (`proposals.rs:120`, `:443`) |
| **Floor on a real program** | `scripts/floor-demo.sh `: a mainnet program's bytes on a local validator with mainnet's feature set; register, stop with one guardian, restore with two | SPL Stake Pool (1.08 MB, v0): stopped with Floor's code, restored byte-identical (`06 §7`) |
| **Our own SIMD-0500 check** | `scripts/build-programs.sh` reads each built `.so` with the reference's `elf_info` and fails unless `e_flags == 3` | Floor, Vault, Harbor: v3 |
| **Compute** | Measured through Harbor's CPI (`05 §10`) and for Floor (`06 §7`) | Within targets |
diff --git a/docs/12-SUBMISSION.md b/docs/12-SUBMISSION.md
index c1c4f89..a3f6e00 100644
--- a/docs/12-SUBMISSION.md
+++ b/docs/12-SUBMISSION.md
@@ -19,7 +19,7 @@ Bulkhead was submitted to the Colosseum Crypto World's Fair (Solana track) on 12
| Floor on a real 1 MB mainnet program's bytes | `scripts/floor-demo.sh ` (`06 §7`) |
| The attacker-vs-guardian run, end to end | `E2E=1 scripts/check-programs.sh` |
| Every test, proof and differential result | `09`; `scripts/check.sh`, `scripts/check-programs.sh`, `scripts/prove.sh` |
-| Every bug the process found in our own code | `09 §4` (95 findings at submission; 96–109 recorded 13–17 Oct: 96–99, 101 and 103 fixed and on devnet since 15 Oct, 105 fixed (CI tooling), 106 and 108 fixed (Vault tests), 107 fixed (AUD-2, the guardian margin; not yet on devnet), 109 fixed (fuzz targets), 100, 102 and 104 stated); `16` |
+| Every bug the process found in our own code | `09 §4` (95 findings at submission; 96–110 recorded 13–17 Oct: 96–99, 101 and 103 fixed and on devnet since 15 Oct, 105 fixed (CI tooling), 106 and 108 fixed (Vault tests), 107 fixed (AUD-2, the guardian margin; not yet on devnet), 109 fixed (fuzz targets), 110 fixed (Floor tests), 100, 102 and 104 stated); `16` |
| Every number's source and label (measured, reported, model, assumption) | `01`, `13` |
## 3. Go-to-market
diff --git a/programs/tests/tests/common/mod.rs b/programs/tests/tests/common/mod.rs
index 430f524..51daff9 100644
--- a/programs/tests/tests/common/mod.rs
+++ b/programs/tests/tests/common/mod.rs
@@ -32,9 +32,15 @@ pub const T0: i64 = 1_790_000_000; // a fixed start time (Sep 2026)
/// Floor error codes (programs/floor/src/error.rs), checked by the tests.
pub mod err {
pub const INVALID_INSTRUCTION: u32 = 7000;
+ pub const NOT_A_FLOOR_CONFIG: u32 = 7001;
+ pub const WRONG_CONFIG_ADDRESS: u32 = 7002;
+ pub const WRONG_AUTHORITY_ADDRESS: u32 = 7003;
+ pub const NOT_LOADER_V3: u32 = 7005;
+ pub const PROGRAM_MISMATCH: u32 = 7006;
pub const NOT_CURRENT_AUTHORITY: u32 = 7007;
pub const INVALID_GUARDIANS: u32 = 7008;
pub const INVALID_THRESHOLD: u32 = 7009;
+ pub const INVALID_INTERVAL: u32 = 7010;
pub const INVALID_DELAY: u32 = 7011;
pub const MISSING_SIGNATURE: u32 = 7012;
pub const NOT_OWNER: u32 = 7013;
@@ -51,10 +57,13 @@ pub mod err {
pub const NO_VALID_SNAPSHOT: u32 = 7024;
pub const PROPOSAL_PENDING: u32 = 7025;
pub const NO_PROPOSAL: u32 = 7026;
+ pub const WRONG_PROPOSAL_KIND: u32 = 7027;
pub const NOT_EXECUTABLE: u32 = 7028;
pub const VETOED: u32 = 7029;
pub const EXPIRED: u32 = 7030;
pub const CANNOT_EJECT: u32 = 7031;
+ pub const WRONG_SYSVAR: u32 = 7032;
+ pub const WRONG_PROGRAM: u32 = 7033;
pub const ABORT_DOES_NOT_FIT: u32 = 7035;
pub const BUFFER_IN_USE: u32 = 7036;
pub const WRONG_ACCOUNT: u32 = 7037;
diff --git a/programs/tests/tests/floor.rs b/programs/tests/tests/floor.rs
index 11f48e0..d6f0b7c 100644
--- a/programs/tests/tests/floor.rs
+++ b/programs/tests/tests/floor.rs
@@ -440,10 +440,25 @@ fn registration_rejects_weak_settings() {
f.register(&pay, &team.pubkey(), &owner, &[a], 1, 7 * DAY, 3 * DAY),
err::INVALID_GUARDIANS,
),
+ // Heartbeats every 1 to 30 days.
+ (
+ f.register(&pay, &team.pubkey(), &owner, &[a, b, c, d], 2, DAY - 1, 3 * DAY),
+ err::INVALID_INTERVAL,
+ ),
+ (
+ f.register(&pay, &team.pubkey(), &owner, &[a, b, c, d], 2, 30 * DAY + 1, 3 * DAY),
+ err::INVALID_INTERVAL,
+ ),
];
for (ix, code) in cases {
assert_eq!(env.fails(&[ix], &[&team]), code);
}
+ // Each heartbeat bound itself is accepted.
+ for interval in [DAY, 30 * DAY] {
+ let (program, _) = env.deploy(&honest_v1(), &team, 1024);
+ let ix = Floor::new(env.floor, program).register(&pay, &team.pubkey(), &owner, &[a, b, c, d], 2, interval, 3 * DAY);
+ env.ok(&[ix], &[&team]);
+ }
}
#[test]
@@ -1711,3 +1726,310 @@ fn the_config_layout_matches_what_off_chain_readers_decode() {
assert_eq!((k(852), d[884]), (c.recovery, c.pending_by_recovery));
}
}
+
+/// A copy of `real`'s account at a fresh address, under `owner`, with `edit`
+/// applied to its data. Never executable: only a loader may own an executable
+/// account.
+fn copy_under(
+ env: &mut Env,
+ real: &solana_address::Address,
+ owner: solana_address::Address,
+ edit: impl FnOnce(&mut Vec),
+) -> solana_address::Address {
+ let mut a = env.account(real);
+ a.owner = owner;
+ a.executable = false;
+ edit(&mut a.data);
+ let at = solana_address::Address::new_unique();
+ env.svm.set_account(at, a).unwrap();
+ at
+}
+
+/// Floor trusts a config only if Floor owns it and wrote it, and a buffer
+/// only if the loader owns it. A copy of either under another owner is
+/// refused, whatever its bytes say. `close_buffer` never writes the config
+/// it reads, so without the owner check a copy naming a stranger as the
+/// owner, with no abort buffer staged, would let that stranger close the real
+/// abort buffer, which is frozen to the real Floor authority, and take its
+/// rent. The real config would still name the closed buffer, so every stop
+/// would fail until a live quorum staged another. And anyone can create an
+/// account Floor owns (the system program assigns it without Floor), so a
+/// config Floor owns must also carry Floor's discriminator.
+#[test]
+fn floor_reads_only_a_config_it_wrote_and_a_buffer_the_loader_owns() {
+ let mut env = Env::new();
+ let p = protect(&mut env, &honest_v1());
+ let f = &p.f;
+ let thief = Keypair::new();
+ env.fund(&thief);
+ let forged = copy_under(&mut env, &f.config, solana_address::Address::new_unique(), |d| {
+ let mut c = bulkhead_floor::Config::load(d).unwrap();
+ c.owner = thief.pubkey().to_bytes();
+ c.abort_buffer = [0; 32];
+ c.store(d).unwrap();
+ });
+ let mut close = f.close_buffer(&thief.pubkey(), &p.abort_buffer);
+ close.accounts[0].pubkey = forged;
+ assert_eq!(env.fails(&[close], &[&thief]), err::NOT_A_FLOOR_CONFIG);
+
+ // A zero-filled account of a config's length, created for Floor by a
+ // stranger's own CreateAccount.
+ let blank = Keypair::new();
+ let len = env.account(&f.config).data.len();
+ let rent = env.svm.minimum_balance_for_rent_exemption(len);
+ let create = solana_system_interface::instruction::create_account(&thief.pubkey(), &blank.pubkey(), rent, len as u64, &env.floor);
+ env.ok(&[create], &[&thief, &blank]);
+ let mut beat = f.heartbeat(&p.g[0].pubkey());
+ beat.accounts[0].pubkey = blank.pubkey();
+ assert_eq!(env.fails(&[beat], &[&p.g[0]]), err::NOT_A_FLOOR_CONFIG);
+
+ // A byte-identical copy of the pinned snapshot, under its writer: the
+ // loader could never install it, so a stop naming it could not restore.
+ let fake_pin = copy_under(&mut env, &p.snapshot, thief.pubkey(), |_| {});
+ assert_eq!(env.fails(&[f.pin_snapshot(&fake_pin)], &[]), err::NOT_LOADER_V3);
+}
+
+/// Registration takes the upgrade authority from the programdata the program
+/// itself names (register.rs:63). Without that, a thief naming their own
+/// programdata, of which they hold the key, would take the config address of
+/// another team's program, and that team could never register it. The program
+/// must also be the loader's (:57): a program account the thief wrote, at an
+/// address of their own, could name the thief's programdata, and Floor would
+/// hold a config for a program the loader never deployed. The team's own
+/// config address is not at risk from that. The programdata half of :57 is
+/// covered only jointly with :63: a program the loader owns names its own
+/// programdata, which the loader owns too. And the programdata must still
+/// have its header (:69): the loader's Close leaves a closed programdata
+/// loader-owned until its transaction ends.
+#[test]
+fn registration_reads_only_the_programs_own_programdata() {
+ let mut env = Env::new();
+ let team = Keypair::new();
+ env.fund(&team);
+ let (program, programdata) = env.deploy(&honest_v1(), &team, 2048);
+ let thief = Keypair::new();
+ env.fund(&thief);
+ let (_, thiefs_programdata) = env.deploy(&honest_v1(), &thief, 2048);
+ let gs = [Keypair::new().pubkey(), Keypair::new().pubkey(), Keypair::new().pubkey(), Keypair::new().pubkey()];
+ let pay = env.payer.pubkey();
+
+ let f = Floor::new(env.floor, program);
+ let mut theirs = f.register(&pay, &thief.pubkey(), &thief.pubkey(), &gs, 2, 7 * DAY, 3 * DAY);
+ theirs.accounts[4].pubkey = thiefs_programdata;
+ assert_eq!(env.fails(&[theirs], &[&thief]), err::PROGRAM_MISMATCH);
+
+ // A copy of the team's program account, under an owner that is not the
+ // loader, naming the thief's real programdata.
+ let fake_program = copy_under(&mut env, &program, thief.pubkey(), |d| {
+ d[4..36].copy_from_slice(thiefs_programdata.as_ref())
+ });
+ let g = Floor::new(env.floor, fake_program);
+ let mut forged = g.register(&pay, &thief.pubkey(), &thief.pubkey(), &gs, 2, 7 * DAY, 3 * DAY);
+ forged.accounts[4].pubkey = thiefs_programdata;
+ assert_eq!(env.fails(&[forged], &[&thief]), err::NOT_LOADER_V3);
+
+ // The team closes its programdata and registers, in one transaction.
+ // Until the transaction ends the closed programdata is still the
+ // loader's and the program still names it, so :57 and :63 pass; it has
+ // no header left, and :69 refuses. Both forms of the close (SIMD-0432:
+ // the program account reclaimed or tombstoned). The failed transaction
+ // undoes the close.
+ for tombstone in [false, true] {
+ let close = solana_loader_v3_interface::instruction::close_any(
+ &programdata,
+ &pay,
+ Some(&team.pubkey()),
+ Some(&program),
+ tombstone,
+ );
+ let reg = f.register(&pay, &team.pubkey(), &team.pubkey(), &gs, 2, 7 * DAY, 3 * DAY);
+ let e = env.send(&[close, reg], &[&team]).map(|_| ()).unwrap_err();
+ assert_eq!(
+ e.err,
+ solana_transaction_error::TransactionError::InstructionError(
+ 1,
+ solana_instruction_error::InstructionError::Custom(err::PROGRAM_MISMATCH)
+ ),
+ "tombstone {tombstone}:\n{}",
+ e.meta.logs.join("\n")
+ );
+ }
+
+ // The team registers its program.
+ env.ok(&[f.register(&pay, &team.pubkey(), &team.pubkey(), &gs, 2, 7 * DAY, 3 * DAY)], &[&team]);
+ assert_eq!(env.upgrade_authority(&programdata), Some(f.authority.to_bytes()));
+}
+
+/// A registration names the real system program, and is refused with Floor's
+/// own code if it does not. Without the check the CPI to the system program
+/// would still fail, with no code saying why.
+#[test]
+fn registration_names_the_system_program() {
+ let mut env = Env::new();
+ let team = Keypair::new();
+ env.fund(&team);
+ let (program, _) = env.deploy(&honest_v1(), &team, 2048);
+ let f = Floor::new(env.floor, program);
+ let gs = [Keypair::new().pubkey(), Keypair::new().pubkey(), Keypair::new().pubkey(), Keypair::new().pubkey()];
+ let reg = f.register(&env.payer.pubkey(), &team.pubkey(), &team.pubkey(), &gs, 2, 7 * DAY, 3 * DAY);
+ let mut no_system = reg.clone();
+ no_system.accounts[6].pubkey = solana_address::Address::new_unique();
+ assert_eq!(env.fails(&[no_system], &[&team]), err::WRONG_PROGRAM);
+ env.ok(&[reg], &[&team]);
+}
+
+/// A stop names its own program, the real sysvars and its own Floor
+/// authority, and each is refused with Floor's code. Without these checks
+/// the loader would still refuse the upgrade, with no code saying which
+/// account was wrong.
+#[test]
+fn a_stop_names_its_own_program_sysvars_and_authority() {
+ let mut env = Env::new();
+ let p = protect(&mut env, &honest_v1());
+ let q = protect(&mut env, &honest_fix());
+ let (f, g0) = (&p.f, p.g[0].pubkey());
+ // Accounts: 2 programdata, 3 program, 6 rent, 7 clock, 8 authority.
+ let stop = || f.abort(&g0, &p.abort_buffer, Some(&p.snapshot));
+ // Each of the pair on its own (loader.rs:140 checks both).
+ for at in [2, 3] {
+ let mut other_program = stop();
+ other_program.accounts[at].pubkey = [q.f.programdata, q.f.program][at - 2];
+ assert_eq!(env.fails(&[other_program], &[&p.g[0]]), err::PROGRAM_MISMATCH);
+ }
+ let mut other_authority = stop();
+ other_authority.accounts[8].pubkey = q.f.authority;
+ assert_eq!(env.fails(&[other_authority], &[&p.g[0]]), err::WRONG_AUTHORITY_ADDRESS);
+ for (at, other) in [(6, CLOCK), (7, RENT)] {
+ let mut wrong_sysvar = stop();
+ wrong_sysvar.accounts[at].pubkey = other;
+ assert_eq!(env.fails(&[wrong_sysvar], &[&p.g[0]]), err::WRONG_SYSVAR);
+ }
+ env.ok(&[stop()], &[&p.g[0]]);
+ stopped_with_floor_code(&mut env, &f.program);
+ assert_eq!(env.call(&q.f.program).map(|_| ()), Ok(()), "the other program still runs");
+}
+
+/// A quorum restore needs a stop, and a stop needs a staged abort buffer,
+/// each refused with its own code. Without the first, a restore while live
+/// is still refused (no snapshot is valid while live). Without the second, a
+/// stop naming a used-up buffer is still refused (it is not the staged one),
+/// but one naming the all-zero address, which equals the empty slot, gets as
+/// far as the loader.
+#[test]
+fn a_restore_needs_a_stop_and_a_stop_needs_an_abort_buffer() {
+ let mut env = Env::new();
+ let p = protect(&mut env, &honest_v1());
+ let (f, gs) = (&p.f, p.guardians());
+ let restore = f.restore_snapshot(&p.snapshot, &p.owner.pubkey(), &gs[0..2]);
+ assert_eq!(env.fails(std::slice::from_ref(&restore), &[&p.g[0], &p.g[1]]), err::NOT_ABORTED);
+ env.ok(&[f.abort(&gs[0], &p.abort_buffer, Some(&p.snapshot))], &[&p.g[0]]);
+ env.next_slot();
+ env.ok(&[restore], &[&p.g[0], &p.g[1]]);
+ env.next_slot();
+ // The stop used the abort buffer up, and nobody has staged another.
+ assert_eq!(read_config(&env, f).abort_buffer, [0; 32]);
+ let empty_slot = solana_address::Address::default();
+ for buffer in [empty_slot, p.abort_buffer] {
+ assert_eq!(env.fails(&[f.abort(&gs[0], &buffer, None)], &[&p.g[0]]), err::NO_ABORT_BUFFER);
+ }
+}
+
+/// A proposal is of a kind Floor knows, and a release names its own
+/// programdata. Without the first check an unknown kind would hold the
+/// proposal slot until cancelled; without the second the loader would
+/// still refuse the release, with no code saying why.
+#[test]
+fn a_proposal_has_a_known_kind_and_a_release_its_own_programdata() {
+ let mut env = Env::new();
+ let p = protect(&mut env, &honest_v1());
+ let q = protect(&mut env, &honest_fix());
+ let f = &p.f;
+ let owner = p.owner.pubkey();
+ let zero = solana_address::Address::default();
+ assert_eq!(env.fails(&[f.propose(&owner, 99, &zero, &[], None)], &[&p.owner]), err::WRONG_PROPOSAL_KIND);
+ assert_eq!(read_config(&env, f).pending_kind, 0);
+
+ let new_key = Keypair::new();
+ env.ok(&[f.propose(&owner, RELEASE_AUTHORITY, &new_key.pubkey(), &[], None)], &[&p.owner]);
+ env.advance(3 * DAY);
+ let release = f.execute_release(&owner, Some(&new_key.pubkey()), &[p.abort_buffer, p.snapshot]);
+ let mut other = release.clone();
+ other.accounts[1].pubkey = q.f.programdata;
+ assert_eq!(env.fails(&[other], &[&new_key]), err::PROGRAM_MISMATCH);
+ assert_eq!(env.upgrade_authority(&q.f.programdata), Some(q.f.authority.to_bytes()));
+ env.ok(&[release], &[&new_key]);
+ assert_eq!(env.upgrade_authority(&f.programdata), Some(new_key.pubkey().to_bytes()));
+}
+
+/// Refusals the substitution sweep or the random differential already see
+/// fail, here asserted by their own code: Floor's PDAs at registration, each
+/// instruction's own programdata, and what needs the program live or stopped.
+#[test]
+fn each_instruction_names_its_own_accounts_and_state() {
+ let mut env = Env::new();
+ let p = protect(&mut env, &honest_v1());
+ let q = protect(&mut env, &honest_fix());
+ let (f, gs) = (&p.f, p.guardians());
+ let owner = p.owner.pubkey();
+ let elsewhere = solana_address::Address::new_unique();
+
+ // Registration: Floor's config and authority PDAs (accounts 1 and 2).
+ let team = Keypair::new();
+ env.fund(&team);
+ let (program, _) = env.deploy(&honest_v1(), &team, 2048);
+ let reg = Floor::new(env.floor, program).register(&env.payer.pubkey(), &team.pubkey(), &team.pubkey(), &gs, 2, 7 * DAY, 3 * DAY);
+ for (at, code) in [(1, err::WRONG_CONFIG_ADDRESS), (2, err::WRONG_AUTHORITY_ADDRESS)] {
+ let mut ix = reg.clone();
+ ix.accounts[at].pubkey = elsewhere;
+ assert_eq!(env.fails(&[ix], &[&team]), code);
+ }
+
+ // Another program's programdata, each checked against what the named
+ // programdata would pass: a replacement abort buffer (account 2), a pin
+ // of the other program's code (1), and a close (5) of a copy of this
+ // program's live code, which a stop may name (finding 85).
+ let frozen = |env: &mut Env, elf: &[u8]| {
+ let b = env.write_buffer(elf, &p.owner);
+ env.set_buffer_authority(&b, &p.owner, &f.authority);
+ b
+ };
+ let (new_abort, copy_of_q, copy_of_live) = (frozen(&mut env, &ABORT_ELF), frozen(&mut env, &honest_fix()), frozen(&mut env, &honest_v1()));
+ let mut stage = f.stage_abort_by(&new_abort, &gs[0..2]);
+ stage.accounts[2].pubkey = q.f.programdata;
+ assert_eq!(env.fails(&[stage], &[&p.g[0], &p.g[1]]), err::PROGRAM_MISMATCH);
+ let mut pin = f.pin_snapshot(©_of_q);
+ pin.accounts[1].pubkey = q.f.programdata;
+ assert_eq!(env.fails(&[pin], &[]), err::PROGRAM_MISMATCH);
+ let mut close = f.close_buffer(&owner, ©_of_live);
+ close.accounts[5].pubkey = q.f.programdata;
+ assert_eq!(env.fails(&[close], &[&p.owner]), err::PROGRAM_MISMATCH);
+ let c = read_config(&env, f);
+ assert_eq!((c.abort_buffer, c.snapshot_buffer), (p.abort_buffer.to_bytes(), p.snapshot.to_bytes()));
+ assert!(env.account(©_of_live).lamports > 0);
+
+ // Live: no restore proposal, and only a restore is approved: not a
+ // pending upgrade, even by its own id.
+ let fix = frozen(&mut env, &honest_fix());
+ assert_eq!(env.fails(&[f.propose(&owner, RESTORE, &fix, &[], Some(&fix))], &[&p.owner]), err::NOT_ABORTED);
+ env.ok(&[f.propose(&owner, UPGRADE, &fix, &[], Some(&fix))], &[&p.owner]);
+ let pid = read_config(&env, f).pending_id;
+ assert_eq!(env.fails(&[f.approve(pid, &gs[0..2])], &[&p.g[0], &p.g[1]]), err::WRONG_PROPOSAL_KIND);
+ assert_eq!(read_config(&env, f).pending_approvals, 0);
+ env.ok(&[f.cancel(&owner)], &[&p.owner]);
+
+ // Stopped: no upgrade proposal, no new pin, and no second stop, even
+ // through an abort buffer anyone may stage while stopped.
+ env.ok(&[f.abort(&gs[0], &p.abort_buffer, Some(&p.snapshot))], &[&p.g[0]]);
+ env.next_slot();
+ assert_eq!(env.fails(&[f.propose(&owner, UPGRADE, &fix, &[], Some(&fix))], &[&p.owner]), err::NOT_LIVE);
+ // A copy of what now runs, the abort binary, would replace the pin.
+ let copy_of_abort = frozen(&mut env, &ABORT_ELF);
+ assert_eq!(env.fails(&[f.pin_snapshot(©_of_abort)], &[]), err::NOT_LIVE);
+ let abort2 = frozen(&mut env, &ABORT_ELF);
+ env.ok(&[f.stage_abort(&abort2)], &[]);
+ let aborted_at = read_config(&env, f).aborted_at;
+ env.advance(DAY);
+ assert_eq!(env.fails(&[f.abort(&gs[1], &abort2, Some(&p.snapshot))], &[&p.g[1]]), err::NOT_LIVE);
+ let c = read_config(&env, f);
+ assert_eq!((c.aborted_at, c.snapshot_buffer, c.snapshot_valid), (aborted_at, p.snapshot.to_bytes(), 1));
+}