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

a3p proposal to create new priceFeeds #9044

Merged
merged 7 commits into from
Mar 20, 2024
Merged

Conversation

Chris-Hibbert
Copy link
Contributor

@Chris-Hibbert Chris-Hibbert commented Mar 7, 2024

refs: #8400
refs: #8740

Description

Add an a3p proposal to upgrade the price feed vats to lay out an approach to replace the existing price feed vats with new ones that won't accumulate uncollectible garbage.

The next steps are feeding prices to these oracles (to demonstrate that we can name them and retrieve them from agoricNames) and updating vaults and auctions to rely on the new feeds.

Security Considerations

Not a security issue.

Scaling Considerations

This is in service of reducing an existing scaling issue.

Documentation Considerations

None

Testing/Upgrade Considerations

This is an a3p test to validate plans to upgrade on-chain contracts to address sustainability concerns.

@Chris-Hibbert Chris-Hibbert added performance Performance related issues test contract-upgrade oracle Related to on-chain oracles. labels Mar 7, 2024
@Chris-Hibbert Chris-Hibbert self-assigned this Mar 7, 2024
@Chris-Hibbert Chris-Hibbert mentioned this pull request Mar 7, 2024
14 tasks
@Chris-Hibbert Chris-Hibbert force-pushed the 8740-replacePriceFeeds branch 7 times, most recently from 310d6b2 to 3da4b8c Compare March 11, 2024 23:19

const inLookup = JSON.parse(IN_BRAND_LOOKUP);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a regression w.r.t. CLI usage.

@michaelfig I wonder if we have any tests for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverting....

if (!brandIn) {
if (brandIn) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changing this file means putting another version of it (in a bundle) on the chain. Is that essential to do?

There are other clients... they probably won't be confused, because they refer to the code by bundleID. But I think we already have 2 versions of this on chain, and keeping them straight is hard enough.

I've been exploring a new contract to do this sort of thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted these changes.

// 'agoric1dxe9dqu4ejpctnp2un7s4l7l8hny6dzr8juur3',
// 'agoric1y750klm8sh8yh4h4mcssx5m7rmvuu8mhk89t0c',

// XXX These are the GOV1ADDR, etc addresses. What should this file specify?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scripts/inter-protocol/price-feed-core.js gets them from the environment and arranges for them to be passed to defaultProposalBuilder. or something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@turadg pointed out that the proposals get built before the environment that would generate addresses exists, so they have to be hard-coded or substituted or something. This relevant issue (Agoric/agoric-3-proposals#5) is apparently coming soon.

if (priceAggregatorRef) {
const bundleID = await E.get(priceAggregatorRef).bundleID;
if (bundleID) {
installationP = E(zoe).installBundleID(bundleID);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to update agoricNames.installation.priceAggregator in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, but i'm going to hold off until I see how we entrain the upgrades to auctions and vaults. If those are planned to follow shortly, then yes, but if not, it depends on the reasoning.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mis-read your question. The answer to your actual question is yes, and we do so on line 141 now.

The answer to the question I thought you asked is "yes, we want to update the instances, and we were already doing so on line 222.


const ORACLE_ADDRESSES = [GOV1ADDR, GOV2ADDR, GOV3ADDR];

test('update all priceFeed vats', async t => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see where this test updates anything.

Is it testing that something was updated?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 22 evals priceFeed-submission

@Chris-Hibbert is updatePriceFeeds.js meant to be its own proposal or part of an upgrade? If it's a CORE_EVAL proposal then make the proposal package type be like,

  "agoricProposal": {
    "type": "/agoric.swingset.CoreEvalProposal",
    "source": "subdir",

b:localchain is a good example.

If it will be part of an Software Upgrade, then put it in a:upgrade-next and its Go app handler like the other proposals there. 'upgrade-next' has a mix of u14 and u15 so we'll already be removing the u14 proposals once that hits Mainnet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving to a:upgrade-next

"sdkImageTag": "unreleased",
"planName": "UNRELEASED_UPGRADE",
"upgradeInfo": {
"coreProposals": []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if coreProposals is empty, what exactly is happening in this Software Upgrade?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It runs the upgrade handlers in the sdkImageTag. But that will have run by a:upgrade-next, so its's not doing anything.

It looks like this proposal package is just a holder for priceFeed.test.js (and its submission).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to a:upgrade-next

"sdkImageTag": "unreleased",
"planName": "UNRELEASED_UPGRADE",
"upgradeInfo": {
"coreProposals": []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It runs the upgrade handlers in the sdkImageTag. But that will have run by a:upgrade-next, so its's not doing anything.

It looks like this proposal package is just a holder for priceFeed.test.js (and its submission).


const ORACLE_ADDRESSES = [GOV1ADDR, GOV2ADDR, GOV3ADDR];

test('update all priceFeed vats', async t => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 22 evals priceFeed-submission

@Chris-Hibbert is updatePriceFeeds.js meant to be its own proposal or part of an upgrade? If it's a CORE_EVAL proposal then make the proposal package type be like,

  "agoricProposal": {
    "type": "/agoric.swingset.CoreEvalProposal",
    "source": "subdir",

b:localchain is a good example.

If it will be part of an Software Upgrade, then put it in a:upgrade-next and its Go app handler like the other proposals there. 'upgrade-next' has a mix of u14 and u15 so we'll already be removing the u14 proposals once that hits Mainnet.

scripts/generate-a3p-submission-dirs.sh Outdated Show resolved Hide resolved
@Chris-Hibbert
Copy link
Contributor Author

If it will be part of an Software Upgrade, then put it in a:upgrade-next and its Go app handler like the other proposals there. 'upgrade-next' has a mix of u14 and u15 so we'll already be removing the u14 proposals once that hits Mainnet.

I moved it to a:upgrade-next, but was unable to add it to app.go. Maybe the four generated scripts should be added near there rather than update-price-feeds.js (the file containing defaultProposalBuilder)? When I added the file, it was invoked without options defined, which resulted in sadness.

@Chris-Hibbert
Copy link
Contributor Author

If it will be part of an Software Upgrade, then put it in a:upgrade-next and its Go app handler like the other proposals there. 'upgrade-next' has a mix of u14 and u15 so we'll already be removing the u14 proposals once that hits Mainnet.

I moved it to a:upgrade-next, but was unable to add it to app.go. Maybe the four generated scripts should be added near there rather than update-price-feeds.js (the file containing defaultProposalBuilder)? When I added the file, it was invoked without options defined, which resulted in sadness.

I split the generation of the priceFeed proposals into 4 separate invocations that work both with app.go and a3p's submission generation.

@@ -6,6 +6,7 @@
"upgradeInfo": {
"coreProposals": []
},
"comment": "all the priceFeed submissions go in the same directory",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we've been using $comment to make clear it's not part of the data

"$comment": "This SwingSet config file (see loadSwingsetConfigFile) is minimal; it has no proposals. It is used by ../cosmic-swingset/Makefile and `agoric start`, which add proposals to it.",

however I'm not sure what this comment serves. What's the misunderstanding it's meant to remedy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dropped this line because the stuff it explained went away. Sorry I didn't get it before you noticed it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file name looks like it's going to "update price feeds" but it just exports some values and a function. please rename to disambiguate. e.g. priceFeedSupport.js.

Though for the code, why not keep it in inter-protocol/price-feed-core.js? It's a variation but belongs there just as much as the original yeah?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @dckc said that we already had two versions of that file on chain. My interpretation was that he preferred starting afresh. I'll rename the file. It has gone through some evolutions, and is now just a support for the actual proposals.

Comment on lines 32 to 33
// XXX I don't know why value.values[-1] doesn't work.
const body = JSON.parse(value.values[value.values.length - 1]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because JS arrays are also dicts and -1 is a valid key

Suggested change
// XXX I don't know why value.values[-1] doesn't work.
const body = JSON.parse(value.values[value.values.length - 1]);
const body = JSON.parse(value.values.at(-1));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks.

Comment on lines 35 to 43
const bodyTruncated = JSON.parse(body.body.substring(1));
const slots = body.slots;

for (const [k, v] of bodyTruncated.entries()) {
if (v[0] === `${price}-USD price feed`) {
// console.log(`PFt `, price, slots[k]);
return slots[k];
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a little opaque. consider,

Suggested change
const bodyTruncated = JSON.parse(body.body.substring(1));
const slots = body.slots;
for (const [k, v] of bodyTruncated.entries()) {
if (v[0] === `${price}-USD price feed`) {
// console.log(`PFt `, price, slots[k]);
return slots[k];
}
}
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 feeds.slots[key];
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's much clearer.


test.serial('check all priceFeed vats updated', async t => {
await null;
process.env.ORACLE_ADDRESSES = JSON.stringify(ORACLE_ADDRESSES);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usually we treat env has readonly. would that be feasible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I'm using this anymore. I'll drop it.

I'm more worried about the addresses at the top of priceFeedSupport.js, and how we're going to get usable values for upgrading on-chain.

@mergify mergify bot merged commit b047af2 into master Mar 20, 2024
68 checks passed
@mergify mergify bot deleted the 8740-replacePriceFeeds branch March 20, 2024 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:squash Automatically squash merge contract-upgrade oracle Related to on-chain oracles. performance Performance related issues test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants