@typesol/cli 0.44.1 → 0.46.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 +343 -0
- package/NOTICE +14 -1
- package/README.md +115 -26
- package/SECURITY.md +10 -8
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +9 -0
- package/dist/cli.js +226 -62
- package/dist/compiler/analyze.js +57 -6
- package/dist/compiler/diagnostics.d.ts +4 -3
- package/dist/compiler/diagnostics.js +10 -6
- package/dist/compiler/emit/base.d.ts +1 -1
- package/dist/compiler/emit/calls.js +18 -5
- package/dist/compiler/emit/cpi-core.d.ts +3 -1
- package/dist/compiler/emit/cpi-core.js +8 -4
- package/dist/compiler/emit/expressions.d.ts +14 -0
- package/dist/compiler/emit/expressions.js +52 -4
- package/dist/compiler/emit/shared.d.ts +8 -1
- package/dist/compiler/emit/shared.js +8 -1
- package/dist/compiler/emit/statements.d.ts +8 -3
- package/dist/compiler/emit/statements.js +68 -3
- package/dist/compiler/emit/storage.js +5 -1
- package/dist/compiler/hints.d.ts +7 -0
- package/dist/compiler/hints.js +58 -9
- package/dist/compiler/index.d.ts +56 -1
- package/dist/compiler/index.js +27 -3
- package/dist/compiler/model.js +3 -2
- package/dist/compiler/toolchain.d.ts +73 -2
- package/dist/compiler/toolchain.js +222 -17
- package/dist/node-version.d.ts +4 -0
- package/dist/node-version.js +12 -0
- package/dist/tools/docker.d.ts +183 -0
- package/dist/tools/docker.js +442 -0
- package/dist/tools/doctor.d.ts +44 -0
- package/dist/tools/doctor.js +108 -14
- package/dist/workspace.d.ts +11 -3
- package/dist/workspace.js +46 -9
- package/docker/Dockerfile +163 -0
- package/docker/deps/0.43.0.lock.json +1206 -0
- package/docker/deps/0.44.0.lock.json +1206 -0
- package/docker/deps/0.44.1.lock.json +1206 -0
- package/docker/deps/0.45.0.lock.json +1206 -0
- package/docker/deps/0.46.0.lock.json +1206 -0
- package/docs/ai.md +2 -1
- package/docs/architecture.md +18 -6
- package/docs/audit.md +15 -7
- package/docs/case-study-phoenix.md +1 -1
- package/docs/case-study-raydium-amm.md +1 -1
- package/docs/case-study-spl-stake-pool.md +1 -1
- package/docs/cli.md +71 -6
- package/docs/errors.md +22 -8
- package/docs/glossary.md +210 -0
- package/docs/language-accounts.md +499 -0
- package/docs/language-basics.md +389 -0
- package/docs/language-builtins.md +411 -0
- package/docs/language-chain.md +198 -0
- package/docs/language-cpi.md +470 -0
- package/docs/language-errors-events.md +184 -0
- package/docs/language-native.md +493 -0
- package/docs/language-pdas.md +198 -0
- package/docs/language-statements.md +620 -0
- package/docs/language-types.md +601 -0
- package/docs/language.md +190 -467
- package/docs/mainnet.md +103 -8
- package/docs/migrate-from-anchor.md +7 -6
- package/docs/security-model.md +4 -4
- package/docs/stability.md +64 -3
- package/docs/test-your-program.md +52 -15
- package/docs/testing.md +49 -2
- package/docs/troubleshooting.md +210 -42
- package/lib/typesol.d.ts +67 -22
- package/llms-full.txt +5084 -591
- package/llms.txt +12 -1
- package/package.json +4 -2
- package/releases/0.43.0.json +669 -0
- package/releases/0.44.0.json +672 -0
- package/releases/0.44.1.json +672 -0
- package/releases/0.45.0.json +732 -0
- package/runtime/LICENSE-compiler-builtins.txt +275 -0
- package/runtime/typesol_builtins.c +484 -0
- package/ts-plugin/index.js +16 -5
package/docs/mainnet.md
CHANGED
|
@@ -2,18 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
From an empty directory to a program on Solana mainnet-beta: create, test, deploy, publish the IDL, then check that
|
|
4
4
|
the deployed binary is the one your source builds. The program here is the counter that `typesol init` creates
|
|
5
|
-
(11,400 bytes, 11.1 KiB, built with TypeSOL 0.
|
|
5
|
+
(11,400 bytes, 11.1 KiB, built with TypeSOL 0.45.0 and platform-tools clang 20.1.7 for SBPF v0; other versions differ
|
|
6
6
|
slightly); any TypeSOL project works the same way.
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
**Before you deploy anything that holds value.** TypeSOL has had internal security reviews by its maintainers, not an
|
|
9
|
+
independent audit ([status](security-model.md#status)). Do not put significant value behind a program built with it
|
|
10
|
+
until an external audit of the compiler and runtime is published, and audit your own program as you would any Solana
|
|
11
|
+
program.
|
|
12
|
+
|
|
13
|
+
You need Node.js 22.12 or later and the Agave CLI with platform-tools (see the README's [Quick start](../README.md#quick-start)).
|
|
9
14
|
|
|
10
15
|
**The toolchain you deploy with.** The binary is what the platform-tools' clang makes of the generated C, so the
|
|
11
16
|
toolchain is part of what you trust. Deploy with the one TypeSOL is tested with (Agave 3.1.10, platform-tools v1.52;
|
|
12
|
-
`typesol doctor` says whether yours is, and `typesol deploy --toolchain-strict` refuses another).
|
|
17
|
+
`typesol doctor` says whether yours is, and `typesol deploy --toolchain-strict` refuses another). The host does not
|
|
18
|
+
matter from 0.45.0 on: with the same TypeSOL and toolchain a program builds to the same bytes on macOS arm64, Linux
|
|
19
|
+
arm64 and Linux x86_64 (measured over 76 programs for SBPF v0 and 14 for v1 and v2; up to 0.44.1 a program with
|
|
20
|
+
128-bit or signed division did not, [stability.md](stability.md#what-builds-the-same-bytes-where)). For a program others should be able to verify, build
|
|
21
|
+
it with `--docker` (step 2) all the same: a pinned linux/amd64 container that anyone can rebuild, so the whole
|
|
22
|
+
environment is one recipe. Keep
|
|
13
23
|
`target/my_app/my_app.build.json` with each deployment, next to the commit you deployed: it records the TypeSOL,
|
|
14
|
-
TypeScript, clang and platform-tools versions
|
|
15
|
-
only when it rebuilds with the same TypeSOL version and toolchain
|
|
16
|
-
|
|
24
|
+
TypeScript, clang and platform-tools versions, the host, the container when there was one, and the deployed bytes'
|
|
25
|
+
sha256. Step 6's `verify` matches only when it rebuilds with the same TypeSOL version and toolchain (and, for a program
|
|
26
|
+
with 128-bit or signed division built with 0.44.1 or earlier, the same kind of host), and on a mismatch `--manifest`
|
|
27
|
+
with that file shows what differs.
|
|
17
28
|
|
|
18
29
|
## 1. Create and test
|
|
19
30
|
|
|
@@ -40,6 +51,54 @@ program's address, and records the address in `typesol.json`.
|
|
|
40
51
|
**Back up `target/deploy/my_app-keypair.json` now.** It is not committed (`.gitignore`), and without it you cannot
|
|
41
52
|
redeploy to that address.
|
|
42
53
|
|
|
54
|
+
### A build others can verify
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
npx --no-install typesol build --docker
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The same files, built inside a container instead of with your platform-tools. The container is made on your machine
|
|
61
|
+
from `docker/Dockerfile`, which ships in the package; every input is pinned: the Node and busybox base images by their
|
|
62
|
+
linux/amd64 digests, the Agave 3.1.10 and platform-tools v1.52 release files by sha256, the TypeSOL package (the
|
|
63
|
+
version your project uses) by its release record, `releases/<version>.json`: the npm tarball's sha512 integrity and
|
|
64
|
+
sha1 shasum and every file's sha256, checked before it is installed, and its npm dependencies (TypeScript, the
|
|
65
|
+
compiler's front end, among them) by that version's lock, `docker/deps/<version>.lock.json`, which `npm ci` installs
|
|
66
|
+
checking every package's integrity, with no install scripts. The lock of a version ships in the package of that
|
|
67
|
+
version (and in later ones); the locks of 0.43.0, 0.44.0 and 0.44.1, released before locks existed, were resolved
|
|
68
|
+
from the npm registry on 2026-11-12, so their integrity values are what the registry served then, not what an image
|
|
69
|
+
built at their release installed. The first `--docker` build of a TypeSOL version
|
|
70
|
+
builds the image (about 750 MB of downloads, a few minutes; Docker must be running, `typesol doctor` shows it); later
|
|
71
|
+
ones take seconds. The build runs with no network, the project mounted read-only, the output directory writable,
|
|
72
|
+
with no capabilities, as your uid and gid (root for a root caller). `my_app.build.json` then records the container:
|
|
73
|
+
the platform, the Dockerfile's sha256, the pinned base images and downloads, the TypeSOL tarball's hashes, the commit
|
|
74
|
+
its release record names, where the record came from (with the record's sha256), the dependency lock and its sha256,
|
|
75
|
+
and the local image id.
|
|
76
|
+
|
|
77
|
+
Deploy that `my_app.so` with the Solana CLI, `solana program deploy target/my_app/my_app.so --program-id
|
|
78
|
+
target/deploy/my_app-keypair.json --use-rpc` (with your `--url`). What replaces the container build: `typesol deploy`
|
|
79
|
+
(`--dry-run` included) and `typesol build` without `--docker`, which build again with your local platform-tools and
|
|
80
|
+
overwrite it; and `npm test` once the program's sources, SBPF version or address changed, which rebuilds it locally
|
|
81
|
+
and says so (`note: … held a --docker build that is out of date`). What does not: `npm test` while the sources are
|
|
82
|
+
the ones `my_app.build.json` records and the `.so` is the one it records, on any host: the tests then run the
|
|
83
|
+
container's binary. After a local build, `typesol build --docker` again before deploying. Commit the source, keep
|
|
84
|
+
`my_app.build.json`, and publish the commit and that file with the program id.
|
|
85
|
+
|
|
86
|
+
The TypeSOL inside the container is the version this `typesol` is, the one your project installs (`npx --no-install
|
|
87
|
+
typesol`); a global `typesol` of another version than the project's `node_modules/typesol` refuses rather than
|
|
88
|
+
guess. `--typesol-version <v>` picks another. Only versions with a release record can be installed (0.43.0 and later).
|
|
89
|
+
A package carries the records of the releases before it, because a release's record is written after it is
|
|
90
|
+
published; for a release the package does not record (the newest one, or a later one asked for), `--docker` fetches
|
|
91
|
+
`releases/<version>.json` from the repository's main branch
|
|
92
|
+
(`https://raw.githubusercontent.com/typesol-lang/typesol/main/releases/<version>.json`, unauthenticated HTTPS), prints
|
|
93
|
+
where it came from and its sha256, and records both in `my_app.build.json` (`container.typesol.record`). The check is
|
|
94
|
+
then two independent sources agreeing: the tarball npm serves must be the one the repository's record describes, so a
|
|
95
|
+
tampered package would have to be matched by a tampered repository. That holds for a fetched record and for a
|
|
96
|
+
`--release-record` file; for a version whose record ships in the running package, the record came from npm too (in
|
|
97
|
+
an earlier package), so the check is then against what npm served before. Offline, or when the repository has no
|
|
98
|
+
record for that version, it is an error that names `--release-record <file>`, which passes the record yourself (from
|
|
99
|
+
a checkout, `releases/<version>.json`). Between `npm publish` and the commit of the release's record the repository
|
|
100
|
+
answers HTTP 404: `--release-record` is the way then.
|
|
101
|
+
|
|
43
102
|
## 3. A wallet with SOL
|
|
44
103
|
|
|
45
104
|
```sh
|
|
@@ -93,8 +152,38 @@ npx --no-install typesol verify my_app
|
|
|
93
152
|
|
|
94
153
|
`verify` rebuilds the program from `programs/my_app.ts`, reads the deployed one at the address in `typesol.json` from
|
|
95
154
|
the cluster in your Solana CLI config, and compares the bytes. `match` means anyone with your source and the same
|
|
96
|
-
TypeSOL version and toolchain gets exactly the program on chain.
|
|
97
|
-
|
|
155
|
+
TypeSOL version and toolchain gets exactly the program on chain (from 0.45.0 on, on any of the hosts measured: macOS arm64, Linux arm64 with the platform-tools `linux-aarch64` package as in [troubleshooting.md](troubleshooting.md#linux-arm64-the-agave-installer-fails-with-a-404), Linux x86_64; with 0.44.1 or earlier, a
|
|
156
|
+
program with 128-bit or signed division also needs the same kind of host). It also prints the upgrade authority and checks the IDL you published in step 5.
|
|
157
|
+
|
|
158
|
+
A match says only that the deployed bytes are what this source and this compiler build. It does not say that the
|
|
159
|
+
program, or the compiler, is correct, and it does not hold after the next upgrade: whoever holds the upgrade authority
|
|
160
|
+
it prints can replace the program at any time.
|
|
161
|
+
|
|
162
|
+
### Verifying someone else's program
|
|
163
|
+
|
|
164
|
+
With the source at the deployed commit, the program id and, ideally, the deployer's `<name>.build.json`:
|
|
165
|
+
|
|
166
|
+
```sh
|
|
167
|
+
git clone <repository> && cd <repository> && git checkout <commit>
|
|
168
|
+
npx --no-install typesol verify my_app --address <program id> --url mainnet-beta --docker --manifest my_app.build.json
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
`--docker` rebuilds in the same container recipe, built on your machine from the Dockerfile and checked inputs. The
|
|
172
|
+
TypeSOL version is the deployed build's (from the manifest whose binary hash is the deployed bytes'), or
|
|
173
|
+
`--typesol-version <v>`; months later, the current `@typesol/cli` installs the old version in the container, checked
|
|
174
|
+
against its release record. On a match it prints what was verified: the program, the source directory and its git
|
|
175
|
+
commit (and whether it has uncommitted changes), the TypeSOL version and tarball, the commit its record names and
|
|
176
|
+
where the record came from, the dependency lock and its sha256, the clang and platform-tools, the container's
|
|
177
|
+
Dockerfile sha256, base images and downloads, and the command that repeats it (with every option given that changes
|
|
178
|
+
the result: `--address`, `--url`, `--config`, `--sbpf`, `--manifest`, `--release-record`). A program built with
|
|
179
|
+
0.44.x on macOS or Linux arm64 that calls 128-bit or signed division does not match a `--docker` rebuild (those
|
|
180
|
+
versions' binaries depended on the host package; [troubleshooting](troubleshooting.md)). On a mismatch it shows the
|
|
181
|
+
toolchain of each side that is known, as without `--docker`. Exit codes: 0 match, 3 mismatch.
|
|
182
|
+
|
|
183
|
+
What this is not: the container is built locally from pinned inputs, not pulled from a published image, so the first
|
|
184
|
+
verification downloads the inputs and builds it. Its local image id can differ between machines; the Dockerfile's
|
|
185
|
+
sha256 and the pinned inputs are what to compare. The result is not registered with an external verified-build
|
|
186
|
+
registry: the evidence is the command and its output, which anyone can rerun.
|
|
98
187
|
|
|
99
188
|
## 7. Call it
|
|
100
189
|
|
|
@@ -102,6 +191,12 @@ published in step 5. Anyone can run it against your program with `--address <pro
|
|
|
102
191
|
|
|
103
192
|
## Later
|
|
104
193
|
|
|
194
|
+
- **Upgrade it.** `typesol deploy` again replaces the code at the same address; the accounts keep their bytes. If an
|
|
195
|
+
account struct changed, existing accounts do not match it. Only the size is checked (at least the struct's): a field
|
|
196
|
+
added fails with 3003 on an account exactly the old size. On one created with spare space or grown since, it passes
|
|
197
|
+
with no error: an appended field reads the spare bytes (zero unless written), and an inserted one makes the fields
|
|
198
|
+
after it read other fields' bytes. A field removed from the middle, or moved, also reads other fields' bytes without
|
|
199
|
+
an error. Migrate the accounts ([migrating an account](language-accounts.md#migrating-an-account)).
|
|
105
200
|
- **Freeze it.** `solana program set-upgrade-authority <program id> --final` makes the program immutable. It cannot
|
|
106
201
|
be undone.
|
|
107
202
|
- **Close it.** `solana program close <program id> --bypass-warning` returns the rent to the authority. The program
|
|
@@ -24,7 +24,9 @@ and error codes. Its notes (on stderr) list what an existing Anchor client would
|
|
|
24
24
|
token types for token accounts (the table below).
|
|
25
25
|
2. Move the constraints from `#[account(...)]` into the parameter types or the body.
|
|
26
26
|
3. Port the body. Integers are `bigint`s with `n` literals, and every `+ - * / %` is checked.
|
|
27
|
-
4. Test with `typesol/testing` ([test your program](test-your-program.md)), then compare the IDLs
|
|
27
|
+
4. Test with `typesol/testing` ([test your program](test-your-program.md)), then compare the IDLs, section by section
|
|
28
|
+
(with `jq`): `diff <(jq -S .instructions ../anchor/target/idl/my_program.json) <(jq -S .instructions
|
|
29
|
+
target/my_program/my_program.json)`, then the same for `.accounts`, `.types`, `.events` and `.errors`.
|
|
28
30
|
|
|
29
31
|
## Accounts and constraints
|
|
30
32
|
|
|
@@ -46,7 +48,7 @@ and error codes. Its notes (on stderr) list what an existing Anchor client would
|
|
|
46
48
|
| `owner = program`, `executable` | `Owner<A, "…">`, `Executable<A>` |
|
|
47
49
|
| `constraint = expr @ MyError::X` (or without an error: 2003) | `constraint(acct, expr, MyError.X)` (or `constraint(acct, expr)`) at the start of the body: it runs with `acct`'s checks, where Anchor runs it |
|
|
48
50
|
| `realloc = n, realloc::payer = p` | `realloc(acct, n, p)` |
|
|
49
|
-
| `Option<Account<'info, T>>` | `Mut<T> \| null` (the client passes the program id to leave it out) |
|
|
51
|
+
| `Option<Account<'info, T>>` | `Account<T> \| null`, or `Mut<T> \| null` with `#[account(mut)]` (the client passes the program id to leave it out) |
|
|
50
52
|
| `UncheckedAccount` / `AccountInfo` | `AccountInfo` / `Mut<AccountInfo>`: check what you rely on yourself |
|
|
51
53
|
| `SystemAccount<'info>` | `SystemAccount` / `Mut<SystemAccount>` |
|
|
52
54
|
| `Migration<'info, From, To>` | `Migrate<From, To>`, then `acct.migrate(payer, value)`; the old struct keeps its on-chain discriminator with `/** @discriminator account:<OldName> */` |
|
|
@@ -76,7 +78,7 @@ and error codes. Its notes (on stderr) list what an existing Anchor client would
|
|
|
76
78
|
| `#[account] pub struct T { … }` | `export interface T { … }` |
|
|
77
79
|
| `u8` … `u128`, `i8` … `i128`, `bool`, `Pubkey` | `u8` … `u128`, `i8` … `i128`, `boolean`, `Pubkey` |
|
|
78
80
|
| `[T; N]` | `FixedArray<T, N>` |
|
|
79
|
-
| `String` with `#[max_len(n)]` | `FixedString<N>`: a u32 length and N bytes, always N bytes long |
|
|
81
|
+
| `String` with `#[max_len(n)]` | `FixedString<N>`: a u32 length and room for N bytes, always 4 + N bytes long |
|
|
80
82
|
| `Vec<T>` with `#[max_len(n)]` | `Vec<T>` (any number, declared anywhere, stored after the fixed-size fields; it grows with `push(v, payer)`), or `FixedVec<T, n>`: a u32 length and room for n, always 4 + n × size bytes; in a `@layout borsh` struct, `Vec<T>` is Anchor's own, bounded only by the account |
|
|
81
83
|
| `Option<T>` | `Option<T>`: fixed size (1 + size of T) |
|
|
82
84
|
| `#[derive(AnchorSerialize…)] enum` | `export enum` (unit variants) or a data enum `type A = { kind: "X"; … } \| …` |
|
|
@@ -90,8 +92,7 @@ fields after them).
|
|
|
90
92
|
To keep an Anchor program's existing accounts, mark the struct `/** @layout borsh */`: it is then stored exactly as
|
|
91
93
|
Anchor stores it (`FixedString<N>` / `FixedVec<T, N>` / `Option<T>` become Borsh String / Vec / Option, N being the
|
|
92
94
|
`#[max_len]`), its IDL type is Anchor's, and the upgraded program reads and writes the accounts in place. `typesol port`
|
|
93
|
-
adds it for you. It costs some compute
|
|
94
|
-
several times cheaper than Anchor. Without it, accounts that use these types need a migration (or a new program) rather
|
|
95
|
+
adds it for you. It costs some compute: the account is unpacked and packed in every instruction that uses it. Without it, accounts that use these types need a migration (or a new program) rather
|
|
95
96
|
than an in-place upgrade. Everything else, including instruction arguments (`String`, `Option`, `Vec` are Borsh there),
|
|
96
97
|
matches byte for byte. A `@layout borsh` struct passed as a whole argument, returned or emitted is Borsh too, so an
|
|
97
98
|
Anchor instruction that takes or returns a struct with `String` / `Vec` / `Option` fields keeps its client bytes.
|
|
@@ -105,7 +106,7 @@ Anchor instruction that takes or returns a struct with `String` / `Vec` / `Optio
|
|
|
105
106
|
| `#[error_code] enum MyError { #[msg("…")] X }` | `export enum MyError { X = "…" }` (codes from 6000, in order; `X = ""` for a variant without `#[msg]`; `/** @code 6200 */` before a member for Anchor's `Y = 200`) |
|
|
106
107
|
| `f64` fields (events) | `f64`, made from the bits the program computed (`f64FromBits`) |
|
|
107
108
|
| `Option<[T; N]>`, structs of Options inside Options (`BankConfigOpt`) | `Option<FixedArray<T, N>>`; a struct argument holding Options is Borsh as Anchor sends it; an event holding one is `/** @layout borsh */` (`typesol port` writes it so) |
|
|
108
|
-
| `#[account(zero_copy)]`, `#[repr(C)]` types with `_pad` fields and `WrappedI80F48` | a fixed-layout struct with `/** @serialization bytemuck */` and `/** @repr c */`, `/** @idlName _pad0 */` on the padding, `/** @bytes */ value: i128` for the wrapped number ([
|
|
109
|
+
| `#[account(zero_copy)]`, `#[repr(C)]` types with `_pad` fields and `WrappedI80F48` | a fixed-layout struct with `/** @serialization bytemuck */` and `/** @repr c */`, `/** @idlName _pad0 */` on the padding, `/** @bytes */ value: i128` for the wrapped number ([zero-copy types](language-accounts.md#zero-copy-types-as-anchors-idl-describes-them)) |
|
|
109
110
|
| `require!(c, MyError::X)`, `err!(MyError::X)` | `require(c, MyError.X)`, `require(false, MyError.X)` |
|
|
110
111
|
| `require_keys_eq!(a, b)`, `err!(ErrorCode::AccountDidNotDeserialize)` (Anchor's own codes) | `require(a === b, AnchorError.RequireKeysEqViolated)` (or your own error), `require(false, AnchorError.AccountDidNotDeserialize)` |
|
|
111
112
|
| `init_if_needed` + `extensions::…` on a mint | `mint.createIfNeeded(…, { metadataPointer: {…}, … })`: an existing mint is checked as Anchor checks it (2024–2039) |
|
package/docs/security-model.md
CHANGED
|
@@ -10,7 +10,7 @@ auditors, [SECURITY.md](../SECURITY.md) how to report a problem.
|
|
|
10
10
|
| --- | --- |
|
|
11
11
|
| The program's author | the program's logic: what it allows, to whom, for how much |
|
|
12
12
|
| TypeSOL (this repository) | that the binary does what the source and these guarantees say, and nothing an attacker can steer beyond it |
|
|
13
|
-
| The toolchain | the TypeScript compiler API (parsing, types), Agave platform-tools (clang, lld), Node.js. The guarantees are tested with one platform-tools release (v1.52, from Agave 3.1.10); a build with another warns, or fails with `--toolchain-strict`, and `<name>.build.json` records which one built a binary |
|
|
13
|
+
| The toolchain | the TypeScript compiler API (parsing, types), Agave platform-tools (clang, lld), Node.js. The guarantees are tested with one platform-tools release (v1.52, from Agave 3.1.10); a build with another warns, or fails with `--toolchain-strict`, and `<name>.build.json` records which one built a binary and on which host. The compiler builtins (128-bit multiplication, division and shifts, signed 64-bit division) are TypeSOL's own (`runtime/typesol_builtins.c`), compiled with the program; nothing is linked from platform-tools' Rust libraries, whose layout differed by host package, so from 0.45.0 on the programs measured build to the same bytes on macOS arm64, Linux arm64 and Linux x86_64 ([stability.md](stability.md#what-builds-the-same-bytes-where): 76 programs for SBPF v0, 14 for v1 and v2). `--docker` builds pin the whole environment in one linux/amd64 container whose inputs are checked by digest, checksum and integrity (base images, release files, the TypeSOL tarball and every npm dependency) |
|
|
14
14
|
| The Solana runtime | account ownership and signer flags as passed, the loader's account serialization, CPI privilege rules, sysvars |
|
|
15
15
|
|
|
16
16
|
Everything a transaction carries is attacker-controlled: the instruction data, which accounts are passed in which
|
|
@@ -26,9 +26,9 @@ Each holds for every instruction of every program the compiler accepts. A break
|
|
|
26
26
|
|
|
27
27
|
1. **Account count.** Fewer accounts than parameters fail (3005); more than the program takes (32, or its `MAX_ACCOUNTS`) fail before parsing (5113).
|
|
28
28
|
2. **Account types.** Each parameter is checked for what its type says: `Signer` signed (3010); `Mut<…>` writable
|
|
29
|
-
(2000); a program account (`Account<T>`, `Mut<T>`) owned by this program (3007),
|
|
30
|
-
|
|
31
|
-
initialized account of that kind (3007
|
|
29
|
+
(2000); a program account (`Account<T>`, `Mut<T>`) initialized (3012), owned by this program (3007), at least
|
|
30
|
+
`T`'s size (3003) and with `T`'s discriminator (3002), checked in that order; a `TokenAccount` / `Mint` an
|
|
31
|
+
initialized account of that kind of SPL Token or Token-2022 (3012 for an empty system account (never created, or closed), 3007 for an account of another program, 3003 for a token program's account that is not an initialized token account (or mint) of its length); program parameters at their fixed address and executable
|
|
32
32
|
(3008 / 3009); `SystemAccount` owned by the System Program (3011); `Zeroed<T>` owned, all-zero discriminator and
|
|
33
33
|
rent-exempt.
|
|
34
34
|
3. **No aliasing.** Two writable parameters are never the same account (2040), whatever slots the transaction uses,
|
package/docs/stability.md
CHANGED
|
@@ -11,9 +11,12 @@ From 1.0 on, within a major version:
|
|
|
11
11
|
|
|
12
12
|
- **Sources keep compiling.** A program that compiles with 1.x compiles with every later 1.y, to a program with the same
|
|
13
13
|
account layouts, IDL, instruction and account discriminators and error codes. New releases add; they do not take away.
|
|
14
|
-
- **Binaries are reproducible and only change for a reason.** With the same TypeSOL release and the
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
- **Binaries are reproducible and only change for a reason.** With the same TypeSOL release and the tested
|
|
15
|
+
toolchain, a source builds to the same bytes in the build container (`--docker`) as on the hosts measured: from
|
|
16
|
+
0.45.0 on, macOS arm64, Linux arm64 and Linux x86_64, for the programs and SBPF versions listed
|
|
17
|
+
[below](#what-builds-the-same-bytes-where).
|
|
18
|
+
A release that changes the binary of a program that uses none of its new features says so, with the release
|
|
19
|
+
manifest's diff (`typesol-<version>-binary-diff.txt`) as the evidence.
|
|
17
20
|
- **The checks stay.** No check a program gets from its parameter types (owner, discriminator, signer, writability,
|
|
18
21
|
aliasing, checked arithmetic, constraints) is removed or weakened.
|
|
19
22
|
- **The tools keep their interfaces**: `typesol build`, `test` (via `typesol/testing`), `check --json`, `deploy`,
|
|
@@ -46,10 +49,68 @@ Meant to stay as they are; a change before 1.0 would be a breaking change listed
|
|
|
46
49
|
- **A build says what made it.** `<name>.build.json` records the TypeSOL, TypeScript, clang and platform-tools versions,
|
|
47
50
|
the host, the SBPF version and the sha256 of every source and of the binary. `typesol verify` uses it to say, on a
|
|
48
51
|
mismatch, whether the toolchains differ. A program on chain records none of this: keep the file with the deployment.
|
|
52
|
+
- **A deployed program anyone can rebuild.** `typesol build --docker` builds in a container made from
|
|
53
|
+
`docker/Dockerfile` (in the package), whose inputs are all pinned: base images by digest, the Agave and
|
|
54
|
+
platform-tools release files by sha256, the TypeSOL tarball by its `releases/<version>.json`. `typesol verify
|
|
55
|
+
--docker` rebuilds there and says what it verified. The image is built locally from those inputs; no image is
|
|
56
|
+
published, and the result is not registered with any external verified-build registry
|
|
57
|
+
([docs/mainnet.md](mainnet.md#6-verify)).
|
|
49
58
|
- **Fixes come as patches of the latest minor.** From 0.44.0 on, a release that only fixes soundness or security
|
|
50
59
|
defects is a patch (0.44.1, …) with no new language surface, and its notes carry the binary diff against the
|
|
51
60
|
previous release ([SECURITY.md](../SECURITY.md#fix-releases)). Older minors are not maintained.
|
|
52
61
|
|
|
62
|
+
## What builds the same bytes where
|
|
63
|
+
|
|
64
|
+
From 0.45.0 on, the programs measured build to the same bytes on each host measured. Measured with this release's
|
|
65
|
+
compiler and platform-tools v1.52 on macOS arm64 (the platform-tools `osx-aarch64` package, native), Linux arm64 and
|
|
66
|
+
Linux x86_64 (the `linux-aarch64` and `linux-x86_64` packages, in containers; x86_64 is the `--docker` image; Linux
|
|
67
|
+
arm64 has no Agave CLI, so there the package is set up by hand with `TYPESOL_SBF_SDK`, as in
|
|
68
|
+
[troubleshooting.md](troubleshooting.md#linux-arm64-the-agave-installer-fails-with-a-404)): for
|
|
69
|
+
SBPF v0 (the default), the 76 programs of the sources (`scripts/release-manifest.ts`, every program under `examples/`
|
|
70
|
+
and `showcase/`); for SBPF v1 and v2, the 14 programs of `test/golden/binaries.json` (counter, vault, escrow, multisig
|
|
71
|
+
and the 10 below).
|
|
72
|
+
|
|
73
|
+
| What | Same on the three hosts? |
|
|
74
|
+
| --- | --- |
|
|
75
|
+
| The generated C and the IDL (all 76) | yes |
|
|
76
|
+
| The binary, SBPF v0 (all 76) | yes |
|
|
77
|
+
| The binary, SBPF v1 and v2 (the 14) | yes |
|
|
78
|
+
| The binary, SBPF v0, against 0.44.1 | 66 programs build to 0.44.1's bytes on each of the three; the 10 below build to new bytes, the same on the three |
|
|
79
|
+
| The binary, SBPF v1 and v2, against 0.44.1 (on macOS arm64) | v1: all 14 build to new bytes; v2: 9 (the 10 below but token-fundraiser) build to new bytes, the other 5 (counter, vault, escrow, multisig, token-fundraiser) to 0.44.1's |
|
|
80
|
+
|
|
81
|
+
The 10 are the programs that call 128-bit or signed 64-bit division (the Phoenix, Marginfi, Raydium AMM, CLMM and
|
|
82
|
+
CP-Swap, Jito priority-fee and Stake Pool ports, transfer-fee, token-fundraiser, token-swap). With 0.44.1 each of them
|
|
83
|
+
built to three different binaries on the three hosts (token-fundraiser: the two Linux ones agreed). The cause was one
|
|
84
|
+
library: platform-tools' SBF `compiler-builtins` Rust library (`libcompiler_builtins-<hash>.rlib`, a different file in
|
|
85
|
+
each host package). Its functions have the same instructions in the three packages (compared function by function for
|
|
86
|
+
SBPF v0, v1 and v2), but each package splits them into differently numbered archive members, so the linker placed the
|
|
87
|
+
ones a division pulls in (`__udivti3`, its shared `u128_div_rem`, `__ashlti3`, `__lshrti3`, …) in another order, and
|
|
88
|
+
the program's calls into them had other offsets. Programs that called at most `__multi3` linked one member and agreed.
|
|
89
|
+
|
|
90
|
+
TypeSOL now links none of that library: `runtime/typesol_builtins.c` defines every builtin the tested clang calls for
|
|
91
|
+
C integer code on SBF (`__multi3`, `__udivti3`, `__umodti3`, `__divti3`, `__modti3`, `__ashlti3`, `__lshrti3`, `__ashrti3`, `__divdi3`,
|
|
92
|
+
`__moddi3`) and is compiled with each program, by the same clang, and linked after it. Multiplication and shifts are
|
|
93
|
+
the instructions compiler-builtins has for them, so on SBPF v0 programs that use only those keep their bytes;
|
|
94
|
+
division is new C that costs no more compute units than compiler-builtins' on any input measured, and fewer on most
|
|
95
|
+
(`test/language/builtins.test.ts`). On SBPF v1, `__multi3` (128-bit multiplication, which checked 64-bit
|
|
96
|
+
multiplication uses too) is C as well, cheaper than compiler-builtins' there (175 against 177.5 compute units a call on average in that test),
|
|
97
|
+
so a v1 program that
|
|
98
|
+
multiplies that way builds to other bytes than with 0.44.1 (every one of the 14 measured does); SBPF v2 multiplies
|
|
99
|
+
with its own instructions and calls no `__multi3`, and its signed 64-bit division is an instruction too, which is
|
|
100
|
+
why token-fundraiser keeps its v2 bytes.
|
|
101
|
+
libc's `memcpy` and `memset` still come from platform-tools; the programs that link them build the same on the three
|
|
102
|
+
hosts. Nothing in the emitted C, the paths or the build directory reaches the binary.
|
|
103
|
+
|
|
104
|
+
The reference environment stays one platform, so that the whole environment is one recipe: the build container is
|
|
105
|
+
`linux/amd64` on every machine (emulated on arm64 hosts). CI checks on every change that a Linux x86_64 runner with
|
|
106
|
+
independently installed platform-tools builds the programs of `test/golden/binaries.json` (the 14 for SBPF v0, and
|
|
107
|
+
counter, escrow, Phoenix and Marginfi for v1 and v2) to the container's bytes; that is the same host package as the
|
|
108
|
+
container's, installed separately. The macOS workflow (on demand) runs the same check on macOS arm64, and anyone can
|
|
109
|
+
run it on another host, binary included. `<name>.build.json` records the host; `typesol verify` counts a host
|
|
110
|
+
difference between builds made before 0.45.0 (which linked compiler-builtins: a possible cause if the program uses
|
|
111
|
+
128-bit or signed division), and between later builds only when one of the hosts is not among the three measured
|
|
112
|
+
(`host (not measured)`).
|
|
113
|
+
|
|
53
114
|
## Experimental
|
|
54
115
|
|
|
55
116
|
Useful today, but may still change before 1.0 (each change listed in the CHANGELOG):
|
|
@@ -24,7 +24,8 @@ it("counts", async () => {
|
|
|
24
24
|
## Instructions
|
|
25
25
|
|
|
26
26
|
`t.pda(...seeds)` derives this program's PDA for the seeds; `t.pdaWithBump(...seeds)` gives `[address, bump]`, for an
|
|
27
|
-
instruction that takes the bump as an argument
|
|
27
|
+
instruction that takes the bump as an argument (prefer a stored bump:
|
|
28
|
+
[PDAs](language-pdas.md#checking-a-pda-in-the-body)).
|
|
28
29
|
|
|
29
30
|
`t.ix(name, args, accounts, remaining?)` builds one instruction.
|
|
30
31
|
|
|
@@ -39,6 +40,26 @@ instruction that takes the bump as an argument.
|
|
|
39
40
|
|
|
40
41
|
`t.send(payer, ...ixs)` sends them in one transaction; keypairs given as accounts sign too.
|
|
41
42
|
|
|
43
|
+
### Seeds of other widths
|
|
44
|
+
|
|
45
|
+
`t.pda` takes text, addresses or keypairs, raw bytes, and bigints, which it encodes as 8-byte little-endian u64s, as
|
|
46
|
+
the program encodes a `u64` seed. A seed of another width is passed as its bytes: for a program that derives
|
|
47
|
+
`["vault", owner.key, index]` with `index: u16`,
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
const u16 = (n: number) => {
|
|
51
|
+
const b = new Uint8Array(2);
|
|
52
|
+
new DataView(b.buffer).setUint16(0, n, true); // little-endian, as the program reads a u16 seed
|
|
53
|
+
return b;
|
|
54
|
+
};
|
|
55
|
+
const vault = await t.pda("vault", alice, u16(3));
|
|
56
|
+
t.ok(await t.send(alice, t.ix("open", { index: 3 }, { owner: alice, vault })));
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`t.pda("vault", alice, 3n)` would be another address (8 bytes for the index). `setUint32` gives a `u32` seed the same
|
|
60
|
+
way. A string that is a valid address is taken as an address; pass `new TextEncoder().encode(s)` for text that only
|
|
61
|
+
looks like one.
|
|
62
|
+
|
|
42
63
|
## Results
|
|
43
64
|
|
|
44
65
|
| Helper | Gives |
|
|
@@ -51,6 +72,22 @@ instruction that takes the bump as an argument.
|
|
|
51
72
|
| `t.errorName(code)` | the name of an error code: your program's, TypeSOL's or Anchor's |
|
|
52
73
|
| `t.connection` | `{ rpc, rpcSubscriptions }` answered by this LiteSVM, for the generated client: `counter.sendInstructions(t.connection, alice, [ix])`, `counter.accounts.Counter.fetch(t.connection.rpc, address)`, views, `resolve`, `watch` and `watchEvents` (as on a cluster: `watch` yields when a later transaction changes the account, not at once; `watchEvents` gets transactions sent after it subscribed, failed ones included in the stream and skipped by the client) |
|
|
53
74
|
|
|
75
|
+
### Expecting an error
|
|
76
|
+
|
|
77
|
+
A test that a check holds sends the transaction that breaks it and compares the code. The program here is the vault
|
|
78
|
+
of [seeds of other widths](#seeds-of-other-widths), whose `spend` requires `amount <= 10n` and whose only error enum is
|
|
79
|
+
`export enum VaultError { TooMuch = "Amount above the limit" }`, so `TooMuch` is 6000 (in the guide's
|
|
80
|
+
[`spend`](language-accounts.md#constraints), `NotOwner` comes first and `TooMuch` is 6001):
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
const res = await t.send(alice, t.ix("spend", { amount: 50n }, { owner: alice, vault }));
|
|
84
|
+
expect(t.errorCode(res)).toBe(6000);
|
|
85
|
+
expect(t.errorName(t.errorCode(res))).toBe("TooMuch");
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
`t.errorCode` throws when the transaction succeeded or failed without a custom code (a runtime error such as missing
|
|
89
|
+
signatures), so the test fails then too.
|
|
90
|
+
|
|
54
91
|
## Tokens and time
|
|
55
92
|
|
|
56
93
|
| Helper | Does |
|
|
@@ -60,6 +97,20 @@ instruction that takes the bump as an argument.
|
|
|
60
97
|
| `t.tokenBalance(address)` | the amount a token account holds, or `null` when it does not exist |
|
|
61
98
|
| `t.warp({ unixTimestamp?, slot?, seconds? })` | moves the Clock: to a timestamp or slot, or forward by `seconds` |
|
|
62
99
|
|
|
100
|
+
## Accounts from a cluster
|
|
101
|
+
|
|
102
|
+
To test against accounts that exist on mainnet (a mint, an oracle, another program), list them in `typesol.json` as
|
|
103
|
+
`"clone": ["<address>", …]` and run `typesol clone --url mainnet-beta` once (or `typesol clone <address>…`). They are
|
|
104
|
+
written to `tests/accounts/`, which `testProgram` loads into its LiteSVM before your first test; commit the directory so
|
|
105
|
+
the tests run offline. `loadClonedAccounts(svm, dir)` does the same for a LiteSVM of your own.
|
|
106
|
+
|
|
107
|
+
`t.svm`, `t.programId`, `t.idl` and `t.coder` are there for anything else. `programHarness(svm, programId, idl)` gives the same helpers for a
|
|
108
|
+
program you loaded yourself, and `svmConnection(svm)` the RPC pair alone (for any LiteSVM, e.g. one with an Anchor
|
|
109
|
+
program loaded). Transactions sent through it run at once; `getProgramAccounts` (`fetchAll`) sees the accounts those
|
|
110
|
+
transactions named, plus any you `track(...)`.
|
|
111
|
+
|
|
112
|
+
The module needs `litesvm` and `@anchor-lang/core`, which `typesol init` adds to `devDependencies`.
|
|
113
|
+
|
|
63
114
|
## Epochs and staking
|
|
64
115
|
|
|
65
116
|
LiteSVM's `warpToSlot` leaves `Clock.epoch` where it was, and its StakeHistory stays empty, so the Stake program takes
|
|
@@ -106,17 +157,3 @@ expect(cluster.activation(stake).effective).toBe(90n * SOL);
|
|
|
106
157
|
(`newRateActivationEpoch` 0, as the Stake program has it); `null` gives the original 25%.
|
|
107
158
|
- **Rent.** In LiteSVM 1.6.1 the Stake program holds back the Rent sysvar's minimum for 200 bytes
|
|
108
159
|
(`svm.minimumBalanceForRentExemption(200n)`), which is less than the `rentExemptReserve` its Initialize stores.
|
|
109
|
-
|
|
110
|
-
## Accounts from a cluster
|
|
111
|
-
|
|
112
|
-
To test against accounts that exist on mainnet (a mint, an oracle, another program), list them in `typesol.json` as
|
|
113
|
-
`"clone": ["<address>", …]` and run `typesol clone --url mainnet-beta` once (or `typesol clone <address>…`). They are
|
|
114
|
-
written to `tests/accounts/`, which `testProgram` loads into its LiteSVM before your first test; commit the directory so
|
|
115
|
-
the tests run offline. `loadClonedAccounts(svm, dir)` does the same for a LiteSVM of your own.
|
|
116
|
-
|
|
117
|
-
`t.svm`, `t.programId`, `t.idl` and `t.coder` are there for anything else. `programHarness(svm, programId, idl)` gives the same helpers for a
|
|
118
|
-
program you loaded yourself, and `svmConnection(svm)` the RPC pair alone (for any LiteSVM, e.g. one with an Anchor
|
|
119
|
-
program loaded). Transactions sent through it run at once; `getProgramAccounts` (`fetchAll`) sees the accounts those
|
|
120
|
-
transactions named, plus any you `track(...)`.
|
|
121
|
-
|
|
122
|
-
The module needs `litesvm` and `@anchor-lang/core`, which `typesol init` adds to `devDependencies`.
|
package/docs/testing.md
CHANGED
|
@@ -47,12 +47,13 @@ From 0.39.0 on, each release's GitHub Release carries its manifest, `typesol-<ve
|
|
|
47
47
|
hand after the npm publish (written by `scripts/release-manifest.ts` from the tag's sources; the scripts need Node 22.18
|
|
48
48
|
or later):
|
|
49
49
|
|
|
50
|
-
- the compiler and toolchain versions (clang, platform-tools, Node, TypeScript, the runtime header
|
|
50
|
+
- the compiler and toolchain versions (clang, platform-tools, Node, TypeScript, the sha256 of the runtime header and,
|
|
51
|
+
from 0.45.0 on, of the runtime's compiler builtins);
|
|
51
52
|
- the sha256 of the SBF binary, IDL and C that every program under `examples/` and `showcase/program-examples/` builds to;
|
|
52
53
|
- the sha256 of the reference binaries the differential tests run against (`test/programs/`);
|
|
53
54
|
- a hash of the test corpus.
|
|
54
55
|
|
|
55
|
-
It also carries `binary-diff.txt
|
|
56
|
+
It also carries `typesol-<version>-binary-diff.txt` (older releases: `binary-diff.txt`): the previous release's sources built by the previous package and by this one,
|
|
56
57
|
compared program by program. That is the check behind a changelog line such as "programs that use none of these compile to the
|
|
57
58
|
same binaries". To redo it, or to compare other versions:
|
|
58
59
|
|
|
@@ -68,6 +69,41 @@ node scripts/release-manifest.ts --diff a.json b.json
|
|
|
68
69
|
For 0.37.0 → 0.38.0 (run by hand before release manifests existed): all 67 programs of the 0.37.0 sources build to
|
|
69
70
|
the same binary and IDL with both packages.
|
|
70
71
|
|
|
72
|
+
### Across hosts
|
|
73
|
+
|
|
74
|
+
From 0.45.0 on the C, IDL and linked binary TypeSOL's builds produce are the same on the hosts measured
|
|
75
|
+
([stability.md](stability.md#what-builds-the-same-bytes-where) has the measurement over 76 programs on macOS arm64,
|
|
76
|
+
Linux arm64 and Linux x86_64, and why 0.44.1 and earlier differed for programs with 128-bit or signed division). The
|
|
77
|
+
reference environment is the `--docker` build container (linux/amd64). `test/golden/binaries.json` holds what 14
|
|
78
|
+
programs build to there with the checkout's compiler: counter, vault, escrow, multisig, and the 10 that call 128-bit or
|
|
79
|
+
signed division (the Phoenix, Marginfi, Raydium AMM, CLMM and CP-Swap, Jito priority-fee and Stake Pool ports,
|
|
80
|
+
transfer-fee, token-fundraiser, token-swap), the ones whose binary used to depend on the host, for SBPF v0; and
|
|
81
|
+
counter, escrow, Phoenix and Marginfi for v1 and v2 (`<path>:v1`, `<path>:v2`). CI checks on every change that its
|
|
82
|
+
Linux x86_64 runner, with platform-tools installed by `cargo-build-sbf`, gives the same C, IDL and bytes (the same
|
|
83
|
+
host package as the container's, installed separately); the macOS workflow, run on demand, checks macOS arm64. On
|
|
84
|
+
another host the check is the same (binary included):
|
|
85
|
+
|
|
86
|
+
```sh
|
|
87
|
+
node scripts/release-manifest.ts --check test/golden/binaries.json # what CI runs; the same result on macOS
|
|
88
|
+
node scripts/release-manifest.ts --docker --out test/golden/binaries.json --programs \
|
|
89
|
+
examples/counter.ts,examples/vault.ts,examples/escrow.ts,showcase/mainnet/multisig/multisig.ts,showcase/mainnet/phoenix/phoenix.ts,showcase/mainnet/marginfi/marginfi.ts,showcase/mainnet/raydium-amm/raydium_amm.ts,showcase/mainnet/raydium-clmm/raydium_clmm.ts,showcase/mainnet/raydium-cp-swap/raydium_cp_swap.ts,showcase/mainnet/jito-mev/priority_fee_distribution.ts,showcase/mainnet/spl-stake-pool/stake_pool.ts,showcase/program-examples/tokens/token-2022/transfer-fee.ts,showcase/program-examples/tokens/token-fundraiser.ts,showcase/program-examples/tokens/token-swap/lib.ts,examples/counter.ts:v1,examples/escrow.ts:v1,showcase/mainnet/phoenix/phoenix.ts:v1,showcase/mainnet/marginfi/marginfi.ts:v1,examples/counter.ts:v2,examples/escrow.ts:v2,showcase/mainnet/phoenix/phoenix.ts:v2,showcase/mainnet/marginfi/marginfi.ts:v2
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The second regenerates the file in the container (Docker, the checkout built with `pnpm build`, committed: `--docker`
|
|
93
|
+
refuses a tree with uncommitted changes, as the file records the commit; no network once the image exists), after a
|
|
94
|
+
change that alters what those programs compile to. `--check` says `STALE` when the C or IDL differ (regenerate) and
|
|
95
|
+
`DIFFERS` when the same C and IDL give other bytes (a toolchain problem); it fails on a reference that lists no
|
|
96
|
+
program, has an entry that did not build, or was made from uncommitted changes (`sources.dirty`).
|
|
97
|
+
`test/cli/release-manifest.test.ts` covers each outcome. The whole set, on more
|
|
98
|
+
hosts: build `scripts/release-manifest.ts` (every program) on each and compare with `--diff`, as for a release. The
|
|
99
|
+
compiler builtins themselves are tested by `test/language/builtins.test.ts`: each against a BigInt reference and
|
|
100
|
+
against platform-tools' compiler-builtins on edge cases and a seeded random set (`FUZZ_SEED`, `BUILTINS_RANDOM`), run as
|
|
101
|
+
SBF in LiteSVM for SBPF v0, v1 and v2, with each call's compute units compared to compiler-builtins' (never more).
|
|
102
|
+
With the default seed that is 84,741 to 91,289 calls per multiplication or division function and 59,506 per shift on
|
|
103
|
+
v0, and 41,506 to 73,289 on v1 and v2. The container itself is tested by `test/cli/docker.test.ts` with
|
|
104
|
+
`TYPESOL_DOCKER_TESTS=1` (off in CI: the first image build downloads about 750 MB); without Docker the same file
|
|
105
|
+
checks the Dockerfile's tarball and dependency-lock scripts on crafted inputs.
|
|
106
|
+
|
|
71
107
|
### The npm tarball
|
|
72
108
|
|
|
73
109
|
From 0.43.0 on, `releases/<version>.json` in the repository describes the package on npm: the tag and its commit, the
|
|
@@ -90,3 +126,14 @@ or another Node (its zlib compresses the archive). The record also keeps the unc
|
|
|
90
126
|
file's, which compare across those, and `--verify --tarball` says which files differ, if any. 0.42.0 and earlier
|
|
91
127
|
were published from a maintainer's checkout without a record.
|
|
92
128
|
|
|
129
|
+
### The build container's dependencies
|
|
130
|
+
|
|
131
|
+
The `--docker` image installs a TypeSOL version's npm dependencies with `npm ci` from `docker/deps/<version>.lock.json`
|
|
132
|
+
(an npm lockfile v3 of the package's runtime dependencies only), so every package is checked against the integrity
|
|
133
|
+
the lock records and nothing is resolved when the image is built. `node scripts/release-check.ts <version> --lock`
|
|
134
|
+
writes it from `package.json` (when it has that version) or from the published package's dependencies (`npm view`),
|
|
135
|
+
resolved from the registry at that moment; the release procedure runs it before the release commit, so the lock of
|
|
136
|
+
version N ships in package N, and the check of the tag refuses a release without it (or with one for other
|
|
137
|
+
dependencies) and installs it with `npm ci` in a temporary directory. The locks of 0.43.0, 0.44.0 and 0.44.1 were
|
|
138
|
+
made this way on 2026-11-12, after those releases: their integrity values are what the registry served that day.
|
|
139
|
+
|