From 3e27c74e5385180799f500232d795508e275c687 Mon Sep 17 00:00:00 2001 From: Chris Hibbert Date: Mon, 16 Dec 2024 10:50:16 -0800 Subject: [PATCH] test: add proposal w/300 E(chainTimerService).getTimerBrand() calls (#10696) ## Description @warner asked for a proposal that would ensure there were several more (300 was settled on) arbitrary calls in order to provoke bring-out-your-dead. ### Security Considerations test environments only: aimed at mainFork. ### Scaling Considerations No implications ### Documentation Considerations Unnecessary ### Testing Considerations For test environments. ### Upgrade Considerations None. --- .../builders/scripts/testing/provokeBOYD.js | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 packages/builders/scripts/testing/provokeBOYD.js diff --git a/packages/builders/scripts/testing/provokeBOYD.js b/packages/builders/scripts/testing/provokeBOYD.js new file mode 100644 index 00000000000..5bc2c232dae --- /dev/null +++ b/packages/builders/scripts/testing/provokeBOYD.js @@ -0,0 +1,54 @@ +/** + * @file call getTimerBrand() 300 times in hopes of provoking BOYD. This is + * intended for tests on mainFork for upgrade-18. If there's a similar need in + * other tests, it can be included there as well. There would be no value in + * including it in an upgrade of MainNet; it just spins cycles to provoke + * garbage collection. + */ + +import { makeTracer } from '@agoric/internal'; +import { E } from '@endo/far'; + +/// +/** @import {Instance} from '@agoric/zoe/src/zoeService/utils.js'; */ + +const trace = makeTracer('provokeBOYD', true); + +/** + * @param {BootstrapPowers} powers + */ +export const provokeBOYD = async ({ consume: { chainTimerService } }) => { + trace(provokeBOYD.name); + await null; + + for (let i = 0; i < 300; i += 1) { + await E(chainTimerService).getTimerBrand(); + } + trace('done'); +}; +harden(provokeBOYD); + +export const getManifestForProvokeBOYD = () => { + return { + manifest: { + [provokeBOYD.name]: { + consume: { chainTimerService: true }, + }, + }, + }; +}; + +/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */ +export const defaultProposalBuilder = async () => + harden({ + sourceSpec: '@agoric/builders/scripts/testing/provokeBOYD.js', + getManifestCall: ['getManifestForProvokeBOYD'], + }); + +/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').DeployScriptFunction} */ +export default async (homeP, endowments) => { + const dspModule = await import('@agoric/deploy-script-support'); + const { makeHelpers } = dspModule; + const { writeCoreEval } = await makeHelpers(homeP, endowments); + await writeCoreEval(provokeBOYD.name, defaultProposalBuilder); +};