@typesol/cli 0.48.0 → 0.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/CHANGELOG.md +556 -1
  2. package/NOTICE +17 -1
  3. package/README.md +122 -43
  4. package/SECURITY.md +6 -0
  5. package/dist/compiler/analyze.d.ts +2 -0
  6. package/dist/compiler/analyze.js +7 -1
  7. package/dist/compiler/emit/base.d.ts +7 -4
  8. package/dist/compiler/emit/base.js +17 -5
  9. package/dist/compiler/emit/borsh.js +8 -8
  10. package/dist/compiler/emit/calls.d.ts +6 -0
  11. package/dist/compiler/emit/calls.js +110 -11
  12. package/dist/compiler/emit/cpi-core.js +3 -3
  13. package/dist/compiler/emit/cpi.js +2 -2
  14. package/dist/compiler/emit/expressions.d.ts +1 -0
  15. package/dist/compiler/emit/expressions.js +15 -1
  16. package/dist/compiler/emit/function.js +12 -8
  17. package/dist/compiler/emit/program.js +10 -4
  18. package/dist/compiler/emit/rbtree.js +1 -1
  19. package/dist/compiler/emit/shared.d.ts +12 -2
  20. package/dist/compiler/emit/shared.js +26 -6
  21. package/dist/compiler/emit/statements.d.ts +8 -1
  22. package/dist/compiler/emit/statements.js +53 -5
  23. package/dist/compiler/emit/storage.js +20 -13
  24. package/dist/compiler/emit/views.js +1 -1
  25. package/dist/compiler/hints.js +3 -0
  26. package/dist/compiler/index.d.ts +15 -1
  27. package/dist/compiler/index.js +50 -9
  28. package/dist/keys.d.ts +12 -1
  29. package/dist/keys.js +57 -7
  30. package/dist/workspace.d.ts +8 -0
  31. package/dist/workspace.js +90 -15
  32. package/docker/deps/0.49.0.lock.json +1206 -0
  33. package/docker/deps/0.50.0.lock.json +1206 -0
  34. package/docs/architecture.md +3 -3
  35. package/docs/audit.md +33 -16
  36. package/docs/case-study-escrow.md +7 -5
  37. package/docs/case-study-jito-mev.md +14 -14
  38. package/docs/case-study-marginfi.md +142 -129
  39. package/docs/case-study-multisig.md +18 -5
  40. package/docs/case-study-raydium-amm.md +2 -1
  41. package/docs/case-study-raydium-clmm.md +44 -28
  42. package/docs/case-study-raydium-cp-swap.md +18 -18
  43. package/docs/case-study-spl-stake-pool.md +4 -3
  44. package/docs/cli.md +4 -3
  45. package/docs/language-accounts.md +21 -16
  46. package/docs/language-basics.md +4 -1
  47. package/docs/language-builtins.md +6 -2
  48. package/docs/language-cpi.md +34 -0
  49. package/docs/language-errors-events.md +1 -1
  50. package/docs/language-native.md +73 -7
  51. package/docs/language-statements.md +5 -3
  52. package/docs/language-types.md +13 -3
  53. package/docs/language.md +2 -2
  54. package/docs/mainnet.md +1 -1
  55. package/docs/runtime.md +25 -1
  56. package/docs/security-model.md +12 -4
  57. package/docs/stability.md +10 -4
  58. package/docs/testing.md +22 -6
  59. package/docs/troubleshooting.md +1 -1
  60. package/lib/typesol.d.ts +43 -3
  61. package/llms-full.txt +190 -51
  62. package/llms.txt +2 -1
  63. package/package.json +3 -3
  64. package/releases/0.48.0.json +847 -0
  65. package/releases/0.49.0.json +857 -0
  66. package/runtime/typesol_builtins.c +47 -2
  67. package/runtime/typesol_rt.h +131 -4
package/CHANGELOG.md CHANGED
@@ -6,6 +6,562 @@ codes, and says so here.
6
6
 
7
7
  ## Unreleased
8
8
 
9
+ ## 0.50.0 — 2026-11-26
10
+
11
+ A minor release: it adds a port of Percolator v16 (all 50 instructions of aeyakovenko/percolator-prog at 7b110913,
12
+ compared with a reference built from the author's source, as no v16 build is deployed) and the built-ins it needed
13
+ (`copyData`, `getReturnData()`, `PANIC_STYLE = "pinocchio"`), copies and zeroes whole values and account data with the
14
+ memory syscalls where the word loops cost more, and fixes overlapping struct copies between views of one account, other
15
+ programs' `@layout borsh` accounts with a discriminator shorter than 8 bytes, `realloc` of `@layout borsh` accounts, the
16
+ folding of a signed minimum modulo -1, the order in which `log64` and `require` read their arguments, `**` inside
17
+ `panicsAt` and builds with a clang above 20. Build manifests now bind a binary to the sources that built it, first
18
+ builds that run at once keep every program's address, and `init` and `new` refuse to write through a symbolic link.
19
+ Programs that compiled with 0.49.0 and still compile build to the same bytes, except 15 of the 80 programs both releases
20
+ build: examples/escrow, ledgerbook and profiles, Jito's two programs, Marginfi, Meteora DBC, Percolator v12.20 and its
21
+ matcher, Raydium CLMM and CP-Swap, SPL Stake Pool and the program-examples realloc, token escrow and token fundraiser,
22
+ for the memory syscalls and the fix of overlapping copies (Raydium CLMM also because its source no longer writes four
23
+ kinds of `msg!` line); their tests pass.
24
+
25
+ - Build manifests (`<name>.build.json`) now bind the binary to the exact sources that built it. A source's sha256 was
26
+ computed after the build, by reading the file again, so a file saved while the build ran (an editor saving mid-build)
27
+ could be recorded beside a binary made from its previous text, and a test reusing that build (`testProgram`,
28
+ `buildForTest`) would take it as current. The build now hashes the bytes the compiler parsed (read once and checked
29
+ against the text TypeScript holds) and the runtime files before clang reads them, hashes every input again once the
30
+ binary is linked, and fails with no manifest when one changed; a previous build's manifest is removed before anything
31
+ is written (docs/cli.md; test/cli/toolchain.test.ts). Binaries are unchanged.
32
+ - First builds that run at once no longer lose a program's address. Two first builds of different programs (each holds
33
+ only its own program's lock) could read `typesol.json`, each add its address and write it back, the later write
34
+ dropping the earlier address (or a reader seeing a partly written file); and a keypair file was created by an
35
+ existence check and an ordinary write, so two first users of one could each make a key and the later replace the
36
+ earlier. `typesol.json` is now changed one process at a time (`typesol.json.lock`) and replaced whole by a rename,
37
+ also by `typesol new`; a keypair is written to a temporary file and linked into place, which fails if it exists, and
38
+ the process that loses reads the winner's key (docs/cli.md; test/cli/workspace.test.ts).
39
+ - `typesol init` and `typesol new` refuse to write through a symbolic link inside the project: a linked `programs/`,
40
+ `tests/` or `.cursor/`, or a link (even a dangling one) where a new file goes, used to receive the file wherever it
41
+ pointed. Files are now also created exclusively, so one created in the meantime is never overwritten. The project
42
+ directory itself may still be a link (docs/cli.md; test/cli/workspace.test.ts).
43
+ - Release manifests (`scripts/release-manifest.ts`): the test corpus hash now covers `showcase/test/` as well as
44
+ `test/` (the mainnet ports' differential tests, helpers and fixtures were left out, so a weakened comparison left the
45
+ hash unchanged) and records the directories it covers (`corpus.roots`). The script also refuses to make a release
46
+ manifest when `test/programs/SOURCES.md` lists a reference binary the tree lacks (`--allow-missing-references`
47
+ records them as `referencesMissing` instead) (docs/testing.md; test/cli/release-manifest.test.ts).
48
+ - Raydium CLMM and multisig ports: their tests now compare what the repository overview claims. For every transaction,
49
+ the bytes of every account an instruction names (not only a chosen list), the inner instructions, the return data
50
+ and the log lines are compared too, with the exceptions each test declares (Anchor's `Instruction:` line and its
51
+ error-message text; for Raydium CLMM also the Associated Token program's Create, called with `[0]` by the original
52
+ and with empty data by the port, pinned in the test). Where the original CLMM panics, the test now requires its
53
+ `ProgramFailedToComplete` and a numbered error from the port. The stronger comparison found that the Raydium CLMM
54
+ port logged four kinds of `msg!` line (from seven places) the deployed program does not: its source writes them only
55
+ with the `enable-log` feature, and the deployed binary holds none of their text. The port no longer writes them,
56
+ which also makes its swaps cheaper (docs/case-study-raydium-clmm.md has the new figures; its binary is 546,080
57
+ bytes, was 551,440); the golden reference (test/golden/binaries.json) is regenerated in the build container with
58
+ it and with the Marginfi and SPL Stake Pool binaries the runtime's changes give. 308 Raydium CLMM
59
+ transactions (not 302 as listed) and 55 multisig ones are compared.
60
+ - Percolator v16 tests: `World.restore` now removes an account its snapshot recorded as missing (one a transaction
61
+ created since survived the restore); no result of the v16 files that restore a world changed.
62
+
63
+ - Fixed (wrong account data, since 0.42.0): a whole struct or array assigned between two views of one account whose
64
+ bytes overlap, the destination after the source by less than the value's size, did not end with the source's value:
65
+ the copy went forward 8 bytes at a time and re-read bytes it had already written (copying a two-word value one word
66
+ to the right in `[1, 2, 3]` gave `[1, 1, 1]`, not `[1, 1, 2]`). Every byte is now loaded before any is stored, at
67
+ any size below 80 bytes (from 80 the memmove syscall copies them, as in the entry below), so the destination ends
68
+ with the source's old bytes in either direction, as Rust's `copy_within` leaves them. Only views of one account at
69
+ run-time byte offsets can overlap that way: `loadRawAt` / `loadRawMutAt` (0.43.0 on), or two views of an account
70
+ passed twice under `NATIVE_ACCOUNT_WRITES` (0.42.0 on). A program is affected if it assigns `d.v = s.v` (or a whole
71
+ view) between such views of one account and the destination's offset can be ahead of the source's by less than the
72
+ value's size; copies between different accounts, distinct fields, elements of one array, through a local, or by
73
+ `copyData` were right. The copy costs the same or less than before. Five of the 81 programs in the release manifest
74
+ build to other binaries for it (examples/profiles, Marginfi, Percolator v12.20 and its matcher, SPL Stake Pool); none of them relied on an overlapping copy (theirs are between distinct places or
75
+ elements of one array), their tests pass, and Marginfi's instructions cost 5 to 49 CU less
76
+ (docs/language-native.md; test/language/bulk-copies.test.ts, which no longer pins the old result).
77
+ - Fixed (wrong account data, since 0.39.0): another program's `@layout borsh` account (`Owner<Account<T>, "…">`)
78
+ whose struct declares a discriminator shorter than 8 bytes (`/** @discriminator 0x07 */`) was decoded from byte 8
79
+ instead of right after its discriminator: its fields were read from the wrong bytes (the valid account `[7, 42]`
80
+ of a struct holding one `u8` did not read 42), and an account shorter than 8 bytes made the decoder's length wrap and
81
+ read past the account's data. Its size was checked against the struct's in-memory size, not its smallest Borsh
82
+ form. The decoder now starts after the declared discriminator and the size check uses the Borsh form. A program is affected only if a struct is both `@layout borsh`
83
+ and `@discriminator` of 1 to 7 bytes and taken as `Owner<Account<T>, "…">`; fixed-layout structs with a shorter
84
+ discriminator were read right. The length check of a growable `Vec` in such a fixed-layout struct counted 8 bytes
85
+ of discriminator and refused accounts of the right size (3003); it now counts the declared length. `initAccount<T>`
86
+ of a struct with a shorter discriminator is now refused when compiling (it writes this program's 8 bytes)
87
+ (docs/language-accounts.md; test/language/foreign-account.test.ts).
88
+ - Fixed (since 0.17.0): `realloc` of a `@layout borsh` account refused sizes below its discriminator and the struct's
89
+ in-memory size (3016), which reserves the full capacity of every `FixedString` and `FixedVec`: an account whose
90
+ only field is an empty `FixedString<64>` could not shrink to the 12 bytes of its Borsh form, although its load
91
+ accepts 12. The smallest size is now the discriminator and the smallest Borsh form, the size the load checks; the
92
+ value written back when the instruction returns must still fit (3004 otherwise, as before). A program is affected
93
+ if it calls `realloc` on a `@layout borsh` account with a size that can fall below that bound: such transactions
94
+ failed with 3016 and now succeed (docs/language-accounts.md; test/language/realloc.test.ts).
95
+ - Fixed: a signed type's minimum reduced modulo -1 in a typed constant (`const X: i8 = -128n % -1n`) folded to 0,
96
+ while the same remainder at run time fails with 5100, as Rust's checked `%` does. It is now a compile error, as the
97
+ quotient `-128n / -1n` already was, at every signed width; an untyped constant stays a bigint without a width
98
+ (docs/language-basics.md, docs/language-types.md; test/language/signed-remainder.test.ts).
99
+ - Fixed: `log64(a, b, c, d, e)` lowered all five arguments before reading any, so an argument that runs code
100
+ changing an earlier one's value (`log64(a.count, bump(a), …)`) logged the changed value; each argument is now read
101
+ before the next is evaluated. `require(condition, code)` with an error code computed at run time likewise tested its
102
+ condition after computing the code; the condition is now read first. The other built-ins taking several values
103
+ already read them in order. Of the programs in the release manifest only Percolator v12.20's C changes (its
104
+ `log64` call reads a temporary one line earlier), and it builds to the same binary for this
105
+ (docs/language-statements.md; test/language/argument-order.test.ts).
106
+ - Fixed: inside `panicsAt(location, …)`, `**` took the panic for its multiplications ("attempt to multiply with
107
+ overflow" at the location) instead of failing with 5100 as its declaration says; it now fails with 5100, and an
108
+ operator written in its operands still panics at the location (docs/language-native.md; test/language/pow.test.ts).
109
+ - Fixed: a program built with a clang above 20 (platform-tools v1.57's clang 22, an untested toolchain, which TypeSOL
110
+ warns about but builds with) faulted at its first 128-bit multiplication or variable 128-bit shift ("Access
111
+ violation writing 8 bytes at address …"): the runtime's assembly `__multi3`, `__ashlti3`, `__lshrti3` and
112
+ `__ashrti3` take the result's address in r1, as clang 20 calls them, while clang 22 passes the first operand there
113
+ and takes the result in registers. The assembly is now compiled only for clang 20 and earlier; any later clang gets
114
+ C definitions of the four, which follow its own convention (test/language/builtins.test.ts runs them on every case
115
+ of every function for SBPF v0, v1 and v2; docs/runtime.md). With the tested toolchain nothing changes: every program
116
+ in the golden manifest builds to the same bytes.
117
+ - Added: `PANIC_STYLE = "pinocchio"`: a Rust panic as pinocchio's `entrypoint!` panic hook reports it under std, the
118
+ location's file verbatim (`src/v16.rs`, or a toolchain path such as
119
+ `/home/runner/work/platform-tools/platform-tools/out/rust/library/alloc/src/raw_vec/mod.rs`), then
120
+ `** PANICKED **`, then abort ("SBF program panicked"). `panic(message, location)` and `panicsAt` take the file
121
+ alone or `file:line:column` (only the file is logged; the message may be null); `PANIC_ON_OVERFLOW` is refused
122
+ beside it. Every panic site calls one shared helper. Checked line for line against a binary built with pinocchio
123
+ 0.11.1's entrypoint (test/language/pinocchio-panics.test.ts; docs/language-native.md).
124
+ - Added: `getReturnData()`: Rust's `get_return_data()`, `const [program, data] = getReturnData()`, the return data of
125
+ any length (up to 1,024 bytes) and the program that set it, unchecked, read with instruction data's methods; Rust's
126
+ `None` is `data.length === 0n`. `returnData<T>(program)` is unchanged (test/language/get-return-data.test.ts;
127
+ docs/language-cpi.md).
128
+ - Tests: a native program at `MAX_ACCOUNTS = 255n` takes a fixed prefix and a tail of 39 and 255 accounts with
129
+ repeats, reads and writes through them and forwards the tail whole in a CPI (test/language/many-accounts.test.ts).
130
+ - Showcase, Percolator v16 (work in progress, 0 of 50 instructions ported, not listed among the ports): the entry
131
+ of the port (the tag dispatch, every tag refused), compared with the Rust build of the pinned commits on empty data
132
+ and all 206 unknown tags; the reference's entrypoint recorded at its limits: 255 accounts (256 refused by the
133
+ runtime), its heap, RefCell conflicts on repeated accounts and its panic lines, partly through a probe built with
134
+ the same entrypoint (`scripts/percolator-v16-reference/probe.sh`; showcase/mainnet/percolator-v16/TESTING.md).
135
+ Every program in the golden manifest builds to the same bytes.
136
+ - Showcase, Percolator v16 (still 0 of 50 instructions ported): the persisted layouts as packed views tied field by
137
+ field to the offsets rustc prints for the pinned sources, the engine's wire conversions, `PercolatorError` and the
138
+ engine-error mapping, and `Instruction::decode` for all 50 tags, compared with the reference on every decode refusal
139
+ (field cuts, trailing bytes, vector counts, random bodies) and on where decoding ends; a decoded instruction ends in a
140
+ placeholder error until its handler is ported (showcase/mainnet/percolator-v16/README.md).
141
+ - Added: `copyData(account, from, to, length)`: a copy within one account's data, as a native program's
142
+ `data.copy_within(from..from + length, to)` (or a struct copied out and written back at another offset), with the
143
+ memmove syscall from 32 bytes (about constant compute units whatever the length, where a whole-struct assignment
144
+ moved words one by one until the change below); overlapping ranges allowed, 3003 past the end with nothing copied, 3006 on a read-only
145
+ account without `NATIVE_ACCOUNT_WRITES` (test/language/native-copy-data.test.ts; docs/language-native.md). Every
146
+ program in the golden manifest builds to the same bytes.
147
+ - Showcase, Percolator v16 (24 of 50 instructions ported, not listed among the ports): InitMarket, InitPortfolio,
148
+ Deposit, ClosePortfolio, UpdateAuthority, UpdateAssetAuthority, the four market-authority policies,
149
+ UpdateBackingFeePolicy, UpdateTradeFeePolicy, ConfigurePermissionlessResolve, UpdateBaseUnitMints, the two ledger
150
+ syncs, ConfigureEwmaMark, PushEwmaMark, ConfigureAuthMark, PushAuthMark, SetMatcherConfig, UpdateAssetLifecycle
151
+ (activation with the market grown by one slot, drain-only, retirement, shutdown into recovery; a permissionless
152
+ activation's insurance deposit and a lapsed backing bucket's expiry end in the port's placeholder),
153
+ RestartAssetOracle and CanonicalizeSpentBackingHistory, with the engine code they reach (the configuration's exact
154
+ solvency envelope, the market's shape, a portfolio's validation against the market, deposits, portfolio
155
+ registration, the raw oracle target, asset accrual and committed funding, slot activation, retirement, recovery and
156
+ restart). Compared whole with the Rust build of the pinned commits on their success paths and refusals, every
157
+ account position, a random walk that keeps the market live, a mutation fuzzer over the market, portfolios and both
158
+ ledgers, and seeded fuzzes of mark pushes and funding accruals (22,027 transactions, 5,944 successes); the port uses
159
+ 31% to 69% of the reference's compute units on average per instruction, fewer on every success. With
160
+ ConfigureAuthMark and SetMatcherConfig ported the author's own suite gets through its set-up
161
+ (showcase/mainnet/percolator-v16/README.md and TESTING.md). `scripts/percolator-v16-reference/author-suite.sh` takes
162
+ `TEST_FILTER` to run a subset of the author's tests.
163
+ - Changed (generated code of existing programs): whole values and account data are copied and zeroed by the memory
164
+ syscalls where the word loops cost more (measured table in runtime/typesol_rt.h; docs/runtime.md). A struct or
165
+ array copied whole between places reached through pointers (account data, views, a helper's struct parameter) is
166
+ the memmove syscall from 80 bytes (16 CU up to 2,749 bytes, where the unrolled loads and stores cost 26 at 80 bytes
167
+ and the loop about 1 CU a byte from 400), and zeroed whole there (`x.o = null` on an `Option<struct>`) the memset
168
+ syscall from 192. A copy into or out of a local of the function (a struct literal built in a temporary, a helper's
169
+ result, a local copy, Borsh fields, instruction arguments, events) takes the syscall only from 400 bytes, a local
170
+ zeroed whole from 600, where clang stops unrolling: below that it drops the stores and loads nothing reads, which an
171
+ opaque call prevents (measured with 80 and 192 there: SPL Stake Pool up to 2,825 CU more, Phoenix 7 to 98 more).
172
+ The bytes `resizeAccount`, `realloc` and a growable Vec's growth add are zeroed by the memset syscall from 64, and
173
+ an account's data at `close` when its type takes 64 bytes or more (9,563 bytes: about 45 CU instead of 4,800).
174
+ Below each threshold the code is what it was. 14 of the 81 programs in the release manifest build to other binaries
175
+ (examples/escrow and ledgerbook, Jito's two programs, Marginfi, Meteora DBC, Percolator v12.20 and its matcher,
176
+ Percolator v16, Raydium CLMM and CP-Swap, and the program-examples realloc, token escrow and token fundraiser); all
177
+ their tests pass, and each of the 161,578 transactions those tests send was run against the binary from before and
178
+ after: 18,451 cost less, 4 more. Two Percolator v16 InitPortfolio transactions cost one CU more (the account grows
179
+ by 8 and 16 bytes: the length is tested at run time), and two refusals of Meteora DBC's
180
+ initialize_virtual_pool_with_token2022_transfer_hook 2 more (its successes 3,079 less). Savings (mean per
181
+ successful transaction): Percolator v12.20 InitMarket 232,685 to 105,768, TradeCpi 3,414 less, PushHyperpMark
182
+ 1,297; Percolator v16 InitPortfolio from an empty account 4,750, Deposit and ClosePortfolio 2,069; Meteora DBC swaps
183
+ 2,056, create_config 3,976; Marginfi 106 to 1,940 on 30 instructions; an account's close 26 to 1,145 (examples/escrow
184
+ take and refund 74). A struct copied between two views of one account that overlap, the destination after the
185
+ source, ends with the source's old bytes from 80 bytes on (memmove); below 80 bytes, see the fix of overlapping
186
+ struct copies above (docs/language-native.md; test/language/bulk-copies.test.ts, which also pins a 1 KiB copy at
187
+ no more than 30 CU and an 8 KiB resize zero-fill at no more than 60).
188
+ - Showcase, Percolator v16 (25 of 50 instructions ported, not listed among the ports): ConfigureHybridOracle and the
189
+ external oracle readers of `mod oracle_v16` (Pyth PriceUpdateV2, Switchboard On-Demand under its mainnet and devnet
190
+ owners, Chainlink OCR2, composites of up to three legs with inversion and unit scale, the legs' coherence and commit,
191
+ the hybrid soft-stale predicate), and a permissionless activation's fee into market 0's insurance domains with its
192
+ SPL Token Transfer (UpdateAssetLifecycle's placeholder path for it removed). Compared whole with the Rust build of the
193
+ pinned commits: each source and composite on its success space, every refusal of the instruction and of each reader
194
+ field by field, a seeded fuzz of 400 configurations, the random walk and mutation fuzzer with a keeper that keeps the
195
+ external prices fresh, 34 permissionless appends (the fee doubled from asset 32) and a reuse; the reader's branches
196
+ that only the crank reaches compared on 1,500 vectors with the original's functions compiled for the host
197
+ (`scripts/percolator-v16-reference/oracle-vectors.ts`). All v16 tests: 23,211 transactions, 6,098 successes, each
198
+ cheaper in the port (ConfigureHybridOracle 52% of the reference's compute units on average); binary 289,728 bytes.
199
+ Every failure of the author's suite subsets rerun against the port reaches an instruction not ported yet
200
+ (showcase/mainnet/percolator-v16/README.md and TESTING.md).
201
+ - Showcase, Percolator v16 (27 of 50 instructions ported, not listed among the ports): SyncMaintenanceFee and Withdraw,
202
+ with the engine's maintenance fee (the fee anchor, the U256 fee saturated to u128, the loss settled from principal,
203
+ the fee charged into the insurance, the cranker's share credited from the insurance, the rest into asset 0's domain
204
+ budgets with the alternating carry, a portfolio its fee empties closed into the market, the deregistration's
205
+ LockActive swallowed as the original does) and `withdraw_not_atomic` (the close ledger, the equity after, the vault
206
+ PDA's signed SPL Token Transfer, the secondary collateral mint). The settlement of a portfolio's open legs against
207
+ the assets' K, F and B indices is not ported: both instructions stop there in the port's placeholder on a Live market
208
+ once the fee anchor has moved. Compared whole with the Rust build of the pinned commits on their success paths and
209
+ refusals, and on 400 generated states (a new reusable generator writes markets and portfolios with open legs, PnL up
210
+ to ±(2^127 − 1), fee debt and extreme totals that the original's validators accept, 91% of the Live ones); the walk
211
+ and mutation fuzzer run both instructions and start a fifth of the mutations from generated states. All v16 tests:
212
+ 24,454 transactions, 6,541 successes, each cheaper in the port (Withdraw 54%, SyncMaintenanceFee 62% of the
213
+ reference's compute units on average); binary 324,432 bytes. Every failure of the author's suite subsets rerun
214
+ against the port reaches an instruction not ported yet (showcase/mainnet/percolator-v16/README.md and TESTING.md).
215
+ - Showcase, Percolator v16 (still 27 of 50 instructions ported, not listed among the ports): the map of the settlement
216
+ of a portfolio's open legs, `settle_account_side_effects_not_atomic`, which SyncMaintenanceFee and Withdraw stop at:
217
+ 275 engine functions and 6,397 lines found by following the calls in the pinned source, layered in the source's own
218
+ order (leaf arithmetic, backing and lien primitives, impaired-lien reconciliation, source-claim burns and PnL
219
+ setters, K/F entries, B chunks, the driver), with what is ported (`scripts/percolator-v16-reference/settlement-map.py`,
220
+ NOTES.md section 10). Most of its leaf layer is ported (`kernels.ts`, 45 functions, 1,134 of the original's lines: the
221
+ source-lien arithmetic, the bucket and lien deltas, the K/F and B targets and deltas of a leg, the F snapshot after
222
+ settlement, the B chunk, the backing utilization fee, v16's wide_math helpers with their panic locations; its 33
223
+ market-view accessors remain), not yet
224
+ wired into an instruction. A new function-level harness compares each with the original's own function compiled
225
+ for the host in Docker (a child module added to a copy of the engine's `v16` module reaches the private functions
226
+ without changing any visibility): 90,000 seeded vectors equal, outputs, changed bytes, errors and panic locations;
227
+ interim evidence until the settlement can be compared with the reference binary (showcase/mainnet/percolator-v16/
228
+ README.md and TESTING.md).
229
+ - Showcase, Percolator v16 (still 27 of 50 instructions ported, not listed among the ports): the next three layers of
230
+ the settlement of open legs from the bottom: the rest of the leaf layer (the market-view and portfolio-view
231
+ accessors), the backing and lien primitives (source-credit setters and the domain recompute, the counterparty and
232
+ insurance liens' create, consume and release, fresh and loser-paid counterparty backing, a Fresh bucket's expiry,
233
+ the post-snapshot residual, the backing utilization fee's collection) and the impaired-lien reconciliation
234
+ (`primitives.ts`, `impairment.ts`, 80 functions, 1,440 of the original's lines; 35 functions, 1,939 lines, remain).
235
+ The function-level harness now takes whole markets and portfolios (the original's views built over the same bytes
236
+ as the program builds them, every byte of both accounts compared) on generated states, about 40% of them accepted by
237
+ the original's own validators and the rest deliberately invalid: 22,800 vectors equal; interim evidence, not the
238
+ reference binary. UpdateAssetLifecycle's retirement now expires a lapsed Fresh backing bucket instead of ending in
239
+ the port's placeholder, compared with the reference binary on 300 buckets written into the market (139 successes,
240
+ each cheaper in the port); binary 354,080 bytes.
241
+ - Showcase, Percolator v16 (still 27 of 50 instructions ported, not listed among the ports): the rest of the settlement
242
+ of a portfolio's open legs, `settle_account_side_effects_not_atomic`: the source-claim burns and PnL setters
243
+ (`claims.ts`), the K/F settlement entries with the par netting of a loss, the haircut-bounded close loss, the
244
+ loss-support booking and the capital-backed loss reservation (`kfsettle.ts`), the B chunks and the driver
245
+ (`settlement.ts`): 35 functions, 1,939 of the original's lines; all 275 functions of the map are now ported. It is
246
+ wired into SyncMaintenanceFee and Withdraw, whose placeholders are gone, and compared with the reference binary on
247
+ generated states with open legs (claims and liens on the market's domains, K/F/B indices, stale cohorts): 3,000 such
248
+ states and 2,000 ordinary ones, 5,000 mutations, every transaction alike, 328 successes that settled legs, the port
249
+ cheaper on every success (SyncMaintenanceFee 39% of the reference's compute units on the mean of those states).
250
+ Each function is also compared alone with the original's compiled for the host (33,000 vectors equal), on a
251
+ generator whose states the original's validators accept 58% of the time (40% before). Branch probes
252
+ (`scripts/percolator-v16-reference/coverage.ts`) show which branches of the port's functions each comparison runs:
253
+ 766 of 836, the rest unreachable from accepted states but for seven (TESTING.md). Binary 588,856 bytes.
254
+
255
+ - Showcase, Percolator v16 (still 27 of 50 instructions ported, not listed among the ports): every key the v16 tests
256
+ make comes from a seed drawn per run and printed with every failure (`PERCOLATOR_V16_SEED` replays it); the port and
257
+ its test programs are refused unless built by the tested toolchain throughout (a fault of one walk run at InitMarket
258
+ was a build by platform-tools v1.57's clang 22, whose link another process switched during the build, meeting the
259
+ runtime's assembly builtins: fixed above; showcase/mainnet/percolator-v16/TESTING.md section 5); the coverage copy is
260
+ one per process; set-ups over tens of thousands of key sets, capacities, PDA bumps and heap frames compared with the
261
+ reference (`percolator-v16-setup-stress.test.ts`); the map extended to margin and health certificates,
262
+ ConvertReleasedPnl and Withdraw (NOTES.md section 11: 33 functions, 764 lines not ported; no ported instruction
263
+ computes a certificate, and no state lets a portfolio with open legs withdraw).
264
+ - Showcase, Percolator v16 (29 of 50 instructions ported, not listed among the ports): TradeNoCpi and
265
+ ConvertReleasedPnl. TradeNoCpi's map (NOTES.md section 12, `settlement-map.py --trade`): 127 processor functions and
266
+ 127 engine functions new to the port (3,645 lines), all ported but six only the crank's refresh and the batch reach:
267
+ the margin and health certificates (`health.ts`), the engine's trade with its position routes, gates, fees, close
268
+ ledger, source liens and residue resets (`trade.ts`), and the processor's zero-move funding accrual, dynamic fee
269
+ quote, trade-driven mark, backing-domain fees and lien bounds (`trading.ts`); ConvertReleasedPnl in `convert.ts`.
270
+ Compared with the reference binary on dedicated tests (routes, 14 legs, bounds, fees, the initial margin to the unit,
271
+ every account pair) and on real state: a random walk in which trades open and close legs on three assets of four
272
+ portfolios while funding accrues, so that the settlement, the refresh and the certificates run on state the
273
+ instructions made (2 × 2,500 steps: 5,266 transactions, 2,058 trades and 22 conversions succeeding in both, 1,851 legs settled by a later instruction, 692 funding accruals with open interest, 4,076 certificates written), and a mutation fuzzer from such a snapshot; every transaction alike, every success
274
+ cheaper in the port (the worst trade: 595,297 CU in the reference, 238,926 in the port; TradeNoCpi 43% of the reference on the mean). Binary 846,712 bytes.
275
+ - Showcase, Percolator v16 (31 of 50 instructions ported, not listed among the ports): PermissionlessCrank on a Live
276
+ market and FinalizeResetSide. The crank's map (NOTES.md section 13, `settlement-map.py --crank`): 94 processor
277
+ functions and 133 engine functions new to the port (4,436 lines); ported, what a Live market reaches (89 engine
278
+ functions, 2,919 lines: the observation of each hinted asset with the hybrid's fall-back to its mark and its
279
+ liveness, accrual at moving prices, the engine's classifier and plan, the refresh with B chunks and lapsed backing,
280
+ liquidation partial and full with its fee and the cranker's reward, the insurance draw, the bankruptcy residual
281
+ booked into the other side's B index, ADL and the side modes, the close-progress ledger, AdvanceClose, the
282
+ declaration of Recovery, the flat account's source-lien release, a Recovery asset's committed-state refresh); a
283
+ market in Recovery, the forfeit of a Recovery asset's released obligation and a Resolved market's close end in the
284
+ port's placeholder where the original calls them (44 engine functions). The engine's NonProgress the processor
285
+ swallows after an accrual, the `clear_leg` Stale the engine swallows and a declared Recovery that liquidation's
286
+ caller turns into success are values in the port, leaving exactly the original's partial writes. Compared with the
287
+ reference binary on dedicated tests (hint shapes, oracle accounts stale, ahead, malformed or repeated, long gaps,
288
+ every account pair, liquidations, bankruptcies, a 14-leg portfolio) and on a real-state walk in which cranks keep
289
+ three assets current while marks and oracle prices move and steered portfolios are liquidated (3 × 8,000 steps:
290
+ 24,772 transactions, 7,604 crank successes, 476 liquidations (366 partial, 110 full), 116 cranker rewards, every one alike), and a mutation
291
+ fuzzer from snapshots with positions under water; every crank success cheaper in the port (40% of the reference on
292
+ the mean; the worst 1,376,639 CU in the reference, 505,213 in the port). Where a 14-leg crank runs the reference past
293
+ 1,400,000 CU, the port succeeds (recorded). Binary 1,005,456 bytes.
294
+ - Showcase, Percolator v16: the placeholder that ends a decoded instruction of an unported tag is now
295
+ Custom(0xc0de0000 + tag), no longer Custom(0x16dec000 + tag), whose log text `custom program error: 0x16dec0..`
296
+ the author's tests took for NonProgress (`custom program error: 0x16`) by its prefix.
297
+
298
+ - Showcase, Percolator v16 (37 of 50 instructions ported, not listed among the ports): PermissionlessCrank on a market
299
+ in Recovery (the forfeit of a released obligation, the market's resolution) and on a Resolved market (the account's
300
+ close-out: the source domains' preparation and realization, the resolved bankruptcy, the solvent legs' detachment,
301
+ the payout ledger and receipt, the payout's signed SPL Token Transfer), which removes the crank's four placeholders;
302
+ and ForfeitRecoveryLeg, RebalanceReduce, CureAndCancelClose, ResolveMarket, ResolveStalePermissionless and
303
+ CloseResolved. Compared whole with the Rust build of the pinned commits: six markets taken out of Live with open legs
304
+ (a declared Recovery with the owners' forfeits, ResolveMarket, ResolveStalePermissionless) and closed out portfolio by
305
+ portfolio with payouts, the conservation the original's tests assert checked in both VMs and never failing, account
306
+ and data sweeps of each instruction, RebalanceReduce on real state, CureAndCancelClose on generated close ledgers; the
307
+ crank walk now resolves and closes out markets, and its mutation fuzzer starts from markets in Recovery and Resolved.
308
+ All v16 tests: 42,222 transactions, 16,223 successes, each cheaper in the port (CloseResolved 35%, ForfeitRecoveryLeg
309
+ 37%, RebalanceReduce 37%, CureAndCancelClose 36% of the reference's compute units on average); binary 1,139,536 bytes
310
+ (showcase/mainnet/percolator-v16/README.md, NOTES.md sections 13 and 14, TESTING.md). No compiler change.
311
+ - Showcase, Percolator v16 (47 of 50 instructions ported, not listed among the ports): the insurance and backing-bucket
312
+ instructions (TopUpInsurance, TopUpInsuranceDomain, TopUpBackingBucket, WithdrawBackingBucket,
313
+ WithdrawBackingBucketEarnings, WithdrawInsuranceAsset, with the engine's fresh-backing deposit and withdrawal, the
314
+ resolved backing surplus, the earnings and domain-insurance withdrawals and the terminal claim-free recredit) and the
315
+ terminal ones (CloseSlab with its terminal scan, the retirement and burn of the vault, the vaults closed and the
316
+ tombstone; ClaimResolvedPayoutTopup; SwapSecondaryForPrimary; ForceCloseAbandonedAsset on the trade engine). Left:
317
+ TradeCpi, BatchTradeNoCpi, BatchTradeCpi. Compared whole with the Rust build of the pinned commits: top-ups and
318
+ withdrawals among trades and cranks, markets resolved and closed by CloseSlab, a second mint swapped and closed, a
319
+ shut-down asset force-closed and drained, payout top-ups after a lapse of backing, account and data sweeps of each;
320
+ the walks now move reserves, shut assets down and close their markets, and the conservation check is asserted
321
+ wherever it is collected. All v16 tests: 68,632 transactions, 24,657 successes, each cheaper in the port (ForceCloseAbandonedAsset 36%,
322
+ CloseSlab 36%, TopUpBackingBucket 33%, WithdrawInsuranceAsset 40% of the reference's compute units on average);
323
+ binary 1,258,064 bytes. The author's suite: one failure in a ported path, `inv_078`, which expects a force-close to
324
+ exceed the compute-unit limit that the port's stays within (showcase/mainnet/percolator-v16/README.md, NOTES.md section 15,
325
+ TESTING.md). No compiler change.
326
+ - Showcase, Percolator v16 tests (no compiler change): a run that compared nothing can no longer pass for one. CI
327
+ gains a `percolator-v16` job that builds the five v16 binaries from the pinned sources in Docker, checks each against
328
+ the sha256 test/programs/SOURCES.md records and runs every v16 test file under `CI_REQUIRE_ALL=built`; there a
329
+ missing binary, a missing port source or a test file that compared no transaction fails (each file prints its count;
330
+ locally, without the binaries, the files still skip and print 0). The showcase job no longer runs them. Where the
331
+ reference is rerun under a raised compute budget, that run now starts from the exact pre-transaction state of every
332
+ covered account (one that did not exist is removed, not left as an earlier replay had it), the port is compared with
333
+ that run's accounts, and an account the run closes is removed from the reference afterwards; the harness test checks
334
+ both cases. The path tests assert the evidence of the paths they name (liens, the backing-domain fee, TradeCpi's cap
335
+ refusal, the lien releases; the gap test's uncovered losses and closes; the haircut test's receipts and top-up), and
336
+ the gap test no longer claims the paths it was written for but does not reach. The log comparison drops the port's
337
+ `0xc0de` probe lines only in coverage runs and matches the runtime's compute-unit line whole. The README, NOTES and
338
+ TESTING now say what CI compares, why two omitted token-value proofs cannot change an outcome (NOTES.md section 17),
339
+ where the port does allocate (section 18), and the refusal and transaction counts as measured.
340
+ - Showcase, Percolator v16 at commit 7b110913 (engine 5e3af07), complete: all 50 instructions ported, now listed among
341
+ the ports (its reference is a binary built here from the author's pinned source, not a deployed program). The last
342
+ three: BatchTradeNoCpi (the engine's batch: one refresh, the position maps kept across up to 14 legs, one end-state
343
+ margin check, the collected fees allocated to the legs) and the matcher ABI v3 with TradeCpi and BatchTradeCpi (the
344
+ LP's matcher config and delegate PDA, the tail check, the accrual and currentness before the call, the call signed by
345
+ the delegate, the answers validated, the slippage and fee caps). The placeholder for unported tags is gone. Compared
346
+ whole through the author's auth and hostile matchers, percolator-match and a rogue matcher of the tests' own (failing,
347
+ changing accounts, calling back, return data too long, short or unasked, resized contexts, prices out of range); batch
348
+ and matcher trades now in both walks. Where the reference runs out of compute units and the port does not, the
349
+ reference is run again under a raised compute budget and the port must equal that run (9 cases, all equal). New
350
+ real-state paths: a trade's counterparty-backed source lien with its backing-domain fee, the provider's earnings
351
+ withdrawn, ReleaseSourceLiens, a lien released at the resolved close. All v16 tests (2026-11-20): 70,881
352
+ transactions compared with the port, 70,678 of them with a Percolator instruction, 25,995 successes, each cheaper in
353
+ the port, and of the 44,683 refusals 44,673 cheaper and 10 at 0 in both; binary 1,362,760 bytes (reference 1,375,936). The author's whole suite
354
+ found one difference, fixed (a matcher's price above MAX_ORACLE_PRICE must be OracleInvalid); its full run on both
355
+ binaries is the next entry. No compiler change.
356
+ - Percolator v16: the author's whole suite (2,071 tests, all six targets unfiltered) ran on the reference and on the
357
+ port's current binary with every transaction recorded and compared (results, errors, return data, logs and every
358
+ account of the transaction's key list, by hash). The reference passes 2,062 and the port 2,060; the 9 failures of
359
+ the reference are its own and the port fails them at the same assertion; the port's 2 others assert the reference's
360
+ compute units (a peak of 554,832; a one-shot force-close expected to exceed the limit, which the port completes).
361
+ Of 2,324,991 transactions compared, 2,324,990 are identical, the other that force-close. None of the 2,127,486
362
+ identical successes costs the port more compute units: port 67,489,438,873, reference 128,297,605,017. The
363
+ first full run, on the port's previous binary, had found 282 that did, at the author's largest shapes
364
+ (ResolveMarket, CloseSlab, InitMarket); they were fixed (next entry) and the full run repeated. The author-suite and
365
+ trace scripts now fail on a target that does not compile, times out or runs nothing, on an empty trace, and on any
366
+ failure, difference or compute-unit excess not listed with its reason in
367
+ `scripts/percolator-v16-reference/author-suite-expected.tsv` (or a listed one no longer seen); the trace writer
368
+ writes each line at once and stops a test it cannot record (showcase/mainnet/percolator-v16/README.md, TESTING.md
369
+ section 3).
370
+ - Percolator v16: the three excesses the author's suite found are removed (no compiler change). ResolveMarket and
371
+ ResolveStalePermissionless (the committed-accrual scan of every configured slot), CloseSlab (the terminal scan of up
372
+ to 256 assets a call) and InitMarket (asset 0's profile copied into every slot) made a view per slot, each with its
373
+ own owner and bounds check and an offset computed with overflow checks, where the original indexes a slice whose
374
+ bounds the market view checked once; they now read the slots through one view of the slot array, and CloseSlab makes
375
+ the two backing expiries effective only for an asset whose step reads them. On a 10 MiB market (5,682 slots):
376
+ ResolveMarket: port 64,034, reference 65,546 (the port was 166,304); InitMarket: port 146,361, reference 211,905 (the
377
+ port was 214,540); a CloseSlab scan of 256 assets with fresh backing: port 17,682, reference 41,318 (was port
378
+ 42,314, reference 38,318). The ResolveMarket
379
+ scan now costs 11 instructions a slot as the reference's does; the port's lead there is its smaller fixed part.
380
+ `percolator-v16-shapes.test.ts` compares the three on markets of 1,000 and 5,682 slots (each success must cost the
381
+ port less; the previous binary fails all three tests). All 31 v16 files (2026-11-21): 226 tests, 70,928
382
+ transactions compared with the port, 26,035 successes, each cheaper in the port. The 20 author's tests whose transactions showed the excesses ran again on the new binary: all pass, their 144,407
383
+ transactions are identical to the reference's recorded ones, and none of their 143,473 identical successes costs the
384
+ port more (the 10 MiB ResolveMarket: port 64,080, reference 65,584); `author-suite-expected.tsv` lists no compute-unit excess
385
+ any more. The whole suite then ran again on the new binary (2026-11-21 to 2026-11-23): no excess anywhere (previous
386
+ entry). Binary 1,362,872 bytes
387
+ (was 1,362,760), sha256 `01c33233…` (showcase/mainnet/percolator-v16/README.md "Where the port costs more",
388
+ TESTING.md).
389
+ - Percolator v16: UpdateAssetLifecycle's permissionless activation now refuses an overflowing doubled fee exactly as
390
+ the original does (EngineArithmeticOverflow whenever a doubling overflows u128, a stored base fee of u128::MAX at an
391
+ asset index of 32 or more included; the port used u128::MAX as its overflow marker and let that base through to the
392
+ maximum-fee check). No instruction stores a base fee above u64::MAX (UpdateMarketInitFeePolicy refuses it), so the
393
+ lifecycle test writes such fees into the market (u128::MAX, u128::MAX/2 + 1, u128::MAX/2) and compares the appending
394
+ and reuse routes at indices 7, 33 and 35; the previous binary fails it. `percolator-v16-shapes.test.ts` now also drives
395
+ CloseSlab's Expire step, a nonzero recredit, the last batch refused while a domain budget remains and ReadyToClose on
396
+ the 5,682-slot market, and asserts the LockActive its wait case gives. The author-suite trace writer leaves out only
397
+ the runtime's whole compute-unit line (and the port's probe lines only when probes are on); the trace comparison
398
+ classes every differing transaction of a test (each kind must be listed for that test) and judges `main.trace`'s
399
+ groups of equal lines whose compute units vary against their cheapest reference line. All 31 v16 files (2026-11-23):
400
+ 227 tests, 70,975 transactions compared with the port, 26,077 successes, each cheaper in the port; of 44,695
401
+ refusals 44,685 cheaper and 10 at 0 in both. Binary 1,362,912 bytes (was 1,362,872), sha256 `c6dc6b24…`. The author's
402
+ whole suite ran again on this binary (2026-11-23 to 2026-11-24) and on the reference (2026-11-25 to 2026-11-26),
403
+ both with these scripts: the same passes and failures, the `inv_078` force-close the one difference, and no
404
+ identical success costing the port more (port 67,489,438,873 units, was 67,489,010,058; the figures above are this
405
+ run's). No compiler change.
406
+ ## 0.49.0 — 2026-11-16
407
+
408
+ A minor release: it adds a port of Percolator v12.20 (all 27 instructions, compared with the immutable mainnet build)
409
+ and the built-ins it needed (`log64`, `zeroData`, `PANIC_STYLE = "solana-1.18"`, `executable` on a remaining account),
410
+ changes lamport writes on remaining accounts under `NATIVE_ACCOUNT_WRITES`, and fixes two example programs
411
+ (`examples/airdrop.ts`, `examples/minter.ts`) that let any caller take an authority. Programs that compiled with 0.48.0
412
+ and still compile build to the same bytes, except those two examples, whose sources changed.
413
+
414
+ - Changed: under `NATIVE_ACCOUNT_WRITES`, a write to a remaining account's `.lamports` is a native program's
415
+ `**a.lamports.borrow_mut() = v`: no writability check (3006) and no refusal of an account passed more than once
416
+ (2040); an account passed twice is one record, and the runtime judges the change when the instruction ends. Programs
417
+ without the flag build as before, and so does every program in the golden manifest
418
+ (test/language/native-lamports.test.ts; docs/language-native.md).
419
+ - Showcase, Percolator: mutation fuzzers against the mainnet binary (`showcase/test/percolator-mutate-*.test.ts`):
420
+ the account list, the instruction data, the environment (several instructions per transaction, a relay at stack
421
+ height 2, low compute-unit limits, Clock and oracle extremes) and the slab's every field, from valid transactions of
422
+ all 27 instructions in eleven market states, each compared byte for byte; and the failure sites a review found
423
+ without a test, reached on purpose (`percolator-sites.test.ts`). Four differences they found are fixed, each kept as
424
+ a named case (`percolator-regressions.test.ts`): CloseSlab with the slab or the admin again in its unused fifth
425
+ position (the port failed with 2040, the original succeeds), a matcher shrinking its context below 64 bytes during
426
+ TradeCpi (InvalidAccountData before any field is read), a TradeCpi tail long enough to exhaust the original's 32 KiB
427
+ heap before the matcher call (the allocator's "out of memory" and abort, now reproduced from the same byte count),
428
+ and the funding rate of a config only patching can make (`i128::clamp`'s assertion panic and `saturating_mul`).
429
+ SetOraclePriceCap changes the config in place (on a Hyperp market it had cost about as much as the original's).
430
+ - Showcase, Percolator: the compute-unit tables re-measured on the current build (363,392 bytes): on the same
431
+ transactions every instruction's mean and largest figure is the earlier build's or lower (SetOraclePriceCap 606 on
432
+ average, from 1,696), each keeper crank of the account-count table costs one unit more, and all stay below the
433
+ original. New differential tests: TradeCpi's tail with signers and writable accounts as the matcher sees them, the
434
+ per-side cap on active positions with real trades, the ADL edges (K without headroom, precision exhausted, a crank
435
+ stopping on a pending reset; the first two only on a slab written in, as no instruction reaches them), and TradeCpi's
436
+ path after the matcher call on nearly full heaps, through a test matcher that takes any tail. One difference found
437
+ and pinned: a panic after the call where the original's heap can no longer hold the formatted panic line (a tail at
438
+ the last length or two the heap holds and a slab written in) logs the allocator's out-of-memory error in the
439
+ original and the panic line in the port; the outcome and every account are the same.
440
+ - Showcase, Percolator: mutation testing of the differential tests. 196 hand-chosen mutants of the port's source (every
441
+ file, 63 in rarely-run paths such as ADL, bad debt past insurance, the resolved wind-down, Hyperp and Chainlink), each
442
+ rebuilt and run against the sixteen test files: 140 killed as the tests stood, 22 equivalent (the reasons in
443
+ the port README), 34 gaps, each now covered by a new differential test in the fitting file and killed (boundaries hit
444
+ exactly, such as the margins, the catch-up envelopes, the deviation band and the deposit cap, and states only a
445
+ written slab has). The new tests found no difference from the mainnet binary. The default run's count now covers all
446
+ sixteen files: 139,185 compared transactions, 33,590 successful under both.
447
+
448
+ - Changed: an account of another type passed where a remaining account or an `AccountInfo` is taken (`programAt`,
449
+ `sysvarAt`, `zeroData`) is now refused by TypeScript (a `RemainingAccount` has `executable`), with the hint "pass a
450
+ remaining account (remainingAccounts().get(i)) or an AccountInfo parameter; a declared parameter of a program or
451
+ sysvar type is used as it is"; the compiler's own message said the same before.
452
+ - Added: `log64(a, b, c, d, e)`, Rust's `sol_log_64` (the runtime writes the five u64s as lowercase hex on one line);
453
+ `zeroData(account, offset, length)`, a memset of account data by the syscall, as a native program's
454
+ `for b in data.iter_mut() { *b = 0 }` compiles (about constant compute units for 1.5 MB); and
455
+ `PANIC_STYLE = "solana-1.18"`, panics logged as solana-program 1.18's handler logs them since rustc 1.73
456
+ (`panicked at <file>:<line>:<col>:` and the message on the next line, then abort). The lines are checked against
457
+ Percolator v12.20's mainnet binary (test/language/native-log64-zero.test.ts; docs/language-native.md). Existing
458
+ programs build to the same bytes.
459
+ - Showcase: the first stage of a port of Percolator v12.20, `showcase/mainnet/percolator/` (Apache-2.0; educational,
460
+ not audited, not for real funds, as the original says), the immutable mainnet program
461
+ `BCGNFw6vDinWTF9AybAbi8vr69gx5nk5w8o2vEWgpsiw` built from aeyakovenko/percolator-prog `06f86fb` and the engine
462
+ aeyakovenko/percolator `3f55f87` (sha256 `502088e9…cc93`, 395,368 bytes; fetched by `scripts/fetch-programs.sh`, not
463
+ kept here). This stage has 15 of its 27 instructions (market creation and configuration, the authorities, account
464
+ creation, deposits, withdrawals, settles, closes on live markets, reclaims, insurance top-ups, fee credits, CloseSlab)
465
+ and the foundation the rest builds on: the 1,525,624-byte slab byte for byte (u128 aligned to 8, as the SBF binary
466
+ lays it out), the engine's 256-bit arithmetic, the oracle readers, accrual, warm-up and fees. Each transaction goes to
467
+ the port and to the mainnet binary, which must agree on outcome, error code, log lines, inner instructions, return
468
+ data and every account's bytes, in five test files and a seeded fuzz of account sequences (README there).
469
+ - Added: `executable` on a remaining account (`rest.get(i).executable`, Rust's `AccountInfo::executable`), as a native
470
+ program checks a program passed among its accounts before calling it (test/language/remaining-executable.test.ts;
471
+ docs/language-accounts.md). Existing programs build to the same bytes.
472
+ - Showcase: the second stage of the Percolator v12.20 port: TradeNoCpi, TradeCpi and ConvertReleasedPnl (18 of 27
473
+ instructions), with the engine's trade (trade PnL, positions attached at the side's indices, the open-interest
474
+ decomposition, trading fees, the margin rules, warm-up of trade profit) and the conversion of released PnL with its
475
+ haircut. TradeCpi calls a matcher: no build of the author's is deployed for v12.20, so the tests run a TypeSOL port of
476
+ aeyakovenko/percolator-match 199b139 (Apache-2.0, a test fixture) under both the mainnet binary and the port. Tests
477
+ that wrote positions into the slab now trade; a fuzz of trade sequences between many users and LPs runs against the
478
+ binary. The port spends fewer compute units than the original on every successful transaction measured, SettleAccount
479
+ included (it no longer copies the 400-byte config twice where nothing reads it in between, and zeroes its instruction
480
+ context with the memset syscall). verify_token_program now checks the token program is executable, as the original
481
+ does.
482
+ - Showcase: the third stage of the Percolator v12.20 port: KeeperCrank, LiquidateAtOracle and CatchupAccrue (21 of 27
483
+ instructions), with the engine's liquidation (full close and the crank's exact partial, the liquidation fee, bad
484
+ debt), `enqueue_adl` (insurance first, then the loss written into the opposite side's K, A shrunk pro rata, drain-only
485
+ sides, side resets with stale accounts settled at the frozen indices), the crank's candidate handling and hint
486
+ validation, the maintenance-fee sweep with its cursor and dust reclaim, the crank reward and the risk buffer's upkeep,
487
+ and complete and partial catch-ups of the market clock. Tests that wrote drain-only and reset-pending sides, a flat
488
+ account with a loss past its capital and the sweep's fee debt into the slab now reach them with liquidations and
489
+ cranks; a second fuzz walk (leveraged trades, crashes, liquidations, cranks) socialises losses and runs side resets
490
+ to their end against the binary. KeeperCrank's compute units are measured at 2 to 4,096 accounts: the port completes
491
+ every crank the original does within the same limit, and 64 liquidations in one crank, which exceed the original's
492
+ 1.4M units, in about 660,000. The port spends fewer compute units than the original on every successful transaction
493
+ measured (18,713 in the two fuzz walks).
494
+ - Showcase: the fourth stage completes the Percolator v12.20 port (27 of 27 instructions): ResolveMarket,
495
+ ResolvePermissionless, ForceCloseResolved, AdminForceCloseAccount, CloseAccount's resolved arm, WithdrawInsurance and
496
+ WithdrawInsuranceLimited, with the engine's resolution (the ordinary arm with its catch-up and deviation band, the
497
+ degenerate arm at the last price for a dead oracle, a silent Hyperp mark or the hard timeout, terminal K deltas kept
498
+ apart from K, every position stale under a new epoch), the reconciliation of resolved accounts, terminal readiness,
499
+ the payout haircut snapshot and the terminal close (fee debt forgiven, the surplus swept into insurance), and the
500
+ bounded insurance withdrawals (bps cap, 10-unit floor, cooldown). Tests that wrote a resolved market into the slab
501
+ now resolve it, and CloseSlab's insurance and stranded-token cases come from real instructions; only states no
502
+ instruction can make are still written in (README there). Both fuzz walks now end each market's life: resolution by
503
+ the admin or by anyone, every account closed out in random order, the insurance withdrawn, the slab closed, and the
504
+ vault and every token account compared at the end (80 full life cycles in a 40-seed run of each walk). The port spends fewer compute units than
505
+ the original on every successful transaction measured (20,225 in the two fuzz walks) and its binary is
506
+ 360,248 bytes against 395,368 (363,392 bytes after the later fixes).
507
+ - Showcase: the Percolator author's own LiteSVM test suite (aeyakovenko/percolator-prog `06f86fb`, engine `3f55f87`)
508
+ run unchanged against the mainnet binary and against the TypeSOL port: 660 tests pass and 11 are ignored under both,
509
+ with the same outcome for every test (609 of them run the program; the rest test the Rust crates on the host); the
510
+ 11 ignored ones, run too, also agree (4 pass, 7 fail at the same assertions). The TradeCpi tests use the TypeSOL
511
+ matcher fixture under both. `scripts/percolator-author-suite.sh` reproduces it (host build only, downloads nothing);
512
+ counts per file and the author's compute-unit benchmark in the port README.
513
+ - Showcase: the Percolator port's checks made stricter, and what they found. Every test now fails a successful
514
+ transaction with a Percolator instruction at the top level unless the port used fewer compute units than the
515
+ original (the differential harness asserts it for every test file, the keeper-crank measurements included; only the
516
+ matcher's own Init and SPL Token transfers, identified by program id, are exempt). A new fuzz walk runs whole market
517
+ life cycles on Chainlink feeds, inverted markets, Pyth feeds at other exponents with the confidence at its limit, and
518
+ Hyperp markets (40 life cycles in a 10-seed run, no divergence). A test matcher logs the slab as it stands during
519
+ TradeCpi's call (the same in both). Two
520
+ divergences found and fixed in the port: the slab passed again where the original holds its mutable borrow across an
521
+ SPL Token call (a user or admin signing with the slab's keypair, or the slab as CloseSlab's vault authority) failed
522
+ the original with AccountBorrowFailed and succeeded in the port; and the trade's per-side position cap, which the
523
+ original counts in i64, gave another error for counts of 2^63 and more (a patched slab only). One difference on a
524
+ patched slab remains and is pinned in a test (a free-list index past the 4,096 slots: Rust's bounds-check panic
525
+ against TypeSOL's). `scripts/percolator-author-suite.sh` now fails on a test file that does not build or run, on
526
+ totals other than the recorded 671 / 660 / 0 / 11, and on test names that differ between the two runs.
527
+
528
+ - Fixed: `examples/airdrop.ts` let the admin of any pot award points to any `Member`: anyone could set up a pot of
529
+ their own and pass other pots' members to `award`. A member now records its pot (`Member.pot`, PDA
530
+ `["member", pot, owner]`, `join` takes the pot), and `award` refuses a member of another pot (`WrongPot`, 6002).
531
+ - Fixed: `examples/minter.ts` let anyone set up the config of any mint, choosing its admin and cap, for example before
532
+ the mint's owner did. `setup` now takes the mint's current mint authority as the signer (`HasOne<Mut<Mint>,
533
+ "mintAuthority">`, 2016), makes it the admin and moves the mint authority to the config PDA in the same instruction,
534
+ with the token program as a new account. Both examples' binaries and IDLs change; neither is in
535
+ `test/golden/binaries.json`. Tests: test/examples/airdrop.test.ts, test/examples/minter.test.ts (the attacks fail,
536
+ the honest paths work).
537
+ - Docs: the `grow` example of docs/language-accounts.md let anyone resize another user's account; it now takes the
538
+ log's owner (`HasOne`).
539
+ - Docs: claims narrowed to what the tests and benchmarks show. The ports: the same outcome, events, return data and
540
+ account bytes on every compared transaction, and the same error codes and log lines except where each case study
541
+ says (Anchor error-message text, panics reported as numbered errors, Marginfi's informational `msg!` lines, CLMM's
542
+ reward-mint order); Phoenix, Raydium AMM v4, SPL Stake Pool and Percolator match every log line. Compute units:
543
+ fewer than native Rust on every instruction measured, fewer than Pinocchio on counter, vault and escrow, and more
544
+ than Pinocchio on 13 of the 26 instructions of the official examples (a sentence `scripts/readme-bench.ts` now
545
+ writes from `official`). Review status: 0.45.0 to 0.48.0 and the unreleased work have had no security review (README,
546
+ SECURITY.md, docs/audit.md, docs/security-model.md), `runtime/typesol_builtins.c` is in the audit scope table and in
547
+ docs/runtime.md, and `EVENT_AUTHORITY_CHECK` is listed as experimental and in the `emitCpi` guarantee. Transaction
548
+ counts are what a default run compares, with breakdowns per file: Marginfi 2,321 (it said 2,081), Raydium AMM v4 144
549
+ with 60 random steps (it said 484, at 400 steps), SPL Stake Pool 2,107 in five files (it said six), coral-xyz/multisig
550
+ 55 (it said 52), Percolator 139,185 in its sixteen files, 3,711 of them in its fixed-seed walks and 128,320 from its
551
+ mutation fuzzers (it said 6,028, the first ten files). The cross-host measurement is the one made with
552
+ 0.45.0 over the 76 programs of its sources; Meteora DBC and Percolator are not in `test/golden/binaries.json`. Also:
553
+ every fuzzer and how it is seeded (docs/testing.md, docs/audit.md), the manifest's `showcase/mainnet` programs and the
554
+ release record's `"tests"` field, what `pnpm fetch:programs` fetches, the mainnet escrow as a benchmark record and
555
+ what its make_offer spends in the ATA program, the escrow case study's figures from the 0.48.0 run, the licence of the
556
+ Meteora port's tests and fixtures, and `llms.txt` listing every port. The destructuring example of
557
+ docs/language-statements.md let anyone overwrite another player's account; it now requires its owner's signature.
558
+ - Showcase: `showcase/mainnet/meteora-dbc/README.md` describes the finished port (released in stages in 0.48.0): Meteora
559
+ Dynamic Bonding Curve 0.2.2, all 35 instructions, with its migrations into DAMM v1 and DAMM v2, checked against the
560
+ mainnet binary on outcome, error code, account bytes, inner instructions, events and return data (log text and
561
+ compute units not compared). The port, its tests (`showcase/test/meteora-dbc*.ts`) and their fixtures
562
+ (`showcase/test/fixtures/meteora-dbc/`) are under Meteora's Non-commercial Licence (NOTICE), which README.md and
563
+ LICENSE now say.
564
+
9
565
  ## 0.48.0 — 2026-11-14
10
566
 
11
567
  A minor release: it adds three built-ins (`transferCheckedWithHook`, the processed sibling instructions,
@@ -128,7 +684,6 @@ and still compile build to the same bytes.
128
684
  which needs `@anchor-lang/core`, and did not see `emitCpi` events. `t.coder` does not change. TypeSOL's Borsh coder
129
685
  decodes events as Anchor's `coder.events.decode` does (test/client/idl-coder.test.ts compares the two on random
130
686
  values for every program with events, and on a wrong discriminator, which both decode as null).
131
-
132
687
  - Changed, now refused: a call of a helper that returns the result of `merkleVerify`, `verifyEd25519` or
133
688
  `verifySecp256k1` whose result decides nothing. 0.46.0 refused such a call of the three themselves (as a statement,
134
689
  as the condition of an `if` with an empty body, kept in a local never read) but compiled the same through a helper,