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

Harmonise core/boot-psm.js with core/boot.js #6568

Merged
merged 15 commits into from
Dec 7, 2022
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
40 changes: 33 additions & 7 deletions packages/agoric-cli/src/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import chalk from 'chalk';
import { createHash } from 'crypto';
import path from 'path';
import { createRequire } from 'module';

import { Nat, isNat } from '@agoric/nat';

Expand All @@ -15,6 +16,8 @@ import {

import { makePspawn, getSDKBinaries } from './helpers.js';

const require = createRequire(import.meta.url);

const terminalOnlyFlags = (...flags) => {
if (process.stdout.isTTY && process.stdin.isTTY) {
return flags;
Expand All @@ -27,10 +30,10 @@ const PROVISION_COINS = [
`5000000000000000${CENTRAL_DENOM}`,
`100provisionpass`,
`100sendpacketpass`,
`1000000000000ibc/0123456789abcdef`, // IbcATOM
`1000000000000ibc/123456789abcdef0`, // AUSD
`1000000000000ibc/23456789abcdef01`,
`1000000000000ibc/3456789abcdef012`,
`1000000000000ibc/atom1234`, // IbcATOM
`1000000000000ibc/toyellie`, // AUSD
`1000000000000ibc/usdc1234`,
`1000000000000ibc/usdt5678`,
].join(',');
const DELEGATE0_COINS = `50000000${STAKING_DENOM}`;
const SOLO_COINS = `13000000${STAKING_DENOM},500000000${CENTRAL_DENOM}`;
Expand Down Expand Up @@ -509,6 +512,32 @@ export default async function startMain(progname, rawArgs, powers, opts) {
return exitStatus;
}
}

// Create the full economy chain config.
const agServerResolve = spec =>
require.resolve(spec, { paths: [agServer] });
const coreConfigPath = agServerResolve(
'@agoric/vats/decentral-core-config.json',
);
const economyTemplPath = agServerResolve(
'@agoric/cosmic-swingset/economy-template.json',
);
const [rawSoloAddr, coreConfigJson, economyTemplJson] = await Promise.all([
fs.readFile(`${agServer}/ag-cosmos-helper-address`, 'utf-8'),
fs.readFile(coreConfigPath, 'utf-8'),
fs.readFile(economyTemplPath, 'utf-8'),
]);
const soloAddr = rawSoloAddr.trimRight();
const economyProposals = JSON.parse(
economyTemplJson.replace(/@FIRST_SOLO_ADDRESS@/g, soloAddr),
);
const economyConfig = JSON.parse(coreConfigJson);
economyConfig.coreProposals = economyProposals;
await fs.writeFile(
`${agServer}/decentral-economy-config.json`,
JSON.stringify(economyConfig, null, 2),
);

if (!opts.restart) {
return 0;
}
Expand Down Expand Up @@ -551,9 +580,6 @@ export default async function startMain(progname, rawArgs, powers, opts) {
let exitStatus;

// Provision the ag-solo, if necessary.
const soloAddr = (
await fs.readFile(`${agServer}/ag-cosmos-helper-address`, 'utf-8')
).trimRight();
let bestRpcAddr;
while (!bestRpcAddr) {
for (const rpcAddr of rpcAddrs) {
Expand Down
11 changes: 5 additions & 6 deletions packages/cosmic-swingset/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,11 @@ scenario2-run-chain-economy: t1/decentral-economy-config.json
CHAIN_BOOTSTRAP_VAT_CONFIG="$$PWD/t1/decentral-economy-config.json" \
$(MAKE) scenario2-run-chain

scenario2-run-chain-psm: ../vats/decentral-psm-config.json
CHAIN_BOOTSTRAP_VAT_CONFIG="$$PWD/../vats/decentral-psm-config.json" \
$(MAKE) scenario2-run-chain

scenario2-run-chain:
OTEL_EXPORTER_PROMETHEUS_PORT=$(OTEL_EXPORTER_PROMETHEUS_PORT) \
# We want to use the same configuration that will be deployed to the next
# devnet.agoric.net so that developers can test their code against it locally.
scenario2-run-chain: ../vats/decentral-devnet-config.json
CHAIN_BOOTSTRAP_VAT_CONFIG="$${CHAIN_BOOTSTRAP_VAT_CONFIG-$$PWD/../vats/decentral-devnet-config.json}" \
OTEL_EXPORTER_PROMETHEUS_PORT=$(OTEL_EXPORTER_PROMETHEUS_PORT) \
$(AGC) --home=t1/n0 start --log_level=warn $(AGC_START_ARGS)

# Run a chain with an explicit halt.
Expand Down
65 changes: 64 additions & 1 deletion packages/cosmic-swingset/economy-template.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[
"@agoric/vats/scripts/init-core.js",
{
"module": "@agoric/inter-protocol/scripts/init-core.js",
"entrypoint": "defaultProposalBuilder",
Expand All @@ -12,6 +13,11 @@
]
},
"@agoric/pegasus/scripts/init-core.js",
{
"module": "@agoric/inter-protocol/scripts/add-collateral-core.js",
"entrypoint": "psmGovernanceBuilder",
"args": []
},
{
"module": "@agoric/inter-protocol/scripts/add-collateral-core.js",
"entrypoint": "defaultProposalBuilder",
Expand All @@ -35,6 +41,62 @@
"anchorOptions": {
"denom": "ibc/usdc1234",
"decimalPlaces": 6,
"keyword": "USDC_axl",
"proposedName": "USD Coin"
}
}
]
},
{
"module": "@agoric/inter-protocol/scripts/add-collateral-core.js",
"entrypoint": "psmProposalBuilder",
"args": [
{
"anchorOptions": {
"denom": "ibc/usdc5678",
"decimalPlaces": 6,
"keyword": "USDC_grv",
"proposedName": "USC Coin"
}
}
]
},
{
"module": "@agoric/inter-protocol/scripts/add-collateral-core.js",
"entrypoint": "psmProposalBuilder",
"args": [
{
"anchorOptions": {
"denom": "ibc/usdt1234",
"decimalPlaces": 6,
"keyword": "USDT_axl",
"proposedName": "Tether USD"
}
}
]
},
{
"module": "@agoric/inter-protocol/scripts/add-collateral-core.js",
"entrypoint": "psmProposalBuilder",
"args": [
{
"anchorOptions": {
"denom": "ibc/usdt5678",
"decimalPlaces": 6,
"keyword": "USDT_grv",
"proposedName": "Tether USD"
}
}
]
},
{
"module": "@agoric/inter-protocol/scripts/add-collateral-core.js",
"entrypoint": "psmProposalBuilder",
"args": [
{
"anchorOptions": {
"denom": "ibc/toyellie",
"decimalPlaces": 6,
"keyword": "AUSD",
"proposedName": "Anchor USD"
}
Expand Down Expand Up @@ -70,7 +132,8 @@
"entrypoint": "defaultProposalBuilder",
"args": [
{
"voterAddresses": { "someone": "@FIRST_SOLO_ADDRESS@" } }
"voterAddresses": { "someone": "@FIRST_SOLO_ADDRESS@" }
}
]
}
]
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/src/sim-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const defaultBeansPerUnit = [
];

export const defaultBootstrapVatConfig =
'@agoric/vats/decentral-demo-config.json';
'@agoric/vats/decentral-devnet-config.json';

export const defaultPowerFlagFees = [
makePowerFlagFee('SMART_WALLET', [makeCoin('ubld', 10_000_000n)]),
Expand Down
54 changes: 52 additions & 2 deletions packages/inter-protocol/scripts/add-collateral-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
import { makeHelpers } from '@agoric/deploy-script-support';

import { getManifestForAddAssetToVault } from '../src/proposals/addAssetToVault.js';
import { getManifestForPsm } from '../src/proposals/startPSM.js';
import {
getManifestForPsm,
getManifestForPsmGovernance,
} from '../src/proposals/startPSM.js';
import { makeInstallCache } from '../src/proposals/utils.js';

export const defaultProposalBuilder = async (
Expand Down Expand Up @@ -51,6 +54,52 @@ export const defaultProposalBuilder = async (
});
};

export const psmGovernanceBuilder = async ({
publishRef,
install: install0,
wrapInstall,
}) => {
const install = wrapInstall ? wrapInstall(install0) : install0;

return harden({
sourceSpec: '../src/proposals/startPSM.js',
getManifestCall: [
getManifestForPsmGovernance.name,
{
installKeys: {
psm: publishRef(
install('../src/psm/psm.js', '../bundles/bundle-psm.js'),
),
econCommitteeCharter: publishRef(
install(
'../src/econCommitteeCharter.js',
'../bundles/bundle-econCommitteeCharter.js',
),
),
contractGovernor: publishRef(
install(
'@agoric/governance/src/contractGovernor.js',
'../../governance/bundles/bundle-contractGovernor.js',
),
),
committee: publishRef(
install(
'@agoric/governance/src/committee.js',
'../../governance/bundles/bundle-committee.js',
),
),
binaryVoteCounter: publishRef(
install(
'@agoric/governance/src/binaryVoteCounter.js',
'../../governance/bundles/bundle-binaryVoteCounter.js',
),
),
},
},
],
});
};

export const psmProposalBuilder = async (
{ publishRef, install: install0, wrapInstall },
{ anchorOptions = /** @type {object} */ ({}) } = {},
Expand All @@ -63,11 +112,12 @@ export const psmProposalBuilder = async (
const install = wrapInstall ? wrapInstall(install0) : install0;

return harden({
sourceSpec: '../src/proposals/addAssetToVault.js',
sourceSpec: '../src/proposals/startPSM.js',
getManifestCall: [
getManifestForPsm.name,
{
anchorOptions: {
...anchorOptions,
denom,
decimalPlaces,
},
Expand Down
15 changes: 7 additions & 8 deletions packages/inter-protocol/scripts/init-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,15 @@ const installKeyGroups = {
* @param {(m: string, b: string, opts?: any) => I} opts.install
* @param {<T>(f: T) => T} [opts.wrapInstall]
*
* @param {object} [options]
* @param {{ committeeName?: string, committeeSize?: number}} [options.econCommitteeOptions]
* @template I
* @template R
*/
export const committeeProposalBuilder = async ({
publishRef,
install: install0,
wrapInstall,
}) => {
const { ROLE = 'chain' } = process.env;

export const committeeProposalBuilder = async (
{ publishRef, install: install0, wrapInstall },
{ econCommitteeOptions } = {},
) => {
const install = wrapInstall ? wrapInstall(install0) : install0;

/** @param {Record<string, [string, string]>} group */
Expand All @@ -93,7 +92,7 @@ export const committeeProposalBuilder = async ({
getManifestCall: [
getManifestForEconCommittee.name,
{
ROLE,
econCommitteeOptions,
installKeys: {
...publishGroup(installKeyGroups.econCommittee),
},
Expand Down
Loading