Skip to content

Commit

Permalink
test: Stop leaking kernel promises from EV.sendOnly calls (#10943)
Browse files Browse the repository at this point in the history
Fixes #10942

## Description
Sets result policy "ignore" in `EV.sendOnly` calls to prevent kpid allocation.

### Security Considerations
n/a

### Scaling Considerations
n/a

### Documentation Considerations
n/a

### Testing Considerations
This code is itself a testing utility.

### Upgrade Considerations
n/a
  • Loading branch information
mergify[bot] authored Feb 5, 2025
2 parents 4a9a6ad + ca93a9b commit 3a87731
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions packages/SwingSet/tools/run-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const makeRunUtils = (controller, harness) => {
};

/**
* @typedef {import('@endo/eventual-send').EProxy | object} EVProxyMethods
* @typedef EVProxyMethods
* @property {(presence: unknown) => Record<string, (...args: any) => Promise<void>>} sendOnly
* Returns a "methods proxy" for the presence that ignores the results of
* each method invocation.
Expand Down Expand Up @@ -118,28 +118,39 @@ export const makeRunUtils = (controller, harness) => {
// promise that can remain pending indefinitely, possibly to be settled by a
// future message delivery.

/**
* @template {(typeof controller.queueToVatObject) | (typeof controller.queueToVatRoot)} T
* @param {T} invoker
* @param {Parameters<T>[0]} target
* @param {boolean} [voidResult]
*/
const makeMethodsProxy = (invoker, target, voidResult = false) =>
new Proxy(harden({}), {
get: (_t, method, _rx) => {
const resultPolicy = voidResult ? 'none' : undefined;
const boundMethod = (...args) =>
queueAndRun(() => invoker(target, method, args), voidResult);
queueAndRun(
() => invoker(target, method, args, resultPolicy),
voidResult,
);
return harden(boundMethod);
},
});

/** @type {EVProxy} */
const EV = Object.assign(
presence => makeMethodsProxy(controller.queueToVatObject, presence),
{
vat: vatName => makeMethodsProxy(controller.queueToVatRoot, vatName),
sendOnly: presence =>
makeMethodsProxy(controller.queueToVatObject, presence, true),
get: presence =>
new Proxy(harden({}), {
get: (_t, key, _rx) =>
EV.vat('bootstrap').awaitVatObject(presence, [key]),
}),
},
const EV = /** @type {EVProxy} */ (
Object.assign(
presence => makeMethodsProxy(controller.queueToVatObject, presence),
{
vat: vatName => makeMethodsProxy(controller.queueToVatRoot, vatName),
sendOnly: presence =>
makeMethodsProxy(controller.queueToVatObject, presence, true),
get: presence =>
new Proxy(harden({}), {
get: (_t, key, _rx) =>
EV.vat('bootstrap').awaitVatObject(presence, [key]),
}),
},
)
);
return harden({ queueAndRun, EV });
};
Expand Down

0 comments on commit 3a87731

Please sign in to comment.