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

Unify flows and orca #15

Open
wants to merge 2 commits into
base: dev/orca-v1
Choose a base branch
from
Open
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
Binary file modified .yarn/install-state.gz
Binary file not shown.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ add-address:
yarn workspace dapp-agoric-orca-contract add:address
lint:
yarn workspace dapp-agoric-orca-contract lint
basic-flow-deploy:
make -C contract basic-flow-deploy
orca-deploy:
make -C contract orca-deploy
2 changes: 2 additions & 0 deletions contract/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
start-sell-concert-tickets-permit.json
start-sell-concert-tickets.js
bundles/
startBasic*
startOrca*
9 changes: 7 additions & 2 deletions contract/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ATOM_DENOM=ibc/BA313C4A19DFBF943586C0387E6B11286F9E416B4DD27574E6909CABE0E342FA
ATOM=000000$(ATOM_DENOM)

# your deployer address made from make add-address
ADDR=agoric1mqvg26gpv6xzch2v0wpv569md3c2z4cdxq9clz
ADDR=agoric1wche60gfuc6dplafsx43yxza89kevct630alr6
PROVISION_POOL_ADDR=agoric1megzytg65cyrgzs6fvzxgrcqvwwl7ugpt62346

PROPOSAL=1
Expand Down Expand Up @@ -269,4 +269,9 @@ e2e:
# todo: figure out why this sequence # is always off by 1 forcing a retry

lint:
yarn lint --fix-dry-run --ignore-pattern "*patch*"
yarn lint --fix-dry-run --ignore-pattern "*patch*"

basic-flow-deploy:
node scripts/deploy-contract.js --builder scripts/init-basic-flows.js
orca-deploy:
node scripts/deploy-contract.js --builder scripts/init-orca.js
34 changes: 21 additions & 13 deletions contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"devDependencies": {
"@agoric/eslint-config": "^0.4.1-upgrade-16-fi-dev-8879538.0",
"@agoric/inter-protocol": "^0.16.2-upgrade-16-fi-dev-8879538.0",
"@agoric/swingset-liveslots": "^0.10.3-u16.1",
"@endo/eslint-plugin": "^0.5.2",
"@endo/far": "1.1.2",
"@endo/ses-ava": "^1.2.2",
Expand All @@ -54,25 +55,32 @@
"typescript-eslint": "^7.13.0"
},
"dependencies": {
"@agoric/async-flow": "0.1.1-dev-9c9e5cf.0",
"@agoric/async-flow": "^0.1.1-dev-ee2126b.0",
"@agoric/cosmic-proto": "dev",
"@agoric/ertp": "dev",
"@agoric/deploy-script-support": "dev",
"@agoric/ertp": "^0.16.2",
"@agoric/governance": "0.10.4-u16.1",
"@agoric/internal": "dev",
"@agoric/internal": "^0.4.0-u16.1",
"@agoric/network": "^0.2.0-u16.1",
"@agoric/notifier": "^0.6.2",
"@agoric/orchestration": "0.1.1-dev-9c9e5cf.0",
"@agoric/store": "0.9.3-u16.0",
"@agoric/time": "dev",
"@agoric/vats": "dev",
"@agoric/vow": "0.1.1-dev-9c9e5cf.0",
"@agoric/zoe": "dev",
"@agoric/zone": "0.2.3-dev-9c9e5cf.0",
"@agoric/store": "0.9.2",
"@agoric/time": "^0.3.2",
"@agoric/vat-data": "^0.5.2",
"@agoric/vats": "^0.16.0-u16.2",
"@agoric/vow": "dev",
"@agoric/zoe": "^0.26.3-u16.1",
"@agoric/zone": "^0.3.0-u16.1",
"@endo/base64": "^1.0.6",
"@endo/bundle-source": "3.2.3",
"@endo/far": "^1.1.2",
"@endo/errors": "^1.2.4",
"@endo/far": "^1.1.4",
"@endo/init": "1.1.2",
"@endo/marshal": "^1.5.0",
"@endo/patterns": "^1.2.0",
"@endo/marshal": "^1.5.2",
"@endo/patterns": "^1.4.2",
"@endo/promise-kit": "^1.1.4",
"@endo/errors": "^1.2.4",
"execa": "^9.2.0",
"fs-extra": "^11.2.0",
"ses": "1.5.0"
},
"ava": {
Expand Down
114 changes: 48 additions & 66 deletions contract/scripts/deploy-contract.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
#!/usr/bin/env node
/* global process, fetch, setTimeout */
// @ts-check
import '@endo/init';
import fsp from 'node:fs/promises';
import { execFile, execFileSync, execSync } from 'node:child_process';
import { basename } from 'node:path';
import '@endo/init/debug.js';
import { createRequire } from 'module';
import { execa } from 'execa';
import fse from 'fs-extra';
import { execFile, execFileSync } from 'node:child_process';

import { makeNodeBundleCache } from '@endo/bundle-source/cache.js';
import { parseArgs } from 'node:util';
import { makeE2ETools } from '../tools/e2e-tools.js';
import { makeE2ETools } from '../tools/flows/e2e-tools.js';

const nodeRequire = createRequire(import.meta.url);
const { readJSON } = fse;

/** @type {import('node:util').ParseArgsConfig['options']} */
const options = {
help: { type: 'boolean' },
install: { type: 'string' },
eval: { type: 'string', multiple: true },
builder: { type: 'string' },
service: { type: 'string', default: 'agd' },
workdir: { type: 'string', default: '/workspace/contract' },
};
/**
* @typedef {{
* help: boolean,
* install?: string,
* eval?: string[],
* builder: string,
* service: string,
* workdir: string,
* }} DeployOptions
Expand All @@ -33,30 +35,15 @@ deploy-contract [options] [--install <contract>] [--eval <proposal>]...

Options:
--help print usage
--install entry module of contract to install
--eval entry module of core evals to run
(cf rollup.config.mjs)
--builder proposal builder
--service SVC docker compose service to run agd (default: ${options.service.default}).
Use . to run agd outside docker.
--workdir DIR workdir for docker service (default: ${options.workdir.default})
`;

const mockExecutionContext = () => {
const withSkip = o =>
Object.assign(o, {
skip: (..._xs) => {},
});
return {
log: withSkip((...args) => console.log(...args)),
is: withSkip((actual, expected, message) =>
assert.equal(actual, expected, message),
),
};
};

const main = async (bundleDir = 'bundles') => {
const { argv } = process;
const { writeFile } = fsp;
// const { writeFile } = fsp;

const progress = (...args) => console.warn(...args); // stderr

Expand All @@ -69,52 +56,47 @@ const main = async (bundleDir = 'bundles') => {
progress(Usage);
return;
}
/** @type {{ _workdir: string, service: string }} */
const { service } = flags;

/** @type {import('../tools/agd-lib.js').ExecSync} */

const dockerExec = (file, dargs, opts = { encoding: 'utf-8', maxBuffer: 1024 * 1024 * 2000 }) => {
console.log("docker exec try 1: ", file);
opts.verbose &&
console.log('exec', JSON.stringify([file, ...dargs]));
console.log("docker exec try 2");

const command = `${file} ${dargs.join(' ')}`;
console.log("command: ", command);
console.log(service);

return execSync(command, opts);
};


const t = mockExecutionContext();
const tools = makeE2ETools(t, bundleCache, {

const { builder } = flags;

const tools = await makeE2ETools(console.log, bundleCache, {
execFileSync,
execFile,
execFileSync: service === '.' ? execFileSync : dockerExec, // see here
fetch,
setTimeout,
writeFile,
bundleDir,
});

const stem = path => basename(path).replace(/\..*/, '');

if (flags.install) {
const name = stem(flags.install);
console.log("installing bundle from deploy-contract.js ....")
await tools.installBundles({ [name]: flags.install }, progress);
console.log(`building plan: ${builder}`);
// build the plan
const { stdout } = await execa`agoric run ${builder}`;
console.log({ stdout })
const match = stdout.match(/ (?<name>[-\w]+)-permit.json/);
if (!(match && match.groups)) {
throw new Error('no permit found');
}
const plan = await readJSON(`./${match.groups.name}-plan.json`);
console.log(plan);

console.log('copying files to container');
tools.copyFiles([
nodeRequire.resolve(`../${plan.script}`),
nodeRequire.resolve(`../${plan.permit}`),
...plan.bundles.map(b => b.fileName),
]);

console.log('installing bundles');
await tools.installBundles(
plan.bundles.map(
b => `/tmp/contracts/${b.bundleID}.json`,
),
console.log,
);

if (flags.eval) {
for await (const entryFile of flags.eval) {
const result = await tools.runCoreEval({
name: stem(entryFile),
entryFile,
});
progress(result);
}
}
console.log('executing proposal');
await tools.runCoreEval({
name: plan.name,
description: `${plan.name} proposal`,
});
};

main().catch(err => console.error(err));
main().catch(err => console.log(err));
26 changes: 26 additions & 0 deletions contract/scripts/init-basic-flows.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { makeHelpers } from '@agoric/deploy-script-support';
import { startBasicFlows } from '../src/proposals/start-basic-flows.js';

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */
export const defaultProposalBuilder = async ({ publishRef, install }) => {
return harden({
sourceSpec: '../src/proposals/start-basic-flows.js',
getManifestCall: [
'getManifestForContract',
{
installKeys: {
basicFlows: publishRef(
install(
'../src/flows/basic-flows.contract.js',
),
),
},
},
],
});
};

export default async (homeP, endowments) => {
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval(startBasicFlows.name, defaultProposalBuilder);
};
26 changes: 26 additions & 0 deletions contract/scripts/init-orca.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { makeHelpers } from '@agoric/deploy-script-support';
import { startOrcaContract } from '../src/proposals/orca.proposal.js';

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */
export const defaultProposalBuilder = async ({ publishRef, install }) => {
return harden({
sourceSpec: '../src/proposals/orca.proposal.js',
getManifestCall: [
'getManifestForOrca',
{
installKeys: {
orca: publishRef(
install(
'../src/orca.contract.js',
),
),
},
},
],
});
};

export default async (homeP, endowments) => {
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval(startOrcaContract.name, defaultProposalBuilder);
};
8 changes: 0 additions & 8 deletions contract/src/@types/zoe-contract-facet.d.ts

This file was deleted.

24 changes: 0 additions & 24 deletions contract/src/collectFees.js

This file was deleted.

41 changes: 0 additions & 41 deletions contract/src/debug.js

This file was deleted.

Loading