Skip to content

Commit

Permalink
Excise reallocate() (#10871)
Browse files Browse the repository at this point in the history
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](Agoric/documentation#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.
  • Loading branch information
mergify[bot] authored Feb 16, 2025
2 parents 8ef3fde + c522d55 commit c9e286a
Show file tree
Hide file tree
Showing 20 changed files with 35 additions and 1,235 deletions.
4 changes: 4 additions & 0 deletions golang/cosmos/app/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ func unreleasedUpgradeHandler(app *GaiaApp, targetUpgrade string) func(sdk.Conte
// Each CoreProposalStep runs sequentially, and can be constructed from
// one or more modules executing in parallel within the step.
CoreProposalSteps = append(CoreProposalSteps,
// Register a new ZCF to be used for all future contract instances and upgrades
vm.CoreProposalStepForModules(
"@agoric/builders/scripts/vats/upgrade-zcf.js",
),
// because of #10794, we need to do at least a null upgrade of
// the walletFactory on every software upgrade
vm.CoreProposalStepForModules(
Expand Down
124 changes: 0 additions & 124 deletions packages/boot/test/bootstrapTests/zcf-upgrade.test.ts

This file was deleted.

154 changes: 0 additions & 154 deletions packages/boot/test/bootstrapTests/zcfProbe.contract.js

This file was deleted.

9 changes: 6 additions & 3 deletions packages/smart-wallet/test/gameAssetContract.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@ export const start = async zcf => {

// We use the deprecated stage/reallocate API
// so that we can test this with the version of zoe on mainnet1B.
playerSeat.decrementBy(gameSeat.incrementBy(give));
const tmp = mint.mintGains(want);
playerSeat.incrementBy(tmp.decrementBy(want));
zcf.reallocate(playerSeat, tmp, gameSeat);
zcf.atomicRearrange(
harden([
[playerSeat, gameSeat, give],
[tmp, playerSeat, want],
]),
);
playerSeat.exit(true);
return 'welcome to the game';
};
Expand Down
2 changes: 2 additions & 0 deletions packages/zoe/docs/AttackGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 atomicRearrange

The current approach (staging, incrementBy/decrementBy and the fact that all seats must
be included in realloc) has led to a few bugs. It's probably worth looking for other cases
that create new stagings or presume there are none outstanding. We plan to replace this
Expand Down
10 changes: 0 additions & 10 deletions packages/zoe/docs/seats.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ __ZCFSeat.exit() Flow:__

![ZCFSeat Exit Flow](./zcf-seat-exit-flow.png)

__ZCF.reallocate() Flow:__

![ZCF Reallocate Flow](./zcf-reallocate-flow.png)


## UserSeat

The `UserSeat` is what is returned when a user calls
Expand Down Expand Up @@ -67,12 +62,7 @@ The type of the ZCFSeat is:
* @property {() => ProposalRecord} getProposal
* @property {ZCFGetAmountAllocated} getAmountAllocated
* @property {() => Allocation} getCurrentAllocation
* @property {() => Allocation} getStagedAllocation
* @property {() => boolean} hasStagedAllocation
* @property {(newAllocation: Allocation) => boolean} isOfferSafe
* @property {(amountKeywordRecord: AmountKeywordRecord) => AmountKeywordRecord} incrementBy
* @property {(amountKeywordRecord: AmountKeywordRecord) => AmountKeywordRecord} decrementBy
* @property {() => void} clear
*/
```
Expand Down
Binary file removed packages/zoe/docs/zcf-reallocate-flow.png
Binary file not shown.
26 changes: 0 additions & 26 deletions packages/zoe/docs/zcf-reallocate-flow.puml

This file was deleted.

4 changes: 2 additions & 2 deletions packages/zoe/docs/zoe-catalog-of-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ seats.

### sumsByBrand - Store from `@agoric/store`

Two of these are created in every call to `zcf.reallocate`, and then
are immediately dropped.
One of these is created in every call to `zcf.atomicRearrange`, and then
is immediately dropped.

**Expected cardinality**: One key per brand of allocation reallocated over.

Expand Down
Loading

0 comments on commit c9e286a

Please sign in to comment.