@typesol/cli 0.44.0 → 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 +166 -0
- package/NOTICE +14 -1
- package/README.md +52 -10
- package/SECURITY.md +1 -1
- package/dist/cli.js +194 -48
- package/dist/compiler/emit/alias.d.ts +16 -2
- package/dist/compiler/emit/alias.js +62 -4
- package/dist/compiler/emit/calls.js +15 -7
- package/dist/compiler/emit/cpi-core.d.ts +6 -0
- package/dist/compiler/emit/cpi-core.js +18 -5
- package/dist/compiler/emit/create.js +19 -11
- package/dist/compiler/emit/function.js +5 -5
- package/dist/compiler/emit/metaplex.js +17 -4
- package/dist/compiler/emit/token.js +64 -39
- 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 +13 -5
- package/docs/audit.md +54 -7
- package/docs/cli.md +31 -4
- package/docs/errors.md +1 -1
- package/docs/language.md +6 -4
- package/docs/mainnet.md +86 -6
- package/docs/security-model.md +47 -12
- package/docs/stability.md +62 -3
- package/docs/testing.md +49 -2
- package/docs/troubleshooting.md +46 -0
- package/llms-full.txt +283 -34
- 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/runtime/typesol_rt.h +8 -5
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# The pinned build environment of `typesol build --docker` and `typesol verify --docker` (docs/mainnet.md).
|
|
2
|
+
#
|
|
3
|
+
# Every input is pinned: the base images by digest, the Agave and platform-tools release files by sha256 (BuildKit
|
|
4
|
+
# refuses a download whose checksum differs), the TypeSOL package by its release record (releases/<version>.json,
|
|
5
|
+
# copied into the build context as release.json): the npm tarball's sha512 integrity and sha1 shasum, and every file's
|
|
6
|
+
# sha256; and its npm dependencies by their lock (docker/deps/<version>.lock.json, copied as deps.lock.json, or an empty
|
|
7
|
+
# deps.lock.json to take the one in the version's own tarball), which `npm ci` installs with every package's integrity
|
|
8
|
+
# checked. Anyone can build the same environment from this file (from the package's or the repository's root):
|
|
9
|
+
#
|
|
10
|
+
# mkdir ctx && cp docker/Dockerfile ctx/ && cp releases/0.44.1.json ctx/release.json && cp docker/deps/0.44.1.lock.json ctx/deps.lock.json
|
|
11
|
+
# docker build --platform linux/amd64 --build-arg TYPESOL_VERSION=0.44.1 -t typesol-build:0.44.1 ctx
|
|
12
|
+
#
|
|
13
|
+
# The image is not published anywhere: it is built locally from these inputs. Its image id can differ between machines
|
|
14
|
+
# (BuildKit and Docker versions, layer dates), so a build records this file's sha256 and the pinned inputs, which do
|
|
15
|
+
# not. Docker Engine 23 or later (BuildKit, with ADD --checksum and heredocs) builds it.
|
|
16
|
+
#
|
|
17
|
+
# The toolchain is the one TypeSOL is tested with (TESTED_TOOLCHAIN in src/compiler/toolchain.ts): Agave 3.1.10,
|
|
18
|
+
# platform-tools v1.52. Only the C SDK (headers and linker script, text) is taken from the Agave release; the compiler
|
|
19
|
+
# runs clang and ld.lld from platform-tools directly, so cargo-build-sbf and the Solana CLI are not installed.
|
|
20
|
+
#
|
|
21
|
+
# One architecture, linux/amd64, on every machine (emulated on arm64 hosts), so that the environment is one recipe.
|
|
22
|
+
# From TypeSOL 0.45.0 on the programs measured build to the same bytes on macOS arm64, Linux arm64 and Linux x86_64
|
|
23
|
+
# too (76 for SBPF v0, 14 for v1 and v2; CI checks a set of them on every change); 0.44.1 and earlier linked the
|
|
24
|
+
# platform-tools compiler-builtins library, which each host package lays out differently, so a program with 128-bit
|
|
25
|
+
# or signed division got other bytes from each (docs/stability.md has both measurements). Every base image below is
|
|
26
|
+
# pinned by its linux/amd64 manifest digest, not by a multi-platform index.
|
|
27
|
+
|
|
28
|
+
# Unpacking: busybox's tar reads .tar.bz2, which the slim Node image cannot without installing bzip2.
|
|
29
|
+
FROM busybox:1.37.0-glibc@sha256:66a6306db78bf2dbf3487f293aa8d6990d8e506fdffab9cc43fe422becf886e4 AS sdk
|
|
30
|
+
ADD --checksum=sha256:a7205ff29bcf0f7199740225ecae2b85a28ea9668892d5ec21bd9749882984a1 \
|
|
31
|
+
https://github.com/anza-xyz/agave/releases/download/v3.1.10/solana-release-x86_64-unknown-linux-gnu.tar.bz2 /dl/agave.tar.bz2
|
|
32
|
+
RUN mkdir /out && tar -xjf /dl/agave.tar.bz2 -C /out solana-release/bin/platform-tools-sdk/sbf/c && rm /dl/agave.tar.bz2
|
|
33
|
+
|
|
34
|
+
FROM busybox:1.37.0-glibc@sha256:66a6306db78bf2dbf3487f293aa8d6990d8e506fdffab9cc43fe422becf886e4 AS platform-tools
|
|
35
|
+
ADD --checksum=sha256:8b3861e93daf085ec12b65c4fac374d9bec4587a3de16871da6b08ab0c1d907e \
|
|
36
|
+
https://github.com/anza-xyz/platform-tools/releases/download/v1.52/platform-tools-linux-x86_64.tar.bz2 /dl/platform-tools.tar.bz2
|
|
37
|
+
RUN mkdir -p /out/platform-tools && tar -xjf /dl/platform-tools.tar.bz2 -C /out/platform-tools && rm /dl/platform-tools.tar.bz2
|
|
38
|
+
|
|
39
|
+
# Node 24 (a supported line, engines >=22.12) on Debian bookworm.
|
|
40
|
+
FROM node:24.22.2-bookworm-slim@sha256:c0a93797ee78814ae6d32fcca2561fdbbe423149c3f5389aad32d86e9fd85bd4
|
|
41
|
+
|
|
42
|
+
# The layout cargo-build-sbf makes (platform-tools-sdk/sbf, its dependencies/platform-tools link into the versioned
|
|
43
|
+
# cache and the empty platform-tools-v1.52.md marker), so the compiler finds the SDK and reports the version.
|
|
44
|
+
COPY --from=sdk /out/solana-release/bin/platform-tools-sdk/sbf/c /opt/solana/platform-tools-sdk/sbf/c
|
|
45
|
+
COPY --from=platform-tools /out/platform-tools /opt/solana/v1.52/platform-tools
|
|
46
|
+
RUN test "$(uname -m)" = x86_64 || { echo "this image is linux/amd64 only (docker build --platform linux/amd64)" >&2; exit 1; } \
|
|
47
|
+
&& mkdir -p /opt/solana/platform-tools-sdk/sbf/dependencies \
|
|
48
|
+
&& ln -s /opt/solana/v1.52/platform-tools /opt/solana/platform-tools-sdk/sbf/dependencies/platform-tools \
|
|
49
|
+
&& touch /opt/solana/platform-tools-sdk/sbf/dependencies/platform-tools-v1.52.md \
|
|
50
|
+
&& /opt/solana/v1.52/platform-tools/llvm/bin/clang --version | head -1
|
|
51
|
+
ENV TYPESOL_SBF_SDK=/opt/solana/platform-tools-sdk/sbf
|
|
52
|
+
|
|
53
|
+
# The tarball check: the tarball npm serves for TYPESOL_VERSION must be the one release.json records, byte for byte
|
|
54
|
+
# (sha512 integrity and sha1 shasum), and each file in it must have the recorded sha256.
|
|
55
|
+
COPY <<'EOF' /opt/typesol/check-tarball.mjs
|
|
56
|
+
import { createHash } from "node:crypto";
|
|
57
|
+
import { readFileSync, readdirSync, statSync } from "node:fs";
|
|
58
|
+
import path from "node:path";
|
|
59
|
+
const [record, tgz, unpacked, version] = process.argv.slice(2);
|
|
60
|
+
const r = JSON.parse(readFileSync(record, "utf8"));
|
|
61
|
+
const fail = (m) => {
|
|
62
|
+
console.error(`typesol tarball check: ${m}`);
|
|
63
|
+
process.exit(1);
|
|
64
|
+
};
|
|
65
|
+
if (r.version !== version) fail(`release.json is the record of ${r.version}, not ${version}`);
|
|
66
|
+
const data = readFileSync(tgz);
|
|
67
|
+
const integrity = `sha512-${createHash("sha512").update(data).digest("base64")}`;
|
|
68
|
+
const shasum = createHash("sha1").update(data).digest("hex");
|
|
69
|
+
if (integrity !== r.tarball.integrity) fail(`integrity ${integrity}, the record has ${r.tarball.integrity}`);
|
|
70
|
+
if (shasum !== r.tarball.shasum) fail(`shasum ${shasum}, the record has ${r.tarball.shasum}`);
|
|
71
|
+
const walk = (d) => readdirSync(d).flatMap((f) => (statSync(path.join(d, f)).isDirectory() ? walk(path.join(d, f)) : [path.join(d, f)]));
|
|
72
|
+
const files = new Map(walk(unpacked).map((f) => [path.relative(unpacked, f), createHash("sha256").update(readFileSync(f)).digest("hex")]));
|
|
73
|
+
for (const f of r.files) if (files.get(f.path) !== f.sha256) fail(`${f.path}: sha256 ${files.get(f.path) ?? "missing"}, the record has ${f.sha256}`);
|
|
74
|
+
if (files.size !== r.files.length) fail(`the tarball has ${files.size} files, the record ${r.files.length}`);
|
|
75
|
+
console.log(`typesol tarball check: @typesol/cli@${version} ${shasum}, ${files.size} files as recorded (the record names commit ${r.commit})`);
|
|
76
|
+
EOF
|
|
77
|
+
|
|
78
|
+
# The script a container build runs: the given programs built with this image's TypeSOL, through its public API
|
|
79
|
+
# (typesol/compiler and typesol/client, there since before 0.43.0), so one recipe serves every recorded version.
|
|
80
|
+
COPY <<'EOF' /opt/typesol/container-build.mjs
|
|
81
|
+
const root = "/opt/typesol/node_modules/@typesol/cli";
|
|
82
|
+
const { build } = await import(`${root}/dist/compiler/index.js`);
|
|
83
|
+
const { writeClient } = await import(`${root}/dist/tools/clientgen.js`);
|
|
84
|
+
const path = await import("node:path");
|
|
85
|
+
const results = [];
|
|
86
|
+
for (const j of JSON.parse(process.argv[2])) {
|
|
87
|
+
try {
|
|
88
|
+
const res = build(j.entry, j.out, j.address, { sbpf: j.sbpf, profile: j.profile });
|
|
89
|
+
writeClient(res.idl, path.join(j.out, `${res.model.name}.client.ts`));
|
|
90
|
+
results.push({ name: res.model.name, so: res.soPath, manifest: res.manifestPath });
|
|
91
|
+
} catch (e) {
|
|
92
|
+
console.error(e instanceof Error ? e.message : String(e));
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
console.log(`TYPESOL_RESULT ${JSON.stringify(results)}`);
|
|
97
|
+
EOF
|
|
98
|
+
|
|
99
|
+
# The dependency install: the npm lockfile of the TypeSOL version's runtime dependencies (docker/deps/<version>.lock.json),
|
|
100
|
+
# from the build context when the running package ships it, else from the version's own tarball, checked above. When
|
|
101
|
+
# both are there they must be the same bytes. The lock must describe exactly the dependencies the tarball's
|
|
102
|
+
# package.json declares, and every package in it must come from the npm registry with an integrity value, which
|
|
103
|
+
# `npm ci` then checks each download against: nothing is resolved at build time.
|
|
104
|
+
COPY <<'EOF' /opt/typesol/install-deps.mjs
|
|
105
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
106
|
+
const [given, unpacked, version, out] = process.argv.slice(2);
|
|
107
|
+
const fail = (m) => {
|
|
108
|
+
console.error(`typesol dependency lock: ${m}`);
|
|
109
|
+
process.exit(1);
|
|
110
|
+
};
|
|
111
|
+
const rel = `docker/deps/${version}.lock.json`;
|
|
112
|
+
const fromContext = existsSync(given) && readFileSync(given).length ? readFileSync(given) : undefined;
|
|
113
|
+
const fromTarball = existsSync(`${unpacked}/${rel}`) ? readFileSync(`${unpacked}/${rel}`) : undefined;
|
|
114
|
+
if (fromContext && fromTarball && !fromContext.equals(fromTarball)) fail(`the package's ${rel} and the tarball's differ`);
|
|
115
|
+
const bytes = fromContext ?? fromTarball;
|
|
116
|
+
if (!bytes) fail(`no ${rel}, in the build context or in the tarball`);
|
|
117
|
+
const lock = JSON.parse(bytes.toString("utf8"));
|
|
118
|
+
if (lock.lockfileVersion !== 3) fail(`lockfileVersion ${lock.lockfileVersion}, expected 3`);
|
|
119
|
+
const root = lock.packages?.[""];
|
|
120
|
+
const declared = JSON.parse(readFileSync(`${unpacked}/package.json`, "utf8")).dependencies ?? {};
|
|
121
|
+
const canonical = (o) => JSON.stringify(Object.keys(o ?? {}).sort().map((k) => [k, o[k]]));
|
|
122
|
+
if (canonical(root?.dependencies) !== canonical(declared)) fail(`the lock is for ${canonical(root?.dependencies)}, the package declares ${canonical(declared)}`);
|
|
123
|
+
const entries = Object.entries(lock.packages).filter(([p]) => p !== "");
|
|
124
|
+
for (const [p, e] of entries) {
|
|
125
|
+
if (e.link) fail(`${p} is a link`);
|
|
126
|
+
if (!/^https:\/\/registry\.npmjs\.org\//.test(e.resolved ?? "")) fail(`${p} resolves to ${e.resolved ?? "nothing"}, not the npm registry`);
|
|
127
|
+
if (!/^sha512-/.test(e.integrity ?? "")) fail(`${p} has no sha512 integrity`);
|
|
128
|
+
}
|
|
129
|
+
writeFileSync(`${out}/package-lock.json`, bytes);
|
|
130
|
+
writeFileSync(`${out}/package.json`, JSON.stringify({ name: root.name, version: root.version, private: true, dependencies: root.dependencies }, null, 2) + "\n");
|
|
131
|
+
console.log(`typesol dependency lock: ${rel} (${fromContext ? "the package's" : "the tarball's"}), ${entries.length} packages, each with its integrity`);
|
|
132
|
+
EOF
|
|
133
|
+
|
|
134
|
+
ARG TYPESOL_VERSION
|
|
135
|
+
COPY release.json deps.lock.json /opt/typesol/ctx/
|
|
136
|
+
# The TypeSOL tarball, checked against the release record, then its dependencies with `npm ci` from the lock (npm checks
|
|
137
|
+
# every package's integrity; no install scripts run), then the checked files moved to node_modules/@typesol/cli
|
|
138
|
+
# without a second resolution.
|
|
139
|
+
RUN test -n "$TYPESOL_VERSION" || { echo "--build-arg TYPESOL_VERSION=<version> is required" >&2; exit 1; } \
|
|
140
|
+
&& mkdir -p /tmp/typesol/unpacked && cd /tmp/typesol \
|
|
141
|
+
&& npm pack "@typesol/cli@${TYPESOL_VERSION}" --pack-destination /tmp/typesol --silent \
|
|
142
|
+
&& tar -xzf "typesol-cli-${TYPESOL_VERSION}.tgz" -C unpacked --strip-components=1 \
|
|
143
|
+
&& node /opt/typesol/check-tarball.mjs /opt/typesol/ctx/release.json "typesol-cli-${TYPESOL_VERSION}.tgz" unpacked "$TYPESOL_VERSION" \
|
|
144
|
+
&& node /opt/typesol/install-deps.mjs /opt/typesol/ctx/deps.lock.json unpacked "$TYPESOL_VERSION" /opt/typesol \
|
|
145
|
+
&& cd /opt/typesol \
|
|
146
|
+
&& npm ci --omit=peer --omit=optional --ignore-scripts --no-audit --no-fund --silent \
|
|
147
|
+
&& mkdir -p /opt/typesol/node_modules/@typesol \
|
|
148
|
+
&& mv /tmp/typesol/unpacked /opt/typesol/node_modules/@typesol/cli \
|
|
149
|
+
&& chmod 755 /opt/typesol/node_modules/@typesol/cli/dist/cli.js \
|
|
150
|
+
&& ln -s /opt/typesol/node_modules/@typesol/cli/dist/cli.js /usr/local/bin/typesol \
|
|
151
|
+
&& rm -rf /tmp/typesol /root/.npm \
|
|
152
|
+
&& typesol --version
|
|
153
|
+
|
|
154
|
+
LABEL org.opencontainers.image.title="typesol-build" \
|
|
155
|
+
org.opencontainers.image.description="TypeSOL ${TYPESOL_VERSION} with Agave 3.1.10 platform-tools v1.52, built from pinned inputs" \
|
|
156
|
+
org.opencontainers.image.source="https://github.com/typesol-lang/typesol" \
|
|
157
|
+
org.typesol.version="${TYPESOL_VERSION}"
|
|
158
|
+
|
|
159
|
+
# A build runs as the caller's uid and gid (passed by the CLI; this user where there is none), without network or
|
|
160
|
+
# capabilities, on a read-only root file system; HOME points at the writable /tmp.
|
|
161
|
+
USER node
|
|
162
|
+
ENV HOME=/tmp
|
|
163
|
+
WORKDIR /src
|