From 9f28f36262e6d0f7187b76245c888218d3ae3081 Mon Sep 17 00:00:00 2001 From: samsiegart Date: Thu, 16 Jan 2025 10:53:06 -0800 Subject: [PATCH] fixup! feat(orchestration): add more chain infos for fusdc --- .../scripts/fetch-starship-chain-info.ts | 3 ++- .../test/bootstrapTests/orchestration.test.ts | 22 +++-------------- .../boot/test/fast-usdc/fast-usdc.test.ts | 24 ------------------- .../orchestration/contract-upgrade.test.ts | 12 ++-------- .../orchestration/restart-contracts.test.ts | 12 ++-------- packages/boot/test/tools/chainInfo.ts | 9 +++++++ .../orchestration/scripts/fetch-chain-info.ts | 9 +++---- packages/orchestration/src/exos/chain-hub.js | 10 ++++---- packages/orchestration/src/utils/registry.js | 6 ++--- 9 files changed, 31 insertions(+), 76 deletions(-) create mode 100644 packages/boot/test/tools/chainInfo.ts diff --git a/multichain-testing/scripts/fetch-starship-chain-info.ts b/multichain-testing/scripts/fetch-starship-chain-info.ts index a81721ca8fa..f0bcd2d9608 100755 --- a/multichain-testing/scripts/fetch-starship-chain-info.ts +++ b/multichain-testing/scripts/fetch-starship-chain-info.ts @@ -5,6 +5,7 @@ import fsp from 'node:fs/promises'; import prettier from 'prettier'; import { convertChainInfo } from '@agoric/orchestration/src/utils/registry.js'; +import { icaChainNames } from '@agoric/orchestration/scripts/fetch-chain-info.ts'; import type { IBCInfo, Chains } from '@chain-registry/types'; @@ -32,7 +33,7 @@ const chainInfo = await convertChainInfo( chains, ibcData: ibc.data, }, - () => true, + chainName => icaChainNames.has(chainName), ); const record = JSON.stringify(chainInfo, null, 2); diff --git a/packages/boot/test/bootstrapTests/orchestration.test.ts b/packages/boot/test/bootstrapTests/orchestration.test.ts index 3ea58c2f425..addfc5fd3e3 100644 --- a/packages/boot/test/bootstrapTests/orchestration.test.ts +++ b/packages/boot/test/bootstrapTests/orchestration.test.ts @@ -13,7 +13,6 @@ import type { start as startStakeIca } from '@agoric/orchestration/src/examples/ import type { Instance } from '@agoric/zoe/src/zoeService/utils.js'; import type { TestFn } from 'ava'; import { SIMULATED_ERRORS } from '@agoric/vats/tools/fake-bridge.js'; -import fetchedChainInfo from '@agoric/orchestration/src/fetched-chain-info.js'; import { buildVTransferEvent } from '@agoric/orchestration/tools/ibc-mocks.js'; import { BridgeId } from '@agoric/internal'; import { makeTestAddress } from '@agoric/orchestration/tools/make-test-address.js'; @@ -25,6 +24,7 @@ import { insistManagerType, makeSwingsetHarness, } from '../../tools/supports.js'; +import { minimalChainInfos } from '../tools/chainInfo.js'; const test: TestFn< WalletFactoryTestContext & { @@ -331,15 +331,7 @@ test.serial('basic-flows', async t => { '@agoric/builders/scripts/orchestration/init-basic-flows.js', [ '--chainInfo', - JSON.stringify( - withChainCapabilities({ - agoric: fetchedChainInfo.agoric, - osmosis: fetchedChainInfo.osmosis, - dydx: fetchedChainInfo.dydx, - noble: fetchedChainInfo.noble, - cosmoshub: fetchedChainInfo.cosmoshub, - }), - ), + JSON.stringify(withChainCapabilities(minimalChainInfos)), '--assetInfo', JSON.stringify([ [ @@ -564,15 +556,7 @@ test.serial('basic-flows - portfolio holder', async t => { '@agoric/builders/scripts/orchestration/init-basic-flows.js', [ '--chainInfo', - JSON.stringify( - withChainCapabilities({ - agoric: fetchedChainInfo.agoric, - osmosis: fetchedChainInfo.osmosis, - dydx: fetchedChainInfo.dydx, - noble: fetchedChainInfo.noble, - cosmoshub: fetchedChainInfo.cosmoshub, - }), - ), + JSON.stringify(withChainCapabilities(minimalChainInfos)), '--assetInfo', JSON.stringify([ [ diff --git a/packages/boot/test/fast-usdc/fast-usdc.test.ts b/packages/boot/test/fast-usdc/fast-usdc.test.ts index 03a5acbec27..57656b6c948 100644 --- a/packages/boot/test/fast-usdc/fast-usdc.test.ts +++ b/packages/boot/test/fast-usdc/fast-usdc.test.ts @@ -386,12 +386,6 @@ test.serial('distributes fees per BLD staker decision', async t => { const ContractFee = 302000n; // see split above t.is(((ContractFee - 250000n) * 5n) / 10n, 26000n); - if (defaultManagerType === 'xs-worker') { - // XXX for some reason the code after this when run under XS fails with: - // message: 'unsettled value for "kp2526"', - return; - } - const cases = [ { dest: 'agoric1a', args: ['--fixedFees', '0.25'], rxd: '250000' }, { dest: 'agoric1b', args: ['--feePortion', '0.5'], rxd: '26000' }, @@ -529,12 +523,6 @@ test.serial('LP withdraws', async t => { test.serial('restart contract', async t => { const { EV } = t.context.runUtils; await null; - if (defaultManagerType === 'xs-worker') { - t.is(defaultManagerType, 'xs-worker'); - // XXX for some reason the code after this when run under XS fails with: - // message: 'unsettled value for "kp2526"', - return; - } const kit = await EV.vat('bootstrap').consumeItem('fastUsdcKit'); const actual = await EV(kit.adminFacet).restartContract(kit.privateArgs); t.deepEqual(actual, { incarnationNumber: 1 }); @@ -549,12 +537,6 @@ test.serial('replace operators', async t => { runUtils: { EV }, walletFactoryDriver: wfd, } = t.context; - if (defaultManagerType === 'xs-worker') { - t.is(defaultManagerType, 'xs-worker'); - // XXX for some reason the code after this when run under XS fails with: - // message: 'unsettled value for "kp2526"', - return; - } const { creatorFacet } = await EV.vat('bootstrap').consumeItem('fastUsdcKit'); const EUD = 'dydx1anything'; @@ -603,12 +585,6 @@ test.serial('replace operators', async t => { } } - if (defaultManagerType === 'xs-worker') { - // XXX for some reason the code after this when run under XS fails with: - // message: 'unsettled value for "kp2526"', - return; - } - // Add some new oracle operator const { // any one would do diff --git a/packages/boot/test/orchestration/contract-upgrade.test.ts b/packages/boot/test/orchestration/contract-upgrade.test.ts index 82d6466cafe..9521ee2de5e 100644 --- a/packages/boot/test/orchestration/contract-upgrade.test.ts +++ b/packages/boot/test/orchestration/contract-upgrade.test.ts @@ -4,13 +4,13 @@ import type { TestFn } from 'ava'; import { BridgeId } from '@agoric/internal'; import { buildVTransferEvent } from '@agoric/orchestration/tools/ibc-mocks.js'; -import fetchedChainInfo from '@agoric/orchestration/src/fetched-chain-info.js'; import { withChainCapabilities } from '@agoric/orchestration'; import { makeTestAddress } from '@agoric/orchestration/tools/make-test-address.js'; import { makeWalletFactoryContext, type WalletFactoryTestContext, } from '../bootstrapTests/walletFactory.js'; +import { minimalChainInfos } from '../tools/chainInfo.js'; const test: TestFn = anyTest; test.before(async t => { @@ -45,15 +45,7 @@ test('resume', async t => { await evalProposal( buildProposal('@agoric/builders/scripts/testing/init-send-anywhere.js', [ '--chainInfo', - JSON.stringify( - withChainCapabilities({ - agoric: fetchedChainInfo.agoric, - osmosis: fetchedChainInfo.osmosis, - dydx: fetchedChainInfo.dydx, - noble: fetchedChainInfo.noble, - cosmoshub: fetchedChainInfo.cosmoshub, - }), - ), + JSON.stringify(withChainCapabilities(minimalChainInfos)), '--assetInfo', JSON.stringify([ [ diff --git a/packages/boot/test/orchestration/restart-contracts.test.ts b/packages/boot/test/orchestration/restart-contracts.test.ts index 6ee48efdca0..593f4b71deb 100644 --- a/packages/boot/test/orchestration/restart-contracts.test.ts +++ b/packages/boot/test/orchestration/restart-contracts.test.ts @@ -9,12 +9,12 @@ import { } from '@agoric/orchestration'; import { buildVTransferEvent } from '@agoric/orchestration/tools/ibc-mocks.js'; import type { UpdateRecord } from '@agoric/smart-wallet/src/smartWallet.js'; -import fetchedChainInfo from '@agoric/orchestration/src/fetched-chain-info.js'; import { makeTestAddress } from '@agoric/orchestration/tools/make-test-address.js'; import { makeWalletFactoryContext, type WalletFactoryTestContext, } from '../bootstrapTests/walletFactory.js'; +import { minimalChainInfos } from '../tools/chainInfo.js'; const test: TestFn = anyTest; test.before(async t => { @@ -39,15 +39,7 @@ test.serial('send-anywhere', async t => { await evalProposal( buildProposal('@agoric/builders/scripts/testing/init-send-anywhere.js', [ '--chainInfo', - JSON.stringify( - withChainCapabilities({ - agoric: fetchedChainInfo.agoric, - osmosis: fetchedChainInfo.osmosis, - dydx: fetchedChainInfo.dydx, - noble: fetchedChainInfo.noble, - cosmoshub: fetchedChainInfo.cosmoshub, - }), - ), + JSON.stringify(withChainCapabilities(minimalChainInfos)), '--assetInfo', JSON.stringify([ [ diff --git a/packages/boot/test/tools/chainInfo.ts b/packages/boot/test/tools/chainInfo.ts new file mode 100644 index 00000000000..53f8b5e551c --- /dev/null +++ b/packages/boot/test/tools/chainInfo.ts @@ -0,0 +1,9 @@ +import fetchedChainInfo from '@agoric/orchestration/src/fetched-chain-info.js'; + +export const minimalChainInfos = { + agoric: fetchedChainInfo.agoric, + osmosis: fetchedChainInfo.osmosis, + dydx: fetchedChainInfo.dydx, + noble: fetchedChainInfo.noble, + cosmoshub: fetchedChainInfo.cosmoshub, +}; diff --git a/packages/orchestration/scripts/fetch-chain-info.ts b/packages/orchestration/scripts/fetch-chain-info.ts index 63649af9897..865c086784e 100755 --- a/packages/orchestration/scripts/fetch-chain-info.ts +++ b/packages/orchestration/scripts/fetch-chain-info.ts @@ -12,7 +12,7 @@ const outputFile = 'src/fetched-chain-info.js'; /** * Names for which to fetch info */ -const icaChainNames = [ +export const icaChainNames = new Set([ 'agoric', 'celestia', 'cosmoshub', @@ -26,7 +26,7 @@ const icaChainNames = [ 'stargaze', 'stride', 'umee', -]; +]); const nonIcaChainNames = [ 'migaloo', @@ -65,8 +65,9 @@ const client = new ChainRegistryClient({ // chain info, assets and ibc data will be downloaded dynamically by invoking fetchUrls method await client.fetchUrls(); -const icaChainSet = new Set(icaChainNames); -const chainInfo = await convertChainInfo(client, name => icaChainSet.has(name)); +const chainInfo = await convertChainInfo(client, name => + icaChainNames.has(name), +); const record = JSON.stringify(chainInfo, null, 2); const src = `/** @file Generated by fetch-chain-info.ts */\nexport default /** @type {const} } */ (${record});`; diff --git a/packages/orchestration/src/exos/chain-hub.js b/packages/orchestration/src/exos/chain-hub.js index a671d8e3d3b..e48aaab2210 100644 --- a/packages/orchestration/src/exos/chain-hub.js +++ b/packages/orchestration/src/exos/chain-hub.js @@ -77,13 +77,13 @@ const CHAIN_ID_SEPARATOR = '_'; /** * Vstorage keys can be only alphanumerics, dash, or underscore, which are all * valid characters in chain IDs. So, double each occurence of - * {@link CHAIN_ID_SEPARATOR} in the chain ID to make it clear that it's part of - * the chain ID rather than a separator. + * {@link CHAIN_ID_SEPARATOR} in the chain ID so the encoded tuple can be + * decoded. * * @param {string} chainId * @see {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md} */ -export const sanitizeChainId = chainId => +export const encodeChainId = chainId => chainId.replaceAll( CHAIN_ID_SEPARATOR, `${CHAIN_ID_SEPARATOR}${CHAIN_ID_SEPARATOR}`, @@ -98,8 +98,8 @@ export const sanitizeChainId = chainId => * @param {string} chainId2 */ export const connectionKey = (chainId1, chainId2) => { - const chainId1Sanitized = sanitizeChainId(chainId1); - const chainId2Sanitized = sanitizeChainId(chainId2); + const chainId1Sanitized = encodeChainId(chainId1); + const chainId2Sanitized = encodeChainId(chainId2); return [chainId1Sanitized, chainId2Sanitized].sort().join(CHAIN_ID_SEPARATOR); }; diff --git a/packages/orchestration/src/utils/registry.js b/packages/orchestration/src/utils/registry.js index 426caff030f..b3e24427ec8 100644 --- a/packages/orchestration/src/utils/registry.js +++ b/packages/orchestration/src/utils/registry.js @@ -82,9 +82,9 @@ function toConnectionEntry(ibcInfo, name, chainInfo) { * Converts the given chain info to our local config format * * @param {Pick} registry - * @param {(chainName: string) => boolean} icaEnabled + * @param {(chainName: string) => boolean} isIcaEnabled */ -export const convertChainInfo = async (registry, icaEnabled) => { +export const convertChainInfo = async (registry, isIcaEnabled) => { /** @type {Record} */ const chainInfo = {}; @@ -96,7 +96,7 @@ export const convertChainInfo = async (registry, icaEnabled) => { stakingTokens: chain.staking?.staking_tokens, // UNTIL https://github.com/Agoric/agoric-sdk/issues/9326 icqEnabled: chain.chain_name === 'osmosis', - icaEnabled: icaEnabled(chain.chain_name), + icaEnabled: isIcaEnabled(chain.chain_name), }; }