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

implement appending #52

Merged
merged 7 commits into from
Jan 8, 2024
Merged
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
38 changes: 27 additions & 11 deletions packages/synthetic-chain/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import { parseArgs } from 'node:util';
import path from 'node:path';
import { execSync } from 'node:child_process';
import { buildProposalSubmissions, buildTestImages } from './src/cli/build.js';
import { refreshDockerfile } from './src/cli/dockerfileGen.js';
import { writeDockerfile } from './src/cli/dockerfileGen.js';
import { matchOneProposal, readProposals } from './src/cli/proposals.js';
import { debugTestImage, runTestImages } from './src/cli/run.js';

// Tag of the agoric-3 image containing all passed proposals
const baseTag = 'main';

const { positionals, values } = parseArgs({
options: {
match: { short: 'm', type: 'string' },
Expand All @@ -28,20 +31,33 @@ const [cmd] = positionals;

// TODO consider a lib like Commander for auto-gen help
const usage = `USAGE:
build
append [<tag>] - build on top of an existing image (defaults to latest from a3p)

rebuild - build from the beginning

test [--debug]
test [--debug] - run the tests of the proposals
`;

const buildImages = () => {
execSync(
// XXX very brittle
'cp -r node_modules/@agoric/synthetic-chain/upgrade-test-scripts .',
);
buildProposalSubmissions(proposals);
buildTestImages(proposals, values.dry);
};

switch (cmd) {
case 'build':
execSync(
// XXX very brittle
'cp -r node_modules/@agoric/synthetic-chain/upgrade-test-scripts .',
);
refreshDockerfile(allProposals);
buildProposalSubmissions(proposals);
buildTestImages(proposals, values.dry);
case 'amend': // alias for backcompat
case 'append':
const fromTag = positionals[1] || baseTag;
writeDockerfile(allProposals, fromTag);
buildImages();
break;
case 'build': // alias for backcompat
case 'rebuild':
writeDockerfile(allProposals);
buildImages();
break;
case 'test':
if (values.debug) {
Expand Down
7 changes: 5 additions & 2 deletions packages/synthetic-chain/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@agoric/synthetic-chain",
"version": "0.0.1-alpha",
"version": "0.0.1",
"description": "Utilities to build a chain and test proposals atop it",
"bin": "./cli.ts",
"main": "index.js",
Expand Down Expand Up @@ -30,5 +30,8 @@
"ts": "module"
}
},
"license": "Apache-2.0"
"license": "Apache-2.0",
"publishConfig": {
"access": "public"
}
}
16 changes: 13 additions & 3 deletions packages/synthetic-chain/src/cli/build.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { execSync } from 'node:child_process';
import fs from 'node:fs';
import path from 'node:path';
import { ProposalInfo, imageNameForProposal } from './proposals.js';

Expand All @@ -22,9 +23,18 @@ export const buildProposalSubmissions = (proposals: ProposalInfo[]) => {
cwd: submissionPath,
env: { ...process.env, HOME: '.' },
});
// UNTIL https://github.com/Agoric/agoric-sdk/pull/8559 is merged
// Move bundles from submission subdir to submission path.
execSync(`mv ${submissionPath}/.agoric/cache/* ${submissionPath}`);
// find the one file ending in -plan.json
// TODO error if there is more than one
const planPath = execSync(
`find ${submissionPath} -maxdepth 1 -type f -name '*-plan.json'`,
)
.toString()
.trim();
const plan = JSON.parse(fs.readFileSync(planPath, 'utf-8'));
for (const { fileName } of plan.bundles) {
// Copy the bundle into the submission path.
execSync(`cp ${fileName} ${submissionPath}`);
}
}
};

Expand Down
25 changes: 13 additions & 12 deletions packages/synthetic-chain/src/cli/dockerfileGen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ import type {
ProposalInfo,
SoftwareUpgradeProposal,
} from './proposals.js';
import { readProposals } from './proposals.js';

const agZeroUpgrade = 'agoric-upgrade-7-2';

// TODO change the tag to 'main' after multi-platform support https://github.com/Agoric/agoric-3-proposals/pull/32
const baseImage = 'ghcr.io/agoric/agoric-3-proposals:pr-32-linux_arm64_v8';

/**
* Templates for Dockerfile stages
Expand All @@ -24,6 +18,7 @@ const stage = {
* @param to
*/
START(proposalName: string, to: string) {
const agZeroUpgrade = 'agoric-upgrade-7-2';
return `
## START
# on ${agZeroUpgrade}, with upgrade to ${to}
Expand All @@ -40,15 +35,16 @@ RUN /usr/src/upgrade-test-scripts/start_ag0.sh
`;
},
/**
* Resume from latest production state
* Resume from state of an existing image
* @param fromTag
* @param proposalName
* @param to
*/
RESUME(proposalName: string, to: string) {
RESUME(fromTag: string, proposalName: string, to: string) {
return `
## RESUME
# on a3p base, with upgrade to ${to}
FROM ${baseImage} as prepare-${proposalName}
FROM ghcr.io/agoric/agoric-3-proposals:${fromTag} as prepare-${proposalName}
mhofman marked this conversation as resolved.
Show resolved Hide resolved
`;
},

Expand Down Expand Up @@ -209,7 +205,10 @@ ENTRYPOINT ./start_agd.sh
},
};

export function refreshDockerfile(allProposals: ProposalInfo[]) {
export function writeDockerfile(
allProposals: ProposalInfo[],
fromTag?: string,
) {
// Each stage tests something about the left argument and prepare an upgrade to the right side (by passing the proposal and halting the chain.)
// The upgrade doesn't happen until the next stage begins executing.
const blocks: string[] = [];
Expand All @@ -227,9 +226,11 @@ export function refreshDockerfile(allProposals: ProposalInfo[]) {
// handle the first proposal specially
if (previousProposal) {
blocks.push(stage.PREPARE(proposal, previousProposal));
} else if (fromTag) {
blocks.push(
stage.RESUME(fromTag, proposal.proposalName, proposal.planName),
);
} else {
// TODO for external use, provide a way to stack upgrades onto an existing chain
// blocks.push(stage.RESUME(proposal.proposalName, proposal.planName));
blocks.push(stage.START(proposal.proposalName, proposal.planName));
}
blocks.push(stage.EXECUTE(proposal));
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion proposals/34:upgrade-10/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"type": "module",
"license": "Apache-2.0",
"dependencies": {
"@agoric/synthetic-chain": "file:./agoric-synthetic-chain-0.0.1-alpha.tgz",
"@agoric/synthetic-chain": "^0.0.1-rc0",
"ava": "^5.3.1",
"better-sqlite3": "^8.5.1",
"execa": "^7.2.0"
Expand Down
33 changes: 27 additions & 6 deletions proposals/34:upgrade-10/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ __metadata:
version: 8
cacheKey: 10c0

"@agoric/synthetic-chain@file:./agoric-synthetic-chain-0.0.1-alpha.tgz::locator=root-workspace-0b6124%40workspace%3A.":
version: 0.0.1-alpha
resolution: "@agoric/synthetic-chain@file:./agoric-synthetic-chain-0.0.1-alpha.tgz#./agoric-synthetic-chain-0.0.1-alpha.tgz::hash=1144d8&locator=root-workspace-0b6124%40workspace%3A."
"@agoric/synthetic-chain@npm:^0.0.1-rc0":
version: 0.0.1-rc0
resolution: "@agoric/synthetic-chain@npm:0.0.1-rc0"
dependencies:
tsx: "npm:^3.12.8"
typescript: "npm:^5.3.3"
bin:
synthetic-chain: ./cli.ts
checksum: 012b67bb80fc818bdb63a16f05007c7183a63d45d0a99a2ce1477079fe2249eae0961c6325b30cea111f4dd38487011f20a94a1518a8b8badef7c4583992d131
synthetic-chain: cli.ts
checksum: b038f72b31d176f35e580ef18ba656f14e39494b165232f5b636bd8b493240c04007752f6d971f2ad3e7a5224f3951ff77f244c98f7ee9d406958fbf297a5f1e
languageName: node
linkType: hard

Expand Down Expand Up @@ -2064,7 +2065,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "root-workspace-0b6124@workspace:."
dependencies:
"@agoric/synthetic-chain": "file:./agoric-synthetic-chain-0.0.1-alpha.tgz"
"@agoric/synthetic-chain": "npm:^0.0.1-rc0"
ava: "npm:^5.3.1"
better-sqlite3: "npm:^8.5.1"
execa: "npm:^7.2.0"
Expand Down Expand Up @@ -2419,6 +2420,26 @@ __metadata:
languageName: node
linkType: hard

"typescript@npm:^5.3.3":
version: 5.3.3
resolution: "typescript@npm:5.3.3"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: e33cef99d82573624fc0f854a2980322714986bc35b9cb4d1ce736ed182aeab78e2cb32b385efa493b2a976ef52c53e20d6c6918312353a91850e2b76f1ea44f
languageName: node
linkType: hard

"typescript@patch:typescript@npm%3A^5.3.3#optional!builtin<compat/typescript>":
version: 5.3.3
resolution: "typescript@patch:typescript@npm%3A5.3.3#optional!builtin<compat/typescript>::version=5.3.3&hash=e012d7"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 1d0a5f4ce496c42caa9a30e659c467c5686eae15d54b027ee7866744952547f1be1262f2d40de911618c242b510029d51d43ff605dba8fb740ec85ca2d3f9500
languageName: node
linkType: hard

"unique-filename@npm:^3.0.0":
version: 3.0.0
resolution: "unique-filename@npm:3.0.0"
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion proposals/43:upgrade-11/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"type": "module",
"license": "Apache-2.0",
"dependencies": {
"@agoric/synthetic-chain": "file:./agoric-synthetic-chain-0.0.1-alpha.tgz",
"@agoric/synthetic-chain": "^0.0.1-rc0",
"ava": "^5.3.1",
"better-sqlite3": "^8.5.1",
"execa": "^7.2.0"
Expand Down
33 changes: 27 additions & 6 deletions proposals/43:upgrade-11/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ __metadata:
version: 8
cacheKey: 10c0

"@agoric/synthetic-chain@file:./agoric-synthetic-chain-0.0.1-alpha.tgz::locator=root-workspace-0b6124%40workspace%3A.":
version: 0.0.1-alpha
resolution: "@agoric/synthetic-chain@file:./agoric-synthetic-chain-0.0.1-alpha.tgz#./agoric-synthetic-chain-0.0.1-alpha.tgz::hash=1144d8&locator=root-workspace-0b6124%40workspace%3A."
"@agoric/synthetic-chain@npm:^0.0.1-rc0":
version: 0.0.1-rc0
resolution: "@agoric/synthetic-chain@npm:0.0.1-rc0"
dependencies:
tsx: "npm:^3.12.8"
typescript: "npm:^5.3.3"
bin:
synthetic-chain: ./cli.ts
checksum: 012b67bb80fc818bdb63a16f05007c7183a63d45d0a99a2ce1477079fe2249eae0961c6325b30cea111f4dd38487011f20a94a1518a8b8badef7c4583992d131
synthetic-chain: cli.ts
checksum: b038f72b31d176f35e580ef18ba656f14e39494b165232f5b636bd8b493240c04007752f6d971f2ad3e7a5224f3951ff77f244c98f7ee9d406958fbf297a5f1e
languageName: node
linkType: hard

Expand Down Expand Up @@ -2064,7 +2065,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "root-workspace-0b6124@workspace:."
dependencies:
"@agoric/synthetic-chain": "file:./agoric-synthetic-chain-0.0.1-alpha.tgz"
"@agoric/synthetic-chain": "npm:^0.0.1-rc0"
ava: "npm:^5.3.1"
better-sqlite3: "npm:^8.5.1"
execa: "npm:^7.2.0"
Expand Down Expand Up @@ -2419,6 +2420,26 @@ __metadata:
languageName: node
linkType: hard

"typescript@npm:^5.3.3":
version: 5.3.3
resolution: "typescript@npm:5.3.3"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: e33cef99d82573624fc0f854a2980322714986bc35b9cb4d1ce736ed182aeab78e2cb32b385efa493b2a976ef52c53e20d6c6918312353a91850e2b76f1ea44f
languageName: node
linkType: hard

"typescript@patch:typescript@npm%3A^5.3.3#optional!builtin<compat/typescript>":
version: 5.3.3
resolution: "typescript@patch:typescript@npm%3A5.3.3#optional!builtin<compat/typescript>::version=5.3.3&hash=e012d7"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 1d0a5f4ce496c42caa9a30e659c467c5686eae15d54b027ee7866744952547f1be1262f2d40de911618c242b510029d51d43ff605dba8fb740ec85ca2d3f9500
languageName: node
linkType: hard

"unique-filename@npm:^3.0.0":
version: 3.0.0
resolution: "unique-filename@npm:3.0.0"
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion proposals/49:smart-wallet-nft/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"license": "Apache-2.0",
"dependencies": {
"@agoric/synthetic-chain": "file:./agoric-synthetic-chain-0.0.1-alpha.tgz",
"@agoric/synthetic-chain": "^0.0.1-rc0",
"@endo/zip": "^0.2.35",
"ava": "^5.3.1",
"better-sqlite3": "^8.5.1",
Expand Down
33 changes: 27 additions & 6 deletions proposals/49:smart-wallet-nft/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ __metadata:
version: 8
cacheKey: 10c0

"@agoric/synthetic-chain@file:./agoric-synthetic-chain-0.0.1-alpha.tgz::locator=root-workspace-0b6124%40workspace%3A.":
version: 0.0.1-alpha
resolution: "@agoric/synthetic-chain@file:./agoric-synthetic-chain-0.0.1-alpha.tgz#./agoric-synthetic-chain-0.0.1-alpha.tgz::hash=1144d8&locator=root-workspace-0b6124%40workspace%3A."
"@agoric/synthetic-chain@npm:^0.0.1-rc0":
version: 0.0.1-rc0
resolution: "@agoric/synthetic-chain@npm:0.0.1-rc0"
dependencies:
tsx: "npm:^3.12.8"
typescript: "npm:^5.3.3"
bin:
synthetic-chain: ./cli.ts
checksum: 012b67bb80fc818bdb63a16f05007c7183a63d45d0a99a2ce1477079fe2249eae0961c6325b30cea111f4dd38487011f20a94a1518a8b8badef7c4583992d131
synthetic-chain: cli.ts
checksum: b038f72b31d176f35e580ef18ba656f14e39494b165232f5b636bd8b493240c04007752f6d971f2ad3e7a5224f3951ff77f244c98f7ee9d406958fbf297a5f1e
languageName: node
linkType: hard

Expand Down Expand Up @@ -2146,7 +2147,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "root-workspace-0b6124@workspace:."
dependencies:
"@agoric/synthetic-chain": "file:./agoric-synthetic-chain-0.0.1-alpha.tgz"
"@agoric/synthetic-chain": "npm:^0.0.1-rc0"
"@endo/zip": "npm:^0.2.35"
ava: "npm:^5.3.1"
better-sqlite3: "npm:^8.5.1"
Expand Down Expand Up @@ -2512,6 +2513,26 @@ __metadata:
languageName: node
linkType: hard

"typescript@npm:^5.3.3":
version: 5.3.3
resolution: "typescript@npm:5.3.3"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: e33cef99d82573624fc0f854a2980322714986bc35b9cb4d1ce736ed182aeab78e2cb32b385efa493b2a976ef52c53e20d6c6918312353a91850e2b76f1ea44f
languageName: node
linkType: hard

"typescript@patch:typescript@npm%3A^5.3.3#optional!builtin<compat/typescript>":
version: 5.3.3
resolution: "typescript@patch:typescript@npm%3A5.3.3#optional!builtin<compat/typescript>::version=5.3.3&hash=e012d7"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 1d0a5f4ce496c42caa9a30e659c467c5686eae15d54b027ee7866744952547f1be1262f2d40de911618c242b510029d51d43ff605dba8fb740ec85ca2d3f9500
languageName: node
linkType: hard

"unique-filename@npm:^3.0.0":
version: 3.0.0
resolution: "unique-filename@npm:3.0.0"
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion proposals/53:kread-start/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"license": "Apache-2.0",
"dependencies": {
"@agoric/synthetic-chain": "file:./agoric-synthetic-chain-0.0.1-alpha.tgz",
"@agoric/synthetic-chain": "^0.0.1-rc0",
"@endo/zip": "^0.2.35",
"ava": "^5.3.1",
"better-sqlite3": "^8.5.1",
Expand Down
Loading