@typesol/cli 0.48.0 → 0.49.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 CHANGED
@@ -6,6 +6,165 @@ codes, and says so here.
6
6
 
7
7
  ## Unreleased
8
8
 
9
+ ## 0.49.0 — 2026-11-16
10
+
11
+ A minor release: it adds a port of Percolator v12.20 (all 27 instructions, compared with the immutable mainnet build)
12
+ and the built-ins it needed (`log64`, `zeroData`, `PANIC_STYLE = "solana-1.18"`, `executable` on a remaining account),
13
+ changes lamport writes on remaining accounts under `NATIVE_ACCOUNT_WRITES`, and fixes two example programs
14
+ (`examples/airdrop.ts`, `examples/minter.ts`) that let any caller take an authority. Programs that compiled with 0.48.0
15
+ and still compile build to the same bytes, except those two examples, whose sources changed.
16
+
17
+ - Changed: under `NATIVE_ACCOUNT_WRITES`, a write to a remaining account's `.lamports` is a native program's
18
+ `**a.lamports.borrow_mut() = v`: no writability check (3006) and no refusal of an account passed more than once
19
+ (2040); an account passed twice is one record, and the runtime judges the change when the instruction ends. Programs
20
+ without the flag build as before, and so does every program in the golden manifest
21
+ (test/language/native-lamports.test.ts; docs/language-native.md).
22
+ - Showcase, Percolator: mutation fuzzers against the mainnet binary (`showcase/test/percolator-mutate-*.test.ts`):
23
+ the account list, the instruction data, the environment (several instructions per transaction, a relay at stack
24
+ height 2, low compute-unit limits, Clock and oracle extremes) and the slab's every field, from valid transactions of
25
+ all 27 instructions in eleven market states, each compared byte for byte; and the failure sites a review found
26
+ without a test, reached on purpose (`percolator-sites.test.ts`). Four differences they found are fixed, each kept as
27
+ a named case (`percolator-regressions.test.ts`): CloseSlab with the slab or the admin again in its unused fifth
28
+ position (the port failed with 2040, the original succeeds), a matcher shrinking its context below 64 bytes during
29
+ TradeCpi (InvalidAccountData before any field is read), a TradeCpi tail long enough to exhaust the original's 32 KiB
30
+ heap before the matcher call (the allocator's "out of memory" and abort, now reproduced from the same byte count),
31
+ and the funding rate of a config only patching can make (`i128::clamp`'s assertion panic and `saturating_mul`).
32
+ SetOraclePriceCap changes the config in place (on a Hyperp market it had cost about as much as the original's).
33
+ - Showcase, Percolator: the compute-unit tables re-measured on the current build (363,392 bytes): on the same
34
+ transactions every instruction's mean and largest figure is the earlier build's or lower (SetOraclePriceCap 606 on
35
+ average, from 1,696), each keeper crank of the account-count table costs one unit more, and all stay below the
36
+ original. New differential tests: TradeCpi's tail with signers and writable accounts as the matcher sees them, the
37
+ per-side cap on active positions with real trades, the ADL edges (K without headroom, precision exhausted, a crank
38
+ stopping on a pending reset; the first two only on a slab written in, as no instruction reaches them), and TradeCpi's
39
+ path after the matcher call on nearly full heaps, through a test matcher that takes any tail. One difference found
40
+ and pinned: a panic after the call where the original's heap can no longer hold the formatted panic line (a tail at
41
+ the last length or two the heap holds and a slab written in) logs the allocator's out-of-memory error in the
42
+ original and the panic line in the port; the outcome and every account are the same.
43
+ - Showcase, Percolator: mutation testing of the differential tests. 196 hand-chosen mutants of the port's source (every
44
+ file, 63 in rarely-run paths such as ADL, bad debt past insurance, the resolved wind-down, Hyperp and Chainlink), each
45
+ rebuilt and run against the sixteen test files: 140 killed as the tests stood, 22 equivalent (the reasons in
46
+ the port README), 34 gaps, each now covered by a new differential test in the fitting file and killed (boundaries hit
47
+ exactly, such as the margins, the catch-up envelopes, the deviation band and the deposit cap, and states only a
48
+ written slab has). The new tests found no difference from the mainnet binary. The default run's count now covers all
49
+ sixteen files: 139,185 compared transactions, 33,590 successful under both.
50
+
51
+ - Changed: an account of another type passed where a remaining account or an `AccountInfo` is taken (`programAt`,
52
+ `sysvarAt`, `zeroData`) is now refused by TypeScript (a `RemainingAccount` has `executable`), with the hint "pass a
53
+ remaining account (remainingAccounts().get(i)) or an AccountInfo parameter; a declared parameter of a program or
54
+ sysvar type is used as it is"; the compiler's own message said the same before.
55
+ - Added: `log64(a, b, c, d, e)`, Rust's `sol_log_64` (the runtime writes the five u64s as lowercase hex on one line);
56
+ `zeroData(account, offset, length)`, a memset of account data by the syscall, as a native program's
57
+ `for b in data.iter_mut() { *b = 0 }` compiles (about constant compute units for 1.5 MB); and
58
+ `PANIC_STYLE = "solana-1.18"`, panics logged as solana-program 1.18's handler logs them since rustc 1.73
59
+ (`panicked at <file>:<line>:<col>:` and the message on the next line, then abort). The lines are checked against
60
+ Percolator v12.20's mainnet binary (test/language/native-log64-zero.test.ts; docs/language-native.md). Existing
61
+ programs build to the same bytes.
62
+ - Showcase: the first stage of a port of Percolator v12.20, `showcase/mainnet/percolator/` (Apache-2.0; educational,
63
+ not audited, not for real funds, as the original says), the immutable mainnet program
64
+ `BCGNFw6vDinWTF9AybAbi8vr69gx5nk5w8o2vEWgpsiw` built from aeyakovenko/percolator-prog `06f86fb` and the engine
65
+ aeyakovenko/percolator `3f55f87` (sha256 `502088e9…cc93`, 395,368 bytes; fetched by `scripts/fetch-programs.sh`, not
66
+ kept here). This stage has 15 of its 27 instructions (market creation and configuration, the authorities, account
67
+ creation, deposits, withdrawals, settles, closes on live markets, reclaims, insurance top-ups, fee credits, CloseSlab)
68
+ and the foundation the rest builds on: the 1,525,624-byte slab byte for byte (u128 aligned to 8, as the SBF binary
69
+ lays it out), the engine's 256-bit arithmetic, the oracle readers, accrual, warm-up and fees. Each transaction goes to
70
+ the port and to the mainnet binary, which must agree on outcome, error code, log lines, inner instructions, return
71
+ data and every account's bytes, in five test files and a seeded fuzz of account sequences (README there).
72
+ - Added: `executable` on a remaining account (`rest.get(i).executable`, Rust's `AccountInfo::executable`), as a native
73
+ program checks a program passed among its accounts before calling it (test/language/remaining-executable.test.ts;
74
+ docs/language-accounts.md). Existing programs build to the same bytes.
75
+ - Showcase: the second stage of the Percolator v12.20 port: TradeNoCpi, TradeCpi and ConvertReleasedPnl (18 of 27
76
+ instructions), with the engine's trade (trade PnL, positions attached at the side's indices, the open-interest
77
+ decomposition, trading fees, the margin rules, warm-up of trade profit) and the conversion of released PnL with its
78
+ haircut. TradeCpi calls a matcher: no build of the author's is deployed for v12.20, so the tests run a TypeSOL port of
79
+ aeyakovenko/percolator-match 199b139 (Apache-2.0, a test fixture) under both the mainnet binary and the port. Tests
80
+ that wrote positions into the slab now trade; a fuzz of trade sequences between many users and LPs runs against the
81
+ binary. The port spends fewer compute units than the original on every successful transaction measured, SettleAccount
82
+ included (it no longer copies the 400-byte config twice where nothing reads it in between, and zeroes its instruction
83
+ context with the memset syscall). verify_token_program now checks the token program is executable, as the original
84
+ does.
85
+ - Showcase: the third stage of the Percolator v12.20 port: KeeperCrank, LiquidateAtOracle and CatchupAccrue (21 of 27
86
+ instructions), with the engine's liquidation (full close and the crank's exact partial, the liquidation fee, bad
87
+ debt), `enqueue_adl` (insurance first, then the loss written into the opposite side's K, A shrunk pro rata, drain-only
88
+ sides, side resets with stale accounts settled at the frozen indices), the crank's candidate handling and hint
89
+ validation, the maintenance-fee sweep with its cursor and dust reclaim, the crank reward and the risk buffer's upkeep,
90
+ and complete and partial catch-ups of the market clock. Tests that wrote drain-only and reset-pending sides, a flat
91
+ account with a loss past its capital and the sweep's fee debt into the slab now reach them with liquidations and
92
+ cranks; a second fuzz walk (leveraged trades, crashes, liquidations, cranks) socialises losses and runs side resets
93
+ to their end against the binary. KeeperCrank's compute units are measured at 2 to 4,096 accounts: the port completes
94
+ every crank the original does within the same limit, and 64 liquidations in one crank, which exceed the original's
95
+ 1.4M units, in about 660,000. The port spends fewer compute units than the original on every successful transaction
96
+ measured (18,713 in the two fuzz walks).
97
+ - Showcase: the fourth stage completes the Percolator v12.20 port (27 of 27 instructions): ResolveMarket,
98
+ ResolvePermissionless, ForceCloseResolved, AdminForceCloseAccount, CloseAccount's resolved arm, WithdrawInsurance and
99
+ WithdrawInsuranceLimited, with the engine's resolution (the ordinary arm with its catch-up and deviation band, the
100
+ degenerate arm at the last price for a dead oracle, a silent Hyperp mark or the hard timeout, terminal K deltas kept
101
+ apart from K, every position stale under a new epoch), the reconciliation of resolved accounts, terminal readiness,
102
+ the payout haircut snapshot and the terminal close (fee debt forgiven, the surplus swept into insurance), and the
103
+ bounded insurance withdrawals (bps cap, 10-unit floor, cooldown). Tests that wrote a resolved market into the slab
104
+ now resolve it, and CloseSlab's insurance and stranded-token cases come from real instructions; only states no
105
+ instruction can make are still written in (README there). Both fuzz walks now end each market's life: resolution by
106
+ the admin or by anyone, every account closed out in random order, the insurance withdrawn, the slab closed, and the
107
+ vault and every token account compared at the end (80 full life cycles in a 40-seed run of each walk). The port spends fewer compute units than
108
+ the original on every successful transaction measured (20,225 in the two fuzz walks) and its binary is
109
+ 360,248 bytes against 395,368 (363,392 bytes after the later fixes).
110
+ - Showcase: the Percolator author's own LiteSVM test suite (aeyakovenko/percolator-prog `06f86fb`, engine `3f55f87`)
111
+ run unchanged against the mainnet binary and against the TypeSOL port: 660 tests pass and 11 are ignored under both,
112
+ with the same outcome for every test (609 of them run the program; the rest test the Rust crates on the host); the
113
+ 11 ignored ones, run too, also agree (4 pass, 7 fail at the same assertions). The TradeCpi tests use the TypeSOL
114
+ matcher fixture under both. `scripts/percolator-author-suite.sh` reproduces it (host build only, downloads nothing);
115
+ counts per file and the author's compute-unit benchmark in the port README.
116
+ - Showcase: the Percolator port's checks made stricter, and what they found. Every test now fails a successful
117
+ transaction with a Percolator instruction at the top level unless the port used fewer compute units than the
118
+ original (the differential harness asserts it for every test file, the keeper-crank measurements included; only the
119
+ matcher's own Init and SPL Token transfers, identified by program id, are exempt). A new fuzz walk runs whole market
120
+ life cycles on Chainlink feeds, inverted markets, Pyth feeds at other exponents with the confidence at its limit, and
121
+ Hyperp markets (40 life cycles in a 10-seed run, no divergence). A test matcher logs the slab as it stands during
122
+ TradeCpi's call (the same in both). Two
123
+ divergences found and fixed in the port: the slab passed again where the original holds its mutable borrow across an
124
+ SPL Token call (a user or admin signing with the slab's keypair, or the slab as CloseSlab's vault authority) failed
125
+ the original with AccountBorrowFailed and succeeded in the port; and the trade's per-side position cap, which the
126
+ original counts in i64, gave another error for counts of 2^63 and more (a patched slab only). One difference on a
127
+ patched slab remains and is pinned in a test (a free-list index past the 4,096 slots: Rust's bounds-check panic
128
+ against TypeSOL's). `scripts/percolator-author-suite.sh` now fails on a test file that does not build or run, on
129
+ totals other than the recorded 671 / 660 / 0 / 11, and on test names that differ between the two runs.
130
+
131
+ - Fixed: `examples/airdrop.ts` let the admin of any pot award points to any `Member`: anyone could set up a pot of
132
+ their own and pass other pots' members to `award`. A member now records its pot (`Member.pot`, PDA
133
+ `["member", pot, owner]`, `join` takes the pot), and `award` refuses a member of another pot (`WrongPot`, 6002).
134
+ - Fixed: `examples/minter.ts` let anyone set up the config of any mint, choosing its admin and cap, for example before
135
+ the mint's owner did. `setup` now takes the mint's current mint authority as the signer (`HasOne<Mut<Mint>,
136
+ "mintAuthority">`, 2016), makes it the admin and moves the mint authority to the config PDA in the same instruction,
137
+ with the token program as a new account. Both examples' binaries and IDLs change; neither is in
138
+ `test/golden/binaries.json`. Tests: test/examples/airdrop.test.ts, test/examples/minter.test.ts (the attacks fail,
139
+ the honest paths work).
140
+ - Docs: the `grow` example of docs/language-accounts.md let anyone resize another user's account; it now takes the
141
+ log's owner (`HasOne`).
142
+ - Docs: claims narrowed to what the tests and benchmarks show. The ports: the same outcome, events, return data and
143
+ account bytes on every compared transaction, and the same error codes and log lines except where each case study
144
+ says (Anchor error-message text, panics reported as numbered errors, Marginfi's informational `msg!` lines, CLMM's
145
+ reward-mint order); Phoenix, Raydium AMM v4, SPL Stake Pool and Percolator match every log line. Compute units:
146
+ fewer than native Rust on every instruction measured, fewer than Pinocchio on counter, vault and escrow, and more
147
+ than Pinocchio on 13 of the 26 instructions of the official examples (a sentence `scripts/readme-bench.ts` now
148
+ writes from `official`). Review status: 0.45.0 to 0.48.0 and the unreleased work have had no security review (README,
149
+ SECURITY.md, docs/audit.md, docs/security-model.md), `runtime/typesol_builtins.c` is in the audit scope table and in
150
+ docs/runtime.md, and `EVENT_AUTHORITY_CHECK` is listed as experimental and in the `emitCpi` guarantee. Transaction
151
+ counts are what a default run compares, with breakdowns per file: Marginfi 2,321 (it said 2,081), Raydium AMM v4 144
152
+ with 60 random steps (it said 484, at 400 steps), SPL Stake Pool 2,107 in five files (it said six), coral-xyz/multisig
153
+ 55 (it said 52), Percolator 139,185 in its sixteen files, 3,711 of them in its fixed-seed walks and 128,320 from its
154
+ mutation fuzzers (it said 6,028, the first ten files). The cross-host measurement is the one made with
155
+ 0.45.0 over the 76 programs of its sources; Meteora DBC and Percolator are not in `test/golden/binaries.json`. Also:
156
+ every fuzzer and how it is seeded (docs/testing.md, docs/audit.md), the manifest's `showcase/mainnet` programs and the
157
+ release record's `"tests"` field, what `pnpm fetch:programs` fetches, the mainnet escrow as a benchmark record and
158
+ what its make_offer spends in the ATA program, the escrow case study's figures from the 0.48.0 run, the licence of the
159
+ Meteora port's tests and fixtures, and `llms.txt` listing every port. The destructuring example of
160
+ docs/language-statements.md let anyone overwrite another player's account; it now requires its owner's signature.
161
+ - Showcase: `showcase/mainnet/meteora-dbc/README.md` describes the finished port (released in stages in 0.48.0): Meteora
162
+ Dynamic Bonding Curve 0.2.2, all 35 instructions, with its migrations into DAMM v1 and DAMM v2, checked against the
163
+ mainnet binary on outcome, error code, account bytes, inner instructions, events and return data (log text and
164
+ compute units not compared). The port, its tests (`showcase/test/meteora-dbc*.ts`) and their fixtures
165
+ (`showcase/test/fixtures/meteora-dbc/`) are under Meteora's Non-commercial Licence (NOTICE), which README.md and
166
+ LICENSE now say.
167
+
9
168
  ## 0.48.0 — 2026-11-14
10
169
 
11
170
  A minor release: it adds three built-ins (`transferCheckedWithHook`, the processed sibling instructions,
@@ -128,7 +287,6 @@ and still compile build to the same bytes.
128
287
  which needs `@anchor-lang/core`, and did not see `emitCpi` events. `t.coder` does not change. TypeSOL's Borsh coder
129
288
  decodes events as Anchor's `coder.events.decode` does (test/client/idl-coder.test.ts compares the two on random
130
289
  values for every program with events, and on a wrong discriminator, which both decode as null).
131
-
132
290
  - Changed, now refused: a call of a helper that returns the result of `merkleVerify`, `verifyEd25519` or
133
291
  `verifySecp256k1` whose result decides nothing. 0.46.0 refused such a call of the three themselves (as a statement,
134
292
  as the condition of an `if` with an empty body, kept in a local never read) but compiled the same through a helper,
package/NOTICE CHANGED
@@ -83,12 +83,19 @@ Third-party material in this repository only (not in the published package)
83
83
  - showcase/mainnet/meteora-dbc/: a TypeSOL port of Meteora's Dynamic Bonding Curve (MeteoraAg/dynamic-bonding-curve,
84
84
  release 0.2.2, commit 91e696e), with its tests showcase/test/meteora-dbc*.ts and the mainnet accounts of two of its
85
85
  pools, the seven DAMM v2 migration configs, the six DAMM v1 migration configs and the wrapped SOL dynamic vault those
86
- tests read (showcase/test/fixtures/meteora-dbc/; DAMM v2 is under the Meteora Noncommercial Licence too, the licences
86
+ tests read (showcase/test/fixtures/meteora-dbc/; DAMM v2 is under the Meteora Non-commercial Licence too, the licences
87
87
  of DAMM v1 and the dynamic vault are not established). It is not under this repository's MIT
88
88
  licence: it is subject to Meteora's Non-commercial Licence, whose text is showcase/mainnet/meteora-dbc/LICENSE.md.
89
89
  Required Notice: All underlying software code is subject to the licence set out at https://github.com/MeteoraAg/dynamic-bonding-curve
90
90
  The program's mainnet binary is not kept here either, nor are those of DAMM v2, the locker, DAMM v1 and the dynamic
91
91
  vault its migrations call:
92
92
  scripts/fetch-programs.sh downloads them (test/programs/SOURCES.md).
93
+ - showcase/mainnet/percolator/: a TypeSOL port of Percolator v12.20, the program aeyakovenko/percolator-prog
94
+ (commit 06f86fb) with its risk engine aeyakovenko/percolator (commit 3f55f87), Copyright Anatoly Yakovenko,
95
+ Apache-2.0 (the licence text is test/programs/LICENSE-Apache-2.0.txt), with its tests showcase/test/percolator*.ts.
96
+ Changes: rewritten in TypeSOL. The original's own warning stands for the port: an educational research project, not
97
+ audited, not for use with real funds. Its mainnet binary is not kept here: scripts/fetch-programs.sh downloads it
98
+ (test/programs/SOURCES.md). showcase/mainnet/percolator/matcher/ is a TypeSOL port of the matcher TradeCpi calls,
99
+ aeyakovenko/percolator-match (commit 199b139), Copyright Anatoly Yakovenko, Apache-2.0, kept as a test fixture.
93
100
  - showcase/program-examples/: ports of solana-developers/program-examples (MIT, Copyright Solana Foundation; the
94
101
  licence text is in showcase/program-examples/README.md).
package/README.md CHANGED
@@ -32,17 +32,22 @@ clients read TypeSOL programs unchanged.
32
32
  - Every arithmetic operation is checked.
33
33
  - Account owner, discriminator, signer, writability and aliasing checks are generated from your parameter types.
34
34
  - Constraints follow Anchor's rules and use Anchor's error codes.
35
- - **Small and fast.** In the LiteSVM benchmarks below, TypeSOL uses 5–32% of Anchor's compute units, with binaries
36
- about 10× smaller, and fewer compute units than native Rust and hand-tuned Pinocchio on every instruction. On
37
- mainnet the results differ by instruction; see [the mainnet table](#on-mainnet).
38
- - **Checked against mainnet.** Eight deployed programs are ported in full, among them Marginfi v2, Phoenix v1 and
39
- SPL Stake Pool, and run beside the original binaries: the same outcomes, log lines, events and account bytes on
40
- thousands of transactions, for fewer compute units ([the ports](#ported-and-checked-against-mainnet-binaries)).
35
+ - **Small and fast.** In the counter, vault and escrow benchmarks below, TypeSOL uses 5–32% of Anchor's compute units,
36
+ with binaries about 10× smaller, and fewer compute units than native Rust and hand-tuned Pinocchio on every
37
+ instruction. On 17 official example programs it uses fewer than Anchor and native Rust on every instruction, and
38
+ more than their Pinocchio versions on 13 of the 26 ([Numbers](#numbers)). On mainnet the results differ by
39
+ instruction; see [the mainnet table](#on-mainnet).
40
+ - **Checked against mainnet.** Nine ports of deployed programs (eleven programs: Jito MEV's row is three), among them
41
+ Marginfi v2, Phoenix v1 and SPL Stake Pool, run beside the original binaries: the same outcomes, events, return data
42
+ and account bytes on thousands of transactions, and the same error codes and log lines but for the exceptions each
43
+ case study lists, for fewer compute units ([the ports](#ported-and-checked-against-mainnet-binaries)).
41
44
  - **Verifiable.** `typesol verify` reads a deployed program from the cluster and checks it, and the IDL published on
42
- chain, against its source. Every release records the hashes of its npm tarball and of every program it builds
43
- ([releases/](releases), [docs/testing.md](docs/testing.md#reproducing-a-release)).
45
+ chain, against its source. Every release records its npm tarball in `releases/<version>.json` ([releases/](releases)),
46
+ and the hashes of every program it builds in its GitHub Release's `typesol-<version>-manifest.json`
47
+ ([docs/testing.md](docs/testing.md#reproducing-a-release)).
44
48
  The same source, TypeSOL version and toolchain build to the same bytes on macOS arm64, Linux arm64 and Linux x86_64
45
- (measured: all 76 programs of the sources for SBPF v0, 14 of them for v1 and v2; Linux arm64 with the platform-tools
49
+ (measured with 0.45.0: all 76 programs then in the sources for SBPF v0, 14 of them for v1 and v2; programs added
50
+ since, the Meteora DBC and Percolator ports among them, were not in that measurement; Linux arm64 with the platform-tools
46
51
  `linux-aarch64` package set up as in [Requirements](#requirements), since there is no Agave CLI for it;
47
52
  [docs/stability.md](docs/stability.md#what-builds-the-same-bytes-where)).
48
53
  `typesol build --docker` builds in a pinned linux/amd64 container that anyone can rebuild from the Dockerfile, and
@@ -65,34 +70,53 @@ Node.js and the Solana toolchain are in place ([Quick start](#quick-start), [Req
65
70
  ## Ported and checked against mainnet binaries
66
71
 
67
72
  Each port is the whole program, written in TypeSOL from the original's source. Its tests send every transaction to
68
- the port and to the binary deployed on mainnet, both in LiteSVM, and require the same outcome, error, log lines,
69
- events, return data and bytes in every account; the port must also use fewer compute units on every transaction that
70
- succeeds. A case study for each says what was compared and what was not.
73
+ the port and to the binary deployed on mainnet, both in LiteSVM, and require the same outcome, events, return data and
74
+ bytes in every account the transaction names, and the same error code and log lines, with the exceptions each case
75
+ study lists. Of those, the kinds that recur:
76
+
77
+ - **Error-message text.** The Anchor ports log their errors in TypeSOL's words, with Anchor's codes; Jito's also leaves
78
+ out Anchor's `Instruction: …` lines.
79
+ - **Panics.** Where the original panics, Marginfi, Raydium CLMM, Raydium CP-Swap and Jito MEV fail with a numbered
80
+ error, and Marginfi also answers a few runtime errors that carry no code (`AccountBorrowFailed`, `BorshIoError`)
81
+ with numbered ones; the tests require that both fail.
82
+ - **Informational logs.** Marginfi writes only the original's `WARN` lines, of about 160 `msg!` lines.
83
+ - **Raydium CLMM's reward mints**, kept in the order added, so `OperationState`'s bytes differ when two or more are
84
+ listed.
85
+ - **Compute.** A Percolator keeper crank that exceeds the compute budget in the original completes in the port.
86
+
87
+ Phoenix v1, Raydium AMM v4, SPL Stake Pool and Percolator match every log line of the compared transactions, panics
88
+ included, except the runtime's compute-unit lines. The port must also use fewer compute units on every transaction that succeeds. A case study for
89
+ each (for Percolator, the port's README) says what was compared and what was not.
71
90
 
72
91
  | Program | Kind | Instructions | Transactions compared |
73
92
  | --- | --- | ---: | ---: |
74
- | [Marginfi v2](docs/case-study-marginfi.md) | Anchor, lending | 124 | 2,081 |
93
+ | [Marginfi v2](docs/case-study-marginfi.md) | Anchor, lending | 124 | 2,321 |
75
94
  | [Phoenix v1](docs/case-study-phoenix.md) | native, limit order book | 28 | 3,575 |
76
95
  | [SPL Stake Pool](docs/case-study-spl-stake-pool.md) | native, liquid staking | 27 | 2,107 |
77
96
  | [Raydium CLMM](docs/case-study-raydium-clmm.md) | Anchor, concentrated liquidity | 37 | 302 |
78
97
  | [Raydium CP-Swap](docs/case-study-raydium-cp-swap.md) | Anchor, constant product | 21 | 136 |
79
- | [Raydium AMM v4](docs/case-study-raydium-amm.md) | native, constant product | all | 484 |
98
+ | [Raydium AMM v4](docs/case-study-raydium-amm.md) | native, constant product | all | 144 (60 random steps) |
80
99
  | [Jito MEV](docs/case-study-jito-mev.md) | Anchor, three programs | 24 | 150 |
81
- | [coral-xyz/multisig](docs/case-study-multisig.md) | Anchor | all | 52 |
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
+ | [coral-xyz/multisig](docs/case-study-multisig.md) | Anchor | all | 55 |
82
102
 
83
- A ninth port is held to a narrower comparison and is not counted above:
103
+ A tenth port is held to a narrower comparison and is not counted above:
84
104
  [Meteora Dynamic Bonding Curve 0.2.2](showcase/mainnet/meteora-dbc) (Anchor, launchpad, all 35 instructions, with its
85
- migrations into DAMM v1 and DAMM v2). Outcomes, error codes, account bytes, events and return data are the same as the
86
- mainnet binary's; log text and compute units are not compared. That directory is under Meteora's Non-commercial
87
- Licence, not this repository's (see its README).
88
-
89
- Random walks with fixed or printed seeds run on top of these counts ([docs/testing.md](docs/testing.md)). The
105
+ migrations into DAMM v1 and DAMM v2). Outcomes, error codes, account bytes, inner instructions (its events are
106
+ self-CPIs) and return data are compared as for the ports above, with the exceptions its README lists; of the log only
107
+ the events' `Program data:` lines are compared, not the rest of its text, and compute units are not compared. The
108
+ port, its tests (`showcase/test/meteora-dbc*.ts`) and their fixtures (`showcase/test/fixtures/meteora-dbc/`) are under
109
+ Meteora's Non-commercial Licence, not this repository's (see [NOTICE](NOTICE)).
110
+
111
+ Each count is what a default test run compares, with the fetch-only binaries present (`pnpm fetch:programs`). Random
112
+ walks, with fixed or printed seeds, run on top of the other ports' counts ([docs/testing.md](docs/testing.md)); the
113
+ multisig port has none. The
90
114
  sources are in [`showcase/mainnet`](showcase/mainnet), and where each original binary comes from is recorded in
91
115
  [test/programs/SOURCES.md](test/programs/SOURCES.md).
92
116
 
93
117
  ## At a glance
94
118
 
95
- **`counter.ts`**: a complete program, 23 lines. (`typesol init` writes it with one more instruction, a read-only
119
+ **`counter.ts`**: a complete program, 23 non-blank lines. (`typesol init` writes it with one more instruction, a read-only
96
120
  `assertAtLeast`.)
97
121
 
98
122
  ```ts
@@ -126,7 +150,7 @@ export function increment(authority: Signer, counter: Mut<Counter>, by: u64): vo
126
150
  ```
127
151
 
128
152
  <details>
129
- <summary><b>The same program in Anchor</b>: 44 lines of Rust</summary>
153
+ <summary><b>The same program in Anchor</b>: 44 non-blank lines of Rust</summary>
130
154
 
131
155
  ```rust
132
156
  #[program]
@@ -264,9 +288,9 @@ the same.
264
288
  `typesol port` starts from your program's IDL; [docs/case-study-escrow.md](docs/case-study-escrow.md) follows one
265
289
  program through the port.
266
290
  - Real programs checked against their mainnet binaries: [Showcase](https://github.com/typesol-lang/typesol#showcase-ports-checked-against-mainnet), with a
267
- case study each (Marginfi v2 in full: all 124 instructions, the same on 2,081 transactions; Phoenix v1, a native
268
- order book, the same on 3,575 transactions down to its event bytes; Raydium AMM v4, a native program, down to its log
269
- lines).
291
+ case study each (Marginfi v2 in full: all 124 instructions, 2,321 transactions with the same outcomes, events and
292
+ account bytes; Phoenix v1, a native order book, the same on 3,575 transactions down to its event bytes and log lines;
293
+ Raydium AMM v4, a native program, down to its log lines).
270
294
  - To mainnet (wallet, cost, deploy, IDL, verification): [docs/mainnet.md](docs/mainnet.md).
271
295
  - With an AI coding agent: [docs/ai.md](docs/ai.md) (agent rules, [llms.txt](https://typesol.com/llms.txt), the MCP server).
272
296
 
@@ -287,7 +311,7 @@ counter.ts ─▶ tsc typecheck ─▶ subset check ─▶ C + typesol_rt.h ─
287
311
  `--sbpf`).
288
312
 
289
313
  Runtime failures point back to your source: `Error 6000 Unauthorized (counter.ts:25)`, or
290
- `TypeSOL: arithmetic overflow (vault.ts:42)`.
314
+ `TypeSOL: arithmetic overflow (vault.ts:44)`.
291
315
 
292
316
  ## What you can write
293
317
 
@@ -367,14 +391,36 @@ CPI account records only for the accounts a call lists. It uses fewer compute un
367
391
  instruction here, while also refusing duplicate writable accounts as Anchor does. Fewer compute
368
392
  units are not a safety claim. The differential tests also run the escrow against its Anchor twin ([docs/testing.md](docs/testing.md)).
369
393
 
394
+ These three programs' Pinocchio versions were written for this comparison.
395
+
396
+ <!-- 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 13 of 26.
398
+ <!-- /bench:official -->
399
+
400
+ Those Pinocchio versions often do less: favorites, close-account and
401
+ program-derived-addresses take the PDA bump from the client instead of searching for it on chain, and pda-rent-payer
402
+ checks the client's bump instead of finding the canonical one; program-derived-addresses' increment checks neither the
403
+ address nor the owner of the account it writes; transfer-sol checks neither that the recipient is a System account nor
404
+ that the paying account of `transfer_sol_with_program` belongs to the program. The notes for each program, and every
405
+ figure, are in the benchmarks' `results.json` (`official`).
406
+
370
407
  ### On mainnet
371
408
 
372
409
  The official escrow ([tokens/escrow](https://github.com/solana-developers/program-examples/tree/de090195e4de698e150572c4f886c333323a64a5/tokens/escrow)),
373
410
  deployed to Solana mainnet-beta in all four versions and called with the same mints, amounts and accounts, one
374
411
  instruction per transaction. The TypeSOL program was upgraded in place to 0.25.0 on 2026-10-29; the others are as first
375
412
  deployed on 2026-10-27. Each figure is the compute units of that transaction, linked to Solscan; the lowest per row is
376
- in bold. The deployed programs match their builds byte for byte (`typesol verify` for TypeSOL; that is the 0.25.0 build, not the current release), and the TypeSOL
377
- program's IDL is published on chain with `typesol idl publish`.
413
+ in bold. The TypeSOL program was checked against its source with `typesol verify` (it is the 0.25.0 build, not the
414
+ current release) and its IDL is published on chain with `typesol idl publish`; the Pinocchio, native Rust and Anchor
415
+ programs are the benchmarks' builds, and this record does not check them byte for byte against those builds.
416
+
417
+ These four programs are a benchmark record, not a service: the maintainers' own keys made every offer and took or
418
+ refunded each one in the runs recorded, so no offer is open and they hold no one's tokens. The TypeSOL one predates
419
+ the defects fixed in 0.44.0 and 0.44.1 (see [Status](#status)); its source,
420
+ [`showcase/program-examples/tokens/escrow.ts`](showcase/program-examples/tokens/escrow.ts) (the same at 0.25.0, then
421
+ `test/ports/tokens/escrow.ts`), uses none of the constructs those defects need: no helper functions, closures,
422
+ `Dup<…>` or loaded accounts, seed lists written in place at each call, token wrapper arguments that are plain reads,
423
+ and no `transferFee` or `updateExtraAccountMetas`.
378
424
 
379
425
  | Transaction | TypeSOL | Pinocchio | Native Rust | Anchor |
380
426
  | --- | ---: | ---: | ---: | ---: |
@@ -385,26 +431,33 @@ program's IDL is published on chain with `typesol idl publish`.
385
431
  | escrow program's own part, 4 transactions | **28,118** | 36,956 | 93,273 | 102,926 |
386
432
  | program | [65ybkcg6…](https://solscan.io/account/65ybkcg6mQa9t5EuHtirRdvf2qAu12qRiK6wYBbGk16P) | [FrQwq3iU…](https://solscan.io/account/FrQwq3iUa8ZkWEne1y27webXTAyLgH4Hj6t986t6VS2G) | [5pnmi1Md…](https://solscan.io/account/5pnmi1MdxzXKmgX7ooRSE212rzZK8rb7nNpRTSMqP8V1) | [EG7M3sLL…](https://solscan.io/account/EG7M3sLLwB7MhmtzwYsaxbhZaFDbshL9hmVK79bQVyVq) |
387
433
 
388
- Most of make_offer is the Associated Token Account program creating the vault. It searches for the vault address's
389
- bump itself at 1,500 CU a try, and every offer has its own vault, so that part varies from offer to offer in every
390
- version (13,585 to 22,585 CU of the make_offers above); programs that check the vault's address re-derive it, so
391
- take_offer and refund_offer vary with it too. The escrow program's own part is steadier: TypeSOL's make_offer spent
392
- 6,620 CU of its own on both offers. The Pinocchio version takes the offer PDA's bump from the client instead of
434
+ In make_offer the Associated Token Account program creates the vault: 13,480 to 22,480 CU of the make_offers above
435
+ (13,585 to 22,585 with the token transfer after it). That is most of the TypeSOL and Pinocchio make_offers (67–77%)
436
+ and about a third to a half of the native Rust and Anchor ones (35–46%), whose own part is larger (15,543 to 29,043
437
+ CU). The ATA program searches for the vault address's bump itself at 1,500 CU a try, and every offer has its own
438
+ vault, so that part depends on the offer (13,510 CU for both of Anchor's, 13,480 and 22,480 for TypeSOL's); programs
439
+ that check the vault's address re-derive it, so take_offer and refund_offer can vary with it too. The escrow
440
+ program's own part is steadier: TypeSOL's make_offer spent 6,620 CU of its own on both offers. The Pinocchio version takes the offer PDA's bump from the client instead of
393
441
  searching for it. Mainnet figures differ from the LiteSVM means above. Every run, including the one before the
394
442
  upgrade, is in [typesol-lang/benchmarks](https://github.com/typesol-lang/benchmarks) (`results/`).
395
443
 
396
444
  ## How it is tested
397
445
 
398
- - **Execution tests.** Every feature is compiled and run in LiteSVM.
399
- - **Diagnostics tests.** Every rejected construct is covered.
400
- - **Golden tests.** The generated C is compared with golden output.
446
+ - **Execution tests.** Programs that use each language feature are compiled and run in LiteSVM (`test/language/`,
447
+ `test/examples/`, `test/integrations/`, `test/security/`), and every complete example of the language guide must
448
+ compile (`test/language/docs-examples.test.ts`).
449
+ - **Diagnostics tests.** Refused constructs are tested with the message they get (`test/language/diagnostics.test.ts`,
450
+ and every row of the guide's "What is refused" table).
451
+ - **Golden tests.** The generated C of the counter and the generated clients of two programs are compared with golden
452
+ output (`test/golden/`), and CI rebuilds 14 programs on Linux x86_64 to the bytes the reference container gives
453
+ (`test/golden/binaries.json`).
401
454
  - **Randomized tests** against independent oracles:
402
455
  - Arithmetic at every integer width is checked against BigInt.
403
456
  - Stateful vault, escrow and ledger runs are checked against a TypeScript model.
404
457
  - Differential runs send the same transactions to TypeSOL and to the Anchor twins and compare outcomes, account
405
458
  contents and balances.
406
- - **Ports against mainnet binaries.** The eight ports above run beside the deployed originals, transaction by
407
- transaction, and random walks over them compare every step.
459
+ - **Ports against mainnet binaries.** The nine ports above run beside the deployed originals, transaction by
460
+ transaction, and random walks over eight of them (all but multisig), and over Meteora DBC, compare every step.
408
461
  - **Localnet smoke test.** A script deploys every example to a local validator and drives it end to end; it is run
409
462
  by hand, not in CI.
410
463
 
@@ -417,7 +470,7 @@ Details are in [docs/testing.md](docs/testing.md).
417
470
  | [`counter.ts`](examples/counter.ts) | PDA init, authority check |
418
471
  | [`vault.ts`](examples/vault.ts) | System CPI, direct lamport moves, rent floor, close |
419
472
  | [`escrow.ts`](examples/escrow.ts) | SPL Token CPIs signed by a PDA, atomic swap, refund |
420
- | [`minter.ts`](examples/minter.ts) | capped issuer over SPL Token and Token-2022 |
473
+ | [`minter.ts`](examples/minter.ts) | capped issuer over SPL Token and Token-2022, set up by the mint's authority |
421
474
  | [`ledgerbook.ts`](examples/ledgerbook.ts) | enums, Options, a Vec that grows and shrinks its account |
422
475
  | [`airdrop.ts`](examples/airdrop.ts) | remaining accounts, batch payouts, `loadAccountMut` |
423
476
  | [`relay.ts`](examples/relay.ts), [`caller.ts`](examples/caller.ts) | generic `invoke`, PDA-signed transfers, return data |
@@ -443,6 +496,7 @@ Case studies: [Marginfi v2](docs/case-study-marginfi.md), [Phoenix v1](docs/case
443
496
  | [`spl-stake-pool/`](showcase/mainnet/spl-stake-pool) | SPL Stake Pool in full, all 27 instructions, a native program and the one behind most liquid staking tokens: pools of stake across up to 20,000 validators, SOL and stake deposits and withdrawals, rebalancing over epochs, fees and authorities, token metadata |
444
497
  | [`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 |
445
498
  | [`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
+ | [`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 |
446
500
  | [`multisig.ts`](showcase/mainnet/multisig/multisig.ts) | coral-xyz/multisig: stored instructions run with `invokeInstruction`, a PDA signing, Anchor's Borsh accounts |
447
501
 
448
502
  ## Status
@@ -454,6 +508,11 @@ change.
454
508
  The two latest, of 0.43.0 and 0.44.0 in November 2026, found defects that made a program that compiled behave
455
509
  differently from its source; each is fixed with a test, and [docs/audit.md](docs/audit.md) lists them, what the
456
510
  reviews covered and what they did not. Programs built before 0.44.1 should be rebuilt.
511
+ - 0.45.0 to 0.49.0 have had no security review. They add, among others,
512
+ `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), and `zeroData`, `log64`,
514
+ `PANIC_STYLE = "solana-1.18"`, `executable` on remaining accounts and lamport writes on remaining accounts under
515
+ `NATIVE_ACCOUNT_WRITES` (0.49.0).
457
516
  - 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
458
517
  notes ([SECURITY.md](SECURITY.md#fix-releases)), and the npm tarball is the one packed from the tag and recorded
459
518
  in [releases/](releases).
@@ -502,6 +561,9 @@ built-in, a constraint or an error code. Then read [CONTRIBUTING.md](CONTRIBUTIN
502
561
 
503
562
  ## License
504
563
 
505
- [MIT](LICENSE). The runtime and `typesol/testing` include code ported from MIT and Apache-2.0 projects, and the tests
564
+ [MIT](LICENSE), except the Meteora Dynamic Bonding Curve port: `showcase/mainnet/meteora-dbc/`, its tests
565
+ `showcase/test/meteora-dbc*.ts` and their fixtures `showcase/test/fixtures/meteora-dbc/` are subject to the Meteora
566
+ Non-commercial Licence ([its text](showcase/mainnet/meteora-dbc/LICENSE.md), [NOTICE](NOTICE)), and none of them is in
567
+ the npm package. The runtime and `typesol/testing` include code ported from MIT and Apache-2.0 projects, and the tests
506
568
  use third-party program binaries and data that are not in the npm package: see [NOTICE](NOTICE) and
507
569
  [test/programs/SOURCES.md](test/programs/SOURCES.md).
package/SECURITY.md CHANGED
@@ -8,6 +8,11 @@ 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.49.0 have had no security review. They add, among others,
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), and `zeroData`, `log64`,
14
+ `PANIC_STYLE = "solana-1.18"`, `executable` on remaining accounts and lamport writes on remaining accounts under
15
+ `NATIVE_ACCOUNT_WRITES` (0.49.0).
11
16
  **Rebuild and redeploy programs built before 0.44.1**;
12
17
  [docs/security-model.md](docs/security-model.md#status) gives the status, its sections on each review say how to
13
18
  tell whether a program was exposed, and [docs/audit.md](docs/audit.md#earlier-reviews) what each review did and did
@@ -134,11 +134,13 @@ export declare abstract class EmitterBase {
134
134
  */
135
135
  protected nativeAccountWrites(): boolean;
136
136
  /**
137
- * `const PANIC_STYLE = "solana-1.14"`: a Rust panic logs what solana_program 1.14's panic handler logs (rustc before
138
- * 1.73 formats it as `panicked at '<message>', <file>:<line>:<col>`) and then aborts, so the runtime reports "SBF
139
- * program panicked"; by default it logs the message and calls sol_panic_ with the location.
137
+ * `const PANIC_STYLE = "solana-1.14"` / `"solana-1.18"`: a Rust panic logs what that solana-program's panic handler
138
+ * logs and then aborts, so the runtime reports "SBF program panicked". rustc before 1.73 (solana-program 1.14 to
139
+ * 1.17) formats a panic as `panicked at '<message>', <file>:<line>:<col>`; from 1.73 (solana-program 1.18's toolchain)
140
+ * as `panicked at <file>:<line>:<col>:\n<message>`, one log line holding the newline. By default it logs the message
141
+ * and calls sol_panic_ with the location.
140
142
  */
141
- protected panicStyle(): "solana-1.14" | undefined;
143
+ protected panicStyle(): "solana-1.14" | "solana-1.18" | undefined;
142
144
  /** The C statements of a Rust panic with `message` (undefined: nothing logged) at `location` ("file:line:col"). */
143
145
  protected panicC(message: string | undefined, location: string): string[];
144
146
  /** `file.ts:line:column` of a node (1-based, as Rust reports a location). */
@@ -419,17 +419,23 @@ export class EmitterBase {
419
419
  return this.model.constants.get("NATIVE_ACCOUNT_WRITES")?.value === true;
420
420
  }
421
421
  /**
422
- * `const PANIC_STYLE = "solana-1.14"`: a Rust panic logs what solana_program 1.14's panic handler logs (rustc before
423
- * 1.73 formats it as `panicked at '<message>', <file>:<line>:<col>`) and then aborts, so the runtime reports "SBF
424
- * program panicked"; by default it logs the message and calls sol_panic_ with the location.
422
+ * `const PANIC_STYLE = "solana-1.14"` / `"solana-1.18"`: a Rust panic logs what that solana-program's panic handler
423
+ * logs and then aborts, so the runtime reports "SBF program panicked". rustc before 1.73 (solana-program 1.14 to
424
+ * 1.17) formats a panic as `panicked at '<message>', <file>:<line>:<col>`; from 1.73 (solana-program 1.18's toolchain)
425
+ * as `panicked at <file>:<line>:<col>:\n<message>`, one log line holding the newline. By default it logs the message
426
+ * and calls sol_panic_ with the location.
425
427
  */
426
428
  panicStyle() {
427
- return this.model.constants.get("PANIC_STYLE")?.value === "solana-1.14" ? "solana-1.14" : undefined;
429
+ const v = this.model.constants.get("PANIC_STYLE")?.value;
430
+ return v === "solana-1.14" || v === "solana-1.18" ? v : undefined;
428
431
  }
429
432
  /** The C statements of a Rust panic with `message` (undefined: nothing logged) at `location` ("file:line:col"). */
430
433
  panicC(message, location) {
431
- if (this.panicStyle())
434
+ const style = this.panicStyle();
435
+ if (style === "solana-1.14")
432
436
  return [`sol_log(${cString(`panicked at '${message}', ${location}`)});`, `abort();`, `__builtin_unreachable();`];
437
+ if (style === "solana-1.18")
438
+ return [`sol_log(${cString(`panicked at ${location}:\n${message}`)});`, `abort();`, `__builtin_unreachable();`];
433
439
  const m = /^(.*?):(\d+)(?::(\d+))?$/.exec(location);
434
440
  const [file, line, col] = m ? [m[1], m[2], m[3] ?? "0"] : [location, "0", "0"];
435
441
  return [
@@ -123,7 +123,7 @@ export class CallEmitter extends ExpressionEmitter {
123
123
  this.fail(node, 'panic() takes an optional message (or null to log nothing) and an optional "file:line:column" location: string literals or string constants');
124
124
  const msg = silent ? undefined : args.length ? text(args[0]) : "explicit panic";
125
125
  if (silent && this.panicStyle())
126
- this.fail(args[0], 'under PANIC_STYLE "solana-1.14" a panic logs its message, as solana_program 1.14\'s panic handler always does: pass the message');
126
+ this.fail(args[0], "under PANIC_STYLE a panic logs its message, as solana_program's panic handler always does: pass the message");
127
127
  // The location the runtime reports ("SBF program Panicked in <file> at <line>:<column>"), or the panic line
128
128
  // logs: the given one, as a ported program's panic reports it, else this source line (with its column under
129
129
  // PANIC_STYLE, as Rust always gives one).
@@ -863,6 +863,46 @@ export class CallEmitter extends ExpressionEmitter {
863
863
  this.line(`sol_set_return_data((const uint8_t *)${s.items}, ${s.count});`);
864
864
  return undefined;
865
865
  }
866
+ case "zeroData": {
867
+ // Rust's `for b in data[offset..offset + length].iter_mut() { *b = 0; }` (a memset): the memset syscall, about
868
+ // constant compute units whatever the length, as the original's compiled loop.
869
+ if (args.length !== 3)
870
+ this.fail(node, "zeroData(account, offset, length) takes an account, a byte offset and a length");
871
+ // The length does not change: views of the account made before stay valid (they read the zeros).
872
+ let a = this.handle(args[0]);
873
+ if (a) {
874
+ if (!this.nativeAccountWrites())
875
+ this.line(`TS_TRY(ts_check_writable(${a}));`);
876
+ }
877
+ else {
878
+ const acct = this.accountParam(args[0], "zeroData's account");
879
+ if (acct.kind.kind !== "info" || (!isWritable(acct.kind) && !this.nativeAccountWrites()))
880
+ this.fail(args[0], "zeroData needs a Mut<AccountInfo> parameter or a remaining account");
881
+ a = `a_${acct.name}`;
882
+ }
883
+ const off = this.expect(this.expr(args[1], U64), U64, args[1]);
884
+ const o = this.tmp("off");
885
+ this.line(`uint64_t ${o} = ${off.c};`);
886
+ const len = this.expect(this.expr(args[2], U64), U64, args[2]);
887
+ const n = this.tmp("len");
888
+ this.line(`uint64_t ${n} = ${len.c};`);
889
+ this.line(`if (${o} > ${a}->data_len || ${a}->data_len - ${o} < ${n}) TS_FAIL(TS_ERR_ACCOUNT_TOO_SMALL, "TypeSOL: write past the end of the account data");`);
890
+ this.line(`ts_memzero_bulk(${a}->data + ${o}, ${n});`);
891
+ return undefined;
892
+ }
893
+ case "log64": {
894
+ // Rust's `sol_log_64(a, b, c, d, e)`: the runtime writes "Program log: 0x<a>, 0x<b>, 0x<c>, 0x<d>, 0x<e>" (hex).
895
+ if (args.length !== 5)
896
+ this.fail(node, "log64(a, b, c, d, e) takes five u64 values");
897
+ const vs = args.map((a) => this.expect(this.expr(a, U64), U64, a).c);
898
+ const ts_ = vs.map((v) => {
899
+ const t = this.tmp("l64");
900
+ this.line(`uint64_t ${t} = ${v};`);
901
+ return t;
902
+ });
903
+ this.line(`sol_log_64(${ts_.join(", ")});`);
904
+ return undefined;
905
+ }
866
906
  case "logComputeUnits": {
867
907
  if (args.length)
868
908
  this.fail(node, "logComputeUnits() takes no arguments");
@@ -493,8 +493,10 @@ export class ExpressionEmitter extends StorageEmitter {
493
493
  return { c: `${h}->is_signer`, type: BOOL };
494
494
  case "isWritable":
495
495
  return { c: `${h}->is_writable`, type: BOOL };
496
+ case "executable":
497
+ return { c: `${h}->executable`, type: BOOL };
496
498
  }
497
- this.fail(node.name, `remaining accounts expose key, owner, lamports, dataLen, isSigner and isWritable, not ${field}`);
499
+ this.fail(node.name, `remaining accounts expose key, owner, lamports, dataLen, isSigner, isWritable and executable, not ${field}`);
498
500
  }
499
501
  // A struct loaded with loadAccount / loadAccountMut is also its account: key, lamports, dataLen, isSigner, isWritable.
500
502
  if (ts.isIdentifier(node.expression)) {