Skip to content

Commit

Permalink
WIP: lots of logging and debugging to track issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris-Hibbert committed Mar 4, 2025
1 parent 2d757f2 commit 9a7ff8a
Show file tree
Hide file tree
Showing 15 changed files with 91 additions and 51 deletions.
2 changes: 1 addition & 1 deletion a3p-integration/proposals/g:gtm-fast-usdc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dependencies": {
"@agoric/client-utils": "dev",
"@agoric/fast-usdc": "dev",
"@agoric/synthetic-chain": "0.5.1",
"@agoric/synthetic-chain": "0.5.3",
"@endo/init": "^1.1.8",
"agoric": "dev",
"ava": "^5.3.1"
Expand Down
37 changes: 19 additions & 18 deletions a3p-integration/proposals/g:gtm-fast-usdc/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -464,19 +464,20 @@ __metadata:
languageName: node
linkType: hard

"@agoric/synthetic-chain@npm:0.5.1":
version: 0.5.1
resolution: "@agoric/synthetic-chain@npm:0.5.1"
"@agoric/synthetic-chain@npm:0.5.3":
version: 0.5.3
resolution: "@agoric/synthetic-chain@npm:0.5.3"
dependencies:
"@endo/zip": "npm:^1.0.7"
better-sqlite3: "npm:^11.8.0"
"@endo/zip": "npm:^1.0.9"
better-sqlite3: "npm:^11.8.1"
chalk: "npm:^5.4.1"
cosmjs-types: "npm:^0.9.0"
execa: "npm:^9.5.2"
glob: "npm:^11.0.0"
glob: "npm:^11.0.1"
tmp: "npm:0.2.3"
bin:
synthetic-chain: dist/cli/cli.js
checksum: 10c0/38d796556a0940d124b750bcf82cbbbd9caee64031feeca4086350c4d05d68256e5b188d418354b511eeb1da0f95160205cc2701ae397bd86c304fc29850bc85
checksum: 10c0/47e984c05a64fd520c1c7063b3f0a63d231f0da431bd169e0dece1cba5535696c3c582d32afc7771d869ecb6aa9f2945991c47e1ae015ba321d43a465e37573b
languageName: node
linkType: hard

Expand Down Expand Up @@ -1264,7 +1265,7 @@ __metadata:
languageName: node
linkType: hard

"@endo/zip@npm:^1.0.7, @endo/zip@npm:^1.0.9":
"@endo/zip@npm:^1.0.9":
version: 1.0.9
resolution: "@endo/zip@npm:1.0.9"
checksum: 10c0/3fccea31bd5dad938a3b5f531454d3c49513892d6d5aba1f0af1034ff0ae54c3e28a346a9df08bd9e5201354acccd631e45c9c0e68fa2848a876a3919f3830dc
Expand Down Expand Up @@ -1993,7 +1994,7 @@ __metadata:
languageName: node
linkType: hard

"better-sqlite3@npm:^11.8.0":
"better-sqlite3@npm:^11.8.1":
version: 11.8.1
resolution: "better-sqlite3@npm:11.8.1"
dependencies:
Expand Down Expand Up @@ -3151,7 +3152,7 @@ __metadata:
languageName: node
linkType: hard

"glob@npm:^11.0.0":
"glob@npm:^11.0.1":
version: 11.0.1
resolution: "glob@npm:11.0.1"
dependencies:
Expand Down Expand Up @@ -4796,7 +4797,7 @@ __metadata:
dependencies:
"@agoric/client-utils": "npm:dev"
"@agoric/fast-usdc": "npm:dev"
"@agoric/synthetic-chain": "npm:0.5.1"
"@agoric/synthetic-chain": "npm:0.5.3"
"@endo/init": "npm:^1.1.8"
agoric: "npm:dev"
ava: "npm:^5.3.1"
Expand Down Expand Up @@ -5266,6 +5267,13 @@ __metadata:
languageName: node
linkType: hard

"tmp@npm:0.2.3, tmp@npm:^0.2.1":
version: 0.2.3
resolution: "tmp@npm:0.2.3"
checksum: 10c0/3e809d9c2f46817475b452725c2aaa5d11985cf18d32a7a970ff25b568438e2c076c2e8609224feef3b7923fa9749b74428e3e634f6b8e520c534eef2fd24125
languageName: node
linkType: hard

"tmp@npm:^0.0.33":
version: 0.0.33
resolution: "tmp@npm:0.0.33"
Expand All @@ -5275,13 +5283,6 @@ __metadata:
languageName: node
linkType: hard

"tmp@npm:^0.2.1":
version: 0.2.3
resolution: "tmp@npm:0.2.3"
checksum: 10c0/3e809d9c2f46817475b452725c2aaa5d11985cf18d32a7a970ff25b568438e2c076c2e8609224feef3b7923fa9749b74428e3e634f6b8e520c534eef2fd24125
languageName: node
linkType: hard

"to-regex-range@npm:^5.0.1":
version: 5.0.1
resolution: "to-regex-range@npm:5.0.1"
Expand Down
3 changes: 3 additions & 0 deletions packages/orchestration/src/examples/send-anywhere.flows.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const sendIt = async (
assets.find(a => a.brand === amt.brand),
`${amt.brand} not registered in vbank`,
);
debugger;

const chain = await orch.getChain(chainName);
const info = await chain.getChainInfo();
Expand All @@ -59,6 +60,7 @@ export const sendIt = async (
await localTransfer(seat, sharedLocalAccount, give);

void log(`completed transfer to localAccount`);
console.log(`completed transfer to localAccount`);

try {
await sharedLocalAccount.transfer(
Expand All @@ -69,6 +71,7 @@ export const sendIt = async (
},
{ denom, value: amt.value },
);
console.log(`completed transfer to ${destAddr}`);
void log(`completed transfer to ${destAddr}`);
} catch (e) {
await withdrawToSeat(sharedLocalAccount, seat, give);
Expand Down
41 changes: 23 additions & 18 deletions packages/orchestration/src/examples/send-cctp.flows.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { M, mustMatch } from '@endo/patterns';
* @import {Vow} from '@agoric/vow';
* @import {LocalOrchestrationAccountKit} from '../exos/local-orchestration-account.js';
* @import {ZoeTools} from '../utils/zoe-tools.js';
* @import {Orchestrator, OrchestrationFlow, LocalAccountMethods, OrchestrationAccountCommon, OrchestrationAccount, IBCConnectionInfo, ChainAddress, ForwardInfo, Chain} from '../types.js';
* @import {Orchestrator, OrchestrationFlow, LocalAccountMethods, OrchestrationAccountCommon, OrchestrationAccount, IBCConnectionInfo, AccountIdArg, ForwardInfo, Chain} from '../types.js';
* @import {IBCChannelID} from '@agoric/vats';
*/

Expand All @@ -25,7 +25,6 @@ harden(makeNobleAccount);

// TODO use case should be handled by `sendIt` based on the destination
/**
* @deprecated `sendIt` should handle this
* @satisfies {OrchestrationFlow}
* @param {Orchestrator} orch
* @param {object} ctx
Expand Down Expand Up @@ -79,9 +78,14 @@ export const sendByCCTP = async (
const sharedLocalAccount = await sharedLocalAccountP;
await localTransfer(seat, sharedLocalAccount, give);

debugger;

if (typeof info.cctpDestinationDomain !== 'number') {
// within the inter-chain; no CCTP needed
console.log('CCTP via IBC');
try {
debugger;

await sharedLocalAccount.transfer(
{
value: destAddr,
Expand All @@ -91,31 +95,32 @@ export const sendByCCTP = async (
{ denom, value: amt.value },
);
void log(`completed transfer to ${destAddr}`);
console.log(`completed transfer to ${destAddr}`);
} catch (e) {
await withdrawToSeat(sharedLocalAccount, seat, give);
const errorMsg = `IBC Transfer failed ${q(e)}`;
void log(`ERROR: ${errorMsg}`);
seat.exit(errorMsg);
throw makeError(errorMsg);
}
}

console.log(`CCTP case: assume USDC`, amt.brand);
} else {
console.log(`CCTP case: assume USDC`, amt.brand);

const nobleAccount = await nobleAccountP;
const nobleAddr = await nobleAccount.getAddress();
const denomAmt = { denom, value: amt.value };
await sharedLocalAccount.transfer(nobleAddr, denomAmt);
console.log('assets are now on noble');

const encoding = 'ethereum'; // XXX TODO. could be solana?
/** @type {ChainAddress} */
const mintRecipient = { chainId, encoding, value: destAddr };
await nobleAccount.depositForBurn(mintRecipient, denomAmt);
console.log(
`transfer complete, we hope; could have FAILed between noble and dest, though`,
);
debugger;
const nobleAccount = await nobleAccountP;
const nobleAddr = await nobleAccount.getAddress();
const denomAmt = { denom, value: amt.value };
await sharedLocalAccount.transfer(nobleAddr, denomAmt);
console.log('assets are now on noble');

const encoding = 'ethereum'; // XXX TODO. could be solana?
/** @type {AccountIdArg} */
const mintRecipient = { chainId, encoding, value: destAddr };
await nobleAccount.depositForBurn(mintRecipient, denomAmt);
console.log(
`transfer complete, we hope; could have FAILed between noble and dest, though`,
);
}
seat.exit();
};
harden(sendByCCTP);
5 changes: 2 additions & 3 deletions packages/orchestration/src/exos/chain-hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { BrandShape } from '@agoric/ertp/src/typeGuards.js';
import { VowShape } from '@agoric/vow';
import {
CosmosChainAddressShape,
ChainInfoShape,
CoinShape,
CosmosChainInfoShape,
DenomAmountShape,
Expand Down Expand Up @@ -239,10 +238,10 @@ const ChainHubI = M.interface('ChainHub', {
/**
* Make a new ChainHub in the zone.
*
* The resulting object is an Exo singleton. It has no precious state. It's only
* The resulting object is an Exo singleton. It has no precious state. Its only
* state is a cache of queries to agoricNames and whatever info was provided in
* registration calls. When you need a newer version you can simply make a hub
* hub and repeat the registrations.
* and repeat the registrations.
*
* @param {Zone} zone
* @param {Remote<NameHub>} agoricNames
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,7 @@ export const prepareCosmosOrchestrationAccountKit = (
}),
),
]);
debugger;
return watch(results, this.facets.delegationQueryWatcher);
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export const prepareLocalOrchestrationAccountKit = (
route: TransferRouteShape,
})
.returns(Vow$(M.record())),
onRejected: M.call(M.error(), M.any()).returns(M.undefined()),
}),
extractFirstResultWatcher: M.interface('extractFirstResultWatcher', {
onFulfilled: M.call([M.record()])
Expand Down Expand Up @@ -356,6 +357,8 @@ export const prepareLocalOrchestrationAccountKit = (
* }} ctx
*/
onFulfilled(timeoutTimestamp, { opts, route }) {
console.log('LOA tw', opts, route);
debugger;
const { forwardInfo, ...transferDetails } = route;
/** @type {string | undefined} */
let memo;
Expand Down Expand Up @@ -390,6 +393,9 @@ export const prepareLocalOrchestrationAccountKit = (
// verified.
return holder.sendThenWaitForAck(sender);
},
onRejected(reason, ...rest) {
console.log('LOA transferWatcher fail', { reason, rest });
},
},
/**
* takes an array of results (from `executeEncodedTx`) and returns the
Expand Down Expand Up @@ -685,6 +691,7 @@ export const prepareLocalOrchestrationAccountKit = (
transfer(destination, amount, opts) {
return asVow(() => {
trace('Transferring funds over IBC');
debugger;

const denomAmount = coerceDenomAmount(chainHub, amount);

Expand Down
2 changes: 2 additions & 0 deletions packages/orchestration/src/exos/packet-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export const preparePacketTools = (zone, vowTools) => {
console.debug('Stashing object in upcallQueue');
this.state.upcallQueue = harden(upcallQueue.concat(obj));
}
debugger;
console.debug('No match yet.');
},
},
Expand Down Expand Up @@ -289,6 +290,7 @@ export const preparePacketTools = (zone, vowTools) => {
if (i < 0) {
// No match yet. Save the pattern for later.
console.debug('No match yet. Save the pattern for later.');
console.log('No match', { pattern });
resolverToPattern.init(resolver, pattern);
return;
}
Expand Down
11 changes: 10 additions & 1 deletion packages/orchestration/test/examples/send-anywhere.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ test('single amount proposal shape (keyword record)', async t => {
}
});

test('send using arbitrary chain info', async t => {
test.only('send using arbitrary chain info', async t => {
t.log('bootstrap, orchestration core-eval');
const {
bootstrap,
Expand Down Expand Up @@ -119,23 +119,29 @@ test('send using arbitrary chain info', async t => {
agoricToHotConnection,
);

console.log('SAt G');
t.log('client uses contract to send to hot new chain');
{
const publicFacet = await E(zoe).getPublicFacet(sendKit.instance);
const inv = E(publicFacet).makeSendInvitation();
const amt = await E(zoe).getInvitationDetails(inv);
t.is(amt.description, 'send');

console.log('SAt H');
const anAmt = ist.units(3.5);
const Send = await pourPayment(anAmt);
console.log('SAt H3');
const userSeat = await E(zoe).offer(
inv,
{ give: { Send: anAmt } },
{ Send },
{ destAddr: 'hot1destAddr', chainName },
);
console.log('SAt H5');
await transmitTransferAck();
console.log('SAt H7');
await vt.when(E(userSeat).getOfferResult());
console.log('SAt I');

const history = inspectLocalBridge();
t.like(history, [
Expand All @@ -146,6 +152,8 @@ test('send using arbitrary chain info', async t => {
t.is(messages.length, 1);
const [txfr] = messages;
t.log('local bridge', txfr);

console.log('SAt J');
t.like(txfr, {
'@type': '/ibc.applications.transfer.v1.MsgTransfer',
receiver: 'hot1destAddr',
Expand All @@ -156,6 +164,7 @@ test('send using arbitrary chain info', async t => {
});
}

console.log('SAt K');
t.log('well-known chains such as cosmos work the same way');
{
const anAmt = ist.units(1.25);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ test('getBalance and getBalances', async t => {
}
});

test('StakingAccountQueries', async t => {
test.only('StakingAccountQueries', async t => {
const {
mocks: { ibcBridge },
} = t.context;
Expand Down Expand Up @@ -775,6 +775,7 @@ test('StakingAccountQueries', async t => {
};

// Test getDelegation
debugger;
const delegationResult = await E(account).getDelegation(mockValidator);
t.deepEqual(delegationResult, {
amount: { denom: 'uatom', value: 1000000n },
Expand Down
2 changes: 2 additions & 0 deletions packages/orchestration/test/network-fakes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ export const makeFakeIBCBridge = (
trace('Could not decode packet data', err);
}
}
debugger;
const ackEvent = ibcBridgeMocks.acknowledgementPacket(obj, {
sequence: ibcSequenceNonce,
acknowledgement: mockAckMapHasData
Expand All @@ -286,6 +287,7 @@ export const makeFakeIBCBridge = (
return undefined;
},
fromBridge: async obj => {
debugger;
trace('fromBridge', obj);
bridgeEvents = bridgeEvents.concat(obj);
if (!bridgeHandler) throw Error('no handler!');
Expand Down
Loading

0 comments on commit 9a7ff8a

Please sign in to comment.