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

support changes to governed APIs #10822

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

Chris-Hibbert
Copy link
Contributor

@Chris-Hibbert Chris-Hibbert commented Jan 8, 2025

closes: #9990

Description

When a contract is upgraded, we'll read the governed APIs afresh.

Security Considerations

Nothing special. The point of governed APIs is that contracts can make access to calling specific APIs legible in the sense used by governance.

Scaling Considerations

Not an issue.

Documentation Considerations

If we had detailed documentation on governance, this would be worth adding to the docs.

Testing Considerations

Added a bootstrap test showing that a contract can be upgraded and the new APIs will be available after upgrade.

Upgrade Considerations

AssetReserve, fluxAggregator, and VaultFactory use apiGovernance and might need this support if any governed APIs were added.

Copy link

cloudflare-workers-and-pages bot commented Jan 9, 2025

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: d1ec616
Status: ✅  Deploy successful!
Preview URL: https://994d62e6.agoric-sdk.pages.dev
Branch Preview URL: https://9990-upgradeapis.agoric-sdk.pages.dev

View logs

@Chris-Hibbert Chris-Hibbert force-pushed the 9990-upgradeAPIs branch 2 times, most recently from 5d8e282 to 0edc4ac Compare January 15, 2025 00:18
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.

Yes, I agree we should merge this.

How to validate it on a testnet in an upcoming release is sort of... interesting. It will have no impact until some governed contract gets upgraded. That might be in a later release. At that point, there would be a testing burden to verify that this fix works. But this issue won't be listed in the things we fixed for that later release. Seems like an acceptable risk.

The rest of my comments are sort of thinking out loud. Maybe I should keep them to myself... but I suppose I'll share anyway.

];

const setUpGovernedContract = async (zoe, timer, EV, controller) => {
const installBundle = contractBundle => EV(zoe).install(contractBundle);
Copy link
Member

Choose a reason for hiding this comment

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

Is it important to use .install(...) rather than .installBundleID(...)?

add2: { outgoing: 'add2' },
};

let governedContract;
Copy link
Member

Choose a reason for hiding this comment

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

module level mutable state. hm. consider using a promise(kit) in t.context something like t.context.governedContractKit.promise and .resolver

const agoricNamesAdmin =
await EV.vat('bootstrap').consumeItem('agoricNamesAdmin');
const instanceAdmin = await EV(agoricNamesAdmin).lookupAdmin('instance');
await EV(instanceAdmin).update('governedContract', instance);
Copy link
Member

Choose a reason for hiding this comment

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

I wonder why we're adding governedContract to agoricNames.instance

Comment on lines +194 to +195
// Far side-effects the object, and can only be applied once
const farGovernedApis = Far('governedAPIs', governedApis);
Copy link
Member

Choose a reason for hiding this comment

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

after thinking about this a bit, it's probably OK as is. But I'll leave some breadcrumbs...

can we make it the caller's responsibility to mark it Far? Making the record in one place and marking it Far in another is odd.

One possibility is to make a new record...

Suggested change
// Far side-effects the object, and can only be applied once
const farGovernedApis = Far('governedAPIs', governedApis);
// Far side-effects the object, and can only be applied once
const farGovernedApis = Far('governedAPIs', { ... governedApis });

Comment on lines +498 to +500
} catch (e) {
Fail`restartContract failed: original contract facets were not durable`;
}
Copy link
Member

Choose a reason for hiding this comment

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

Is it really the case that the only exception possible is that the facets were not durable? I suppose so... zcfBaggage.get(...) is the only thing in the try.

But if get(...) had a bug, we might lose diagnostic info here. It feels weird to throw away e completely.
log it?

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 support something like this?

Suggested change
} catch (e) {
Fail`restartContract failed: original contract facets were not durable`;
}
} catch (e) {
throw assert.error(`restartContract failed: original contract facets were not durable`, { cause: e });
}

@@ -0,0 +1,311 @@
import { test as anyTest } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';
Copy link
Member

Choose a reason for hiding this comment

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

it's a little hard to see the forest for the trees.

Part of me would like the uninteresting stuff moved to a separate file, but then I'd have to jump back and forth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API governance captures governed APIs at initial creation, doesn't notice upgrades
2 participants