Skip to content

Commit

Permalink
chore: uprade 18 cherrypicks round 5 (#10676)
Browse files Browse the repository at this point in the history
### Description

Cherry-picks the following commits from master:
- #10672
(3b478fb)
- #10668
(a74161c)
- #10680 (c883c39,
1581127)
 
 No new upgrade name has been added. 
 
 Done partially via git cherry-pick and via the following rebase-todo:
 ```
# PR #10680 Branch
Record-instances-that-will-be-replaced-so-we-can-manage-them-10680-
label
base-Record-instances-that-will-be-replaced-so-we-can-manage-them-10680-
pick c883c39 feat: record instances that will be replaced so we can
manage them
pick 1581127 refactor: provideRetiredInstances
label
pr-10680--Record-instances-that-will-be-replaced-so-we-can-manage-them-10680-
reset
base-Record-instances-that-will-be-replaced-so-we-can-manage-them-10680-
merge -C d35659b
pr-10680--Record-instances-that-will-be-replaced-so-we-can-manage-them-10680-
# Record instances that will be replaced so we can manage them (#10680)
 ```
  • Loading branch information
mujahidkay authored Dec 13, 2024
2 parents 6a4fdea + d632323 commit 6cab101
Show file tree
Hide file tree
Showing 14 changed files with 254 additions and 46 deletions.
1 change: 1 addition & 0 deletions a3p-integration/proposals/z:acceptance/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
restart-valueVow
start-valueVow
localchaintest-submission
recorded-instances-submission
1 change: 1 addition & 0 deletions a3p-integration/proposals/z:acceptance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"type": "/agoric.swingset.CoreEvalProposal",
"sdk-generate": [
"testing/start-valueVow.js start-valueVow",
"testing/recorded-retired-instances.js recorded-instances-submission",
"vats/test-localchain.js localchaintest-submission",
"testing/restart-valueVow.js restart-valueVow"
]
Expand Down
11 changes: 11 additions & 0 deletions a3p-integration/proposals/z:acceptance/recorded-retired.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import test from 'ava';

import { evalBundles } from '@agoric/synthetic-chain';

const SUBMISSION_DIR = 'recorded-instances-submission';

test(`recorded instances in u18`, async t => {
const result = await evalBundles(SUBMISSION_DIR);
console.log('recorded retired instance result:', result);
t.pass('checked names');
});
3 changes: 3 additions & 0 deletions a3p-integration/proposals/z:acceptance/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ yarn ava core-eval.test.js
npm install -g tsx
scripts/test-vaults.mts

echo ACCEPTANCE TESTING recorded instances
yarn ava recorded-retired.test.js

echo ACCEPTANCE TESTING kread
./create-kread-item-test.sh

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ test.serial('setupVaults; run updatePriceFeeds proposals', async t => {

t.log('building all relevant CoreEvals');
const coreEvals = await Promise.all([
buildProposal(priceFeedBuilder, ['MAINNET']),
buildProposal(priceFeedBuilder, ['BOOT_TEST']),
buildProposal('@agoric/builders/scripts/vats/upgradeVaults.js'),
buildProposal('@agoric/builders/scripts/vats/add-auction.js'),
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ test('modify manager & director params; update vats, check', async t => {
const priceFeedBuilder =
'@agoric/builders/scripts/inter-protocol/updatePriceFeeds.js';
const coreEvals = await Promise.all([
buildProposal(priceFeedBuilder, ['MAINNET']),
buildProposal(priceFeedBuilder, ['BOOT_TEST']),
buildProposal('@agoric/builders/scripts/vats/upgradeVaults.js'),
buildProposal('@agoric/builders/scripts/vats/add-auction.js'),
]);
Expand Down
10 changes: 10 additions & 0 deletions packages/builders/scripts/inter-protocol/updatePriceFeeds.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ const configurations = {
],
inBrandNames: ['ATOM', 'stATOM', 'stOSMO', 'stTIA', 'stkATOM'],
},
BOOT_TEST: {
oracleAddresses: [
'agoric144rrhh4m09mh7aaffhm6xy223ym76gve2x7y78', // DSRV
'agoric19d6gnr9fyp6hev4tlrg87zjrzsd5gzr5qlfq2p', // Stakin
'agoric19uscwxdac6cf6z7d5e26e0jm0lgwstc47cpll8', // 01node
'agoric1krunjcqfrf7la48zrvdfeeqtls5r00ep68mzkr', // Simply Staking
'agoric1n4fcxsnkxe4gj6e24naec99hzmc4pjfdccy5nj', // P2P
],
inBrandNames: ['ATOM'],
},
};

const { keys } = Object;
Expand Down
73 changes: 73 additions & 0 deletions packages/builders/scripts/testing/recorded-retired-instances.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { makeTracer } from '@agoric/internal';
import { E } from '@endo/far';

const trace = makeTracer('RecordedRetired', true);

/**
* @param {BootstrapPowers &
* PromiseSpaceOf<{ retiredContractInstances: MapStore<string, Instance>;
* }>
* } powers
*/
export const testRecordedRetiredInstances = async ({
consume: {
contractKits,
// governedContractKits,
retiredContractInstances: retiredContractInstancesP,
},
}) => {
trace('Start');
const retiredContractInstances = await retiredContractInstancesP;

const auctionIDs = Array.from(retiredContractInstances.keys()).filter(k =>
k.startsWith('auction'),
);
assert(auctionIDs);
assert(auctionIDs.length === 1);
const auctionInstance = retiredContractInstances.get(auctionIDs[0]);
trace({ auctionInstance });
// I don't know why it's neither in governedContractKits nor contractKits
// assert(await E(governedContractKits).get(auctionInstance));

const committeeIDs = Array.from(retiredContractInstances.keys()).filter(k =>
k.startsWith('economicCommittee'),
);
assert(committeeIDs);
assert(committeeIDs.length === 1);
const committeeInstance = retiredContractInstances.get(committeeIDs[0]);
assert(await E(contractKits).get(committeeInstance));

trace('done');
};
harden(testRecordedRetiredInstances);

export const getManifestForRecordedRetiredInstances = () => {
return {
manifest: {
[testRecordedRetiredInstances.name]: {
consume: {
contractKits: true,
// governedContractKits: true,
retiredContractInstances: true,
},
},
},
};
};

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */
export const defaultProposalBuilder = async () =>
harden({
sourceSpec:
'@agoric/builders/scripts/testing/recorded-retired-instances.js',
getManifestCall: ['getManifestForRecordedRetiredInstances', {}],
});

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').DeployScriptFunction} */
export default async (homeP, endowments) => {
// import dynamically so the module can work in CoreEval environment
const dspModule = await import('@agoric/deploy-script-support');
const { makeHelpers } = dspModule;
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval('recorded-retired', defaultProposalBuilder);
};
18 changes: 17 additions & 1 deletion packages/inter-protocol/src/proposals/add-auction.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { deeplyFulfilledObject, makeTracer } from '@agoric/internal';
import { makeStorageNodeChild } from '@agoric/internal/src/lib-chainStorage.js';
import { E } from '@endo/far';
import { Stable } from '@agoric/internal/src/tokens.js';
import { E } from '@endo/far';
import { makeGovernedTerms as makeGovernedATerms } from '../auction/params.js';
import { provideRetiredInstances } from './utils.js';

const trace = makeTracer('NewAuction', true);

Expand All @@ -11,6 +12,7 @@ const trace = makeTracer('NewAuction', true);
* auctionUpgradeNewInstance: Instance;
* auctionUpgradeNewGovCreator: any;
* newContractGovBundleId: string;
* retiredContractInstances: MapStore<string, Instance>;
* }>} interlockPowers
*/

Expand All @@ -35,13 +37,15 @@ export const addAuction = async (
economicCommitteeCreatorFacet: electorateCreatorFacet,
governedContractKits: governedContractKitsP,
priceAuthority8400,
retiredContractInstances: retiredContractInstancesP,
zoe,
},
produce: {
auctioneerKit: produceAuctioneerKit,
auctionUpgradeNewInstance,
auctionUpgradeNewGovCreator,
newContractGovBundleId,
retiredContractInstances: produceRetiredInstances,
},
instance: {
consume: { reserve: reserveInstance },
Expand Down Expand Up @@ -79,6 +83,16 @@ export const addAuction = async (
auctioneerInstallationP,
]);

const retiredInstances = await provideRetiredInstances(
retiredContractInstancesP,
produceRetiredInstances,
);

// save the auctioneer instance so we can manage it later
const boardID = await E(board).getId(legacyKit.instance);
const identifier = `auctioneer-${boardID}`;
retiredInstances.init(identifier, legacyKit.instance);

// Each field has an extra layer of type + value:
// AuctionStartDelay: { type: 'relativeTime', value: { relValue: 2n, timerBrand: Object [Alleged: timerBrand] {} } }
/** @type {any} */
Expand Down Expand Up @@ -210,13 +224,15 @@ export const ADD_AUCTION_MANIFEST = harden({
economicCommitteeCreatorFacet: true,
governedContractKits: true,
priceAuthority8400: true,
retiredContractInstances: true,
zoe: true,
},
produce: {
auctioneerKit: true,
auctionUpgradeNewInstance: true,
auctionUpgradeNewGovCreator: true,
newContractGovBundleId: true,
retiredContractInstances: true,
},
instance: {
consume: { reserve: true },
Expand Down
31 changes: 28 additions & 3 deletions packages/inter-protocol/src/proposals/deploy-price-feeds.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { E } from '@endo/far';
import { unitAmount } from '@agoric/zoe/src/contractSupport/priceQuote.js';
import {
oracleBrandFeedName,
provideRetiredInstances,
reserveThenDeposit,
sanitizePathSegment,
} from './utils.js';
Expand Down Expand Up @@ -84,7 +85,8 @@ export const ensureOracleBrand = async (
};

/**
* @param {EconomyBootstrapPowers} powers
* @param {EconomyBootstrapPowers &
* PromiseSpaceOf<{ retiredContractInstances: MapStore<string, Instance> }>} powers
* @param {{
* AGORIC_INSTANCE_NAME: string;
* contractTerms: import('@agoric/inter-protocol/src/price/fluxAggregatorKit.js').ChainlinkConfig;
Expand All @@ -96,15 +98,18 @@ export const ensureOracleBrand = async (
const startPriceAggregatorInstance = async (
{
consume: {
agoricNames,
board,
chainStorage,
chainTimerService,
econCharterKit,
highPrioritySendersManager,
namesByAddressAdmin,
startGovernedUpgradable,
retiredContractInstances: retiredContractInstancesP,
},
instance: { produce: produceInstance },
produce: { retiredContractInstances: produceRetiredInstances },
},
{ AGORIC_INSTANCE_NAME, contractTerms, brandIn, brandOut },
installation,
Expand Down Expand Up @@ -139,6 +144,22 @@ const startPriceAggregatorInstance = async (
// @ts-expect-error GovernableStartFn vs. fluxAggregatorContract.js start
installation,
});
const retiredContractInstances = await provideRetiredInstances(
retiredContractInstancesP,
produceRetiredInstances,
);

// save the instance so we can manage it later
const retiringInstance = await E(agoricNames).lookup(
'instance',
AGORIC_INSTANCE_NAME,
);
const boardID = await E(board).getId(retiringInstance);
retiredContractInstances.init(
`priceFeed-${AGORIC_INSTANCE_NAME}-${boardID}`,
retiringInstance,
);

produceInstance[AGORIC_INSTANCE_NAME].reset();
produceInstance[AGORIC_INSTANCE_NAME].resolve(governedKit.instance);
trace(
Expand Down Expand Up @@ -191,7 +212,9 @@ const distributeInvitations = async (
};

/**
* @param {EconomyBootstrapPowers & NamedVatPowers} powers
* @param {EconomyBootstrapPowers &
* NamedVatPowers &
* PromiseSpaceOf<{ retiredContractInstances: MapStore<string, Instance> }>} powers
* @param {{
* options: PriceFeedConfig & {
* priceAggregatorRef: { bundleID: string };
Expand Down Expand Up @@ -300,16 +323,18 @@ export const getManifestForPriceFeeds = async (
namesByAddressAdmin: t,
priceAuthority: t,
priceAuthorityAdmin: t,
retiredContractInstances: t,
startGovernedUpgradable: t,
startUpgradable: t,
zoe: t,
},
installation: { produce: { priceAggregator: t } },
instance: {
produce: t,
consume: t,
},
oracleBrand: { produce: t },
produce: { priceAuthority8400: t },
produce: { priceAuthority8400: t, retiredContractInstances: t },
},
},
options: { ...priceFeedOptions },
Expand Down
Loading

0 comments on commit 6cab101

Please sign in to comment.