Skip to content

Commit 237359b

Browse files
authored
fix: remove intermediateRecipient from ForwardInfo (#11121)
incidental ## Description Updates `ChainHub.makeTransferRoute` to ensure it only includes PFM `forward` fields specified by the protocol. While debugging I noticed a regression from #10626 where `intermediateRecipient: ChainAddress` was in the memo payload. **There are no observable runtime errors without this change** - pfm transfers still work with extraneous fields - but it still warrants fixing. ### Security Considerations None ### Scaling Considerations Stops sending extraneous data in ibc packets for pfm scenarios where `intermediateRecipient` is set. ### Documentation Considerations None ### Testing Considerations - adds tests scenarios for when `IBCMsgTransferOptions.forwardOpts.intermediateRecipient` is set in `.transfer()` - updates existing tests to prefer `.deepEqual` to `.like` so full packet contents are more apparent ### Upgrade Considerations Only changes library code. Not planned for a release, but would be included in the next FUSDC release as it relies on `@agoric/orchestration/src/exos/chain-hub.js`
2 parents 6fb05ae + 2aade6f commit 237359b

File tree

3 files changed

+38
-9
lines changed

3 files changed

+38
-9
lines changed

packages/orchestration/src/exos/chain-hub.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,14 +720,15 @@ export const makeChainHub = (zone, agoricNames, vowTools) => {
720720
connectionInfos.get(issuerToDestKey),
721721
);
722722

723+
const { intermediateRecipient, ...rest } = forwardOpts ?? {};
723724
/** @type {ForwardInfo} */
724725
const forwardInfo = harden({
725726
forward: {
726727
receiver: destination.value,
727728
port: issuerToDest.transferChannel.portId,
728729
channel: issuerToDest.transferChannel.channelId,
729730
...DefaultPfmTimeoutOpts,
730-
...forwardOpts,
731+
.../** @type {ForwardInfo} */ (rest), // timeout and retries
731732
},
732733
});
733734
return harden({
@@ -741,7 +742,7 @@ export const makeChainHub = (zone, agoricNames, vowTools) => {
741742
* purposely using invalid bech32
742743
* {@link https://github.com/cosmos/ibc-apps/blob/26f3ad8f58e4ffc7769c6766cb42b954181dc100/middleware/packet-forward-middleware/README.md#minimal-example---chain-forward-a-b-c}
743744
*/
744-
receiver: forwardOpts?.intermediateRecipient?.value || PFM_RECEIVER,
745+
receiver: intermediateRecipient?.value || PFM_RECEIVER,
745746
forwardInfo,
746747
});
747748
},

packages/orchestration/test/exos/chain-hub-transfer-routes.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,18 +220,29 @@ test('takes forwardOpts', t => {
220220
chainId: 'noble-1',
221221
});
222222

223-
t.like(
223+
t.deepEqual(
224224
chainHub.makeTransferRoute(dest, amt, 'osmosis', {
225225
timeout: '99m',
226226
intermediateRecipient: nobleAddr,
227227
}),
228228
{
229229
receiver: nobleAddr.value,
230+
sourceChannel: 'channel-750',
231+
sourcePort: 'transfer',
230232
forwardInfo: {
231233
forward: {
234+
channel: 'channel-21',
232235
timeout: '99m' as const,
236+
port: 'transfer',
237+
receiver: 'agoric1234',
238+
retries: 3,
233239
},
234240
},
241+
token: {
242+
amount: '100',
243+
denom:
244+
'ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4',
245+
},
235246
},
236247
'each field is optional',
237248
);

packages/orchestration/test/exos/local-orchestration-account-kit.test.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ test(expectUnhandled(1), 'transfer', async t => {
244244
return promise;
245245
};
246246

247-
const lastestTxMsg = () => {
247+
const latestTxMsg = () => {
248248
const tx = inspectLocalBridge().at(-1);
249249
if (tx.type !== 'VLOCALCHAIN_EXECUTE_TX') {
250250
throw new Error('last message was not VLOCALCHAIN_EXECUTE_TX');
@@ -258,7 +258,7 @@ test(expectUnhandled(1), 'transfer', async t => {
258258
}),
259259
'can create transfer msg with memo',
260260
);
261-
t.like(lastestTxMsg(), {
261+
t.like(latestTxMsg(), {
262262
memo: 'hello',
263263
});
264264

@@ -304,28 +304,45 @@ test(expectUnhandled(1), 'transfer', async t => {
304304
),
305305
);
306306

307-
t.like(lastestTxMsg(), {
308-
receiver: PFM_RECEIVER,
309-
memo: '{"forward":{"receiver":"dydx1test","port":"transfer","channel":"channel-33","retries":3,"timeout":"10m"}}',
307+
t.is(latestTxMsg().receiver, PFM_RECEIVER, 'defaults to "pfm" receiver');
308+
t.deepEqual(JSON.parse(latestTxMsg().memo), {
309+
forward: {
310+
receiver: 'dydx1test',
311+
port: 'transfer',
312+
channel: 'channel-33',
313+
retries: 3,
314+
timeout: '10m',
315+
},
310316
});
311317

312318
t.log('accepts pfm `forwardOpts`');
319+
const intermediateRecipient: CosmosChainAddress = {
320+
chainId: 'noble-1',
321+
value: 'noble1testintermediaterecipient',
322+
encoding: 'bech32',
323+
};
313324
await t.notThrowsAsync(
314325
doTransfer(
315326
aDenomAmount,
316327
dydxDest,
317328
{
318329
forwardOpts: {
319330
timeout: '999m',
331+
intermediateRecipient,
320332
},
321333
},
322334
fetchedChainInfo.agoric.connections['noble-1'].transferChannel.channelId,
323335
),
324336
);
325337

326-
t.like(JSON.parse(lastestTxMsg().memo), {
338+
t.is(latestTxMsg().receiver, intermediateRecipient.value);
339+
t.deepEqual(JSON.parse(latestTxMsg().memo), {
327340
forward: {
328341
timeout: '999m',
342+
channel: 'channel-33',
343+
port: 'transfer',
344+
receiver: 'dydx1test',
345+
retries: 3,
329346
},
330347
});
331348
});

0 commit comments

Comments
 (0)