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

6701 ec oracles list #6963

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b13f85f
chore: remove empty amm integration test
turadg Feb 10, 2023
e2207ff
refactor(fluxAggregator): split singleton / contract
turadg Feb 9, 2023
727f40c
chore(types): BundleCap
turadg Feb 9, 2023
cd4b947
feat: puppetGovernance setup tools
turadg Feb 9, 2023
fbe5136
test(price): rename test-fluxAggregator
turadg Feb 10, 2023
2add695
test(price): simplify fluxAggregator test
turadg Feb 10, 2023
9e65ecf
chore(types): cleanup
turadg Feb 10, 2023
acd263b
chore(types): fix DeeplyAwaited
turadg Feb 10, 2023
d4ac24e
chore(types): fix allValues
turadg Feb 10, 2023
8010fb2
fix(vaultDirector): add setOfferFilter
turadg Feb 10, 2023
a9c03a5
fix(vaultDirector): getContractGovernor return
turadg Feb 10, 2023
b255ca3
chore(types): installations in WellKnownSpaces
turadg Feb 10, 2023
dbc0159
WIP feat(price): fluxAggregator governance
turadg Feb 10, 2023
dfd334a
WIP: instances don't match
turadg Feb 10, 2023
dcafc14
chore(types): fixup governance
turadg Feb 10, 2023
9931e4f
refactor: WellKnownInstallations
turadg Feb 10, 2023
50b38a8
Revert "refactor: WellKnownInstallations"
turadg Feb 10, 2023
8bc4870
WIP
turadg Feb 10, 2023
ae3d5d2
chore(vaultFactory)!: subscription method compatible with governance
turadg Feb 10, 2023
96a7589
feat!: allow paths in governance methods
turadg Feb 10, 2023
d2fc0ef
fixup something
turadg Feb 10, 2023
5b137a9
give up
turadg Feb 10, 2023
e8c9eb0
fixup getGovernedApiNames
turadg Feb 10, 2023
f6377d9
oracle test passing
turadg Feb 10, 2023
8ec7e31
fixup puppet gov
turadg Feb 10, 2023
7410bb7
clean up debugging
turadg Feb 10, 2023
be64930
fixup splitof fluxAggregator.contract
turadg Feb 10, 2023
b0f4e4a
feat(ec-charter): VoteOnApiCall
turadg Feb 11, 2023
6c7a922
fix(governApi): harden returns
turadg Feb 11, 2023
edc7d2c
test(smartWallet): extract helpers from psm integration
turadg Feb 11, 2023
49ec3ee
fixup! WIP feat(price): fluxAggregator governance
turadg Feb 11, 2023
cd8211a
refactor: DRY WalletName.depositFacet
turadg Feb 11, 2023
d9204e4
feat(price): addOracles by EC
turadg Feb 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/SwingSet/src/types-external.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ export {};
* Vat Creation and Management
*
* @typedef { string } BundleID
* @typedef {*} BundleCap
* @typedef {'BundleCap' & import("@endo/marshal").Remotable<'BundleCap'>} BundleCap
* @typedef { { moduleFormat: 'endoZipBase64', endoZipBase64: string, endoZipBase64Sha512: string } } EndoZipBase64Bundle
*
* @typedef { unknown } Meter
Expand Down
6 changes: 3 additions & 3 deletions packages/governance/src/contractGovernance/governApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const { Fail, quote: q } = assert;
const makeApiInvocationPositions = (apiMethodName, methodArgs) => {
const positive = harden({ apiMethodName, methodArgs });
const negative = harden({ dontInvoke: apiMethodName });
return { positive, negative };
return harden({ positive, negative });
};

/**
Expand Down Expand Up @@ -113,11 +113,11 @@ const setupApiGovernance = async (
},
);

return {
return harden({
outcomeOfUpdate,
instance: voteCounter,
details: E(counterPublicFacet).getDetails(),
};
});
};

return Far('paramGovernor', {
Expand Down
9 changes: 8 additions & 1 deletion packages/governance/src/contractGovernance/governParam.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ const assertBallotConcernsParam = (paramSpec, questionSpec) => {
Fail`Question path (${issue.spec.paramPath}) doesn't match request (${paramPath})`;
};

/** @type {SetupGovernance} */
/**
* @param {ERef<ZoeService>} zoe
* @param {ERef<ParamManagerRetriever>} paramManagerRetriever
* @param {Instance} contractInstance
* @param {ERef<import('@agoric/time/src/types').TimerService>} timer
* @param {() => Promise<PoserFacet>} getUpdatedPoserFacet
* @returns {Promise<ParamGovernor>}
*/
const setupParamGovernance = async (
zoe,
paramManagerRetriever,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ const isAsync = {
* @typedef {[type: T, value: ParamValueForType<T>]} ST param spec tuple
*/

/**
* @typedef {{ type: 'invitation', value: Amount<'set'> }} InvitationParam
*/

// XXX better to use the manifest constant ParamTypes
// but importing that here turns this file into a module,
// breaking the ambient typing
Expand Down
42 changes: 37 additions & 5 deletions packages/governance/src/contractGovernor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { E } from '@endo/eventual-send';
import { Far } from '@endo/marshal';
import { mustMatch } from '@agoric/store';

import { makeTracer } from '@agoric/internal';
import {
CONTRACT_ELECTORATE,
setupParamGovernance,
Expand All @@ -12,6 +13,8 @@ import { ParamChangesQuestionDetailsShape } from './typeGuards.js';

const { Fail } = assert;

const trace = makeTracer('CGov');
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const trace = makeTracer('CGov');
const trace = makeTracer('CGov', false);


/**
* Validate that the question details correspond to a parameter change question
* that the electorate hosts, and that the voteCounter and other details are
Expand Down Expand Up @@ -57,7 +60,7 @@ const validateQuestionFromCounter = async (zoe, electorate, voteCounter) => {

/**
* @typedef {StandardTerms} ContractGovernorTerms
* @property {import('@agoric/time/src/types').TimerService} timer
* @property {ERef<import('@agoric/time/src/types').TimerService>} timer
* @property {Installation} governedContractInstallation
*/

Expand Down Expand Up @@ -115,27 +118,40 @@ const validateQuestionFromCounter = async (zoe, electorate, voteCounter) => {
* governedContractInstallation: Installation<CF>,
* governed: {
* issuerKeywordRecord: IssuerKeywordRecord,
* terms: {governedParams: {[CONTRACT_ELECTORATE]: Amount<'set'>}},
* terms: {governedParams: {[CONTRACT_ELECTORATE]: InvitationParam}},
* }
* }>}
*/

/**
* @template {() => {creatorFacet: GovernorFacet<any>, publicFacet: GovernedPublicFacetMethods} } SF Start function of governed contract
* @typedef {(zcf?: any, privateArgs?: any, baggage?: any) => import('type-fest').Promisable<{creatorFacet: GovernorFacet<any>, publicFacet: GovernedPublicFacetMethods}>} GovernableStartFn
*/
/**
* @template {GovernableStartFn} SF Start function of governed contract
* @typedef {GovernedContractFacetAccess<Awaited<ReturnType<SF>>['publicFacet'], Awaited<ReturnType<SF>>['creatorFacet']>} GovernedContractFnFacetAccess
* Like GovernedContractFacetAccess but templated by the start function
*/

/**
* Start an instance of a governor, governing a "governed" contract specified in terms.
*
* @template {GovernableStartFn} SF Start function of governed contract
* @param {ZCF<{
* timer: import('@agoric/time/src/types').TimerService,
* timer: ERef<import('@agoric/time/src/types').TimerService>,
* governedContractInstallation: Installation<SF>,
* governed: {
* issuerKeywordRecord: IssuerKeywordRecord,
* terms: {governedParams: {[CONTRACT_ELECTORATE]: Amount<'set'>}},
* terms: {governedParams: {[CONTRACT_ELECTORATE]: import('./contractGovernance/typedParamManager.js').InvitationParam}},
* }
* }>} zcf
* @param {{
* governed: Record<string, unknown>
* }} privateArgs
*/
const start = async (zcf, privateArgs) => {
trace('start');
const zoe = zcf.getZoeService();
trace('getTerms', zcf.getTerms());
const {
timer,
governedContractInstallation,
Expand All @@ -144,6 +160,7 @@ const start = async (zcf, privateArgs) => {
terms: contractTerms,
},
} = zcf.getTerms();
trace('contractTerms', contractTerms);
contractTerms.governedParams[CONTRACT_ELECTORATE] ||
Fail`Contract must declare ${CONTRACT_ELECTORATE} as a governed parameter`;

Expand All @@ -152,6 +169,13 @@ const start = async (zcf, privateArgs) => {
electionManager: zcf.getInstance(),
});

trace('starting governedContractInstallation');
/** @type {{
* creatorFacet: GovernorFacet<Awaited<ReturnType<SF>>['creatorFacet']>,
* instance: import('@agoric/zoe/src/zoeService/utils').Instance<SF>,
* publicFacet: Awaited<ReturnType<SF>>['publicFacet'],
* adminFacet: AdminFacet,
* }} */
const {
creatorFacet: governedCF,
instance: governedInstance,
Expand All @@ -168,6 +192,7 @@ const start = async (zcf, privateArgs) => {

/** @type {() => Promise<Instance>} */
const getElectorateInstance = async () => {
// @ts-expect-error FIXME use getGovernedParams() and possibly a helper
const invitationAmount = await E(governedPF).getInvitationAmount(
CONTRACT_ELECTORATE,
);
Expand All @@ -191,9 +216,11 @@ const start = async (zcf, privateArgs) => {
}
return poserFacet;
};
trace('awaiting getUpdatedPoserFacet');
await getUpdatedPoserFacet();
assert(poserFacet, 'question poser facet must be initialized');

trace('awaiting setupParamGovernance');
// All governed contracts have at least a governed electorate
const { voteOnParamChanges, createdQuestion: createdParamQuestion } =
await setupParamGovernance(
Expand All @@ -204,6 +231,7 @@ const start = async (zcf, privateArgs) => {
getUpdatedPoserFacet,
);

trace('awaiting setupFilterGovernance');
const { voteOnFilter, createdFilterQuestion } = await setupFilterGovernance(
zoe,
governedInstance,
Expand Down Expand Up @@ -296,7 +324,11 @@ const start = async (zcf, privateArgs) => {
voteOnOfferFilter: voteOnFilter,
getCreatorFacet: () => limitedCreatorFacet,
getAdminFacet: () => adminFacet,
// TODO use distinct names. "governed" could apply to governance aspects or the contract subject to governance
// "governee" could be used to name the contract that the governor instantiated
// TODO rename to getGoverneeInstance for clarity
getInstance: () => governedInstance,
// TODO rename to getGoverneePublicFacet for clarity
getPublicFacet: () => governedPF,
});

Expand Down
3 changes: 1 addition & 2 deletions packages/governance/src/contractHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const facetHelpers = (zcf, paramManager) => {
/**
* @template {{}} CF
* @param {CF} limitedCreatorFacet
* @param {{}} [governedApis]
* @param {Record<string, (...any) => unknown>} [governedApis]
* @returns {GovernorFacet<CF>}
*/
const makeFarGovernorFacet = (limitedCreatorFacet, governedApis = {}) => {
Expand All @@ -127,7 +127,6 @@ const facetHelpers = (zcf, paramManager) => {
// The contract provides a facet with the APIs that can be invoked by
// governance
/** @type {() => GovernedApis} */
// @ts-expect-error TS think this is a RemotableBrand??
getGovernedApis: () => Far('governedAPIs', governedApis),
// The facet returned by getGovernedApis is Far, so we can't see what
// methods it has. There's no clean way to have contracts specify the APIs
Expand Down
39 changes: 15 additions & 24 deletions packages/governance/src/types-ambient.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,31 +569,32 @@
* @property {VoteOnParamChanges} voteOnParamChanges
* @property {VoteOnApiInvocation} voteOnApiInvocation
* @property {VoteOnOfferFilter} voteOnOfferFilter
* @property {() => Promise<LimitedCreatorFacet<CF>>} getCreatorFacet - creator
* @property {() => ERef<LimitedCreatorFacet<CF>>} getCreatorFacet - creator
* facet of the governed contract, without the tightly held ability to change
* param values.
* @property {(poserInvitation: Invitation) => Promise<void>} replaceElectorate
* @property {() => Promise<AdminFacet>} getAdminFacet
* @property {() => ERef<AdminFacet>} getAdminFacet
* @property {() => GovernedPublicFacet<PF>} getPublicFacet - public facet of the governed contract
* @property {() => Instance} getInstance - instance of the governed
* contract
*/

/**
* @typedef GovernedPublicFacetMethods
* @property {() => StoredSubscription<GovernanceSubscriptionState>} getSubscription
* @property {(path?: any) => StoredSubscription<GovernanceSubscriptionState>} getSubscription
* @property {() => Instance} getContractGovernor
* @property {() => ParamStateRecord} getGovernedParams - get descriptions of
* @property {(path?: any) => ParamStateRecord} getGovernedParams - get descriptions of
* all the governed parameters
* @property {(name: string) => Amount} getAmount
* @property {(name: string) => Brand} getBrand
* @property {(name: string) => Instance} getInstance
* @property {(name: string) => Installation} getInstallation
* @property {(name: string) => Amount} getInvitationAmount
* @property {(name: string) => bigint} getNat
* @property {(name: string) => Ratio} getRatio
* @property {(name: string) => string} getString
* @property {(name: string) => any} getUnknown
// FIXME these accessors are onerous for the contract. A facade for them can be made from getGovernedParams()
// property {(name: string) => Amount} getAmount
// property {(name: string) => Brand} getBrand
// property {(name: string) => Instance} getInstance
// property {(name: string) => Installation} getInstallation
// property {(name: string) => Amount} getInvitationAmount
// property {(name: string) => bigint} getNat
// property {(name: string) => Ratio} getRatio
// property {(name: string) => string} getString
// property {(name: string) => any} getUnknown
*/

/**
Expand Down Expand Up @@ -633,7 +634,7 @@

/**
* @typedef {object} ParamManagerRetriever
* @property {(paramKey?: ParamKey) => AnyParamManager} get
* @property {(paramKey: unknown) => AnyParamManager} get
*/

/**
Expand Down Expand Up @@ -681,16 +682,6 @@
* @property {CreatedQuestion} createdFilterQuestion
*/

/**
* @callback SetupGovernance
* @param {ERef<ZoeService>} zoe
* @param {ERef<ParamManagerRetriever>} paramManagerRetriever
* @param {Instance} contractInstance
* @param {import('@agoric/time/src/types').TimerService} timer
* @param {() => Promise<PoserFacet>} getUpdatedPoserFacet
* @returns {ParamGovernor}
*/

/**
* @callback CreatedQuestion
* Was this question created by this ContractGovernor?
Expand Down
8 changes: 8 additions & 0 deletions packages/governance/test/unitTests/test-paramGovernance.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ const setUpGovernedContract = async (zoe, electorateTerms, timer) => {
installBundle(zoe, voteCounterBundle),
installBundle(zoe, governedBundle),
]);
/**
* @type {{
* governor: Installation<import('../../src/contractGovernor.js').start>,
* electorate: Installation<import('../../src/noActionElectorate.js').start>,
* counter: Installation<import('../../src/binaryVoteCounter.js').start>,
* governed: Installation<import('../swingsetTests/contractGovernor/governedContract.js').start>,
* }}
*/
const installs = { governor, electorate, counter, governed };

const { creatorFacet: committeeCreator } = await E(zoe).startInstance(
Expand Down
Loading