@typesol/cli 0.47.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 +299 -0
- package/NOTICE +17 -0
- package/README.md +106 -37
- package/SECURITY.md +5 -0
- package/dist/compiler/emit/base.d.ts +12 -4
- package/dist/compiler/emit/base.js +19 -5
- package/dist/compiler/emit/calls.js +59 -1
- package/dist/compiler/emit/cpi.js +3 -1
- package/dist/compiler/emit/expressions.js +3 -1
- package/dist/compiler/emit/function.js +7 -2
- package/dist/compiler/emit/program.js +9 -4
- package/dist/compiler/emit/statements.d.ts +29 -2
- package/dist/compiler/emit/statements.js +149 -6
- package/dist/compiler/emit/storage.js +8 -3
- package/dist/compiler/emit/token.js +18 -1
- package/dist/compiler/hints.js +3 -0
- package/dist/compiler/toolchain.js +1 -0
- package/dist/idl-coder.d.ts +21 -2
- package/dist/idl-coder.js +42 -4
- package/dist/testing.d.ts +14 -3
- package/dist/testing.js +87 -17
- package/docker/deps/0.48.0.lock.json +1206 -0
- package/docker/deps/0.49.0.lock.json +1206 -0
- package/docs/architecture.md +2 -2
- package/docs/audit.md +31 -15
- 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-basics.md +2 -1
- package/docs/language-builtins.md +5 -1
- package/docs/language-chain.md +13 -1
- package/docs/language-cpi.md +26 -0
- package/docs/language-errors-events.md +16 -1
- package/docs/language-native.md +23 -3
- package/docs/language-statements.md +4 -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/test-your-program.md +43 -4
- package/docs/testing.md +16 -4
- package/docs/troubleshooting.md +1 -1
- package/lib/typesol.d.ts +46 -1
- package/llms-full.txt +164 -34
- package/llms.txt +2 -1
- package/package.json +3 -3
- package/releases/0.47.0.json +837 -0
- package/releases/0.48.0.json +847 -0
- package/runtime/typesol_rt.h +276 -1
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
|
|
|
@@ -598,7 +598,8 @@ export function setup(config: Mut<Config>): void {
|
|
|
598
598
|
other than its accounts.
|
|
599
599
|
- A few names configure the compiler: `HEAP_SIZE_KIB` ([below](#memory-stack-and-heap)), `MAX_ACCOUNTS`
|
|
600
600
|
([accounts](language-accounts.md#how-many-accounts)), `NATIVE_ACCOUNT_WRITES`, `PANIC_ON_OVERFLOW`, `PANIC_STYLE`,
|
|
601
|
-
`ERROR_LOG_PREFIX`, `PROGRAM_ERROR_LOG_PREFIX` ([native programs](language-native.md))
|
|
601
|
+
`ERROR_LOG_PREFIX`, `PROGRAM_ERROR_LOG_PREFIX` ([native programs](language-native.md)), `EVENT_AUTHORITY_CHECK`
|
|
602
|
+
([events through CPI](language-errors-events.md#events-through-cpi)).
|
|
602
603
|
|
|
603
604
|
## Type aliases
|
|
604
605
|
|
|
@@ -1552,7 +1553,7 @@ members`). A `switch` on a string is refused (`switch works on integers and enum
|
|
|
1552
1553
|
## Destructuring
|
|
1553
1554
|
|
|
1554
1555
|
```ts
|
|
1555
|
-
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";
|
|
1556
1557
|
|
|
1557
1558
|
export interface Point {
|
|
1558
1559
|
x: u64;
|
|
@@ -1565,7 +1566,8 @@ export interface Player {
|
|
|
1565
1566
|
score: u64;
|
|
1566
1567
|
}
|
|
1567
1568
|
|
|
1568
|
-
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");
|
|
1569
1571
|
const { owner, pos: p } = player;
|
|
1570
1572
|
let { score } = player;
|
|
1571
1573
|
score += p.x;
|
|
@@ -1930,6 +1932,7 @@ may gain a hint line.
|
|
|
1930
1932
|
| an unused proof or signature check | `merkleVerify(leaf, proof, root);` | the result of merkleVerify is discarded, so nothing is checked: it returns whether the proof holds; write require(merkleVerify(…), error) |
|
|
1931
1933
|
| a proof check in an empty `if` | `if (merkleVerify(leaf, proof, root)) {}` | the result of merkleVerify is not acted on: the if around it has an empty body, so nothing is checked: it returns whether the proof holds; write require(merkleVerify(…), error) |
|
|
1932
1934
|
| a proof check kept in a local never read | `const ok = merkleVerify(leaf, proof, root);` (`ok` unused) | the result of merkleVerify is never read (ok is not used), so nothing is checked: it returns whether the proof holds; write require(merkleVerify(…), error) |
|
|
1935
|
+
| an unused helper that returns a check | `checkProof(leaf, proof, root);` (`checkProof` returns `merkleVerify(…)`) | the result of checkProof is discarded, so nothing is checked: it returns the result of merkleVerify; write require(checkProof(…), error) |
|
|
1933
1936
|
| a `@code` tag outside a doc comment | `export enum E { A = "a", /* @code 6100 */ B = "b" }` | this @code tag is not read: only a doc comment (/** … */) is, not a /* … */ comment; write /** @code … */ above B |
|
|
1934
1937
|
| a `@code` tag after other code on its line | `export enum E { A = "a", /** @code 6100 */ B = "b" }` | this @code tag is not read: other code comes before it on its line; put /** @code … */ on its own line above B |
|
|
1935
1938
|
|
|
@@ -2127,8 +2130,8 @@ export interface Log {
|
|
|
2127
2130
|
entries: u64;
|
|
2128
2131
|
}
|
|
2129
2132
|
|
|
2130
|
-
export function grow(
|
|
2131
|
-
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);
|
|
2132
2135
|
}
|
|
2133
2136
|
|
|
2134
2137
|
export function remove(owner: Mut<Signer>, log: HasOne<Mut<Log>, "owner">): void {
|
|
@@ -2140,9 +2143,8 @@ export function remove(owner: Mut<Signer>, log: HasOne<Mut<Log>, "owner">): void
|
|
|
2140
2143
|
account) and its data is zeroed. The account is not used after it in the function, except its `key` (compile
|
|
2141
2144
|
errors, or 2040 at run time in a helper given one account twice). `CloseTo<A, "dest">` does the same when the
|
|
2142
2145
|
instruction succeeds ([constraints](#constraints)).
|
|
2143
|
-
- Who may call them:
|
|
2144
|
-
|
|
2145
|
-
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.
|
|
2146
2148
|
- `realloc(account, newSize, payer)` on a `Mut<Struct>`: growing charges the payer the extra rent (at most 10 KiB per
|
|
2147
2149
|
instruction, 3016); shrinking keeps the lamports in the account; never below the struct. Refused on a struct with a
|
|
2148
2150
|
growable `Vec` (its push / pop / clear size the account).
|
|
@@ -2337,7 +2339,7 @@ export function count(tally: Mut<Tally>): void {
|
|
|
2337
2339
|
`remainingAccounts()` gives the accounts passed after the declared ones, in order.
|
|
2338
2340
|
|
|
2339
2341
|
- `.length`, `.get(i)` (5104 past the end) → `key`, `owner`, `lamports` (writes check writability, 3006), `isSigner`,
|
|
2340
|
-
`isWritable`, the data length and data.
|
|
2342
|
+
`isWritable`, `executable`, the data length and data.
|
|
2341
2343
|
- `loadAccount<T>(acct)` / `loadAccountMut<T>(acct)` give checked struct views (owner, discriminator and size, as
|
|
2342
2344
|
`Account<T>` / `Mut<T>`), also of an `AccountInfo` parameter (Anchor's `AccountLoader::try_from` on an
|
|
2343
2345
|
`UncheckedAccount`).
|
|
@@ -2711,7 +2713,7 @@ it); a zero code fails with 5100.
|
|
|
2711
2713
|
- `require(cond, "message")` errors come after the highest code.
|
|
2712
2714
|
|
|
2713
2715
|
When the program fails, the logs show the error and the source line, `Error 6000 NotOwner (vault.ts:21)`, and
|
|
2714
|
-
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
|
|
2715
2717
|
that line ([log lines](language-native.md#log-lines-as-the-original-writes-them)).
|
|
2716
2718
|
|
|
2717
2719
|
## log
|
|
@@ -2766,6 +2768,9 @@ export function deposit(owner: Signer, pool: Mut<Pool>, amount: u64, tags: Vec<u
|
|
|
2766
2768
|
when empty.
|
|
2767
2769
|
- An event is at most 1024 bytes (5107).
|
|
2768
2770
|
|
|
2771
|
+
In a test, `t.events(res)` gives a transaction's events decoded, `emitCpi`'s too
|
|
2772
|
+
([asserting events](test-your-program.md#events)).
|
|
2773
|
+
|
|
2769
2774
|
### Events through CPI
|
|
2770
2775
|
|
|
2771
2776
|
```ts
|
|
@@ -2790,6 +2795,18 @@ instruction) instead of the logs. The instruction takes `eventAuthority:
|
|
|
2790
2795
|
EventAuthority` (Anchor's `["__event_authority"]` PDA) and `self: SelfProgram` parameters, and the program accepts
|
|
2791
2796
|
Anchor's event instruction (2002 when the event authority did not sign it, 2006 when it is not that PDA).
|
|
2792
2797
|
|
|
2798
|
+
By default the two accounts are checked when the instruction's accounts load: the event authority by its seeds (2006)
|
|
2799
|
+
and `self` against this program's address (3008). Anchor 1.x's `#[event_cpi]` checks them differently, and
|
|
2800
|
+
`export const EVENT_AUTHORITY_CHECK = "address"` does as it does, for ports of Anchor 1.x programs:
|
|
2801
|
+
|
|
2802
|
+
- the event authority is compared with the PDA's address among the constraints, in account order after the accounts
|
|
2803
|
+
load and the `create`s run (ConstraintAddress, 2012);
|
|
2804
|
+
- the `self` account is not checked: the self-CPI names this program's id whatever account was passed there. An
|
|
2805
|
+
instruction that emits nothing then accepts any account in that slot; one that emits fails in the runtime
|
|
2806
|
+
(MissingAccount) when this program is not among its accounts, as Anchor's `emit_cpi!` does.
|
|
2807
|
+
|
|
2808
|
+
Programs without the constant build as before.
|
|
2809
|
+
|
|
2793
2810
|
## Return values
|
|
2794
2811
|
|
|
2795
2812
|
```ts
|
|
@@ -2883,6 +2900,7 @@ Pass signer seeds (with the bump) as the last argument when the authority is a P
|
|
|
2883
2900
|
| Methods | Notes |
|
|
2884
2901
|
| --- | --- |
|
|
2885
2902
|
| `transfer`, `transferChecked(from, mint, to, authority, amount)` | Token-2022 mints with fees or hooks require `transferChecked` |
|
|
2903
|
+
| `transferCheckedWithHook(from, mint, to, authority, amount, hookAccounts)` | `transferChecked` for a mint with a transfer hook: [the hook's extra accounts](#calling-a-transfer-hook-mint) resolved among `hookAccounts` |
|
|
2886
2904
|
| `mintTo`, `mintToChecked(mint, to, authority, amount)` | the mint may be one this instruction just created |
|
|
2887
2905
|
| `burn`, `burnChecked(from, mint, authority, amount)` | |
|
|
2888
2906
|
| `approve(source, delegate, owner, amount)`, `approveChecked(source, mint, delegate, owner, amount)`, `revoke` | the checked forms take the decimals from the mint |
|
|
@@ -3296,6 +3314,31 @@ ExtraAccountMetaList).
|
|
|
3296
3314
|
- Inside the hook, `isTransferring(source)` says whether Token-2022 is transferring from it.
|
|
3297
3315
|
- See [`test/fixtures/hook.ts`](https://github.com/typesol-lang/typesol/blob/main/test/fixtures/hook.ts) and the transfer-hook ports.
|
|
3298
3316
|
|
|
3317
|
+
### Calling a transfer hook mint
|
|
3318
|
+
|
|
3319
|
+
A program that moves a hooked mint's tokens by CPI must pass Token-2022 the hook's extra accounts, the validation
|
|
3320
|
+
account and the hook program after the four of TransferChecked. `tokenProgram.transferCheckedWithHook(from, mint, to,
|
|
3321
|
+
authority, amount, hookAccounts, signerSeeds?)` builds that call as Rust's
|
|
3322
|
+
`spl_transfer_hook_interface::onchain::add_extra_accounts_for_execute_cpi` does: `hookAccounts` (`remainingAccounts()`
|
|
3323
|
+
or `rest.slice(a, b)`) must hold the hook program and, when the transfer needs it, the validation account and every
|
|
3324
|
+
extra account, in any order. Each extra account is resolved from the list (a fixed address, a PDA of the hook or of
|
|
3325
|
+
another program from literal, instruction-data, account-key and account-data seeds, or a key read from an account's
|
|
3326
|
+
data), against the execute instruction's accounts (source, mint, destination, authority, the validation account, then
|
|
3327
|
+
the extra accounts already resolved), made read-only where every earlier mention of it is, and never a signer. The
|
|
3328
|
+
refusals are the Rust crates' and their codes: the hook program missing (TransferHookError::IncorrectAccount,
|
|
3329
|
+
2110272652), an extra account missing (AccountResolutionError::IncorrectAccount, 2724315840; the other
|
|
3330
|
+
AccountResolutionError codes for bad seeds), no list in the validation account (TlvError::TypeNotFound, 1202666432), a
|
|
3331
|
+
malformed one (InvalidAccountData, InvalidArgument, or 1 for a list shorter than its count). Without the validation
|
|
3332
|
+
account among `hookAccounts` only the hook program is added; a mint without a hook gets a plain `transferChecked`.
|
|
3333
|
+
|
|
3334
|
+
```ts
|
|
3335
|
+
import { type Mint, type Mut, type Signer, type TokenAccount, type TokenInterface, type u64, remainingAccounts } from "typesol";
|
|
3336
|
+
|
|
3337
|
+
export function pay(from: Mut<TokenAccount>, mint: Mint, to: Mut<TokenAccount>, owner: Signer, tokenProgram: TokenInterface, amount: u64): void {
|
|
3338
|
+
tokenProgram.transferCheckedWithHook(from, mint, to, owner, amount, remainingAccounts());
|
|
3339
|
+
}
|
|
3340
|
+
```
|
|
3341
|
+
|
|
3299
3342
|
**Next:** [Sysvars, hashes, signatures and oracles](language-chain.md).
|
|
3300
3343
|
|
|
3301
3344
|
<!-- docs/language-chain.md -->
|
|
@@ -3383,7 +3426,14 @@ export function commit(c: Mut<Commit>, owner: Pubkey, text: string, n: u64): voi
|
|
|
3383
3426
|
themselves. Unlike a check such as `HasOne`, nothing happens when the answer is false: wrap them in
|
|
3384
3427
|
`require(…, error)`. The compiler refuses a call used as a statement, one that is the
|
|
3385
3428
|
condition of an `if` with an empty body and no `else` or an empty one, and one whose result is kept in a local the function never
|
|
3386
|
-
reads.
|
|
3429
|
+
reads. The same goes for a call of a helper that returns such a result: one with a `return` that gives the result of
|
|
3430
|
+
one of the three or of another such helper, directly, combined with `&&`, `||`, `!` or `?:`, or through a local of
|
|
3431
|
+
the helper that nothing but its returns reads (`the result of checkProof is discarded, so nothing is checked: it
|
|
3432
|
+
returns the result of merkleVerify; write require(checkProof(…), error)`). A helper that acts on the result itself
|
|
3433
|
+
(requires it, reads it outside a `return`) is not one. Not caught: a result stored in an account field, a struct or an
|
|
3434
|
+
Option, compared (`=== true`) or passed to another function that ignores it, a helper that branches on the result and
|
|
3435
|
+
returns literals (`if (!ok) { return false; } return true;`), and a helper that returns what a function passed to it
|
|
3436
|
+
returns (a function parameter is not followed).
|
|
3387
3437
|
|
|
3388
3438
|
```ts
|
|
3389
3439
|
import { type Account, type Hash, type Init, type InstructionsSysvar, type Mut, type Pubkey, type Signer, type SystemProgram, type u8, type u64, type Vec, keccak256, merkleVerify, require, verifyEd25519, verifySecp256k1 } from "typesol";
|
|
@@ -3432,6 +3482,11 @@ export function approved(drop: Account<Drop>, ixs: InstructionsSysvar, who: Pubk
|
|
|
3432
3482
|
`is(program, "name")` (that program's instruction by its default Anchor discriminator, sha256("global:<name>"); an
|
|
3433
3483
|
instruction with its own `@discriminator` is matched with `programId` and `readU64(0)` instead).
|
|
3434
3484
|
- Every read is bounds-checked (5104).
|
|
3485
|
+
- `processedSiblingInstructionCount()` and `processedSiblingInstruction(i)` (a `TransactionInstruction`, 5104 past
|
|
3486
|
+
the last) read the instructions already processed at this program's stack height, with the
|
|
3487
|
+
`sol_get_processed_sibling_instruction` syscall as Rust's `get_processed_sibling_instruction` reads it: under a
|
|
3488
|
+
caller, the instructions that caller already invoked (index 0 the latest); at the top level, the transaction's
|
|
3489
|
+
earlier instructions. With `stackHeight()`, a program can refuse to run twice under one caller.
|
|
3435
3490
|
- It is the transaction author's data: require things of the transaction with it (a repay instruction after a flash
|
|
3436
3491
|
loan), never treat it as proof.
|
|
3437
3492
|
|
|
@@ -3817,7 +3872,7 @@ direct mapping), one that was only read (or written with the bytes it held) is f
|
|
|
3817
3872
|
`AccountInfo`s over one buffer.
|
|
3818
3873
|
|
|
3819
3874
|
- **By default** `loadRawMut` and `storeBorsh` check writability up front (3006), `loadRawMut` claims the account once
|
|
3820
|
-
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
|
|
3821
3876
|
port fails where the original succeeds (a read-only validator list that is only read; the list passed again as a
|
|
3822
3877
|
stake account, which the original skips by its address checks).
|
|
3823
3878
|
- **With the flag**, `loadRawMut`, `storeBorsh` and the BigVec writes through a `loadRawMut` view skip both, and both
|
|
@@ -3831,8 +3886,14 @@ direct mapping), one that was only read (or written with the bytes it held) is f
|
|
|
3831
3886
|
`loadRaw` of an account also loaded with `loadRawMut` (or written with `storeBorsh`) reads what was written, BigVec
|
|
3832
3887
|
pushes included. The flag only lifts the up-front checks (a second `loadRawMut` of one account, at the same position
|
|
3833
3888
|
or another, is 2040 without it).
|
|
3834
|
-
-
|
|
3835
|
-
|
|
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.
|
|
3836
3897
|
|
|
3837
3898
|
### Inout places that may be one account
|
|
3838
3899
|
|
|
@@ -3858,6 +3919,13 @@ On remaining accounts and `AccountInfo` parameters:
|
|
|
3858
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).
|
|
3859
3920
|
- `assignOwner(account, owner)` is `AccountInfo::assign` (the runtime accepts it for a writable account of this program
|
|
3860
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.
|
|
3861
3929
|
- `resizeAccount(account, size)` also takes a remaining account (`realloc(size, true)`: new bytes zeroed, at most
|
|
3862
3930
|
10 KiB past the size it had when the instruction started, 3016). That size is the one the entrypoint records in the
|
|
3863
3931
|
account's record, as solana_program 1.14's does, only in programs that resize a remaining account.
|
|
@@ -3908,6 +3976,11 @@ export function entry(): void {
|
|
|
3908
3976
|
location)` log `panicked at '<message>', <location>` and then abort, so the runtime's last line is "SBF program
|
|
3909
3977
|
panicked" with no location, as that panic handler leaves it. `panic(null, …)` is refused there (the handler always
|
|
3910
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.
|
|
3911
3984
|
- **Overflow panics with Rust's message and location.** `panicsAt("src/quantities.rs:233:1", a + b)` is `a + b` whose
|
|
3912
3985
|
checked arithmetic panics as Rust's overflow checks do at that location ("attempt to add with overflow"; also
|
|
3913
3986
|
"attempt to subtract / multiply with overflow", "attempt to divide by zero", "attempt to calculate the remainder with
|
|
@@ -3938,6 +4011,8 @@ export function entry(): void {
|
|
|
3938
4011
|
- `createProgramAddress(seeds, program)` is `Pubkey::create_program_address` (null for no address).
|
|
3939
4012
|
- `logComputeUnits()` is `sol_log_compute_units()`: the runtime writes "Program consumption: N units remaining" at that
|
|
3940
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).
|
|
3941
4016
|
|
|
3942
4017
|
## Byte strings built by hand
|
|
3943
4018
|
|
|
@@ -4001,7 +4076,7 @@ void instruction (Phoenix's Borsh `Vec<FIFOOrderId>` of the orders that rested,
|
|
|
4001
4076
|
|
|
4002
4077
|
<!-- Generated by scripts/language-builtins.ts from lib/typesol.d.ts; do not edit by hand. -->
|
|
4003
4078
|
|
|
4004
|
-
Every name `"typesol"` exports (
|
|
4079
|
+
Every name `"typesol"` exports (220 names, 233 declarations), grouped, with its declaration and the first sentence of its doc
|
|
4005
4080
|
comment in `lib/typesol.d.ts`. Each group links to the part of the [language guide](language.md) that explains it;
|
|
4006
4081
|
your editor shows the full doc comment on hover. Methods of account and program types (`systemProgram.transfer`,
|
|
4007
4082
|
`acct.create`, …) are described with their types in the guide.
|
|
@@ -4345,6 +4420,8 @@ Explained in [Sysvars, hashes, signatures and oracles: Sysvars](language-chain.m
|
|
|
4345
4420
|
| `SlotHashesSysvar` | `interface SlotHashesSysvar` | The SlotHashes sysvar (`SysvarS1otHashes…`), read as an account: it is too large for the sysvar syscalls (Anchor's `Sysvar<SlotHashes>` cannot load it either). |
|
|
4346
4421
|
| `StakeHistorySysvar` | `interface StakeHistorySysvar` | The StakeHistory sysvar (`SysvarStakeHistory…`), read as an account: the cluster's stake per recent epoch (up to 512, newest first), as the Stake program uses it for warmup and cooldown. |
|
|
4347
4422
|
| `stackHeight` | `function stackHeight(): u64` | How deep in cross-program calls this program runs: 1 when the transaction calls it directly, more when another program invoked it. |
|
|
4423
|
+
| `processedSiblingInstructionCount` | `function processedSiblingInstructionCount(): u64` | How many instructions the caller of this program has already invoked at this program's stack height (its processed siblings), or, when the transaction calls this program directly, how many top-level instructions ran before this one (Rust's `get_processed_sibling_instruction(i)` until it returns None). |
|
|
4424
|
+
| `processedSiblingInstruction` | `function processedSiblingInstruction(index: u64): TransactionInstruction` | Processed sibling instruction `index` (0 the latest), as Rust's `get_processed_sibling_instruction(index)` reads it with the `sol_get_processed_sibling_instruction` syscall: its program id, accounts and data, as a TransactionInstruction. 5104 when there is none at that index. |
|
|
4348
4425
|
|
|
4349
4426
|
## Hashes, signatures and introspection
|
|
4350
4427
|
|
|
@@ -4400,12 +4477,14 @@ Explained in [Porting a native program (advanced)](language-native.md).
|
|
|
4400
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). |
|
|
4401
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). |
|
|
4402
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. |
|
|
4403
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. |
|
|
4404
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). |
|
|
4405
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. |
|
|
4406
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). |
|
|
4407
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. |
|
|
4408
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). |
|
|
4409
4488
|
|
|
4410
4489
|
**Next:** [Glossary](glossary.md): the Solana and TypeSOL terms the guide uses.
|
|
4411
4490
|
|
|
@@ -4766,7 +4845,13 @@ instruction that takes the bump as an argument (prefer a stored bump:
|
|
|
4766
4845
|
constants, arguments or other accounts' keys (`t.ix("initialize", {}, { authority: alice })` derives `counter`). Pass a keypair for an account that
|
|
4767
4846
|
signs, an address otherwise, and `null` to leave an optional account out.
|
|
4768
4847
|
- **Arguments as plain values:** bigints or numbers for integers, address strings for Pubkeys, `null` for an empty
|
|
4769
|
-
Option, objects for structs (camelCase or snake_case fields), arrays for Vecs
|
|
4848
|
+
Option, objects for structs (camelCase or snake_case fields), arrays for Vecs, `{ Variant: { field: value } }` for a
|
|
4849
|
+
data enum (a unit enum also as its index or variant name). Every argument and every field of a struct or variant
|
|
4850
|
+
must be given, except an Option, which left out is None. A missing one is an error that names it and lists the
|
|
4851
|
+
instruction's arguments (`set: argument "amount" is missing (it takes amount, cap, frame, shape; …)`,
|
|
4852
|
+
`set(frame).origin.y is missing (Point has x, y; …)`), and so is a key that names no argument or field
|
|
4853
|
+
(`set has no argument "amonut" (it takes amount, cap, frame, shape)`), so a misspelt name is never sent as zeros
|
|
4854
|
+
or as None.
|
|
4770
4855
|
- **Remaining accounts:** `[{ address, writable?, signer? }]`, where `signer` is the account's `KeyPairSigner` (it then
|
|
4771
4856
|
signs as a signer account; `writable` defaults to false).
|
|
4772
4857
|
|
|
@@ -4798,8 +4883,9 @@ looks like one.
|
|
|
4798
4883
|
| --- | --- |
|
|
4799
4884
|
| `t.ok(res)` | the successful result, or throws with the error, its name (`NotAdmin`) and the program's logs |
|
|
4800
4885
|
| `t.errorCode(res)` | the custom error code of a failed transaction: 6000 + the member's index in your error enum, or a framework code ([errors.md](errors.md)) |
|
|
4801
|
-
| `t.account(type, address)` | the account decoded by its IDL type (bigints, address strings), or `null` once closed.
|
|
4886
|
+
| `t.account(type, address)` | the account decoded by its IDL type (bigints, address strings), or `null` once closed. A `FixedString<N>` comes back as a string and a fixed-layout Option as its value or `null`; a `FixedVec<T, N>` as its IDL struct `{ len, items }` (the generated client gives an array) |
|
|
4802
4887
|
| `t.returned(instruction, res)` | the instruction's return data: an integer, boolean, Pubkey or struct |
|
|
4888
|
+
| `t.events(res)` | the events the transaction emitted, decoded, in order: `[{ name, data }]` ([events](#events)) |
|
|
4803
4889
|
| `t.balance(address)` | lamports |
|
|
4804
4890
|
| `t.errorName(code)` | the name of an error code: your program's, TypeSOL's or Anchor's |
|
|
4805
4891
|
| `t.connection` | `{ rpc, rpcSubscriptions }` answered by this LiteSVM, for the generated client: `counter.sendInstructions(t.connection, alice, [ix])`, `counter.accounts.Counter.fetch(t.connection.rpc, address)`, views, `resolve`, `watch` and `watchEvents` (as on a cluster: `watch` yields when a later transaction changes the account, not at once; `watchEvents` gets transactions sent after it subscribed, failed ones included in the stream and skipped by the client) |
|
|
@@ -4820,6 +4906,38 @@ expect(t.errorName(t.errorCode(res))).toBe("TooMuch");
|
|
|
4820
4906
|
`t.errorCode` throws when the transaction succeeded or failed without a custom code (a runtime error such as missing
|
|
4821
4907
|
signatures), so the test fails then too.
|
|
4822
4908
|
|
|
4909
|
+
### Events
|
|
4910
|
+
|
|
4911
|
+
`t.events(res)` decodes the events of a successful transaction (it throws as `t.ok` does when it failed), in the
|
|
4912
|
+
order the program emitted them: `emit`'s `Program data:` log lines and `emitCpi`'s self-CPIs alike, only this
|
|
4913
|
+
program's. Each is `{ name, data }`, the fields as `t.account` gives them (bigints, address strings, a `FixedString`
|
|
4914
|
+
as a string).
|
|
4915
|
+
|
|
4916
|
+
For a program that emits
|
|
4917
|
+
|
|
4918
|
+
```ts
|
|
4919
|
+
export interface Deposited {
|
|
4920
|
+
owner: Pubkey;
|
|
4921
|
+
amount: u64;
|
|
4922
|
+
memo: string;
|
|
4923
|
+
referrer: Option<Pubkey>;
|
|
4924
|
+
}
|
|
4925
|
+
|
|
4926
|
+
export function deposit(owner: Signer, amount: u64): void {
|
|
4927
|
+
emit<Deposited>({ owner: owner.key, amount, memo: "thanks", referrer: null });
|
|
4928
|
+
}
|
|
4929
|
+
```
|
|
4930
|
+
|
|
4931
|
+
a test asserts
|
|
4932
|
+
|
|
4933
|
+
```ts
|
|
4934
|
+
const res = await t.send(alice, t.ix("deposit", { amount: 5n }, { owner: alice }));
|
|
4935
|
+
expect(t.events(res)).toEqual([{ name: "Deposited", data: { owner: alice.address, amount: 5n, memo: "thanks", referrer: null } }]);
|
|
4936
|
+
```
|
|
4937
|
+
|
|
4938
|
+
Log lines past the runtime's log limit are cut off, and the events in them with them. See [events](language-errors-events.md#events) for
|
|
4939
|
+
what a program can emit.
|
|
4940
|
+
|
|
4823
4941
|
## Tokens and time
|
|
4824
4942
|
|
|
4825
4943
|
| Helper | Does |
|
|
@@ -4842,8 +4960,8 @@ program you loaded yourself, and `svmConnection(svm)` the RPC pair alone (for an
|
|
|
4842
4960
|
program loaded). Transactions sent through it run at once; `getProgramAccounts` (`fetchAll`) sees the accounts those
|
|
4843
4961
|
transactions named, plus any you `track(...)`.
|
|
4844
4962
|
|
|
4845
|
-
The module needs `litesvm`, which `typesol init` adds to `devDependencies`. It encodes arguments and decodes accounts
|
|
4846
|
-
|
|
4963
|
+
The module needs `litesvm`, which `typesol init` adds to `devDependencies`. It encodes arguments and decodes accounts,
|
|
4964
|
+
return data and events from the IDL with its own Borsh coder, so Anchor's TypeScript package is not needed.
|
|
4847
4965
|
|
|
4848
4966
|
## Epochs and staking
|
|
4849
4967
|
|
|
@@ -5397,7 +5515,7 @@ an account you change is a `Mut<T>` parameter; the time is `now()`, not `Date.no
|
|
|
5397
5515
|
### A transaction fails with a custom error
|
|
5398
5516
|
|
|
5399
5517
|
See [errors.md](errors.md). Failures raised by the compiler's checks log their TypeScript location, e.g. `TypeSOL:
|
|
5400
|
-
arithmetic overflow (vault.ts:
|
|
5518
|
+
arithmetic overflow (vault.ts:44)`.
|
|
5401
5519
|
|
|
5402
5520
|
### "exceeded CUs meter" / "Computational budget exceeded"
|
|
5403
5521
|
|
|
@@ -5548,7 +5666,7 @@ You need Node.js 22.12 or later and the Agave CLI with platform-tools (see the R
|
|
|
5548
5666
|
toolchain is part of what you trust. Deploy with the one TypeSOL is tested with (Agave 3.1.10, platform-tools v1.52;
|
|
5549
5667
|
`typesol doctor` says whether yours is, and `typesol deploy --toolchain-strict` refuses another). The host does not
|
|
5550
5668
|
matter from 0.45.0 on: with the same TypeSOL and toolchain a program builds to the same bytes on macOS arm64, Linux
|
|
5551
|
-
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
|
|
5552
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
|
|
5553
5671
|
it with `--docker` (step 2) all the same: a pinned linux/amd64 container that anyone can rebuild, so the whole
|
|
5554
5672
|
environment is one recipe. Keep
|
|
@@ -5751,7 +5869,7 @@ auditors, [SECURITY.md](../SECURITY.md) how to report a problem.
|
|
|
5751
5869
|
| --- | --- |
|
|
5752
5870
|
| The program's author | the program's logic: what it allows, to whom, for how much |
|
|
5753
5871
|
| TypeSOL (this repository) | that the binary does what the source and these guarantees say, and nothing an attacker can steer beyond it |
|
|
5754
|
-
| 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) |
|
|
5755
5873
|
| The Solana runtime | account ownership and signer flags as passed, the loader's account serialization, CPI privilege rules, sysvars |
|
|
5756
5874
|
|
|
5757
5875
|
Everything a transaction carries is attacker-controlled: the instruction data, which accounts are passed in which
|
|
@@ -5823,7 +5941,10 @@ Each holds for every instruction of every program the compiler accepts. A break
|
|
|
5823
5941
|
transaction did not pass that way and any signer the program's seeds do not cover. Only programs that store
|
|
5824
5942
|
instructions to run (a multisig, a DAO) need it; review who can write those values.
|
|
5825
5943
|
Return data is read only from the program named, at the expected size (5106).
|
|
5826
|
-
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.
|
|
5827
5948
|
|
|
5828
5949
|
### When it ends
|
|
5829
5950
|
|
|
@@ -5918,8 +6039,12 @@ exposed to them.
|
|
|
5918
6039
|
The compiler and runtime have had internal security reviews, the latest of 0.44.0 (above); its findings are fixed in
|
|
5919
6040
|
0.44.1. It was an internal review, not an independent audit; it covered the token, Token-2022, Metaplex and Stake
|
|
5920
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
|
|
5921
|
-
wrappers for unusual argument shapes beyond reading them, the large ports on SBPF v1/v2, or Windows.
|
|
5922
|
-
|
|
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).
|
|
5923
6048
|
|
|
5924
6049
|
<!-- docs/ai.md -->
|
|
5925
6050
|
|
|
@@ -6047,14 +6172,17 @@ Meant to stay as they are; a change before 1.0 would be a breaking change listed
|
|
|
6047
6172
|
|
|
6048
6173
|
## What builds the same bytes where
|
|
6049
6174
|
|
|
6050
|
-
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
|
|
6051
6176
|
compiler and platform-tools v1.52 on macOS arm64 (the platform-tools `osx-aarch64` package, native), Linux arm64 and
|
|
6052
6177
|
Linux x86_64 (the `linux-aarch64` and `linux-x86_64` packages, in containers; x86_64 is the `--docker` image; Linux
|
|
6053
6178
|
arm64 has no Agave CLI, so there the package is set up by hand with `TYPESOL_SBF_SDK`, as in
|
|
6054
6179
|
[troubleshooting.md](troubleshooting.md#linux-arm64-the-agave-installer-fails-with-a-404)): for
|
|
6055
|
-
SBPF v0 (the default), the 76 programs
|
|
6056
|
-
and `showcase/`); for SBPF v1 and v2, the 14 programs of `test/golden/binaries.json` (counter, vault,
|
|
6057
|
-
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).
|
|
6058
6186
|
|
|
6059
6187
|
| What | Same on the three hosts? |
|
|
6060
6188
|
| --- | --- |
|
|
@@ -6112,6 +6240,8 @@ Useful today, but may still change before 1.0 (each change listed in the CHANGEL
|
|
|
6112
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).
|
|
6113
6241
|
- `panic(null, location)` (no log line) and `abort()` (Rust's abort, "SBF program panicked") (0.42.0).
|
|
6114
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).
|
|
6115
6245
|
- `findProgramAddressWithBump` (0.43.0), with `const [address, bump] = …` its only array destructuring.
|
|
6116
6246
|
- Plain type aliases (0.43.0): `type Price = u64`, replaced by the type they name.
|
|
6117
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",
|