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

Excise reallocate() #10871

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

Excise reallocate() #10871

wants to merge 6 commits into from

Conversation

Chris-Hibbert
Copy link
Contributor

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

closes: #6679

Description

Removes the last vestiges of zcf.reallocate() and staged allocations.

Security Considerations

The deprecated code turned out to be a bug farm. We've had no problems with the replacement.

Scaling Considerations

None.

Documentation Considerations

A separate PR (Docs:#1266) will remove the documentation. It has been marked deprecated for quite some time.

Testing Considerations

Removed tests. All the new code (using atomicRearrange) has had tests all along.

Upgrade Considerations

No known code uses the deprecated functionality. These changes are confined to ZCF. It won't matter when or if Zoe gets upgraded. The next time we bump the ZCF version, new and upgraded contracts will start using the new ZCF, but there's no hurry to make that happen.

@Chris-Hibbert Chris-Hibbert added Zoe package: Zoe code-style defensive correctness patterns; readability thru consistency contract-upgrade labels Jan 22, 2025
@Chris-Hibbert Chris-Hibbert self-assigned this Jan 22, 2025
@Chris-Hibbert Chris-Hibbert requested a review from a team as a code owner January 22, 2025 01:01
Copy link

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

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: b6231b6
Status: ✅  Deploy successful!
Preview URL: https://40b94d30.agoric-sdk.pages.dev
Branch Preview URL: https://6679-excisereallocate.agoric-sdk.pages.dev

View logs

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.

looks ok from a quick skim.

I should think it thru some more before approving

Comment on lines +42 to +45
// Removed. See #6679
if (zcfBaggage.has('zcfSeatToStagedAllocations')) {
zcfBaggage.delete('zcfSeatToStagedAllocations');
}
Copy link
Member

Choose a reason for hiding this comment

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

So all of the relevant state is in a side table? There's no exo state schema evolution monkey business?

That's awfully convenient.

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 the deprecated form of reallocate() was the second design, and so ended up ini baggage rather than state.

Copy link
Member

Choose a reason for hiding this comment

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

Since this is a regular map, should we assert that the map is empty before throwing away state?

And to ensure we don't run into this case, have we checked that all collections are empty on known chains?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this is a regular map, should we assert that the map is empty before throwing away state?

The state is never valuable.

  • it contains proposed allocations, so the contents are amounts and not assets
  • Best practices is (and has been for a year) to use atomicRearrange rather than reallocate. If a contract we don't know about still has staged allocations, this update would make them unusable.

And to ensure we don't run into this case, have we checked that all collections are empty on known chains?

I've made sure that all contracts that we know about don't use reallocate. Contracts that don't use reallocate, can't make productive use of the collection.

There aren't any contracts that we don't know about running on durable chains. If third parties have code in draft that still follows the old approach, this will help them modernize before they get to a chain.

Copy link
Member

@mhofman mhofman left a comment

Choose a reason for hiding this comment

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

Regarding upgrade considerations, removing a deprecated API is I think safe if we've checked that no currently deployed contract uses it.

Technically we should be able to remove a ZCF API like this even if a contract were using it since a null upgrade of a vat doesn't currently bump the zcf bundle, and picking up the change would be an explicit upgrade / restart of the contract.

@@ -18,6 +18,8 @@ The main focus of most threats would be a breach of one of Zoe's core invariants

## Reallocation

THIS SECTION IS OBSOLETE. We've converted all code to use attomicRearrange
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
THIS SECTION IS OBSOLETE. We've converted all code to use attomicRearrange
THIS SECTION IS OBSOLETE. We've converted all code to use atomicRearrange

Copy link
Member

Choose a reason for hiding this comment

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

I suppose we have coverage of basic upgrade functionality through some other test (preferably something lighter than an integration test)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, we don't.

In order to test upgrading a contract from one version of ZCF to another, we'd need to be able to do what I call time-travel testing, or maintain two different versions of ZCF to install within a single test. We can do that in agoric-3-proposals to represent the change from a past version to the current version, or in a3p-integration to represent the change from the current-on-chain version to this new one. But otherwise, any unit test or bootstrap test would be testing a move the the current version to itself, which is no change at all.

The test it would be straightforward to add to a3p-integration would call E(zoeConfigFacet).updateZcfBundleId(newBundleId), early in the upgrade process, and then any vat that gets upgraded later will use the new ZCF. The tests in p::upgrade-19 exercise ZCF enough to show that the upgrade will be successful.

I'll add that to the tests, and also add the update to the staged changes in upgrade.go.

Copy link
Member

@mhofman mhofman Jan 25, 2025

Choose a reason for hiding this comment

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

I thought we had the ability to do a fake livelsots test of a single contract? I suppose any interaction with Zoe is a problem for such a test?

Comment on lines +42 to +45
// Removed. See #6679
if (zcfBaggage.has('zcfSeatToStagedAllocations')) {
zcfBaggage.delete('zcfSeatToStagedAllocations');
}
Copy link
Member

Choose a reason for hiding this comment

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

Since this is a regular map, should we assert that the map is empty before throwing away state?

And to ensure we don't run into this case, have we checked that all collections are empty on known chains?

@Chris-Hibbert Chris-Hibbert added the force:integration Force integration tests to run on PR label Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-style defensive correctness patterns; readability thru consistency contract-upgrade force:integration Force integration tests to run on PR Zoe package: Zoe
Projects
None yet
Development

Successfully merging this pull request may close these issues.

move atomicTransfer from helper into Zoe
3 participants