-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upgrade scaledPriceAuthorities (#9382)
refs: #8400 refs: #8498 closes: #9371 ## Description #8400 reported that the priceFeed vats hold onto old quotes in their recoverySet, preventing them from being collected. #9283 applied the fixes to master. These fixes address the growth in priceFeed vats and Zoe, but scaledPriceAuthorities were still growing. This resolves that problem by upgrading scaledPriceAuthority contracts to not use their recoverySets. <details> <summary><b>Expand</b> for performance graphs</summary> <img width="809" alt="image" src="https://github.com/Agoric/agoric-sdk/assets/13372636/889bb283-89c8-434f-8a67-efa56d0382ad"> Kernel allocation is in blue, and the scale is on the left. It varies from 48862 to 49743, with a small amount of long-term growth.The other active vats (v9=Zoe, v29=ATOM-USD_priceFeed, v43=wallet, 72=ATOM-USD_priceFeed, 74=auctioneer) use the scale on the right, with Zoe varying tightly around 3600, and the others low and stable. scaledPriceAuthority-ATOM doesn't have enough variation to be worth graphing. </details> ### Security Considerations Upgrade existing contracts. No new vulnerabilities. ### Scaling Considerations This addresses the largest known category of growth on the chain. ### Documentation Considerations Add some documentation on creating proposals. ### Testing Considerations Tested in A3P. We should exercise all the clients of priceFeeds in our test environments. ### Upgrade Considerations This PR includes a proposal that will upgrade all vats with `scaledPriceAuthority` in their label. That should work on or test chains as well as MainNet. These changes should be included in the next release.
- Loading branch information
Showing
6 changed files
with
138 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
packages/builders/scripts/vats/upgradeScaledPriceAuthorities.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { makeHelpers } from '@agoric/deploy-script-support'; | ||
|
||
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */ | ||
export const defaultProposalBuilder = async ({ publishRef, install }) => | ||
harden({ | ||
sourceSpec: | ||
'@agoric/inter-protocol/src/proposals/upgrade-scaledPriceAuthorities.js', | ||
getManifestCall: [ | ||
'getManifestForUpgradeScaledPriceAuthorities', | ||
{ | ||
scaledPARef: publishRef( | ||
install('@agoric/zoe/src/contracts/scaledPriceAuthority.js'), | ||
), | ||
}, | ||
], | ||
}); | ||
|
||
export default async (homeP, endowments) => { | ||
const { writeCoreProposal } = await makeHelpers(homeP, endowments); | ||
|
||
await writeCoreProposal( | ||
'upgradeScaledPriceAuthorities', | ||
defaultProposalBuilder, | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
# Proposals | ||
|
||
These are code snippets that go into propoals to the BLDer DAO to start the Inter Protocol. | ||
These scripts are referenced by proposals to the BLDer DAO to run on the chain. | ||
|
||
One of the latest is `startPSM.js` so best to model after that. The style in `econ-behaviors.js` will be refactored to be like startPSM. | ||
See the documentation in .../deploy-script-support/README.md | ||
|
||
[syntax of the manifests](../../packages/vats/src/core/manifest.js) |
78 changes: 78 additions & 0 deletions
78
packages/inter-protocol/src/proposals/upgrade-scaledPriceAuthorities.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { makeTracer } from '@agoric/internal'; | ||
import { E } from '@endo/far'; | ||
|
||
const trace = makeTracer('upgradeScaledPA', true); | ||
|
||
/** | ||
* @param {ChainBootstrapSpace} powers | ||
* @param {{ options: { scaledPARef: { bundleID: string } } }} options | ||
*/ | ||
export const upgradeScaledPriceAuthorities = async ( | ||
{ | ||
consume: { | ||
agoricNamesAdmin, | ||
contractKits: contractKitsP, | ||
instancePrivateArgs: instancePrivateArgsP, | ||
zoe, | ||
}, | ||
}, | ||
{ options }, | ||
) => { | ||
trace('start'); | ||
const { scaledPARef } = options; | ||
await null; | ||
|
||
const bundleID = scaledPARef.bundleID; | ||
if (scaledPARef && bundleID) { | ||
await E.when( | ||
E(zoe).installBundleID(bundleID), | ||
installation => | ||
E(E(agoricNamesAdmin).lookupAdmin('installation')).update( | ||
'scaledPriceAuthority', | ||
installation, | ||
), | ||
err => | ||
console.error( | ||
`🚨 failed to update scaledPriceAuthority installation`, | ||
err, | ||
), | ||
); | ||
} | ||
|
||
const [contractKits, instancePrivateArgs] = await Promise.all([ | ||
contractKitsP, | ||
instancePrivateArgsP, | ||
]); | ||
/** @type {StartedInstanceKit<any>[]} */ | ||
const scaledPAKitEntries = Array.from(contractKits.values()).filter( | ||
kit => kit.label && kit.label.match(/scaledPriceAuthority/), | ||
); | ||
|
||
for (const kitEntry of scaledPAKitEntries) { | ||
const { instance } = kitEntry; | ||
const privateArgs = instancePrivateArgs.get(instance); | ||
trace('upgrade scaledPriceAuthority', kitEntry.label); | ||
await E(kitEntry.adminFacet).upgradeContract(bundleID, privateArgs); | ||
} | ||
}; | ||
|
||
const t = 'upgradeScaledPriceAuthority'; | ||
export const getManifestForUpgradeScaledPriceAuthorities = async ( | ||
_ign, | ||
upgradeSPAOptions, | ||
) => ({ | ||
manifest: { | ||
[upgradeScaledPriceAuthorities.name]: { | ||
consume: { | ||
agoricNamesAdmin: t, | ||
contractKits: t, | ||
instancePrivateArgs: t, | ||
zoe: t, | ||
}, | ||
instance: { | ||
produce: t, | ||
}, | ||
}, | ||
}, | ||
options: { ...upgradeSPAOptions }, | ||
}); |