@typesol/cli 0.49.0 → 0.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +541 -0
- package/NOTICE +9 -0
- package/README.md +34 -15
- package/SECURITY.md +6 -3
- package/dist/cli.js +36 -5
- package/dist/compiler/analyze.d.ts +10 -1
- package/dist/compiler/analyze.js +234 -20
- package/dist/compiler/diagnostics.d.ts +4 -0
- package/dist/compiler/diagnostics.js +5 -1
- package/dist/compiler/emit/base.d.ts +35 -4
- package/dist/compiler/emit/base.js +46 -4
- package/dist/compiler/emit/borsh.js +8 -8
- package/dist/compiler/emit/calls.d.ts +6 -0
- package/dist/compiler/emit/calls.js +98 -18
- package/dist/compiler/emit/cpi-core.d.ts +3 -0
- package/dist/compiler/emit/cpi-core.js +11 -5
- package/dist/compiler/emit/cpi.js +6 -4
- package/dist/compiler/emit/create.js +9 -9
- package/dist/compiler/emit/expressions.d.ts +9 -1
- package/dist/compiler/emit/expressions.js +77 -0
- package/dist/compiler/emit/function.d.ts +2 -0
- package/dist/compiler/emit/function.js +71 -15
- package/dist/compiler/emit/outline.d.ts +35 -0
- package/dist/compiler/emit/outline.js +547 -0
- package/dist/compiler/emit/program.js +19 -4
- package/dist/compiler/emit/rbtree.js +1 -1
- package/dist/compiler/emit/shared.d.ts +69 -4
- package/dist/compiler/emit/shared.js +44 -9
- package/dist/compiler/emit/statements.d.ts +36 -2
- package/dist/compiler/emit/statements.js +332 -29
- package/dist/compiler/emit/storage.d.ts +16 -0
- package/dist/compiler/emit/storage.js +134 -13
- package/dist/compiler/emit/views.js +1 -1
- package/dist/compiler/hints.d.ts +1 -1
- package/dist/compiler/hints.js +9 -1
- package/dist/compiler/idl.js +1 -1
- package/dist/compiler/index.d.ts +30 -2
- package/dist/compiler/index.js +94 -16
- package/dist/compiler/model.d.ts +13 -1
- package/dist/compiler/stack.d.ts +71 -0
- package/dist/compiler/stack.js +309 -0
- package/dist/compiler/toolchain.d.ts +87 -5
- package/dist/compiler/toolchain.js +384 -19
- package/dist/keys.d.ts +12 -1
- package/dist/keys.js +57 -7
- package/dist/workspace.d.ts +9 -0
- package/dist/workspace.js +91 -16
- package/docker/deps/0.50.0.lock.json +1206 -0
- package/docker/deps/0.51.0.lock.json +1206 -0
- package/docs/architecture.md +1 -1
- package/docs/audit.md +16 -13
- package/docs/case-study-escrow.md +1 -1
- package/docs/case-study-jito-mev.md +14 -14
- package/docs/case-study-marginfi.md +127 -127
- package/docs/case-study-multisig.md +16 -4
- package/docs/case-study-raydium-clmm.md +44 -28
- package/docs/case-study-raydium-cp-swap.md +18 -18
- package/docs/cli.md +5 -4
- package/docs/glossary.md +2 -1
- package/docs/language-accounts.md +16 -10
- package/docs/language-basics.md +29 -2
- package/docs/language-builtins.md +4 -2
- package/docs/language-cpi.md +34 -0
- package/docs/language-native.md +50 -4
- package/docs/language-pdas.md +6 -2
- package/docs/language-statements.md +103 -12
- package/docs/language-types.md +93 -8
- package/docs/runtime.md +20 -3
- package/docs/security-model.md +6 -3
- package/docs/stability.md +10 -5
- package/docs/testing.md +6 -2
- package/docs/troubleshooting.md +45 -1
- package/lib/typesol.d.ts +25 -3
- package/llms-full.txt +403 -54
- package/package.json +1 -1
- package/releases/0.49.0.json +857 -0
- package/releases/0.50.0.json +874 -0
- package/runtime/typesol_builtins.c +47 -2
- package/runtime/typesol_rt.h +254 -54
package/README.md
CHANGED
|
@@ -74,8 +74,8 @@ the port and to the binary deployed on mainnet, both in LiteSVM, and require the
|
|
|
74
74
|
bytes in every account the transaction names, and the same error code and log lines, with the exceptions each case
|
|
75
75
|
study lists. Of those, the kinds that recur:
|
|
76
76
|
|
|
77
|
-
- **Error-message text.** The Anchor ports log their errors in TypeSOL's words, with Anchor's codes; Jito's
|
|
78
|
-
out Anchor's `Instruction: …` lines.
|
|
77
|
+
- **Error-message text.** The Anchor ports log their errors in TypeSOL's words, with Anchor's codes; Jito's, Raydium
|
|
78
|
+
CLMM's and the multisig's also leave out Anchor's `Instruction: …` lines.
|
|
79
79
|
- **Panics.** Where the original panics, Marginfi, Raydium CLMM, Raydium CP-Swap and Jito MEV fail with a numbered
|
|
80
80
|
error, and Marginfi also answers a few runtime errors that carry no code (`AccountBorrowFailed`, `BorshIoError`)
|
|
81
81
|
with numbered ones; the tests require that both fail.
|
|
@@ -93,14 +93,26 @@ each (for Percolator, the port's README) says what was compared and what was not
|
|
|
93
93
|
| [Marginfi v2](docs/case-study-marginfi.md) | Anchor, lending | 124 | 2,321 |
|
|
94
94
|
| [Phoenix v1](docs/case-study-phoenix.md) | native, limit order book | 28 | 3,575 |
|
|
95
95
|
| [SPL Stake Pool](docs/case-study-spl-stake-pool.md) | native, liquid staking | 27 | 2,107 |
|
|
96
|
-
| [Raydium CLMM](docs/case-study-raydium-clmm.md) | Anchor, concentrated liquidity | 37 |
|
|
96
|
+
| [Raydium CLMM](docs/case-study-raydium-clmm.md) | Anchor, concentrated liquidity | 37 | 308 |
|
|
97
97
|
| [Raydium CP-Swap](docs/case-study-raydium-cp-swap.md) | Anchor, constant product | 21 | 136 |
|
|
98
98
|
| [Raydium AMM v4](docs/case-study-raydium-amm.md) | native, constant product | all | 144 (60 random steps) |
|
|
99
99
|
| [Jito MEV](docs/case-study-jito-mev.md) | Anchor, three programs | 24 | 150 |
|
|
100
100
|
| [Percolator v12.20](showcase/mainnet/percolator) | native, perpetuals risk engine | 27 | 139,185 (132,031 random or mutated: 3,711 in random walks on fixed seeds, 128,320 from the mutation fuzzers) |
|
|
101
|
+
| [Percolator v16 at commit 7b110913 (engine 5e3af07)](showcase/mainnet/percolator-v16) | native, multi-asset perpetuals risk engine; compared with a binary built here from the author's pinned source, not a deployed program | 50 | 70,975 |
|
|
101
102
|
| [coral-xyz/multisig](docs/case-study-multisig.md) | Anchor | all | 55 |
|
|
102
103
|
|
|
103
|
-
|
|
104
|
+
No Percolator v16 build is deployed, so its row is the one port above not compared with a mainnet binary: its
|
|
105
|
+
reference is the Rust build of the pinned commits (reproducible, its recipe matching the author's recorded hash at an
|
|
106
|
+
older commit). Not compared there: a deployed program, matchers other than the three the author's tests load and one
|
|
107
|
+
of the tests' own, and a few paths no instruction sequence reached (its README lists them); where the reference runs
|
|
108
|
+
out of compute units the port is compared with the reference run under a raised budget. The author's own suite ran on
|
|
109
|
+
both binaries, with every transaction compared (2,324,990 of 2,324,991 identical, the other a force-close that exceeds
|
|
110
|
+
the reference's compute budget); none of the 2,127,486 identical successes costs the port more (port 67,489,438,873
|
|
111
|
+
units, reference 128,297,605,017). A first run, on an earlier binary of the port, had found
|
|
112
|
+
282 such successes at the author's largest market shapes (ResolveMarket, CloseSlab, InitMarket); the cause was fixed
|
|
113
|
+
and the full run repeated (its README has the figures).
|
|
114
|
+
|
|
115
|
+
A further port is held to a narrower comparison and is not counted above:
|
|
104
116
|
[Meteora Dynamic Bonding Curve 0.2.2](showcase/mainnet/meteora-dbc) (Anchor, launchpad, all 35 instructions, with its
|
|
105
117
|
migrations into DAMM v1 and DAMM v2). Outcomes, error codes, account bytes, inner instructions (its events are
|
|
106
118
|
self-CPIs) and return data are compared as for the ports above, with the exceptions its README lists; of the log only
|
|
@@ -108,7 +120,10 @@ the events' `Program data:` lines are compared, not the rest of its text, and co
|
|
|
108
120
|
port, its tests (`showcase/test/meteora-dbc*.ts`) and their fixtures (`showcase/test/fixtures/meteora-dbc/`) are under
|
|
109
121
|
Meteora's Non-commercial Licence, not this repository's (see [NOTICE](NOTICE)).
|
|
110
122
|
|
|
111
|
-
Each count is what a default test run compares, with the fetch-only binaries present (`pnpm fetch:programs`)
|
|
123
|
+
Each count is what a default test run compares, with the fetch-only binaries present (`pnpm fetch:programs`); the
|
|
124
|
+
Percolator v16 count needs its reference binaries built as well (`scripts/percolator-v16-reference/build.sh` and
|
|
125
|
+
`probe.sh`, Docker), as CI's `percolator-v16` job does, and is the sum of the `percolator-v16 compared: …` line each of
|
|
126
|
+
its test files prints (without the binaries those files skip and print 0). Random
|
|
112
127
|
walks, with fixed or printed seeds, run on top of the other ports' counts ([docs/testing.md](docs/testing.md)); the
|
|
113
128
|
multisig port has none. The
|
|
114
129
|
sources are in [`showcase/mainnet`](showcase/mainnet), and where each original binary comes from is recorded in
|
|
@@ -372,16 +387,16 @@ toolchain and records them with every result:
|
|
|
372
387
|
<!-- bench:table -->
|
|
373
388
|
| Instruction | TypeSOL | Pinocchio 0.10 | Native Rust | Anchor 1.0.2 |
|
|
374
389
|
| --- | ---: | ---: | ---: | ---: |
|
|
375
|
-
| counter.initialize | **1,
|
|
390
|
+
| counter.initialize | **1,852** | 3,186 | 4,601 | 6,573 |
|
|
376
391
|
| counter.increment | **110** | 113 | 857 | 2,323 |
|
|
377
|
-
| vault.open | **1,
|
|
392
|
+
| vault.open | **1,871** | 3,185 | 4,613 | 6,627 |
|
|
378
393
|
| vault.deposit | **1,314** | 1,377 | 2,832 | 4,355 |
|
|
379
394
|
| vault.withdraw | **315** | 370 | 1,176 | 3,628 |
|
|
380
395
|
| vault.shut | **161** | 167 | 950 | 2,024 |
|
|
381
|
-
| escrow.make | **3,
|
|
382
|
-
| escrow.take | **
|
|
383
|
-
| escrow.refund | **2,
|
|
384
|
-
| binary, counter / vault / escrow | 11.
|
|
396
|
+
| escrow.make | **3,590** | 6,179 | 9,240 | 13,304 |
|
|
397
|
+
| escrow.take | **3,945** | 4,051 | 8,500 | 14,365 |
|
|
398
|
+
| escrow.refund | **2,622** | 2,769 | 5,695 | 8,449 |
|
|
399
|
+
| binary, counter / vault / escrow | 11.0 / 14.1 / 21.4 KB | 19.6 / 22.9 / 29.4 KB | 27.9 / 35.0 / 46.5 KB | 145.2 / 158.9 / 190.7 KB |
|
|
385
400
|
<!-- /bench:table -->
|
|
386
401
|
|
|
387
402
|
`initialize`, `open` and `make` include the PDA bump search. TypeSOL hashes PDA candidates with the sha256 and
|
|
@@ -394,7 +409,7 @@ units are not a safety claim. The differential tests also run the escrow against
|
|
|
394
409
|
These three programs' Pinocchio versions were written for this comparison.
|
|
395
410
|
|
|
396
411
|
<!-- bench:official -->
|
|
397
|
-
On the official examples, 17 programs of solana-developers/program-examples@de09019 that this project did not write (26 instructions, `official.ts` in the benchmarks repository), TypeSOL uses fewer compute units than Anchor on 26 of 26 instructions and than native Rust on 26 of 26, and more than Pinocchio on
|
|
412
|
+
On the official examples, 17 programs of solana-developers/program-examples@de09019 that this project did not write (26 instructions, `official.ts` in the benchmarks repository), TypeSOL uses fewer compute units than Anchor on 26 of 26 instructions and than native Rust on 26 of 26, and more than Pinocchio on 12 of 26.
|
|
398
413
|
<!-- /bench:official -->
|
|
399
414
|
|
|
400
415
|
Those Pinocchio versions often do less: favorites, close-account and
|
|
@@ -497,6 +512,7 @@ Case studies: [Marginfi v2](docs/case-study-marginfi.md), [Phoenix v1](docs/case
|
|
|
497
512
|
| [`raydium-amm/`](showcase/mainnet/raydium-amm) | Raydium AMM v4, the original constant-product AMM and a native (non-Anchor) program, in full: pool creation, deposits and withdrawals, the v1 and v2 swaps, P&L and administration, down to its log records and panics |
|
|
498
513
|
| [`meteora-dbc/`](showcase/mainnet/meteora-dbc) | Meteora Dynamic Bonding Curve 0.2.2 in full, all 35 instructions: configs, pool creation on SPL Token and Token-2022 (transfer fees and hooks), the three swap modes, fee schedulers and the rate limiter, fee claims, the locker, and the migrations into DAMM v1 and DAMM v2. Under Meteora's Non-commercial Licence (its own `LICENSE.md`); log text and compute units are not compared |
|
|
499
514
|
| [`percolator/`](showcase/mainnet/percolator) | Percolator v12.20, Anatoly Yakovenko's perpetuals risk engine and its native program, in full, all 27 instructions, against the immutable mainnet build: one 1.5 MB slab of 4,096 accounts, U256 and U512 arithmetic, trades through matcher programs, funding, liquidation, the keeper crank with pro-rata loss socialisation and side resets, resolution and teardown. The author's own suite gives the same outcome on every test under both binaries (660 passed). Upstream is educational and not audited |
|
|
515
|
+
| [`percolator-v16/`](showcase/mainnet/percolator-v16) | Percolator v16 at commit 7b110913 (engine 5e3af07), Anatoly Yakovenko's multi-asset perpetuals risk engine and its native program, all 50 instructions: portfolios of up to 14 legs, trades direct, batched and through matcher programs, the crank with liquidation, bankrupt closes, Recovery and resolution, insurance and backing buckets with source liens, terminal close-out. Compared with a binary built from the author's pinned source (not a deployed program). Upstream is educational and not audited |
|
|
500
516
|
| [`multisig.ts`](showcase/mainnet/multisig/multisig.ts) | coral-xyz/multisig: stored instructions run with `invokeInstruction`, a PDA signing, Anchor's Borsh accounts |
|
|
501
517
|
|
|
502
518
|
## Status
|
|
@@ -508,11 +524,14 @@ change.
|
|
|
508
524
|
The two latest, of 0.43.0 and 0.44.0 in November 2026, found defects that made a program that compiled behave
|
|
509
525
|
differently from its source; each is fixed with a test, and [docs/audit.md](docs/audit.md) lists them, what the
|
|
510
526
|
reviews covered and what they did not. Programs built before 0.44.1 should be rebuilt.
|
|
511
|
-
- 0.45.0 to 0.
|
|
527
|
+
- 0.45.0 to 0.51.0 have had no security review. They add, among others,
|
|
512
528
|
`runtime/typesol_builtins.c` (the compiler builtins as TypeSOL's own C, 0.45.0), `transferCheckedWithHook`,
|
|
513
|
-
`EVENT_AUTHORITY_CHECK` and the reads of processed sibling instructions (0.48.0),
|
|
529
|
+
`EVENT_AUTHORITY_CHECK` and the reads of processed sibling instructions (0.48.0), `zeroData`, `log64`,
|
|
514
530
|
`PANIC_STYLE = "solana-1.18"`, `executable` on remaining accounts and lamport writes on remaining accounts under
|
|
515
|
-
`NATIVE_ACCOUNT_WRITES` (0.49.0)
|
|
531
|
+
`NATIVE_ACCOUNT_WRITES` (0.49.0), `copyData`, `getReturnData()`, `PANIC_STYLE = "pinocchio"` and whole values
|
|
532
|
+
copied and zeroed by the memory syscalls (0.50.0), and the base58 text of keys from a table, derivations without
|
|
533
|
+
the run-time seed-limit check, object-type structs, `extends`, struct spreads, labels, logical assignment and the
|
|
534
|
+
stack layout the build chooses for a program that does not fit (0.51.0).
|
|
516
535
|
- From 0.44.0 on, a release that only fixes defects is a patch with no new language surface and a binary diff in its
|
|
517
536
|
notes ([SECURITY.md](SECURITY.md#fix-releases)), and the npm tarball is the one packed from the tag and recorded
|
|
518
537
|
in [releases/](releases).
|
package/SECURITY.md
CHANGED
|
@@ -8,11 +8,14 @@ TypeSOL generates programs that hold funds. Treat it accordingly.
|
|
|
8
8
|
0.44.0 on 2026-11-11, found defects in the compiler (wrong token-wrapper instruction data, and a reference that could
|
|
9
9
|
outlive a resize and reach another record) and a latent one in the runtime; they are fixed in 0.44.1. The one
|
|
10
10
|
before it, of 0.43.0, found defects fixed in 0.44.0 (one of them could break an authorization check in a helper).
|
|
11
|
-
0.45.0 to 0.
|
|
11
|
+
0.45.0 to 0.51.0 have had no security review. They add, among others,
|
|
12
12
|
`runtime/typesol_builtins.c` (the compiler builtins as TypeSOL's own C, 0.45.0), `transferCheckedWithHook`,
|
|
13
|
-
`EVENT_AUTHORITY_CHECK` and the reads of processed sibling instructions (0.48.0),
|
|
13
|
+
`EVENT_AUTHORITY_CHECK` and the reads of processed sibling instructions (0.48.0), `zeroData`, `log64`,
|
|
14
14
|
`PANIC_STYLE = "solana-1.18"`, `executable` on remaining accounts and lamport writes on remaining accounts under
|
|
15
|
-
`NATIVE_ACCOUNT_WRITES` (0.49.0)
|
|
15
|
+
`NATIVE_ACCOUNT_WRITES` (0.49.0), `copyData`, `getReturnData()`, `PANIC_STYLE = "pinocchio"` and whole values
|
|
16
|
+
copied and zeroed by the memory syscalls (0.50.0), and the base58 text of keys from a table, derivations without
|
|
17
|
+
the run-time seed-limit check, object-type structs, `extends`, struct spreads, labels, logical assignment and the
|
|
18
|
+
stack layout the build chooses for a program that does not fit (0.51.0).
|
|
16
19
|
**Rebuild and redeploy programs built before 0.44.1**;
|
|
17
20
|
[docs/security-model.md](docs/security-model.md#status) gives the status, its sections on each review say how to
|
|
18
21
|
tell whether a program was exposed, and [docs/audit.md](docs/audit.md#earlier-reviews) what each review did and did
|
package/dist/cli.js
CHANGED
|
@@ -6,7 +6,7 @@ import path from "node:path";
|
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { parseArgs } from "node:util";
|
|
8
8
|
import { createHash } from "node:crypto";
|
|
9
|
-
import { build, CompileError, COMPILER_VERSION, describeToolchain, elfLength, generate, MEASURED_HOSTS, SBPF_VERSIONS, toolchainDifferences, verifyBinary, } from "./compiler/index.js";
|
|
9
|
+
import { build, CompileError, COMPILER_VERSION, describeToolchain, elfLength, generate, MEASURED_HOSTS, SBPF_VERSIONS, stackNotes, toolchainDifferences, verifyBinary, } from "./compiler/index.js";
|
|
10
10
|
import { setToolchainStrict, shortClang } from "./compiler/toolchain.js";
|
|
11
11
|
import { generateCpi } from "./tools/cpigen.js";
|
|
12
12
|
import { generatePort } from "./tools/portgen.js";
|
|
@@ -50,6 +50,28 @@ const DOCKER_HELP = [
|
|
|
50
50
|
"--release-record <file> the releases/<v>.json to check that version's tarball against (default: this package's, else the repository's)",
|
|
51
51
|
].join("\n ");
|
|
52
52
|
const DOCKER_OPTIONS = { docker: { type: "boolean" }, "typesol-version": { type: "string" }, "release-record": { type: "string" } };
|
|
53
|
+
const STACK_AUTO_HELP = [
|
|
54
|
+
"--stack-auto on|off on (the default): a program that does not fit the stack is laid out another way when it can (statements",
|
|
55
|
+
" scoped, helpers kept out of line, an instruction's large locals on the heap), each step printed as a note",
|
|
56
|
+
" and recorded in <name>.build.json; off: such a build fails (as const STACK_AUTO = false does)",
|
|
57
|
+
].join("\n ");
|
|
58
|
+
/** --stack-auto: undefined (the default, on), true or false. */
|
|
59
|
+
function stackAutoOf(v) {
|
|
60
|
+
const s = v["stack-auto"];
|
|
61
|
+
if (s === undefined)
|
|
62
|
+
return undefined;
|
|
63
|
+
if (s !== "on" && s !== "off")
|
|
64
|
+
throw new UsageError("--stack-auto must be on or off");
|
|
65
|
+
if (v.docker && s === "off")
|
|
66
|
+
throw new UsageError("--stack-auto off applies to local builds: for a container build, write const STACK_AUTO = false in the program");
|
|
67
|
+
return s === "on";
|
|
68
|
+
}
|
|
69
|
+
/** The notes of a build that did not fit the stack as written (see stackNotes), one line each. */
|
|
70
|
+
function logStackNotes(manifest, indent = " ") {
|
|
71
|
+
if (manifest.stack)
|
|
72
|
+
for (const n of stackNotes(manifest.stack, manifest.sbpf))
|
|
73
|
+
log(`${indent}note: ${n}`);
|
|
74
|
+
}
|
|
53
75
|
const COMMANDS = {
|
|
54
76
|
new: {
|
|
55
77
|
usage: "typesol new <program> [--template counter|vault|escrow]",
|
|
@@ -126,12 +148,13 @@ const COMMANDS = {
|
|
|
126
148
|
},
|
|
127
149
|
},
|
|
128
150
|
build: {
|
|
129
|
-
usage: "typesol build [<program>…] [--sbpf v0|v1|v2] [--profile] [--toolchain-strict] [--docker [--typesol-version <v>] [--release-record <file>]]\n typesol build <program.ts> [--out <dir>] [--program-id <keypair.json>] [--sbpf …] [--profile] [--toolchain-strict] [--docker …]",
|
|
151
|
+
usage: "typesol build [<program>…] [--sbpf v0|v1|v2] [--profile] [--stack-auto on|off] [--toolchain-strict] [--docker [--typesol-version <v>] [--release-record <file>]]\n typesol build <program.ts> [--out <dir>] [--program-id <keypair.json>] [--sbpf …] [--profile] [--stack-auto on|off] [--toolchain-strict] [--docker …]",
|
|
130
152
|
help: [
|
|
131
153
|
`In a project (${CONFIG}): build every program, or the ones named, into <out>/<name>/ (.so, IDL .json, .client.ts, .c, .build.json).`,
|
|
132
154
|
"Outside a project, or with a .ts file: build that file (its keypair is created next to the output if needed).",
|
|
133
155
|
SBPF,
|
|
134
156
|
"--profile log a marker and the remaining compute units before every statement (for `typesol profile`; not for release)",
|
|
157
|
+
STACK_AUTO_HELP,
|
|
135
158
|
TOOLCHAIN_STRICT,
|
|
136
159
|
DOCKER_HELP,
|
|
137
160
|
"--quiet no banner",
|
|
@@ -139,6 +162,7 @@ const COMMANDS = {
|
|
|
139
162
|
options: {
|
|
140
163
|
sbpf: { type: "string" },
|
|
141
164
|
profile: { type: "boolean" },
|
|
165
|
+
"stack-auto": { type: "string" },
|
|
142
166
|
out: { type: "string" },
|
|
143
167
|
"program-id": { type: "string" },
|
|
144
168
|
quiet: { type: "boolean" },
|
|
@@ -150,6 +174,7 @@ const COMMANDS = {
|
|
|
150
174
|
setToolchainStrict();
|
|
151
175
|
const sbpf = sbpfOf(v);
|
|
152
176
|
const profile = !!v.profile;
|
|
177
|
+
const stackAuto = stackAutoOf(v);
|
|
153
178
|
const ws = findWorkspace(process.cwd());
|
|
154
179
|
const file = args.length === 1 && args[0].endsWith(".ts") ? args[0] : undefined;
|
|
155
180
|
// A .ts that is one of the project's programs builds as that program (same keypair, output and settings).
|
|
@@ -172,12 +197,15 @@ const COMMANDS = {
|
|
|
172
197
|
built.forEach((r, i) => {
|
|
173
198
|
const j = jobs[i];
|
|
174
199
|
log(` ${j.paths.name.padEnd(12)} ${j.address}${j.created ? " (new keypair)" : j.keyless ? " (no keypair here: deploying needs it)" : ""} ${path.relative(process.cwd(), r.soPath)}`);
|
|
200
|
+
logStackNotes(r.manifest, " ");
|
|
175
201
|
});
|
|
176
202
|
log(containerLine(image));
|
|
177
203
|
return 0;
|
|
178
204
|
}
|
|
179
|
-
for (const b of buildWorkspace(ws, inProject ? [inProject] : names(ws, args), { sbpf, profile }))
|
|
205
|
+
for (const b of buildWorkspace(ws, inProject ? [inProject] : names(ws, args), { sbpf, profile, stackAuto })) {
|
|
180
206
|
log(` ${b.paths.name.padEnd(12)} ${b.address}${b.created ? " (new keypair)" : b.keyless ? " (no keypair here: deploying needs it)" : ""} ${path.relative(process.cwd(), b.result.soPath)}`);
|
|
207
|
+
logStackNotes(b.result.manifest, " ");
|
|
208
|
+
}
|
|
181
209
|
return 0;
|
|
182
210
|
}
|
|
183
211
|
if (!file)
|
|
@@ -202,10 +230,10 @@ const COMMANDS = {
|
|
|
202
230
|
if (image) {
|
|
203
231
|
// The container sees the entry's directory: the program and the files it imports from there.
|
|
204
232
|
const [r] = containerBuild(image, path.dirname(path.resolve(file)), [{ entry: file, outDir, address, sbpf: sbpf ?? "v0", profile }]);
|
|
205
|
-
res = { soPath: r.soPath, idlPath: path.join(outDir, `${name}.json`), manifestPath: r.manifestPath };
|
|
233
|
+
res = { soPath: r.soPath, idlPath: path.join(outDir, `${name}.json`), manifestPath: r.manifestPath, manifest: r.manifest };
|
|
206
234
|
}
|
|
207
235
|
else {
|
|
208
|
-
const local = build(file, outDir, address, { sbpf: sbpf ?? "v0", profile });
|
|
236
|
+
const local = build(file, outDir, address, { sbpf: sbpf ?? "v0", profile, stackAuto });
|
|
209
237
|
writeClient(local.idl, path.join(outDir, `${name}.client.ts`));
|
|
210
238
|
res = local;
|
|
211
239
|
}
|
|
@@ -215,6 +243,7 @@ const COMMANDS = {
|
|
|
215
243
|
log(` idl ${res.idlPath}`);
|
|
216
244
|
log(` client ${path.join(outDir, `${name}.client.ts`)}`);
|
|
217
245
|
log(` manifest ${res.manifestPath}`);
|
|
246
|
+
logStackNotes(res.manifest);
|
|
218
247
|
log(`\n deploy: solana program deploy ${shellQuote(res.soPath)} --program-id ${shellQuote(keyFile)}`);
|
|
219
248
|
if (image)
|
|
220
249
|
log(containerLine(image));
|
|
@@ -605,6 +634,8 @@ const COMMANDS = {
|
|
|
605
634
|
const what = deployedPath ??
|
|
606
635
|
`${onChain.address} (${onChain.info.dataAccount === onChain.address ? "" : `data ${onChain.info.dataAccount}, `}loader ${onChain.info.loader})`;
|
|
607
636
|
log(same ? ` match ${rebuilt.binary} (sbpf ${sbpf})` : ` MISMATCH ${what} is not what ${entry} builds to (${rebuilt.binary}, sbpf ${sbpf})`);
|
|
637
|
+
// A program that did not fit the stack as written: the rebuild laid it out the same way, step by step.
|
|
638
|
+
logStackNotes(rebuilt);
|
|
608
639
|
if (same && image && root)
|
|
609
640
|
for (const line of verifiedLines({ what, entry, root, rebuilt, image, args, v }))
|
|
610
641
|
log(line);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
import { Reporter } from "./diagnostics.js";
|
|
3
|
-
import { type OptionInner, type DataEnumDef, type EnumDef, type GenericHelper, type Helper, type ProgramModel, type ScalarType, type StructDef, type StructField, type ValueType, isScalar } from "./model.js";
|
|
3
|
+
import { type OptionInner, type DataEnumDef, type EnumDef, type GenericHelper, type Helper, type ProgramModel, type ScalarType, type StructDecl, type StructDef, type StructField, type ValueType, isScalar } from "./model.js";
|
|
4
4
|
export declare const LIB_PATH: string;
|
|
5
5
|
/** Members every account parameter has (`acct.key`, `acct.isSigner`, …): a struct held in an account cannot use them. */
|
|
6
6
|
export declare const ACCOUNT_MEMBERS: Set<string>;
|
|
@@ -22,6 +22,8 @@ export interface Analysis {
|
|
|
22
22
|
sourceFile: ts.SourceFile;
|
|
23
23
|
/** Every TypeSOL file of the program, entry last. */
|
|
24
24
|
files: string[];
|
|
25
|
+
/** Each of those files' text as the compiler parsed it (a build checks the bytes it records against it). */
|
|
26
|
+
texts: Map<string, string>;
|
|
25
27
|
/** Local identifier -> `typesol` export name, for imports. */
|
|
26
28
|
imports: Map<string, string>;
|
|
27
29
|
reporter: Reporter;
|
|
@@ -71,4 +73,11 @@ export declare function resolveValueType(node: ts.TypeNode, scope: TypeScope, al
|
|
|
71
73
|
export declare function heapVecOf(s: StructDef): StructField | undefined;
|
|
72
74
|
/** The helper (or generic) a call's callee names: a local function by its declaration, others by name. */
|
|
73
75
|
export declare function calleeName(callee: ts.Identifier, decls: Map<ts.Node, string>, checker: ts.TypeChecker): string | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* What to write instead of a TypeScript type form TypeSOL does not have (a parameter's, a field's, a result's or a
|
|
78
|
+
* local's type), or undefined when the type is not one of those forms.
|
|
79
|
+
*/
|
|
80
|
+
export declare function unsupportedTypeForm(node: ts.TypeNode, imports: Map<string, string>): string | undefined;
|
|
81
|
+
/** The members of a struct's declaration: the interface's, or the object type's (`type P = { … }`). */
|
|
82
|
+
export declare function structMembers(decl: StructDecl): ts.NodeArray<ts.TypeElement>;
|
|
74
83
|
export { isScalar };
|