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

Merged
merged 9 commits into from
Feb 16, 2025
Merged

Excise reallocate() #10871

merged 9 commits into from
Feb 16, 2025

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: c522d55
Status: ✅  Deploy successful!
Preview URL: https://19e59eaf.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 +50
// 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.

Still applicable.

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

@Chris-Hibbert Chris-Hibbert Jan 24, 2025

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 from the current version to itself, which is no change at all.

The test would be straightforward to add to a3p-integration. It 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bootstrap tests (in packages/boot/test/bootstrapTests) have the ability to test a contract running in a vat, and interacting with the standard set of vats started up using the whole bootstrap mechanism. It's hard to use these tests to do upgrade tests from one version of code to another because they get their code from agoric-sdk directly. So using this to compare what happens when upgrading from one version of ZCF to another would also be problematic.

This PR has now been rebased on top of the repaired Upgrade 19 (#10947). On top of that, it now installs a new version of ZCF early in the cycle. From the logs, I can see that the contracts that get installed or upgraded after that get the new version of ZCF.

Since the U19 upgrade repairs also ensured that the acceptance tests are now running on the upgraded versions of the contracts, we can also be sure that everything that is tested in the acceptance tests is running against upgraded contracts.

Comment on lines +42 to +50
// 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
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.

LGTM but I'll defer approval to someone closer to this part of the system

Comment on lines 191 to 194
// Register a new ZCF to be used for all future contract instances and upgrades
vm.CoreProposalStepForModules(
"@agoric/builders/scripts/vats/upgrade-zcf.js",
),
Copy link
Member

Choose a reason for hiding this comment

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

Why not apply this before the wallet factory upgrade so that vat can pick up the new zcf too?

@@ -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.

Still applicable.

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.

After some discussion of Upgrade Considerations with @turadg and @mhofman , it seems that this is ready to go.

In particular, upgrading zcf is sufficiently testedc.

@Chris-Hibbert Chris-Hibbert added the automerge:rebase Automatically rebase updates, then merge label Feb 16, 2025
Copy link
Contributor

mergify bot commented Feb 16, 2025

This pull request has been removed from the queue for the following reason: checks failed.

The merge conditions cannot be satisfied due to failing checks:

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.

If you want to requeue this pull request, you need to post a comment with the text: @mergifyio requeue

@mergify mergify bot merged commit c9e286a into master Feb 16, 2025
83 checks passed
@mergify mergify bot deleted the 6679-exciseReallocate branch February 16, 2025 22:11
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 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