@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 +159 -1
- package/NOTICE +8 -1
- package/README.md +103 -41
- package/SECURITY.md +5 -0
- package/dist/compiler/emit/base.d.ts +6 -4
- package/dist/compiler/emit/base.js +11 -5
- package/dist/compiler/emit/calls.js +41 -1
- package/dist/compiler/emit/expressions.js +3 -1
- package/dist/compiler/emit/program.js +4 -4
- package/dist/compiler/emit/storage.js +8 -3
- package/dist/compiler/hints.js +3 -0
- package/docker/deps/0.49.0.lock.json +1206 -0
- package/docs/architecture.md +2 -2
- package/docs/audit.md +30 -14
- package/docs/case-study-escrow.md +7 -5
- package/docs/case-study-marginfi.md +15 -2
- package/docs/case-study-multisig.md +2 -1
- package/docs/case-study-raydium-amm.md +2 -1
- package/docs/case-study-spl-stake-pool.md +4 -3
- package/docs/language-accounts.md +5 -6
- package/docs/language-builtins.md +3 -1
- package/docs/language-errors-events.md +1 -1
- package/docs/language-native.md +23 -3
- package/docs/language-statements.md +3 -2
- package/docs/language.md +2 -2
- package/docs/mainnet.md +1 -1
- package/docs/runtime.md +7 -0
- package/docs/security-model.md +11 -4
- package/docs/stability.md +9 -4
- package/docs/testing.md +16 -4
- package/docs/troubleshooting.md +1 -1
- package/lib/typesol.d.ts +19 -1
- package/llms-full.txt +62 -28
- package/llms.txt +2 -1
- package/package.json +3 -3
- package/releases/0.48.0.json +847 -0
- package/runtime/typesol_rt.h +2 -1
package/lib/typesol.d.ts
CHANGED
|
@@ -240,6 +240,8 @@ export interface RemainingAccount {
|
|
|
240
240
|
readonly dataLen: u64;
|
|
241
241
|
readonly isSigner: boolean;
|
|
242
242
|
readonly isWritable: boolean;
|
|
243
|
+
/** Whether the account is an executable program (AccountInfo::executable). */
|
|
244
|
+
readonly executable: boolean;
|
|
243
245
|
}
|
|
244
246
|
|
|
245
247
|
/**
|
|
@@ -2488,7 +2490,8 @@ export declare enum ProgramError {
|
|
|
2488
2490
|
* own: `panic(null, "src/lib.rs:105:19")` leaves only the runtime's "SBF program Panicked in src/lib.rs at 105:19".
|
|
2489
2491
|
* Under `export const PANIC_STYLE = "solana-1.14"` (a program built with solana-program 1.14 to 1.17) it logs
|
|
2490
2492
|
* `panicked at '<message>', <location>` and aborts, so the runtime reports "SBF program panicked", as that panic
|
|
2491
|
-
* handler does;
|
|
2493
|
+
* handler does; under `"solana-1.18"` (rustc 1.73 and later) it logs `panicked at <location>:` with the message on the
|
|
2494
|
+
* next line, in one log line, and aborts. A message is then required.
|
|
2492
2495
|
*/
|
|
2493
2496
|
export declare function panic(message?: string | null, location?: string): never;
|
|
2494
2497
|
/**
|
|
@@ -2584,6 +2587,21 @@ export declare function setReturnData(bytes: IndexedList<u8>): void;
|
|
|
2584
2587
|
*/
|
|
2585
2588
|
export declare function logComputeUnits(): void;
|
|
2586
2589
|
|
|
2590
|
+
/**
|
|
2591
|
+
* Log five u64 values as Rust's `sol_log_64(a, b, c, d, e)` does: the runtime writes
|
|
2592
|
+
* "Program log: 0x<a>, 0x<b>, 0x<c>, 0x<d>, 0x<e>" (lowercase hex, no padding). For native ports whose original logs
|
|
2593
|
+
* numbers this way.
|
|
2594
|
+
*/
|
|
2595
|
+
export declare function log64(a: u64, b: u64, c: u64, d: u64, e: u64): void;
|
|
2596
|
+
|
|
2597
|
+
/**
|
|
2598
|
+
* Zero `length` bytes of an account's data from `offset`, as a native program's
|
|
2599
|
+
* `for b in data[offset..offset + length].iter_mut() { *b = 0; }` (a memset): the memset syscall, about constant compute
|
|
2600
|
+
* units whatever the length. A remaining account (or a `Mut<AccountInfo>` parameter); past the end of the data fails
|
|
2601
|
+
* with 3003 and writes nothing. Only this program's accounts can change: check the owner first.
|
|
2602
|
+
*/
|
|
2603
|
+
export declare function zeroData(account: RemainingAccount | Mut<AccountInfo>, offset: u64, length: u64): void;
|
|
2604
|
+
|
|
2587
2605
|
/**
|
|
2588
2606
|
* Verify `account.key` is the PDA for `seeds` + `bump` under this program. Any bump that gives a PDA passes (Anchor's
|
|
2589
2607
|
* `bump = expr`): use a stored bump, not one from the arguments, or the caller picks among up to 256 addresses.
|
package/llms-full.txt
CHANGED
|
@@ -108,9 +108,9 @@ the same.
|
|
|
108
108
|
`typesol port` starts from your program's IDL; [docs/case-study-escrow.md](docs/case-study-escrow.md) follows one
|
|
109
109
|
program through the port.
|
|
110
110
|
- Real programs checked against their mainnet binaries: [Showcase](https://github.com/typesol-lang/typesol#showcase-ports-checked-against-mainnet), with a
|
|
111
|
-
case study each (Marginfi v2 in full: all 124 instructions,
|
|
112
|
-
order book, the same on 3,575 transactions down to its event bytes
|
|
113
|
-
lines).
|
|
111
|
+
case study each (Marginfi v2 in full: all 124 instructions, 2,321 transactions with the same outcomes, events and
|
|
112
|
+
account bytes; Phoenix v1, a native order book, the same on 3,575 transactions down to its event bytes and log lines;
|
|
113
|
+
Raydium AMM v4, a native program, down to its log lines).
|
|
114
114
|
- To mainnet (wallet, cost, deploy, IDL, verification): [docs/mainnet.md](docs/mainnet.md).
|
|
115
115
|
- With an AI coding agent: [docs/ai.md](docs/ai.md) (agent rules, [llms.txt](https://typesol.com/llms.txt), the MCP server).
|
|
116
116
|
|
|
@@ -177,9 +177,9 @@ The error codes are in [errors.md](errors.md); what a compiled program checks fo
|
|
|
177
177
|
- `?.` and `!` on anything but optional accounts, Options and a `find` on struct elements.
|
|
178
178
|
- Functions stored in a struct, chosen from a list by index, or returned from an instruction.
|
|
179
179
|
- A fused `map` to strings: store it, annotated.
|
|
180
|
-
- Floating point (by design).
|
|
181
180
|
|
|
182
|
-
They are rejected at compile time rather than half-supported.
|
|
181
|
+
They are rejected at compile time rather than half-supported. Floating-point arithmetic is not planned at all, by
|
|
182
|
+
design: an `f64` is carried only as its bits, in accounts and events ([f64](language-types.md#f64)).
|
|
183
183
|
|
|
184
184
|
## Index of the former sections
|
|
185
185
|
|
|
@@ -1553,7 +1553,7 @@ members`). A `switch` on a string is refused (`switch works on integers and enum
|
|
|
1553
1553
|
## Destructuring
|
|
1554
1554
|
|
|
1555
1555
|
```ts
|
|
1556
|
-
import { type Account, type Mut, type Pubkey, type u64 } from "typesol";
|
|
1556
|
+
import { type Account, type Mut, type Pubkey, type Signer, type u64, require } from "typesol";
|
|
1557
1557
|
|
|
1558
1558
|
export interface Point {
|
|
1559
1559
|
x: u64;
|
|
@@ -1566,7 +1566,8 @@ export interface Player {
|
|
|
1566
1566
|
score: u64;
|
|
1567
1567
|
}
|
|
1568
1568
|
|
|
1569
|
-
export function read(player: Account<Player>, out: Mut<Player>): void {
|
|
1569
|
+
export function read(signer: Signer, player: Account<Player>, out: Mut<Player>): void {
|
|
1570
|
+
require(out.owner === signer.key, "only the owner of out can overwrite it");
|
|
1570
1571
|
const { owner, pos: p } = player;
|
|
1571
1572
|
let { score } = player;
|
|
1572
1573
|
score += p.x;
|
|
@@ -2129,8 +2130,8 @@ export interface Log {
|
|
|
2129
2130
|
entries: u64;
|
|
2130
2131
|
}
|
|
2131
2132
|
|
|
2132
|
-
export function grow(
|
|
2133
|
-
realloc(log, size,
|
|
2133
|
+
export function grow(owner: Mut<Signer>, log: HasOne<Mut<Log>, "owner">, systemProgram: SystemProgram, size: u64): void {
|
|
2134
|
+
realloc(log, size, owner);
|
|
2134
2135
|
}
|
|
2135
2136
|
|
|
2136
2137
|
export function remove(owner: Mut<Signer>, log: HasOne<Mut<Log>, "owner">): void {
|
|
@@ -2142,9 +2143,8 @@ export function remove(owner: Mut<Signer>, log: HasOne<Mut<Log>, "owner">): void
|
|
|
2142
2143
|
account) and its data is zeroed. The account is not used after it in the function, except its `key` (compile
|
|
2143
2144
|
errors, or 2040 at run time in a helper given one account twice). `CloseTo<A, "dest">` does the same when the
|
|
2144
2145
|
instruction succeeds ([constraints](#constraints)).
|
|
2145
|
-
- Who may call them:
|
|
2146
|
-
|
|
2147
|
-
left open here; restrict it too if the extra bytes, or their absence, matter to your program.
|
|
2146
|
+
- Who may call them: `HasOne` above lets only the log's owner close it (the lamports of a closed account are value)
|
|
2147
|
+
or resize it. Without that check anyone could pay to grow, or shrink, another user's account.
|
|
2148
2148
|
- `realloc(account, newSize, payer)` on a `Mut<Struct>`: growing charges the payer the extra rent (at most 10 KiB per
|
|
2149
2149
|
instruction, 3016); shrinking keeps the lamports in the account; never below the struct. Refused on a struct with a
|
|
2150
2150
|
growable `Vec` (its push / pop / clear size the account).
|
|
@@ -2339,7 +2339,7 @@ export function count(tally: Mut<Tally>): void {
|
|
|
2339
2339
|
`remainingAccounts()` gives the accounts passed after the declared ones, in order.
|
|
2340
2340
|
|
|
2341
2341
|
- `.length`, `.get(i)` (5104 past the end) → `key`, `owner`, `lamports` (writes check writability, 3006), `isSigner`,
|
|
2342
|
-
`isWritable`, the data length and data.
|
|
2342
|
+
`isWritable`, `executable`, the data length and data.
|
|
2343
2343
|
- `loadAccount<T>(acct)` / `loadAccountMut<T>(acct)` give checked struct views (owner, discriminator and size, as
|
|
2344
2344
|
`Account<T>` / `Mut<T>`), also of an `AccountInfo` parameter (Anchor's `AccountLoader::try_from` on an
|
|
2345
2345
|
`UncheckedAccount`).
|
|
@@ -2713,7 +2713,7 @@ it); a zero code fails with 5100.
|
|
|
2713
2713
|
- `require(cond, "message")` errors come after the highest code.
|
|
2714
2714
|
|
|
2715
2715
|
When the program fails, the logs show the error and the source line, `Error 6000 NotOwner (vault.ts:21)`, and
|
|
2716
|
-
TypeSOL's own failures say what failed, `TypeSOL: arithmetic overflow (vault.ts:
|
|
2716
|
+
TypeSOL's own failures say what failed, `TypeSOL: arithmetic overflow (vault.ts:44)`. Native ports can change or drop
|
|
2717
2717
|
that line ([log lines](language-native.md#log-lines-as-the-original-writes-them)).
|
|
2718
2718
|
|
|
2719
2719
|
## log
|
|
@@ -3872,7 +3872,7 @@ direct mapping), one that was only read (or written with the bytes it held) is f
|
|
|
3872
3872
|
`AccountInfo`s over one buffer.
|
|
3873
3873
|
|
|
3874
3874
|
- **By default** `loadRawMut` and `storeBorsh` check writability up front (3006), `loadRawMut` claims the account once
|
|
3875
|
-
and `storeBorsh` refuses an account passed more than once (2040, as a write to a remaining account's lamports). So a
|
|
3875
|
+
and `storeBorsh` refuses an account passed more than once (2040, as a write to a remaining account's lamports does without the flag). So a
|
|
3876
3876
|
port fails where the original succeeds (a read-only validator list that is only read; the list passed again as a
|
|
3877
3877
|
stake account, which the original skips by its address checks).
|
|
3878
3878
|
- **With the flag**, `loadRawMut`, `storeBorsh` and the BigVec writes through a `loadRawMut` view skip both, and both
|
|
@@ -3886,8 +3886,14 @@ direct mapping), one that was only read (or written with the bytes it held) is f
|
|
|
3886
3886
|
`loadRaw` of an account also loaded with `loadRawMut` (or written with `storeBorsh`) reads what was written, BigVec
|
|
3887
3887
|
pushes included. The flag only lifts the up-front checks (a second `loadRawMut` of one account, at the same position
|
|
3888
3888
|
or another, is 2040 without it).
|
|
3889
|
-
-
|
|
3890
|
-
|
|
3889
|
+
- A write to a remaining account's `.lamports` (`a.lamports = v`, `+=`, `-=`) is `**a.lamports.borrow_mut() = v`
|
|
3890
|
+
under the flag: no writability check (3006) and no refusal of an account passed more than once (2040). An account
|
|
3891
|
+
passed twice is one record, as Rust's two `AccountInfo`s share one `RefCell`, so a write through either position is
|
|
3892
|
+
read through the other; the runtime refuses a read-only account's change, or lamports created or destroyed, when the
|
|
3893
|
+
instruction ends (`ReadonlyLamportChange`, `UnbalancedInstruction`). Percolator's CloseSlab moves the slab's
|
|
3894
|
+
lamports to the admin this way while the admin (or the slab) is also named in an unused position.
|
|
3895
|
+
- `loadAccountMut`, CPI account metas and the checks of `Mut<…>` parameters stay as they are, and programs without the
|
|
3896
|
+
flag compile exactly as before.
|
|
3891
3897
|
|
|
3892
3898
|
### Inout places that may be one account
|
|
3893
3899
|
|
|
@@ -3913,6 +3919,13 @@ On remaining accounts and `AccountInfo` parameters:
|
|
|
3913
3919
|
lamports in the receiver; [`test/language/native-close.test.ts`](https://github.com/typesol-lang/typesol/blob/main/test/language/native-close.test.ts) compares it with Phoenix's own Tombstone).
|
|
3914
3920
|
- `assignOwner(account, owner)` is `AccountInfo::assign` (the runtime accepts it for a writable account of this program
|
|
3915
3921
|
whose data is empty or zeroed).
|
|
3922
|
+
- `zeroData(account, offset, length)` zeroes that range of the data, as a native program's `for b in
|
|
3923
|
+
data.iter_mut() { *b = 0; }`, which compiles to a memset: the memset syscall, about constant compute units whatever
|
|
3924
|
+
the length (Percolator clears its 1.5 MB slab this way at InitMarket and CloseSlab). Past the end of the data fails
|
|
3925
|
+
with 3003 and writes nothing; without `NATIVE_ACCOUNT_WRITES` the account must be writable (3006). It does not check
|
|
3926
|
+
the account's owner: check that it is this program's first (the runtime would fail the instruction after it returns,
|
|
3927
|
+
having changed another program's account). The length does not change, so views made before stay valid and read the
|
|
3928
|
+
zeros.
|
|
3916
3929
|
- `resizeAccount(account, size)` also takes a remaining account (`realloc(size, true)`: new bytes zeroed, at most
|
|
3917
3930
|
10 KiB past the size it had when the instruction started, 3016). That size is the one the entrypoint records in the
|
|
3918
3931
|
account's record, as solana_program 1.14's does, only in programs that resize a remaining account.
|
|
@@ -3963,6 +3976,11 @@ export function entry(): void {
|
|
|
3963
3976
|
location)` log `panicked at '<message>', <location>` and then abort, so the runtime's last line is "SBF program
|
|
3964
3977
|
panicked" with no location, as that panic handler leaves it. `panic(null, …)` is refused there (the handler always
|
|
3965
3978
|
logs); without a location the TypeScript line and column are used. `PANIC_ON_OVERFLOW`'s panics abort too.
|
|
3979
|
+
- **Panics as solana-program 1.18 writes them.** `export const PANIC_STYLE = "solana-1.18"` (a program built with
|
|
3980
|
+
solana-program 1.18, whose rustc formats a panic as it has since 1.73: Percolator v12.20) makes `panic(message,
|
|
3981
|
+
location)` log one line, `panicked at <location>:` and the message after a newline, and then abort ("SBF program
|
|
3982
|
+
panicked"), as that panic handler does: `panicked at src/wide_math.rs:1554:30:\nmul_div_floor_u128: a*b overflow`.
|
|
3983
|
+
As under "solana-1.14", a message is required and `PANIC_ON_OVERFLOW`'s panics abort.
|
|
3966
3984
|
- **Overflow panics with Rust's message and location.** `panicsAt("src/quantities.rs:233:1", a + b)` is `a + b` whose
|
|
3967
3985
|
checked arithmetic panics as Rust's overflow checks do at that location ("attempt to add with overflow"; also
|
|
3968
3986
|
"attempt to subtract / multiply with overflow", "attempt to divide by zero", "attempt to calculate the remainder with
|
|
@@ -3993,6 +4011,8 @@ export function entry(): void {
|
|
|
3993
4011
|
- `createProgramAddress(seeds, program)` is `Pubkey::create_program_address` (null for no address).
|
|
3994
4012
|
- `logComputeUnits()` is `sol_log_compute_units()`: the runtime writes "Program consumption: N units remaining" at that
|
|
3995
4013
|
point, as for the original (Phoenix's cancel and withdraw paths log it).
|
|
4014
|
+
- `log64(a, b, c, d, e)` is `sol_log_64(a, b, c, d, e)`: the runtime writes the five u64s as lowercase hex,
|
|
4015
|
+
`Program log: 0x174778, 0x3e8, 0x0, 0x0, 0x0` (Percolator logs the slab length it wants and the one it got this way).
|
|
3996
4016
|
|
|
3997
4017
|
## Byte strings built by hand
|
|
3998
4018
|
|
|
@@ -4056,7 +4076,7 @@ void instruction (Phoenix's Borsh `Vec<FIFOOrderId>` of the orders that rested,
|
|
|
4056
4076
|
|
|
4057
4077
|
<!-- Generated by scripts/language-builtins.ts from lib/typesol.d.ts; do not edit by hand. -->
|
|
4058
4078
|
|
|
4059
|
-
Every name `"typesol"` exports (
|
|
4079
|
+
Every name `"typesol"` exports (220 names, 233 declarations), grouped, with its declaration and the first sentence of its doc
|
|
4060
4080
|
comment in `lib/typesol.d.ts`. Each group links to the part of the [language guide](language.md) that explains it;
|
|
4061
4081
|
your editor shows the full doc comment on hover. Methods of account and program types (`systemProgram.transfer`,
|
|
4062
4082
|
`acct.create`, …) are described with their types in the guide.
|
|
@@ -4457,12 +4477,14 @@ Explained in [Porting a native program (advanced)](language-native.md).
|
|
|
4457
4477
|
| `RbEntry` | `interface RbEntry<K, V>` | A node of a RedBlackTree: its key (read-only), its value (in place) and its index in the tree's node array (1-based). |
|
|
4458
4478
|
| `closeRaw` | `function closeRaw(account: RemainingAccount \| Mut<AccountInfo>, receiver: RemainingAccount \| Mut<AccountInfo>): void` | Close an account of this program as a native program does it by hand (Phoenix's Tombstone), in this order: `receiver.lamports += account.lamports`, `account.lamports = 0`, the owner set to the System Program, the data length set to 0 (`realloc(0, false)`: the bytes are not zeroed, the runtime drops them with the length). |
|
|
4459
4479
|
| `assignOwner` | `function assignOwner(account: RemainingAccount \| Mut<AccountInfo>, owner: Pubkey): void` | Set an account's owner in place (Rust's `AccountInfo::assign`). |
|
|
4480
|
+
| `zeroData` | `function zeroData(account: RemainingAccount \| Mut<AccountInfo>, offset: u64, length: u64): void` | Zero `length` bytes of an account's data from `offset`, as a native program's `for b in data[offset..offset + length].iter_mut() { *b = 0; }` (a memset): the memset syscall, about constant compute units whatever the length. |
|
|
4460
4481
|
| `setReturnData` | `function setReturnData(bytes: IndexedList<u8>): void` | Set this instruction's return data to `bytes` as they are (Rust's `set_return_data(&bytes)`): a list of u8 such as a local `FixedVec<u8, N>`, a Vec or FixedVec in account data, or the instruction data or a slice of it. |
|
|
4461
4482
|
| `panic` | `function panic(message?: string \| null, location?: string): never` | Stop the program as a Rust `panic!` / `unwrap()` on `None` / `unreachable!()` does: the message is logged and the instruction fails with ProgramFailedToComplete (no error code). |
|
|
4462
4483
|
| `panicsAt` | `function panicsAt<T>(location: string, value: T): T` | `value`, with its checked arithmetic panicking as Rust's overflow checks do at `location` ("file:line:column", where the original's expression is): `panicsAt("src/quantities.rs:233:1", a + b)` logs "attempt to add with overflow" there (also "attempt to subtract / multiply with overflow", "attempt to divide by zero", "attempt to calculate the remainder with a divisor of zero", "attempt to negate with overflow", "attempt to divide with overflow", "attempt to shift left / right with overflow" for a shift amount past the width), as `panic` logs (see `PANIC_STYLE`), instead of failing with 5100 / 5101. |
|
|
4463
4484
|
| `abort` | `function abort(): never` | Stop the program as Rust's `abort` does on SBF (the allocator's out-of-memory error, `std::process::abort`): the runtime's `abort` syscall, which fails the instruction with ProgramFailedToComplete and logs "SBF program panicked" (no location, nothing else). |
|
|
4464
4485
|
| `logBase64` | `function logBase64(prefix: string, value: object): void` | Log `prefix` followed by the base64 (standard, padded) of a struct value's bytes, as a native program's `msg!("ray_log: {}", base64(bincode(log)))` does. |
|
|
4465
4486
|
| `logComputeUnits` | `function logComputeUnits(): void` | Log the compute units left (Rust's `sol_log_compute_units()`): the runtime writes "Program consumption: <N> units remaining", as the original's line, at the same place. |
|
|
4487
|
+
| `log64` | `function log64(a: u64, b: u64, c: u64, d: u64, e: u64): void` | Log five u64 values as Rust's `sol_log_64(a, b, c, d, e)` does: the runtime writes "Program log: 0x<a>, 0x<b>, 0x<c>, 0x<d>, 0x<e>" (lowercase hex, no padding). |
|
|
4466
4488
|
|
|
4467
4489
|
**Next:** [Glossary](glossary.md): the Solana and TypeSOL terms the guide uses.
|
|
4468
4490
|
|
|
@@ -5493,7 +5515,7 @@ an account you change is a `Mut<T>` parameter; the time is `now()`, not `Date.no
|
|
|
5493
5515
|
### A transaction fails with a custom error
|
|
5494
5516
|
|
|
5495
5517
|
See [errors.md](errors.md). Failures raised by the compiler's checks log their TypeScript location, e.g. `TypeSOL:
|
|
5496
|
-
arithmetic overflow (vault.ts:
|
|
5518
|
+
arithmetic overflow (vault.ts:44)`.
|
|
5497
5519
|
|
|
5498
5520
|
### "exceeded CUs meter" / "Computational budget exceeded"
|
|
5499
5521
|
|
|
@@ -5644,7 +5666,7 @@ You need Node.js 22.12 or later and the Agave CLI with platform-tools (see the R
|
|
|
5644
5666
|
toolchain is part of what you trust. Deploy with the one TypeSOL is tested with (Agave 3.1.10, platform-tools v1.52;
|
|
5645
5667
|
`typesol doctor` says whether yours is, and `typesol deploy --toolchain-strict` refuses another). The host does not
|
|
5646
5668
|
matter from 0.45.0 on: with the same TypeSOL and toolchain a program builds to the same bytes on macOS arm64, Linux
|
|
5647
|
-
arm64 and Linux x86_64 (measured over 76 programs for SBPF v0 and 14 for v1 and v2; up to 0.44.1 a program with
|
|
5669
|
+
arm64 and Linux x86_64 (measured with 0.45.0 over the 76 programs then in the sources for SBPF v0 and 14 for v1 and v2; up to 0.44.1 a program with
|
|
5648
5670
|
128-bit or signed division did not, [stability.md](stability.md#what-builds-the-same-bytes-where)). For a program others should be able to verify, build
|
|
5649
5671
|
it with `--docker` (step 2) all the same: a pinned linux/amd64 container that anyone can rebuild, so the whole
|
|
5650
5672
|
environment is one recipe. Keep
|
|
@@ -5847,7 +5869,7 @@ auditors, [SECURITY.md](../SECURITY.md) how to report a problem.
|
|
|
5847
5869
|
| --- | --- |
|
|
5848
5870
|
| The program's author | the program's logic: what it allows, to whom, for how much |
|
|
5849
5871
|
| TypeSOL (this repository) | that the binary does what the source and these guarantees say, and nothing an attacker can steer beyond it |
|
|
5850
|
-
| The toolchain | the TypeScript compiler API (parsing, types), Agave platform-tools (clang, lld), Node.js. The guarantees are tested with one platform-tools release (v1.52, from Agave 3.1.10); a build with another warns, or fails with `--toolchain-strict`, and `<name>.build.json` records which one built a binary and on which host. The compiler builtins (128-bit multiplication, division and shifts, signed 64-bit division) are TypeSOL's own (`runtime/typesol_builtins.c`), compiled with the program; nothing is linked from platform-tools' Rust libraries, whose layout differed by host package, so from 0.45.0 on the programs measured build to the same bytes on macOS arm64, Linux arm64 and Linux x86_64 ([stability.md](stability.md#what-builds-the-same-bytes-where): 76 programs for SBPF v0, 14 for v1 and v2). `--docker` builds pin the whole environment in one linux/amd64 container whose inputs are checked by digest, checksum and integrity (base images, release files, the TypeSOL tarball and every npm dependency) |
|
|
5872
|
+
| The toolchain | the TypeScript compiler API (parsing, types), Agave platform-tools (clang, lld), Node.js. The guarantees are tested with one platform-tools release (v1.52, from Agave 3.1.10); a build with another warns, or fails with `--toolchain-strict`, and `<name>.build.json` records which one built a binary and on which host. The compiler builtins (128-bit multiplication, division and shifts, signed 64-bit division) are TypeSOL's own (`runtime/typesol_builtins.c`), compiled with the program; nothing is linked from platform-tools' Rust libraries, whose layout differed by host package, so from 0.45.0 on the programs measured build to the same bytes on macOS arm64, Linux arm64 and Linux x86_64 ([stability.md](stability.md#what-builds-the-same-bytes-where): measured with 0.45.0 over the 76 programs then in the sources for SBPF v0, 14 for v1 and v2). `--docker` builds pin the whole environment in one linux/amd64 container whose inputs are checked by digest, checksum and integrity (base images, release files, the TypeSOL tarball and every npm dependency) |
|
|
5851
5873
|
| The Solana runtime | account ownership and signer flags as passed, the loader's account serialization, CPI privilege rules, sysvars |
|
|
5852
5874
|
|
|
5853
5875
|
Everything a transaction carries is attacker-controlled: the instruction data, which accounts are passed in which
|
|
@@ -5919,7 +5941,10 @@ Each holds for every instruction of every program the compiler accepts. A break
|
|
|
5919
5941
|
transaction did not pass that way and any signer the program's seeds do not cover. Only programs that store
|
|
5920
5942
|
instructions to run (a multisig, a DAO) need it; review who can write those values.
|
|
5921
5943
|
Return data is read only from the program named, at the expected size (5106).
|
|
5922
|
-
13. **Events.** `emitCpi` is accepted only from this program's event-authority PDA, signed (2002).
|
|
5944
|
+
13. **Events.** `emitCpi` is accepted only from this program's event-authority PDA, signed (2002). Under
|
|
5945
|
+
`EVENT_AUTHORITY_CHECK = "address"` (0.48.0) the event authority is checked by address among the constraints
|
|
5946
|
+
(2012) instead, and the self-program account is not checked at all: an instruction that emits fails in the runtime
|
|
5947
|
+
(MissingAccount) when this program is not among its accounts, as Anchor 1.x's does.
|
|
5923
5948
|
|
|
5924
5949
|
### When it ends
|
|
5925
5950
|
|
|
@@ -6014,8 +6039,12 @@ exposed to them.
|
|
|
6014
6039
|
The compiler and runtime have had internal security reviews, the latest of 0.44.0 (above); its findings are fixed in
|
|
6015
6040
|
0.44.1. It was an internal review, not an independent audit; it covered the token, Token-2022, Metaplex and Stake
|
|
6016
6041
|
wrappers, the oracles and SBPF v1/v2 builds of the examples that the review of 0.43.0 left out, but not the Metaplex
|
|
6017
|
-
wrappers for unusual argument shapes beyond reading them, the large ports on SBPF v1/v2, or Windows.
|
|
6018
|
-
|
|
6042
|
+
wrappers for unusual argument shapes beyond reading them, the large ports on SBPF v1/v2, or Windows. 0.45.0 to 0.49.0
|
|
6043
|
+
have had no security review. They add, among others, `runtime/typesol_builtins.c` (the
|
|
6044
|
+
compiler builtins as TypeSOL's own C, 0.45.0), `transferCheckedWithHook`, `EVENT_AUTHORITY_CHECK` and the reads of
|
|
6045
|
+
processed sibling instructions (0.48.0), and `zeroData`, `log64`,
|
|
6046
|
+
`PANIC_STYLE = "solana-1.18"`, `executable` on remaining accounts and lamport writes on remaining accounts under
|
|
6047
|
+
`NATIVE_ACCOUNT_WRITES` (0.49.0). There has been no external audit: see [audit.md](audit.md).
|
|
6019
6048
|
|
|
6020
6049
|
<!-- docs/ai.md -->
|
|
6021
6050
|
|
|
@@ -6143,14 +6172,17 @@ Meant to stay as they are; a change before 1.0 would be a breaking change listed
|
|
|
6143
6172
|
|
|
6144
6173
|
## What builds the same bytes where
|
|
6145
6174
|
|
|
6146
|
-
From 0.45.0 on, the programs measured build to the same bytes on each host measured. Measured with
|
|
6175
|
+
From 0.45.0 on, the programs measured build to the same bytes on each host measured. Measured with 0.45.0's
|
|
6147
6176
|
compiler and platform-tools v1.52 on macOS arm64 (the platform-tools `osx-aarch64` package, native), Linux arm64 and
|
|
6148
6177
|
Linux x86_64 (the `linux-aarch64` and `linux-x86_64` packages, in containers; x86_64 is the `--docker` image; Linux
|
|
6149
6178
|
arm64 has no Agave CLI, so there the package is set up by hand with `TYPESOL_SBF_SDK`, as in
|
|
6150
6179
|
[troubleshooting.md](troubleshooting.md#linux-arm64-the-agave-installer-fails-with-a-404)): for
|
|
6151
|
-
SBPF v0 (the default), the 76 programs
|
|
6152
|
-
and `showcase/`); for SBPF v1 and v2, the 14 programs of `test/golden/binaries.json` (counter, vault,
|
|
6153
|
-
and the 10 below).
|
|
6180
|
+
SBPF v0 (the default), the 76 programs then in the sources (`scripts/release-manifest.ts`, every program under
|
|
6181
|
+
`examples/` and `showcase/`); for SBPF v1 and v2, the 14 programs of `test/golden/binaries.json` (counter, vault,
|
|
6182
|
+
escrow, multisig and the 10 below). Programs added since were not measured on the three hosts, and two of them that
|
|
6183
|
+
divide 128-bit and wider integers, the Meteora DBC port (0.48.0; u128 and u256 division) and the Percolator port
|
|
6184
|
+
(0.49.0; U256 and U512), are not in `test/golden/binaries.json`, so CI's cross-host check does not build them yet
|
|
6185
|
+
(adding them needs the file regenerated in the `--docker` reference environment).
|
|
6154
6186
|
|
|
6155
6187
|
| What | Same on the three hosts? |
|
|
6156
6188
|
| --- | --- |
|
|
@@ -6208,6 +6240,8 @@ Useful today, but may still change before 1.0 (each change listed in the CHANGEL
|
|
|
6208
6240
|
its panics in solana-program 1.14–1.17's format, `removeAt(index)` (what it gives for a node in no tree may change).
|
|
6209
6241
|
- `panic(null, location)` (no log line) and `abort()` (Rust's abort, "SBF program panicked") (0.42.0).
|
|
6210
6242
|
- Failures without a log line (0.43.0): `ERROR_LOG_PREFIX = null` / `PROGRAM_ERROR_LOG_PREFIX = null`.
|
|
6243
|
+
- `EVENT_AUTHORITY_CHECK = "address"` (0.48.0): `emitCpi`'s event authority checked by address, as Anchor 1.x's
|
|
6244
|
+
`#[event_cpi]` does, and the self-program account not checked (docs/security-model.md, guarantee 13).
|
|
6211
6245
|
- `findProgramAddressWithBump` (0.43.0), with `const [address, bump] = …` its only array destructuring.
|
|
6212
6246
|
- Plain type aliases (0.43.0): `type Price = u64`, replaced by the type they name.
|
|
6213
6247
|
- File-local structs (0.43.0): `interface Pair { … }` without `export`, for helpers and locals, out of the IDL.
|
package/llms.txt
CHANGED
|
@@ -38,4 +38,5 @@ The rules and the whole reference in one file: https://typesol.com/llms-full.txt
|
|
|
38
38
|
|
|
39
39
|
## Optional
|
|
40
40
|
|
|
41
|
-
- [Case studies](https://typesol.com/docs/case-study-marginfi/): mainnet programs (Marginfi v2, Phoenix v1, SPL Stake Pool, Raydium AMM v4, CLMM, CP-Swap, Jito) ported and checked against their binaries
|
|
41
|
+
- [Case studies](https://typesol.com/docs/case-study-marginfi/): mainnet programs (Marginfi v2, Phoenix v1, SPL Stake Pool, Raydium AMM v4, CLMM, CP-Swap, Jito MEV, coral-xyz/multisig) ported and checked against their binaries
|
|
42
|
+
- [Percolator v12.20 and Meteora DBC 0.2.2](https://github.com/typesol-lang/typesol/tree/main/showcase/mainnet): two more ports checked against their mainnet binaries, each described in its own README (Meteora's under Meteora's Non-commercial Licence)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typesol/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Compile a TypeScript
|
|
3
|
+
"version": "0.49.0",
|
|
4
|
+
"description": "Compile a TypeScript subset to Solana SBF programs (through C and the platform-tools clang), with an Anchor-compatible IDL.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"test": "vitest run",
|
|
70
70
|
"typesol": "node dist/cli.js",
|
|
71
71
|
"smoke": "node scripts/smoke.ts",
|
|
72
|
-
"fuzz": "FUZZ_RUNS=2000 FUZZ_STEPS=600 FUZZ_VERBOSE=1 vitest run test/verification/fuzz-arith.test.ts test/verification/fuzz-state.test.ts test/verification/fuzz-layout.test.ts test/verification/differential.test.ts showcase/test/fuzz-jito.test.ts showcase/test/fuzz-marginfi.test.ts showcase/test/phoenix-fuzz.test.ts --silent=false",
|
|
72
|
+
"fuzz": "FUZZ_RUNS=2000 FUZZ_STEPS=600 FUZZ_VERBOSE=1 vitest run test/verification/fuzz-arith.test.ts test/verification/fuzz-state.test.ts test/verification/fuzz-layout.test.ts test/verification/differential.test.ts showcase/test/fuzz-jito.test.ts showcase/test/fuzz-marginfi.test.ts showcase/test/phoenix-fuzz.test.ts showcase/test/percolator-fuzz.test.ts --silent=false",
|
|
73
73
|
"build:twins": "cd test/anchor-twins && cargo-build-sbf",
|
|
74
74
|
"prepack": "npm run build",
|
|
75
75
|
"fetch:programs": "bash scripts/fetch-programs.sh",
|