Skip to content

Commit

Permalink
create vaults and auctions release (proposal 76) (#172)
Browse files Browse the repository at this point in the history
* test: add 76:vaults-auctions

* fetch proposal 76 details from the chain (#175)

Co-authored-by: Dan Connolly <[email protected]>
  • Loading branch information
Chris-Hibbert and dckc authored Sep 10, 2024
1 parent d37362f commit 01f675b
Showing 20 changed files with 3,529 additions and 0 deletions.
3 changes: 3 additions & 0 deletions proposals/76:vaults-auctions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# intermediate files on the way to finding the tx
proposer.json
proposer-tx-hist.json
1 change: 1 addition & 0 deletions proposals/76:vaults-auctions/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
49 changes: 49 additions & 0 deletions proposals/76:vaults-auctions/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This Makefile is here to help you find out what went on the
# chain for a CoreEval proposal such as #76 for vaults / auctions.
PROPOSAL=76

##
# Find the proposal transaction

# To find the transaction, let's start with: Who proposed 76?
proposer.json:
agd --node $(ARCHIVE_NODE) query gov proposer $(PROPOSAL) -o json >$@

# Get proposer's tranasction history.
proposer-tx-hist.json: proposer.json
PROPOSER="$$(jq -r .proposer $<)"; \
agd --node $(ARCHIVE_NODE) query txs --events="message.sender=$$PROPOSER" -o json >$@

# pick out their most recent CoreEvalProposal
tx.json: proposer-tx-hist.json
jq '.txs | .[] | select(.tx.body.messages[0].content["@type"] == "/agoric.swingset.CoreEvalProposal")' \
$< >$@

# A CoreEval proposal has a sequence of json_permits,js_code pairs.
# We happen to know there were 2 in this case, and we have
# been using certain filenames for them.

EVALS=submission/add-auction-permit.json submission/add-auction.js \
submission/upgrade-vaults-permit.json submission/upgrade-vaults.js

core-evals: $(EVALS)

# Now pick out their contents from the transaction.
submission/add-auction-permit.json: tx.json
jq -r '.tx.body.messages[0].content.evals[0].json_permits' $< >$@
submission/add-auction.js: tx.json
jq -r '.tx.body.messages[0].content.evals[0].js_code' $< >$@

submission/upgrade-vaults-permit.json: tx.json
jq -r '.tx.body.messages[0].content.evals[1].json_permits' $< >$@
submission/upgrade-vaults.js: tx.json
jq -r '.tx.body.messages[0].content.evals[1].js_code' $< >$@


# clean up locally computed files
clean:
rm -f $(EVALS)

# clean up files cached from the network as well
realclean: clean
rm -f tx.json proposer.json tx-hist-proposer.json
6 changes: 6 additions & 0 deletions proposals/76:vaults-auctions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# CoreEvalProposal to upgrade vaults and auctions

The `assets` for this proposal match proposal 76 submitted to mainNet
https://github.com/Agoric/agoric-sdk/releases/tag/agoric-upgrade-16av
They were generated as part of [creating
the release](https://github.com/Agoric/agoric-sdk/releases/tag/agoric-upgrade-16av).
9 changes: 9 additions & 0 deletions proposals/76:vaults-auctions/eval.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

echo "[$PROPOSAL] Recording the auctioneer instance"
./saveAuctionInstance.js

echo "[$PROPOSAL] Running proposal declared in package.json"
# copy to run in the proposal package so the dependencies can be resolved
cp /usr/src/upgrade-test-scripts/eval_submission.js .
./eval_submission.js
24 changes: 24 additions & 0 deletions proposals/76:vaults-auctions/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"agoricProposal": {
"type": "/agoric.swingset.CoreEvalProposal",
"releaseNotes": "https://github.com/Agoric/agoric-sdk/releases/tag/agoric-upgrade-16av"
},
"type": "module",
"license": "Apache-2.0",
"dependencies": {
"@agoric/synthetic-chain": "^0.2.0",
"ava": "^5.3.1",
"better-sqlite3": "^8.5.1"
},
"ava": {
"concurrency": 1,
"timeout": "2m",
"files": [
"!submission"
]
},
"scripts": {
"agops": "yarn --cwd /usr/src/agoric-sdk/ --silent agops"
},
"packageManager": "[email protected]"
}
4 changes: 4 additions & 0 deletions proposals/76:vaults-auctions/saveAuctionInstance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env node
import { recordAuctioneerInstance } from './vatDetails.js';

await recordAuctioneerInstance();
45 changes: 45 additions & 0 deletions proposals/76:vaults-auctions/submission/add-auction-permit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"consume": {
"agoricNamesAdmin": "makeCoreProposalBehavior",
"auctioneerKit": true,
"board": true,
"chainStorage": true,
"chainTimerService": true,
"econCharterKit": true,
"economicCommitteeCreatorFacet": true,
"priceAuthority": true,
"zoe": "makeCoreProposalBehavior",
"vatAdminSvc": "makeCoreProposalBehavior"
},
"produce": {
"auctioneerKit": true,
"auctionUpgradeNewInstance": true
},
"instance": {
"consume": {
"reserve": true
},
"produce": {
"auctioneer": true
}
},
"installation": {
"consume": {
"contractGovernor": true
},
"produce": {
"auctioneer": true
}
},
"issuer": {
"consume": {
"IST": true
}
},
"evaluateBundleCap": "makeCoreProposalBehavior",
"modules": {
"utils": {
"runModuleBehaviors": "makeCoreProposalBehavior"
}
}
}
198 changes: 198 additions & 0 deletions proposals/76:vaults-auctions/submission/add-auction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
// This is generated by writeCoreEval; please edit!
/* eslint-disable */

const manifestBundleRef = {bundleID:"b1-47c15fc48569fde3afe4e4947f877242d2d6367c07876951acea99a20d9c890974f3d237f22b5033a84c5e3d506acc6e899e519590a8557d49d6d43611dc9c65"};
const getManifestCall = harden([
"getManifestForAddAuction",
{
auctionsRef: {
bundleID: "b1-31bf1ef20dd190a9f541471bc15238a51f621ff2340e6eb225214b9fdf3970f2bc3bc4fe151a79ef2e740b2679cf03f553b89a828da704dec9ccba9463fc3f79",
},
},
]);
const customManifest = {
addAuction: {
consume: {
agoricNamesAdmin: true,
auctioneerKit: true,
board: true,
chainStorage: true,
chainTimerService: true,
econCharterKit: true,
economicCommitteeCreatorFacet: true,
priceAuthority: true,
zoe: true,
},
installation: {
consume: {
contractGovernor: true,
},
produce: {
auctioneer: true,
},
},
instance: {
consume: {
reserve: true,
},
produce: {
auctioneer: true,
},
},
issuer: {
consume: {
IST: true,
},
},
produce: {
auctionUpgradeNewInstance: true,
auctioneerKit: true,
},
},
};

// Make a behavior function and "export" it by way of script completion value.
// It is constructed by an anonymous invocation to ensure the absence of a global binding
// for makeCoreProposalBehavior, which may not be necessary but preserves behavior pre-dating
// https://github.com/Agoric/agoric-sdk/pull/8712 .
const behavior = (({
manifestBundleRef,
getManifestCall: [manifestGetterName, ...manifestGetterArgs],
customManifest,
E,
log = console.info,
customRestoreRef,
}) => {
const { entries, fromEntries } = Object;

/**
* Given an object whose properties may be promise-valued, return a promise
* for an analogous object in which each such value has been replaced with its
* fulfillment.
* This is a non-recursive form of endo `deeplyFulfilled`.
*
* @template T
* @param {{[K in keyof T]: (T[K] | Promise<T[K]>)}} obj
* @returns {Promise<T>}
*/
const shallowlyFulfilled = async obj => {
if (!obj) {
return obj;
}
const awaitedEntries = await Promise.all(
entries(obj).map(async ([key, valueP]) => {
const value = await valueP;
return [key, value];
}),
);
return fromEntries(awaitedEntries);
};

const makeRestoreRef = (vatAdminSvc, zoe) => {
/** @type {(ref: import\('./externalTypes.js').ManifestBundleRef) => Promise<Installation<unknown>>} */
const defaultRestoreRef = async bundleRef => {
// extract-proposal.js creates these records, and bundleName is
// the optional name under which the bundle was installed into
// config.bundles
const bundleIdP =
'bundleName' in bundleRef
? E(vatAdminSvc).getBundleIDByName(bundleRef.bundleName)
: bundleRef.bundleID;
const bundleID = await bundleIdP;
const label = bundleID.slice(0, 8);
return E(zoe).installBundleID(bundleID, label);
};
return defaultRestoreRef;
};

/** @param {ChainBootstrapSpace & BootstrapPowers & { evaluateBundleCap: any }} powers */
const coreProposalBehavior = async powers => {
// NOTE: `powers` is expected to match or be a superset of the above `permits` export,
// which should therefore be kept in sync with this deconstruction code.
// HOWEVER, do note that this function is invoked with at least the *union* of powers
// required by individual moduleBehaviors declared by the manifest getter, which is
// necessary so it can use `runModuleBehaviors` to provide the appropriate subset to
// each one (see ./writeCoreEvalParts.js).
// Handle `powers` with the requisite care.
const {
consume: { vatAdminSvc, zoe, agoricNamesAdmin },
evaluateBundleCap,
installation: { produce: produceInstallations },
modules: {
utils: { runModuleBehaviors },
},
} = powers;

// Get the on-chain installation containing the manifest and behaviors.
log('evaluateBundleCap', {
manifestBundleRef,
manifestGetterName,
vatAdminSvc,
});
let bcapP;
if ('bundleName' in manifestBundleRef) {
bcapP = E(vatAdminSvc).getNamedBundleCap(manifestBundleRef.bundleName);
} else if ('bundleID' in manifestBundleRef) {
bcapP = E(vatAdminSvc).getBundleCap(manifestBundleRef.bundleID);
} else {
const keys = Reflect.ownKeys(manifestBundleRef).map(key =>
typeof key === 'string' ? JSON.stringify(key) : String(key),
);
const keysStr = `[${keys.join(', ')}]`;
throw Error(
`bundleRef must have own bundleName or bundleID, missing in ${keysStr}`,
);
}
const bundleCap = await bcapP;

const proposalNS = await evaluateBundleCap(bundleCap);

// Get the manifest and its metadata.
log('execute', {
manifestGetterName,
bundleExports: Object.keys(proposalNS),
});
const restoreRef = customRestoreRef || makeRestoreRef(vatAdminSvc, zoe);
const {
manifest,
options: rawOptions,
installations: rawInstallations,
} = await proposalNS[manifestGetterName](
harden({ restoreRef }),
...manifestGetterArgs,
);

// Await promises in the returned options and installations records.
const [options, installations] = await Promise.all(
[rawOptions, rawInstallations].map(shallowlyFulfilled),
);

// Publish the installations for our dependencies.
const installationEntries = entries(installations || {});
if (installationEntries.length > 0) {
const installAdmin = E(agoricNamesAdmin).lookupAdmin('installation');
await Promise.all(
installationEntries.map(([key, value]) => {
produceInstallations[key].resolve(value);
return E(installAdmin).update(key, value);
}),
);
}

// Evaluate the manifest.
return runModuleBehaviors({
// Remember that `powers` may be arbitrarily broad.
allPowers: powers,
behaviors: proposalNS,
manifest: customManifest || manifest,
makeConfig: (name, _permit) => {
log('coreProposal:', name);
return { options };
},
});
};

return coreProposalBehavior;
})({ manifestBundleRef, getManifestCall, customManifest, E });
behavior;

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions proposals/76:vaults-auctions/submission/upgrade-vaults-permit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"consume": {
"auctionUpgradeNewInstance": "upgradeVaults",
"chainTimerService": "upgradeVaults",
"economicCommitteeCreatorFacet": "upgradeVaults",
"reserveKit": "upgradeVaults",
"vaultFactoryKit": "upgradeVaults",
"zoe": "upgradeVaults",
"agoricNamesAdmin": "makeCoreProposalBehavior",
"vatAdminSvc": "makeCoreProposalBehavior"
},
"produce": {
"auctionUpgradeNewInstance": "upgradeVaults"
},
"installation": {
"produce": {
"VaultFactory": true
}
},
"instance": {
"consume": {
"auctioneer": true
}
},
"evaluateBundleCap": "makeCoreProposalBehavior",
"modules": {
"utils": {
"runModuleBehaviors": "makeCoreProposalBehavior"
}
}
}
Loading

0 comments on commit 01f675b

Please sign in to comment.