Skip to content

Commit

Permalink
chore(59): USDC core-eval script, permit from chain
Browse files Browse the repository at this point in the history
 - Makefile to query materials
  • Loading branch information
dckc authored and turadg committed Nov 19, 2024
1 parent df02dc1 commit a0ff429
Show file tree
Hide file tree
Showing 4 changed files with 249 additions and 0 deletions.
30 changes: 30 additions & 0 deletions proposals/59:usdc-psm/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 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=59

##
# Find the proposal details

proposal.json:
agd --node $(ARCHIVE_NODE) query gov proposal $(PROPOSAL) -o json >$@

# A CoreEval proposal has a sequence of json_permits,js_code pairs.
# We happen to know there was 1 in this case.

EVALS=submission/add-usdc-permit.json submission/add-usdc.js

core-evals: $(EVALS)

# Now pick out their contents from the transaction.
submission/add-usdc-permit.json: proposal.json
jq -r '.messages[0].content.evals[0].json_permits' $< >$@
submission/add-usdc.js: proposal.json
jq -r '.messages[0].content.evals[0].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
1 change: 1 addition & 0 deletions proposals/59:usdc-psm/proposal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id":"59","messages":[{"@type":"/cosmos.gov.v1.MsgExecLegacyContent","content":{"@type":"/agoric.swingset.CoreEvalProposal","title":"Start USDC (Noble) PSM","description":"Evaluate gov-start-usdc-psm.js. See discussion: https://community.agoric.com/t/add-native-usdc-to-the-inter-protocol-parity-stability-module/466. This proposal supercedes proposal 56.","evals":[{"json_permits":"{\n \"vatParameters\": {\n \"chainStorageEntries\": true\n },\n \"consume\": {\n \"agoricNamesAdmin\": \"makeCoreProposalBehavior\",\n \"bankManager\": \"bank\",\n \"startUpgradable\": true,\n \"anchorBalancePayments\": true,\n \"anchorKits\": true,\n \"board\": true,\n \"chainStorage\": true,\n \"diagnostics\": true,\n \"zoe\": \"zoe\",\n \"feeMintAccess\": \"zoe\",\n \"economicCommitteeCreatorFacet\": \"economicCommittee\",\n \"provisionPoolStartResult\": true,\n \"econCharterKit\": \"econCommitteeCharter\",\n \"chainTimerService\": \"timer\",\n \"psmKit\": true,\n \"vatAdminSvc\": \"makeCoreProposalBehavior\"\n },\n \"installation\": {\n \"consume\": {\n \"mintHolder\": \"zoe\",\n \"contractGovernor\": \"zoe\",\n \"psm\": \"zoe\"\n }\n },\n \"produce\": {\n \"testFirstAnchorKit\": true,\n \"anchorBalancePayments\": true,\n \"anchorKits\": true,\n \"psmKit\": \"true\"\n },\n \"instance\": {\n \"consume\": {\n \"economicCommittee\": \"economicCommittee\"\n }\n },\n \"brand\": {\n \"consume\": {\n \"IST\": \"zoe\"\n }\n },\n \"evaluateBundleCap\": \"makeCoreProposalBehavior\",\n \"modules\": {\n \"utils\": {\n \"runModuleBehaviors\": \"makeCoreProposalBehavior\"\n }\n }\n}\n","js_code":"// This is generated by writeCoreProposal; please edit!\n/* eslint-disable */\n\nconst manifestBundleRef = {\n bundleID:\n \"b1-4c34c89b707bc8ece5a41e97e6a354081f7ae8a40391f1462848348613dd1218dcce574b3e30901a9825a966cb85bda6a92ba9f9ce9ba325e4c475f9a678b930\",\n};\nconst getManifestCall = harden([\n \"getManifestForPsm\",\n {\n anchorOptions: {\n decimalPlaces: 6,\n denom:\n \"ibc/FE98AAD68F02F03565E9FA39A5E627946699B2B07115889ED812D8BA639576A9\",\n keyword: \"USDC\",\n proposedName: \"USDC\",\n },\n installKeys: {},\n },\n]);\nconst overrideManifest = {\n makeAnchorAsset: {\n consume: {\n agoricNamesAdmin: true,\n anchorBalancePayments: true,\n anchorKits: true,\n bankManager: \"bank\",\n startUpgradable: true,\n },\n installation: {\n consume: {\n mintHolder: \"zoe\",\n },\n },\n produce: {\n anchorBalancePayments: true,\n anchorKits: true,\n testFirstAnchorKit: true,\n },\n vatParameters: {\n chainStorageEntries: true,\n },\n },\n startPSM: {\n brand: {\n consume: {\n IST: \"zoe\",\n },\n },\n consume: {\n agoricNamesAdmin: true,\n anchorBalancePayments: true,\n board: true,\n chainStorage: true,\n chainTimerService: \"timer\",\n diagnostics: true,\n econCharterKit: \"econCommitteeCharter\",\n economicCommitteeCreatorFacet: \"economicCommittee\",\n feeMintAccess: \"zoe\",\n provisionPoolStartResult: true,\n psmKit: true,\n zoe: \"zoe\",\n },\n installation: {\n consume: {\n contractGovernor: \"zoe\",\n psm: \"zoe\",\n },\n },\n instance: {\n consume: {\n economicCommittee: \"economicCommittee\",\n },\n },\n produce: {\n psmKit: \"true\",\n },\n vatParameters: {\n chainStorageEntries: true,\n },\n },\n};\n\n// Make the behavior the completion value.\n(({\n manifestBundleRef,\n getManifestCall,\n overrideManifest,\n E,\n log = console.info,\n restoreRef = () =\u003e {},\n}) =\u003e {\n const { entries, fromEntries } = Object;\n\n // deeplyFulfilled is a bit overkill for what we need.\n const shallowlyFulfilled = async (obj) =\u003e {\n if (!obj) {\n return obj;\n }\n const ents = await Promise.all(\n entries(obj).map(async ([key, valueP]) =\u003e {\n const value = await valueP;\n return [key, value];\n })\n );\n return fromEntries(ents);\n };\n\n /** @param {ChainBootstrapSpace \u0026 BootstrapPowers \u0026 { evaluateBundleCap: any }} allPowers */\n const behavior = async (allPowers) =\u003e {\n // NOTE: If updating any of these names extracted from `allPowers`, you must\n // change `permits` above to reflect their accessibility.\n const {\n consume: { vatAdminSvc, zoe },\n evaluateBundleCap,\n modules: {\n utils: { runModuleBehaviors },\n },\n } = allPowers;\n const [exportedGetManifest, ...manifestArgs] = getManifestCall;\n\n // Get the on-chain installation containing the manifest and behaviors.\n console.info(\"evaluateBundleCap\", {\n manifestBundleRef,\n exportedGetManifest,\n vatAdminSvc,\n });\n let bcapP;\n if (\"bundleName\" in manifestBundleRef) {\n bcapP = E(vatAdminSvc).getNamedBundleCap(manifestBundleRef.bundleName);\n } else {\n bcapP = E(vatAdminSvc).getBundleCap(manifestBundleRef.bundleID);\n }\n const bundleCap = await bcapP;\n\n const manifestNS = await evaluateBundleCap(bundleCap);\n\n console.error(\"execute\", {\n exportedGetManifest,\n behaviors: Object.keys(manifestNS),\n });\n const { manifest, options: rawOptions } = await manifestNS[\n exportedGetManifest\n ](harden({ restoreRef }), ...manifestArgs);\n\n const options = await shallowlyFulfilled(rawOptions);\n\n // All dependency bundles are already installed, so we ignore `installations` from the getManifest response.\n\n // Evaluate the manifest for our behaviors.\n return runModuleBehaviors({\n allPowers,\n behaviors: manifestNS,\n manifest: overrideManifest || manifest,\n makeConfig: (name, _permit) =\u003e {\n log(\"coreProposal:\", name);\n return { options };\n },\n });\n };\n\n // Make the behavior the completion value.\n return behavior;\n})({ manifestBundleRef, getManifestCall, overrideManifest, E });\n"}]},"authority":"agoric10d07y265gmmuvt4z0w9aw880jnsr700jgl36x9"}],"status":"PROPOSAL_STATUS_PASSED","final_tally_result":{"yes_count":"241396650486277","abstain_count":"12249650813647","no_count":"1644182107","no_with_veto_count":"29600000"},"submit_time":"2023-10-29T16:19:59.738532447Z","deposit_end_time":"2023-10-31T16:19:59.738532447Z","total_deposit":[{"denom":"ubld","amount":"5000000000"}],"voting_start_time":"2023-10-29T16:30:16.851873623Z","voting_end_time":"2023-11-01T16:30:16.851873623Z","metadata":""}
53 changes: 53 additions & 0 deletions proposals/59:usdc-psm/submission/add-usdc-permit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"vatParameters": {
"chainStorageEntries": true
},
"consume": {
"agoricNamesAdmin": "makeCoreProposalBehavior",
"bankManager": "bank",
"startUpgradable": true,
"anchorBalancePayments": true,
"anchorKits": true,
"board": true,
"chainStorage": true,
"diagnostics": true,
"zoe": "zoe",
"feeMintAccess": "zoe",
"economicCommitteeCreatorFacet": "economicCommittee",
"provisionPoolStartResult": true,
"econCharterKit": "econCommitteeCharter",
"chainTimerService": "timer",
"psmKit": true,
"vatAdminSvc": "makeCoreProposalBehavior"
},
"installation": {
"consume": {
"mintHolder": "zoe",
"contractGovernor": "zoe",
"psm": "zoe"
}
},
"produce": {
"testFirstAnchorKit": true,
"anchorBalancePayments": true,
"anchorKits": true,
"psmKit": "true"
},
"instance": {
"consume": {
"economicCommittee": "economicCommittee"
}
},
"brand": {
"consume": {
"IST": "zoe"
}
},
"evaluateBundleCap": "makeCoreProposalBehavior",
"modules": {
"utils": {
"runModuleBehaviors": "makeCoreProposalBehavior"
}
}
}

165 changes: 165 additions & 0 deletions proposals/59:usdc-psm/submission/add-usdc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
// This is generated by writeCoreProposal; please edit!
/* eslint-disable */

const manifestBundleRef = {
bundleID:
"b1-4c34c89b707bc8ece5a41e97e6a354081f7ae8a40391f1462848348613dd1218dcce574b3e30901a9825a966cb85bda6a92ba9f9ce9ba325e4c475f9a678b930",
};
const getManifestCall = harden([
"getManifestForPsm",
{
anchorOptions: {
decimalPlaces: 6,
denom:
"ibc/FE98AAD68F02F03565E9FA39A5E627946699B2B07115889ED812D8BA639576A9",
keyword: "USDC",
proposedName: "USDC",
},
installKeys: {},
},
]);
const overrideManifest = {
makeAnchorAsset: {
consume: {
agoricNamesAdmin: true,
anchorBalancePayments: true,
anchorKits: true,
bankManager: "bank",
startUpgradable: true,
},
installation: {
consume: {
mintHolder: "zoe",
},
},
produce: {
anchorBalancePayments: true,
anchorKits: true,
testFirstAnchorKit: true,
},
vatParameters: {
chainStorageEntries: true,
},
},
startPSM: {
brand: {
consume: {
IST: "zoe",
},
},
consume: {
agoricNamesAdmin: true,
anchorBalancePayments: true,
board: true,
chainStorage: true,
chainTimerService: "timer",
diagnostics: true,
econCharterKit: "econCommitteeCharter",
economicCommitteeCreatorFacet: "economicCommittee",
feeMintAccess: "zoe",
provisionPoolStartResult: true,
psmKit: true,
zoe: "zoe",
},
installation: {
consume: {
contractGovernor: "zoe",
psm: "zoe",
},
},
instance: {
consume: {
economicCommittee: "economicCommittee",
},
},
produce: {
psmKit: "true",
},
vatParameters: {
chainStorageEntries: true,
},
},
};

// Make the behavior the completion value.
(({
manifestBundleRef,
getManifestCall,
overrideManifest,
E,
log = console.info,
restoreRef = () => {},
}) => {
const { entries, fromEntries } = Object;

// deeplyFulfilled is a bit overkill for what we need.
const shallowlyFulfilled = async (obj) => {
if (!obj) {
return obj;
}
const ents = await Promise.all(
entries(obj).map(async ([key, valueP]) => {
const value = await valueP;
return [key, value];
})
);
return fromEntries(ents);
};

/** @param {ChainBootstrapSpace & BootstrapPowers & { evaluateBundleCap: any }} allPowers */
const behavior = async (allPowers) => {
// NOTE: If updating any of these names extracted from `allPowers`, you must
// change `permits` above to reflect their accessibility.
const {
consume: { vatAdminSvc, zoe },
evaluateBundleCap,
modules: {
utils: { runModuleBehaviors },
},
} = allPowers;
const [exportedGetManifest, ...manifestArgs] = getManifestCall;

// Get the on-chain installation containing the manifest and behaviors.
console.info("evaluateBundleCap", {
manifestBundleRef,
exportedGetManifest,
vatAdminSvc,
});
let bcapP;
if ("bundleName" in manifestBundleRef) {
bcapP = E(vatAdminSvc).getNamedBundleCap(manifestBundleRef.bundleName);
} else {
bcapP = E(vatAdminSvc).getBundleCap(manifestBundleRef.bundleID);
}
const bundleCap = await bcapP;

const manifestNS = await evaluateBundleCap(bundleCap);

console.error("execute", {
exportedGetManifest,
behaviors: Object.keys(manifestNS),
});
const { manifest, options: rawOptions } = await manifestNS[
exportedGetManifest
](harden({ restoreRef }), ...manifestArgs);

const options = await shallowlyFulfilled(rawOptions);

// All dependency bundles are already installed, so we ignore `installations` from the getManifest response.

// Evaluate the manifest for our behaviors.
return runModuleBehaviors({
allPowers,
behaviors: manifestNS,
manifest: overrideManifest || manifest,
makeConfig: (name, _permit) => {
log("coreProposal:", name);
return { options };
},
});
};

// Make the behavior the completion value.
return behavior;
})({ manifestBundleRef, getManifestCall, overrideManifest, E });

0 comments on commit a0ff429

Please sign in to comment.