Skip to content

Commit

Permalink
chore(provisionPool): allow overriding PerAccountInitialAmount during…
Browse files Browse the repository at this point in the history
… contract upgrade (#10638)

closes: #10562 

## Description


This PR introduces changes to the provisionPool contract to allow the overriding of the PerAccountInitialAmount parameter, governed by the Economic Committee, during a contract upgrade.

To achieve the above functionality, this PR introduces the following changes:

- The PerAccountInitialAmount can now be injected into the contract through privateArgs by defining governedParamOverrides.
- The handleParamGovernance method from the governance package was updated to include an aditional optional argument called `overrides` so it can be passed to the makeParamManagerFromTerms to manage the governed parameter during contract upgrades.

The core-eval proposal used to upgrade provisionPool was also updated to fetch the current value of PerAccountInitialAmount set on Vstorage and include it on the new privateArgs.
If the governedParamOverrides is not provided to the privateArgs during the contract upgrade, the value of PerAccountInitialAmount will reset to the default one set on the contract terms.


### Security Considerations


### Scaling Considerations


### Documentation Considerations


### Testing Considerations


The existing unit tests for the inter-protocol and vats packages, as well as the a3p-integration tests, have been verified to continue passing with these changes.

Additionally, these changes were tested against the governance acceptance tests in the a3p-integration which ensures that governed parameter values remain intact after a contract upgrade, as well as testing that, if not included in the governedParamOverrides on the core-eval proposal, the value of PerAccountInitialAmount will reset to the default one set on the contract terms.

To maintain the scope of this PR, that test is not included here, however, it will be introduced in PR #10555, which is planned to be opened once this is merged.

### Upgrade Considerations
  • Loading branch information
mergify[bot] authored Dec 13, 2024
2 parents c7a005e + 6c5ccde commit 6e25d9f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
3 changes: 3 additions & 0 deletions packages/governance/src/contractHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,15 @@ const facetHelpers = (zcf, paramManager) => {
* @param {M} paramTypesMap
* @param {ERef<StorageNode>} [storageNode]
* @param {ERef<Marshaller>} [marshaller]
* @param {object} [overrides]
*/
const handleParamGovernance = (
zcf,
initialPoserInvitation,
paramTypesMap,
storageNode,
marshaller,
overrides,
) => {
/** @type {import('@agoric/notifier').StoredPublisherKit<GovernanceSubscriptionState>} */
const publisherKit = makeStoredPublisherKit(
Expand All @@ -269,6 +271,7 @@ const handleParamGovernance = (
zcf,
{ Electorate: initialPoserInvitation },
paramTypesMap,
overrides,
);

return facetHelpers(zcf, paramManager);
Expand Down
2 changes: 2 additions & 0 deletions packages/inter-protocol/src/provisionPool.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ harden(meta);
* storageNode: StorageNode;
* marshaller: Marshal<any>;
* metricsOverride?: import('./provisionPoolKit.js').MetricsNotification;
* governedParamOverrides?: Record<string, Amount | undefined>;
* }} privateArgs
* @param {import('@agoric/vat-data').Baggage} baggage
*/
Expand All @@ -74,6 +75,7 @@ export const start = async (zcf, privateArgs, baggage) => {
},
privateArgs.storageNode,
privateArgs.marshaller,
privateArgs.governedParamOverrides,
);

const zone = makeDurableZone(baggage);
Expand Down
22 changes: 15 additions & 7 deletions packages/vats/src/proposals/upgrade-provisionPool-proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { E } from '@endo/far';
import { deeplyFulfilled } from '@endo/marshal';
import { makeTracer } from '@agoric/internal';

const tracer = makeTracer('UpgradeProvisionPool');
const trace = makeTracer('UpgradeProvisionPool');

/**
* @param {BootstrapPowers & {
Expand Down Expand Up @@ -30,7 +30,7 @@ export const upgradeProvisionPool = async (
const { provisionPoolRef } = options.options;

assert(provisionPoolRef.bundleID);
tracer(`PROVISION POOL BUNDLE ID: `, provisionPoolRef);
trace(`PROVISION POOL BUNDLE ID: `, provisionPoolRef);

const [
provisionPoolStartResult,
Expand All @@ -49,6 +49,7 @@ export const upgradeProvisionPool = async (
adminFacet,
instance,
creatorFacet: ppCreatorFacet,
publicFacet: ppPublicFacet,
} = provisionPoolStartResult;
const { creatorFacet: wfCreatorFacet } = walletFactoryStartResult;

Expand All @@ -59,35 +60,42 @@ export const upgradeProvisionPool = async (
E(electorateCreatorFacet).getPoserInvitation(),
]);

const params = await E(ppPublicFacet).getGovernedParams();
const governedParamOverrides = harden({
PerAccountInitialAmount: params.PerAccountInitialAmount.value,
});
trace('governedParamOverrides: ', { governedParamOverrides });

const newPrivateArgs = harden({
...originalPrivateArgs,
initialPoserInvitation: poserInvitation,
governedParamOverrides,
});

const upgradeResult = await E(adminFacet).upgradeContract(
provisionPoolRef.bundleID,
newPrivateArgs,
);

tracer('ProvisionPool upgraded: ', upgradeResult);
trace('ProvisionPool upgraded: ', upgradeResult);

const references = {
bankManager,
namesByAddressAdmin,
walletFactory: wfCreatorFacet,
};

tracer('Calling setReferences with: ', references);
trace('Calling setReferences with: ', references);
await E(ppCreatorFacet).setReferences(references);

tracer('Creating bridgeHandler...');
trace('Creating bridgeHandler...');
const bridgeHandler = await E(ppCreatorFacet).makeHandler();

tracer('Setting new bridgeHandler...');
trace('Setting new bridgeHandler...');
// @ts-expect-error casting
await E(provisionWalletBridgeManager).setHandler(bridgeHandler);

tracer('Done.');
trace('Done.');
};

export const getManifestForUpgradingProvisionPool = (
Expand Down

0 comments on commit 6e25d9f

Please sign in to comment.