ckb-cycle-tools 1.1.0 → 1.3.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.
@@ -0,0 +1,107 @@
1
+ /**
2
+ * What a report's numbers were measured with, so two reports can be checked for
3
+ * comparability (review #46, point 4): the tool, the debugger binary, the
4
+ * commit, the toolchain, and per scenario the CKB-VM version, a hash of its
5
+ * inputs and the binaries swapped into it. Node only (hashes files, runs git);
6
+ * the shape is in diff.ts, which compares it.
7
+ */
8
+ import { execFile } from "node:child_process";
9
+ import { createHash } from "node:crypto";
10
+ import { createReadStream } from "node:fs";
11
+ import { readFile } from "node:fs/promises";
12
+ export const sha256 = (data) => createHash("sha256").update(data).digest("hex");
13
+ /** The sha256 and size of a file, read as a stream (a debugger binary is tens of MB). */
14
+ export function fileDigest(path) {
15
+ return new Promise((resolve, reject) => {
16
+ const hash = createHash("sha256");
17
+ let size = 0;
18
+ createReadStream(path)
19
+ .on("data", (chunk) => {
20
+ const bytes = typeof chunk === "string" ? Buffer.from(chunk) : chunk;
21
+ size += bytes.length;
22
+ hash.update(bytes);
23
+ })
24
+ .on("error", reject)
25
+ .on("end", () => resolve({ sha256: hash.digest("hex"), size }));
26
+ });
27
+ }
28
+ /** This package's name and version, from its package.json ("unknown" if it cannot be read). */
29
+ export async function toolIdentity() {
30
+ try {
31
+ const pkg = JSON.parse(await readFile(new URL("../package.json", import.meta.url), "utf8"));
32
+ return { name: String(pkg.name ?? "ckb-cycle-tools"), version: String(pkg.version ?? "unknown") };
33
+ }
34
+ catch {
35
+ return { name: "ckb-cycle-tools", version: "unknown" };
36
+ }
37
+ }
38
+ const COMMIT = /^[0-9a-f]{40}([0-9a-f]{24})?$/;
39
+ /**
40
+ * The commit checked out at `dir`, or undefined: not a git checkout, no git, or
41
+ * anything else. Never fails the report. Only a commit id is kept, whatever git printed.
42
+ */
43
+ export function gitCommit(dir) {
44
+ return new Promise((resolve) => {
45
+ try {
46
+ execFile("git", ["rev-parse", "--verify", "--quiet", "HEAD"], { cwd: dir, timeout: 10_000, windowsHide: true, env: { ...process.env, GIT_OPTIONAL_LOCKS: "0", GIT_TERMINAL_PROMPT: "0" } }, (err, stdout) => {
47
+ const out = String(stdout ?? "").trim().toLowerCase();
48
+ resolve(!err && COMMIT.test(out) ? out : undefined);
49
+ });
50
+ }
51
+ catch {
52
+ resolve(undefined);
53
+ }
54
+ });
55
+ }
56
+ /** JSON with object keys sorted at every level: the same value always gives the same text. */
57
+ export function canonicalJson(value) {
58
+ if (Array.isArray(value))
59
+ return `[${value.map(canonicalJson).join(",")}]`;
60
+ if (value && typeof value === "object") {
61
+ const o = value;
62
+ return `{${Object.keys(o)
63
+ .filter((k) => o[k] !== undefined)
64
+ .sort()
65
+ .map((k) => `${JSON.stringify(k)}:${canonicalJson(o[k])}`)
66
+ .join(",")}}`;
67
+ }
68
+ return JSON.stringify(value) ?? "null";
69
+ }
70
+ /**
71
+ * The part of a scenario's cycles.json entry that decides what runs: its form
72
+ * (and transaction hash), the binaries it names, its CKB-VM version, and for a
73
+ * transaction fetched from a node, the network. Not its name (the key it is
74
+ * matched by), the path of its file (whose bytes are hashed instead: a moved
75
+ * file with the same bytes is the same input), nor `functions` (which records
76
+ * names, not cycles).
77
+ */
78
+ export function scenarioInputs(s, network) {
79
+ const kind = s.mock !== undefined ? "mock" : s.file !== undefined ? "file" : "tx";
80
+ return {
81
+ kind,
82
+ ...(s.tx !== undefined && { tx: s.tx.toLowerCase() }),
83
+ ...(s.binaries !== undefined && { binaries: [...s.binaries].sort() }),
84
+ ...(s.scriptVersion !== undefined && { scriptVersion: s.scriptVersion }),
85
+ ...(kind !== "mock" && { network: network ?? null }),
86
+ };
87
+ }
88
+ /**
89
+ * sha256 over a scenario's inputs: the canonical entry (scenarioInputs), then
90
+ * the bytes of its mock or transaction file exactly as read, if it has one.
91
+ */
92
+ export function inputsHash(entry, file) {
93
+ const h = createHash("sha256");
94
+ h.update("ckb-cycles inputs v1\n");
95
+ h.update(canonicalJson(entry));
96
+ h.update("\n");
97
+ if (file)
98
+ h.update(file);
99
+ return h.digest("hex");
100
+ }
101
+ /** The longest toolchain description a report keeps. */
102
+ export const TOOLCHAIN_MAX = 4096;
103
+ /** A toolchain description as a report keeps it: trimmed, clipped; undefined when empty. */
104
+ export function toolchainOf(s) {
105
+ const t = (s ?? "").trim();
106
+ return t ? (t.length > TOOLCHAIN_MAX ? `${t.slice(0, TOOLCHAIN_MAX - 1)}…` : t) : undefined;
107
+ }
package/dist/mock.d.ts CHANGED
@@ -82,6 +82,11 @@ export interface NodeConsensus {
82
82
  /** "mainnet", "testnet", or the chain id for any other chain. */
83
83
  network: string;
84
84
  vmEpochs: VmEpochs;
85
+ /**
86
+ * The consensus `max_block_cycles`, when the node gives it: the node verifies
87
+ * each transaction under this one limit (see DEFAULT_TX_CYCLE_LIMIT).
88
+ */
89
+ maxBlockCycles?: bigint;
85
90
  }
86
91
  /**
87
92
  * Asks the node which chain it serves and when its hardforks took effect, so a
package/dist/mock.js CHANGED
@@ -94,7 +94,8 @@ export async function nodeConsensus(rpc) {
94
94
  return f.epoch_number === null ? Infinity : Number(f.epoch_number);
95
95
  };
96
96
  const network = c.id === "ckb" ? "mainnet" : c.id === "ckb_testnet" ? "testnet" : c.id;
97
- return { chain: c.id, network, vmEpochs: [epochOf("0032"), epochOf("0049")] };
97
+ const max = typeof c.max_block_cycles === "string" && /^0x[0-9a-fA-F]+$/.test(c.max_block_cycles) ? BigInt(c.max_block_cycles) : undefined;
98
+ return { chain: c.id, network, vmEpochs: [epochOf("0032"), epochOf("0049")], ...(max !== undefined && max > 0n && { maxBlockCycles: max }) };
98
99
  }
99
100
  /** Parses a molecule OutPointVec: u32 LE count, then 36-byte out points. */
100
101
  export function parseOutPointVec(data) {
package/dist/profile.d.ts CHANGED
@@ -49,6 +49,12 @@ export interface FlameGroup {
49
49
  /** With `bin`: the exit code of that run (with the deployed binary), and whether the VM stopped it. */
50
50
  deployedResult?: number;
51
51
  deployedError?: string;
52
+ /**
53
+ * How many scripts this group's script spawned (CKB2023 `spawn`). ckb-debugger
54
+ * profiles only the root script: the spawned ones' cycles are in `cycles`
55
+ * but in no frame of `folded`, and `--bin` replaces only the root's binary.
56
+ */
57
+ spawned?: number;
52
58
  }
53
59
  /**
54
60
  * Profiles each script group with ckb-debugger's flamegraph mode. `bins` maps a
package/dist/profile.js CHANGED
@@ -5,7 +5,7 @@ import { join } from "node:path";
5
5
  import { promisify } from "node:util";
6
6
  import { checkDebuggerPath, resolveDebugger } from "./debugger.js";
7
7
  import { elfFunctionNames } from "./elf.js";
8
- import { nameAddresses, parseFolded } from "./flame.js";
8
+ import { nameAddresses, parseFolded, spawnedScripts } from "./flame.js";
9
9
  import { debuggerArgs, parseDebuggerRun, planReplay, replayGroups, selectorFor, TYPE_ID_CODE_HASH, } from "./replay.js";
10
10
  // The pure parts live in replay.ts, shared with the browser; existing imports keep working.
11
11
  export { checkTypeId, parseDebuggerOutput, parseDebuggerRun, parseNames, readTransactionJson, selectorFor, TYPE_ID_CODE_HASH, TYPE_ID_CYCLES, } from "./replay.js";
@@ -112,6 +112,7 @@ export async function flameTransaction(target, options) {
112
112
  "--flamegraph-output",
113
113
  out,
114
114
  ]);
115
+ const spawned = spawnedScripts(runOut.stdout);
115
116
  const names = bin ? await namesOf(bin) : new Map();
116
117
  const folded = nameAddresses(parseFolded(await options.readFile(out).catch(() => "")), names);
117
118
  // Flamegraph mode leaves out loading the binary, so result and cycles come
@@ -127,6 +128,7 @@ export async function flameTransaction(target, options) {
127
128
  ...(parsed.error && { error: parsed.error }),
128
129
  cycles: parsed.cycles,
129
130
  folded,
131
+ ...(spawned && { spawned }),
130
132
  ...(bin &&
131
133
  deployed && {
132
134
  bin,
package/dist/replay.d.ts CHANGED
@@ -10,6 +10,12 @@ export interface GroupRun {
10
10
  cycles: bigint;
11
11
  /** Lines the script printed through ckb_debug. */
12
12
  logs: string[];
13
+ /**
14
+ * Set only when some group rejects: whether the node would run this group at
15
+ * all. It verifies groups in its own order (nodeOrder) and stops at the first
16
+ * one that fails, so the groups after that one never run there.
17
+ */
18
+ nodeReaches?: boolean;
13
19
  }
14
20
  export type ProfiledGroup = ScriptGroup & GroupRun;
15
21
  export interface Profile {
@@ -18,8 +24,30 @@ export interface Profile {
18
24
  status: string;
19
25
  /** Total cycles as reported by the node. */
20
26
  nodeCycles?: bigint;
21
- /** Sum of the per-group cycles measured by ckb-debugger. */
27
+ /**
28
+ * Sum of the per-group cycles measured by ckb-debugger, each group run on its
29
+ * own. When a group rejects, this is not what the node spent: see nodeStopsAt.
30
+ */
22
31
  measuredCycles: bigint;
32
+ /**
33
+ * Set when some group rejects: the selector of the group the node would stop
34
+ * at, the first failing one in the node's order (nodeOrder). The node then
35
+ * rejects the transaction and reports no cycles for it.
36
+ */
37
+ nodeStopsAt?: string;
38
+ /**
39
+ * Set only when the groups' cycles add up to more than the node's limit for
40
+ * one transaction (`limit`: the consensus `max_block_cycles`, or
41
+ * DEFAULT_TX_CYCLE_LIMIT). ckb-debugger gives every group that limit on its
42
+ * own; the node gives the whole transaction that limit, each group what the
43
+ * ones before it left, so it would reject this transaction (exceeded max
44
+ * cycles). `nodeStopsAt` then names the group at which the running sum, in
45
+ * the node's order, passes the limit, unless a failing group comes first.
46
+ */
47
+ overTxLimit?: {
48
+ limit: bigint;
49
+ sum: bigint;
50
+ };
23
51
  groups: ProfiledGroup[];
24
52
  /** Where the numbers came from, so a result can be reproduced. */
25
53
  env: {
@@ -49,7 +77,19 @@ export interface ReplayOptions {
49
77
  * transaction's block, or the current one (2) for a transaction not on chain.
50
78
  */
51
79
  scriptVersion?: 0 | 1 | 2;
80
+ /**
81
+ * The node's cycle limit for one transaction. By default, the `max_block_cycles`
82
+ * of the node's `get_consensus` when it was asked, else DEFAULT_TX_CYCLE_LIMIT.
83
+ */
84
+ txCycleLimit?: bigint;
52
85
  }
86
+ /**
87
+ * The node's cycle limit for one transaction when its consensus is not known:
88
+ * `max_block_cycles` on mainnet and testnet. The node verifies a transaction's
89
+ * groups one after another under this one budget (each gets what the ones
90
+ * before it left), where ckb-debugger gives each group all of it.
91
+ */
92
+ export declare const DEFAULT_TX_CYCLE_LIMIT = 3500000000n;
53
93
  /**
54
94
  * Type ID is verified natively by the node rather than by a script binary, so
55
95
  * ckb-debugger cannot run it. The node charges it a fixed cost (TYPE_ID_CYCLES
@@ -111,6 +151,8 @@ export interface ReplayPlan {
111
151
  /** "testnet", "mainnet", or a devnet's chain id: what the node says it serves, when it was asked. */
112
152
  network: string;
113
153
  rpcUrl: string;
154
+ /** The node's limit for one transaction, when known (the option, or the node's `max_block_cycles`); else DEFAULT_TX_CYCLE_LIMIT applies. */
155
+ txCycleLimit?: bigint;
114
156
  }
115
157
  /**
116
158
  * Refuses a mock transaction that ckb-debugger would read as more than data.
@@ -155,6 +197,61 @@ export declare function replayGroups(plan: ReplayPlan, run: RunDebugger, options
155
197
  debugger: string;
156
198
  onGroup?: (index: number, selector: string) => void;
157
199
  }): Promise<Profile>;
200
+ /**
201
+ * The groups in the order the node verifies them: every lock group, then every
202
+ * type group, each set sorted by script hash (byte order, the same as the order
203
+ * of the lowercase hex). ckb-script keeps them in two BTreeMaps keyed by script
204
+ * hash and chains locks before types (TxData::new and TxInfo::groups in
205
+ * script/src/types.rs); TransactionScriptsVerifier::verify (script/src/verify.rs)
206
+ * runs them in that order and returns at the first error, with no cycles.
207
+ * Groups are listed elsewhere in first-appearance order, which is not this one.
208
+ */
209
+ export declare function nodeOrder<G extends {
210
+ role: "lock" | "type";
211
+ scriptHash: string;
212
+ }>(groups: G[]): G[];
213
+ /** A group the node would count as a failure: a non-zero exit, a VM stop, a refused Type ID. */
214
+ export declare const rejects: (g: {
215
+ result: number;
216
+ error?: string;
217
+ }) => boolean;
218
+ /**
219
+ * Where the node would stop, for a transaction some group rejects: the first
220
+ * failing group in nodeOrder, and the groups the node reaches (every one up to
221
+ * and including it). Undefined when every group accepts.
222
+ *
223
+ * With `limit` (the node's cycle limit for the transaction), a group at which
224
+ * the running sum of cycles in nodeOrder passes the limit also stops the node
225
+ * (exceeded max cycles), even though it accepts on its own here: the node gives
226
+ * each group only what the ones before it left. `overLimit` says that is why.
227
+ */
228
+ export declare function nodeStop<G extends {
229
+ role: "lock" | "type";
230
+ scriptHash: string;
231
+ result: number;
232
+ error?: string;
233
+ cycles?: bigint;
234
+ }>(groups: G[], limit?: bigint): {
235
+ stopsAt: G;
236
+ reaches: Set<G>;
237
+ overLimit?: boolean;
238
+ } | undefined;
239
+ /**
240
+ * The line(s) a profile's table ends its groups with: the sum. For a transaction
241
+ * every group accepts it is what the node spends, and the CLI checks it against
242
+ * the node. When a group rejects, the node would stop at the first failing group
243
+ * in its order and report no cycles, so the sum is labelled as what it is: every
244
+ * group run on its own. `name` cleans script names for the output (termLine).
245
+ */
246
+ export declare function sumLines(p: Profile, name?: (s: string) => string): string[];
247
+ /**
248
+ * What a transaction whose groups add up to more than the node's limit for one
249
+ * transaction is told: the CLI, a report and the web page say the same.
250
+ */
251
+ export declare function overTxLimitLines(o: {
252
+ limit: bigint | number;
253
+ sum: bigint | number;
254
+ }): string[];
158
255
  /** How a profile's total compares with the node's: what the CLI and the web page both print. */
159
256
  export declare function nodeVerdict(p: Profile): "match" | "mismatch" | "not recorded" | undefined;
160
257
  /**
package/dist/replay.js CHANGED
@@ -9,6 +9,13 @@ import { ccc } from "@ckb-ccc/core";
9
9
  import { cccA } from "@ckb-ccc/core/advanced";
10
10
  import { groupScripts, knownScriptNames } from "./analyze.js";
11
11
  import { buildMockTransaction, httpRpc, isCellbase, mockFromTransaction, nodeConsensus, scriptVersionAt, } from "./mock.js";
12
+ /**
13
+ * The node's cycle limit for one transaction when its consensus is not known:
14
+ * `max_block_cycles` on mainnet and testnet. The node verifies a transaction's
15
+ * groups one after another under this one budget (each gets what the ones
16
+ * before it left), where ckb-debugger gives each group all of it.
17
+ */
18
+ export const DEFAULT_TX_CYCLE_LIMIT = 3500000000n;
12
19
  /**
13
20
  * Type ID is verified natively by the node rather than by a script binary, so
14
21
  * ckb-debugger cannot run it. The node charges it a fixed cost (TYPE_ID_CYCLES
@@ -177,6 +184,7 @@ export async function planReplay(target, options = {}) {
177
184
  ]);
178
185
  const { mock, cycles, status, epoch } = fetched;
179
186
  const network = consensus?.network ?? options.network ?? "testnet";
187
+ const txCycleLimit = options.txCycleLimit ?? consensus?.maxBlockCycles;
180
188
  const groups = groupsOf(mock);
181
189
  // Known-script names are CCC's table for the network, through the same node;
182
190
  // a network CCC does not know (a devnet) names its scripts with `scriptNames`.
@@ -202,6 +210,7 @@ export async function planReplay(target, options = {}) {
202
210
  (epoch === undefined ? 2 : scriptVersionAt(consensus?.vmEpochs ?? (network === "mainnet" ? "mainnet" : "testnet"), epoch)),
203
211
  network,
204
212
  rpcUrl,
213
+ ...(txCycleLimit !== undefined && { txCycleLimit }),
205
214
  };
206
215
  }
207
216
  /**
@@ -246,15 +255,112 @@ export async function replayGroups(plan, run, options) {
246
255
  const out = await run(debuggerArgs(options.txFile, selector, plan.scriptVersion));
247
256
  profiled.push({ ...g, selector, ...(typeof out === "string" ? parseDebuggerOutput(out) : parseDebuggerRun(out)) });
248
257
  }
258
+ const limit = plan.txCycleLimit ?? DEFAULT_TX_CYCLE_LIMIT;
259
+ const stop = nodeStop(profiled, limit);
260
+ if (stop)
261
+ for (const g of profiled)
262
+ g.nodeReaches = stop.reaches.has(g);
263
+ const measuredCycles = profiled.reduce((sum, g) => sum + g.cycles, 0n);
249
264
  return {
250
265
  hash: plan.hash,
251
266
  status: plan.status,
252
267
  ...(plan.nodeCycles !== undefined && { nodeCycles: plan.nodeCycles }),
253
- measuredCycles: profiled.reduce((sum, g) => sum + g.cycles, 0n),
268
+ measuredCycles,
269
+ ...(stop && { nodeStopsAt: stop.stopsAt.selector }),
270
+ ...(measuredCycles > limit && { overTxLimit: { limit, sum: measuredCycles } }),
254
271
  groups: profiled,
255
272
  env: { debugger: options.debugger, network: plan.network, rpcUrl: plan.rpcUrl, scriptVersion: plan.scriptVersion },
256
273
  };
257
274
  }
275
+ /**
276
+ * The groups in the order the node verifies them: every lock group, then every
277
+ * type group, each set sorted by script hash (byte order, the same as the order
278
+ * of the lowercase hex). ckb-script keeps them in two BTreeMaps keyed by script
279
+ * hash and chains locks before types (TxData::new and TxInfo::groups in
280
+ * script/src/types.rs); TransactionScriptsVerifier::verify (script/src/verify.rs)
281
+ * runs them in that order and returns at the first error, with no cycles.
282
+ * Groups are listed elsewhere in first-appearance order, which is not this one.
283
+ */
284
+ export function nodeOrder(groups) {
285
+ const rank = (g) => (g.role === "lock" ? 0 : 1);
286
+ return [...groups].sort((a, b) => {
287
+ if (rank(a) !== rank(b))
288
+ return rank(a) - rank(b);
289
+ const x = a.scriptHash.toLowerCase();
290
+ const y = b.scriptHash.toLowerCase();
291
+ return x < y ? -1 : x > y ? 1 : 0;
292
+ });
293
+ }
294
+ /** A group the node would count as a failure: a non-zero exit, a VM stop, a refused Type ID. */
295
+ export const rejects = (g) => g.result !== 0 || g.error !== undefined;
296
+ /**
297
+ * Where the node would stop, for a transaction some group rejects: the first
298
+ * failing group in nodeOrder, and the groups the node reaches (every one up to
299
+ * and including it). Undefined when every group accepts.
300
+ *
301
+ * With `limit` (the node's cycle limit for the transaction), a group at which
302
+ * the running sum of cycles in nodeOrder passes the limit also stops the node
303
+ * (exceeded max cycles), even though it accepts on its own here: the node gives
304
+ * each group only what the ones before it left. `overLimit` says that is why.
305
+ */
306
+ export function nodeStop(groups, limit) {
307
+ const ordered = nodeOrder(groups);
308
+ let sum = 0n;
309
+ for (const [at, g] of ordered.entries()) {
310
+ sum += g.cycles ?? 0n;
311
+ const over = limit !== undefined && sum > limit;
312
+ if (rejects(g) || over) {
313
+ return { stopsAt: g, reaches: new Set(ordered.slice(0, at + 1)), ...(!rejects(g) && { overLimit: true }) };
314
+ }
315
+ }
316
+ return undefined;
317
+ }
318
+ /**
319
+ * The line(s) a profile's table ends its groups with: the sum. For a transaction
320
+ * every group accepts it is what the node spends, and the CLI checks it against
321
+ * the node. When a group rejects, the node would stop at the first failing group
322
+ * in its order and report no cycles, so the sum is labelled as what it is: every
323
+ * group run on its own. `name` cleans script names for the output (termLine).
324
+ */
325
+ export function sumLines(p, name = (s) => s) {
326
+ const n = (x) => x.toLocaleString("en-US");
327
+ if (p.nodeStopsAt === undefined)
328
+ return [`measured (sum of groups) ${n(p.measuredCycles)}`];
329
+ const stop = p.groups.find((g) => g.selector === p.nodeStopsAt);
330
+ const label = stop?.name ? `${p.nodeStopsAt} (${name(stop.name)})` : p.nodeStopsAt;
331
+ const out = p.overTxLimit && stop && !rejects(stop)
332
+ ? [
333
+ `sum of groups, each run on its own ${n(p.measuredCycles)}`,
334
+ ...overTxLimitLines(p.overTxLimit).map((l) => ` ${l}`),
335
+ ` ckb-debugger gives each group the whole limit; the node gives each group what the`,
336
+ ` ones before it left, so it stops at ${label}, where the running sum passes it`,
337
+ ` (it runs lock groups, then type groups, each in script-hash order)`,
338
+ ]
339
+ : [
340
+ `sum of groups, each run on its own ${n(p.measuredCycles)}`,
341
+ ` not what the node spends: it stops at the first failing group, ${label},`,
342
+ ` and reports no cycles for a rejected tx (it runs lock groups, then type groups,`,
343
+ ` each in script-hash order)`,
344
+ ...(p.overTxLimit ? [` the sum is also over the node's per-transaction limit of ${n(p.overTxLimit.limit)} cycles`] : []),
345
+ ];
346
+ const skipped = p.groups.filter((g) => g.nodeReaches === false).map((g) => g.selector);
347
+ if (skipped.length) {
348
+ const shown = skipped.slice(0, 8).join(", ");
349
+ out.push(` the node never runs: ${shown}${skipped.length > 8 ? `, and ${skipped.length - 8} more` : ""}`);
350
+ }
351
+ return out;
352
+ }
353
+ /**
354
+ * What a transaction whose groups add up to more than the node's limit for one
355
+ * transaction is told: the CLI, a report and the web page say the same.
356
+ */
357
+ export function overTxLimitLines(o) {
358
+ const n = (x) => x.toLocaleString("en-US");
359
+ return [
360
+ `over the node's per-transaction limit of ${n(o.limit)} cycles: the node would reject`,
361
+ `this transaction (exceeded max cycles)`,
362
+ ];
363
+ }
258
364
  /** How a profile's total compares with the node's: what the CLI and the web page both print. */
259
365
  export function nodeVerdict(p) {
260
366
  if (p.nodeCycles !== undefined)
package/dist/report.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CycleReport, GroupResult, ScenarioResult } from "./diff.js";
1
+ import type { CycleReport, GroupResult, ReportManifest, ScenarioResult } from "./diff.js";
2
2
  import { type RpcOutPoint } from "./mock.js";
3
3
  import { type Profile, type ProfileOptions } from "./profile.js";
4
4
  export interface BinaryConfig {
@@ -64,6 +64,17 @@ export interface ReportOptions {
64
64
  onScenario?: (s: ScenarioResult) => void;
65
65
  /** Runs ckb-debugger instead of the native binary (see ProfileOptions): for tests. */
66
66
  runDebugger?: ProfileOptions["runDebugger"];
67
+ /**
68
+ * With `runDebugger`: what it runs, for the manifest (a WebAssembly build's
69
+ * id, or a native binary's sha256). Without `runDebugger`, the binary that
70
+ * runs is hashed instead.
71
+ */
72
+ debuggerBuild?: {
73
+ wasm?: string;
74
+ sha256?: string;
75
+ };
76
+ /** Free text for the manifest: the compiler and build profile the binaries were built with (e.g. `rustc -V`). */
77
+ toolchain?: string;
67
78
  }
68
79
  export declare function groupResults(p: Profile): GroupResult[];
69
80
  /**
@@ -74,6 +85,7 @@ export declare function groupResults(p: Profile): GroupResult[];
74
85
  export declare function runReport(configPath: string, options?: ReportOptions): Promise<CycleReport & {
75
86
  errors: string[];
76
87
  notices?: string[];
88
+ manifest: ReportManifest;
77
89
  }>;
78
90
  /**
79
91
  * `file` with its symlinks resolved, when it is inside one of `roots` (already