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

chore: update installations when restarting or upgrading #10999

Merged
merged 7 commits into from
Feb 13, 2025

Conversation

Chris-Hibbert
Copy link
Contributor

Description

I've known for a while that there was something magic about the installations keyword in getManifestForFoo in coreEval proposals, but I was never able to track it down. Now I've found the relevant code. In coreProposalBehavior (which is copied into generated proposals), if the manifest contains named installations, then they are added to both agoricNames and the bootstrap promiseSpace. When upgrading a contract to a new installation, the installation should nearly always be updated this way.

This PR updates all the proposals/scripts currently slated for upgrade-19 to include their upgraded bundles in installations so future references will automatically pick them up.

Security Considerations

related to security and reliability of the contracts, not the chain.

Scaling Considerations

not relevant.

Documentation Considerations

I updated the README in deploy-script-support.

Testing Considerations

The n:upgrade-next and z:acceptance tests continue to pass.

Upgrade Considerations

PSM is the only contract being upgraded in Upgrade19 that starts up multiple copies, and it was already doing this correctly.

@Chris-Hibbert Chris-Hibbert self-assigned this Feb 12, 2025
@Chris-Hibbert Chris-Hibbert requested a review from a team as a code owner February 12, 2025 23:37
@Chris-Hibbert Chris-Hibbert added deployment Chain deployment mechanism (e.g. testnet) Zoe Contract Contracts within Zoe contract-upgrade labels Feb 12, 2025
@Chris-Hibbert Chris-Hibbert requested a review from dckc February 12, 2025 23:58
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.

Making mintHolder work like PSM seems good.

There are various problems with the rest.

Comment on lines 59 to 61
installations: {
walletFactory: restoreRef(walletRef),
},
Copy link
Member

Choose a reason for hiding this comment

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

This will create a new installation handle, which is a little tricky...

This upgrade-wallet-factory2-proposal.js is designed to upgrade the wallet factory contract instance. That instance's installation handle will still be the installation handle that it was started with. I'm not sure we want to make that installation handle harder to find by removing it from agoricNames. It's not like we plan to start more smartWallet contract instances.

I suppose we can get the original handle back using E(Zoe).getInstallationForInstance(instance), so maybe there's not much harm here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will create a new installation handle, which is a little tricky...

I think that's what I intend. Without this change, the installation registered (in AoricNames and bootstrap space) would remain the old one, and if someone used that to start a new instance, they'd get the old one. I think each contract name in those tables should lead to the most recent installation, i.e. the one you would want to use.

Admittedly this doesn't make as much sense for singleton vats like walletFactory, but if I wanted to do a null-upgrade, this is the installation I'd want to use.

This upgrade-wallet-factory2-proposal.js is designed to upgrade the wallet factory contract instance. That instance's installation handle will still be the installation handle that it was started with.

That seems like a bug to me. I think @erights and I talked about this at some point and agreed that E(Zoe).getInstallationForInstance(instance) should return info about the current installation. It is currently never updated. Perhaps it should return an ordered list of installations, but the current one should be there, as that's the one that someone might want to verify.

Copy link
Member

Choose a reason for hiding this comment

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

if I wanted to do a null-upgrade, this is the installation I'd want to use.

upgrade doesn't use installations. it uses bundle hashes.
I suppose you can get a bundle hash from an installation, so I suppose that argues for updating the installation

Comment on lines 46 to 48
installations: {
walletFactory: restoreRef(agoricNamesRef),
},
Copy link
Member

Choose a reason for hiding this comment

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

walletFactory? I suppose that's a copy-and-paste-o

but more to the point: agoricNames is not a contract vat. There's no relevant 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.

done

@@ -89,5 +89,8 @@ export const getManifestForUpgradingAssetReserve = (
},
},
},
installations: {
walletFactory: restoreRef(assetReserveRef),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
walletFactory: restoreRef(assetReserveRef),
reserve: restoreRef(assetReserveRef),

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

Comment on lines 40 to 42
installations: {
walletFactory: restoreRef(bankRef),
},
Copy link
Member

Choose a reason for hiding this comment

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

not a contract vat. there are no relevant installations

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you.

@@ -51,6 +54,9 @@ export const getManifestForUpgradingRegistry = (_powers, { registryRef }) => ({
brand: { consume: { [Stable.symbol]: par } },
},
},
installations: {
walletFactory: restoreRef(registryRef),
Copy link
Member

Choose a reason for hiding this comment

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

walletFactory looks like a copy-and-paste-o

These changes don't seem to get tested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

corrected.

I don't know how to test these. Suggestions?

Copy link
Member

Choose a reason for hiding this comment

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

I can think of a contrived way to test for this particular problem:

  1. run some/all of these upgrades
  2. for each entry in agoricNames.installation, get the bundleId from the installation; extract the bundle from the kernel db; get the entry module of the bundle
  3. check that the entry module makes sense compared to the key of agoricNames.installation

But it seems like a lot of work compared to the gain. Especially since the harm from this goofy code is minimal: we don't intend to start another walletFactory. z:acceptance tests all the things we do plan to do (or: it's supposed to).

@@ -128,5 +128,8 @@ export const getManifestForUpgradingProvisionPool = (
produce: {},
},
},
installations: {
walletFactory: restoreRef(provisionPoolRef),
Copy link
Member

Choose a reason for hiding this comment

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

walletFactory again

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

cloudflare-workers-and-pages bot commented Feb 13, 2025

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: d1241a6
Status: ✅  Deploy successful!
Preview URL: https://28628f55.agoric-sdk.pages.dev
Branch Preview URL: https://cth-recordinstallations.agoric-sdk.pages.dev

View logs

@@ -89,5 +89,8 @@ export const getManifestForUpgradingAssetReserve = (
},
},
},
installations: {
assetReserve: restoreRef(assetReserveRef),
Copy link
Member

Choose a reason for hiding this comment

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

Again, I suggest reserve, not assetReserve.

Suggested change
assetReserve: restoreRef(assetReserveRef),
reserve: restoreRef(assetReserveRef),

We can see this in published.agoricNames.installation on mainnet (or any of our running networks, I'm pretty sure).

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
Contributor Author

Choose a reason for hiding this comment

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

I decided to import agoricNamesReserved from @agoric/vats/src/core/utils.js to verify that I'm using actual installation names.

@@ -51,6 +54,9 @@ export const getManifestForUpgradingRegistry = (_powers, { registryRef }) => ({
brand: { consume: { [Stable.symbol]: par } },
},
},
installations: {
priceAuthority: restoreRef(registryRef),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
priceAuthority: restoreRef(registryRef),
priceAggregator: restoreRef(registryRef),

Copy link
Member

Choose a reason for hiding this comment

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

wait... now I'm getting things mixed up.

priceAuthorityRegistry is not a contract vat.

https://github.com/Agoric/agoric-sdk/blob/a92cf556a0c806df293027458883f2a81a2bfade/packages/vats/src/vat-priceAuthority.js

Copy link
Contributor Author

Choose a reason for hiding this comment

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

dropped. I hate the names for priceAuthority/Registry/fluxAggregator!

@Chris-Hibbert Chris-Hibbert requested a review from dckc February 13, 2025 18:47
@@ -56,5 +57,8 @@ export const getManifestForUpgradeWallet = (_powers, { walletRef }) => ({
},
},
},
installations: {
[agoricNamesReserved.installation.walletFactory]: restoreRef(walletRef),
Copy link
Member

@dckc dckc Feb 13, 2025

Choose a reason for hiding this comment

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

interesting idea, but that expression evaluates to 'multitenant smart wallet'

walletFactory: 'multitenant smart wallet',

Comment on lines 60 to 61
installations: {
[agoricNamesReserved.installation.walletFactory]: restoreRef(walletRef),
Copy link
Member

@dckc dckc Feb 13, 2025

Choose a reason for hiding this comment

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

maybe...

Suggested change
installations: {
[agoricNamesReserved.installation.walletFactory]: restoreRef(walletRef),
/** @satisfies {Record<keyof typeof agoricNamesReserved.installation, unknown>} */
installations: {
'walletFactory': restoreRef(walletRef),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks good, and I'd prefer it to no check, but it didn't enforce correct names.

@@ -89,5 +90,8 @@ export const getManifestForUpgradingAssetReserve = (
},
},
},
installations: {
[agoricNamesReserved.installation.reserve]: restoreRef(assetReserveRef),
Copy link
Member

@dckc dckc Feb 13, 2025

Choose a reason for hiding this comment

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

same problem

likewise the 2 below

@Chris-Hibbert Chris-Hibbert requested a review from dckc February 13, 2025 19:56
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'm still uneasy that so many ways to get it sort of wrong are not detected by tests.
But I can't think of any cost-effective ways to improve the situation.

@Chris-Hibbert Chris-Hibbert added the automerge:squash Automatically squash merge label Feb 13, 2025
@Chris-Hibbert
Copy link
Contributor Author

I'm still uneasy that so many ways to get it sort of wrong are not detected by tests.
But I can't think of any cost-effective ways to improve the situation.

I agree. I thought of trying to impose your suggestion of keyof typeof agoricNamesReserved.installation at the manifest level, but I couldn't see a place to do that. If we had a type declaration on the value returned by getManifestForFoo, it might be worth the payoff to add that type in all the proposals.

@mergify mergify bot merged commit 9db2909 into master Feb 13, 2025
83 checks passed
@mergify mergify bot deleted the cth-recordInstallations branch February 13, 2025 21:56
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 deployment Chain deployment mechanism (e.g. testnet) Zoe Contract Contracts within Zoe
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants