@agoric/fast-usdc 0.1.1-dev-adb17dd.0 → 0.1.1-dev-9e5f628.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 +15 -15
- package/src/exos/operator-kit.js +6 -6
- package/src/exos/settler.js +1 -1
- package/src/exos/status-manager.js +34 -30
- package/src/exos/transaction-feed.js +45 -23
- package/src/fast-usdc.contract.js +1 -0
- package/src/types.ts +2 -0
- package/src/utils/deploy-config.js +8 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/fast-usdc",
|
|
3
|
-
"version": "0.1.1-dev-
|
|
3
|
+
"version": "0.1.1-dev-9e5f628.0+9e5f628",
|
|
4
4
|
"description": "CLI and library for Fast USDC product",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"lint:eslint": "eslint ."
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
26
|
-
"@agoric/vats": "0.15.2-dev-
|
|
27
|
-
"@agoric/zone": "0.2.3-dev-
|
|
25
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-9e5f628.0+9e5f628",
|
|
26
|
+
"@agoric/vats": "0.15.2-dev-9e5f628.0+9e5f628",
|
|
27
|
+
"@agoric/zone": "0.2.3-dev-9e5f628.0+9e5f628",
|
|
28
28
|
"@fast-check/ava": "^2.0.1",
|
|
29
29
|
"ava": "^5.3.0",
|
|
30
30
|
"c8": "^10.1.2",
|
|
@@ -32,16 +32,16 @@
|
|
|
32
32
|
"ts-blank-space": "^0.4.4"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@agoric/client-utils": "0.1.1-dev-
|
|
36
|
-
"@agoric/cosmic-proto": "0.4.1-dev-
|
|
37
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
38
|
-
"@agoric/internal": "0.3.3-dev-
|
|
39
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
40
|
-
"@agoric/orchestration": "0.1.1-dev-
|
|
41
|
-
"@agoric/store": "0.9.3-dev-
|
|
42
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
43
|
-
"@agoric/vow": "0.1.1-dev-
|
|
44
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
35
|
+
"@agoric/client-utils": "0.1.1-dev-9e5f628.0+9e5f628",
|
|
36
|
+
"@agoric/cosmic-proto": "0.4.1-dev-9e5f628.0+9e5f628",
|
|
37
|
+
"@agoric/ertp": "0.16.3-dev-9e5f628.0+9e5f628",
|
|
38
|
+
"@agoric/internal": "0.3.3-dev-9e5f628.0+9e5f628",
|
|
39
|
+
"@agoric/notifier": "0.6.3-dev-9e5f628.0+9e5f628",
|
|
40
|
+
"@agoric/orchestration": "0.1.1-dev-9e5f628.0+9e5f628",
|
|
41
|
+
"@agoric/store": "0.9.3-dev-9e5f628.0+9e5f628",
|
|
42
|
+
"@agoric/vat-data": "0.5.3-dev-9e5f628.0+9e5f628",
|
|
43
|
+
"@agoric/vow": "0.1.1-dev-9e5f628.0+9e5f628",
|
|
44
|
+
"@agoric/zoe": "0.26.3-dev-9e5f628.0+9e5f628",
|
|
45
45
|
"@cosmjs/proto-signing": "^0.32.4",
|
|
46
46
|
"@cosmjs/stargate": "^0.32.4",
|
|
47
47
|
"@endo/base64": "^1.0.9",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"publishConfig": {
|
|
82
82
|
"access": "public"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "9e5f628a3d953539bcea5e3ba2365367158ec069"
|
|
85
85
|
}
|
package/src/exos/operator-kit.js
CHANGED
|
@@ -12,7 +12,7 @@ const trace = makeTracer('TxOperator');
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @typedef {object} OperatorPowers
|
|
15
|
-
* @property {(evidence: CctpTxEvidence,
|
|
15
|
+
* @property {(evidence: CctpTxEvidence, operatorId: string) => void} attest
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -35,7 +35,7 @@ const OperatorKitI = {
|
|
|
35
35
|
}),
|
|
36
36
|
|
|
37
37
|
operator: M.interface('Operator', {
|
|
38
|
-
submitEvidence: M.call(CctpTxEvidenceShape).returns(
|
|
38
|
+
submitEvidence: M.call(CctpTxEvidenceShape).returns(),
|
|
39
39
|
getStatus: M.call().returns(M.record()),
|
|
40
40
|
}),
|
|
41
41
|
};
|
|
@@ -87,7 +87,7 @@ export const prepareOperatorKit = (zone, staticPowers) =>
|
|
|
87
87
|
const { operator } = this.facets;
|
|
88
88
|
// TODO(bootstrap integration): cause this call to throw and confirm that it
|
|
89
89
|
// shows up in the the smart-wallet UpdateRecord `error` property
|
|
90
|
-
|
|
90
|
+
operator.submitEvidence(evidence);
|
|
91
91
|
return staticPowers.makeInertInvitation(
|
|
92
92
|
'evidence was pushed in the invitation maker call',
|
|
93
93
|
);
|
|
@@ -98,12 +98,12 @@ export const prepareOperatorKit = (zone, staticPowers) =>
|
|
|
98
98
|
* submit evidence from this operator
|
|
99
99
|
*
|
|
100
100
|
* @param {CctpTxEvidence} evidence
|
|
101
|
+
* @returns {void}
|
|
101
102
|
*/
|
|
102
|
-
|
|
103
|
+
submitEvidence(evidence) {
|
|
103
104
|
const { state } = this;
|
|
104
105
|
!state.disabled || Fail`submitEvidence for disabled operator`;
|
|
105
|
-
|
|
106
|
-
return result;
|
|
106
|
+
state.powers.attest(evidence, state.operatorId);
|
|
107
107
|
},
|
|
108
108
|
/** @returns {OperatorStatus} */
|
|
109
109
|
getStatus() {
|
package/src/exos/settler.js
CHANGED
|
@@ -260,7 +260,7 @@ export const prepareSettler = (
|
|
|
260
260
|
repayer.repay(settlingSeat, split);
|
|
261
261
|
|
|
262
262
|
// update status manager, marking tx `SETTLED`
|
|
263
|
-
statusManager.disbursed(txHash);
|
|
263
|
+
statusManager.disbursed(txHash, split);
|
|
264
264
|
},
|
|
265
265
|
/**
|
|
266
266
|
* @param {EvmHash} txHash
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Fail, makeError, q } from '@endo/errors';
|
|
1
|
+
import { makeTracer } from '@agoric/internal';
|
|
3
2
|
import { appendToStoredArray } from '@agoric/store/src/stores/store-utils.js';
|
|
3
|
+
import { AmountKeywordRecordShape } from '@agoric/zoe/src/typeGuards.js';
|
|
4
|
+
import { Fail, makeError, q } from '@endo/errors';
|
|
4
5
|
import { E } from '@endo/eventual-send';
|
|
5
|
-
import {
|
|
6
|
+
import { M } from '@endo/patterns';
|
|
7
|
+
import { PendingTxStatus, TerminalTxStatus, TxStatus } from '../constants.js';
|
|
6
8
|
import {
|
|
7
9
|
CctpTxEvidenceShape,
|
|
8
10
|
EvmHashShape,
|
|
9
11
|
PendingTxShape,
|
|
10
12
|
} from '../type-guards.js';
|
|
11
|
-
import { PendingTxStatus, TerminalTxStatus, TxStatus } from '../constants.js';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* @import {MapStore, SetStore} from '@agoric/store';
|
|
@@ -48,6 +49,7 @@ const pendingTxKeyOf = evidence => {
|
|
|
48
49
|
/**
|
|
49
50
|
* @typedef {{
|
|
50
51
|
* log?: LogFn;
|
|
52
|
+
* marshaller: ERef<Marshaller>;
|
|
51
53
|
* }} StatusManagerPowers
|
|
52
54
|
*/
|
|
53
55
|
|
|
@@ -66,6 +68,7 @@ export const prepareStatusManager = (
|
|
|
66
68
|
zone,
|
|
67
69
|
txnsNode,
|
|
68
70
|
{
|
|
71
|
+
marshaller,
|
|
69
72
|
log = makeTracer('Advancer', true),
|
|
70
73
|
} = /** @type {StatusManagerPowers} */ ({}),
|
|
71
74
|
) => {
|
|
@@ -102,14 +105,25 @@ export const prepareStatusManager = (
|
|
|
102
105
|
/**
|
|
103
106
|
* @param {EvmHash} txId
|
|
104
107
|
* @param {TransactionRecord} record
|
|
108
|
+
* @returns {Promise<void>}
|
|
105
109
|
*/
|
|
106
|
-
const publishTxnRecord = (txId, record) => {
|
|
110
|
+
const publishTxnRecord = async (txId, record) => {
|
|
107
111
|
const txNode = E(txnsNode).makeChildNode(txId, {
|
|
108
112
|
sequence: true, // avoid overwriting other output in the block
|
|
109
113
|
});
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
)
|
|
114
|
+
|
|
115
|
+
// XXX awkward for publish* to update a store, but it's temporary
|
|
116
|
+
if (record.status && TerminalTxStatus[record.status]) {
|
|
117
|
+
// UNTIL https://github.com/Agoric/agoric-sdk/issues/7405
|
|
118
|
+
// Queue it for deletion later because if we deleted it now the earlier
|
|
119
|
+
// writes in this block would be wiped. For now we keep track of what to
|
|
120
|
+
// delete when we know it'll be another block.
|
|
121
|
+
storedCompletedTxs.add(txId);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const capData = await E(marshaller).toCapData(record);
|
|
125
|
+
|
|
126
|
+
await E(txNode).setValue(JSON.stringify(capData));
|
|
113
127
|
};
|
|
114
128
|
|
|
115
129
|
/**
|
|
@@ -124,22 +138,6 @@ export const prepareStatusManager = (
|
|
|
124
138
|
);
|
|
125
139
|
};
|
|
126
140
|
|
|
127
|
-
/**
|
|
128
|
-
* @param {CctpTxEvidence['txHash']} hash
|
|
129
|
-
* @param {TxStatus} status
|
|
130
|
-
*/
|
|
131
|
-
const publishStatus = (hash, status) => {
|
|
132
|
-
// Don't await, just writing to vstorage.
|
|
133
|
-
void publishTxnRecord(hash, harden({ status }));
|
|
134
|
-
if (TerminalTxStatus[status]) {
|
|
135
|
-
// UNTIL https://github.com/Agoric/agoric-sdk/issues/7405
|
|
136
|
-
// Queue it for deletion later because if we deleted it now the earlier
|
|
137
|
-
// writes in this block would be wiped. For now we keep track of what to
|
|
138
|
-
// delete when we know it'll be another block.
|
|
139
|
-
storedCompletedTxs.add(hash);
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
|
|
143
141
|
/**
|
|
144
142
|
* Ensures that `txHash+chainId` has not been processed
|
|
145
143
|
* and adds entry to `seenTxs` set.
|
|
@@ -164,7 +162,7 @@ export const prepareStatusManager = (
|
|
|
164
162
|
publishEvidence(txHash, evidence);
|
|
165
163
|
if (status !== PendingTxStatus.Observed) {
|
|
166
164
|
// publishEvidence publishes Observed
|
|
167
|
-
|
|
165
|
+
void publishTxnRecord(txHash, harden({ status }));
|
|
168
166
|
}
|
|
169
167
|
};
|
|
170
168
|
|
|
@@ -187,7 +185,7 @@ export const prepareStatusManager = (
|
|
|
187
185
|
];
|
|
188
186
|
const txpost = { ...tx, status };
|
|
189
187
|
pendingTxs.set(key, harden([...prefix, txpost, ...suffix]));
|
|
190
|
-
|
|
188
|
+
void publishTxnRecord(tx.txHash, harden({ status }));
|
|
191
189
|
}
|
|
192
190
|
|
|
193
191
|
return zone.exo(
|
|
@@ -212,7 +210,9 @@ export const prepareStatusManager = (
|
|
|
212
210
|
M.undefined(),
|
|
213
211
|
),
|
|
214
212
|
),
|
|
215
|
-
disbursed: M.call(EvmHashShape).returns(
|
|
213
|
+
disbursed: M.call(EvmHashShape, AmountKeywordRecordShape).returns(
|
|
214
|
+
M.undefined(),
|
|
215
|
+
),
|
|
216
216
|
forwarded: M.call(M.opt(EvmHashShape), M.string(), M.nat()).returns(
|
|
217
217
|
M.undefined(),
|
|
218
218
|
),
|
|
@@ -313,9 +313,13 @@ export const prepareStatusManager = (
|
|
|
313
313
|
* Mark a transaction as `DISBURSED`
|
|
314
314
|
*
|
|
315
315
|
* @param {EvmHash} txHash
|
|
316
|
+
* @param {import('./liquidity-pool.js').RepayAmountKWR} split
|
|
316
317
|
*/
|
|
317
|
-
disbursed(txHash) {
|
|
318
|
-
|
|
318
|
+
disbursed(txHash, split) {
|
|
319
|
+
void publishTxnRecord(
|
|
320
|
+
txHash,
|
|
321
|
+
harden({ split, status: TxStatus.Disbursed }),
|
|
322
|
+
);
|
|
319
323
|
},
|
|
320
324
|
|
|
321
325
|
/**
|
|
@@ -327,7 +331,7 @@ export const prepareStatusManager = (
|
|
|
327
331
|
*/
|
|
328
332
|
forwarded(txHash, nfa, amount) {
|
|
329
333
|
if (txHash) {
|
|
330
|
-
|
|
334
|
+
void publishTxnRecord(txHash, harden({ status: TxStatus.Forwarded }));
|
|
331
335
|
} else {
|
|
332
336
|
// TODO store (early) `Minted` transactions to check against incoming evidence
|
|
333
337
|
log(
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { makeTracer } from '@agoric/internal';
|
|
2
2
|
import { prepareDurablePublishKit } from '@agoric/notifier';
|
|
3
|
-
import { M } from '@endo/patterns';
|
|
3
|
+
import { keyEQ, M } from '@endo/patterns';
|
|
4
|
+
import { Fail } from '@endo/errors';
|
|
4
5
|
import { CctpTxEvidenceShape } from '../type-guards.js';
|
|
5
6
|
import { defineInertInvitation } from '../utils/zoe.js';
|
|
6
7
|
import { prepareOperatorKit } from './operator-kit.js';
|
|
@@ -18,7 +19,7 @@ export const INVITATION_MAKERS_DESC = 'oracle operator invitation';
|
|
|
18
19
|
|
|
19
20
|
const TransactionFeedKitI = harden({
|
|
20
21
|
operatorPowers: M.interface('Transaction Feed Admin', {
|
|
21
|
-
|
|
22
|
+
attest: M.call(CctpTxEvidenceShape, M.string()).returns(),
|
|
22
23
|
}),
|
|
23
24
|
creator: M.interface('Transaction Feed Creator', {
|
|
24
25
|
// TODO narrow the return shape to OperatorKit
|
|
@@ -118,23 +119,16 @@ export const prepareTransactionFeedKit = (zone, zcf) => {
|
|
|
118
119
|
/**
|
|
119
120
|
* Add evidence from an operator.
|
|
120
121
|
*
|
|
122
|
+
* NB: the operatorKit is responsible for
|
|
123
|
+
*
|
|
121
124
|
* @param {CctpTxEvidence} evidence
|
|
122
|
-
* @param {
|
|
125
|
+
* @param {string} operatorId
|
|
123
126
|
*/
|
|
124
|
-
|
|
125
|
-
const { pending } = this.state;
|
|
126
|
-
trace(
|
|
127
|
-
'submitEvidence',
|
|
128
|
-
operatorKit.operator.getStatus().operatorId,
|
|
129
|
-
evidence,
|
|
130
|
-
);
|
|
131
|
-
const { operatorId } = operatorKit.operator.getStatus();
|
|
132
|
-
|
|
133
|
-
// TODO should this verify that the operator is one made by this exo?
|
|
134
|
-
// This doesn't work...
|
|
135
|
-
// operatorKit === operators.get(operatorId) ||
|
|
136
|
-
// Fail`operatorKit mismatch`;
|
|
127
|
+
attest(evidence, operatorId) {
|
|
128
|
+
const { operators, pending } = this.state;
|
|
129
|
+
trace('submitEvidence', operatorId, evidence);
|
|
137
130
|
|
|
131
|
+
// TODO https://github.com/Agoric/agoric-sdk/pull/10720
|
|
138
132
|
// TODO validate that it's a valid for Fast USDC before accepting
|
|
139
133
|
// E.g. that the `recipientAddress` is the FU settlement account and that
|
|
140
134
|
// the EUD is a chain supported by FU.
|
|
@@ -154,18 +148,46 @@ export const prepareTransactionFeedKit = (zone, zcf) => {
|
|
|
154
148
|
const found = [...pending.values()].filter(store =>
|
|
155
149
|
store.has(txHash),
|
|
156
150
|
);
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
151
|
+
const minAttestations = Math.ceil(operators.getSize() / 2);
|
|
152
|
+
trace(
|
|
153
|
+
'transaction',
|
|
154
|
+
txHash,
|
|
155
|
+
'has',
|
|
156
|
+
found.length,
|
|
157
|
+
'of',
|
|
158
|
+
minAttestations,
|
|
159
|
+
'necessary attestations',
|
|
160
|
+
);
|
|
161
|
+
if (found.length < minAttestations) {
|
|
160
162
|
return;
|
|
161
163
|
}
|
|
162
164
|
|
|
163
|
-
|
|
165
|
+
let lastEvidence;
|
|
166
|
+
for (const store of found) {
|
|
167
|
+
const next = store.get(txHash);
|
|
168
|
+
if (lastEvidence) {
|
|
169
|
+
if (keyEQ(lastEvidence, next)) {
|
|
170
|
+
lastEvidence = next;
|
|
171
|
+
} else {
|
|
172
|
+
trace(
|
|
173
|
+
'🚨 conflicting evidence for',
|
|
174
|
+
txHash,
|
|
175
|
+
':',
|
|
176
|
+
lastEvidence,
|
|
177
|
+
'!=',
|
|
178
|
+
next,
|
|
179
|
+
);
|
|
180
|
+
Fail`conflicting evidence for ${txHash}`;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
lastEvidence = next;
|
|
184
|
+
}
|
|
164
185
|
|
|
165
|
-
//
|
|
166
|
-
for (const
|
|
167
|
-
|
|
186
|
+
// sufficient agreement, so remove from pending and publish
|
|
187
|
+
for (const store of found) {
|
|
188
|
+
store.delete(txHash);
|
|
168
189
|
}
|
|
190
|
+
trace('publishing evidence', evidence);
|
|
169
191
|
publisher.publish(evidence);
|
|
170
192
|
},
|
|
171
193
|
},
|
package/src/types.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { Amount } from '@agoric/ertp';
|
|
|
9
9
|
import type { CopyRecord, Passable } from '@endo/pass-style';
|
|
10
10
|
import type { PendingTxStatus, TxStatus } from './constants.js';
|
|
11
11
|
import type { FastUsdcTerms } from './fast-usdc.contract.js';
|
|
12
|
+
import type { RepayAmountKWR } from './exos/liquidity-pool.js';
|
|
12
13
|
|
|
13
14
|
export type EvmHash = `0x${string}`;
|
|
14
15
|
export type EvmAddress = `0x${string & { length: 40 }}`;
|
|
@@ -40,6 +41,7 @@ export interface CctpTxEvidence {
|
|
|
40
41
|
*/
|
|
41
42
|
export interface TransactionRecord extends CopyRecord {
|
|
42
43
|
evidence?: CctpTxEvidence;
|
|
44
|
+
split?: RepayAmountKWR;
|
|
43
45
|
status: TxStatus;
|
|
44
46
|
}
|
|
45
47
|
|
|
@@ -156,3 +156,11 @@ export const configurations = {
|
|
|
156
156
|
},
|
|
157
157
|
};
|
|
158
158
|
harden(configurations);
|
|
159
|
+
|
|
160
|
+
// Constraints on the configurations
|
|
161
|
+
const MAINNET_EXPECTED_ORACLES = 3;
|
|
162
|
+
assert(
|
|
163
|
+
new Set(Object.values(configurations.MAINNET.oracles)).size ===
|
|
164
|
+
MAINNET_EXPECTED_ORACLES,
|
|
165
|
+
`Mainnet must have exactly ${MAINNET_EXPECTED_ORACLES} oracles`,
|
|
166
|
+
);
|