@typesol/cli 0.37.0 → 0.39.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 +352 -1
- package/README.md +31 -14
- package/SECURITY.md +1 -1
- package/dist/compiler/analyze.d.ts +7 -6
- package/dist/compiler/analyze.js +350 -38
- package/dist/compiler/emit/alias.js +3 -2
- package/dist/compiler/emit/base.d.ts +5 -0
- package/dist/compiler/emit/base.js +2 -0
- package/dist/compiler/emit/borsh.js +63 -2
- package/dist/compiler/emit/calls.d.ts +9 -1
- package/dist/compiler/emit/calls.js +147 -18
- package/dist/compiler/emit/cpi-core.js +21 -6
- package/dist/compiler/emit/cpi.js +81 -27
- package/dist/compiler/emit/create.d.ts +7 -0
- package/dist/compiler/emit/create.js +27 -0
- package/dist/compiler/emit/expressions.js +7 -4
- package/dist/compiler/emit/function.d.ts +7 -0
- package/dist/compiler/emit/function.js +168 -30
- package/dist/compiler/emit/program.js +15 -2
- package/dist/compiler/emit/shared.d.ts +5 -5
- package/dist/compiler/emit/shared.js +5 -0
- package/dist/compiler/emit/statements.d.ts +8 -0
- package/dist/compiler/emit/statements.js +93 -6
- package/dist/compiler/emit/storage.d.ts +10 -1
- package/dist/compiler/emit/storage.js +50 -11
- package/dist/compiler/idl.d.ts +2 -2
- package/dist/compiler/idl.js +48 -13
- package/dist/compiler/model.d.ts +47 -10
- package/dist/compiler/model.js +14 -4
- package/dist/testing.js +8 -0
- package/dist/tools/clientgen.js +10 -1
- package/dist/tools/portgen.d.ts +6 -0
- package/dist/tools/portgen.js +68 -17
- package/docs/architecture.md +5 -4
- package/docs/audit.md +31 -19
- package/docs/case-study-escrow.md +5 -5
- package/docs/case-study-jito-mev.md +171 -0
- package/docs/case-study-marginfi.md +797 -0
- package/docs/case-study-multisig.md +3 -3
- package/docs/case-study-raydium-clmm.md +151 -101
- package/docs/case-study-raydium-cp-swap.md +3 -3
- package/docs/cli.md +5 -5
- package/docs/client.md +1 -1
- package/docs/errors.md +15 -4
- package/docs/language.md +39 -26
- package/docs/migrate-from-anchor.md +4 -1
- package/docs/runtime.md +1 -1
- package/docs/security-model.md +2 -1
- package/docs/testing.md +33 -1
- package/lib/typesol.d.ts +48 -9
- package/package.json +9 -7
- package/runtime/typesol_rt.h +111 -17
package/dist/tools/clientgen.js
CHANGED
|
@@ -81,7 +81,8 @@ export const TYPESOL_ERRORS = {
|
|
|
81
81
|
const INTS = { u8: 8, u16: 16, u32: 32, u64: 64, u128: 128, i8: 8, i16: 16, i32: 32, i64: 64, i128: 128 };
|
|
82
82
|
const FLOATS = { f32: 32, f64: 64 };
|
|
83
83
|
const NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
84
|
-
|
|
84
|
+
/** A seed path: `arg`, `arg.field…`, or `opt.unwrap_or(N)` (Anchor's text for an Option argument with a default). */
|
|
85
|
+
const PATH = /^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*(\.unwrap_or\(-?\d+\))?$/;
|
|
85
86
|
const BASE58 = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
|
|
86
87
|
const JS_RESERVED = new Set(("break case catch class const continue debugger default delete do else enum export extends false finally for function if import in " +
|
|
87
88
|
"instanceof new null return super switch this throw true try typeof var void while with yield let static implements interface package " +
|
|
@@ -1112,6 +1113,14 @@ function generate(idl, opts) {
|
|
|
1112
1113
|
if (s.kind === "const")
|
|
1113
1114
|
return bytes(s.value);
|
|
1114
1115
|
if (s.kind === "arg") {
|
|
1116
|
+
// `opt.unwrap_or(7)`: an Option argument, or 7 when it is None.
|
|
1117
|
+
const fallback = /^(.*)\.unwrap_or\((-?\d+)\)$/.exec(s.path);
|
|
1118
|
+
if (fallback) {
|
|
1119
|
+
const t = argType.get(fallback[1]);
|
|
1120
|
+
if (t === undefined || typeof t !== "object" || t.option === undefined || !(typeof t.option === "string" && t.option in INTS))
|
|
1121
|
+
return { why: `the seed ${s.path} is not an Option integer argument with a default` };
|
|
1122
|
+
return `${codec(t.option)}.encode(${refs.arg(camel(fallback[1]))} ?? ${fallback[2]})`;
|
|
1123
|
+
}
|
|
1115
1124
|
// `params.id`: a field (of a field…) of a struct argument.
|
|
1116
1125
|
const [head, ...rest] = s.path.split(".");
|
|
1117
1126
|
let t = argType.get(head);
|
package/dist/tools/portgen.d.ts
CHANGED
package/dist/tools/portgen.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* data enum, a COption) it says so in a note and a comment.
|
|
10
10
|
*/
|
|
11
11
|
import { createHash } from "node:crypto";
|
|
12
|
-
import { cNameProblem } from "../compiler/analyze.js";
|
|
12
|
+
import { ACCOUNT_MEMBERS, cNameProblem, fieldIdlName } from "../compiler/analyze.js";
|
|
13
13
|
const RESERVED = new Set("break case catch class const continue debugger default delete do else enum export extends false finally for function if import in instanceof new null return super switch this throw true try typeof var void while with yield let static implements interface package private protected public await".split(" "));
|
|
14
14
|
const camel = (s) => s.replace(/[_-]+([a-zA-Z0-9])/g, (_, c) => c.toUpperCase()).replace(/^[A-Z]/, (c) => c.toLowerCase());
|
|
15
15
|
const pascal = (s) => camel(s).replace(/^[a-z]/, (c) => c.toUpperCase());
|
|
@@ -130,6 +130,9 @@ export function generatePort(idl) {
|
|
|
130
130
|
}
|
|
131
131
|
if (t === "bytes")
|
|
132
132
|
return tsType({ vec: "u8" }, where, at, last);
|
|
133
|
+
// An f64 is held as its bits (no float arithmetic): f64FromBits / f64Bits.
|
|
134
|
+
if (t === "f64")
|
|
135
|
+
return use("f64");
|
|
133
136
|
notes.push(`${at}: IDL type "${t}" has no TypeSOL equivalent; left as u64`);
|
|
134
137
|
return `${use("u64")} /* TODO: ${t} */`;
|
|
135
138
|
}
|
|
@@ -145,7 +148,8 @@ export function generatePort(idl) {
|
|
|
145
148
|
notes.push(`${at}: a COption (4-byte tag in Anchor); TypeSOL's Option has a 1-byte tag, so this layout differs.`);
|
|
146
149
|
if (t.option || t.coption) {
|
|
147
150
|
const inner = tsType((t.option ?? t.coption), where === "variant" ? "variant" : where, at);
|
|
148
|
-
|
|
151
|
+
// A struct argument holding Options is Borsh on the wire (as Anchor sends it); account data and variants are fixed.
|
|
152
|
+
if (fixed(where) && where !== "struct")
|
|
149
153
|
notes.push(`${at}: an Option in ${describe(where)} is fixed-size in TypeSOL (1 + size of T), Borsh (1, or 1 + size) in Anchor: the layout differs.`);
|
|
150
154
|
return `${use("Option")}<${inner}>`;
|
|
151
155
|
}
|
|
@@ -182,13 +186,26 @@ export function generatePort(idl) {
|
|
|
182
186
|
return `${use("u64")} /* TODO */`;
|
|
183
187
|
};
|
|
184
188
|
/** A String, Vec or Option at a struct's top level: Borsh-sized in Anchor. */
|
|
189
|
+
const nestedOption = (t, seen = new Set()) => {
|
|
190
|
+
if (typeof t === "string")
|
|
191
|
+
return false;
|
|
192
|
+
if (t.option || t.coption)
|
|
193
|
+
return true;
|
|
194
|
+
if (t.array)
|
|
195
|
+
return nestedOption(t.array[0], seen);
|
|
196
|
+
const name = t.defined ? (typeof t.defined === "string" ? t.defined : t.defined.name) : undefined;
|
|
197
|
+
if (!name || seen.has(name))
|
|
198
|
+
return false;
|
|
199
|
+
const def = (idl.types ?? []).find((d) => d.name === name);
|
|
200
|
+
return !!def && def.type.kind === "struct" && (def.type.fields ?? []).some((f) => nestedOption(f.type, new Set([...seen, name])));
|
|
201
|
+
};
|
|
185
202
|
const borshOnly = (t) => t === "string" || t === "bytes" || (typeof t === "object" && (!!t.vec || !!t.option));
|
|
186
203
|
/** A field's type in a `@layout borsh` struct, or undefined when that layout cannot hold it. Notes the capacities. */
|
|
187
204
|
const borshField = (t, at) => {
|
|
188
205
|
const quiet = at === "";
|
|
189
206
|
const fixedOk = (u) => {
|
|
190
207
|
if (typeof u === "string")
|
|
191
|
-
return INTS.has(u) || u === "bool" || u === "pubkey" || u === "publicKey";
|
|
208
|
+
return INTS.has(u) || u === "bool" || u === "pubkey" || u === "publicKey" || u === "f64";
|
|
192
209
|
if (u.array)
|
|
193
210
|
return Number.isInteger(Number(u.array[1])) && fixedOk(u.array[0]);
|
|
194
211
|
if (u.defined) {
|
|
@@ -226,17 +243,37 @@ export function generatePort(idl) {
|
|
|
226
243
|
notes.push(`${at}: set the Vec's capacity to Anchor's #[max_len] (Borsh bytes are kept: @layout borsh)`);
|
|
227
244
|
return `${use("FixedVec")}<${elem}, 8> /* TODO: #[max_len] */`;
|
|
228
245
|
}
|
|
246
|
+
// A struct with Options inside (Marginfi's event header): Borsh at every depth, its own fields fixed or Options.
|
|
247
|
+
const nestedOk = (u) => {
|
|
248
|
+
if (typeof u !== "object" || !u.defined)
|
|
249
|
+
return false;
|
|
250
|
+
const d = defs.get(definedName(u.defined));
|
|
251
|
+
if (!d || d.type.kind !== "struct")
|
|
252
|
+
return false;
|
|
253
|
+
return (d.type.fields ?? []).every((f) => fixedOk(f.type) || nestedOk(f.type) || (typeof f.type === "object" && !!f.type.option && (fixedOk(f.type.option) || nestedOk(f.type.option))));
|
|
254
|
+
};
|
|
229
255
|
if (typeof t === "object" && t.option) {
|
|
230
|
-
if (!fixedOk(t.option))
|
|
256
|
+
if (!fixedOk(t.option) && !nestedOk(t.option))
|
|
231
257
|
return undefined;
|
|
232
|
-
return quiet ? "x" : `${use("Option")}<${tsType(t.option, "
|
|
258
|
+
return quiet ? "x" : `${use("Option")}<${tsType(t.option, "event", at)}>`;
|
|
233
259
|
}
|
|
260
|
+
if (nestedOk(t))
|
|
261
|
+
return quiet ? "x" : tsType(t, "event", at);
|
|
234
262
|
if (!fixedOk(t))
|
|
235
263
|
return undefined;
|
|
236
264
|
return quiet ? "x" : tsType(t, "account", at);
|
|
237
265
|
};
|
|
238
266
|
const esc = (s) => s.replace(/\*\//g, "* /");
|
|
239
|
-
const docs = (lines, pad = ""
|
|
267
|
+
const docs = (lines, pad = "", tags = []) => tags.length
|
|
268
|
+
? `${pad}/**\n${lines?.length ? `${pad} * ${esc(lines.join(" "))}\n` : ""}${tags.map((t) => `${pad} * ${t}\n`).join("")}${pad} */\n`
|
|
269
|
+
: lines?.length
|
|
270
|
+
? `${pad}/** ${esc(lines.join(" "))} */\n`
|
|
271
|
+
: "";
|
|
272
|
+
// What an Anchor IDL says of a zero-copy type (repr, serialization), kept as tags so the port's IDL says it too.
|
|
273
|
+
const metaTags = (def) => [
|
|
274
|
+
...(def.serialization ? [`@serialization ${def.serialization}`] : []),
|
|
275
|
+
...(def.repr ? [`@repr ${def.repr.kind}${def.repr.packed ? " packed" : ""}${def.repr.align ? ` align ${def.repr.align}` : ""}`] : []),
|
|
276
|
+
];
|
|
240
277
|
const out = [];
|
|
241
278
|
// Constants: integer literals and strings; expressions are left to port by hand.
|
|
242
279
|
for (const c of idl.constants ?? []) {
|
|
@@ -266,26 +303,34 @@ export function generatePort(idl) {
|
|
|
266
303
|
// An account struct, or one passed / returned whole, with a String, Vec or Option of its own: `@layout borsh`
|
|
267
304
|
// keeps Anchor's bytes.
|
|
268
305
|
const borshable = accountNames.has(def.name) || (whole.has(def.name) && !nested.has(def.name) && !eventNames.has(def.name));
|
|
269
|
-
const borsh = borshable && !isTuple(fields) && fields.some((f) => borshOnly(f.type)) && fields.every((f) => borshField(f.type, "") !== undefined)
|
|
306
|
+
const borsh = (borshable && !isTuple(fields) && fields.some((f) => borshOnly(f.type)) && fields.every((f) => borshField(f.type, "") !== undefined)) ||
|
|
307
|
+
// An event holding a struct with Options (Marginfi's header { signer: Option<Pubkey> }): Borsh at every depth.
|
|
308
|
+
(eventNames.has(def.name) && !isTuple(fields) && fields.some((f) => nestedOption(f.type)));
|
|
270
309
|
const tag = accountNames.has(def.name) ? " (account)" : eventNames.has(def.name) ? ` (event: emit<${typeName(def.name)}>({ … }))` : "";
|
|
271
310
|
const doc = def.docs?.length ? esc(def.docs.join(" ")) : `${def.name}${tag}`;
|
|
272
|
-
|
|
311
|
+
const typeTags = [...(borsh ? ["@layout borsh"] : []), ...metaTags(def)];
|
|
312
|
+
out.push(typeTags.length ? `/**\n * ${doc}\n${typeTags.map((t) => ` * ${t}\n`).join("")} */` : `/** ${doc} */`);
|
|
273
313
|
out.push(`export interface ${typeName(def.name)} {`);
|
|
274
314
|
const seen = new Set();
|
|
275
315
|
fields.forEach((f, i) => {
|
|
276
316
|
let n = ident(f.name, true);
|
|
317
|
+
// An account member's name (key, lamports) is held as key_, which the IDL still calls key.
|
|
318
|
+
if (ACCOUNT_MEMBERS.has(n))
|
|
319
|
+
n = `${n}_`;
|
|
277
320
|
while (seen.has(n))
|
|
278
321
|
n = `${n}2`;
|
|
279
322
|
seen.add(n);
|
|
280
323
|
const ty = borsh ? borshField(f.type, `${def.name}.${f.name}`) : tsType(f.type, where, `${def.name}.${f.name}`, i === fields.length - 1);
|
|
281
|
-
|
|
324
|
+
// The IDL's own name where TypeSOL's would differ (_pad0, integration_acc_1).
|
|
325
|
+
const tags = fieldIdlName(n) === f.name ? [] : [`@idlName ${f.name}`];
|
|
326
|
+
out.push(`${docs(f.docs, " ", tags)} ${n}: ${ty};`);
|
|
282
327
|
});
|
|
283
328
|
out.push("}", "");
|
|
284
329
|
}
|
|
285
330
|
else {
|
|
286
331
|
const variants = def.type.variants ?? [];
|
|
287
332
|
if (variants.every((v) => !v.fields?.length)) {
|
|
288
|
-
out.push(`${docs(def.docs)}export enum ${typeName(def.name)} {`, ...variants.map((v) => ` ${ident(v.name, true).replace(/^[a-z]/, (c) => c.toUpperCase())},`), "}", "");
|
|
333
|
+
out.push(`${docs(def.docs, "", metaTags(def))}export enum ${typeName(def.name)} {`, ...variants.map((v) => ` ${ident(v.name, true).replace(/^[a-z]/, (c) => c.toUpperCase())},`), "}", "");
|
|
289
334
|
}
|
|
290
335
|
else {
|
|
291
336
|
// Strings in variants are fine in arguments and events (Borsh); account data needs fixed-size variants.
|
|
@@ -296,17 +341,17 @@ export function generatePort(idl) {
|
|
|
296
341
|
: `f${i}: ${tsType(f, vw, `${def.name}.${v.name}`)}`);
|
|
297
342
|
return `{ kind: "${pascal(v.name)}"${fs.map((x) => `; ${x}`).join("")} }`;
|
|
298
343
|
});
|
|
299
|
-
out.push(`${docs(def.docs)}export type ${typeName(def.name)} =\n | ${parts.join("\n | ")};`, "");
|
|
344
|
+
out.push(`${docs(def.docs, "", metaTags(def))}export type ${typeName(def.name)} =\n | ${parts.join("\n | ")};`, "");
|
|
300
345
|
}
|
|
301
346
|
}
|
|
302
347
|
}
|
|
303
|
-
// Errors: TypeSOL numbers them 6000
|
|
304
|
-
// codes of the program's own errors do not move.
|
|
305
|
-
const errors = idl.errors ?? [];
|
|
348
|
+
// Errors: TypeSOL numbers them from 6000 in order; `/** @code N */` keeps an IDL code that skips ahead. NotPorted,
|
|
349
|
+
// last, marks the instructions still to write, so the codes of the program's own errors do not move.
|
|
350
|
+
const errors = [...(idl.errors ?? [])].sort((a, b) => a.code - b.code);
|
|
306
351
|
const program = typeName(pascal(idl.metadata?.name ?? "program"));
|
|
307
352
|
const errorEnum = `${program}Error`;
|
|
308
|
-
if (
|
|
309
|
-
notes.push(`errors:
|
|
353
|
+
if (errors.some((e, i) => e.code < 6000 || (i > 0 && e.code === errors[i - 1].code)))
|
|
354
|
+
notes.push(`errors: codes below 6000 or repeated in the IDL (${errors.map((e) => e.code).join(", ")}) cannot be kept, so clients see other codes`);
|
|
310
355
|
const memberNames = new Set();
|
|
311
356
|
const member = (name) => {
|
|
312
357
|
// RequireFailedN is TypeSOL's own name for require("message") errors; it is reserved in source.
|
|
@@ -316,7 +361,13 @@ export function generatePort(idl) {
|
|
|
316
361
|
memberNames.add(n);
|
|
317
362
|
return n;
|
|
318
363
|
};
|
|
319
|
-
|
|
364
|
+
let nextCode = 6000;
|
|
365
|
+
const errorLines = errors.flatMap((e) => {
|
|
366
|
+
const skip = e.code > nextCode ? [` /** @code ${e.code} */`] : [];
|
|
367
|
+
nextCode = Math.max(nextCode, e.code) + 1;
|
|
368
|
+
// An error without a message has none in TypeSOL's IDL either.
|
|
369
|
+
return [...skip, ` ${member(e.name)} = ${JSON.stringify(e.msg ?? "")},`];
|
|
370
|
+
});
|
|
320
371
|
const notPorted = member("NotPorted");
|
|
321
372
|
out.push(`export enum ${errorEnum} {`, ...errorLines, ` ${notPorted} = "This instruction is not ported yet",`, "}", "");
|
|
322
373
|
// Accounts of an instruction, nested groups flattened.
|
package/docs/architecture.md
CHANGED
|
@@ -31,9 +31,10 @@ program.so + program.build.json (manifest: versions, sha256 of sources and binar
|
|
|
31
31
|
| `lib/` | `typesol.d.ts`, the language surface programs typecheck against |
|
|
32
32
|
| `ts-plugin/` | The editor plugin (`typesol/ts-plugin`) |
|
|
33
33
|
| `examples/` | Example programs; the `typesol init` templates are copies of three of them |
|
|
34
|
-
| `test/` | The test suite, by subject: `language/`, `security/`, `examples/`, `integrations/` (token, Metaplex, oracle and other CPIs), `client/`, `cli/`, `
|
|
35
|
-
| `
|
|
36
|
-
| `
|
|
34
|
+
| `test/` | The compiler's test suite (`pnpm test:core`), by subject: `language/`, `security/`, `examples/`, `integrations/` (token, Metaplex, oracle and other CPIs), `client/`, `cli/`, `verification/` (differential and fuzz tests). Shared: `harness.ts` and the `*-helpers.ts`, `fixtures/` (programs the tests compile), `golden/` (pinned generated C and clients), `programs/` (third-party program binaries, see its SOURCES.md), `anchor-twins/` (below) |
|
|
35
|
+
| `showcase/` | Ports, apart from the compiler's own tests (`pnpm test:showcase`, its own CI job): `mainnet/` (Raydium CP-Swap and CLMM, Jito's MEV programs, Marginfi, coral-xyz/multisig, each checked against the binary on mainnet), `program-examples/` (TypeSOL rewrites of solana-developers/program-examples), `test/` (their differential tests, fuzzers, helpers and fixtures; `porting/` for the program-examples) |
|
|
36
|
+
| `test/anchor-twins/` | Anchor twins of the counter, vault and escrow examples, for the differential tests (`pnpm build:twins`) and the zero-copy client test; the benchmarks themselves are in [typesol-lang/benchmarks](https://github.com/typesol-lang/benchmarks) |
|
|
37
|
+
| `scripts/` | `smoke.ts`, `localnet.sh` and `localnet-fixtures.ts` (a local validator run), `fetch-programs.sh` (third-party binaries), `readme-bench.ts` (the README numbers), `codegen-snapshot.ts` (the generated C and IDL of every program, to diff a refactor), `release-manifest.ts` (a release's binary, IDL and toolchain hashes) |
|
|
37
38
|
| `docs/` | User and contributor documentation (also published on typesol.com) |
|
|
38
39
|
| `assets/` | The CLI's logo and the README images (`readme/`, generated) |
|
|
39
40
|
|
|
@@ -101,7 +102,7 @@ representation in between. We reviewed this on 2026-10-30 and kept it that way f
|
|
|
101
102
|
named in the source, see `alias.ts`), a second backend (SBF without clang), and optimizations clang cannot see
|
|
102
103
|
because they depend on account semantics (dropping a repeated check, packing a `@layout borsh` account only where
|
|
103
104
|
it changed).
|
|
104
|
-
- **What it would cost now:** rewriting most of the compiler's
|
|
105
|
+
- **What it would cost now:** rewriting most of the compiler's 14,000 lines, and losing the property every release
|
|
105
106
|
relies on: programs that do not use a change compile to the same binaries. Audit scope and differential results
|
|
106
107
|
would start over.
|
|
107
108
|
- **What we have instead:** the layers above, each owning one concern; `Ref` / `Value` as the typed place and value
|
package/docs/audit.md
CHANGED
|
@@ -7,21 +7,21 @@ with TypeSOL are out of scope; their authors audit them.
|
|
|
7
7
|
|
|
8
8
|
## Scope
|
|
9
9
|
|
|
10
|
-
In order of priority. Line counts at 0.
|
|
10
|
+
In order of priority. Line counts at 0.38.0 plus main (November 2026).
|
|
11
11
|
|
|
12
12
|
| Priority | Component | Files | Lines | Why |
|
|
13
13
|
| --- | --- | --- | ---: | --- |
|
|
14
|
-
| 1 | C runtime | `runtime/typesol_rt.h` |
|
|
15
|
-
| 1 | Instruction prologue and constraints | `src/compiler/emit/function.ts` |
|
|
16
|
-
| 1 | Account data, Vecs and assignment | `src/compiler/emit/alias.ts`, `storage.ts`, `statements.ts`, `base.ts` | 2,
|
|
17
|
-
| 1 | Calls and CPIs | `src/compiler/emit/calls.ts`, `cpi-core.ts`, `cpi.ts`, `create.ts`, `token.ts` | 3,
|
|
18
|
-
| 1 | Metaplex CPIs | `src/compiler/emit/metaplex.ts` | 1,
|
|
19
|
-
| 1 | Expressions | `src/compiler/emit/expressions.ts`, `shared.ts`, `borsh.ts` | 1,
|
|
20
|
-
| 2 | Front end | `src/compiler/analyze.ts`, `model.ts` | 2,
|
|
21
|
-
| 2 | Interface | `src/compiler/idl.ts`, `src/tools/clientgen.ts` | 2,
|
|
14
|
+
| 1 | C runtime | `runtime/typesol_rt.h` | 2,407 | In every program: input parsing, account checks, checked arithmetic, PDAs, system and token CPIs, account creation, resizing and closing, oracles, signature checks, the heap |
|
|
15
|
+
| 1 | Instruction prologue and constraints | `src/compiler/emit/function.ts` | 733 | Which checks each account parameter gets, and their order |
|
|
16
|
+
| 1 | Account data, Vecs and assignment | `src/compiler/emit/alias.ts`, `storage.ts`, `statements.ts`, `base.ts` | 2,577 | Reads and writes of account data, growable Vec layout and resizing, references and aliasing, closure and helper expansion |
|
|
17
|
+
| 1 | Calls and CPIs | `src/compiler/emit/calls.ts`, `cpi-core.ts`, `cpi.ts`, `create.ts`, `token.ts` | 3,730 | Built-ins, remaining accounts, `invoke` / `invokeInstruction` and their account flags, signer seeds, token CPIs, account creation |
|
|
18
|
+
| 1 | Metaplex CPIs | `src/compiler/emit/metaplex.ts` | 1,454 | Token Metadata, Core and Bubblegum instruction layouts and their account lists |
|
|
19
|
+
| 1 | Expressions | `src/compiler/emit/expressions.ts`, `shared.ts`, `borsh.ts` | 1,656 | Checked arithmetic and casts, Borsh encoding of arguments and `@layout borsh` accounts |
|
|
20
|
+
| 2 | Front end | `src/compiler/analyze.ts`, `model.ts` | 2,715 | What the language accepts; constraints and account types as parsed from the source |
|
|
21
|
+
| 2 | Interface | `src/compiler/idl.ts`, `src/tools/clientgen.ts` | 2,293 | The IDL and the generated client must describe the program exactly (a mismatch can make clients sign the wrong thing) |
|
|
22
22
|
| 3 | Build and tooling | `src/compiler/toolchain.ts`, `src/cli.ts`, `src/workspace.ts`, `src/tools/` | | Build flags, deploy and verification commands |
|
|
23
23
|
|
|
24
|
-
The language surface is `lib/typesol.d.ts` (
|
|
24
|
+
The language surface is `lib/typesol.d.ts` (2,057 lines): every type and built-in a program can use, with its
|
|
25
25
|
documented behavior. [docs/language.md](language.md) is the reference; [docs/architecture.md](architecture.md) maps
|
|
26
26
|
the code, [docs/runtime.md](runtime.md) the runtime's conventions.
|
|
27
27
|
|
|
@@ -48,7 +48,12 @@ accepts. Areas where a bug would be most damaging, and where earlier internal re
|
|
|
48
48
|
|
|
49
49
|
## Earlier reviews
|
|
50
50
|
|
|
51
|
-
Internal reviews, by the maintainers, in October 2026. Their findings and fixes are in the CHANGELOG
|
|
51
|
+
Internal reviews, by the maintainers, in October 2026. Their findings and fixes are in the CHANGELOG. The releases
|
|
52
|
+
after 0.25.0 (0.26.0 to 0.38.0, and main since) have had no review of this kind yet; they add, among others, `u256`,
|
|
53
|
+
big-endian seeds and accounts loaded in the body (0.37.0), stored bumps in nested fields and error members without
|
|
54
|
+
messages (0.38.0), and on main `@code`, `@repr` / `@serialization`, `@bytes` / `@idlName`, `f64`, Options inside
|
|
55
|
+
Options in arguments and events, and loop-scoped `loadAccountMut` with `Dup<T>`. An external review should include
|
|
56
|
+
them.
|
|
52
57
|
|
|
53
58
|
- **0.25.0** (runtime and emitted checks): two Medium issues fixed, a remaining account loaded mutably twice through
|
|
54
59
|
the same slot, and a Vec element written after its right side resized the Vec; plus a token program ambiguity,
|
|
@@ -60,22 +65,29 @@ Internal reviews, by the maintainers, in October 2026. Their findings and fixes
|
|
|
60
65
|
|
|
61
66
|
## Evidence
|
|
62
67
|
|
|
63
|
-
- **Tests**:
|
|
68
|
+
- **Tests**: by subject under `test/` (`docs/architecture.md`); the count of each run is in CI's log (727 on main on
|
|
69
|
+
2026-11-01). `test/security/` holds the attacks.
|
|
64
70
|
- **Differential tests**: the same transactions to TypeSOL and to Anchor twins (`test/anchor-twins`), comparing
|
|
65
71
|
outcomes, account contents and balances after every step.
|
|
66
|
-
- **Model-based fuzzing** (`test/verification/`): arithmetic against BigInt at every width
|
|
67
|
-
|
|
68
|
-
|
|
72
|
+
- **Model-based fuzzing** (`test/verification/`): arithmetic against BigInt at every width, `u256` against BigInt,
|
|
73
|
+
Marginfi's I80F48 against vectors the `fixed` crate wrote; honest and hostile action sequences against state models
|
|
74
|
+
with value conservation; account layout with two growable Vecs and aliasing through remaining accounts. Each run
|
|
75
|
+
prints its seed (`FUZZ_SEED`), `pnpm fuzz` runs them wide.
|
|
76
|
+
- **Random transactions against mainnet binaries**: Jito's three MEV programs (`showcase/test/fuzz-jito.test.ts`),
|
|
77
|
+
Marginfi's administration and interest (`showcase/test/fuzz-marginfi.test.ts`) and Raydium CLMM (the `fuzz:`
|
|
78
|
+
case of its differential test) take random sequences of honest and hostile
|
|
79
|
+
transactions, in the original and the port alike, with the same outcome, account bytes and events required after
|
|
80
|
+
every step. A new seed on every run, CI's included.
|
|
69
81
|
- **Ported programs**: all 46 programs of solana-developers/program-examples, run through their original tests' flows
|
|
70
|
-
and failure paths ([
|
|
71
|
-
- **Four-way comparison**: [typesol/benchmarks](https://github.com/typesol/benchmarks) runs 17 of those programs in
|
|
82
|
+
and failure paths ([showcase/program-examples/README.md](https://github.com/typesol-lang/typesol/blob/main/showcase/program-examples/README.md)).
|
|
83
|
+
- **Four-way comparison**: [typesol-lang/benchmarks](https://github.com/typesol-lang/benchmarks) runs 17 of those programs in
|
|
72
84
|
TypeSOL, Anchor, native Rust and Pinocchio, requires the same outcome, and records how each refuses the hostile calls
|
|
73
85
|
and with which error.
|
|
74
86
|
|
|
75
87
|
## Running it
|
|
76
88
|
|
|
77
89
|
```sh
|
|
78
|
-
git clone https://github.com/typesol/typesol && cd typesol
|
|
90
|
+
git clone https://github.com/typesol-lang/typesol && cd typesol
|
|
79
91
|
pnpm install && pnpm build
|
|
80
92
|
pnpm fetch:programs # Metaplex binaries for the token-metadata, Core and Bubblegum tests
|
|
81
93
|
pnpm build:twins # the Anchor twins (Rust + Anchor 1.0.2)
|
|
@@ -88,5 +100,5 @@ way to review what a construct compiles to; `test/golden/counter.c` is a pinned
|
|
|
88
100
|
|
|
89
101
|
## Contact
|
|
90
102
|
|
|
91
|
-
Coordinate through a private advisory on https://github.com/typesol/typesol/security, or report findings the same way
|
|
103
|
+
Coordinate through a private advisory on https://github.com/typesol-lang/typesol/security, or report findings the same way
|
|
92
104
|
(SECURITY.md).
|
|
@@ -4,7 +4,7 @@ This page follows one complete Anchor program into TypeSOL: the token escrow fro
|
|
|
4
4
|
[solana-developers/program-examples](https://github.com/solana-developers/program-examples/tree/de090195e4de698e150572c4f886c333323a64a5/tokens/escrow/anchor)
|
|
5
5
|
(`tokens/escrow`, commit `de09019`). It shows the original and the port side by side, what changed, how the two were
|
|
6
6
|
checked against each other, where they still differ, and what the port costs to run. The port is
|
|
7
|
-
[`
|
|
7
|
+
[`showcase/program-examples/tokens/escrow.ts`](https://github.com/typesol-lang/typesol/blob/main/showcase/program-examples/tokens/escrow.ts); [Migrate from Anchor](migrate-from-anchor.md) is the
|
|
8
8
|
general reference.
|
|
9
9
|
|
|
10
10
|
## The program
|
|
@@ -160,17 +160,17 @@ tokenProgram.closeAccount(vault, maker, offer, ["offer", maker.key, offer.id, of
|
|
|
160
160
|
| `ErrorCode::CustomError` (unused upstream) | `enum ErrorCode`, the same code 6000 |
|
|
161
161
|
|
|
162
162
|
Nothing in the program needed a construct TypeSOL lacks, and every account constraint has its TypeSOL form; the port
|
|
163
|
-
is marked PORTED in [the ports table](https://github.com/typesol/typesol/blob/main/
|
|
163
|
+
is marked PORTED in [the ports table](https://github.com/typesol-lang/typesol/blob/main/showcase/program-examples/README.md).
|
|
164
164
|
|
|
165
165
|
## Same inputs, same results
|
|
166
166
|
|
|
167
167
|
Two independent checks run the original and the port against each other.
|
|
168
168
|
|
|
169
|
-
- **The port's own test** ([`test/porting/ports-tokens.test.ts`](https://github.com/typesol/typesol/blob/main/test/porting/ports-tokens.test.ts)) runs the upstream flow with SPL
|
|
169
|
+
- **The port's own test** ([`showcase/test/porting/ports-tokens.test.ts`](https://github.com/typesol-lang/typesol/blob/main/showcase/test/porting/ports-tokens.test.ts)) runs the upstream flow with SPL
|
|
170
170
|
Token mints and again with Token-2022 mints: make, take (creating the taker's and the maker's missing token accounts),
|
|
171
171
|
make again, a refund attempt by someone other than the maker, and the refund. It checks balances, the decoded offer
|
|
172
172
|
and that offer and vault are closed.
|
|
173
|
-
- **The four-way comparison** in [typesol/benchmarks](https://github.com/typesol/benchmarks) builds the upstream Anchor,
|
|
173
|
+
- **The four-way comparison** in [typesol-lang/benchmarks](https://github.com/typesol-lang/benchmarks) builds the upstream Anchor,
|
|
174
174
|
native and Pinocchio versions unmodified and sends all four the same 21 offers (ten taken, ten refunded, one left
|
|
175
175
|
open). The decoded open offer, every token balance, the vault's authority and which accounts were closed must be
|
|
176
176
|
identical before any number is reported. They are.
|
|
@@ -191,7 +191,7 @@ token account. A client that matches on this code needs to accept either.
|
|
|
191
191
|
## Cost
|
|
192
192
|
|
|
193
193
|
Mean compute units per instruction in LiteSVM (21 make_offer, 10 take_offer and 10 refund_offer calls), and the
|
|
194
|
-
program size, from typesol/benchmarks (TypeSOL at this version; Anchor 1.0.2). Lower is better.
|
|
194
|
+
program size, from typesol-lang/benchmarks (TypeSOL at this version; Anchor 1.0.2). Lower is better.
|
|
195
195
|
|
|
196
196
|
| | TypeSOL | Anchor | Native Rust | Pinocchio |
|
|
197
197
|
| --- | ---: | ---: | ---: | ---: |
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# Case study: Jito's MEV programs
|
|
2
|
+
|
|
3
|
+
This page ports the three on-chain programs behind Jito's MEV tips, from
|
|
4
|
+
[jito-foundation/jito-programs](https://github.com/jito-foundation/jito-programs) (`mev-programs/programs` at ce1dfb6,
|
|
5
|
+
Anchor 0.31.1, Apache-2.0). Each one is checked against the binary that runs on mainnet, not a rebuild:
|
|
6
|
+
|
|
7
|
+
| Program | Mainnet id | Port |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| Tip payment | `T1pyyaTNZsKv2WcRAB8oVnk93mLJw2XzjtVYqCsaHqt` | [`tip_payment.ts`](https://github.com/typesol-lang/typesol/blob/main/showcase/mainnet/jito-mev/tip_payment.ts) |
|
|
10
|
+
| Tip distribution | `4R3gSG8BpU4t19KYj8CfnbtRpnT8gtk4dvTHxVRwc2r7` | [`tip_distribution.ts`](https://github.com/typesol-lang/typesol/blob/main/showcase/mainnet/jito-mev/tip_distribution.ts) |
|
|
11
|
+
| Priority fee distribution | `Priority6weCZ5HwDn29NxLFpb7TDp2iLZ6XKc5e8d3` | [`priority_fee_distribution.ts`](https://github.com/typesol-lang/typesol/blob/main/showcase/mainnet/jito-mev/priority_fee_distribution.ts) |
|
|
12
|
+
|
|
13
|
+
Searchers pay tips into eight fixed tip payment accounts. When the leader changes, the tip payment program pays them
|
|
14
|
+
out to the current tip receiver and the block builder's commission to the block builder. The tip receiver is
|
|
15
|
+
usually the validator's tip distribution account for the epoch. After the epoch, an uploaded Merkle root says who may
|
|
16
|
+
claim how much from it. The priority fee distribution program does the same for the priority fees a validator shares.
|
|
17
|
+
|
|
18
|
+
## What is ported
|
|
19
|
+
|
|
20
|
+
All 24 instructions of the three programs:
|
|
21
|
+
|
|
22
|
+
- **Tip payment.** `initialize`, which creates the config and the eight tip accounts, then `change_tip_receiver` and
|
|
23
|
+
`change_block_builder`. Each pays out the tips collected so far before it changes anything.
|
|
24
|
+
- **Tip distribution.**
|
|
25
|
+
- `initialize` and `update_config`;
|
|
26
|
+
- `initialize_tip_distribution_account`, signed by the vote account's node key;
|
|
27
|
+
- `upload_merkle_root` and `claim`, with a Merkle proof;
|
|
28
|
+
- `close_claim_status` and `close_tip_distribution_account`, once the account has expired;
|
|
29
|
+
- the merkle root upload config (`initialize_` / `update_merkle_root_upload_config`) and
|
|
30
|
+
`migrate_tda_merkle_root_upload_authority`.
|
|
31
|
+
- **Priority fee distribution.** The same ten instructions under its own names, and `transfer_priority_fee_tips`. That
|
|
32
|
+
instruction counts the fees a validator moves into its account, and moves them only from the go-live epoch on.
|
|
33
|
+
|
|
34
|
+
`merkle.ts` holds the Merkle proof check the two distribution programs share. Each file keeps its program's account
|
|
35
|
+
layouts, names, argument order and error codes. Each emits the same events and writes the same log lines.
|
|
36
|
+
|
|
37
|
+
The tip payment program on mainnet is not the one at the last commit before its deploy (b230b2b, which still has
|
|
38
|
+
`claim_tips`). Its binary has no `claim_tips` and logs the `WARN: did not transfer …` lines of #143, the "payments
|
|
39
|
+
patch". The repository merged #143 after that deploy, and ce1dfb6 has the same program. The port follows the binary.
|
|
40
|
+
|
|
41
|
+
## What it needed
|
|
42
|
+
|
|
43
|
+
- **A bump stored inside another account's struct.** Anchor's `bump = config.bumps.tip_payment_account_0` reads the
|
|
44
|
+
bump from a nested field. `Seeds<…>` now takes that path: `"@config.bumps.tip_payment_account_0"`.
|
|
45
|
+
- **An argument named like an account.** `initialize_merkle_root_upload_config` has an `authority` account and an
|
|
46
|
+
`authority` argument. TypeSOL needs distinct names, so the port names the argument `authority_`. An argument whose
|
|
47
|
+
name is an account's plus one trailing underscore keeps the account's name in the IDL, so clients encode the same
|
|
48
|
+
arguments.
|
|
49
|
+
- **Errors without messages.** The tip payment errors have no `#[msg]`. A member written `X = ""` now leaves `msg`
|
|
50
|
+
out of the IDL, as Anchor does.
|
|
51
|
+
- **Hash ordering.** The proof check orders each pair of hashes before hashing them. `Hash.compare` was already
|
|
52
|
+
compiled; its typing was missing.
|
|
53
|
+
- **One account in two writable slots.** The original lets several of these accounts be the same account:
|
|
54
|
+
- right after `initialize`, the tip receiver and the block builder are both the payer;
|
|
55
|
+
- a claimant can pay for its own claim record;
|
|
56
|
+
- a cranker can sign as the expired funds account.
|
|
57
|
+
|
|
58
|
+
`Dup<…>` lifts TypeSOL's check for exactly those parameters.
|
|
59
|
+
- **A float in a log line.** Before it goes live, `transfer_priority_fee_tips` logs the amount in SOL to five
|
|
60
|
+
decimals. Rust formats the `f64` nearest to `lamports / 1e9` with `{:.5}`. The port works this out in integers:
|
|
61
|
+
- the 53-bit mantissa of that `f64`, rounded half to even;
|
|
62
|
+
- then that binary value rounded at five decimals, ties to even.
|
|
63
|
+
|
|
64
|
+
For example, 35,000 lamports prints `0.00003`, because the `f64` is just below 0.000035, while 15,625,000 lamports
|
|
65
|
+
(exactly 1/64 SOL) prints `0.01562`. Tests for the compiler parts are in `test/language/anchor-shapes.test.ts`.
|
|
66
|
+
|
|
67
|
+
The rest uses what TypeSOL already had:
|
|
68
|
+
|
|
69
|
+
- the Merkle root as an `Option<MerkleRoot>` in a `@layout borsh` account;
|
|
70
|
+
- lamports moved directly between accounts;
|
|
71
|
+
- the vote account's node key read at bytes 4..36;
|
|
72
|
+
- explicit account sizes where Anchor reserves the Rust struct's padded size (tip distribution's `Config` is 88
|
|
73
|
+
bytes, its `TipDistributionAccount` 168).
|
|
74
|
+
|
|
75
|
+
## How it was checked
|
|
76
|
+
|
|
77
|
+
[`showcase/test/jito-mev.test.ts`](https://github.com/typesol-lang/typesol/blob/main/showcase/test/jito-mev.test.ts) loads
|
|
78
|
+
the binaries dumped from mainnet on 2026-10-31 (sha256 in
|
|
79
|
+
[`test/programs/SOURCES.md`](https://github.com/typesol-lang/typesol/blob/main/test/programs/SOURCES.md)). A dump is padded
|
|
80
|
+
with zeros to its program account's size, 10 MB for tip distribution, so the files are cut where the ELF ends. Each
|
|
81
|
+
original runs in one LiteSVM and its port in another, under the same program id and with the same clock.
|
|
82
|
+
|
|
83
|
+
- **Vote accounts** are written in both: owned by the Vote program, with the node key at bytes 4..36.
|
|
84
|
+
- **Tips** are added to an account's lamports in both, as a searcher's transfer would add them.
|
|
85
|
+
- **Merkle trees** are built in the test as Jito's tooling builds them:
|
|
86
|
+
- leaves are `sha256(0x00 ‖ sha256(claimant ‖ amount))`;
|
|
87
|
+
- nodes are `sha256(0x01 ‖ lower ‖ higher)`.
|
|
88
|
+
- **Epochs** move by setting the clock in both.
|
|
89
|
+
|
|
90
|
+
For each transaction, the test requires the same outcome (success, or the same error down to the code). It also
|
|
91
|
+
requires the same lamports, owner and data for every account involved, the same events byte for byte, and the same
|
|
92
|
+
log lines the programs write themselves (the `WARN` lines and the not-live message).
|
|
93
|
+
|
|
94
|
+
There are 150 transactions:
|
|
95
|
+
|
|
96
|
+
- **Tip payment (26).**
|
|
97
|
+
- `initialize`; refused at the wrong PDA, over a tip account that already holds lamports, and a second time.
|
|
98
|
+
- Receivers and block builders changed, with tips paid out at commissions of 0, 7, 50 and 100%, including to one
|
|
99
|
+
account that is both receiver and builder.
|
|
100
|
+
- Refusals: the wrong old receiver or builder, a commission over 100%, a new receiver or builder that is a program,
|
|
101
|
+
a loader's account, a sysvar or a Config program account.
|
|
102
|
+
- A payout to an empty account that would stay below rent: its share goes back into tip account 0, with the
|
|
103
|
+
warning.
|
|
104
|
+
- Tip account 0 itself as the receiver; a tip account below rent.
|
|
105
|
+
- **Tip distribution (48).**
|
|
106
|
+
- The config: invalid ones (0 or 11 epochs, a commission cap over 100%, the default key), then created and updated.
|
|
107
|
+
- Validators' accounts: commission over the cap, not the node key, not a vote account.
|
|
108
|
+
- Roots: uploaded too early, by the wrong authority, replaced before any claim, refused after one.
|
|
109
|
+
- Claims: unsigned, the wrong amount or proof, claimed twice, over the root's total, expired; one paid by the
|
|
110
|
+
claimant.
|
|
111
|
+
- Claim records and accounts closed before and after they expire, to the wrong account, with the wrong epoch seed.
|
|
112
|
+
- The upload config created and changed, and an account migrated to the override authority (and not one with a
|
|
113
|
+
root).
|
|
114
|
+
- **Priority fee distribution (76).** The same, plus `transfer_priority_fee_tips`:
|
|
115
|
+
- 22 amounts before go-live, including exact binary ties and 1.8 × 10¹⁹ lamports, each logged as the original logs
|
|
116
|
+
it;
|
|
117
|
+
- a go-live epoch in the future, then the current one;
|
|
118
|
+
- a transfer into last epoch's account.
|
|
119
|
+
|
|
120
|
+
Besides these, `showcase/test/fuzz-jito.test.ts` sends random sequences of the same transactions, honest and
|
|
121
|
+
hostile, to the originals and the ports, with a new seed on every run (CI's included). It requires the same outcome,
|
|
122
|
+
bytes, events and log lines after every step; `FUZZ_SEED=<seed>` reproduces a run, `FUZZ_STEPS=<n>` lengthens it.
|
|
123
|
+
|
|
124
|
+
## Cost
|
|
125
|
+
|
|
126
|
+
Compute units per transaction, mainnet original against the port, from one run of that test:
|
|
127
|
+
|
|
128
|
+
| Instruction | Jito (mainnet) | TypeSOL | |
|
|
129
|
+
| --- | ---: | ---: | ---: |
|
|
130
|
+
| tip payment `initialize` | 60,085 | 23,628 | −61% |
|
|
131
|
+
| `change_tip_receiver`, the receiver also the builder (both shares to one account) | 29,889 | 7,723 | −74% |
|
|
132
|
+
| `change_block_builder`, a 7% commission paid first | 29,911 | 7,736 | −74% |
|
|
133
|
+
| `change_tip_receiver`, a share kept in tip account 0 | 41,355 | 9,192 | −78% |
|
|
134
|
+
| tip distribution `initialize` | 7,284 | 1,946 | −73% |
|
|
135
|
+
| `initialize_tip_distribution_account` | 10,007 | 2,624 | −74% |
|
|
136
|
+
| `upload_merkle_root` | 3,943 | 977 | −75% |
|
|
137
|
+
| `claim` | 13,067 | 3,940 | −70% |
|
|
138
|
+
| `close_claim_status` | 4,302 | 1,036 | −76% |
|
|
139
|
+
| `close_tip_distribution_account` | 5,735 | 1,561 | −73% |
|
|
140
|
+
| `update_config` | 2,850 | 645 | −77% |
|
|
141
|
+
| `migrate_tda_merkle_root_upload_authority` | 6,467 | 1,342 | −79% |
|
|
142
|
+
| priority fee `claim` | 12,730 | 3,933 | −69% |
|
|
143
|
+
| `transfer_priority_fee_tips`, live | 6,059 | 2,014 | −67% |
|
|
144
|
+
| `transfer_priority_fee_tips`, not live (logs SOL) | 6,362 | 2,673 | −58% |
|
|
145
|
+
|
|
146
|
+
`claim` and the account openings vary from run to run with the PDA bump searches of the random keys the test uses,
|
|
147
|
+
in both programs alike.
|
|
148
|
+
|
|
149
|
+
| Binary | Jito (mainnet, ELF without the padding) | TypeSOL |
|
|
150
|
+
| --- | ---: | ---: |
|
|
151
|
+
| Tip payment | 297,848 bytes | 47,128 bytes |
|
|
152
|
+
| Tip distribution | 342,432 bytes | 46,848 bytes |
|
|
153
|
+
| Priority fee distribution | 387,440 bytes | 61,432 bytes |
|
|
154
|
+
|
|
155
|
+
## Where they differ
|
|
156
|
+
|
|
157
|
+
- **A short vote account.** With fewer than 36 bytes of data, the original panics slicing the node key out. The port
|
|
158
|
+
fails with 3003 (AccountDidNotDeserialize).
|
|
159
|
+
- **Check order on double faults.** Anchor checks the accounts one at a time, in their order. The port checks every
|
|
160
|
+
account's owner, discriminator, signer and seeds first, then the constraints. A transaction that breaks one check
|
|
161
|
+
gets the same code. One that breaks two at once can be reported differently.
|
|
162
|
+
- **Other accounts passed twice.** `Dup<…>` lifts the check only for the accounts listed above, and only against
|
|
163
|
+
accounts read and written in place. Any other account passed twice is refused (2040) where the original would run
|
|
164
|
+
it: for example, a tip distribution account (a Borsh account, copied out and back) as its own claimant.
|
|
165
|
+
- **IDL.**
|
|
166
|
+
- `ValidatorCommissionBpsUpdatedEvent` and `MerkleRootUploadAuthorityUpdatedEvent`, which no instruction emits, are
|
|
167
|
+
not in the distribution ports' IDLs.
|
|
168
|
+
- The port's IDLs also list the PDA seeds and fixed addresses that the IDLs in Jito's repository leave out.
|
|
169
|
+
Names, discriminators, arguments, accounts and errors match.
|
|
170
|
+
- **Logs.** The original logs `Instruction: …` before each instruction and Anchor's error text on failure. The port
|
|
171
|
+
logs neither; its errors are TypeSOL's messages with the same codes. The programs' own lines are the same.
|