Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include builder script name in output filenames #9472

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions packages/builders/scripts/inter-protocol/add-STARS.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ const starsOraclesProposalBuilder = async powers => {

export default async (homeP, endowments) => {
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval('add-STARS', starsVaultProposalBuilder);
await writeCoreEval('add-STARS-oracles', starsOraclesProposalBuilder);
await writeCoreEval('vault', starsVaultProposalBuilder, import.meta.url);
await writeCoreEval('oracle', starsOraclesProposalBuilder, import.meta.url);
};
15 changes: 11 additions & 4 deletions packages/builders/scripts/inter-protocol/add-collateral-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,16 @@ export default async (homeP, endowments) => {
loadBundle: spec => import(spec),
});

await writeCoreEval('gov-add-collateral', defaultProposalBuilder);
await writeCoreEval('gov-start-psm', opts =>
// @ts-expect-error XXX makeInstallCache types
psmProposalBuilder({ ...opts, wrapInstall: tool.wrapInstall }),
await writeCoreEval(
'add-collateral',
defaultProposalBuilder,
import.meta.url,
);
await writeCoreEval(
'start-psm',
opts =>
// @ts-expect-error XXX makeInstallCache types
psmProposalBuilder({ ...opts, wrapInstall: tool.wrapInstall }),
import.meta.url,
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ export const defaultProposalBuilder = async (

export default async (homeP, endowments) => {
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval('gov-invite-committee', defaultProposalBuilder);
await writeCoreEval('gov', defaultProposalBuilder, import.meta.url);
};
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const createGov = async (homeP, endowments) => {
brandIn: lookup(inLookup).catch(() => undefined),
brandOut: lookup(outLookup).catch(() => undefined),
});
await writeCoreEval('gov-price-feed', proposalBuilder); // gov-price-feed.js gov-price-feed-permit.json
await writeCoreEval('gov', proposalBuilder, import.meta.url);
};

export default createGov;
2 changes: 1 addition & 1 deletion packages/builders/scripts/vats/init-localchain.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export const defaultProposalBuilder = async ({ publishRef, install }) =>

export default async (homeP, endowments) => {
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval('gov-localchain', defaultProposalBuilder);
await writeCoreEval('gov', defaultProposalBuilder, import.meta.url);
};
2 changes: 1 addition & 1 deletion packages/builders/scripts/vats/init-network.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export const defaultProposalBuilder = async ({ publishRef, install }) =>

export default async (homeP, endowments) => {
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval('gov-network', defaultProposalBuilder);
await writeCoreEval('gov', defaultProposalBuilder, import.meta.url);
};
2 changes: 1 addition & 1 deletion packages/builders/scripts/vats/init-orchestration.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export const defaultProposalBuilder = async ({ publishRef, install }) =>

export default async (homeP, endowments) => {
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval('gov-orchestration', defaultProposalBuilder);
await writeCoreEval('gov', defaultProposalBuilder, import.meta.url);
};
2 changes: 1 addition & 1 deletion packages/builders/scripts/vats/replace-provisioning.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ export const defaultProposalBuilder = async ({ publishRef, install }) =>

export default async (homeP, endowments) => {
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval('gov-provisioning', defaultProposalBuilder);
await writeCoreEval('gov', defaultProposalBuilder, import.meta.url);
};
29 changes: 18 additions & 11 deletions packages/deploy-script-support/src/writeCoreEvalParts.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// @ts-check
import fs from 'fs';
import { E } from '@endo/far';
import { deeplyFulfilled } from '@endo/marshal';

import { createBundles } from '@agoric/internal/src/node/createBundles.js';
import { deeplyFulfilledObject } from '@agoric/internal';
import path from 'node:path';
import { defangAndTrim, mergePermits, stringify } from './code-gen.js';
import {
makeCoreProposalBehavior,
Expand All @@ -14,6 +15,7 @@ import {
* @import {CoreEvalDescriptor} from './externalTypes.js';
*/

// TODO consider using dots instead of dashes distinguish the module shape qualifierfrom the identifier. (e.g. `-plan.json' to `.plan.json`)
/**
* @typedef CoreEvalPlan
* @property {string} name
Expand All @@ -26,7 +28,7 @@ import {
* @callback WriteCoreEval write to disk the files needed for a CoreEval (js code to`${filePrefix}.js`, permits to `${filePrefix}-permit.json`, an overall
* summary to `${filePrefix}-plan.json), plus whatever bundles bundles the code loads)
* see CoreEval in {@link '/golang/cosmos/x/swingset/types/swingset.pb.go'}
* @param {string} filePrefix name on disk
* @param {string} evalName name on disk
* @param {import('./externalTypes.js').CoreEvalBuilder} builder
* @returns {Promise<CoreEvalPlan>}
*/
Expand Down Expand Up @@ -100,7 +102,7 @@ export const makeWriteCoreEval = (
Promise.resolve()
);
/** @type {WriteCoreEval} */
const writeCoreEval = async (filePrefix, builder) => {
const writeCoreEval = async (evalName, builder, scriptModule) => {
/**
*
* @param {string} entrypoint
Expand Down Expand Up @@ -132,7 +134,7 @@ export const makeWriteCoreEval = (

// Serialise the installations.
mutex = E.when(mutex, async () => {
// console.log('installing', { filePrefix, entrypoint, bundlePath });
// console.log('installing', { evalName, entrypoint, bundlePath });
const spec = await getBundleSpec(bundle, getBundler, opts);
bundles.push({
entrypoint,
Expand All @@ -157,11 +159,11 @@ export const makeWriteCoreEval = (
};

// Create the eval structure.
const evalDescriptor = await deeplyFulfilled(
const evalDescriptor = await deeplyFulfilledObject(
harden(builder({ publishRef, install })),
);
const { sourceSpec, getManifestCall } = evalDescriptor;
// console.log('created', { filePrefix, sourceSpec, getManifestCall });
// console.log('created', { evalName, sourceSpec, getManifestCall });

// Extract the top-level permit.
const { permits: evalPermits, manifest: customManifest } =
Expand All @@ -170,7 +172,7 @@ export const makeWriteCoreEval = (
// Get an install
const manifestBundleRef = await publishRef(install(sourceSpec));

// console.log('writing', { filePrefix, manifestBundleRef, sourceSpec });
// console.log('writing', { evalName, manifestBundleRef, sourceSpec });
const code = `\
// This is generated by writeCoreEval; please edit!
/* eslint-disable */
Expand All @@ -189,24 +191,29 @@ behavior;

const trimmed = defangAndTrim(code);

const permitFile = `${filePrefix}-permit.json`;
// If the scriptModule is present, include it in the name of the plan
const planName = scriptModule
? `${path.basename(scriptModule, '.js')}-${evalName}`
: evalName;

const permitFile = `${planName}-permit.json`;
log(`creating ${permitFile}`);
await writeFile(permitFile, JSON.stringify(evalPermits, null, 2));

const codeFile = `${filePrefix}.js`;
const codeFile = `${planName}.js`;
log(`creating ${codeFile}`);
await writeFile(codeFile, trimmed);

/** @type {CoreEvalPlan} */
const plan = {
name: filePrefix,
name: planName,
script: codeFile,
permit: permitFile,
bundles,
};

await writeFile(
`${filePrefix}-plan.json`,
`${planName}-plan.json`,
`${JSON.stringify(plan, null, 2)}\n`,
);

Expand Down
Loading