Skip to content

Commit

Permalink
using governedContractKits in core eval replacing committee and chart…
Browse files Browse the repository at this point in the history
…er (#10178)

<!-- < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < ☺
v                               ✰  Thanks for creating a PR! ✰
☺ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >  -->

<!-- Most PRs should close a specific Issue. All PRs should at least
reference one or more Issues. Edit and/or delete the following lines as
appropriate (note: you don't need both `refs` and `closes` for the same
one): -->


refs: #10134  #10133 

## Description
This pull request builds on #10166 and #10164. It updates the core eval
code to utilize the `governorCreatorFacet` for the governed contracts
via the `governedContractKit`. Initially, the aim was to use the
`governedContractKit` to access facets from price feed contracts. But
since it also includes facets for other governed contracts, I expanded
the code to incorporate these as well.

### Security Considerations
Same as #10166 and #10164 

### Scaling Considerations
<!-- Does this change require or encourage significant increase in
consumption of CPU cycles, RAM, on-chain storage, message exchanges, or
other scarce resources? If so, can that be prevented or mitigated? -->

### Documentation Considerations
<!-- Give our docs folks some hints about what needs to be described to
downstream users. Backwards compatibility: what happens to existing data
or deployments when this code is shipped? Do we need to instruct users
to do something to upgrade their saved data? If there is no upgrade path
possible, how bad will that be for users? -->

### Testing Considerations
Same as specified in #10164 

### Upgrade Considerations
<!-- What aspects of this PR are relevant to upgrading live production
systems, and how should they be addressed? -->
  • Loading branch information
rabi-siddique authored Oct 2, 2024
2 parents cd7809e + 0fba11e commit 8277e1b
Showing 1 changed file with 17 additions and 56 deletions.
73 changes: 17 additions & 56 deletions packages/inter-protocol/src/proposals/replaceElectorate.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,56 +198,26 @@ const startNewEconCharter = async ({
};

const addGovernorsToEconCharter = async (
{
consume: {
reserveKit,
vaultFactoryKit,
auctioneerKit,
psmKit,
provisionPoolStartResult,
},
instance: {
consume: { reserve, VaultFactory, auctioneer, provisionPool },
},
},
{ consume: { psmKit, governedContractKits } },
{ options: { econCharterKit } },
) => {
const { creatorFacet } = E.get(econCharterKit);
const { creatorFacet: ecCreatorFacet } = E.get(econCharterKit);

const psmKitMap = await psmKit;

for (const { psm, psmGovernorCreatorFacet, label } of psmKitMap.values()) {
E(creatorFacet).addInstance(psm, psmGovernorCreatorFacet, label);
E(ecCreatorFacet).addInstance(psm, psmGovernorCreatorFacet, label);
}

await Promise.all(
[
{
label: 'reserve',
instanceP: reserve,
facetP: E.get(reserveKit).governorCreatorFacet,
},
{
label: 'VaultFactory',
instanceP: VaultFactory,
facetP: E.get(vaultFactoryKit).governorCreatorFacet,
},
{
label: 'auctioneer',
instanceP: auctioneer,
facetP: E.get(auctioneerKit).governorCreatorFacet,
},
{
label: 'provisionPool',
instanceP: provisionPool,
facetP: E.get(provisionPoolStartResult).governorCreatorFacet,
},
].map(async ({ label, instanceP, facetP }) => {
const [instance, govFacet] = await Promise.all([instanceP, facetP]);
const governedContractKitMap = await governedContractKits;

return E(creatorFacet).addInstance(instance, govFacet, label);
}),
);
for (const {
instance,
governorCreatorFacet,
label,
} of governedContractKitMap.values()) {
E(ecCreatorFacet).addInstance(instance, governorCreatorFacet, label);
}
};

export const replaceElectorate = async (permittedPowers, config) => {
Expand All @@ -264,14 +234,14 @@ export const replaceElectorate = async (permittedPowers, config) => {
},
);

const governedContractKitsMap =
await permittedPowers.consume.governedContractKits;
const psmKitMap = await permittedPowers.consume.psmKit;

const creatorFacets = [
E.get(permittedPowers.consume.reserveKit).governorCreatorFacet,
E.get(permittedPowers.consume.auctioneerKit).governorCreatorFacet,
E.get(permittedPowers.consume.vaultFactoryKit).governorCreatorFacet,
E.get(permittedPowers.consume.provisionPoolStartResult)
.governorCreatorFacet,
...[...governedContractKitsMap.values()].map(
governedContractKit => governedContractKit.governorCreatorFacet,
),
...[...psmKitMap.values()].map(psmKit => psmKit.psmGovernorCreatorFacet),
];

Expand Down Expand Up @@ -317,11 +287,8 @@ export const getManifestForReplaceElectorate = async (_, options) => ({
manifest: {
[replaceElectorate.name]: {
consume: {
reserveKit: true,
auctioneerKit: true,
vaultFactoryKit: true,
psmKit: true,
provisionPoolStartResult: true,
governedContractKits: true,

board: true,
chainStorage: true,
Expand All @@ -347,12 +314,6 @@ export const getManifestForReplaceElectorate = async (_, options) => ({
economicCommittee: true,
econCommitteeCharter: true,
},
consume: {
reserve: true,
VaultFactory: true,
auctioneer: true,
provisionPool: true,
},
},
},
},
Expand Down

0 comments on commit 8277e1b

Please sign in to comment.