diff --git a/packages/fast-usdc/src/exos/advancer.js b/packages/fast-usdc/src/exos/advancer.js index 0878598ad1a..9ba161b0d62 100644 --- a/packages/fast-usdc/src/exos/advancer.js +++ b/packages/fast-usdc/src/exos/advancer.js @@ -211,6 +211,8 @@ export const prepareAdvancerKit = ( poolAccount, harden({ USDC: advanceAmount }), ); + // WARNING: this must never reject, see handler @throws {never} below + // void not enforced by linter until #10627 no-floating-vows void watch(depositV, this.facets.depositHandler, { advanceAmount, destination, @@ -233,6 +235,7 @@ export const prepareAdvancerKit = ( /** * @param {undefined} result * @param {AdvancerVowCtx & { tmpSeat: ZCFSeat }} ctx + * @throws {never} WARNING: this function must not throw, because user funds are at risk */ onFulfilled(result, ctx) { const { poolAccount, intermediateRecipient, settlementAddress } = @@ -265,6 +268,7 @@ export const prepareAdvancerKit = ( * * @param {Error} error * @param {AdvancerVowCtx & { tmpSeat: ZCFSeat }} ctx + * @throws {never} WARNING: this function must not throw, because user funds are at risk */ onRejected(error, { tmpSeat, advanceAmount, ...restCtx }) { log( @@ -285,17 +289,12 @@ export const prepareAdvancerKit = ( /** * @param {undefined} result * @param {AdvancerVowCtx} ctx + * @throws {never} WARNING: this function must not throw, because user funds are at risk */ onFulfilled(result, ctx) { const { notifier } = this.state; const { advanceAmount, destination, ...detail } = ctx; log('Advance succeeded', { advanceAmount, destination }); - // During development, due to a bug, this call threw. - // The failure was silent (no diagnostics) due to: - // - #10576 Vows do not report unhandled rejections - // For now, the advancer kit relies on consistency between - // notify, statusManager, and callers of handleTransactionEvent(). - // TODO: revisit #10576 during #10510 notifier.notifyAdvancingResult({ destination, ...detail }, true); }, /** @@ -314,6 +313,8 @@ export const prepareAdvancerKit = ( tmpReturnSeat, harden({ USDC: advanceAmount }), ); + // WARNING: this must never reject, see handler @throws {never} below + // void not enforced by linter until #10627 no-floating-vows void watch(withdrawV, this.facets.withdrawHandler, { advanceAmount, tmpReturnSeat, @@ -325,6 +326,7 @@ export const prepareAdvancerKit = ( * * @param {undefined} result * @param {{ advanceAmount: Amount<'nat'>; tmpReturnSeat: ZCFSeat; }} ctx + * @throws {never} WARNING: this function must not throw, because user funds are at risk */ onFulfilled(result, { advanceAmount, tmpReturnSeat }) { const { borrower } = this.state; @@ -342,6 +344,7 @@ export const prepareAdvancerKit = ( /** * @param {Error} error * @param {{ advanceAmount: Amount<'nat'>; tmpReturnSeat: ZCFSeat; }} ctx + * @throws {never} WARNING: this function must not throw, because user funds are at risk */ onRejected(error, { advanceAmount, tmpReturnSeat }) { log( diff --git a/packages/fast-usdc/src/exos/status-manager.js b/packages/fast-usdc/src/exos/status-manager.js index f854337bc8c..2403f045c59 100644 --- a/packages/fast-usdc/src/exos/status-manager.js +++ b/packages/fast-usdc/src/exos/status-manager.js @@ -117,9 +117,8 @@ export const prepareStatusManager = ( /** * @param {EvmHash} txId * @param {TransactionRecord} record - * @returns {Promise} */ - const publishTxnRecord = async (txId, record) => { + const publishTxnRecord = (txId, record) => { const txNode = E(txnsNode).makeChildNode(txId, { sequence: true, // avoid overwriting other output in the block }); @@ -133,9 +132,10 @@ export const prepareStatusManager = ( storedCompletedTxs.add(txId); } - const capData = await E(marshaller).toCapData(record); - - await E(txNode).setValue(JSON.stringify(capData)); + // Don't await, just writing to vstorage. + void E.when(E(marshaller).toCapData(record), capData => + E(txNode).setValue(JSON.stringify(capData)), + ); }; /** @@ -144,10 +144,7 @@ export const prepareStatusManager = ( */ const publishEvidence = (hash, evidence) => { // Don't await, just writing to vstorage. - void publishTxnRecord( - hash, - harden({ evidence, status: TxStatus.Observed }), - ); + publishTxnRecord(hash, harden({ evidence, status: TxStatus.Observed })); }; /** @@ -174,10 +171,10 @@ export const prepareStatusManager = ( ); publishEvidence(txHash, evidence); if (status === PendingTxStatus.AdvanceSkipped) { - void publishTxnRecord(txHash, harden({ status, risksIdentified })); + publishTxnRecord(txHash, harden({ status, risksIdentified })); } else if (status !== PendingTxStatus.Observed) { // publishEvidence publishes Observed - void publishTxnRecord(txHash, harden({ status })); + publishTxnRecord(txHash, harden({ status })); } }; @@ -200,7 +197,7 @@ export const prepareStatusManager = ( ]; const txpost = { ...tx, status }; pendingSettleTxs.set(key, harden([...prefix, txpost, ...suffix])); - void publishTxnRecord(tx.txHash, harden({ status })); + publishTxnRecord(tx.txHash, harden({ status })); } return zone.exo( @@ -288,7 +285,7 @@ export const prepareStatusManager = ( * @param {boolean} success whether the Transfer succeeded */ advanceOutcomeForMintedEarly(txHash, success) { - void publishTxnRecord( + publishTxnRecord( txHash, harden({ status: success @@ -381,10 +378,7 @@ export const prepareStatusManager = ( * @param {import('./liquidity-pool.js').RepayAmountKWR} split */ disbursed(txHash, split) { - void publishTxnRecord( - txHash, - harden({ split, status: TxStatus.Disbursed }), - ); + publishTxnRecord(txHash, harden({ split, status: TxStatus.Disbursed })); }, /** @@ -394,7 +388,7 @@ export const prepareStatusManager = ( * @param {boolean} success */ forwarded(txHash, success) { - void publishTxnRecord( + publishTxnRecord( txHash, harden({ status: success ? TxStatus.Forwarded : TxStatus.ForwardFailed, diff --git a/packages/fast-usdc/src/exos/transaction-feed.js b/packages/fast-usdc/src/exos/transaction-feed.js index 98e668357bf..2c9f9643cfb 100644 --- a/packages/fast-usdc/src/exos/transaction-feed.js +++ b/packages/fast-usdc/src/exos/transaction-feed.js @@ -1,7 +1,8 @@ +/** @file Exo for @see {prepareTransactionFeedKit} */ import { makeTracer } from '@agoric/internal'; import { prepareDurablePublishKit } from '@agoric/notifier'; -import { keyEQ, M } from '@endo/patterns'; import { Fail, quote } from '@endo/errors'; +import { keyEQ, M } from '@endo/patterns'; import { CctpTxEvidenceShape, RiskAssessmentShape } from '../type-guards.js'; import { defineInertInvitation } from '../utils/zoe.js'; import { prepareOperatorKit } from './operator-kit.js'; @@ -64,8 +65,14 @@ export const stateShape = { pending: M.remotable(), risks: M.remotable(), }; +harden(stateShape); /** + * A TransactionFeed is responsible for finding quorum among oracles. + * + * It receives attestations, records their evidence, and when enough oracles + * agree, publishes the results for the advancer to act on. + * * @param {Zone} zone * @param {ZCF} zcf */ @@ -148,18 +155,20 @@ export const prepareTransactionFeedKit = (zone, zcf) => { /** @param {string} operatorId */ removeOperator(operatorId) { - const { operators } = this.state; + const { operators, pending, risks } = this.state; trace('removeOperator', operatorId); const operatorKit = operators.get(operatorId); operatorKit.admin.disable(); operators.delete(operatorId); + pending.delete(operatorId); + risks.delete(operatorId); }, }, operatorPowers: { /** * Add evidence from an operator. * - * NB: the operatorKit is responsible for + * NB: the operatorKit is responsible for revoking access. * * @param {CctpTxEvidence} evidence * @param {RiskAssessment} riskAssessment @@ -169,10 +178,6 @@ export const prepareTransactionFeedKit = (zone, zcf) => { const { operators, pending, risks } = this.state; trace('attest', operatorId, evidence); - // TODO https://github.com/Agoric/agoric-sdk/pull/10720 - // TODO validate that it's a valid for Fast USDC before accepting - // E.g. that the `recipientAddress` is the FU settlement account and that - // the EUD is a chain supported by FU. const { txHash } = evidence; // accept the evidence @@ -192,6 +197,29 @@ export const prepareTransactionFeedKit = (zone, zcf) => { const found = [...pending.values()].filter(store => store.has(txHash), ); + + { + let lastEvidence; + for (const store of found) { + const next = store.get(txHash); + if (lastEvidence && !keyEQ(lastEvidence, next)) { + // Ignore conflicting evidence, but treat it as an error + // because it should never happen and needs to be prevented + // from happening again. + trace( + '🚨 conflicting evidence for', + txHash, + ':', + lastEvidence, + '!=', + next, + ); + Fail`conflicting evidence for ${quote(txHash)}`; + } + lastEvidence = next; + } + } + const minAttestations = Math.ceil(operators.getSize() / 2); trace( 'transaction', @@ -202,48 +230,37 @@ export const prepareTransactionFeedKit = (zone, zcf) => { minAttestations, 'necessary attestations', ); + if (found.length < minAttestations) { + // wait for more return; } - let lastEvidence; - for (const store of found) { - const next = store.get(txHash); - if (lastEvidence && !keyEQ(lastEvidence, next)) { - // Ignore conflicting evidence, but treat it as an error - // because it should never happen and needs to be prevented - // from happening again. - trace( - '🚨 conflicting evidence for', - txHash, - ':', - lastEvidence, - '!=', - next, - ); - Fail`conflicting evidence for ${quote(txHash)}`; - } - lastEvidence = next; - } - const riskStores = [...risks.values()].filter(store => store.has(txHash), ); - // take the union of risks identified from all operators - const risksIdentified = allRisksIdentified(riskStores, txHash); - // sufficient agreement, so remove from pending risks, then publish - for (const store of found) { - store.delete(txHash); + // Publish at the threshold of agreement + if (found.length === minAttestations) { + // take the union of risks identified from all operators + const risksIdentified = allRisksIdentified(riskStores, txHash); + trace('publishing evidence', evidence, risksIdentified); + publisher.publish({ + evidence, + risk: { risksIdentified }, + }); + return; } - for (const store of riskStores) { - store.delete(txHash); + + if (found.length === pending.getSize()) { + // all have reported so clean up + for (const store of found) { + store.delete(txHash); + } + for (const store of riskStores) { + store.delete(txHash); + } } - trace('publishing evidence', evidence, risksIdentified); - publisher.publish({ - evidence, - risk: { risksIdentified }, - }); }, }, public: { diff --git a/packages/fast-usdc/src/fast-usdc.contract.js b/packages/fast-usdc/src/fast-usdc.contract.js index 8f114f99f3f..5703719591f 100644 --- a/packages/fast-usdc/src/fast-usdc.contract.js +++ b/packages/fast-usdc/src/fast-usdc.contract.js @@ -67,10 +67,11 @@ harden(meta); * @param {ERef} marshaller * @param {FeeConfig} feeConfig */ -const publishFeeConfig = async (node, marshaller, feeConfig) => { +const publishFeeConfig = (node, marshaller, feeConfig) => { const feeNode = E(node).makeChildNode(FEE_NODE); - const value = await E(marshaller).toCapData(feeConfig); - return E(feeNode).setValue(JSON.stringify(value)); + void E.when(E(marshaller).toCapData(feeConfig), value => + E(feeNode).setValue(JSON.stringify(value)), + ); }; /** @@ -247,7 +248,7 @@ export const contract = async (zcf, privateArgs, zone, tools) => { // So we use zone.exoClassKit above to define the liquidity pool kind // and pass the shareMint into the maker / init function. - void publishFeeConfig(storageNode, marshaller, feeConfig); + publishFeeConfig(storageNode, marshaller, feeConfig); const shareMint = await provideSingleton( zone.mapStore('mint'), diff --git a/packages/fast-usdc/test/exos/transaction-feed.test.ts b/packages/fast-usdc/test/exos/transaction-feed.test.ts index 77c32a76e49..ccfeb7e2e50 100644 --- a/packages/fast-usdc/test/exos/transaction-feed.test.ts +++ b/packages/fast-usdc/test/exos/transaction-feed.test.ts @@ -3,6 +3,7 @@ import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js'; import { deeplyFulfilledObject } from '@agoric/internal'; import { makeHeapZone } from '@agoric/zone'; +import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js'; import { prepareTransactionFeedKit, stateShape, @@ -160,9 +161,14 @@ test('disagreement', async t => { assert(e1.txHash === e1bad.txHash); op1.operator.submitEvidence(e1); + // conflicting between operators t.throws(() => op2.operator.submitEvidence(e1bad), { - message: - 'conflicting evidence for "0xc81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff387552761702"', + message: /conflicting evidence/, + }); + + // self conflicting + t.throws(() => op1.operator.submitEvidence(e1bad), { + message: /conflicting evidence/, }); }); @@ -180,31 +186,48 @@ test('disagreement after publishing', async t => { updateCount: 1n, }); - // it's simply ignored - t.notThrows(() => op3.operator.submitEvidence(e1bad)); + t.throws(() => op3.operator.submitEvidence(e1bad), { + message: /conflicting evidence/, + }); t.like(await evidenceSubscriber.getUpdateSince(0), { updateCount: 1n, }); - // now another op repeats the bad evidence, so it's published to the stream. - // It's the responsibility of the Advancer to fail because it has already processed that tx hash. - op1.operator.submitEvidence(e1bad); + // Disagreement is still detected after publishing + t.throws(() => op1.operator.submitEvidence(e1bad), { + message: /conflicting evidence/, + }); t.like(await evidenceSubscriber.getUpdateSince(0), { - updateCount: 2n, + updateCount: 1n, }); }); test('remove operator', async t => { const feedKit = makeFeedKit(); - const { op1 } = await makeOperators(feedKit); + const evidenceSubscriber = feedKit.public.getEvidenceSubscriber(); + const { op1, op2 } = await makeOperators(feedKit); const evidence = MockCctpTxEvidences.AGORIC_PLUS_OSMO(); + let published; + void evidenceSubscriber + .getUpdateSince(0) + .then(accepted => (published = accepted.value.evidence)); + // works before disabling op1.operator.submitEvidence(evidence); + await eventLoopIteration(); + t.falsy(published); - await feedKit.creator.removeOperator('op1'); - + // remove op1 and their in-flight evidence + feedKit.creator.removeOperator('op1'); t.throws(() => op1.operator.submitEvidence(evidence), { message: 'submitEvidence for disabled operator', }); + + // one attestation is now sufficient (half of two) but the only evidence was just removed + await eventLoopIteration(); + t.falsy(published); + op2.operator.submitEvidence(evidence); + await eventLoopIteration(); + t.deepEqual(published, evidence); }); diff --git a/packages/fast-usdc/test/snapshots/fast-usdc.contract.test.ts.md b/packages/fast-usdc/test/snapshots/fast-usdc.contract.test.ts.md index 3d4a77bb395..06fdfc8ca41 100644 --- a/packages/fast-usdc/test/snapshots/fast-usdc.contract.test.ts.md +++ b/packages/fast-usdc/test/snapshots/fast-usdc.contract.test.ts.md @@ -3103,15 +3103,14 @@ Generated by [AVA](https://avajs.dev). }, }, pending: { - 'operator-0': {}, - 'operator-1': { - '0x000008': { + 'operator-0': { + '0x0000010': { aux: { forwardingChannel: 'channel-21', - recipientAddress: 'agoric10rchqqgqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq06924zr6mmnd4hnzvr5wscqq9qe499xw', + recipientAddress: 'agoric10rchqqgqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq06924zr6mmnd4hnzetpwfkrxqq5g04wk9', }, blockHash: '0x90d7343e04f8160892e94f02d6a9b9f255663ed0ac34caca98544c8143fee665', - blockNumber: 21037671n, + blockNumber: 21037673n, blockTimestamp: 1632340000n, chainId: 1, tx: { @@ -3119,142 +3118,37 @@ Generated by [AVA](https://avajs.dev). forwardingAddress: 'noble1x0ydg69dh6fqvr27xjvp6maqmrldam6yfelqkd', sender: '0xDefaultFakeEthereumAddress', }, - txHash: '0x000008', + txHash: '0x0000010', }, }, - 'operator-2': { - '0x000001': { - aux: { - forwardingChannel: 'channel-21', - recipientAddress: 'agoric10rchqqgqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq06924zr6mmnd4hnzv3nqq2qhf2ep2', - }, - blockHash: '0x90d7343e04f8160892e94f02d6a9b9f255663ed0ac34caca98544c8143fee665', - blockNumber: 21037664n, - blockTimestamp: 1632340000n, - chainId: 1, - tx: { - amount: 1000000n, - forwardingAddress: 'noble1x0ydg69dh6fqvr27xjvp6maqmrldam6yfelqkd', - sender: '0xDefaultFakeEthereumAddress', - }, - txHash: '0x000001', - }, - '0x000002': { - aux: { - forwardingChannel: 'channel-21', - recipientAddress: 'agoric10rchqqgqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq06924zr6mmnd4hnzv3nx3skganpde3k2jrpwpc8jqq5jzq8ex', - }, - blockHash: '0x90d7343e04f8160892e94f02d6a9b9f255663ed0ac34caca98544c8143fee665', - blockNumber: 21037665n, - blockTimestamp: 1632340000n, - chainId: 1, - tx: { - amount: 108000000n, - forwardingAddress: 'noble1x0ydg69dh6fqvr27xjvp6maqmrldam6yfelqkd', - sender: '0xDefaultFakeEthereumAddress', - }, - txHash: '0x000002', - }, - '0x000003': { - aux: { - forwardingChannel: 'channel-21', - recipientAddress: 'agoric10rchqqgqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq06924zr6mmnd4hnzv3nx3ssq9qfqjyle', - }, - blockHash: '0x90d7343e04f8160892e94f02d6a9b9f255663ed0ac34caca98544c8143fee665', - blockNumber: 21037666n, - blockTimestamp: 1632340000n, - chainId: 1, - tx: { - amount: 110000000n, - forwardingAddress: 'noble1x0ydg69dh6fqvr27xjvp6maqmrldam6yfelqkd', - sender: '0xDefaultFakeEthereumAddress', - }, - txHash: '0x000003', - }, - '0x000004': { - aux: { - forwardingChannel: 'channel-21', - recipientAddress: 'agoric10rchqqgqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq06924zr6mmnd4hnzv3nx33qq9q874uwh', - }, - blockHash: '0x90d7343e04f8160892e94f02d6a9b9f255663ed0ac34caca98544c8143fee665', - blockNumber: 21037667n, - blockTimestamp: 1632340000n, - chainId: 1, - tx: { - amount: 120000000n, - forwardingAddress: 'noble1x0ydg69dh6fqvr27xjvp6maqmrldam6yfelqkd', - sender: '0xDefaultFakeEthereumAddress', - }, - txHash: '0x000004', - }, - '0x000005': { - aux: { - forwardingChannel: 'channel-21', - recipientAddress: 'agoric10rchqqgqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq06924zr6mmnd4hnzv3nx33sq9qdp5z6c', - }, - blockHash: '0x90d7343e04f8160892e94f02d6a9b9f255663ed0ac34caca98544c8143fee665', - blockNumber: 21037668n, - blockTimestamp: 1632340000n, - chainId: 1, - tx: { - amount: 125000000n, - forwardingAddress: 'noble1x0ydg69dh6fqvr27xjvp6maqmrldam6yfelqkd', - sender: '0xDefaultFakeEthereumAddress', - }, - txHash: '0x000005', - }, - '0x000006': { - aux: { - forwardingChannel: 'channel-21', - recipientAddress: 'agoric10rchqqgqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq06924zr6mmnd4hnzv3nvfhkydgqzs8gv9xu', - }, - blockHash: '0x90d7343e04f8160892e94f02d6a9b9f255663ed0ac34caca98544c8143fee665', - blockNumber: 21037669n, - blockTimestamp: 1632340000n, - chainId: 1, - tx: { - amount: 6000000n, - forwardingAddress: 'noble1x0ydg69dh6fqvr27xjvp6maqmrldam6yfelqkd', - sender: '0xDefaultFakeEthereumAddress', - }, - txHash: '0x000006', - }, - '0x000007': { + 'operator-1': { + '0x0000010': { aux: { forwardingChannel: 'channel-21', - recipientAddress: 'agoric10rchqqgqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq06924zr6mmnd4hnzv3nqq2qhf2ep2', + recipientAddress: 'agoric10rchqqgqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq06924zr6mmnd4hnzetpwfkrxqq5g04wk9', }, blockHash: '0x90d7343e04f8160892e94f02d6a9b9f255663ed0ac34caca98544c8143fee665', - blockNumber: 21037670n, + blockNumber: 21037673n, blockTimestamp: 1632340000n, chainId: 1, tx: { - amount: 150000000n, + amount: 5000000n, forwardingAddress: 'noble1x0ydg69dh6fqvr27xjvp6maqmrldam6yfelqkd', sender: '0xDefaultFakeEthereumAddress', }, - txHash: '0x000007', + txHash: '0x0000010', }, }, + 'operator-2': {}, }, risks: { - 'operator-0': {}, - 'operator-1': { - '0x000008': {}, + 'operator-0': { + '0x0000010': {}, }, - 'operator-2': { - '0x000001': { - risksIdentified: [ - 'RISK1', - ], - }, - '0x000002': {}, - '0x000003': {}, - '0x000004': {}, - '0x000005': {}, - '0x000006': {}, - '0x000007': {}, + 'operator-1': { + '0x0000010': {}, }, + 'operator-2': {}, }, settlerKit: { creator: Object @Alleged: Fast USDC Settler creator {}, diff --git a/packages/fast-usdc/test/snapshots/fast-usdc.contract.test.ts.snap b/packages/fast-usdc/test/snapshots/fast-usdc.contract.test.ts.snap index 3bcf939dafe..eb51e85e3f4 100644 Binary files a/packages/fast-usdc/test/snapshots/fast-usdc.contract.test.ts.snap and b/packages/fast-usdc/test/snapshots/fast-usdc.contract.test.ts.snap differ diff --git a/packages/orchestration/src/exos/packet-tools.js b/packages/orchestration/src/exos/packet-tools.js index 2b873ebc2eb..46f0ef7c0f9 100644 --- a/packages/orchestration/src/exos/packet-tools.js +++ b/packages/orchestration/src/exos/packet-tools.js @@ -3,6 +3,9 @@ import { Shape as NetworkShape } from '@agoric/network'; import { M, matches } from '@endo/patterns'; import { E } from '@endo/far'; import { pickFacet } from '@agoric/vat-data'; +import { makeTracer } from '@agoric/internal'; + +const trace = makeTracer('PacketTools'); const { toCapData } = makeMarshal(undefined, undefined, { marshalName: 'JustEncoder', @@ -207,7 +210,7 @@ export const preparePacketTools = (zone, vowTools) => { async receiveUpcall(obj) { const { monitor, resolverToPattern, upcallQueue, pending } = this.state; - console.debug( + trace( `Trying ${resolverToPattern.getSize()} current patterns and ${pending} pending patterns against`, just(obj), ); @@ -219,7 +222,7 @@ export const preparePacketTools = (zone, vowTools) => { // Check all our fulfilled patterns for matches. for (const [resolver, pattern] of resolverToPattern.entries()) { if (matches(obj, pattern)) { - console.debug('Matched pattern:', just(pattern)); + trace('Matched pattern:', just(pattern)); resolver.resolve(obj); resolverToPattern.delete(resolver); return; @@ -228,10 +231,10 @@ export const preparePacketTools = (zone, vowTools) => { if (upcallQueue) { // We have some pending patterns (ones that have been requested but // haven't yet settled) that may match this object. - console.debug('Stashing object in upcallQueue'); + trace('Stashing object in upcallQueue'); this.state.upcallQueue = harden(upcallQueue.concat(obj)); } - console.debug('No match yet.'); + trace('No match yet.'); }, }, sendPacketWatcher: { @@ -276,10 +279,10 @@ export const preparePacketTools = (zone, vowTools) => { onFulfilled(pattern, { resolver }) { const { resolverToPattern, upcallQueue } = this.state; - console.debug('watchPacketPattern onFulfilled', just(pattern)); + trace('watchPacketPattern onFulfilled', just(pattern)); if (!upcallQueue) { // Save the pattern for later. - console.debug('No upcall queue yet. Save the pattern for later.'); + trace('No upcall queue yet. Save the pattern for later.'); resolverToPattern.init(resolver, pattern); return; } @@ -288,13 +291,13 @@ export const preparePacketTools = (zone, vowTools) => { const i = upcallQueue.findIndex(obj => matches(obj, pattern)); if (i < 0) { // No match yet. Save the pattern for later. - console.debug('No match yet. Save the pattern for later.'); + trace('No match yet. Save the pattern for later.'); resolverToPattern.init(resolver, pattern); return; } // Success! Remove the matched object from the queue. - console.debug( + trace( 'Success! Remove the matched object from the queue.', just(upcallQueue[i]), ); diff --git a/packages/orchestration/src/utils/zoe-tools.js b/packages/orchestration/src/utils/zoe-tools.js index a5cbbe389f8..803982c8fe1 100644 --- a/packages/orchestration/src/utils/zoe-tools.js +++ b/packages/orchestration/src/utils/zoe-tools.js @@ -18,6 +18,9 @@ import { makeError, q, Fail } from '@endo/errors'; import { depositToSeat } from '@agoric/zoe/src/contractSupport/index.js'; import { E } from '@endo/far'; +import { makeTracer } from '@agoric/internal'; + +const trace = makeTracer('ZoeTools'); const { assign, keys, values } = Object; @@ -121,7 +124,7 @@ export const makeZoeTools = (zcf, { when, allVows, allSettled, asVow }) => { amounts, paymentKwr, ); - console.debug(depositResponse); + trace('localTransfer depositResponse', depositResponse); throw makeError(`One or more deposits failed ${q(errors)}`); } // TODO #9541 remove userSeat from baggage @@ -174,7 +177,7 @@ export const makeZoeTools = (zcf, { when, allVows, allSettled, asVow }) => { amounts, paymentKwr, ); - console.debug(depositResponse); + trace('withdrawToSeat depositResponse', depositResponse); }); return harden({