Skip to content

Commit

Permalink
fix(orchestration): chain-info (#9712)
Browse files Browse the repository at this point in the history
refs: #9063

## Description
Fixes bugs in unreleased code related to publishing `IBCConnectionInfo` to vstorage and parameterizing ICA channel creation.

### Testing Considerations
These were surfaced in  E2E testing. Includes an additional test to verify connection info between two well known chains, as current snapshots are a bit hard to decipher.

### Upgrade Considerations
Changes unreleased code.
  • Loading branch information
mergify[bot] committed Jul 15, 2024
2 parents 66bf702 + 746261e commit 31a57fc
Show file tree
Hide file tree
Showing 13 changed files with 392 additions and 328 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,11 @@ jobs:
with:
datadog-token: ${{ secrets.DATADOG_API_KEY }}

test-multichain-e2e:
needs: pre_check
if: needs.pre_check.outputs.should_run == 'true'
uses: ./.github/workflows/multichain-e2e.yml

finalize-integration-result:
needs:
- pre_check
Expand Down
24 changes: 16 additions & 8 deletions .github/workflows/multichain-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@ name: Multichain E2E Tests

on:
workflow_dispatch:
push:
branches:
# $default-branch
- master
- 'release-*'
- 'dev-*'
tags:
- '@agoric/sdk@*'
workflow_call:

jobs:
multichain-e2e:
Expand Down Expand Up @@ -75,3 +68,18 @@ jobs:
- name: Run @agoric/multichain-testing E2E Tests
run: yarn test
working-directory: ./agoric-sdk/multichain-testing

- name: Capture and print agoric validator logs
if: always()
run: kubectl logs agoriclocal-genesis-0 --container=validator || true
working-directory: ./agoric-sdk/multichain-testing

- name: Capture and print agoric-osmosis relayer logs
if: always()
run: kubectl logs hermes-agoric-osmosis-0 --container=relayer || true
working-directory: ./agoric-sdk/multichain-testing

- name: Capture and print agoric-cosmos relayer logs
if: always()
run: kubectl logs hermes-agoric-gaia-0 --container=relayer || true
working-directory: ./agoric-sdk/multichain-testing
22 changes: 20 additions & 2 deletions packages/boot/test/bootstrapTests/orchestration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,24 @@ test.serial('config', async t => {
node: 'agoricNames.chainConnection',
});
}
{
const connection = await EV(agoricNames).lookup(
'chainConnection',
'agoric-3_osmosis-1',
);
t.like(connection, {
id: 'connection-1',
client_id: '07-tendermint-1',
counterparty: {
client_id: '07-tendermint-2109',
connection_id: 'connection-1649',
},
transferChannel: {
counterPartyChannelId: 'channel-320',
channelId: 'channel-1',
},
});
}
});

test.skip('stakeOsmo - queries', async t => {
Expand Down Expand Up @@ -223,8 +241,8 @@ test.serial('revise chain info', async t => {
'cosmoshub-4_hot-1',
);
t.like(connection, {
id: 'connection-99',
client_id: '07-tendermint-3',
id: 'connection-1',
client_id: '07-tendermint-2',
});
});

Expand Down
204 changes: 102 additions & 102 deletions packages/boot/test/bootstrapTests/snapshots/orchestration.test.ts.md

Large diffs are not rendered by default.

Binary file not shown.
39 changes: 36 additions & 3 deletions packages/orchestration/src/chain-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { connectionKey } from './exos/chain-hub.js';
import fetchedChainInfo from './fetched-chain-info.js'; // Refresh with scripts/refresh-chain-info.ts
import { CosmosChainInfoShape } from './typeGuards.js';

/** @import {CosmosChainInfo, EthChainInfo} from './types.js'; */
/** @import {CosmosChainInfo, EthChainInfo, IBCConnectionInfo} from './types.js'; */

/** @typedef {CosmosChainInfo | EthChainInfo} ChainInfo */

Expand Down Expand Up @@ -65,6 +65,35 @@ const knownChains = /** @satisfies {Record<string, ChainInfo>} */ (

/** @typedef {typeof knownChains} KnownChains */

/**
* Utility to reverse connection info perspective.
*
* @param {IBCConnectionInfo} connInfo
* @returns {IBCConnectionInfo}
*/
const reverseConnInfo = connInfo => {
const { transferChannel } = connInfo;
return {
id: connInfo.counterparty.connection_id,
client_id: connInfo.counterparty.client_id,
counterparty: {
client_id: connInfo.client_id,
connection_id: connInfo.id,
prefix: {
key_prefix: '',
},
},
state: connInfo.state,
transferChannel: {
...transferChannel,
channelId: transferChannel.counterPartyChannelId,
counterPartyChannelId: transferChannel.channelId,
portId: transferChannel.counterPartyPortId,
counterPartyPortId: transferChannel.portId,
},
};
};

/**
* @param {ERef<import('@agoric/vats').NameHubKit['nameAdmin']>} agoricNamesAdmin
* @param {string} name
Expand All @@ -90,12 +119,16 @@ export const registerChain = async (
.then(() => log(`registered agoricNames chain.${name}`)),
];

const { chainId } = chainInfo;
// FIXME updates redundantly, twice per edge
for (const [counterChainId, connInfo] of Object.entries(connections)) {
const key = connectionKey(chainInfo.chainId, counterChainId);
const key = connectionKey(chainId, counterChainId);
const normalizedConnInfo =
chainId < counterChainId ? connInfo : reverseConnInfo(connInfo);

promises.push(
E(connAdmin)
.update(key, connInfo)
.update(key, normalizedConnInfo)
.then(() => log(`registering agoricNames chainConnection.${key}`)),
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/orchestration/src/exos/remote-chain-facade.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ const prepareRemoteChainFacadeKit = (
return watch(
E(orchestration).makeAccount(
remoteChainInfo.chainId,
connectionInfo.id,
connectionInfo.counterparty.connection_id,
connectionInfo.id,
),
this.facets.makeAccountWatcher,
);
Expand Down
Loading

0 comments on commit 31a57fc

Please sign in to comment.