@agoric/inter-protocol 0.16.2-dev-feae722.0 → 0.16.2-dev-6415ef6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/inter-protocol",
|
|
3
|
-
"version": "0.16.2-dev-
|
|
3
|
+
"version": "0.16.2-dev-6415ef6.0+6415ef6",
|
|
4
4
|
"description": "Core cryptoeconomy contracts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -31,15 +31,15 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
35
|
-
"@agoric/governance": "0.10.4-dev-
|
|
36
|
-
"@agoric/internal": "0.3.3-dev-
|
|
37
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
38
|
-
"@agoric/store": "0.9.3-dev-
|
|
39
|
-
"@agoric/time": "0.3.3-dev-
|
|
40
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
41
|
-
"@agoric/vats": "0.15.2-dev-
|
|
42
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
34
|
+
"@agoric/ertp": "0.16.3-dev-6415ef6.0+6415ef6",
|
|
35
|
+
"@agoric/governance": "0.10.4-dev-6415ef6.0+6415ef6",
|
|
36
|
+
"@agoric/internal": "0.3.3-dev-6415ef6.0+6415ef6",
|
|
37
|
+
"@agoric/notifier": "0.6.3-dev-6415ef6.0+6415ef6",
|
|
38
|
+
"@agoric/store": "0.9.3-dev-6415ef6.0+6415ef6",
|
|
39
|
+
"@agoric/time": "0.3.3-dev-6415ef6.0+6415ef6",
|
|
40
|
+
"@agoric/vat-data": "0.5.3-dev-6415ef6.0+6415ef6",
|
|
41
|
+
"@agoric/vats": "0.15.2-dev-6415ef6.0+6415ef6",
|
|
42
|
+
"@agoric/zoe": "0.26.3-dev-6415ef6.0+6415ef6",
|
|
43
43
|
"@endo/captp": "^4.3.0",
|
|
44
44
|
"@endo/errors": "^1.2.5",
|
|
45
45
|
"@endo/eventual-send": "^1.2.5",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"jessie.js": "^0.3.4"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@agoric/smart-wallet": "0.5.4-dev-
|
|
54
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
55
|
-
"@agoric/swingset-vat": "0.32.3-dev-
|
|
56
|
-
"@agoric/zone": "0.2.3-dev-
|
|
53
|
+
"@agoric/smart-wallet": "0.5.4-dev-6415ef6.0+6415ef6",
|
|
54
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-6415ef6.0+6415ef6",
|
|
55
|
+
"@agoric/swingset-vat": "0.32.3-dev-6415ef6.0+6415ef6",
|
|
56
|
+
"@agoric/zone": "0.2.3-dev-6415ef6.0+6415ef6",
|
|
57
57
|
"@endo/bundle-source": "^3.4.0",
|
|
58
58
|
"@endo/init": "^1.1.4",
|
|
59
59
|
"@endo/promise-kit": "^1.1.5",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"typeCoverage": {
|
|
85
85
|
"atLeast": 95.8
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "6415ef6aea262e9c32eddaabd3e7f379665c38ff"
|
|
88
88
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export function replaceAllElectorates(permittedPowers: EconomyBootstrapPowers, config: {
|
|
2
|
+
options: {
|
|
3
|
+
committeeName: string;
|
|
4
|
+
voterAddresses: Record<string, string>;
|
|
5
|
+
highPrioritySendersConfig: {
|
|
6
|
+
addressesToAdd: string[];
|
|
7
|
+
addressesToRemove: string[];
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
}): Promise<void>;
|
|
11
|
+
export function getManifestForReplaceAllElectorates({ economicCommitteeRef: _economicCommitteeRef }: {
|
|
12
|
+
economicCommitteeRef: any;
|
|
13
|
+
}, options: any): Promise<{
|
|
14
|
+
manifest: {
|
|
15
|
+
[x: string]: {
|
|
16
|
+
consume: {
|
|
17
|
+
psmKit: boolean;
|
|
18
|
+
governedContractKits: boolean;
|
|
19
|
+
chainStorage: boolean;
|
|
20
|
+
highPrioritySendersManager: boolean;
|
|
21
|
+
namesByAddressAdmin: boolean;
|
|
22
|
+
board: boolean;
|
|
23
|
+
startUpgradable: boolean;
|
|
24
|
+
};
|
|
25
|
+
produce: {
|
|
26
|
+
economicCommitteeKit: boolean;
|
|
27
|
+
economicCommitteeCreatorFacet: string;
|
|
28
|
+
};
|
|
29
|
+
installation: {
|
|
30
|
+
consume: {
|
|
31
|
+
committee: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
instance: {
|
|
35
|
+
produce: {
|
|
36
|
+
economicCommittee: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
options: any;
|
|
42
|
+
}>;
|
|
43
|
+
import type { EconomyBootstrapPowers } from './econ-behaviors.js';
|
|
44
|
+
//# sourceMappingURL=replaceElectorate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replaceElectorate.d.ts","sourceRoot":"","sources":["replaceElectorate.js"],"names":[],"mappings":"AAqPO,uDAlBI,sBAAsB,UAGtB;IACN,OAAO,EAAE;QACP,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACvC,yBAAyB,EAAE;YACzB,cAAc,EAAE,MAAM,EAAE,CAAC;YACzB,iBAAiB,EAAE,MAAM,EAAE,CAAC;SAC7B,CAAC;KACH,CAAC;CACH,GAGS,OAAO,CAAC,IAAI,CAAC,CA4DzB;AAIM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BL;4CA5TwC,qBAAqB"}
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file A proposal to replace the EC committee and charter.
|
|
3
|
+
*
|
|
4
|
+
* This script manages configuration updates, distributes invitations, and
|
|
5
|
+
* establishes committees using specified voter addresses and related
|
|
6
|
+
* parameters.
|
|
7
|
+
*
|
|
8
|
+
* See `@agoric/builders/scripts/inter-protocol/replace-electorate-core.js` for
|
|
9
|
+
* the proposal builder.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// @ts-check
|
|
13
|
+
import { E } from '@endo/eventual-send';
|
|
14
|
+
import {
|
|
15
|
+
assertPathSegment,
|
|
16
|
+
makeStorageNodeChild,
|
|
17
|
+
} from '@agoric/internal/src/lib-chainStorage.js';
|
|
18
|
+
import { reserveThenDeposit } from './utils.js';
|
|
19
|
+
|
|
20
|
+
/** @import {EconomyBootstrapPowers} from './econ-behaviors.js' */
|
|
21
|
+
/** @import {CommitteeElectorateCreatorFacet} from '@agoric/governance/src/committee.js'; */
|
|
22
|
+
|
|
23
|
+
const trace = (...args) => console.log('GovReplaceCommiteeAndCharter', ...args);
|
|
24
|
+
|
|
25
|
+
const traced = (label, x) => {
|
|
26
|
+
trace(label, x);
|
|
27
|
+
return x;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const { values } = Object;
|
|
31
|
+
|
|
32
|
+
/** @type {<X, Y>(xs: X[], ys: Y[]) => [X, Y][]} */
|
|
33
|
+
const zip = (xs, ys) => xs.map((x, i) => [x, ys[i]]);
|
|
34
|
+
|
|
35
|
+
/** @type {(name: string) => string} */
|
|
36
|
+
const sanitizePathSegment = name => {
|
|
37
|
+
const candidate = name.replace(/[ ,]/g, '_');
|
|
38
|
+
assertPathSegment(candidate);
|
|
39
|
+
return candidate;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Handles the configuration updates for high-priority senders list by adding or
|
|
44
|
+
* removing addresses.
|
|
45
|
+
*
|
|
46
|
+
* @param {EconomyBootstrapPowers} powers - The bootstrap powers required for
|
|
47
|
+
* economic operations.
|
|
48
|
+
* @param {{
|
|
49
|
+
* options: {
|
|
50
|
+
* highPrioritySendersConfig: {
|
|
51
|
+
* addressesToAdd: string[];
|
|
52
|
+
* addressesToRemove: string[];
|
|
53
|
+
* };
|
|
54
|
+
* };
|
|
55
|
+
* }} config
|
|
56
|
+
* - The configuration object containing lists of addresses to add or remove.
|
|
57
|
+
*/
|
|
58
|
+
const handlehighPrioritySendersList = async (
|
|
59
|
+
{ consume: { highPrioritySendersManager: highPrioritySendersManagerP } },
|
|
60
|
+
{ options: { highPrioritySendersConfig } },
|
|
61
|
+
) => {
|
|
62
|
+
const HIGH_PRIORITY_SENDERS_NAMESPACE = 'economicCommittee';
|
|
63
|
+
const highPrioritySendersManager = await highPrioritySendersManagerP;
|
|
64
|
+
|
|
65
|
+
if (!highPrioritySendersManager) {
|
|
66
|
+
throw assert.error(`highPrioritySendersManager is not defined`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const { addressesToAdd, addressesToRemove } = highPrioritySendersConfig;
|
|
70
|
+
|
|
71
|
+
await Promise.all(
|
|
72
|
+
addressesToAdd.map(addr =>
|
|
73
|
+
E(highPrioritySendersManager).add(
|
|
74
|
+
HIGH_PRIORITY_SENDERS_NAMESPACE,
|
|
75
|
+
traced('High Priority Senders: adding', addr),
|
|
76
|
+
),
|
|
77
|
+
),
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
await Promise.all(
|
|
81
|
+
addressesToRemove.map(addr =>
|
|
82
|
+
E(highPrioritySendersManager).remove(
|
|
83
|
+
HIGH_PRIORITY_SENDERS_NAMESPACE,
|
|
84
|
+
traced('High Priority Senders: removing', addr),
|
|
85
|
+
),
|
|
86
|
+
),
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Invites Economic Committee (EC) members by distributing voting invitations to
|
|
92
|
+
* the specified addresses.
|
|
93
|
+
*
|
|
94
|
+
* @param {EconomyBootstrapPowers} powers - The bootstrap powers required for
|
|
95
|
+
* economic operations, including `namesByAddressAdmin` used for managing
|
|
96
|
+
* names.
|
|
97
|
+
* @param {{
|
|
98
|
+
* options: {
|
|
99
|
+
* voterAddresses: Record<string, string>;
|
|
100
|
+
* economicCommitteeCreatorFacet: CommitteeElectorateCreatorFacet;
|
|
101
|
+
* };
|
|
102
|
+
* }} config
|
|
103
|
+
* - The configuration object containing voter addresses and the economic
|
|
104
|
+
* committee facet to create voter invitations.
|
|
105
|
+
*
|
|
106
|
+
* @returns {Promise<void>} A promise that resolves once the invitations have
|
|
107
|
+
* been distributed.
|
|
108
|
+
*/
|
|
109
|
+
const inviteECMembers = async (
|
|
110
|
+
{ consume: { namesByAddressAdmin } },
|
|
111
|
+
{ options: { voterAddresses = {}, economicCommitteeCreatorFacet } },
|
|
112
|
+
) => {
|
|
113
|
+
trace('Create invitations for new committee');
|
|
114
|
+
|
|
115
|
+
const invitations = await E(
|
|
116
|
+
economicCommitteeCreatorFacet,
|
|
117
|
+
).getVoterInvitations();
|
|
118
|
+
assert.equal(invitations.length, values(voterAddresses).length);
|
|
119
|
+
|
|
120
|
+
trace('Distribute invitations');
|
|
121
|
+
/** @param {[string, Promise<Invitation>][]} addrInvitations */
|
|
122
|
+
const distributeInvitations = async addrInvitations => {
|
|
123
|
+
await Promise.all(
|
|
124
|
+
addrInvitations.map(async ([addr, invitationP]) => {
|
|
125
|
+
const [voterInvitation] = await Promise.all([invitationP]);
|
|
126
|
+
trace('Sending voting invitations to', addr);
|
|
127
|
+
await reserveThenDeposit(
|
|
128
|
+
`econ committee member ${addr}`,
|
|
129
|
+
namesByAddressAdmin,
|
|
130
|
+
addr,
|
|
131
|
+
[voterInvitation],
|
|
132
|
+
);
|
|
133
|
+
}),
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
await distributeInvitations(zip(values(voterAddresses), invitations));
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Starts a new Economic Committee (EC) by creating an instance with the
|
|
142
|
+
* provided committee specifications.
|
|
143
|
+
*
|
|
144
|
+
* @param {EconomyBootstrapPowers} powers - The resources and capabilities
|
|
145
|
+
* required to start the committee.
|
|
146
|
+
* @param {{
|
|
147
|
+
* options: {
|
|
148
|
+
* committeeName: string;
|
|
149
|
+
* committeeSize: number;
|
|
150
|
+
* };
|
|
151
|
+
* }} config
|
|
152
|
+
* - Configuration object containing the name and size of the committee.
|
|
153
|
+
*
|
|
154
|
+
* @returns {Promise<CommitteeElectorateCreatorFacet>} A promise that resolves
|
|
155
|
+
* to the creator facet of the newly created EC instance.
|
|
156
|
+
*/
|
|
157
|
+
const startNewEconomicCommittee = async (
|
|
158
|
+
{
|
|
159
|
+
consume: { board, chainStorage, startUpgradable },
|
|
160
|
+
produce: { economicCommitteeKit, economicCommitteeCreatorFacet },
|
|
161
|
+
installation: {
|
|
162
|
+
consume: { committee },
|
|
163
|
+
},
|
|
164
|
+
instance: {
|
|
165
|
+
produce: { economicCommittee },
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
{ options: { committeeName, committeeSize } },
|
|
169
|
+
) => {
|
|
170
|
+
const COMMITTEES_ROOT = 'committees';
|
|
171
|
+
|
|
172
|
+
trace('startNewEconomicCommittee');
|
|
173
|
+
|
|
174
|
+
trace(`committeeName ${committeeName}`);
|
|
175
|
+
trace(`committeeSize ${committeeSize}`);
|
|
176
|
+
|
|
177
|
+
const committeesNode = await makeStorageNodeChild(
|
|
178
|
+
chainStorage,
|
|
179
|
+
COMMITTEES_ROOT,
|
|
180
|
+
);
|
|
181
|
+
const storageNode = await E(committeesNode).makeChildNode(
|
|
182
|
+
sanitizePathSegment(committeeName),
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
const marshaller = await E(board).getPublishingMarshaller();
|
|
186
|
+
|
|
187
|
+
trace('Starting new EC Committee Instance');
|
|
188
|
+
|
|
189
|
+
const privateArgs = {
|
|
190
|
+
storageNode,
|
|
191
|
+
marshaller,
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const terms = {
|
|
195
|
+
committeeName,
|
|
196
|
+
committeeSize,
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const startResult = await E(startUpgradable)({
|
|
200
|
+
label: 'economicCommittee',
|
|
201
|
+
installation: committee,
|
|
202
|
+
privateArgs,
|
|
203
|
+
terms,
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
const { instance, creatorFacet } = startResult;
|
|
207
|
+
|
|
208
|
+
trace('Started new EC Committee Instance Successfully');
|
|
209
|
+
|
|
210
|
+
economicCommitteeKit.reset();
|
|
211
|
+
economicCommitteeKit.resolve(
|
|
212
|
+
harden({ ...startResult, label: 'economicCommittee' }),
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
economicCommittee.reset();
|
|
216
|
+
economicCommittee.resolve(instance);
|
|
217
|
+
|
|
218
|
+
economicCommitteeCreatorFacet.reset();
|
|
219
|
+
economicCommitteeCreatorFacet.resolve(creatorFacet);
|
|
220
|
+
|
|
221
|
+
return creatorFacet;
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Replaces the electorate for governance contracts by creating a new Economic
|
|
226
|
+
* Committee and updating contracts with the new electorate's creator facet.
|
|
227
|
+
*
|
|
228
|
+
* @param {EconomyBootstrapPowers} permittedPowers - The resources and
|
|
229
|
+
* capabilities needed for operations, including access to governance
|
|
230
|
+
* contracts and the PSM kit.
|
|
231
|
+
* @param {{
|
|
232
|
+
* options: {
|
|
233
|
+
* committeeName: string;
|
|
234
|
+
* voterAddresses: Record<string, string>;
|
|
235
|
+
* highPrioritySendersConfig: {
|
|
236
|
+
* addressesToAdd: string[];
|
|
237
|
+
* addressesToRemove: string[];
|
|
238
|
+
* };
|
|
239
|
+
* };
|
|
240
|
+
* }} config
|
|
241
|
+
* - Configuration object containing the committee details and governance options.
|
|
242
|
+
*
|
|
243
|
+
* @returns {Promise<void>} A promise that resolves when the electorate has been
|
|
244
|
+
* replaced.
|
|
245
|
+
*/
|
|
246
|
+
export const replaceAllElectorates = async (permittedPowers, config) => {
|
|
247
|
+
const { committeeName, voterAddresses, highPrioritySendersConfig } =
|
|
248
|
+
config.options;
|
|
249
|
+
|
|
250
|
+
const economicCommitteeCreatorFacet = await startNewEconomicCommittee(
|
|
251
|
+
permittedPowers,
|
|
252
|
+
{
|
|
253
|
+
options: {
|
|
254
|
+
committeeName,
|
|
255
|
+
committeeSize: values(voterAddresses).length,
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
const governedContractKitsMap =
|
|
261
|
+
await permittedPowers.consume.governedContractKits;
|
|
262
|
+
const psmKitMap = await permittedPowers.consume.psmKit;
|
|
263
|
+
|
|
264
|
+
const governanceDetails = [
|
|
265
|
+
...[...governedContractKitsMap.values()].map(governedContractKit => ({
|
|
266
|
+
creatorFacet: governedContractKit.governorCreatorFacet,
|
|
267
|
+
label: governedContractKit.label,
|
|
268
|
+
})),
|
|
269
|
+
...[...psmKitMap.values()].map(psmKit => ({
|
|
270
|
+
creatorFacet: psmKit.psmGovernorCreatorFacet,
|
|
271
|
+
label: psmKit.label,
|
|
272
|
+
})),
|
|
273
|
+
];
|
|
274
|
+
|
|
275
|
+
await Promise.all(
|
|
276
|
+
governanceDetails.map(async ({ creatorFacet, label }) => {
|
|
277
|
+
trace(`Getting PoserInvitation for ${label}...`);
|
|
278
|
+
const newElectoratePoser = await E(
|
|
279
|
+
economicCommitteeCreatorFacet,
|
|
280
|
+
).getPoserInvitation();
|
|
281
|
+
trace(`Successfully received newElectoratePoser for ${label}`);
|
|
282
|
+
|
|
283
|
+
trace(`Replacing electorate for ${label}`);
|
|
284
|
+
await E(creatorFacet).replaceElectorate(newElectoratePoser);
|
|
285
|
+
trace(`Successfully replaced electorate for ${label}`);
|
|
286
|
+
}),
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
await inviteECMembers(permittedPowers, {
|
|
290
|
+
options: {
|
|
291
|
+
voterAddresses,
|
|
292
|
+
economicCommitteeCreatorFacet,
|
|
293
|
+
},
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
await handlehighPrioritySendersList(permittedPowers, {
|
|
297
|
+
options: {
|
|
298
|
+
highPrioritySendersConfig,
|
|
299
|
+
},
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
trace('Installed New Economic Committee');
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
harden(replaceAllElectorates);
|
|
306
|
+
|
|
307
|
+
export const getManifestForReplaceAllElectorates = async (
|
|
308
|
+
{ economicCommitteeRef: _economicCommitteeRef },
|
|
309
|
+
options,
|
|
310
|
+
) => ({
|
|
311
|
+
manifest: {
|
|
312
|
+
[replaceAllElectorates.name]: {
|
|
313
|
+
consume: {
|
|
314
|
+
psmKit: true,
|
|
315
|
+
governedContractKits: true,
|
|
316
|
+
chainStorage: true,
|
|
317
|
+
highPrioritySendersManager: true,
|
|
318
|
+
namesByAddressAdmin: true,
|
|
319
|
+
// Rest of these are designed to be widely shared
|
|
320
|
+
board: true,
|
|
321
|
+
startUpgradable: true,
|
|
322
|
+
},
|
|
323
|
+
produce: {
|
|
324
|
+
economicCommitteeKit: true,
|
|
325
|
+
economicCommitteeCreatorFacet: 'economicCommittee',
|
|
326
|
+
},
|
|
327
|
+
installation: {
|
|
328
|
+
consume: { committee: 'zoe' },
|
|
329
|
+
},
|
|
330
|
+
instance: {
|
|
331
|
+
produce: { economicCommittee: 'economicCommittee' },
|
|
332
|
+
},
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
options: { ...options },
|
|
336
|
+
});
|