Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
f84130a
feat(monitor): Page every operation the governance timelock schedules
ebma Oct 21, 2026
ab76af8
docs: Note that the monitor pages queued timelock operations
ebma Oct 21, 2026
918aeb1
feat(monitor): Page pending Pendulum governance proposals and referenda
ebma Oct 21, 2026
a3dddce
test(monitor): Drive single polls against stand-in chains
ebma Oct 22, 2026
a91c516
fix(monitor): Retry once-only pages until the webhook accepts them
ebma Oct 22, 2026
dd5bd96
fix(monitor): Keep the Base-side checks running when Pendulum fails
ebma Oct 22, 2026
7667e35
fix(monitor): Page an unreadable governance item and watch on
ebma Oct 22, 2026
d5a5c8a
fix(monitor): Bound the governance calls the monitor decodes
ebma Oct 22, 2026
f760559
fix(monitor): Re-check governance calls until they can be read
ebma Oct 22, 2026
d33ab0c
feat(monitor): Watch council and technical-committee motions
ebma Oct 22, 2026
2ad36cf
feat(monitor): Page when the Base view stops advancing
ebma Oct 22, 2026
ea18c2c
feat(monitor): Check that the auto-pause would work
ebma Oct 22, 2026
16eea87
feat(monitor): Page every vault admin event
ebma Oct 22, 2026
f5bd76b
fix(monitor): Send one liveness page per kind and poll
ebma Oct 22, 2026
f124f69
fix(monitor): Hold the Base cursor on events still awaiting their source
ebma Oct 22, 2026
139b4cb
feat(monitor): Let operators acknowledge a quantified release excess
ebma Oct 22, 2026
6c4224b
docs(monitor): Document the new checks, settings and pages
ebma Oct 22, 2026
9dd4088
fix(monitor): Page a failed readiness read instead of aborting the poll
ebma Oct 22, 2026
ea38185
fix(monitor): Keep the vault balance check running when the admin sca…
ebma Oct 22, 2026
8746062
fix(monitor): Reconcile Base events while Pendulum cannot be read
ebma Oct 22, 2026
2e90230
fix(monitor): Page a motion or external proposal made again with the …
ebma Oct 22, 2026
5d5a4a0
fix(monitor): Validate GUARDIAN_MIN_BALANCE_WEI at startup
ebma Oct 22, 2026
38b5014
fix(monitor): Retry the AUTO-PAUSE DISABLED page until it is delivered
ebma Oct 22, 2026
895a5ab
fix(monitor): Read legacy preimage lengths from the deprecated status…
ebma Oct 22, 2026
ead5e11
docs(monitor): Clarify the governance watch cost and the guardian key
ebma Oct 22, 2026
508ca2b
fix(monitor): Page a scheduled operation whatever its delay or event …
ebma Oct 22, 2026
756a16a
fix(monitor): Give the Base admin scan its own persisted cursor
ebma Oct 22, 2026
e7440b7
fix(monitor): Run the vault balance check before the Pendulum and log…
ebma Oct 22, 2026
215f516
fix(monitor): Page an external proposal made again after it was tabled
ebma Oct 22, 2026
f4a5205
fix(monitor): Page a timelock operation scheduled again with the same id
ebma Oct 22, 2026
2bf7b75
feat(monitor): Send pages as Slack incoming-webhook messages
ebma Oct 22, 2026
d6e6024
feat(monitor): Request an optional heartbeat URL after each complete …
ebma Oct 22, 2026
f0bf444
feat(monitor): Pause on disagreeing approvals only from two attestors
ebma Oct 22, 2026
81c3f35
feat(monitor): Check each scanned Base range against the vault's totals
ebma Oct 22, 2026
fc59f49
feat(monitor): Ingest Pendulum blocks along a verified parent-hash chain
ebma Oct 22, 2026
c9c471a
feat(monitor): Cross-check the Pendulum source with an optional secon…
ebma Oct 22, 2026
d6ada28
feat(monitor): Anchor the Pendulum source to the relay chain
ebma Oct 22, 2026
2b865d3
fix(monitor): Say why a connection to a checking node failed
ebma Oct 22, 2026
970dbf2
feat(monitor): Pause when a treasury migration pays an unexpected add…
ebma Oct 22, 2026
a7bb423
test(monitor): Cover more of the pause decisions at the call site
ebma Oct 22, 2026
c609077
fix(monitor): Validate the URLs of the checking nodes at startup
ebma Oct 22, 2026
6abfe67
docs(monitor): Note the Base node's state needs and the walk's bound
ebma Oct 22, 2026
f047d1a
docs(monitor): Trim the Pendulum chain verification section
ebma Oct 22, 2026
b170f5e
docs(monitor): Drop history notes from code comments
ebma Oct 22, 2026
43e8187
fix(monitor): Keep the source bound to a relay head past its finalize…
ebma Oct 22, 2026
58cd923
fix(monitor): Let a relay head above the finalized head wait for the …
ebma Oct 22, 2026
d113eb3
feat(monitor): Confirm a relay-chain contradiction with a second rela…
ebma Oct 22, 2026
7e04431
fix(monitor): Compare the second node's hash only at a height it fina…
ebma Oct 22, 2026
7a43a5e
feat(monitor): Compare migration totals and events with the second node
ebma Oct 22, 2026
1d4609f
fix(monitor): Run the conservation check while a Base log range is held
ebma Oct 22, 2026
3a42713
feat(monitor): Page critical when a Base log range stays held
ebma Oct 22, 2026
72c4fa2
feat(monitor): Run the vault balance check on its own while a poll is…
ebma Oct 22, 2026
52a43df
fix(monitor): Pause on one disagreeing approval at a threshold of two
ebma Oct 22, 2026
cc2050f
feat(monitor): Page critical when the Base admin scan keeps failing
ebma Oct 22, 2026
bfbd2b5
fix(monitor): Say that the monitor holds at a treasury violation
ebma Oct 22, 2026
e6414ca
test(monitor): Cover the re-read of a Base range and a failing totals…
ebma Oct 22, 2026
52be02d
test(monitor): Cover each second-node total and a relay head below th…
ebma Oct 22, 2026
34c0c42
test(monitor): Cover range boundaries and header numbers, bound a wait
ebma Oct 22, 2026
e24b668
fix(monitor): Ingest only Pendulum blocks the second node has finalized
ebma Oct 22, 2026
d2ca453
fix(monitor): Ask the next relay RPC until one anchors the source
ebma Oct 22, 2026
5c69684
fix(monitor): Ingest only Pendulum blocks the relay chain anchored
ebma Oct 22, 2026
cb39e15
fix(monitor): Bound the walk down to a relay head below the ingested …
ebma Oct 22, 2026
83235a6
fix(monitor): Count a vault paused by hand as paused without a guardi…
ebma Oct 22, 2026
9c4f84e
feat(monitor): Page critical when the treasury destination is not the…
ebma Oct 22, 2026
1bfeef3
docs(monitor): Correct the vault balance check's timing and an attest…
ebma Oct 22, 2026
53e2be5
test(monitor): Cover the checked view's total, a lagging second node …
ebma Oct 22, 2026
b87414a
test(monitor): Cover pauses not final yet, unconfirmed tuple pauses a…
ebma Oct 22, 2026
1f70338
test(monitor): Cover the auto-pause transaction and its confirmation
ebma Oct 22, 2026
1bd1425
fix(monitor): Count a relay RPC with a stale relay chain view as not …
ebma Oct 22, 2026
1d1627d
fix(monitor): Anchor the highest relay record while the anchored head…
ebma Oct 22, 2026
492513a
fix(monitor): Name the checker that holds a stalled Pendulum view back
ebma Oct 22, 2026
6c7ce15
test(monitor): Cover a second node that disagrees on the block ingest…
ebma Oct 22, 2026
3b70784
test(monitor): Cover a Base event the source view provably lacks
ebma Oct 22, 2026
fc5f5b0
test(monitor): Cover a relay contradiction confirmed past a lower rel…
ebma Oct 22, 2026
480cc50
test(monitor): Tidy the batched call test
ebma Oct 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/pen-migration-security.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ team, and the safeguards below limit what a compromise can do.
never unpause; unpausing requires the vault admin.
- **Admin changes.** Admin transfers are two-step. After the governance
handover every admin action passes a 48-hour timelock, during which a
designated canceller can veto a queued operation.
designated canceller can veto a queued operation. The monitor pages every
operation the timelock schedules.
- **Sweep floor.** The unmigrated remainder cannot be moved before
2027-03-01 00:00 UTC (immutable), and only through a governance decision.
- **Separation of duties.** The guardian and the monitor are operated by
Expand Down
153 changes: 133 additions & 20 deletions monitor/README.md

Large diffs are not rendered by default.

92 changes: 89 additions & 3 deletions monitor/src/checks.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* Unit tests for the monitor's conservation/liveness predicates.
*
* Run with `npm test` (compiles, then `node --test`). These lock in the
* round-5 fixes: the M2b check must ignore a token surplus (donation / vault
* recipient) and only fire on a real deficit.
* Run with `npm test` (compiles, then `node --test`). Among others, these lock
* in that the M2b check ignores a token surplus (donation / vault recipient)
* and only fires on a real deficit.
*/

import assert from "node:assert/strict";
Expand All @@ -12,11 +12,17 @@ import {
approvalMismatch,
blockRanges,
chunks,
describeCall,
describeTimelockOperation,
disagreeingAttestors,
isStale,
provablyUnsourced,
releaseMismatch,
releasedExceedsMigrated,
riskyCalls,
shouldAwaitSource,
slackText,
toCallNode,
vaultConservationDeficit,
} from "./checks.js";

Expand All @@ -32,6 +38,11 @@ test("M2a: released exceeding migrated fires", () => {
assert.equal(releasedExceedsMigrated(6n * CF, 5n, CF), true);
});

test("M2a: an acknowledged loss is tolerated, and nothing beyond it", () => {
assert.equal(releasedExceedsMigrated(6n * CF, 5n, CF, CF), false);
assert.equal(releasedExceedsMigrated(6n * CF + 1n, 5n, CF, CF), true);
});

test("M2b: exact conservation is not a deficit", () => {
// balance + released + swept == totalSupply
assert.equal(vaultConservationDeficit(SUPPLY - 30n, 20n, 10n, SUPPLY), false);
Expand Down Expand Up @@ -113,6 +124,20 @@ test("M2 tuple matching rejects missing, wrong-recipient and wrong-amount approv
assert.equal(approvalMismatch(expected, { ...expected, recipient: expected.recipient.toUpperCase() }), undefined);
});

test("approvals against the burn count once per attestor and only while they disagree", () => {
const burn = { nonce: 7n, recipient: "0x1111111111111111111111111111111111111111", palletAmount: 100n };
const [a, b] = ["0xA1a1a1a1a1A1a1a1a1a1a1A1a1a1a1a1a1a1A1a1", "0xa2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2"];
const approvals = [
{ ...burn, palletAmount: 99n, attestor: a },
{ ...burn, palletAmount: 98n, attestor: a.toLowerCase() },
{ ...burn, attestor: b }, // agrees
{ ...burn, nonce: 8n, palletAmount: 99n, attestor: b }, // another nonce
];
assert.deepEqual(disagreeingAttestors(burn, 7n, approvals), [a.toLowerCase()]);
assert.deepEqual(disagreeingAttestors(undefined, 7n, approvals), [a.toLowerCase(), b]); // no burn known
assert.deepEqual(disagreeingAttestors({ ...burn, palletAmount: 99n }, 7n, approvals), [a.toLowerCase(), b]);
});

test("M2 release matching includes the one-and-only decimal conversion", () => {
const expected = { nonce: 7n, recipient: "0x1111111111111111111111111111111111111111", palletAmount: 100n };
assert.equal(releaseMismatch(expected, { ...expected, tokenAmount: 100n * CF }, CF), undefined);
Expand All @@ -124,3 +149,64 @@ test("RPC work is split into inclusive block ranges and bounded batches", () =>
assert.deepEqual(blockRanges(11n, 10n, 4n), []);
assert.deepEqual(chunks([1, 2, 3, 4, 5], 2), [[1, 2], [3, 4], [5]]);
});

test("a scheduled governance operation is described with names, targets and the veto deadline", () => {
const vault = "0x2222222222222222222222222222222222222222";
const labels = { [vault]: "vault" };
const functions = { "0x0e18b681": "acceptAdmin()", "0x212bf316": "setCaps(uint256,uint256)" };
const calls = [
{ index: 1n, target: vault.toUpperCase().replace("0X", "0x"), value: 0n, data: "0x212bf316" + "00".repeat(64) },
{ index: 0n, target: vault, value: 0n, data: "0x0e18b681" },
];
const now = Date.UTC(2026, 9, 21, 10, 0, 0);
const text = describeTimelockOperation("0xabc", calls, BigInt((now + (48 * 60 + 5) * 60_000) / 1000), now, labels, functions);
assert.match(text, /^operation 0xabc: #0 vault\.acceptAdmin\(\) data=0x0e18b681; #1 vault\.setCaps\(uint256,uint256\)/);
assert.match(text, /executable by anyone from 2026-10-23T10:05:00\.000Z \(in 48h 5m\)/);
assert.match(text, /canceller must cancel it before then$/);
});

test("a scheduled operation with unknown parts or a settled timestamp still pages readably", () => {
const other = "0x3333333333333333333333333333333333333333";
const call = { index: 0n, target: other, value: 5n, data: "0xdeadbeef" };
assert.match(describeTimelockOperation("0x1", [call], 0n, 0, {}, {}), new RegExp(`#0 ${other}\\.unknown function 0xdeadbeef value=5 .*cancelled\\)$`));
assert.match(describeTimelockOperation("0x1", [call], 1n, 0, {}, {}), /already executed$/);
assert.match(describeTimelockOperation("0x1", [call], 100n, 200_000, {}, {}), /\(ready now\)/);
});

test("a scheduled operation pages whatever its delay or its event carries", () => {
const call = { index: 0n, target: "0x3333333333333333333333333333333333333333", value: 0n, data: "0x8456cb59" };
assert.match(describeTimelockOperation("0x1", [call], 10n ** 20n, 0, {}, {}), /from timestamp 100000000000000000000 \(in /);
const undecoded = { index: undefined, target: undefined, value: undefined, data: undefined } as unknown as typeof call;
assert.match(describeTimelockOperation("0x1", [undecoded, call], 5n, 0, {}, {}), /^operation 0x1: #undefined undefined\.unknown function undefined/);
});

test("a page is Slack text with its control characters escaped and a long detail cut short", () => {
assert.equal(
slackText("pen-monitor", "critical", "SUBJECT", "to <!channel> & <https://x.example|click>"),
"[CRITICAL] pen-monitor: SUBJECT\nto &lt;!channel&gt; &amp; &lt;https://x.example|click&gt;",
);
const text = slackText("pen-monitor", "warning", "SUBJECT", "a".repeat(10_000));
assert.ok(text.startsWith(`[WARNING] pen-monitor: SUBJECT\n${"a".repeat(3_000)}… (cut short`), text.slice(0, 80));
assert.ok(text.length < 3_200, String(text.length));
});

test("a governance call tree is walked through batches and minting calls are flagged", () => {
const setBalance = { section: "tokens", method: "setBalance", args: ["who", "Native", 4_000_000n] };
const batch = toCallNode({ section: "utility", method: "batch", args: [[setBalance, setBalance]] });
assert.equal(describeCall(batch), "utility.batch(tokens.setBalance, tokens.setBalance)");
assert.deepEqual(riskyCalls(batch), ["tokens.setBalance"]);
const nested = toCallNode({ section: "utility", method: "dispatchAs", args: ["Root", { section: "tokenMigration", method: "setPaused", args: [false] }] });
assert.deepEqual(riskyCalls(nested), ["tokenMigration.setPaused"]);
assert.deepEqual(riskyCalls(toCallNode({ section: "system", method: "remark", args: ["0x00"] })), []);
});

test("the call-tree walk is bounded in size and depth", () => {
const remark = { section: "system", method: "remark", args: [] };
const batch = (calls: unknown[]) => ({ section: "utility", method: "batch", args: [calls] });
assert.equal(toCallNode(batch(Array(255).fill(remark))).calls.length, 255);
assert.throws(() => toCallNode(batch(Array(256).fill(remark))), /more than 256 calls/);
let nested: { section: string; method: string; args: unknown[] } = remark;
for (let depth = 1; depth < 16; depth++) nested = batch([nested]);
assert.equal(describeCall(toCallNode(nested)).split("(").length, 16);
assert.throws(() => toCallNode(batch([nested])), /more than 16 levels/);
});
167 changes: 163 additions & 4 deletions monitor/src/checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
* Pure conservation/liveness predicates for the invariant monitor.
*
* These are isolated from the chain-client plumbing in `main.ts` so they can be
* unit-tested exhaustively (see checks.test.ts). Every subtlety that has bitten
* a review round lives here.
* unit-tested exhaustively (see checks.test.ts).
*/

/**
Expand All @@ -13,13 +12,18 @@
* units. It lags `totalMigrated` only via finality delay, never the other way,
* because a release requires attestations of an already-finalized burn — so any
* excess is the strongest possible signal of attestor compromise.
*
* `acknowledgedExcess` is a loss operators have quantified and accepted: it
* stays in the cumulative totals for good, and without it the check would
* re-pause the vault after every recovery unpause.
*/
export function releasedExceedsMigrated(
totalReleased: bigint,
totalMigrated: bigint,
conversionFactor: bigint,
acknowledgedExcess = 0n,
): boolean {
return totalReleased > totalMigrated * conversionFactor;
return totalReleased > totalMigrated * conversionFactor + acknowledgedExcess;
}

/**
Expand Down Expand Up @@ -90,7 +94,7 @@ export function shouldAwaitSource(
* timestamp: OP-stack L2 block timestamps trail real time by the length of any
* sequencer outage while it catches up, and an artificially old event
* timestamp would let a merely-lagging source "prove" a legitimate event
* fabricated (review round 9). A lagging source never satisfies this predicate
* fabricated. A lagging source never satisfies this predicate
* (its head timestamp trails the observation), and a future-dated source view
* (a collator clock ahead of real time) proves nothing either and is excluded,
* so neither can turn node lag into a false pause.
Expand Down Expand Up @@ -126,6 +130,22 @@ export function approvalMismatch(expected: MigrationTuple | undefined, actual: M
return undefined;
}

/**
* The distinct attestors whose recorded approvals of `nonce` disagree with its
* finalized burn, or with its absence. Approvals that the source view has
* since confirmed no longer count.
*/
export function disagreeingAttestors(
expected: MigrationTuple | undefined,
nonce: bigint,
approvals: Array<MigrationTuple & { attestor: string }>,
): string[] {
const attestors = approvals
.filter((approval) => approval.nonce === nonce && approvalMismatch(expected, approval))
.map((approval) => approval.attestor.toLowerCase());
return [...new Set(attestors)];
}

export function releaseMismatch(
expected: MigrationTuple | undefined,
actual: MigrationTuple & { tokenAmount: bigint },
Expand Down Expand Up @@ -156,3 +176,142 @@ export function chunks<T>(items: T[], size: number): T[][] {
for (let start = 0; start < items.length; start += size) result.push(items.slice(start, start + size));
return result;
}

/** One call of a governance Timelock operation (one `CallScheduled` event). */
export interface ScheduledCall {
index: bigint;
target: string;
value: bigint;
data: string;
}

/**
* The page for one operation the governance Timelock scheduled. Every such
* operation pages: once its delay has passed, anyone may execute it, so the
* canceller has exactly the delay to review and veto it.
*
* `readyAtSeconds` is the Timelock's `getTimestamp(id)`, whose sentinels are
* 0 (unknown or cancelled) and 1 (executed). `labels` maps lowercased
* addresses and `functions` maps selectors to readable names. Never throws,
* whatever the event carries: one operation must not hide the next.
*/
export function describeTimelockOperation(
id: string,
calls: ScheduledCall[],
readyAtSeconds: bigint,
nowMs: number,
labels: Record<string, string>,
functions: Record<string, string>,
): string {
const callText = [...calls]
.sort((a, b) => (a.index < b.index ? -1 : a.index > b.index ? 1 : 0))
.map((call) => {
const target = labels[String(call.target).toLowerCase()] ?? call.target;
const selector = String(call.data).slice(0, 10).toLowerCase();
const name = functions[selector] ?? `unknown function ${selector}`;
return `#${call.index} ${target}.${name}${call.value ? ` value=${call.value}` : ""} data=${call.data}`;
})
.join("; ");
let status: string;
if (readyAtSeconds === 0n) status = "no longer pending (cancelled)";
else if (readyAtSeconds === 1n) status = "already executed";
else {
const readyMs = Number(readyAtSeconds) * 1000;
const leftMinutes = Math.floor((readyMs - nowMs) / 60_000);
// A Date holds at most 8.64e15 ms; a later time is shown in seconds.
const readyText = readyMs <= 8.64e15 ? new Date(readyMs).toISOString() : `timestamp ${readyAtSeconds}`;
status =
`executable by anyone from ${readyText}` +
(leftMinutes > 0 ? ` (in ${Math.floor(leftMinutes / 60)}h ${leftMinutes % 60}m)` : " (ready now)") +
"; if it is not intended, the canceller must cancel it before then";
}
return `operation ${id}: ${callText} — ${status}`;
}

export type Severity = "critical" | "warning";

/** Longest page detail sent; the monitor's log line keeps the full text. */
const MAX_PAGE_DETAIL = 3_000;

/**
* A page as the `text` of a Slack incoming-webhook message: severity, subject
* and detail, with Slack's control characters `&`, `<` and `>` escaped, so
* that no detail can mention anyone or hide a link.
*/
export function slackText(service: string, severity: Severity, subject: string, detail: string): string {
const body = detail.length > MAX_PAGE_DETAIL
? `${detail.slice(0, MAX_PAGE_DETAIL)}… (cut short; the monitor log has the full text)`
: detail;
const escapes: Record<string, string> = { "&": "&amp;", "<": "&lt;", ">": "&gt;" };
return `[${severity.toUpperCase()}] ${service}: ${subject}\n${body}`.replace(/[&<>]/g, (char) => escapes[char]);
}

/** A decoded Pendulum call: `section.method` plus any calls nested in its arguments. */
export interface CallNode {
name: string;
calls: CallNode[];
}

/** The duck type of a polkadot.js `Call`, enough to walk nested calls. */
interface CallLike {
section: string;
method: string;
args: unknown[];
}

function isCallLike(value: unknown): value is CallLike {
const call = value as CallLike | null;
return typeof call?.section === "string" && typeof call.method === "string" && Array.isArray(call.args);
}

/** Bounds on a walked call tree. A governance call is untrusted data;
* legitimate ones stay far below both, and a bigger tree is unreadable. */
const MAX_CALL_NODES = 256;
const MAX_CALL_DEPTH = 16;

/** Walks a decoded call, descending into arguments that are calls or lists of
* calls (batch, dispatch_as, ...). Throws past the node or depth bound. */
export function toCallNode(call: CallLike): CallNode {
let nodes = 0;
const walk = (node: CallLike, depth: number): CallNode => {
if (++nodes > MAX_CALL_NODES) throw new Error(`call tree has more than ${MAX_CALL_NODES} calls`);
if (depth > MAX_CALL_DEPTH) throw new Error(`call tree is nested more than ${MAX_CALL_DEPTH} levels deep`);
const calls: CallNode[] = [];
for (const arg of node.args) {
if (isCallLike(arg)) calls.push(walk(arg, depth + 1));
else if (Array.isArray(arg)) for (const item of arg) if (isCallLike(item)) calls.push(walk(item, depth + 1));
}
return { name: `${node.section}.${node.method}`, calls };
};
return walk(call, 1);
}

/** Calls that mint, move or unlock balances outside normal transfers, or change
* the runtime or the migration pallet. Minted PEN that is burned through the
* migration drains the fixed-supply vault on Base, and only Pendulum governance
* can stop such a call before it is enacted. */
const RISKY_CALLS = new Set([
"balances.forceSetBalance", "balances.setBalance", "balances.setBalanceDeprecated", "balances.forceTransfer",
"balances.forceUnreserve", "balances.forceAdjustTotalIssuance", "tokens.setBalance", "tokens.forceTransfer",
"currencies.updateBalance", "vesting.forceVestedTransfer", "vestingManager.removeVestingSchedule",
"system.setCode", "system.setCodeWithoutChecks", "system.setStorage", "system.killStorage", "system.killPrefix",
"system.authorizeUpgrade", "system.authorizeUpgradeWithoutChecks", "parachainSystem.authorizeUpgrade",
"parachainSystem.enactAuthorizedUpgrade",
]);
const RISKY_SECTIONS = new Set(["sudo", "tokenMigration"]);

/** The risky calls anywhere in a call tree, deduplicated. */
export function riskyCalls(call: CallNode): string[] {
const found = new Set<string>();
const walk = (node: CallNode) => {
if (RISKY_CALLS.has(node.name) || RISKY_SECTIONS.has(node.name.split(".")[0])) found.add(node.name);
node.calls.forEach(walk);
};
walk(call);
return [...found];
}

/** Compact one-line form: `utility.batch(tokens.setBalance, tokens.setBalance)`. */
export function describeCall(call: CallNode): string {
return call.calls.length ? `${call.name}(${call.calls.map(describeCall).join(", ")})` : call.name;
}
Loading
Loading