Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(network): Connection should include negotiated remoteAddress and localAddress #9186

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions packages/network/src/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -962,9 +962,21 @@ const prepareBinder = (zone, powers) => {
},
},
binderOutboundConnectWatcher: {
onFulfilled({ handler: rchandler }, watchContext) {
const { lastFailure, remoteAddr, localAddr, lchandler, port } =
watchContext;
onFulfilled(
{
handler: rchandler,
remoteAddress: negotiatedRemoteAddress,
localAddress: negotiatedLocalAddress,
},
watchContext,
) {
const {
lastFailure,
lchandler,
localAddr: requestedLocalAddress,
remoteAddr: requestedRemoteAddress,
port,
} = watchContext;

const { currentConnections } = this.state;

Expand All @@ -979,11 +991,11 @@ const prepareBinder = (zone, powers) => {
/** @type {import('@agoric/vow').Remote<Required<ConnectionHandler>>} */ (
lchandler
),
localAddr,
negotiatedLocalAddress || requestedLocalAddress,
/** @type {import('@agoric/vow').Remote<Required<ConnectionHandler>>} */ (
rchandler
),
remoteAddr,
negotiatedRemoteAddress || requestedRemoteAddress,
makeConnection,
current,
)[0];
Expand Down
2 changes: 1 addition & 1 deletion packages/vats/src/ibc.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ export const prepareIBCProtocol = (zone, powers) => {
// Finish the outbound connection.
const ibcHops = rHops.map(hop => `/ibc-hop/${hop}`).join('/');
const remoteAddress = `${ibcHops}/ibc-port/${rPortID}/${chanInfo.order.toLowerCase()}/${rVersion}/ibc-channel/${rChannelID}`;
const localAddress = `${localAddr}/ibc-channel/${channelID}`;
const localAddress = `${localAddr}/${chanInfo.order.toLowerCase()}/${rVersion}/ibc-channel/${channelID}`;
const rchandler = makeIBCConnectionHandler(
{
protocolUtils: util,
Expand Down
13 changes: 12 additions & 1 deletion packages/vats/test/test-network.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,22 @@ test('network - ibc', async t => {
portID: 'port-1',
channelID: 'channel-1',
counterparty: { port_id: 'port-98', channel_id: 'channel-22' },
counterpartyVersion: 'bar',
counterpartyVersion: 'bar-negotiated',
connectionHops: ['connection-11'],
});

const c = await when(cP);
const remoteAddress = c.getRemoteAddress();
const localAddress = c.getLocalAddress();
t.is(
remoteAddress,
'/ibc-hop/connection-11/ibc-port/port-98/unordered/bar-negotiated/ibc-channel/channel-22',
);
t.is(
localAddress,
'/ibc-port/port-1/unordered/bar-negotiated/ibc-channel/channel-1',
);

t.log('Sending Data - transfer');
const ack = E(c).send('some-transfer-message');

Expand Down
Loading