@typesol/cli 0.44.1 → 0.45.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 +116 -0
- package/NOTICE +14 -1
- package/README.md +52 -10
- package/SECURITY.md +1 -1
- package/dist/cli.js +194 -48
- package/dist/compiler/index.d.ts +51 -1
- package/dist/compiler/index.js +17 -2
- package/dist/compiler/toolchain.d.ts +23 -0
- package/dist/compiler/toolchain.js +128 -8
- package/dist/tools/docker.d.ts +183 -0
- package/dist/tools/docker.js +442 -0
- package/dist/tools/doctor.d.ts +3 -0
- package/dist/tools/doctor.js +12 -0
- package/dist/workspace.d.ts +2 -1
- package/dist/workspace.js +33 -6
- 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/docs/architecture.md +12 -4
- package/docs/audit.md +9 -1
- package/docs/cli.md +31 -4
- package/docs/mainnet.md +86 -6
- package/docs/security-model.md +1 -1
- package/docs/stability.md +62 -3
- package/docs/testing.md +49 -2
- package/docs/troubleshooting.md +46 -0
- package/llms-full.txt +230 -18
- package/package.json +3 -1
- 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/runtime/LICENSE-compiler-builtins.txt +275 -0
- package/runtime/typesol_builtins.c +484 -0
package/llms-full.txt
CHANGED
|
@@ -39,10 +39,6 @@ sh -c "$(curl -sSfL https://release.anza.xyz/v3.1.10/install)"
|
|
|
39
39
|
cargo-build-sbf --install-only --force-tools-install --tools-version v1.52
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
Other versions work, but their binaries are not covered by the project's tests: `typesol build` warns once when the
|
|
43
|
-
clang is another one (`--toolchain-strict` or `TYPESOL_TOOLCHAIN=strict` makes that an error), and every build records
|
|
44
|
-
its clang, platform-tools and host in `<name>.build.json`.
|
|
45
|
-
|
|
46
42
|
```sh
|
|
47
43
|
npx @typesol/cli init my-app --name counter # typesol.json, programs/counter.ts, tests/counter.test.ts, tsconfig
|
|
48
44
|
cd my-app && npm install
|
|
@@ -50,6 +46,10 @@ npm test # builds the program and runs it i
|
|
|
50
46
|
npx --no-install typesol build # target/counter/{counter.so, counter.json (IDL), counter.client.ts, counter.build.json}
|
|
51
47
|
```
|
|
52
48
|
|
|
49
|
+
Other versions work, but their binaries are not covered by the project's tests: `typesol build` warns once when the
|
|
50
|
+
clang is another one (`--toolchain-strict` or `TYPESOL_TOOLCHAIN=strict` makes that an error), and every build records
|
|
51
|
+
its clang, platform-tools and host in `<name>.build.json`.
|
|
52
|
+
|
|
53
53
|
`npx --no-install typesol doctor` checks all of this (Node.js, platform-tools and whether they are the tested ones, Solana CLI, keypair, RPC) and prints the command
|
|
54
54
|
that fixes anything missing. Inside a project, `npx --no-install typesol …` (or `npm run build`, `npm run deploy`) runs the
|
|
55
55
|
project's own copy; outside one, use `npx @typesol/cli …`. Plain `npx typesol` is not TypeSOL: `typesol` is not the npm
|
|
@@ -802,9 +802,9 @@ error. Exit codes: **0** success, **1** failure (compile errors, failed deploy,
|
|
|
802
802
|
| --- | --- |
|
|
803
803
|
| `typesol init [<dir>] [--name <program>] [--template counter\|vault\|escrow]` | Create a project: `typesol.json`, `programs/<name>.ts`, `tests/<name>.test.ts` (LiteSVM), `package.json`, `tsconfig.json`, `programs/tsconfig.json` (with the editor plugin), `.vscode/settings.json` (the workspace TypeScript, so the plugin loads), `.gitignore`, the rules for AI coding agents (`AGENTS.md`, `CLAUDE.md` importing it, `.cursor/rules/typesol.mdc`) and the MCP server configuration (`.mcp.json`, `.cursor/mcp.json`; see [ai.md](ai.md)). `<name>` must be snake_case; by default it is derived from `<dir>` (`my-app` → `my_app`). The template picks the program and its test: `counter` (default, a PDA counter per user), `vault` (SOL at a PDA: deposit, withdraw above rent, close) or `escrow` (SPL tokens: make, take, refund, the offer PDA signing for its vault). Refuses to overwrite files. It warns, with the install commands, when the platform-tools that building needs are missing. |
|
|
804
804
|
| `typesol new <program> [--template counter\|vault\|escrow]` | In a project: add a program, `programs/<program>.ts` and `tests/<program>.test.ts` from the template, and its entry in `typesol.json`. Refuses to overwrite files or reuse a name. |
|
|
805
|
-
| `typesol doctor [--url <rpc>] [--config <cli config>]` | Check what building, testing and deploying need: Node.js, the platform-tools (and a `toolchain` row: the tested ones, or untested with both versions), the Solana CLI, its keypair, the RPC (`--url`, a cluster moniker, or the CLI config) and the keypair's balance there, and the project. Each problem is printed with the command that fixes it. Exit code 1 when building is impossible (Node.js or the platform-tools missing); deploy pieces are warnings. |
|
|
806
|
-
| `typesol build [<program>…] [--sbpf v0\|v1\|v2] [--profile] [--toolchain-strict] [--quiet]` | In a project: build every program (or those named) into `<out>/<name>/`: `<name>.so`, `<name>.json` (Anchor IDL), `<name>.client.ts` (TypeScript client, see [client.md](client.md)), `<name>.c`, `<name>.build.json` (the TypeSOL, TypeScript, clang and platform-tools versions, the host, the SBPF version, each source's sha256 and the binary's). With platform-tools other than the tested ones it warns once; `--toolchain-strict` (or `TYPESOL_TOOLCHAIN=strict`) refuses them. The first build creates `<out>/deploy/<name>-keypair.json` and records the address in `typesol.json`; later builds refuse a different keypair. Without the keypair (a fresh clone, CI) it builds at the recorded address and says so; only `deploy` needs the keypair. |
|
|
807
|
-
| `typesol build <file.ts> [--out <dir>] [--program-id <keypair.json>] [--sbpf …] [--profile] [--toolchain-strict] [--quiet]` | Outside a project (or a file that is not one of its programs): build that file. Its keypair is `--program-id`, which must exist, or `<out>/<name>-keypair.json`, created on the first build. A project program's `.ts` builds as that program. |
|
|
805
|
+
| `typesol doctor [--url <rpc>] [--config <cli config>]` | Check what building, testing and deploying need: Node.js, the platform-tools (and a `toolchain` row: the tested ones, or untested with both versions), the Solana CLI, Docker (optional: only `--docker` builds need it; it says when they run emulated), its keypair, the RPC (`--url`, a cluster moniker, or the CLI config) and the keypair's balance there, and the project. Each problem is printed with the command that fixes it. Exit code 1 when building is impossible (Node.js or the platform-tools missing); deploy pieces are warnings. |
|
|
806
|
+
| `typesol build [<program>…] [--sbpf v0\|v1\|v2] [--profile] [--toolchain-strict] [--docker [--typesol-version <v>] [--release-record <file>]] [--quiet]` | In a project: build every program (or those named) into `<out>/<name>/`: `<name>.so`, `<name>.json` (Anchor IDL), `<name>.client.ts` (TypeScript client, see [client.md](client.md)), `<name>.c`, `<name>.build.json` (the TypeSOL, TypeScript, clang and platform-tools versions, the host, the SBPF version, each source's sha256 and the binary's). With platform-tools other than the tested ones it warns once; `--toolchain-strict` (or `TYPESOL_TOOLCHAIN=strict`) refuses them. The first build creates `<out>/deploy/<name>-keypair.json` and records the address in `typesol.json`; later builds refuse a different keypair. Without the keypair (a fresh clone, CI) it builds at the recorded address and says so; only `deploy` needs the keypair. `--docker` builds in the pinned container instead ([below](#build---docker-and-verify---docker)). |
|
|
807
|
+
| `typesol build <file.ts> [--out <dir>] [--program-id <keypair.json>] [--sbpf …] [--profile] [--toolchain-strict] [--docker …] [--quiet]` | Outside a project (or a file that is not one of its programs): build that file. Its keypair is `--program-id`, which must exist, or `<out>/<name>-keypair.json`, created on the first build. A project program's `.ts` builds as that program. |
|
|
808
808
|
| `typesol check [<program>… \| <file.ts>] [--json] [--stdin \| --files]` | Type-check and validate without building. In a project, no argument checks every program (or those named) and exits 1 if any has errors. `--json` prints `{ ok, diagnostics: [{ file, line, column, message }] }`, always (a missing file or unreadable `--files` input is a diagnostic too, exit 1 or 2); `--stdin` checks the text given on stdin as that file (its imports come from disk); `--files` reads `{ "files": { "<absolute path>": "<text>", … } }` from stdin and checks with those texts instead of the disk (an editor's unsaved buffers). |
|
|
809
809
|
| `typesol clone [<address>…] [--url <rpc>] [--config <cli config>] [--out <dir>]` | Copy cluster accounts and programs for the tests (Anchor's `[test.validator.clone]`): each account to `<address>.json` (lamports, owner, data), each program to `<address>.so` (its ELF, from the ProgramData account for upgradeable programs), in `tests/accounts` (`"accounts"` in `typesol.json`) or `--out`. Without addresses it clones the project's `"clone"` list. `testProgram` loads that directory into its LiteSVM; commit it so the tests run offline. |
|
|
810
810
|
| `typesol emit-c <file.ts> [--out <file.c>] [--profile]` | Print or write the generated C. |
|
|
@@ -814,7 +814,7 @@ error. Exit codes: **0** success, **1** failure (compile errors, failed deploy,
|
|
|
814
814
|
| `typesol cpi <idl.json> [--out <file.ts>] [--prefix <name>] [--address <base58>]` | Generate TypeSOL helpers that call another program from its IDL. Unsupported instructions are listed on stderr. |
|
|
815
815
|
| `typesol port <idl.json> [--out <file.ts>]` | A TypeSOL program skeleton from an Anchor IDL (0.30+/1.x), to port an Anchor program: account structs, enums, errors, events and one function per instruction with its accounts and arguments, each body `require(false, …NotPorted)` until written. Instruction discriminators (an explicit `@discriminator` when the name derives another), account names and error codes are kept, so existing clients keep working where the layouts match; notes on stderr list where they do not (Borsh `String`/`Option` in account data, a `Vec` that is not the last field). Error codes that skip ahead are kept with `@code`, and zero-copy types keep their IDL `repr`, `serialization` and field names (`@repr`, `@serialization`, `@idlName`). |
|
|
816
816
|
| `typesol client <idl.json> [--out <file.ts>] [--address <base58>]`, `typesol client --address <program id> [--url <rpc>] [--config <cli config>] [--out <file.ts>]` | Generate a typed TypeScript client on `@solana/kit` from an Anchor IDL (0.30+/1.x or TypeSOL); the IDL is validated first, and what the client leaves out is printed as notes. Without a file, the IDL is read from the chain: the canonical Program Metadata IDL, else Anchor's IDL account. See [client.md](client.md). |
|
|
817
|
-
| `typesol verify <program\|file.ts> [<deployed.so>] [--address <program id>] [--url <rpc>] [--config <cli config>] [--sbpf …] [--manifest <name.build.json>]` | Rebuild and compare with what is deployed. Without a `.so`, reads the program from the cluster (`--url`, cluster monikers such as `mainnet-beta` included, else the Solana CLI config) at `--address` or the address `typesol.json` records, under any loader (v2, upgradeable v3, v4); prints the upgrade authority (or that the program is immutable) and the last deploy slot, and compares the IDL published with `typesol idl publish` (a published IDL that differs is a mismatch). With a `.so` (e.g. `solana program dump`), compares with that file. Trailing zero padding is ignored; the SBPF version is read from the deployed ELF unless `--sbpf` is given. On a mismatch it prints the rebuild's toolchain (clang, platform-tools, host, TypeSOL) and the deployed build's when a build manifest's binary hash is the deployed bytes' (`--manifest`, `<deployed>.build.json` next to a given `.so`, or the local build's), and what differs; otherwise it says the deployed side's toolchain is unknown (a program on chain records none). |
|
|
817
|
+
| `typesol verify <program\|file.ts> [<deployed.so>] [--address <program id>] [--url <rpc>] [--config <cli config>] [--sbpf …] [--manifest <name.build.json>] [--docker …]` | Rebuild and compare with what is deployed. Without a `.so`, reads the program from the cluster (`--url`, cluster monikers such as `mainnet-beta` included, else the Solana CLI config) at `--address` or the address `typesol.json` records, under any loader (v2, upgradeable v3, v4); prints the upgrade authority (or that the program is immutable) and the last deploy slot, and compares the IDL published with `typesol idl publish` (a published IDL that differs is a mismatch). With a `.so` (e.g. `solana program dump`), compares with that file. Trailing zero padding is ignored; the SBPF version is read from the deployed ELF unless `--sbpf` is given. On a mismatch it prints the rebuild's toolchain (clang, platform-tools, host, TypeSOL) and the deployed build's when a build manifest's binary hash is the deployed bytes' (`--manifest`, `<deployed>.build.json` next to a given `.so`, or the local build's), and what differs; otherwise it says the deployed side's toolchain is unknown (a program on chain records none). A host difference alone is named as such; it counts only between builds of 0.44.1 or earlier, whose programs with 128-bit or signed division linked platform-tools' compiler-builtins (laid out differently by each host package). `--docker` rebuilds in the pinned container and, on a match, prints what was verified ([below](#build---docker-and-verify---docker)). |
|
|
818
818
|
| `typesol profile <logs.txt\|-> [--program <id>]` | Compute units per TypeScript line from the logs of a `--profile` build's transaction (exit 1 when the logs have no markers). |
|
|
819
819
|
| `typesol help <command>` | Same as `typesol <command> --help`. |
|
|
820
820
|
| `typesol --version` | Print the version. |
|
|
@@ -827,6 +827,33 @@ Builds (`build`, `deploy`, `verify`, `typesol/testing`) compare the active clang
|
|
|
827
827
|
with (`TESTED_TOOLCHAIN` in `typesol/compiler`: Agave 3.1.10, platform-tools v1.52): another one gets one warning per
|
|
828
828
|
process on stderr. `TYPESOL_TOOLCHAIN=strict` makes it an error everywhere, `warn` is the default.
|
|
829
829
|
|
|
830
|
+
## build --docker and verify --docker
|
|
831
|
+
|
|
832
|
+
`--docker` builds in a container made on your machine from `docker/Dockerfile` (shipped in the package): linux/amd64
|
|
833
|
+
on every machine (emulated on arm64), Node 24, the platform-tools v1.52 of Agave 3.1.10, and a TypeSOL version from
|
|
834
|
+
npm whose tarball is checked against `releases/<version>.json` (sha512 integrity, sha1 shasum, every file's sha256)
|
|
835
|
+
before it is installed, with its npm dependencies installed by `npm ci` from `docker/deps/<version>.lock.json` (every
|
|
836
|
+
package checked against the lock's integrity; the package's lock, or the version's own tarball's). Every input is
|
|
837
|
+
pinned by digest, checksum or integrity. The image is `typesol-build:<version>-<first 12
|
|
838
|
+
of the Dockerfile's sha256>`, built the first time it is needed (progress on stderr; about 750 MB of downloads) and
|
|
839
|
+
reused after. Builds run with `--network none`, the sources read-only (the project root, or a single file's
|
|
840
|
+
directory: imports from outside it are not there), the output directory writable, no capabilities, a read-only root
|
|
841
|
+
file system, as your uid and gid (root for a root caller, still without capabilities). The written files are the
|
|
842
|
+
ones `build` writes; `<name>.build.json` adds `container` (platform, Dockerfile sha256, base images, downloads, the
|
|
843
|
+
TypeSOL tarball's hashes and the commit its record names, where the release record came from and the record's sha256,
|
|
844
|
+
the dependency lock with its sha256, the local image id). An image is reused only when its labels carry this
|
|
845
|
+
record's integrity, shasum, commit and file list and this lock's sha256; an image of the same tag made from other
|
|
846
|
+
values is an error that names it (remove it to build from this record).
|
|
847
|
+
|
|
848
|
+
| Option | |
|
|
849
|
+
| --- | --- |
|
|
850
|
+
| `--typesol-version <v>` | The TypeSOL in the container. Default: this `typesol`'s version (in a project that installs another `typesol` than the one running, an error naming both); for `verify`, the version of the deployed build's manifest when one is known (`--manifest`, `<deployed>.build.json`, or the local build's whose binary hash is the deployed one's). |
|
|
851
|
+
| `--release-record <file>` | The record to check that version's tarball against. Default: the package's (a package ships the records of the releases before it: a record is written after its release is published), else `releases/<version>.json` fetched from the repository's main branch over HTTPS (said on stderr; where it came from and the sha256 of its bytes go into `container.typesol.record`), so that the npm tarball is checked against a second, independent source (as with a file given here; a record the package ships came from npm too). Offline, or for a version the repository has no record of, an error names this option. Versions before 0.43.0 have no record and are refused. |
|
|
852
|
+
|
|
853
|
+
Without Docker, with its daemon stopped or when the image build fails, `--docker` is an error and nothing is built;
|
|
854
|
+
it never falls back to the local toolchain. `TYPESOL_DOCKER_CPUS` and `TYPESOL_DOCKER_MEMORY` (e.g. `2`, `4g`) limit
|
|
855
|
+
the build container on a shared machine. Why one platform: [stability.md](stability.md#what-builds-the-same-bytes-where).
|
|
856
|
+
|
|
830
857
|
## typesol.json
|
|
831
858
|
|
|
832
859
|
```json
|
|
@@ -1154,6 +1181,52 @@ version are used. Then the toolchain: verify prints the rebuild's clang and plat
|
|
|
1154
1181
|
when a `<name>.build.json` describes the deployed bytes (`--manifest <file>`, one next to a given `.so`, or the local
|
|
1155
1182
|
build's). A program on chain carries no such record, so keep the build manifest of every deployment.
|
|
1156
1183
|
|
|
1184
|
+
**`--docker needs Docker: docker is not installed` / `the Docker daemon is not running`** — `build --docker` and
|
|
1185
|
+
`verify --docker` run in a container: install Docker, or start Docker Desktop (or `sudo systemctl start docker`).
|
|
1186
|
+
`typesol doctor` has a `docker` row. Nothing is built without it; drop `--docker` to build with your own platform-tools.
|
|
1187
|
+
|
|
1188
|
+
**`docker build of typesol-build:… failed`** — the first `--docker` build makes the image, which needs the network:
|
|
1189
|
+
the base images from Docker Hub, the Agave and platform-tools release files from GitHub, the TypeSOL tarball from npm.
|
|
1190
|
+
A `checksum` error means a downloaded file is not the one the Dockerfile pins (retry; if it persists, report it).
|
|
1191
|
+
`typesol tarball check: integrity …` means the tarball npm served is not the one `releases/<version>.json` records:
|
|
1192
|
+
do not use that version until it is explained. `typesol dependency lock: …` means the lock does not describe the
|
|
1193
|
+
package's dependencies or names a package without a registry integrity; an `EINTEGRITY` error from `npm ci` means a
|
|
1194
|
+
downloaded dependency is not the one the lock records: the same.
|
|
1195
|
+
|
|
1196
|
+
**`the local image typesol-build:… was not built from this release record and dependency lock`** — an image of that
|
|
1197
|
+
tag exists, made from a record or lock with other values (it names them). Two records of one version disagree, so
|
|
1198
|
+
find out which is right before going on; to build from the one given now, `docker image rm` the tag and run again.
|
|
1199
|
+
|
|
1200
|
+
**`no dependency lock for TypeSOL <version>`** — neither this package nor that version's tarball has
|
|
1201
|
+
`docker/deps/<version>.lock.json`: use a later `@typesol/cli`, which ships the locks of the versions before it. On arm64 machines the image is linux/amd64 and runs emulated: Docker
|
|
1202
|
+
Desktop provides the x86_64 emulation (QEMU or Rosetta); other Docker installs may need `binfmt` for amd64.
|
|
1203
|
+
|
|
1204
|
+
**`no release record for TypeSOL <version>`** / **`could not fetch the release record`** — the container installs only
|
|
1205
|
+
versions whose tarball has a record: the package's own, or `releases/<version>.json` on the repository's main branch,
|
|
1206
|
+
which `--docker` fetches for a release newer than the package. Offline (or behind a proxy that blocks
|
|
1207
|
+
raw.githubusercontent.com), pass the record yourself with `--release-record releases/<version>.json` from a checkout,
|
|
1208
|
+
or choose a version the package records with `--typesol-version`. HTTP 404 means the repository has no record for that
|
|
1209
|
+
version: check that it is a released version. 0.42.0 and earlier have no record.
|
|
1210
|
+
|
|
1211
|
+
**`this project installs typesol X …, but this is typesol Y`** — a `typesol` other than the project's ran `--docker`.
|
|
1212
|
+
Run the project's own (`npx --no-install typesol …`), or say which version to use with `--typesol-version`.
|
|
1213
|
+
|
|
1214
|
+
**`the container build failed … the container sees only <dir>`** — the compiler's error is printed above it. The
|
|
1215
|
+
container mounts only the project root (or a single file's directory): an import from outside it is missing there.
|
|
1216
|
+
|
|
1217
|
+
**`verify` says `differs host`** — the same TypeSOL (0.44.1 or earlier) and toolchain built the two sides on
|
|
1218
|
+
different hosts. That may be the cause if the program has 128-bit or signed division: those versions linked
|
|
1219
|
+
platform-tools' compiler-builtins, which each host package lays out differently. Rebuild on the deployed side's kind
|
|
1220
|
+
of host (or with `--docker`, if the deployed build was one). From 0.45.0 on the host is not a difference between
|
|
1221
|
+
macOS arm64, Linux arm64 and Linux x86_64 (the hosts measured); `differs host (not measured)` means one side was
|
|
1222
|
+
built on another host.
|
|
1223
|
+
|
|
1224
|
+
**A 0.44.x program with division, deployed from macOS or Linux arm64, does not match `verify --docker`** — 0.44.0 and
|
|
1225
|
+
0.44.1 linked platform-tools' compiler-builtins, so a program that calls 128-bit or signed division built to other
|
|
1226
|
+
bytes on each host package; the container is linux/amd64 and gives the Linux x86_64 bytes. What verifies it is a
|
|
1227
|
+
0.44.x install (the version in its `.build.json`) on the same kind of host as the one that built it, without
|
|
1228
|
+
`--docker`: `npx @typesol/cli@0.44.1 verify …` on macOS arm64 for a build made there.
|
|
1229
|
+
|
|
1157
1230
|
**Windows** — not tested; use WSL2 with the Linux Agave CLI.
|
|
1158
1231
|
|
|
1159
1232
|
**Node errors such as `ERR_UNKNOWN_FILE_EXTENSION` or `ERR_REQUIRE_ESM`** — use Node.js 22.12 or newer.
|
|
@@ -1204,11 +1277,17 @@ You need Node.js 22.12 or later and the Agave CLI with platform-tools (see the R
|
|
|
1204
1277
|
|
|
1205
1278
|
**The toolchain you deploy with.** The binary is what the platform-tools' clang makes of the generated C, so the
|
|
1206
1279
|
toolchain is part of what you trust. Deploy with the one TypeSOL is tested with (Agave 3.1.10, platform-tools v1.52;
|
|
1207
|
-
`typesol doctor` says whether yours is, and `typesol deploy --toolchain-strict` refuses another).
|
|
1280
|
+
`typesol doctor` says whether yours is, and `typesol deploy --toolchain-strict` refuses another). The host does not
|
|
1281
|
+
matter from 0.45.0 on: with the same TypeSOL and toolchain a program builds to the same bytes on macOS arm64, Linux
|
|
1282
|
+
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
|
|
1283
|
+
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
|
|
1284
|
+
it with `--docker` (step 2) all the same: a pinned linux/amd64 container that anyone can rebuild, so the whole
|
|
1285
|
+
environment is one recipe. Keep
|
|
1208
1286
|
`target/my_app/my_app.build.json` with each deployment, next to the commit you deployed: it records the TypeSOL,
|
|
1209
|
-
TypeScript, clang and platform-tools versions
|
|
1210
|
-
only when it rebuilds with the same TypeSOL version and toolchain
|
|
1211
|
-
|
|
1287
|
+
TypeScript, clang and platform-tools versions, the host, the container when there was one, and the deployed bytes'
|
|
1288
|
+
sha256. Step 6's `verify` matches only when it rebuilds with the same TypeSOL version and toolchain (and, for a program
|
|
1289
|
+
with 128-bit or signed division built with 0.44.1 or earlier, the same kind of host), and on a mismatch `--manifest`
|
|
1290
|
+
with that file shows what differs.
|
|
1212
1291
|
|
|
1213
1292
|
## 1. Create and test
|
|
1214
1293
|
|
|
@@ -1235,6 +1314,54 @@ program's address, and records the address in `typesol.json`.
|
|
|
1235
1314
|
**Back up `target/deploy/my_app-keypair.json` now.** It is not committed (`.gitignore`), and without it you cannot
|
|
1236
1315
|
redeploy to that address.
|
|
1237
1316
|
|
|
1317
|
+
### A build others can verify
|
|
1318
|
+
|
|
1319
|
+
```sh
|
|
1320
|
+
npx --no-install typesol build --docker
|
|
1321
|
+
```
|
|
1322
|
+
|
|
1323
|
+
The same files, built inside a container instead of with your platform-tools. The container is made on your machine
|
|
1324
|
+
from `docker/Dockerfile`, which ships in the package; every input is pinned: the Node and busybox base images by their
|
|
1325
|
+
linux/amd64 digests, the Agave 3.1.10 and platform-tools v1.52 release files by sha256, the TypeSOL package (the
|
|
1326
|
+
version your project uses) by its release record, `releases/<version>.json`: the npm tarball's sha512 integrity and
|
|
1327
|
+
sha1 shasum and every file's sha256, checked before it is installed, and its npm dependencies (TypeScript, the
|
|
1328
|
+
compiler's front end, among them) by that version's lock, `docker/deps/<version>.lock.json`, which `npm ci` installs
|
|
1329
|
+
checking every package's integrity, with no install scripts. The lock of a version ships in the package of that
|
|
1330
|
+
version (and in later ones); the locks of 0.43.0, 0.44.0 and 0.44.1, released before locks existed, were resolved
|
|
1331
|
+
from the npm registry on 2026-11-12, so their integrity values are what the registry served then, not what an image
|
|
1332
|
+
built at their release installed. The first `--docker` build of a TypeSOL version
|
|
1333
|
+
builds the image (about 750 MB of downloads, a few minutes; Docker must be running, `typesol doctor` shows it); later
|
|
1334
|
+
ones take seconds. The build runs with no network, the project mounted read-only, the output directory writable,
|
|
1335
|
+
with no capabilities, as your uid and gid (root for a root caller). `my_app.build.json` then records the container:
|
|
1336
|
+
the platform, the Dockerfile's sha256, the pinned base images and downloads, the TypeSOL tarball's hashes, the commit
|
|
1337
|
+
its release record names, where the record came from (with the record's sha256), the dependency lock and its sha256,
|
|
1338
|
+
and the local image id.
|
|
1339
|
+
|
|
1340
|
+
Deploy that `my_app.so` with the Solana CLI, `solana program deploy target/my_app/my_app.so --program-id
|
|
1341
|
+
target/deploy/my_app-keypair.json --use-rpc` (with your `--url`). What replaces the container build: `typesol deploy`
|
|
1342
|
+
(`--dry-run` included) and `typesol build` without `--docker`, which build again with your local platform-tools and
|
|
1343
|
+
overwrite it; and `npm test` once the program's sources, SBPF version or address changed, which rebuilds it locally
|
|
1344
|
+
and says so (`note: … held a --docker build that is out of date`). What does not: `npm test` while the sources are
|
|
1345
|
+
the ones `my_app.build.json` records and the `.so` is the one it records, on any host: the tests then run the
|
|
1346
|
+
container's binary. After a local build, `typesol build --docker` again before deploying. Commit the source, keep
|
|
1347
|
+
`my_app.build.json`, and publish the commit and that file with the program id.
|
|
1348
|
+
|
|
1349
|
+
The TypeSOL inside the container is the version this `typesol` is, the one your project installs (`npx --no-install
|
|
1350
|
+
typesol`); a global `typesol` of another version than the project's `node_modules/typesol` refuses rather than
|
|
1351
|
+
guess. `--typesol-version <v>` picks another. Only versions with a release record can be installed (0.43.0 and later).
|
|
1352
|
+
A package carries the records of the releases before it, because a release's record is written after it is
|
|
1353
|
+
published; for a release the package does not record (the newest one, or a later one asked for), `--docker` fetches
|
|
1354
|
+
`releases/<version>.json` from the repository's main branch
|
|
1355
|
+
(`https://raw.githubusercontent.com/typesol-lang/typesol/main/releases/<version>.json`, unauthenticated HTTPS), prints
|
|
1356
|
+
where it came from and its sha256, and records both in `my_app.build.json` (`container.typesol.record`). The check is
|
|
1357
|
+
then two independent sources agreeing: the tarball npm serves must be the one the repository's record describes, so a
|
|
1358
|
+
tampered package would have to be matched by a tampered repository. That holds for a fetched record and for a
|
|
1359
|
+
`--release-record` file; for a version whose record ships in the running package, the record came from npm too (in
|
|
1360
|
+
an earlier package), so the check is then against what npm served before. Offline, or when the repository has no
|
|
1361
|
+
record for that version, it is an error that names `--release-record <file>`, which passes the record yourself (from
|
|
1362
|
+
a checkout, `releases/<version>.json`). Between `npm publish` and the commit of the release's record the repository
|
|
1363
|
+
answers HTTP 404: `--release-record` is the way then.
|
|
1364
|
+
|
|
1238
1365
|
## 3. A wallet with SOL
|
|
1239
1366
|
|
|
1240
1367
|
```sh
|
|
@@ -1288,8 +1415,34 @@ npx --no-install typesol verify my_app
|
|
|
1288
1415
|
|
|
1289
1416
|
`verify` rebuilds the program from `programs/my_app.ts`, reads the deployed one at the address in `typesol.json` from
|
|
1290
1417
|
the cluster in your Solana CLI config, and compares the bytes. `match` means anyone with your source and the same
|
|
1291
|
-
TypeSOL version and toolchain gets exactly the program on chain.
|
|
1292
|
-
|
|
1418
|
+
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, Linux x86_64; with 0.44.1 or earlier, a
|
|
1419
|
+
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.
|
|
1420
|
+
|
|
1421
|
+
### Verifying someone else's program
|
|
1422
|
+
|
|
1423
|
+
With the source at the deployed commit, the program id and, ideally, the deployer's `<name>.build.json`:
|
|
1424
|
+
|
|
1425
|
+
```sh
|
|
1426
|
+
git clone <repository> && cd <repository> && git checkout <commit>
|
|
1427
|
+
npx --no-install typesol verify my_app --address <program id> --url mainnet-beta --docker --manifest my_app.build.json
|
|
1428
|
+
```
|
|
1429
|
+
|
|
1430
|
+
`--docker` rebuilds in the same container recipe, built on your machine from the Dockerfile and checked inputs. The
|
|
1431
|
+
TypeSOL version is the deployed build's (from the manifest whose binary hash is the deployed bytes'), or
|
|
1432
|
+
`--typesol-version <v>`; months later, the current `@typesol/cli` installs the old version in the container, checked
|
|
1433
|
+
against its release record. On a match it prints what was verified: the program, the source directory and its git
|
|
1434
|
+
commit (and whether it has uncommitted changes), the TypeSOL version and tarball, the commit its record names and
|
|
1435
|
+
where the record came from, the dependency lock and its sha256, the clang and platform-tools, the container's
|
|
1436
|
+
Dockerfile sha256, base images and downloads, and the command that repeats it (with every option given that changes
|
|
1437
|
+
the result: `--address`, `--url`, `--config`, `--sbpf`, `--manifest`, `--release-record`). A program built with
|
|
1438
|
+
0.44.x on macOS or Linux arm64 that calls 128-bit or signed division does not match a `--docker` rebuild (those
|
|
1439
|
+
versions' binaries depended on the host package; [troubleshooting](troubleshooting.md)). On a mismatch it shows the
|
|
1440
|
+
toolchain of each side that is known, as without `--docker`. Exit codes: 0 match, 3 mismatch.
|
|
1441
|
+
|
|
1442
|
+
What this is not: the container is built locally from pinned inputs, not pulled from a published image, so the first
|
|
1443
|
+
verification downloads the inputs and builds it. Its local image id can differ between machines; the Dockerfile's
|
|
1444
|
+
sha256 and the pinned inputs are what to compare. The result is not registered with an external verified-build
|
|
1445
|
+
registry: the evidence is the command and its output, which anyone can rerun.
|
|
1293
1446
|
|
|
1294
1447
|
## 7. Call it
|
|
1295
1448
|
|
|
@@ -1319,7 +1472,7 @@ auditors, [SECURITY.md](../SECURITY.md) how to report a problem.
|
|
|
1319
1472
|
| --- | --- |
|
|
1320
1473
|
| The program's author | the program's logic: what it allows, to whom, for how much |
|
|
1321
1474
|
| TypeSOL (this repository) | that the binary does what the source and these guarantees say, and nothing an attacker can steer beyond it |
|
|
1322
|
-
| 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 |
|
|
1475
|
+
| 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) |
|
|
1323
1476
|
| The Solana runtime | account ownership and signer flags as passed, the loader's account serialization, CPI privilege rules, sysvars |
|
|
1324
1477
|
|
|
1325
1478
|
Everything a transaction carries is attacker-controlled: the instruction data, which accounts are passed in which
|
|
@@ -1564,9 +1717,12 @@ From 1.0 on, within a major version:
|
|
|
1564
1717
|
|
|
1565
1718
|
- **Sources keep compiling.** A program that compiles with 1.x compiles with every later 1.y, to a program with the same
|
|
1566
1719
|
account layouts, IDL, instruction and account discriminators and error codes. New releases add; they do not take away.
|
|
1567
|
-
- **Binaries are reproducible and only change for a reason.** With the same TypeSOL release and the
|
|
1568
|
-
|
|
1569
|
-
|
|
1720
|
+
- **Binaries are reproducible and only change for a reason.** With the same TypeSOL release and the tested
|
|
1721
|
+
toolchain, a source builds to the same bytes in the build container (`--docker`) as on the hosts measured: from
|
|
1722
|
+
0.45.0 on, macOS arm64, Linux arm64 and Linux x86_64, for the programs and SBPF versions listed
|
|
1723
|
+
[below](#what-builds-the-same-bytes-where).
|
|
1724
|
+
A release that changes the binary of a program that uses none of its new features says so, with the release
|
|
1725
|
+
manifest's diff (`typesol-<version>-binary-diff.txt`) as the evidence.
|
|
1570
1726
|
- **The checks stay.** No check a program gets from its parameter types (owner, discriminator, signer, writability,
|
|
1571
1727
|
aliasing, checked arithmetic, constraints) is removed or weakened.
|
|
1572
1728
|
- **The tools keep their interfaces**: `typesol build`, `test` (via `typesol/testing`), `check --json`, `deploy`,
|
|
@@ -1599,10 +1755,66 @@ Meant to stay as they are; a change before 1.0 would be a breaking change listed
|
|
|
1599
1755
|
- **A build says what made it.** `<name>.build.json` records the TypeSOL, TypeScript, clang and platform-tools versions,
|
|
1600
1756
|
the host, the SBPF version and the sha256 of every source and of the binary. `typesol verify` uses it to say, on a
|
|
1601
1757
|
mismatch, whether the toolchains differ. A program on chain records none of this: keep the file with the deployment.
|
|
1758
|
+
- **A deployed program anyone can rebuild.** `typesol build --docker` builds in a container made from
|
|
1759
|
+
`docker/Dockerfile` (in the package), whose inputs are all pinned: base images by digest, the Agave and
|
|
1760
|
+
platform-tools release files by sha256, the TypeSOL tarball by its `releases/<version>.json`. `typesol verify
|
|
1761
|
+
--docker` rebuilds there and says what it verified. The image is built locally from those inputs; no image is
|
|
1762
|
+
published, and the result is not registered with any external verified-build registry
|
|
1763
|
+
([docs/mainnet.md](mainnet.md#6-verify)).
|
|
1602
1764
|
- **Fixes come as patches of the latest minor.** From 0.44.0 on, a release that only fixes soundness or security
|
|
1603
1765
|
defects is a patch (0.44.1, …) with no new language surface, and its notes carry the binary diff against the
|
|
1604
1766
|
previous release ([SECURITY.md](../SECURITY.md#fix-releases)). Older minors are not maintained.
|
|
1605
1767
|
|
|
1768
|
+
## What builds the same bytes where
|
|
1769
|
+
|
|
1770
|
+
From 0.45.0 on, the programs measured build to the same bytes on each host measured. Measured with this release's
|
|
1771
|
+
compiler and platform-tools v1.52 on macOS arm64 (the platform-tools `osx-aarch64` package, native), Linux arm64 and
|
|
1772
|
+
Linux x86_64 (the `linux-aarch64` and `linux-x86_64` packages, in containers; x86_64 is the `--docker` image): for
|
|
1773
|
+
SBPF v0 (the default), the 76 programs of the sources (`scripts/release-manifest.ts`, every program under `examples/`
|
|
1774
|
+
and `showcase/`); for SBPF v1 and v2, the 14 programs of `test/golden/binaries.json` (counter, vault, escrow, multisig
|
|
1775
|
+
and the 10 below).
|
|
1776
|
+
|
|
1777
|
+
| What | Same on the three hosts? |
|
|
1778
|
+
| --- | --- |
|
|
1779
|
+
| The generated C and the IDL (all 76) | yes |
|
|
1780
|
+
| The binary, SBPF v0 (all 76) | yes |
|
|
1781
|
+
| The binary, SBPF v1 and v2 (the 14) | yes |
|
|
1782
|
+
| 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 |
|
|
1783
|
+
| 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 |
|
|
1784
|
+
|
|
1785
|
+
The 10 are the programs that call 128-bit or signed 64-bit division (the Phoenix, Marginfi, Raydium AMM, CLMM and
|
|
1786
|
+
CP-Swap, Jito priority-fee and Stake Pool ports, transfer-fee, token-fundraiser, token-swap). With 0.44.1 each of them
|
|
1787
|
+
built to three different binaries on the three hosts (token-fundraiser: the two Linux ones agreed). The cause was one
|
|
1788
|
+
library: platform-tools' SBF `compiler-builtins` Rust library (`libcompiler_builtins-<hash>.rlib`, a different file in
|
|
1789
|
+
each host package). Its functions have the same instructions in the three packages (compared function by function for
|
|
1790
|
+
SBPF v0, v1 and v2), but each package splits them into differently numbered archive members, so the linker placed the
|
|
1791
|
+
ones a division pulls in (`__udivti3`, its shared `u128_div_rem`, `__ashlti3`, `__lshrti3`, …) in another order, and
|
|
1792
|
+
the program's calls into them had other offsets. Programs that called at most `__multi3` linked one member and agreed.
|
|
1793
|
+
|
|
1794
|
+
TypeSOL now links none of that library: `runtime/typesol_builtins.c` defines every builtin the tested clang calls for
|
|
1795
|
+
C integer code on SBF (`__multi3`, `__udivti3`, `__umodti3`, `__divti3`, `__modti3`, `__ashlti3`, `__lshrti3`, `__ashrti3`, `__divdi3`,
|
|
1796
|
+
`__moddi3`) and is compiled with each program, by the same clang, and linked after it. Multiplication and shifts are
|
|
1797
|
+
the instructions compiler-builtins has for them, so on SBPF v0 programs that use only those keep their bytes;
|
|
1798
|
+
division is new C that costs no more compute units than compiler-builtins' on any input measured, and fewer on most
|
|
1799
|
+
(`test/language/builtins.test.ts`). On SBPF v1, `__multi3` (128-bit multiplication, which checked 64-bit
|
|
1800
|
+
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),
|
|
1801
|
+
so a v1 program that
|
|
1802
|
+
multiplies that way builds to other bytes than with 0.44.1 (every one of the 14 measured does); SBPF v2 multiplies
|
|
1803
|
+
with its own instructions and calls no `__multi3`, and its signed 64-bit division is an instruction too, which is
|
|
1804
|
+
why token-fundraiser keeps its v2 bytes.
|
|
1805
|
+
libc's `memcpy` and `memset` still come from platform-tools; the programs that link them build the same on the three
|
|
1806
|
+
hosts. Nothing in the emitted C, the paths or the build directory reaches the binary.
|
|
1807
|
+
|
|
1808
|
+
The reference environment stays one platform, so that the whole environment is one recipe: the build container is
|
|
1809
|
+
`linux/amd64` on every machine (emulated on arm64 hosts). CI checks on every change that a Linux x86_64 runner with
|
|
1810
|
+
independently installed platform-tools builds the programs of `test/golden/binaries.json` (the 14 for SBPF v0, and
|
|
1811
|
+
counter, escrow, Phoenix and Marginfi for v1 and v2) to the container's bytes; that is the same host package as the
|
|
1812
|
+
container's, installed separately. The macOS workflow (on demand) runs the same check on macOS arm64, and anyone can
|
|
1813
|
+
run it on another host, binary included. `<name>.build.json` records the host; `typesol verify` counts a host
|
|
1814
|
+
difference between builds made before 0.45.0 (which linked compiler-builtins: a possible cause if the program uses
|
|
1815
|
+
128-bit or signed division), and between later builds only when one of the hosts is not among the three measured
|
|
1816
|
+
(`host (not measured)`).
|
|
1817
|
+
|
|
1606
1818
|
## Experimental
|
|
1607
1819
|
|
|
1608
1820
|
Useful today, but may still change before 1.0 (each change listed in the CHANGELOG):
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typesol/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.0",
|
|
4
4
|
"description": "Compile a TypeScript-syntax language directly to Solana SBF programs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -58,6 +58,8 @@
|
|
|
58
58
|
"CHANGELOG.md",
|
|
59
59
|
"SECURITY.md",
|
|
60
60
|
"docs",
|
|
61
|
+
"docker",
|
|
62
|
+
"releases",
|
|
61
63
|
"llms.txt",
|
|
62
64
|
"llms-full.txt"
|
|
63
65
|
],
|