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

fix: contractGovernor can change params after contract is upgraded #10163

Merged
merged 5 commits into from
Oct 9, 2024

Conversation

Chris-Hibbert
Copy link
Contributor

@Chris-Hibbert Chris-Hibbert commented Sep 27, 2024

closes: #9982
closes: #10172

Description

When a governed contract is upgraded, its paramManager (which was ephemeral) is replaced, and the contractGovernor needs to get a fresh copy.

Security Considerations

This bug caused us to need to cut RC2 when preparing the vaultFactory release. That time, the fix was to upgrade the contractGovernor when upgrading a governed contract.

Scaling Considerations

No scaling impacts.

Testing Considerations

added a new test, which fails without the fix.

Upgrade Considerations

This is staged on top of #10074, and the goal is to include it with the priceFeed coreEval. Recent commits have updated the coreEval to include upgrading and installing the contractGovernor code.

@Chris-Hibbert Chris-Hibbert added bug Something isn't working Governance Governance contract-upgrade labels Sep 27, 2024
@Chris-Hibbert Chris-Hibbert self-assigned this Sep 27, 2024
@Chris-Hibbert Chris-Hibbert requested a review from dckc September 27, 2024 16:55
@dckc
Copy link
Member

dckc commented Sep 27, 2024

What's the upgrade / deployment story?

@Chris-Hibbert
Copy link
Contributor Author

What's the upgrade / deployment story?

My hope is that we can approve it before the priceFeed coreEval goes out, so the change will be included in any contractGovernors that get upgraded or replaced.

Hmm. that means I'll need a follow-on PR to add installing the code to the priceFeed coreEval. Thanks for asking.

@dckc
Copy link
Member

dckc commented Sep 27, 2024

Hmm. that means I'll need a follow-on PR to add ...

does that mean "closes: #9982" should be changed to "refs"?

@Chris-Hibbert
Copy link
Contributor Author

does that mean "closes: #9982" should be changed to "refs"?

I don't think so. AIUI, we close bug reports when the code that fixes the issue is merged, not when it gets to the chain.

@dckc
Copy link
Member

dckc commented Sep 27, 2024

My understanding is that merging to master is supposed to include whatever code / tests are necessary to get it on chain.

Copy link

cloudflare-workers-and-pages bot commented Sep 28, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 25d3578
Status: ✅  Deploy successful!
Preview URL: https://40a50467.agoric-sdk.pages.dev
Branch Preview URL: https://9982-gov-upgrade-parammgr.agoric-sdk.pages.dev

View logs

@Chris-Hibbert
Copy link
Contributor Author

merging to master is supposed to include whatever code / tests are necessary to get it on chain.

added.

Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

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

Please add a test, if not a fix, for deploying the installation, since it's already .resolve()d in bootstrapPowers.installation.produce.

Comment on lines 16 to 19
governorRef: publishRef(
install(
'@agoric/governance/src/contractGovernor.js',
'../bundles/bundle-contractGovernor.js',
Copy link
Member

@dckc dckc Sep 30, 2024

Choose a reason for hiding this comment

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

Please add a test that this works.

I just ran into at least one case where it does not while working on dapp-orchestration-basics deployment testing. And now I see why. Note the lack of .reset() in...

await Promise.all(
installationEntries.map(([key, value]) => {
produceInstallations[key].resolve(value);

Perhaps an easy 1-line fix. IOU I just made issue. Fixing it in this same PR seems fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please add a test that this works.

Ah, now that I understand #10172, I get that by "works", you mean that it saves the installation to promise space. That had never been part of my mental model of what publishRef(install() did, and so most of the time, I manually populated produce.instance.contract.
Now that I get what it's supposed to be doing, I'll ensure that the key matches the one used for the governance installation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

commit 7b9e75f uses restoreRef() to replace a bunch of manual fiddling with bundles and install() calls. The line in coreProposalBehavior.js is part of the solution.

@dckc
Copy link
Member

dckc commented Sep 30, 2024

Also, please include an Upgrade Considerations section in the PR description that goes into the merge commit. @ivanlei recently asked for a list of all the vats that we're upgrading in u17. When u18 or whatever comes around, I want to be able to show that we thought about that list ahead of time. Thanks for adding the contract-upgrade label; that will make this easier to find.

@Chris-Hibbert Chris-Hibbert requested a review from dckc October 4, 2024 21:38
Comment on lines +16 to +21
contractGovernorRef: publishRef(
install(
'@agoric/governance/src/contractGovernor.js',
'../bundles/bundle-contractGovernor.js',
),
),
Copy link
Member

Choose a reason for hiding this comment

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

Looks like we're installing the governor from two places. So we'll get 2 installation handles.

Does it matter whether the governor for VaultFactory has an identical installation handle to the one from the auctioneer instance? Does it matter that only one of them can be checked against agoricNames.installation to see whether it's the "right" one?

Copy link
Member

Choose a reason for hiding this comment

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

We discussed the possibility of only using this mechanism in 1 place and waiting for it in the other. (take care to not just wait for consume.installation.contractGovernor, since that's already resolved)

It doesn't seem that either option is catastrophic, so I'll leave it at your discretion.

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 made a separate issue: #10248. I'd like to fix it before this gets to the chain, but I think it's second priority, and there's other work to get done.

Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

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

I'd like to discuss installation handle identities briefly.

@@ -149,7 +139,7 @@ export const upgradeVaults = async (
});

const upgradeResult = await E(kit.adminFacet).upgradeContract(
bundleID,
VaultFactoryBundle.bundleID,
Copy link
Member

Choose a reason for hiding this comment

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

that name is kinda misleading.

I went "whoa! we're putting the whole text of the vault factory contract in there??!?" but then I realized no, it's just a small data structure with a .bundleID. The relevant type is ManifestBundleRef. A name based on that might be nice: vaultsBundleRef.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

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

yay for progress on bug fixes...

@Chris-Hibbert Chris-Hibbert force-pushed the 9584-upgradePriceFeeds branch from bf1bd0c to eb941d4 Compare October 9, 2024 17:34
@Chris-Hibbert Chris-Hibbert requested a review from a team as a code owner October 9, 2024 17:34
Base automatically changed from 9584-upgradePriceFeeds to master October 9, 2024 18:14
Rather than holding the paramManager retriever, paramGovernance holds
an accessor that asks the contract for the paramManager each time it
needs it.
priceFeeds don't have governed params, so they don't need the upgrade
of their governor, and they are started by startGovernedUpgradeable(),
which grabs the old governor installation before these coreEvals can
change it.
@Chris-Hibbert Chris-Hibbert force-pushed the 9982-gov-upgrade-paramMgr branch from 7b9e75f to 25d3578 Compare October 9, 2024 18:44
@Chris-Hibbert Chris-Hibbert added the automerge:rebase Automatically rebase updates, then merge label Oct 9, 2024
@mergify mergify bot merged commit da89a20 into master Oct 9, 2024
93 checks passed
@mergify mergify bot deleted the 9982-gov-upgrade-paramMgr branch October 9, 2024 20:14
mergify bot added a commit that referenced this pull request Oct 21, 2024
closes: #10248

## Description

#10163 (priceFeed coreEval) installed the contractGovernor twice, unnecessarily. This installs it once, and passes the reference from the auction proposal to the vaultFactory proposal.

### Security Considerations

Repairs a minor issue with legibility of upgraded contracts.

### Scaling Considerations

N/A

### Documentation Considerations

N/A

### Testing Considerations

priceFeed update tests continue to pass.

### Upgrade Considerations

This will be included with the priceFeed coreEval, which is expected to be added to upgrade 18.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge bug Something isn't working contract-upgrade Governance Governance
Projects
None yet
2 participants