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

zoe adminFacet can terminate contract #10267

Merged
merged 6 commits into from
Oct 17, 2024
Merged

zoe adminFacet can terminate contract #10267

merged 6 commits into from
Oct 17, 2024

Conversation

Chris-Hibbert
Copy link
Contributor

@Chris-Hibbert Chris-Hibbert commented Oct 11, 2024

closes: #9716

Description

Add the ability to terminate a vat if you have the adminFacet.

Security Considerations

Doesn't add authority, because anyone with the adminFacet could also upgrade the contract to something that calls zcf.shutdown(). In practice, this will be controlled by governance or the bootstrap space.

Scaling Considerations

The scaling issue is about cleaning up abandoned vats that are holding memory we'd like to release.

Documentation Considerations

We should (not urgently) update the zoe docs to mention this ability.

Testing Considerations

Adding a unit test wouldn't show anything, since it relies on the adminNode.

A SwingSet test shows that the vat is dead.

I will pass this to @warner as a draft, so he can do extensive testing of the cleanup process.

Upgrade Considerations

The upgrade requires only merging the code and upgrading Zoe. This will redefine all the existing adminFacets. The holders of those facets (in the bootstrap space) will then be able to invoke the method and observe the results.

@Chris-Hibbert Chris-Hibbert self-assigned this Oct 11, 2024
@Chris-Hibbert Chris-Hibbert requested a review from a team as a code owner October 11, 2024 21:41
@Chris-Hibbert Chris-Hibbert marked this pull request as draft October 11, 2024 21:41
Copy link

cloudflare-workers-and-pages bot commented Oct 11, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 507c979
Status: ✅  Deploy successful!
Preview URL: https://4b226e84.agoric-sdk.pages.dev
Branch Preview URL: https://9716-zoe-kill.agoric-sdk.pages.dev

View logs

@Chris-Hibbert Chris-Hibbert marked this pull request as ready for review October 15, 2024 18:55
@Chris-Hibbert Chris-Hibbert requested a review from dckc October 15, 2024 18:55
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.

The plan to get this code to mainnet isn't completely explicit, but I think it's clear enough.

The upgrade requires only ... upgrading Zoe.

We have rough plans to upgrade all vats to match master in due course:

In particular, we have experience with replace-zoe.js in #8291

Comment on lines 552 to 579
const liquidityIssuer = await E(publicFacet).getLiquidityIssuer();
const liquidityBrand = await E(liquidityIssuer).getBrand();
const liquidity = value => AmountMath.make(liquidityBrand, value);

// Alice adds liquidity
// 10 moola = 5 simoleans at the time of the liquidity adding
// aka 2 moola = 1 simolean
const addLiquidityProposal = harden({
give: { Central: moola(10n), Secondary: simoleans(5n) },
want: { Liquidity: liquidity(10n) },
});
const paymentKeywordRecord = harden({
Central: moolaPayment,
Secondary: simoleanPayment,
});
const addLiquidityInvitation = E(publicFacet).makeAddLiquidityInvitation();
const addLiqSeatP = await E(zoe).offer(
addLiquidityInvitation,
addLiquidityProposal,
paymentKeywordRecord,
);

console.log(await E(addLiqSeatP).getOfferResult());

const liquidityPayout = await E(addLiqSeatP).getPayout('Liquidity');

const liquidityTokenPurseP = E(liquidityIssuer).makeEmptyPurse();
await E(liquidityTokenPurseP).deposit(liquidityPayout);
Copy link
Member

Choose a reason for hiding this comment

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

What's the purpose of the stuff between starting the contract and shutting it down?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

copied from a previous test. Not adding anything here.

[3, 7, 0],
];
const dump = await main(t, ['shutdownAutoswap', startingValues]);
t.deepEqual(dump.log, expectedShutdownAutoswapOkLog);
Copy link
Member

Choose a reason for hiding this comment

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

Have you considered using t.snapshot()?

Suggested change
t.deepEqual(dump.log, expectedShutdownAutoswapOkLog);
t.snapshot(dump.log);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, hadn't thought of that.

Perhaps moderately simpler to maintain.

@dckc
Copy link
Member

dckc commented Oct 15, 2024

@warner I just realized that this somewhat depends on #8928 , which is still open. Is it OK to presume that #8928 will get addressed before we deploy this?

@Chris-Hibbert
Copy link
Contributor Author

Chris-Hibbert commented Oct 15, 2024

@warner I just realized that this somewhat depends on #8928 , which is still open. Is it OK to presume that #8928 will get addressed before we deploy this?

I was at first intending to not request review until this had been tested with those changes. Then I realized that this code only gets invoked by a coreEval, and it's benign until invoked. We can make this change now, and wait for kernel changes to try to run it. If you think we should wait for that testing before merging and installing on-chain, then please say so and revert your approval. Or just wait to approve the upcoming PR that will add this change to app.og.

@dckc
Copy link
Member

dckc commented Oct 16, 2024

... We can make this change now, and wait for kernel changes to try to run it.

I'm content with that plan.

@Chris-Hibbert Chris-Hibbert added the automerge:rebase Automatically rebase updates, then merge label Oct 16, 2024
@Chris-Hibbert Chris-Hibbert removed the automerge:rebase Automatically rebase updates, then merge label Oct 16, 2024
@Chris-Hibbert Chris-Hibbert added the automerge:rebase Automatically rebase updates, then merge label Oct 17, 2024
@mergify mergify bot merged commit 55a8847 into master Oct 17, 2024
90 checks passed
@mergify mergify bot deleted the 9716-zoe-kill branch October 17, 2024 19:19
mergify bot added a commit that referenced this pull request Oct 23, 2024
refs: #10267

## Description

Upgrade Zoe as part of the next software upgrade.

### Security Considerations

The new Zoe will add the ability to terminate vats from bootstrap space. 

### Scaling Considerations

Terminating vats will allow us to address some space leakage issues.

### Documentation Considerations

The new behavior is accessible on a facet that is only exposed to the bootstrap space. Doesn't need to impact developer docs.

### Testing Considerations

Tested in a bootstrap test.

### Upgrade Considerations

We expect to include this change with the next software upgrade, so we can start making use of the ability to remove unneeded vats.
mergify bot added a commit that referenced this pull request Oct 24, 2024
refs: #10267

## Description

We'll be upgrading Zoe in the next SW upgrade. We need to reset the KREAd subscribers when we do that.

### Security Considerations

No broader security implications

### Scaling Considerations

Not a scaling concern

### Documentation Considerations

I should have remembered this when adding the Zoe upgrade.

### Testing Considerations

None

### Upgrade Considerations

There's a constraint that we need to enforce when we upgrade Zoe. So far, we've been remembering it, but it would be better to automate.
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 contract-upgrade Zoe package: Zoe
Projects
None yet
Development

Successfully merging this pull request may close these issues.

can/should zoe expose vat-termination on the instance admin facet?
2 participants