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

rc1 verification - reapply upgrade #10484

Draft
wants to merge 21 commits into
base: dev-upgrade-18
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"agoricProposal": {
"releaseNotes": false,
"sdkImageTag": "unreleased",
"sdkImageTag": "50",
"planName": "agoric-upgrade-18-a3p",
"upgradeInfo": {
"coreProposals": [],
Expand Down
12 changes: 12 additions & 0 deletions a3p-integration/proposals/a:upgrade-18-rc0/prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# Exit when any command fails
set -uxeo pipefail

# Place here any actions that should happen before the upgrade is proposed. The
# actions are executed in the previous chain software, and the effects are
# persisted so they can be used in the steps after the upgrade is complete,
# such as in the "use" or "test" steps, or further proposal layers.

yarn
node ./addGov4
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import test from 'ava';
import '@endo/init';
import { GOV1ADDR, GOV2ADDR } from '@agoric/synthetic-chain';
import { passStyleOf } from '@endo/marshal';
import { GOV4ADDR, queryVstorageFormatted } from './agoric-tools.js';

const governanceAddresses = [GOV4ADDR, GOV2ADDR, GOV1ADDR];

test.serial('should be able to view the new accepted invitations', async t => {
const instance = await queryVstorageFormatted(
`published.agoricNames.instance`,
);
const instances = Object.fromEntries(instance);

for (const address of governanceAddresses) {
const wallet = await queryVstorageFormatted(
`published.wallet.${address}.current`,
);
const usedInvitations = wallet.offerToUsedInvitation.map(v => v[1]);

const charterInvitation = usedInvitations.find(
v =>
v.value[0].instance.getBoardId() ===
instances.econCommitteeCharter.getBoardId(),
);
t.is(passStyleOf(charterInvitation), 'undefined');

const committeeInvitation = usedInvitations.find(
v =>
v.value[0].instance.getBoardId() ===
instances.economicCommittee.getBoardId(),
);
t.is(passStyleOf(committeeInvitation), 'copyRecord');
}
});
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# Exit when any command fails
set -uxeo pipefail

node ./addGov4

# Econ Committee accept invitations for Committee and Charter
./acceptInvites.js

Expand Down
1 change: 1 addition & 0 deletions a3p-integration/proposals/n:upgrade-18-rc1/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
9 changes: 9 additions & 0 deletions a3p-integration/proposals/n:upgrade-18-rc1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Proposal to upgrade the chain software

This holds the draft proposal for agoric-upgrade-18, which will be added to
[agoric-3-proposals](https://github.com/Agoric/agoric-3-proposals) after it
passes.

The "binaries" property of `upgradeInfo` is now required since Cosmos SDK 0.46,
however it cannot be computed for an unreleased upgrade. To disable the check,
`releaseNotes` is set to `false`.
19 changes: 19 additions & 0 deletions a3p-integration/proposals/n:upgrade-18-rc1/acceptInvites.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env node
import '@endo/init';
import { agops, GOV1ADDR, GOV2ADDR } from '@agoric/synthetic-chain';
import { GOV4ADDR } from './agoric-tools.js';

// New GOV4 account to be added
const addresses = [GOV1ADDR, GOV2ADDR, GOV4ADDR];

await Promise.all(
addresses.map((addr, idx) =>
agops.ec('committee', '--send-from', addr, '--voter', `${idx}`),
),
);

await Promise.all(
addresses.map(addr =>
agops.ec('charter', '--send-from', addr, '--name', 'econCommitteeCharter'),
),
);
20 changes: 20 additions & 0 deletions a3p-integration/proposals/n:upgrade-18-rc1/addGov4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import '@endo/init';
import { execFileSync } from 'node:child_process';
import { makeAgd } from './synthetic-chain-excerpt.js';
import { GOV4ADDR } from './agoric-tools.js';

const agd = makeAgd({ execFileSync }).withOpts({ keyringBackend: 'test' });

agd.keys.add(
'gov4',
'smile unveil sketch gaze length bulb goddess street case exact table fetch robust chronic power choice endorse toward pledge dish access sad illegal dance',
);

agd.tx(
['swingset', 'provision-one', 'faucet_provision', GOV4ADDR, 'SMART_WALLET'],
{
chainId: 'agoriclocal',
from: 'validator',
yes: true,
},
);
207 changes: 207 additions & 0 deletions a3p-integration/proposals/n:upgrade-18-rc1/agd-tools.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
import {
agd,
agops,
agopsLocation,
CHAINID,
executeCommand,
executeOffer,
GOV1ADDR,
GOV2ADDR,
GOV3ADDR,
VALIDATORADDR,
} from '@agoric/synthetic-chain';

const ORACLE_ADDRESSES = [GOV1ADDR, GOV2ADDR, GOV3ADDR];

export const BID_OFFER_ID = 'bid-vaultUpgrade-test3';

const queryVstorage = path =>
agd.query('vstorage', 'data', '--output', 'json', path);

// XXX use endo/marshal?
const getQuoteBody = async path => {
const queryOut = await queryVstorage(path);

const body = JSON.parse(JSON.parse(queryOut.value).values[0]);
return JSON.parse(body.body.substring(1));
};

export const getOracleInstance = async price => {
const instanceRec = await queryVstorage(`published.agoricNames.instance`);

const value = JSON.parse(instanceRec.value);
const body = JSON.parse(value.values.at(-1));

const feeds = JSON.parse(body.body.substring(1));
const feedName = `${price}-USD price feed`;

const key = Object.keys(feeds).find(k => feeds[k][0] === feedName);
if (key) {
return body.slots[key];
}
return null;
};

export const checkForOracle = async (t, name) => {
const instance = await getOracleInstance(name);
t.truthy(instance);
};

export const registerOraclesForBrand = async (brandIn, oraclesByBrand) => {
await null;
const promiseArray = [];

const oraclesWithID = oraclesByBrand.get(brandIn);
for (const oracle of oraclesWithID) {
const { address, offerId } = oracle;
promiseArray.push(
executeOffer(
address,
agops.oracle('accept', '--offerId', offerId, `--pair ${brandIn}.USD`),
),
);
}

return Promise.all(promiseArray);
};

/**
* Generate a consistent map of oracleIDs for a brand that can be used to
* register oracles or to push prices. The baseID changes each time new
* invitations are sent/accepted, and need to be maintained as constants in
* scripts that use the oracles. Each oracleAddress and brand needs a unique
* offerId, so we create recoverable IDs using the brandName and oracle id,
* mixed with the upgrade at which the invitations were accepted.
*
* @param {string} baseId
* @param {string} brandName
*/
const addOraclesForBrand = (baseId, brandName) => {
const oraclesWithID = [];
for (let i = 0; i < ORACLE_ADDRESSES.length; i += 1) {
const oracleAddress = ORACLE_ADDRESSES[i];
const offerId = `${brandName}.${baseId}.${i}`;
oraclesWithID.push({ address: oracleAddress, offerId });
}
return oraclesWithID;
};

export const addPreexistingOracles = async (brandIn, oraclesByBrand) => {
await null;

const oraclesWithID = [];
for (let i = 0; i < ORACLE_ADDRESSES.length; i += 1) {
const oracleAddress = ORACLE_ADDRESSES[i];

const path = `published.wallet.${oracleAddress}.current`;
const wallet = await getQuoteBody(path);
const idToInvitation = wallet.offerToUsedInvitation.find(([k]) => {
return !Number.isNaN(k[0]);
});
if (idToInvitation) {
oraclesWithID.push({
address: oracleAddress,
offerId: idToInvitation[0],
});
} else {
console.log('AGD addO skip', oraclesWithID);
}
}

oraclesByBrand.set(brandIn, oraclesWithID);
};

/**
* Generate a consistent map of oracleIDs and brands that can be used to
* register oracles or to push prices. The baseID changes each time new
* invitations are sent/accepted, and need to be maintained as constants in
* scripts that use these records to push prices.
*
* @param {string} baseId
* @param {string[]} brandNames
*/
export const generateOracleMap = (baseId, brandNames) => {
const oraclesByBrand = new Map();
for (const brandName of brandNames) {
const oraclesWithID = addOraclesForBrand(baseId, brandName);
oraclesByBrand.set(brandName, oraclesWithID);
}
return oraclesByBrand;
};

export const pushPrices = (price, brandIn, oraclesByBrand) => {
const promiseArray = [];

for (const oracle of oraclesByBrand.get(brandIn)) {
promiseArray.push(
executeOffer(
oracle.address,
agops.oracle(
'pushPriceRound',
'--price',
price,
'--oracleAdminAcceptOfferId',
oracle.offerId,
),
),
);
}

return Promise.all(promiseArray);
};

export const getPriceQuote = async price => {
const path = `published.priceFeed.${price}-USD_price_feed`;
const body = await getQuoteBody(path);
return body.amountOut.value;
};

export const agopsInter = (...params) => {
const newParams = ['inter', ...params];
return executeCommand(agopsLocation, newParams);
};

export const createBid = (price, addr, offerId) => {
return agopsInter(
'bid',
'by-price',
`--price ${price}`,
`--give 1.0IST`,
'--from',
addr,
'--keyring-backend test',
`--offer-id ${offerId}`,
);
};

export const getLiveOffers = async addr => {
const path = `published.wallet.${addr}.current`;
const body = await getQuoteBody(path);
return body.liveOffers;
};

export const getAuctionCollateral = async index => {
const path = `published.auction.book${index}`;
const body = await getQuoteBody(path);
return body.collateralAvailable.value;
};

export const getVaultPrices = async index => {
const path = `published.vaultFactory.managers.manager${index}.quotes`;
const body = await getQuoteBody(path);
return body.quoteAmount;
};

export const bankSend = (addr, wanted) => {
const chain = ['--chain-id', CHAINID];
const from = ['--from', VALIDATORADDR];
const testKeyring = ['--keyring-backend', 'test'];
const noise = [...from, ...chain, ...testKeyring, '--yes'];

return agd.tx('bank', 'send', VALIDATORADDR, addr, wanted, ...noise);
};

export const getProvisionPoolMetrics = async () => {
const path = `published.provisionPool.metrics`;
return getQuoteBody(path);
};
Loading
Loading