@typesol/cli 0.49.0 → 0.51.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 (79) hide show
  1. package/CHANGELOG.md +541 -0
  2. package/NOTICE +9 -0
  3. package/README.md +34 -15
  4. package/SECURITY.md +6 -3
  5. package/dist/cli.js +36 -5
  6. package/dist/compiler/analyze.d.ts +10 -1
  7. package/dist/compiler/analyze.js +234 -20
  8. package/dist/compiler/diagnostics.d.ts +4 -0
  9. package/dist/compiler/diagnostics.js +5 -1
  10. package/dist/compiler/emit/base.d.ts +35 -4
  11. package/dist/compiler/emit/base.js +46 -4
  12. package/dist/compiler/emit/borsh.js +8 -8
  13. package/dist/compiler/emit/calls.d.ts +6 -0
  14. package/dist/compiler/emit/calls.js +98 -18
  15. package/dist/compiler/emit/cpi-core.d.ts +3 -0
  16. package/dist/compiler/emit/cpi-core.js +11 -5
  17. package/dist/compiler/emit/cpi.js +6 -4
  18. package/dist/compiler/emit/create.js +9 -9
  19. package/dist/compiler/emit/expressions.d.ts +9 -1
  20. package/dist/compiler/emit/expressions.js +77 -0
  21. package/dist/compiler/emit/function.d.ts +2 -0
  22. package/dist/compiler/emit/function.js +71 -15
  23. package/dist/compiler/emit/outline.d.ts +35 -0
  24. package/dist/compiler/emit/outline.js +547 -0
  25. package/dist/compiler/emit/program.js +19 -4
  26. package/dist/compiler/emit/rbtree.js +1 -1
  27. package/dist/compiler/emit/shared.d.ts +69 -4
  28. package/dist/compiler/emit/shared.js +44 -9
  29. package/dist/compiler/emit/statements.d.ts +36 -2
  30. package/dist/compiler/emit/statements.js +332 -29
  31. package/dist/compiler/emit/storage.d.ts +16 -0
  32. package/dist/compiler/emit/storage.js +134 -13
  33. package/dist/compiler/emit/views.js +1 -1
  34. package/dist/compiler/hints.d.ts +1 -1
  35. package/dist/compiler/hints.js +9 -1
  36. package/dist/compiler/idl.js +1 -1
  37. package/dist/compiler/index.d.ts +30 -2
  38. package/dist/compiler/index.js +94 -16
  39. package/dist/compiler/model.d.ts +13 -1
  40. package/dist/compiler/stack.d.ts +71 -0
  41. package/dist/compiler/stack.js +309 -0
  42. package/dist/compiler/toolchain.d.ts +87 -5
  43. package/dist/compiler/toolchain.js +384 -19
  44. package/dist/keys.d.ts +12 -1
  45. package/dist/keys.js +57 -7
  46. package/dist/workspace.d.ts +9 -0
  47. package/dist/workspace.js +91 -16
  48. package/docker/deps/0.50.0.lock.json +1206 -0
  49. package/docker/deps/0.51.0.lock.json +1206 -0
  50. package/docs/architecture.md +1 -1
  51. package/docs/audit.md +16 -13
  52. package/docs/case-study-escrow.md +1 -1
  53. package/docs/case-study-jito-mev.md +14 -14
  54. package/docs/case-study-marginfi.md +127 -127
  55. package/docs/case-study-multisig.md +16 -4
  56. package/docs/case-study-raydium-clmm.md +44 -28
  57. package/docs/case-study-raydium-cp-swap.md +18 -18
  58. package/docs/cli.md +5 -4
  59. package/docs/glossary.md +2 -1
  60. package/docs/language-accounts.md +16 -10
  61. package/docs/language-basics.md +29 -2
  62. package/docs/language-builtins.md +4 -2
  63. package/docs/language-cpi.md +34 -0
  64. package/docs/language-native.md +50 -4
  65. package/docs/language-pdas.md +6 -2
  66. package/docs/language-statements.md +103 -12
  67. package/docs/language-types.md +93 -8
  68. package/docs/runtime.md +20 -3
  69. package/docs/security-model.md +6 -3
  70. package/docs/stability.md +10 -5
  71. package/docs/testing.md +6 -2
  72. package/docs/troubleshooting.md +45 -1
  73. package/lib/typesol.d.ts +25 -3
  74. package/llms-full.txt +403 -54
  75. package/package.json +1 -1
  76. package/releases/0.49.0.json +857 -0
  77. package/releases/0.50.0.json +874 -0
  78. package/runtime/typesol_builtins.c +47 -2
  79. package/runtime/typesol_rt.h +254 -54
package/CHANGELOG.md CHANGED
@@ -6,6 +6,547 @@ codes, and says so here.
6
6
 
7
7
  ## Unreleased
8
8
 
9
+ ## 0.51.0 — 2026-11-30
10
+
11
+ A minor release: it fixes programs that built but computed wrong results (stack frames the SBF backend lays out wrongly
12
+ on SBPF v0, v1 and v2, `===` on structs, data enums and lists, `s += f()` on strings, `loadAccountMut` views kept
13
+ after a `break` or `return`) and two compiler crashes, makes three runtime paths cheaper (the base58 text of keys,
14
+ the seed-limit check, the bump search), adds object-type structs, `extends`, struct spreads, labeled statements and
15
+ `||=`, `&&=`, `??=`, and lays out a program that does not fit the stack another way before refusing it. Changed,
16
+ now refused: a v0 call that passes arguments past a full frame, a v1/v2 frame over 32,767 bytes or call path over
17
+ 256 KiB (each only when the new layouts do not make it fit), and `===`, `!==`, `==`, `!=` on structs, data enums,
18
+ lists, Options of a struct and accounts; their binaries were wrong. Changed: seeds whose bumps 255 to 1 are all on the
19
+ curve have no address (2006), as on Solana. Error codes and their order are otherwise unchanged. Of the 81 programs
20
+ both releases build, 32 build to the same bytes as with 0.50.0 and 49 differ, all from the runtime changes, from 896 bytes smaller
21
+ (Marginfi) to 1,840 bytes larger (the program-examples create-account, which writes a key into a log line; Phoenix,
22
+ which does too, is 1,712 larger); their tests pass. The fixes and the language
23
+ additions alone leave every program that still builds at the same bytes.
24
+
25
+ - A `Pubkey` or `Hash` in a template string (`` `${key}` ``, so also in `` log(`…${key}`) ``) costs about 460 fewer
26
+ compute units per key: an instruction logging one random key went from 1,393 to 933 CU, and the official examples'
27
+ `create_system_account`, `set_favorites` and `create_token_mint` from 4,074 to 3,614, 6,514 to 6,051 and 41,110 to
28
+ 40,646 (`transfer_tokens`, three keys: 8,390 to 7,018). The runtime wrote the base58 text by long division, a 64-bit
29
+ division per remaining 32-bit limb for every five digits; it now converts the eight limbs at once, multiplying them
30
+ by a table of constants (each limb's weight written in base 58^5) and carrying, as Firedancer's encoder does. A key
31
+ whose first 20 bytes are zero (below 2^96) keeps a long division over its last 12, which is cheaper there, and the
32
+ zero key (the System Program's address) is written directly, so every key measured costs less than before (one key
33
+ with 0, 1, 2, 3, 4, 5, 6, 8, 12 or 16 leading zero bytes: 895 to 982 CU against 1,007 to 1,393; with 20, 24, 28 or
34
+ 31: 719 to 761 against 726 to 899; the zero key: 193 against 598). The text is the same for every key:
35
+ test/language/base58.test.ts compares a program's log lines with a reference and @solana/kit's codec on edge cases
36
+ (zero, all 0xff, 1 to 32 leading zero bytes, powers of 2 and of 58 and their neighbours) and on 20,000 seeded random
37
+ keys, one in eight with leading zero bytes. `log(key)` (the `sol_log_pubkey` syscall) is unchanged. A program that
38
+ puts keys in strings is 1.6 to 1.8 KB larger (the table and the two paths).
39
+ - The run-time check of Solana's seed limits (each seed at most 32 bytes, at most 16 seeds with the bump) is left out
40
+ of a derivation whose seed list cannot exceed them: every seed's length is known at compile time (keys, integers,
41
+ enums, `bigEndian`, string literals and constants), and the count was already checked by the compiler.
42
+ `findProgramAddress`, `findProgramAddressBump`, `findProgramAddressWithBump`, `createProgramAddress`, `requirePda`,
43
+ `Seeds<…>` and the event-authority check use the runtime's unchecked forms for such lists (`ts_find_pda_fit`,
44
+ `ts_create_pda_address_fit`, `ts_require_pda_fit`). `create`, `createIfNeeded`, `createPda` and the token creates,
45
+ one copy each in a program, leave it out when every list the program passes them is such a list (the generated C
46
+ defines `TS_PDA_SEEDS_FIT`). The runtime's own derivations (associated token accounts, Metaplex metadata and
47
+ editions, ProgramData, the event authority, the extra-account-metas list) leave it out too. A list with a `string`
48
+ value keeps the check exactly where it was, and a seed over 32 bytes still fails with 2006
49
+ (test/language/seed-limits.test.ts). A few compute units per derivation: `increment_page_visits` 481 to 449,
50
+ `close_user` 712 to 686, `counter.initialize` 1,856 to 1,852.
51
+ - The canonical-bump search tries the bumps 255 down to 1, as `sol_try_find_program_address` and
52
+ `Pubkey::find_program_address` do (Agave's loop runs 255 times from bump 255); it went on to bump 0. Seeds whose
53
+ bumps 255 to 1 all give points on the curve (a chance of about 2^-255 per list) now have no address, as on Solana:
54
+ `findProgramAddress` and its forms fail with 2006, and so do `create` and `Seeds<…>` for any account passed, where
55
+ TypeSOL found bump 0 and an address Solana's derivation never gives. test/language/pda-search.test.ts runs the
56
+ search with the hash and curve syscalls replaced, so that it chooses which bumps give an address.
57
+
58
+ - SBPF v0: a call that passes arguments on the stack past a full frame is refused. A helper call with more than 5
59
+ arguments in C puts the rest on the stack, after the caller's locals; with the caller's frame at the 4 KiB limit
60
+ they overwrote the caller's own values. clang's SBF backend printed "A function call in method … overwrites values in
61
+ the frame" (or "Stack offset of N exceeded max offset of M") and still built, and the build discarded that output: an
62
+ affected program ran and returned wrong values (one test program returned 0x2048 where 0x32 is right). The build now
63
+ fails on these messages, naming the instruction or helper and the helpers it calls with arguments on the stack, with
64
+ what to do (docs/troubleshooting.md). A program that printed the message but happened to compute the right result is
65
+ refused too.
66
+ - SBPF v1 and v2: a function whose stack frame is over 32,767 bytes is refused. Frames are sized per function there, but
67
+ a load or store reaches its slot with a signed 16-bit offset, and clang encodes a larger offset wrapped (+34,284 as
68
+ -31,252) without a message: an affected program built silently and read and wrote the wrong memory (two test
69
+ programs with frames of 36,288 and 40,384 bytes returned wrong sums). The build now applies clang's frame check at
70
+ 32,767 bytes on v1 and v2, with its own message. A program with a frame between 32,768 and about 34,300 bytes that
71
+ happened to run correctly is now refused as well; that is intended, as its offsets are past the encodable range.
72
+ - SBPF v1 and v2: a program whose deepest call path needs more than 256 KiB of stack is refused. All the frames of a
73
+ call path share one 256 KiB stack, and past it the program failed at run time with an access violation (a chain of
74
+ frames totalling 265,024 bytes failed; 244,800 ran). After linking, the build now measures the deepest path from the
75
+ program's own instructions (its calls and the frame each function reserves, so a helper clang inlined counts in its
76
+ caller, and the helpers it calls stay on the path) and refuses one over 262,144 bytes, listing the path with each
77
+ function's frame. An indirect call, which TypeSOL does not generate, would make the path unmeasurable; such a program
78
+ is refused with a request to report it.
79
+ - Added: a program that does not fit the stack (any of the three refusals above, or a v0 frame over 4 KiB) is laid out
80
+ another way by the build before it gives up, in a fixed order, measuring with clang after each step: (1) the
81
+ statements of the function that does not fit, and of the helpers inlined into it, get C blocks of their own, so clang
82
+ can give the temporaries of different statements one slot (three struct literals assigned to account fields went
83
+ from a 4,352-byte frame to 1,472); (2) helpers inlined into it are kept out of line, as `@noinline` would, largest
84
+ frame first, never one that takes a function or is marked `/** @inline */` (about 10 compute units per call);
85
+ (3) in an instruction, its largest list and struct locals, and the struct results of helpers it holds, go on the
86
+ heap, as `@heap` would put them (one allocation per declaration or call site, reused by a loop; about 17 compute
87
+ units each), while the instruction's heap locals together fit in the heap, never one marked `/** @stack */`. Each
88
+ step is printed as a note and recorded in `<name>.build.json` (`stack`: the actions in order, and the frames before
89
+ and after); `typesol verify` takes the same steps from the same sources. When none is enough, the error is the one
90
+ the build gave before, with a line saying what was tried. `const STACK_AUTO = false` in the program, or
91
+ `typesol build --stack-auto off`, turns it off. A program that fits is not touched: none of this runs for it, its C
92
+ and binary are the same as before, and its manifest has no `stack` field (docs/language-basics.md, "Memory").
93
+ - The documentation said the stack limit "does not apply" on SBPF v1 and v2. It now says that the 4 KiB per-function
94
+ limit is lifted there, but a frame holds at most 32,767 bytes and the whole stack 256 KiB (docs/language-basics.md,
95
+ docs/troubleshooting.md, docs/language-statements.md, docs/language-types.md).
96
+ - `===`, `!==`, `==` and `!=` on two structs, data enums, lists, Options of a struct or accounts are refused. They
97
+ compiled to a comparison of C pointers, so they tested where the two values were held, not what they held; and the
98
+ compiler copies such values where JavaScript would pass the same object (a helper's struct parameter, a local declared
99
+ with its type), so the answer could differ from JavaScript's: `same(h, h.p, h.p)` with `return p === q` gave false
100
+ where JavaScript gives true. Each is now a compile error that says what to compare instead (the fields, `.kind`,
101
+ `.length` and the elements, `.key`). Comparisons of integers, booleans, enums, `Pubkey`s, strings and Options of those,
102
+ and of an Option with `null`, are unchanged (docs/language-statements.md, "What is refused").
103
+ - `declare function` and overload signatures on a helper crashed the compiler (`TypeError: Cannot read properties of
104
+ undefined (reading 'kind')`). Both are now refused with a message: a declared function has no body to compile, and
105
+ overloads are to be written as one function with an `Option<T>` parameter for an argument that may be left out.
106
+ - `s += x` on a local string read `s` after `x` ran. When `x` assigned `s` (through a closure it called), the result was
107
+ built from the new value: with `s = "A"` and `f` setting `s` to `"B"` and returning `"C"`, `s += f()` gave `BC` where
108
+ JavaScript gives `AC`, and `` s += `[${f()}]` `` gave `B[C]` for `A[C]`. The value of `s` from before the right side
109
+ ran is now the one appended to. The generated C is unchanged when the right side does not write `s`. Account text
110
+ (`FixedString` fields) and `s = s + x` already read the left side first.
111
+ - Added: `type Point = { x: u64; y: u64 }` is a struct, as `interface Point { … }` is: account data, arguments, results,
112
+ events, helper parameters and fields of other structs. An object type with `kind: "Name"` stays a data enum of one
113
+ variant. Generic object types, intersection types and account groups written as object types are refused with a
114
+ message saying what to write.
115
+ - Added: `interface B extends A, C { … }` with structs of the program as parents: B's fields are A's, then C's, then
116
+ its own, in that order (its layout and its IDL order). A field in two parents with one type is one field; differing
117
+ types, redeclaring an inherited field, generic parents, data enums and account groups as parents are refused. A `B`
118
+ is not passed or assigned where an `A` is expected (JavaScript would pass the object itself, which TypeSOL, copying
119
+ structs, cannot reproduce): the message says to write `{ ...b }`.
120
+ - Added: spreads in struct literals, `{ ...p, x: 1n }` and `{ x: 1n, ...p }`, with p a struct place or struct account
121
+ of the literal's type, a parent of it or a child of it. Entries run left to right, each once, later ones winning, and
122
+ a spread reads p's fields at its place, as in JavaScript. A spread copies as assignment does; a field holding a
123
+ struct, list or data enum (which JavaScript would share between the two values) must be given after the spread
124
+ (`pos: { ...p.pos }`), else the literal is refused. Spreads in `emit<T>(…)`, data enum literals, list literals and
125
+ built-ins' object arguments are refused.
126
+ - Added: labeled statements. `break label` and `continue label` on `for`, `for … of`, `while` and `do … while` at any
127
+ depth, and `break label` out of a labeled block, as in JavaScript (a `for`'s update runs on `continue label`). A label
128
+ on any other statement, and two labels on one, are refused. A `loadAccountMut` view held by a loop the jump leaves is
129
+ dropped first, as at the end of that loop's pass.
130
+ - Added: `x ||= v` and `x &&= v` on booleans and `x ??= v` on Options (also of a struct), wherever `x = v` is accepted:
131
+ the place is found once and `v` runs, and is written, only when JavaScript would run it. On other types they are
132
+ refused, with the `if` to write instead.
133
+ - A `const c: Action = cond ? { kind: "A", … } : { kind: "B" }` local of a data enum compiles (it was refused with
134
+ "expected a Action"), and a lone `;` statement is accepted.
135
+ - Messages: the first error now names the construct and what to write for type forms TypeSOL does not have (unions of
136
+ types or literals, `Readonly<T>`, `Pick<…>` and the other utility types, `keyof`, `typeof` and indexed access in a
137
+ type, type predicates, function-typed fields), nested `function` declarations, `x++` and `x += …` used as values,
138
+ `void`, `new`, `debugger`, `satisfies` on an object literal, `this`, `f.call(…)`, a function called where it is
139
+ written, one instruction calling another, `for … of` over a string, a string's `.length` used as a `u64`, `let` on a
140
+ struct, spreads in list literals, re-exports and export lists, and generic helpers whose type parameter cannot be
141
+ inferred. The errors that only followed from a first one (a call of the refused nested function, uses of a refused
142
+ local, a parameter naming a struct whose declaration failed) are no longer reported.
143
+ - Fixed: a plain `break` out of a loop whose body held a `loadAccountMut` view left the view's claim in place, so
144
+ loading the same account again after the loop failed with 2040 (JavaScript has no such failure). The claim is now
145
+ dropped before the `break`, as the end of a pass drops it. Programs without such a loop build to the same C.
146
+ - Fixed: a `return` from inside such a loop in a helper or a closure left the claim in place too, so the caller
147
+ failed with 2040 when it loaded the same account again. The views of every loop the `return` leaves are now dropped
148
+ before it (a `return` of an instruction needs nothing: no code of it runs after). Programs without such a return
149
+ build to the same C.
150
+ - Programs that built before build to the same C: the generated C of the 263 programs under examples/, showcase/ and
151
+ test/fixtures that build is byte-identical before and after these changes (scripts/codegen-snapshot.ts).
152
+
153
+ ## 0.50.0 — 2026-11-26
154
+
155
+ A minor release: it adds a port of Percolator v16 (all 50 instructions of aeyakovenko/percolator-prog at 7b110913,
156
+ compared with a reference built from the author's source, as no v16 build is deployed) and the built-ins it needed
157
+ (`copyData`, `getReturnData()`, `PANIC_STYLE = "pinocchio"`), copies and zeroes whole values and account data with the
158
+ memory syscalls where the word loops cost more, and fixes overlapping struct copies between views of one account, other
159
+ programs' `@layout borsh` accounts with a discriminator shorter than 8 bytes, `realloc` of `@layout borsh` accounts, the
160
+ folding of a signed minimum modulo -1, the order in which `log64` and `require` read their arguments, `**` inside
161
+ `panicsAt` and builds with a clang above 20. Build manifests now bind a binary to the sources that built it, first
162
+ builds that run at once keep every program's address, and `init` and `new` refuse to write through a symbolic link.
163
+ Programs that compiled with 0.49.0 and still compile build to the same bytes, except 15 of the 80 programs both releases
164
+ build: examples/escrow, ledgerbook and profiles, Jito's two programs, Marginfi, Meteora DBC, Percolator v12.20 and its
165
+ matcher, Raydium CLMM and CP-Swap, SPL Stake Pool and the program-examples realloc, token escrow and token fundraiser,
166
+ for the memory syscalls and the fix of overlapping copies (Raydium CLMM also because its source no longer writes four
167
+ kinds of `msg!` line); their tests pass.
168
+
169
+ - Build manifests (`<name>.build.json`) now bind the binary to the exact sources that built it. A source's sha256 was
170
+ computed after the build, by reading the file again, so a file saved while the build ran (an editor saving mid-build)
171
+ could be recorded beside a binary made from its previous text, and a test reusing that build (`testProgram`,
172
+ `buildForTest`) would take it as current. The build now hashes the bytes the compiler parsed (read once and checked
173
+ against the text TypeScript holds) and the runtime files before clang reads them, hashes every input again once the
174
+ binary is linked, and fails with no manifest when one changed; a previous build's manifest is removed before anything
175
+ is written (docs/cli.md; test/cli/toolchain.test.ts). Binaries are unchanged.
176
+ - First builds that run at once no longer lose a program's address. Two first builds of different programs (each holds
177
+ only its own program's lock) could read `typesol.json`, each add its address and write it back, the later write
178
+ dropping the earlier address (or a reader seeing a partly written file); and a keypair file was created by an
179
+ existence check and an ordinary write, so two first users of one could each make a key and the later replace the
180
+ earlier. `typesol.json` is now changed one process at a time (`typesol.json.lock`) and replaced whole by a rename,
181
+ also by `typesol new`; a keypair is written to a temporary file and linked into place, which fails if it exists, and
182
+ the process that loses reads the winner's key (docs/cli.md; test/cli/workspace.test.ts).
183
+ - `typesol init` and `typesol new` refuse to write through a symbolic link inside the project: a linked `programs/`,
184
+ `tests/` or `.cursor/`, or a link (even a dangling one) where a new file goes, used to receive the file wherever it
185
+ pointed. Files are now also created exclusively, so one created in the meantime is never overwritten. The project
186
+ directory itself may still be a link (docs/cli.md; test/cli/workspace.test.ts).
187
+ - Release manifests (`scripts/release-manifest.ts`): the test corpus hash now covers `showcase/test/` as well as
188
+ `test/` (the mainnet ports' differential tests, helpers and fixtures were left out, so a weakened comparison left the
189
+ hash unchanged) and records the directories it covers (`corpus.roots`). The script also refuses to make a release
190
+ manifest when `test/programs/SOURCES.md` lists a reference binary the tree lacks (`--allow-missing-references`
191
+ records them as `referencesMissing` instead) (docs/testing.md; test/cli/release-manifest.test.ts).
192
+ - Raydium CLMM and multisig ports: their tests now compare what the repository overview claims. For every transaction,
193
+ the bytes of every account an instruction names (not only a chosen list), the inner instructions, the return data
194
+ and the log lines are compared too, with the exceptions each test declares (Anchor's `Instruction:` line and its
195
+ error-message text; for Raydium CLMM also the Associated Token program's Create, called with `[0]` by the original
196
+ and with empty data by the port, pinned in the test). Where the original CLMM panics, the test now requires its
197
+ `ProgramFailedToComplete` and a numbered error from the port. The stronger comparison found that the Raydium CLMM
198
+ port logged four kinds of `msg!` line (from seven places) the deployed program does not: its source writes them only
199
+ with the `enable-log` feature, and the deployed binary holds none of their text. The port no longer writes them,
200
+ which also makes its swaps cheaper (docs/case-study-raydium-clmm.md has the new figures; its binary is 546,080
201
+ bytes, was 551,440); the golden reference (test/golden/binaries.json) is regenerated in the build container with
202
+ it and with the Marginfi and SPL Stake Pool binaries the runtime's changes give. 308 Raydium CLMM
203
+ transactions (not 302 as listed) and 55 multisig ones are compared.
204
+ - Percolator v16 tests: `World.restore` now removes an account its snapshot recorded as missing (one a transaction
205
+ created since survived the restore); no result of the v16 files that restore a world changed.
206
+
207
+ - Fixed (wrong account data, since 0.42.0): a whole struct or array assigned between two views of one account whose
208
+ bytes overlap, the destination after the source by less than the value's size, did not end with the source's value:
209
+ the copy went forward 8 bytes at a time and re-read bytes it had already written (copying a two-word value one word
210
+ 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
211
+ any size below 80 bytes (from 80 the memmove syscall copies them, as in the entry below), so the destination ends
212
+ with the source's old bytes in either direction, as Rust's `copy_within` leaves them. Only views of one account at
213
+ run-time byte offsets can overlap that way: `loadRawAt` / `loadRawMutAt` (0.43.0 on), or two views of an account
214
+ passed twice under `NATIVE_ACCOUNT_WRITES` (0.42.0 on). A program is affected if it assigns `d.v = s.v` (or a whole
215
+ view) between such views of one account and the destination's offset can be ahead of the source's by less than the
216
+ value's size; copies between different accounts, distinct fields, elements of one array, through a local, or by
217
+ `copyData` were right. The copy costs the same or less than before. Five of the 81 programs in the release manifest
218
+ 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
219
+ elements of one array), their tests pass, and Marginfi's instructions cost 5 to 49 CU less
220
+ (docs/language-native.md; test/language/bulk-copies.test.ts, which no longer pins the old result).
221
+ - Fixed (wrong account data, since 0.39.0): another program's `@layout borsh` account (`Owner<Account<T>, "…">`)
222
+ whose struct declares a discriminator shorter than 8 bytes (`/** @discriminator 0x07 */`) was decoded from byte 8
223
+ instead of right after its discriminator: its fields were read from the wrong bytes (the valid account `[7, 42]`
224
+ of a struct holding one `u8` did not read 42), and an account shorter than 8 bytes made the decoder's length wrap and
225
+ read past the account's data. Its size was checked against the struct's in-memory size, not its smallest Borsh
226
+ 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`
227
+ and `@discriminator` of 1 to 7 bytes and taken as `Owner<Account<T>, "…">`; fixed-layout structs with a shorter
228
+ discriminator were read right. The length check of a growable `Vec` in such a fixed-layout struct counted 8 bytes
229
+ of discriminator and refused accounts of the right size (3003); it now counts the declared length. `initAccount<T>`
230
+ of a struct with a shorter discriminator is now refused when compiling (it writes this program's 8 bytes)
231
+ (docs/language-accounts.md; test/language/foreign-account.test.ts).
232
+ - Fixed (since 0.17.0): `realloc` of a `@layout borsh` account refused sizes below its discriminator and the struct's
233
+ in-memory size (3016), which reserves the full capacity of every `FixedString` and `FixedVec`: an account whose
234
+ only field is an empty `FixedString<64>` could not shrink to the 12 bytes of its Borsh form, although its load
235
+ accepts 12. The smallest size is now the discriminator and the smallest Borsh form, the size the load checks; the
236
+ value written back when the instruction returns must still fit (3004 otherwise, as before). A program is affected
237
+ if it calls `realloc` on a `@layout borsh` account with a size that can fall below that bound: such transactions
238
+ failed with 3016 and now succeed (docs/language-accounts.md; test/language/realloc.test.ts).
239
+ - Fixed: a signed type's minimum reduced modulo -1 in a typed constant (`const X: i8 = -128n % -1n`) folded to 0,
240
+ while the same remainder at run time fails with 5100, as Rust's checked `%` does. It is now a compile error, as the
241
+ quotient `-128n / -1n` already was, at every signed width; an untyped constant stays a bigint without a width
242
+ (docs/language-basics.md, docs/language-types.md; test/language/signed-remainder.test.ts).
243
+ - Fixed: `log64(a, b, c, d, e)` lowered all five arguments before reading any, so an argument that runs code
244
+ changing an earlier one's value (`log64(a.count, bump(a), …)`) logged the changed value; each argument is now read
245
+ before the next is evaluated. `require(condition, code)` with an error code computed at run time likewise tested its
246
+ condition after computing the code; the condition is now read first. The other built-ins taking several values
247
+ already read them in order. Of the programs in the release manifest only Percolator v12.20's C changes (its
248
+ `log64` call reads a temporary one line earlier), and it builds to the same binary for this
249
+ (docs/language-statements.md; test/language/argument-order.test.ts).
250
+ - Fixed: inside `panicsAt(location, …)`, `**` took the panic for its multiplications ("attempt to multiply with
251
+ overflow" at the location) instead of failing with 5100 as its declaration says; it now fails with 5100, and an
252
+ operator written in its operands still panics at the location (docs/language-native.md; test/language/pow.test.ts).
253
+ - Fixed: a program built with a clang above 20 (platform-tools v1.57's clang 22, an untested toolchain, which TypeSOL
254
+ warns about but builds with) faulted at its first 128-bit multiplication or variable 128-bit shift ("Access
255
+ violation writing 8 bytes at address …"): the runtime's assembly `__multi3`, `__ashlti3`, `__lshrti3` and
256
+ `__ashrti3` take the result's address in r1, as clang 20 calls them, while clang 22 passes the first operand there
257
+ and takes the result in registers. The assembly is now compiled only for clang 20 and earlier; any later clang gets
258
+ C definitions of the four, which follow its own convention (test/language/builtins.test.ts runs them on every case
259
+ of every function for SBPF v0, v1 and v2; docs/runtime.md). With the tested toolchain nothing changes: every program
260
+ in the golden manifest builds to the same bytes.
261
+ - Added: `PANIC_STYLE = "pinocchio"`: a Rust panic as pinocchio's `entrypoint!` panic hook reports it under std, the
262
+ location's file verbatim (`src/v16.rs`, or a toolchain path such as
263
+ `/home/runner/work/platform-tools/platform-tools/out/rust/library/alloc/src/raw_vec/mod.rs`), then
264
+ `** PANICKED **`, then abort ("SBF program panicked"). `panic(message, location)` and `panicsAt` take the file
265
+ alone or `file:line:column` (only the file is logged; the message may be null); `PANIC_ON_OVERFLOW` is refused
266
+ beside it. Every panic site calls one shared helper. Checked line for line against a binary built with pinocchio
267
+ 0.11.1's entrypoint (test/language/pinocchio-panics.test.ts; docs/language-native.md).
268
+ - Added: `getReturnData()`: Rust's `get_return_data()`, `const [program, data] = getReturnData()`, the return data of
269
+ any length (up to 1,024 bytes) and the program that set it, unchecked, read with instruction data's methods; Rust's
270
+ `None` is `data.length === 0n`. `returnData<T>(program)` is unchanged (test/language/get-return-data.test.ts;
271
+ docs/language-cpi.md).
272
+ - Tests: a native program at `MAX_ACCOUNTS = 255n` takes a fixed prefix and a tail of 39 and 255 accounts with
273
+ repeats, reads and writes through them and forwards the tail whole in a CPI (test/language/many-accounts.test.ts).
274
+ - Showcase, Percolator v16 (work in progress, 0 of 50 instructions ported, not listed among the ports): the entry
275
+ of the port (the tag dispatch, every tag refused), compared with the Rust build of the pinned commits on empty data
276
+ and all 206 unknown tags; the reference's entrypoint recorded at its limits: 255 accounts (256 refused by the
277
+ runtime), its heap, RefCell conflicts on repeated accounts and its panic lines, partly through a probe built with
278
+ the same entrypoint (`scripts/percolator-v16-reference/probe.sh`; showcase/mainnet/percolator-v16/TESTING.md).
279
+ Every program in the golden manifest builds to the same bytes.
280
+ - Showcase, Percolator v16 (still 0 of 50 instructions ported): the persisted layouts as packed views tied field by
281
+ field to the offsets rustc prints for the pinned sources, the engine's wire conversions, `PercolatorError` and the
282
+ engine-error mapping, and `Instruction::decode` for all 50 tags, compared with the reference on every decode refusal
283
+ (field cuts, trailing bytes, vector counts, random bodies) and on where decoding ends; a decoded instruction ends in a
284
+ placeholder error until its handler is ported (showcase/mainnet/percolator-v16/README.md).
285
+ - Added: `copyData(account, from, to, length)`: a copy within one account's data, as a native program's
286
+ `data.copy_within(from..from + length, to)` (or a struct copied out and written back at another offset), with the
287
+ memmove syscall from 32 bytes (about constant compute units whatever the length, where a whole-struct assignment
288
+ moved words one by one until the change below); overlapping ranges allowed, 3003 past the end with nothing copied, 3006 on a read-only
289
+ account without `NATIVE_ACCOUNT_WRITES` (test/language/native-copy-data.test.ts; docs/language-native.md). Every
290
+ program in the golden manifest builds to the same bytes.
291
+ - Showcase, Percolator v16 (24 of 50 instructions ported, not listed among the ports): InitMarket, InitPortfolio,
292
+ Deposit, ClosePortfolio, UpdateAuthority, UpdateAssetAuthority, the four market-authority policies,
293
+ UpdateBackingFeePolicy, UpdateTradeFeePolicy, ConfigurePermissionlessResolve, UpdateBaseUnitMints, the two ledger
294
+ syncs, ConfigureEwmaMark, PushEwmaMark, ConfigureAuthMark, PushAuthMark, SetMatcherConfig, UpdateAssetLifecycle
295
+ (activation with the market grown by one slot, drain-only, retirement, shutdown into recovery; a permissionless
296
+ activation's insurance deposit and a lapsed backing bucket's expiry end in the port's placeholder),
297
+ RestartAssetOracle and CanonicalizeSpentBackingHistory, with the engine code they reach (the configuration's exact
298
+ solvency envelope, the market's shape, a portfolio's validation against the market, deposits, portfolio
299
+ registration, the raw oracle target, asset accrual and committed funding, slot activation, retirement, recovery and
300
+ restart). Compared whole with the Rust build of the pinned commits on their success paths and refusals, every
301
+ account position, a random walk that keeps the market live, a mutation fuzzer over the market, portfolios and both
302
+ ledgers, and seeded fuzzes of mark pushes and funding accruals (22,027 transactions, 5,944 successes); the port uses
303
+ 31% to 69% of the reference's compute units on average per instruction, fewer on every success. With
304
+ ConfigureAuthMark and SetMatcherConfig ported the author's own suite gets through its set-up
305
+ (showcase/mainnet/percolator-v16/README.md and TESTING.md). `scripts/percolator-v16-reference/author-suite.sh` takes
306
+ `TEST_FILTER` to run a subset of the author's tests.
307
+ - Changed (generated code of existing programs): whole values and account data are copied and zeroed by the memory
308
+ syscalls where the word loops cost more (measured table in runtime/typesol_rt.h; docs/runtime.md). A struct or
309
+ array copied whole between places reached through pointers (account data, views, a helper's struct parameter) is
310
+ the memmove syscall from 80 bytes (16 CU up to 2,749 bytes, where the unrolled loads and stores cost 26 at 80 bytes
311
+ and the loop about 1 CU a byte from 400), and zeroed whole there (`x.o = null` on an `Option<struct>`) the memset
312
+ syscall from 192. A copy into or out of a local of the function (a struct literal built in a temporary, a helper's
313
+ result, a local copy, Borsh fields, instruction arguments, events) takes the syscall only from 400 bytes, a local
314
+ zeroed whole from 600, where clang stops unrolling: below that it drops the stores and loads nothing reads, which an
315
+ opaque call prevents (measured with 80 and 192 there: SPL Stake Pool up to 2,825 CU more, Phoenix 7 to 98 more).
316
+ The bytes `resizeAccount`, `realloc` and a growable Vec's growth add are zeroed by the memset syscall from 64, and
317
+ an account's data at `close` when its type takes 64 bytes or more (9,563 bytes: about 45 CU instead of 4,800).
318
+ Below each threshold the code is what it was. 14 of the 81 programs in the release manifest build to other binaries
319
+ (examples/escrow and ledgerbook, Jito's two programs, Marginfi, Meteora DBC, Percolator v12.20 and its matcher,
320
+ Percolator v16, Raydium CLMM and CP-Swap, and the program-examples realloc, token escrow and token fundraiser); all
321
+ their tests pass, and each of the 161,578 transactions those tests send was run against the binary from before and
322
+ after: 18,451 cost less, 4 more. Two Percolator v16 InitPortfolio transactions cost one CU more (the account grows
323
+ by 8 and 16 bytes: the length is tested at run time), and two refusals of Meteora DBC's
324
+ initialize_virtual_pool_with_token2022_transfer_hook 2 more (its successes 3,079 less). Savings (mean per
325
+ successful transaction): Percolator v12.20 InitMarket 232,685 to 105,768, TradeCpi 3,414 less, PushHyperpMark
326
+ 1,297; Percolator v16 InitPortfolio from an empty account 4,750, Deposit and ClosePortfolio 2,069; Meteora DBC swaps
327
+ 2,056, create_config 3,976; Marginfi 106 to 1,940 on 30 instructions; an account's close 26 to 1,145 (examples/escrow
328
+ take and refund 74). A struct copied between two views of one account that overlap, the destination after the
329
+ source, ends with the source's old bytes from 80 bytes on (memmove); below 80 bytes, see the fix of overlapping
330
+ struct copies above (docs/language-native.md; test/language/bulk-copies.test.ts, which also pins a 1 KiB copy at
331
+ no more than 30 CU and an 8 KiB resize zero-fill at no more than 60).
332
+ - Showcase, Percolator v16 (25 of 50 instructions ported, not listed among the ports): ConfigureHybridOracle and the
333
+ external oracle readers of `mod oracle_v16` (Pyth PriceUpdateV2, Switchboard On-Demand under its mainnet and devnet
334
+ owners, Chainlink OCR2, composites of up to three legs with inversion and unit scale, the legs' coherence and commit,
335
+ the hybrid soft-stale predicate), and a permissionless activation's fee into market 0's insurance domains with its
336
+ SPL Token Transfer (UpdateAssetLifecycle's placeholder path for it removed). Compared whole with the Rust build of the
337
+ pinned commits: each source and composite on its success space, every refusal of the instruction and of each reader
338
+ field by field, a seeded fuzz of 400 configurations, the random walk and mutation fuzzer with a keeper that keeps the
339
+ external prices fresh, 34 permissionless appends (the fee doubled from asset 32) and a reuse; the reader's branches
340
+ that only the crank reaches compared on 1,500 vectors with the original's functions compiled for the host
341
+ (`scripts/percolator-v16-reference/oracle-vectors.ts`). All v16 tests: 23,211 transactions, 6,098 successes, each
342
+ cheaper in the port (ConfigureHybridOracle 52% of the reference's compute units on average); binary 289,728 bytes.
343
+ Every failure of the author's suite subsets rerun against the port reaches an instruction not ported yet
344
+ (showcase/mainnet/percolator-v16/README.md and TESTING.md).
345
+ - Showcase, Percolator v16 (27 of 50 instructions ported, not listed among the ports): SyncMaintenanceFee and Withdraw,
346
+ with the engine's maintenance fee (the fee anchor, the U256 fee saturated to u128, the loss settled from principal,
347
+ the fee charged into the insurance, the cranker's share credited from the insurance, the rest into asset 0's domain
348
+ budgets with the alternating carry, a portfolio its fee empties closed into the market, the deregistration's
349
+ LockActive swallowed as the original does) and `withdraw_not_atomic` (the close ledger, the equity after, the vault
350
+ PDA's signed SPL Token Transfer, the secondary collateral mint). The settlement of a portfolio's open legs against
351
+ the assets' K, F and B indices is not ported: both instructions stop there in the port's placeholder on a Live market
352
+ once the fee anchor has moved. Compared whole with the Rust build of the pinned commits on their success paths and
353
+ refusals, and on 400 generated states (a new reusable generator writes markets and portfolios with open legs, PnL up
354
+ to ±(2^127 − 1), fee debt and extreme totals that the original's validators accept, 91% of the Live ones); the walk
355
+ and mutation fuzzer run both instructions and start a fifth of the mutations from generated states. All v16 tests:
356
+ 24,454 transactions, 6,541 successes, each cheaper in the port (Withdraw 54%, SyncMaintenanceFee 62% of the
357
+ reference's compute units on average); binary 324,432 bytes. Every failure of the author's suite subsets rerun
358
+ against the port reaches an instruction not ported yet (showcase/mainnet/percolator-v16/README.md and TESTING.md).
359
+ - Showcase, Percolator v16 (still 27 of 50 instructions ported, not listed among the ports): the map of the settlement
360
+ of a portfolio's open legs, `settle_account_side_effects_not_atomic`, which SyncMaintenanceFee and Withdraw stop at:
361
+ 275 engine functions and 6,397 lines found by following the calls in the pinned source, layered in the source's own
362
+ order (leaf arithmetic, backing and lien primitives, impaired-lien reconciliation, source-claim burns and PnL
363
+ setters, K/F entries, B chunks, the driver), with what is ported (`scripts/percolator-v16-reference/settlement-map.py`,
364
+ NOTES.md section 10). Most of its leaf layer is ported (`kernels.ts`, 45 functions, 1,134 of the original's lines: the
365
+ source-lien arithmetic, the bucket and lien deltas, the K/F and B targets and deltas of a leg, the F snapshot after
366
+ settlement, the B chunk, the backing utilization fee, v16's wide_math helpers with their panic locations; its 33
367
+ market-view accessors remain), not yet
368
+ wired into an instruction. A new function-level harness compares each with the original's own function compiled
369
+ for the host in Docker (a child module added to a copy of the engine's `v16` module reaches the private functions
370
+ without changing any visibility): 90,000 seeded vectors equal, outputs, changed bytes, errors and panic locations;
371
+ interim evidence until the settlement can be compared with the reference binary (showcase/mainnet/percolator-v16/
372
+ README.md and TESTING.md).
373
+ - Showcase, Percolator v16 (still 27 of 50 instructions ported, not listed among the ports): the next three layers of
374
+ the settlement of open legs from the bottom: the rest of the leaf layer (the market-view and portfolio-view
375
+ accessors), the backing and lien primitives (source-credit setters and the domain recompute, the counterparty and
376
+ insurance liens' create, consume and release, fresh and loser-paid counterparty backing, a Fresh bucket's expiry,
377
+ the post-snapshot residual, the backing utilization fee's collection) and the impaired-lien reconciliation
378
+ (`primitives.ts`, `impairment.ts`, 80 functions, 1,440 of the original's lines; 35 functions, 1,939 lines, remain).
379
+ The function-level harness now takes whole markets and portfolios (the original's views built over the same bytes
380
+ as the program builds them, every byte of both accounts compared) on generated states, about 40% of them accepted by
381
+ the original's own validators and the rest deliberately invalid: 22,800 vectors equal; interim evidence, not the
382
+ reference binary. UpdateAssetLifecycle's retirement now expires a lapsed Fresh backing bucket instead of ending in
383
+ the port's placeholder, compared with the reference binary on 300 buckets written into the market (139 successes,
384
+ each cheaper in the port); binary 354,080 bytes.
385
+ - Showcase, Percolator v16 (still 27 of 50 instructions ported, not listed among the ports): the rest of the settlement
386
+ of a portfolio's open legs, `settle_account_side_effects_not_atomic`: the source-claim burns and PnL setters
387
+ (`claims.ts`), the K/F settlement entries with the par netting of a loss, the haircut-bounded close loss, the
388
+ loss-support booking and the capital-backed loss reservation (`kfsettle.ts`), the B chunks and the driver
389
+ (`settlement.ts`): 35 functions, 1,939 of the original's lines; all 275 functions of the map are now ported. It is
390
+ wired into SyncMaintenanceFee and Withdraw, whose placeholders are gone, and compared with the reference binary on
391
+ generated states with open legs (claims and liens on the market's domains, K/F/B indices, stale cohorts): 3,000 such
392
+ states and 2,000 ordinary ones, 5,000 mutations, every transaction alike, 328 successes that settled legs, the port
393
+ cheaper on every success (SyncMaintenanceFee 39% of the reference's compute units on the mean of those states).
394
+ Each function is also compared alone with the original's compiled for the host (33,000 vectors equal), on a
395
+ generator whose states the original's validators accept 58% of the time (40% before). Branch probes
396
+ (`scripts/percolator-v16-reference/coverage.ts`) show which branches of the port's functions each comparison runs:
397
+ 766 of 836, the rest unreachable from accepted states but for seven (TESTING.md). Binary 588,856 bytes.
398
+
399
+ - Showcase, Percolator v16 (still 27 of 50 instructions ported, not listed among the ports): every key the v16 tests
400
+ make comes from a seed drawn per run and printed with every failure (`PERCOLATOR_V16_SEED` replays it); the port and
401
+ its test programs are refused unless built by the tested toolchain throughout (a fault of one walk run at InitMarket
402
+ was a build by platform-tools v1.57's clang 22, whose link another process switched during the build, meeting the
403
+ runtime's assembly builtins: fixed above; showcase/mainnet/percolator-v16/TESTING.md section 5); the coverage copy is
404
+ one per process; set-ups over tens of thousands of key sets, capacities, PDA bumps and heap frames compared with the
405
+ reference (`percolator-v16-setup-stress.test.ts`); the map extended to margin and health certificates,
406
+ ConvertReleasedPnl and Withdraw (NOTES.md section 11: 33 functions, 764 lines not ported; no ported instruction
407
+ computes a certificate, and no state lets a portfolio with open legs withdraw).
408
+ - Showcase, Percolator v16 (29 of 50 instructions ported, not listed among the ports): TradeNoCpi and
409
+ ConvertReleasedPnl. TradeNoCpi's map (NOTES.md section 12, `settlement-map.py --trade`): 127 processor functions and
410
+ 127 engine functions new to the port (3,645 lines), all ported but six only the crank's refresh and the batch reach:
411
+ the margin and health certificates (`health.ts`), the engine's trade with its position routes, gates, fees, close
412
+ ledger, source liens and residue resets (`trade.ts`), and the processor's zero-move funding accrual, dynamic fee
413
+ quote, trade-driven mark, backing-domain fees and lien bounds (`trading.ts`); ConvertReleasedPnl in `convert.ts`.
414
+ Compared with the reference binary on dedicated tests (routes, 14 legs, bounds, fees, the initial margin to the unit,
415
+ every account pair) and on real state: a random walk in which trades open and close legs on three assets of four
416
+ portfolios while funding accrues, so that the settlement, the refresh and the certificates run on state the
417
+ 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
418
+ 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.
419
+ - Showcase, Percolator v16 (31 of 50 instructions ported, not listed among the ports): PermissionlessCrank on a Live
420
+ market and FinalizeResetSide. The crank's map (NOTES.md section 13, `settlement-map.py --crank`): 94 processor
421
+ functions and 133 engine functions new to the port (4,436 lines); ported, what a Live market reaches (89 engine
422
+ functions, 2,919 lines: the observation of each hinted asset with the hybrid's fall-back to its mark and its
423
+ liveness, accrual at moving prices, the engine's classifier and plan, the refresh with B chunks and lapsed backing,
424
+ liquidation partial and full with its fee and the cranker's reward, the insurance draw, the bankruptcy residual
425
+ booked into the other side's B index, ADL and the side modes, the close-progress ledger, AdvanceClose, the
426
+ declaration of Recovery, the flat account's source-lien release, a Recovery asset's committed-state refresh); a
427
+ market in Recovery, the forfeit of a Recovery asset's released obligation and a Resolved market's close end in the
428
+ port's placeholder where the original calls them (44 engine functions). The engine's NonProgress the processor
429
+ swallows after an accrual, the `clear_leg` Stale the engine swallows and a declared Recovery that liquidation's
430
+ caller turns into success are values in the port, leaving exactly the original's partial writes. Compared with the
431
+ reference binary on dedicated tests (hint shapes, oracle accounts stale, ahead, malformed or repeated, long gaps,
432
+ every account pair, liquidations, bankruptcies, a 14-leg portfolio) and on a real-state walk in which cranks keep
433
+ three assets current while marks and oracle prices move and steered portfolios are liquidated (3 × 8,000 steps:
434
+ 24,772 transactions, 7,604 crank successes, 476 liquidations (366 partial, 110 full), 116 cranker rewards, every one alike), and a mutation
435
+ fuzzer from snapshots with positions under water; every crank success cheaper in the port (40% of the reference on
436
+ 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
437
+ 1,400,000 CU, the port succeeds (recorded). Binary 1,005,456 bytes.
438
+ - Showcase, Percolator v16: the placeholder that ends a decoded instruction of an unported tag is now
439
+ Custom(0xc0de0000 + tag), no longer Custom(0x16dec000 + tag), whose log text `custom program error: 0x16dec0..`
440
+ the author's tests took for NonProgress (`custom program error: 0x16`) by its prefix.
441
+
442
+ - Showcase, Percolator v16 (37 of 50 instructions ported, not listed among the ports): PermissionlessCrank on a market
443
+ in Recovery (the forfeit of a released obligation, the market's resolution) and on a Resolved market (the account's
444
+ close-out: the source domains' preparation and realization, the resolved bankruptcy, the solvent legs' detachment,
445
+ the payout ledger and receipt, the payout's signed SPL Token Transfer), which removes the crank's four placeholders;
446
+ and ForfeitRecoveryLeg, RebalanceReduce, CureAndCancelClose, ResolveMarket, ResolveStalePermissionless and
447
+ CloseResolved. Compared whole with the Rust build of the pinned commits: six markets taken out of Live with open legs
448
+ (a declared Recovery with the owners' forfeits, ResolveMarket, ResolveStalePermissionless) and closed out portfolio by
449
+ portfolio with payouts, the conservation the original's tests assert checked in both VMs and never failing, account
450
+ and data sweeps of each instruction, RebalanceReduce on real state, CureAndCancelClose on generated close ledgers; the
451
+ crank walk now resolves and closes out markets, and its mutation fuzzer starts from markets in Recovery and Resolved.
452
+ All v16 tests: 42,222 transactions, 16,223 successes, each cheaper in the port (CloseResolved 35%, ForfeitRecoveryLeg
453
+ 37%, RebalanceReduce 37%, CureAndCancelClose 36% of the reference's compute units on average); binary 1,139,536 bytes
454
+ (showcase/mainnet/percolator-v16/README.md, NOTES.md sections 13 and 14, TESTING.md). No compiler change.
455
+ - Showcase, Percolator v16 (47 of 50 instructions ported, not listed among the ports): the insurance and backing-bucket
456
+ instructions (TopUpInsurance, TopUpInsuranceDomain, TopUpBackingBucket, WithdrawBackingBucket,
457
+ WithdrawBackingBucketEarnings, WithdrawInsuranceAsset, with the engine's fresh-backing deposit and withdrawal, the
458
+ resolved backing surplus, the earnings and domain-insurance withdrawals and the terminal claim-free recredit) and the
459
+ terminal ones (CloseSlab with its terminal scan, the retirement and burn of the vault, the vaults closed and the
460
+ tombstone; ClaimResolvedPayoutTopup; SwapSecondaryForPrimary; ForceCloseAbandonedAsset on the trade engine). Left:
461
+ TradeCpi, BatchTradeNoCpi, BatchTradeCpi. Compared whole with the Rust build of the pinned commits: top-ups and
462
+ withdrawals among trades and cranks, markets resolved and closed by CloseSlab, a second mint swapped and closed, a
463
+ shut-down asset force-closed and drained, payout top-ups after a lapse of backing, account and data sweeps of each;
464
+ the walks now move reserves, shut assets down and close their markets, and the conservation check is asserted
465
+ wherever it is collected. All v16 tests: 68,632 transactions, 24,657 successes, each cheaper in the port (ForceCloseAbandonedAsset 36%,
466
+ CloseSlab 36%, TopUpBackingBucket 33%, WithdrawInsuranceAsset 40% of the reference's compute units on average);
467
+ binary 1,258,064 bytes. The author's suite: one failure in a ported path, `inv_078`, which expects a force-close to
468
+ exceed the compute-unit limit that the port's stays within (showcase/mainnet/percolator-v16/README.md, NOTES.md section 15,
469
+ TESTING.md). No compiler change.
470
+ - Showcase, Percolator v16 tests (no compiler change): a run that compared nothing can no longer pass for one. CI
471
+ gains a `percolator-v16` job that builds the five v16 binaries from the pinned sources in Docker, checks each against
472
+ the sha256 test/programs/SOURCES.md records and runs every v16 test file under `CI_REQUIRE_ALL=built`; there a
473
+ missing binary, a missing port source or a test file that compared no transaction fails (each file prints its count;
474
+ locally, without the binaries, the files still skip and print 0). The showcase job no longer runs them. Where the
475
+ reference is rerun under a raised compute budget, that run now starts from the exact pre-transaction state of every
476
+ covered account (one that did not exist is removed, not left as an earlier replay had it), the port is compared with
477
+ that run's accounts, and an account the run closes is removed from the reference afterwards; the harness test checks
478
+ both cases. The path tests assert the evidence of the paths they name (liens, the backing-domain fee, TradeCpi's cap
479
+ refusal, the lien releases; the gap test's uncovered losses and closes; the haircut test's receipts and top-up), and
480
+ the gap test no longer claims the paths it was written for but does not reach. The log comparison drops the port's
481
+ `0xc0de` probe lines only in coverage runs and matches the runtime's compute-unit line whole. The README, NOTES and
482
+ TESTING now say what CI compares, why two omitted token-value proofs cannot change an outcome (NOTES.md section 17),
483
+ where the port does allocate (section 18), and the refusal and transaction counts as measured.
484
+ - Showcase, Percolator v16 at commit 7b110913 (engine 5e3af07), complete: all 50 instructions ported, now listed among
485
+ the ports (its reference is a binary built here from the author's pinned source, not a deployed program). The last
486
+ three: BatchTradeNoCpi (the engine's batch: one refresh, the position maps kept across up to 14 legs, one end-state
487
+ margin check, the collected fees allocated to the legs) and the matcher ABI v3 with TradeCpi and BatchTradeCpi (the
488
+ LP's matcher config and delegate PDA, the tail check, the accrual and currentness before the call, the call signed by
489
+ the delegate, the answers validated, the slippage and fee caps). The placeholder for unported tags is gone. Compared
490
+ whole through the author's auth and hostile matchers, percolator-match and a rogue matcher of the tests' own (failing,
491
+ changing accounts, calling back, return data too long, short or unasked, resized contexts, prices out of range); batch
492
+ and matcher trades now in both walks. Where the reference runs out of compute units and the port does not, the
493
+ reference is run again under a raised compute budget and the port must equal that run (9 cases, all equal). New
494
+ real-state paths: a trade's counterparty-backed source lien with its backing-domain fee, the provider's earnings
495
+ withdrawn, ReleaseSourceLiens, a lien released at the resolved close. All v16 tests (2026-11-20): 70,881
496
+ transactions compared with the port, 70,678 of them with a Percolator instruction, 25,995 successes, each cheaper in
497
+ 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
498
+ found one difference, fixed (a matcher's price above MAX_ORACLE_PRICE must be OracleInvalid); its full run on both
499
+ binaries is the next entry. No compiler change.
500
+ - Percolator v16: the author's whole suite (2,071 tests, all six targets unfiltered) ran on the reference and on the
501
+ port's current binary with every transaction recorded and compared (results, errors, return data, logs and every
502
+ account of the transaction's key list, by hash). The reference passes 2,062 and the port 2,060; the 9 failures of
503
+ the reference are its own and the port fails them at the same assertion; the port's 2 others assert the reference's
504
+ compute units (a peak of 554,832; a one-shot force-close expected to exceed the limit, which the port completes).
505
+ Of 2,324,991 transactions compared, 2,324,990 are identical, the other that force-close. None of the 2,127,486
506
+ identical successes costs the port more compute units: port 67,489,438,873, reference 128,297,605,017. The
507
+ first full run, on the port's previous binary, had found 282 that did, at the author's largest shapes
508
+ (ResolveMarket, CloseSlab, InitMarket); they were fixed (next entry) and the full run repeated. The author-suite and
509
+ trace scripts now fail on a target that does not compile, times out or runs nothing, on an empty trace, and on any
510
+ failure, difference or compute-unit excess not listed with its reason in
511
+ `scripts/percolator-v16-reference/author-suite-expected.tsv` (or a listed one no longer seen); the trace writer
512
+ writes each line at once and stops a test it cannot record (showcase/mainnet/percolator-v16/README.md, TESTING.md
513
+ section 3).
514
+ - Percolator v16: the three excesses the author's suite found are removed (no compiler change). ResolveMarket and
515
+ ResolveStalePermissionless (the committed-accrual scan of every configured slot), CloseSlab (the terminal scan of up
516
+ to 256 assets a call) and InitMarket (asset 0's profile copied into every slot) made a view per slot, each with its
517
+ own owner and bounds check and an offset computed with overflow checks, where the original indexes a slice whose
518
+ bounds the market view checked once; they now read the slots through one view of the slot array, and CloseSlab makes
519
+ the two backing expiries effective only for an asset whose step reads them. On a 10 MiB market (5,682 slots):
520
+ ResolveMarket: port 64,034, reference 65,546 (the port was 166,304); InitMarket: port 146,361, reference 211,905 (the
521
+ port was 214,540); a CloseSlab scan of 256 assets with fresh backing: port 17,682, reference 41,318 (was port
522
+ 42,314, reference 38,318). The ResolveMarket
523
+ scan now costs 11 instructions a slot as the reference's does; the port's lead there is its smaller fixed part.
524
+ `percolator-v16-shapes.test.ts` compares the three on markets of 1,000 and 5,682 slots (each success must cost the
525
+ port less; the previous binary fails all three tests). All 31 v16 files (2026-11-21): 226 tests, 70,928
526
+ 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
527
+ transactions are identical to the reference's recorded ones, and none of their 143,473 identical successes costs the
528
+ port more (the 10 MiB ResolveMarket: port 64,080, reference 65,584); `author-suite-expected.tsv` lists no compute-unit excess
529
+ any more. The whole suite then ran again on the new binary (2026-11-21 to 2026-11-23): no excess anywhere (previous
530
+ entry). Binary 1,362,872 bytes
531
+ (was 1,362,760), sha256 `01c33233…` (showcase/mainnet/percolator-v16/README.md "Where the port costs more",
532
+ TESTING.md).
533
+ - Percolator v16: UpdateAssetLifecycle's permissionless activation now refuses an overflowing doubled fee exactly as
534
+ the original does (EngineArithmeticOverflow whenever a doubling overflows u128, a stored base fee of u128::MAX at an
535
+ asset index of 32 or more included; the port used u128::MAX as its overflow marker and let that base through to the
536
+ maximum-fee check). No instruction stores a base fee above u64::MAX (UpdateMarketInitFeePolicy refuses it), so the
537
+ lifecycle test writes such fees into the market (u128::MAX, u128::MAX/2 + 1, u128::MAX/2) and compares the appending
538
+ and reuse routes at indices 7, 33 and 35; the previous binary fails it. `percolator-v16-shapes.test.ts` now also drives
539
+ CloseSlab's Expire step, a nonzero recredit, the last batch refused while a domain budget remains and ReadyToClose on
540
+ the 5,682-slot market, and asserts the LockActive its wait case gives. The author-suite trace writer leaves out only
541
+ the runtime's whole compute-unit line (and the port's probe lines only when probes are on); the trace comparison
542
+ classes every differing transaction of a test (each kind must be listed for that test) and judges `main.trace`'s
543
+ groups of equal lines whose compute units vary against their cheapest reference line. All 31 v16 files (2026-11-23):
544
+ 227 tests, 70,975 transactions compared with the port, 26,077 successes, each cheaper in the port; of 44,695
545
+ refusals 44,685 cheaper and 10 at 0 in both. Binary 1,362,912 bytes (was 1,362,872), sha256 `c6dc6b24…`. The author's
546
+ 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),
547
+ both with these scripts: the same passes and failures, the `inv_078` force-close the one difference, and no
548
+ identical success costing the port more (port 67,489,438,873 units, was 67,489,010,058; the figures above are this
549
+ run's). No compiler change.
9
550
  ## 0.49.0 — 2026-11-16
10
551
 
11
552
  A minor release: it adds a port of Percolator v12.20 (all 27 instructions, compared with the immutable mainnet build)
package/NOTICE CHANGED
@@ -97,5 +97,14 @@ Third-party material in this repository only (not in the published package)
97
97
  audited, not for use with real funds. Its mainnet binary is not kept here: scripts/fetch-programs.sh downloads it
98
98
  (test/programs/SOURCES.md). showcase/mainnet/percolator/matcher/ is a TypeSOL port of the matcher TradeCpi calls,
99
99
  aeyakovenko/percolator-match (commit 199b139), Copyright Anatoly Yakovenko, Apache-2.0, kept as a test fixture.
100
+ - showcase/mainnet/percolator-v16/: a TypeSOL port of Percolator v16, all 50 instructions, the program
101
+ aeyakovenko/percolator-prog (commit 7b11091) with its risk engine aeyakovenko/percolator (commit 5e3af07), Copyright
102
+ Anatoly Yakovenko, Apache-2.0 (the licence text is test/programs/LICENSE-Apache-2.0.txt), with its tests
103
+ showcase/test/percolator-v16*.ts, whose layout table (percolator-v16-layout.ts) transcribes the original's account
104
+ structs. Changes: rewritten in TypeSOL. The original's own warning stands for the port: an educational research
105
+ project, not audited, not for use with real funds. No v16 build is deployed to compare with:
106
+ scripts/percolator-v16-reference/ builds the reference binary from those commits, and the matchers its tests load
107
+ (aeyakovenko/percolator-match commit 60aac3a and two test matchers of percolator-prog, Apache-2.0), in Docker; none
108
+ of the binaries is kept here (test/programs/SOURCES.md).
100
109
  - showcase/program-examples/: ports of solana-developers/program-examples (MIT, Copyright Solana Foundation; the
101
110
  licence text is in showcase/program-examples/README.md).