@typesol/cli 0.50.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.
- package/CHANGELOG.md +144 -0
- package/README.md +12 -10
- package/SECURITY.md +5 -3
- package/dist/cli.js +36 -5
- package/dist/compiler/analyze.d.ts +8 -1
- package/dist/compiler/analyze.js +227 -19
- package/dist/compiler/diagnostics.d.ts +4 -0
- package/dist/compiler/diagnostics.js +5 -1
- package/dist/compiler/emit/base.d.ts +31 -1
- package/dist/compiler/emit/base.js +37 -1
- package/dist/compiler/emit/calls.js +27 -6
- package/dist/compiler/emit/cpi-core.d.ts +3 -0
- package/dist/compiler/emit/cpi-core.js +8 -2
- package/dist/compiler/emit/cpi.js +4 -2
- package/dist/compiler/emit/create.js +9 -9
- package/dist/compiler/emit/expressions.d.ts +8 -1
- package/dist/compiler/emit/expressions.js +65 -0
- package/dist/compiler/emit/function.d.ts +2 -0
- package/dist/compiler/emit/function.js +59 -7
- package/dist/compiler/emit/outline.d.ts +35 -0
- package/dist/compiler/emit/outline.js +547 -0
- package/dist/compiler/emit/program.js +11 -2
- package/dist/compiler/emit/shared.d.ts +57 -2
- package/dist/compiler/emit/shared.js +18 -3
- package/dist/compiler/emit/statements.d.ts +28 -1
- package/dist/compiler/emit/statements.js +279 -24
- package/dist/compiler/emit/storage.d.ts +16 -0
- package/dist/compiler/emit/storage.js +122 -3
- package/dist/compiler/hints.d.ts +1 -1
- package/dist/compiler/hints.js +9 -1
- package/dist/compiler/idl.js +1 -1
- package/dist/compiler/index.d.ts +15 -1
- package/dist/compiler/index.js +47 -10
- package/dist/compiler/model.d.ts +13 -1
- package/dist/compiler/stack.d.ts +71 -0
- package/dist/compiler/stack.js +309 -0
- package/dist/compiler/toolchain.d.ts +87 -5
- package/dist/compiler/toolchain.js +384 -19
- package/dist/workspace.d.ts +1 -0
- package/dist/workspace.js +1 -1
- package/docker/deps/0.51.0.lock.json +1206 -0
- package/docs/architecture.md +1 -1
- package/docs/audit.md +13 -11
- package/docs/case-study-escrow.md +1 -1
- package/docs/cli.md +2 -2
- package/docs/glossary.md +2 -1
- package/docs/language-basics.md +25 -1
- package/docs/language-pdas.md +6 -2
- package/docs/language-statements.md +101 -11
- package/docs/language-types.md +80 -5
- package/docs/runtime.md +1 -1
- package/docs/security-model.md +5 -3
- package/docs/stability.md +5 -1
- package/docs/troubleshooting.md +45 -1
- package/llms-full.txt +271 -27
- package/package.json +1 -1
- package/releases/0.50.0.json +874 -0
- package/runtime/typesol_rt.h +125 -51
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,150 @@ 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
|
+
|
|
9
153
|
## 0.50.0 — 2026-11-26
|
|
10
154
|
|
|
11
155
|
A minor release: it adds a port of Percolator v16 (all 50 instructions of aeyakovenko/percolator-prog at 7b110913,
|
package/README.md
CHANGED
|
@@ -387,16 +387,16 @@ toolchain and records them with every result:
|
|
|
387
387
|
<!-- bench:table -->
|
|
388
388
|
| Instruction | TypeSOL | Pinocchio 0.10 | Native Rust | Anchor 1.0.2 |
|
|
389
389
|
| --- | ---: | ---: | ---: | ---: |
|
|
390
|
-
| counter.initialize | **1,
|
|
390
|
+
| counter.initialize | **1,852** | 3,186 | 4,601 | 6,573 |
|
|
391
391
|
| counter.increment | **110** | 113 | 857 | 2,323 |
|
|
392
|
-
| vault.open | **1,
|
|
392
|
+
| vault.open | **1,871** | 3,185 | 4,613 | 6,627 |
|
|
393
393
|
| vault.deposit | **1,314** | 1,377 | 2,832 | 4,355 |
|
|
394
394
|
| vault.withdraw | **315** | 370 | 1,176 | 3,628 |
|
|
395
395
|
| vault.shut | **161** | 167 | 950 | 2,024 |
|
|
396
|
-
| escrow.make | **3,
|
|
397
|
-
| escrow.take | **
|
|
398
|
-
| escrow.refund | **2,
|
|
399
|
-
| binary, counter / vault / escrow | 11.
|
|
396
|
+
| escrow.make | **3,590** | 6,179 | 9,240 | 13,304 |
|
|
397
|
+
| escrow.take | **3,945** | 4,051 | 8,500 | 14,365 |
|
|
398
|
+
| escrow.refund | **2,622** | 2,769 | 5,695 | 8,449 |
|
|
399
|
+
| binary, counter / vault / escrow | 11.0 / 14.1 / 21.4 KB | 19.6 / 22.9 / 29.4 KB | 27.9 / 35.0 / 46.5 KB | 145.2 / 158.9 / 190.7 KB |
|
|
400
400
|
<!-- /bench:table -->
|
|
401
401
|
|
|
402
402
|
`initialize`, `open` and `make` include the PDA bump search. TypeSOL hashes PDA candidates with the sha256 and
|
|
@@ -409,7 +409,7 @@ units are not a safety claim. The differential tests also run the escrow against
|
|
|
409
409
|
These three programs' Pinocchio versions were written for this comparison.
|
|
410
410
|
|
|
411
411
|
<!-- bench:official -->
|
|
412
|
-
On the official examples, 17 programs of solana-developers/program-examples@de09019 that this project did not write (26 instructions, `official.ts` in the benchmarks repository), TypeSOL uses fewer compute units than Anchor on 26 of 26 instructions and than native Rust on 26 of 26, and more than Pinocchio on
|
|
412
|
+
On the official examples, 17 programs of solana-developers/program-examples@de09019 that this project did not write (26 instructions, `official.ts` in the benchmarks repository), TypeSOL uses fewer compute units than Anchor on 26 of 26 instructions and than native Rust on 26 of 26, and more than Pinocchio on 12 of 26.
|
|
413
413
|
<!-- /bench:official -->
|
|
414
414
|
|
|
415
415
|
Those Pinocchio versions often do less: favorites, close-account and
|
|
@@ -524,12 +524,14 @@ change.
|
|
|
524
524
|
The two latest, of 0.43.0 and 0.44.0 in November 2026, found defects that made a program that compiled behave
|
|
525
525
|
differently from its source; each is fixed with a test, and [docs/audit.md](docs/audit.md) lists them, what the
|
|
526
526
|
reviews covered and what they did not. Programs built before 0.44.1 should be rebuilt.
|
|
527
|
-
- 0.45.0 to 0.
|
|
527
|
+
- 0.45.0 to 0.51.0 have had no security review. They add, among others,
|
|
528
528
|
`runtime/typesol_builtins.c` (the compiler builtins as TypeSOL's own C, 0.45.0), `transferCheckedWithHook`,
|
|
529
529
|
`EVENT_AUTHORITY_CHECK` and the reads of processed sibling instructions (0.48.0), `zeroData`, `log64`,
|
|
530
530
|
`PANIC_STYLE = "solana-1.18"`, `executable` on remaining accounts and lamport writes on remaining accounts under
|
|
531
|
-
`NATIVE_ACCOUNT_WRITES` (0.49.0),
|
|
532
|
-
copied and zeroed by the memory syscalls (0.50.0)
|
|
531
|
+
`NATIVE_ACCOUNT_WRITES` (0.49.0), `copyData`, `getReturnData()`, `PANIC_STYLE = "pinocchio"` and whole values
|
|
532
|
+
copied and zeroed by the memory syscalls (0.50.0), and the base58 text of keys from a table, derivations without
|
|
533
|
+
the run-time seed-limit check, object-type structs, `extends`, struct spreads, labels, logical assignment and the
|
|
534
|
+
stack layout the build chooses for a program that does not fit (0.51.0).
|
|
533
535
|
- From 0.44.0 on, a release that only fixes defects is a patch with no new language surface and a binary diff in its
|
|
534
536
|
notes ([SECURITY.md](SECURITY.md#fix-releases)), and the npm tarball is the one packed from the tag and recorded
|
|
535
537
|
in [releases/](releases).
|
package/SECURITY.md
CHANGED
|
@@ -8,12 +8,14 @@ TypeSOL generates programs that hold funds. Treat it accordingly.
|
|
|
8
8
|
0.44.0 on 2026-11-11, found defects in the compiler (wrong token-wrapper instruction data, and a reference that could
|
|
9
9
|
outlive a resize and reach another record) and a latent one in the runtime; they are fixed in 0.44.1. The one
|
|
10
10
|
before it, of 0.43.0, found defects fixed in 0.44.0 (one of them could break an authorization check in a helper).
|
|
11
|
-
0.45.0 to 0.
|
|
11
|
+
0.45.0 to 0.51.0 have had no security review. They add, among others,
|
|
12
12
|
`runtime/typesol_builtins.c` (the compiler builtins as TypeSOL's own C, 0.45.0), `transferCheckedWithHook`,
|
|
13
13
|
`EVENT_AUTHORITY_CHECK` and the reads of processed sibling instructions (0.48.0), `zeroData`, `log64`,
|
|
14
14
|
`PANIC_STYLE = "solana-1.18"`, `executable` on remaining accounts and lamport writes on remaining accounts under
|
|
15
|
-
`NATIVE_ACCOUNT_WRITES` (0.49.0),
|
|
16
|
-
copied and zeroed by the memory syscalls (0.50.0)
|
|
15
|
+
`NATIVE_ACCOUNT_WRITES` (0.49.0), `copyData`, `getReturnData()`, `PANIC_STYLE = "pinocchio"` and whole values
|
|
16
|
+
copied and zeroed by the memory syscalls (0.50.0), and the base58 text of keys from a table, derivations without
|
|
17
|
+
the run-time seed-limit check, object-type structs, `extends`, struct spreads, labels, logical assignment and the
|
|
18
|
+
stack layout the build chooses for a program that does not fit (0.51.0).
|
|
17
19
|
**Rebuild and redeploy programs built before 0.44.1**;
|
|
18
20
|
[docs/security-model.md](docs/security-model.md#status) gives the status, its sections on each review say how to
|
|
19
21
|
tell whether a program was exposed, and [docs/audit.md](docs/audit.md#earlier-reviews) what each review did and did
|
package/dist/cli.js
CHANGED
|
@@ -6,7 +6,7 @@ import path from "node:path";
|
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { parseArgs } from "node:util";
|
|
8
8
|
import { createHash } from "node:crypto";
|
|
9
|
-
import { build, CompileError, COMPILER_VERSION, describeToolchain, elfLength, generate, MEASURED_HOSTS, SBPF_VERSIONS, toolchainDifferences, verifyBinary, } from "./compiler/index.js";
|
|
9
|
+
import { build, CompileError, COMPILER_VERSION, describeToolchain, elfLength, generate, MEASURED_HOSTS, SBPF_VERSIONS, stackNotes, toolchainDifferences, verifyBinary, } from "./compiler/index.js";
|
|
10
10
|
import { setToolchainStrict, shortClang } from "./compiler/toolchain.js";
|
|
11
11
|
import { generateCpi } from "./tools/cpigen.js";
|
|
12
12
|
import { generatePort } from "./tools/portgen.js";
|
|
@@ -50,6 +50,28 @@ const DOCKER_HELP = [
|
|
|
50
50
|
"--release-record <file> the releases/<v>.json to check that version's tarball against (default: this package's, else the repository's)",
|
|
51
51
|
].join("\n ");
|
|
52
52
|
const DOCKER_OPTIONS = { docker: { type: "boolean" }, "typesol-version": { type: "string" }, "release-record": { type: "string" } };
|
|
53
|
+
const STACK_AUTO_HELP = [
|
|
54
|
+
"--stack-auto on|off on (the default): a program that does not fit the stack is laid out another way when it can (statements",
|
|
55
|
+
" scoped, helpers kept out of line, an instruction's large locals on the heap), each step printed as a note",
|
|
56
|
+
" and recorded in <name>.build.json; off: such a build fails (as const STACK_AUTO = false does)",
|
|
57
|
+
].join("\n ");
|
|
58
|
+
/** --stack-auto: undefined (the default, on), true or false. */
|
|
59
|
+
function stackAutoOf(v) {
|
|
60
|
+
const s = v["stack-auto"];
|
|
61
|
+
if (s === undefined)
|
|
62
|
+
return undefined;
|
|
63
|
+
if (s !== "on" && s !== "off")
|
|
64
|
+
throw new UsageError("--stack-auto must be on or off");
|
|
65
|
+
if (v.docker && s === "off")
|
|
66
|
+
throw new UsageError("--stack-auto off applies to local builds: for a container build, write const STACK_AUTO = false in the program");
|
|
67
|
+
return s === "on";
|
|
68
|
+
}
|
|
69
|
+
/** The notes of a build that did not fit the stack as written (see stackNotes), one line each. */
|
|
70
|
+
function logStackNotes(manifest, indent = " ") {
|
|
71
|
+
if (manifest.stack)
|
|
72
|
+
for (const n of stackNotes(manifest.stack, manifest.sbpf))
|
|
73
|
+
log(`${indent}note: ${n}`);
|
|
74
|
+
}
|
|
53
75
|
const COMMANDS = {
|
|
54
76
|
new: {
|
|
55
77
|
usage: "typesol new <program> [--template counter|vault|escrow]",
|
|
@@ -126,12 +148,13 @@ const COMMANDS = {
|
|
|
126
148
|
},
|
|
127
149
|
},
|
|
128
150
|
build: {
|
|
129
|
-
usage: "typesol build [<program>…] [--sbpf v0|v1|v2] [--profile] [--toolchain-strict] [--docker [--typesol-version <v>] [--release-record <file>]]\n typesol build <program.ts> [--out <dir>] [--program-id <keypair.json>] [--sbpf …] [--profile] [--toolchain-strict] [--docker …]",
|
|
151
|
+
usage: "typesol build [<program>…] [--sbpf v0|v1|v2] [--profile] [--stack-auto on|off] [--toolchain-strict] [--docker [--typesol-version <v>] [--release-record <file>]]\n typesol build <program.ts> [--out <dir>] [--program-id <keypair.json>] [--sbpf …] [--profile] [--stack-auto on|off] [--toolchain-strict] [--docker …]",
|
|
130
152
|
help: [
|
|
131
153
|
`In a project (${CONFIG}): build every program, or the ones named, into <out>/<name>/ (.so, IDL .json, .client.ts, .c, .build.json).`,
|
|
132
154
|
"Outside a project, or with a .ts file: build that file (its keypair is created next to the output if needed).",
|
|
133
155
|
SBPF,
|
|
134
156
|
"--profile log a marker and the remaining compute units before every statement (for `typesol profile`; not for release)",
|
|
157
|
+
STACK_AUTO_HELP,
|
|
135
158
|
TOOLCHAIN_STRICT,
|
|
136
159
|
DOCKER_HELP,
|
|
137
160
|
"--quiet no banner",
|
|
@@ -139,6 +162,7 @@ const COMMANDS = {
|
|
|
139
162
|
options: {
|
|
140
163
|
sbpf: { type: "string" },
|
|
141
164
|
profile: { type: "boolean" },
|
|
165
|
+
"stack-auto": { type: "string" },
|
|
142
166
|
out: { type: "string" },
|
|
143
167
|
"program-id": { type: "string" },
|
|
144
168
|
quiet: { type: "boolean" },
|
|
@@ -150,6 +174,7 @@ const COMMANDS = {
|
|
|
150
174
|
setToolchainStrict();
|
|
151
175
|
const sbpf = sbpfOf(v);
|
|
152
176
|
const profile = !!v.profile;
|
|
177
|
+
const stackAuto = stackAutoOf(v);
|
|
153
178
|
const ws = findWorkspace(process.cwd());
|
|
154
179
|
const file = args.length === 1 && args[0].endsWith(".ts") ? args[0] : undefined;
|
|
155
180
|
// A .ts that is one of the project's programs builds as that program (same keypair, output and settings).
|
|
@@ -172,12 +197,15 @@ const COMMANDS = {
|
|
|
172
197
|
built.forEach((r, i) => {
|
|
173
198
|
const j = jobs[i];
|
|
174
199
|
log(` ${j.paths.name.padEnd(12)} ${j.address}${j.created ? " (new keypair)" : j.keyless ? " (no keypair here: deploying needs it)" : ""} ${path.relative(process.cwd(), r.soPath)}`);
|
|
200
|
+
logStackNotes(r.manifest, " ");
|
|
175
201
|
});
|
|
176
202
|
log(containerLine(image));
|
|
177
203
|
return 0;
|
|
178
204
|
}
|
|
179
|
-
for (const b of buildWorkspace(ws, inProject ? [inProject] : names(ws, args), { sbpf, profile }))
|
|
205
|
+
for (const b of buildWorkspace(ws, inProject ? [inProject] : names(ws, args), { sbpf, profile, stackAuto })) {
|
|
180
206
|
log(` ${b.paths.name.padEnd(12)} ${b.address}${b.created ? " (new keypair)" : b.keyless ? " (no keypair here: deploying needs it)" : ""} ${path.relative(process.cwd(), b.result.soPath)}`);
|
|
207
|
+
logStackNotes(b.result.manifest, " ");
|
|
208
|
+
}
|
|
181
209
|
return 0;
|
|
182
210
|
}
|
|
183
211
|
if (!file)
|
|
@@ -202,10 +230,10 @@ const COMMANDS = {
|
|
|
202
230
|
if (image) {
|
|
203
231
|
// The container sees the entry's directory: the program and the files it imports from there.
|
|
204
232
|
const [r] = containerBuild(image, path.dirname(path.resolve(file)), [{ entry: file, outDir, address, sbpf: sbpf ?? "v0", profile }]);
|
|
205
|
-
res = { soPath: r.soPath, idlPath: path.join(outDir, `${name}.json`), manifestPath: r.manifestPath };
|
|
233
|
+
res = { soPath: r.soPath, idlPath: path.join(outDir, `${name}.json`), manifestPath: r.manifestPath, manifest: r.manifest };
|
|
206
234
|
}
|
|
207
235
|
else {
|
|
208
|
-
const local = build(file, outDir, address, { sbpf: sbpf ?? "v0", profile });
|
|
236
|
+
const local = build(file, outDir, address, { sbpf: sbpf ?? "v0", profile, stackAuto });
|
|
209
237
|
writeClient(local.idl, path.join(outDir, `${name}.client.ts`));
|
|
210
238
|
res = local;
|
|
211
239
|
}
|
|
@@ -215,6 +243,7 @@ const COMMANDS = {
|
|
|
215
243
|
log(` idl ${res.idlPath}`);
|
|
216
244
|
log(` client ${path.join(outDir, `${name}.client.ts`)}`);
|
|
217
245
|
log(` manifest ${res.manifestPath}`);
|
|
246
|
+
logStackNotes(res.manifest);
|
|
218
247
|
log(`\n deploy: solana program deploy ${shellQuote(res.soPath)} --program-id ${shellQuote(keyFile)}`);
|
|
219
248
|
if (image)
|
|
220
249
|
log(containerLine(image));
|
|
@@ -605,6 +634,8 @@ const COMMANDS = {
|
|
|
605
634
|
const what = deployedPath ??
|
|
606
635
|
`${onChain.address} (${onChain.info.dataAccount === onChain.address ? "" : `data ${onChain.info.dataAccount}, `}loader ${onChain.info.loader})`;
|
|
607
636
|
log(same ? ` match ${rebuilt.binary} (sbpf ${sbpf})` : ` MISMATCH ${what} is not what ${entry} builds to (${rebuilt.binary}, sbpf ${sbpf})`);
|
|
637
|
+
// A program that did not fit the stack as written: the rebuild laid it out the same way, step by step.
|
|
638
|
+
logStackNotes(rebuilt);
|
|
608
639
|
if (same && image && root)
|
|
609
640
|
for (const line of verifiedLines({ what, entry, root, rebuilt, image, args, v }))
|
|
610
641
|
log(line);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
import { Reporter } from "./diagnostics.js";
|
|
3
|
-
import { type OptionInner, type DataEnumDef, type EnumDef, type GenericHelper, type Helper, type ProgramModel, type ScalarType, type StructDef, type StructField, type ValueType, isScalar } from "./model.js";
|
|
3
|
+
import { type OptionInner, type DataEnumDef, type EnumDef, type GenericHelper, type Helper, type ProgramModel, type ScalarType, type StructDecl, type StructDef, type StructField, type ValueType, isScalar } from "./model.js";
|
|
4
4
|
export declare const LIB_PATH: string;
|
|
5
5
|
/** Members every account parameter has (`acct.key`, `acct.isSigner`, …): a struct held in an account cannot use them. */
|
|
6
6
|
export declare const ACCOUNT_MEMBERS: Set<string>;
|
|
@@ -73,4 +73,11 @@ export declare function resolveValueType(node: ts.TypeNode, scope: TypeScope, al
|
|
|
73
73
|
export declare function heapVecOf(s: StructDef): StructField | undefined;
|
|
74
74
|
/** The helper (or generic) a call's callee names: a local function by its declaration, others by name. */
|
|
75
75
|
export declare function calleeName(callee: ts.Identifier, decls: Map<ts.Node, string>, checker: ts.TypeChecker): string | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* What to write instead of a TypeScript type form TypeSOL does not have (a parameter's, a field's, a result's or a
|
|
78
|
+
* local's type), or undefined when the type is not one of those forms.
|
|
79
|
+
*/
|
|
80
|
+
export declare function unsupportedTypeForm(node: ts.TypeNode, imports: Map<string, string>): string | undefined;
|
|
81
|
+
/** The members of a struct's declaration: the interface's, or the object type's (`type P = { … }`). */
|
|
82
|
+
export declare function structMembers(decl: StructDecl): ts.NodeArray<ts.TypeElement>;
|
|
76
83
|
export { isScalar };
|