diff --git a/packages/orchestration/src/examples/stake-bld.contract.js b/packages/orchestration/src/examples/stake-bld.contract.js index 82454422525..f51136e2629 100644 --- a/packages/orchestration/src/examples/stake-bld.contract.js +++ b/packages/orchestration/src/examples/stake-bld.contract.js @@ -43,7 +43,11 @@ export const start = async (zcf, privateArgs, baggage) => { ); const vowTools = prepareVowTools(zone.subZone('vows')); - const chainHub = makeChainHub(privateArgs.agoricNames, vowTools); + const chainHub = makeChainHub( + zone.subZone('chainHub'), + privateArgs.agoricNames, + vowTools, + ); const zoeTools = makeZoeTools(zcf, vowTools); const { localchain, timerService } = privateArgs; diff --git a/packages/orchestration/src/examples/stake-ica.contract.js b/packages/orchestration/src/examples/stake-ica.contract.js index d6b89145368..11dde1662b2 100644 --- a/packages/orchestration/src/examples/stake-ica.contract.js +++ b/packages/orchestration/src/examples/stake-ica.contract.js @@ -84,7 +84,11 @@ export const start = async (zcf, privateArgs, baggage) => { const vowTools = prepareVowTools(zone.subZone('vows')); - const chainHub = makeChainHub(agoricNames, vowTools); + const chainHub = makeChainHub( + zone.subZone('chainHub'), + agoricNames, + vowTools, + ); const makeCosmosOrchestrationAccount = prepareCosmosOrchestrationAccount( zone, diff --git a/packages/orchestration/src/exos/chain-hub.js b/packages/orchestration/src/exos/chain-hub.js index 903fb370c48..e9f52972e4b 100644 --- a/packages/orchestration/src/exos/chain-hub.js +++ b/packages/orchestration/src/exos/chain-hub.js @@ -4,12 +4,12 @@ import { M } from '@endo/patterns'; import { BrandShape } from '@agoric/ertp/src/typeGuards.js'; import { VowShape } from '@agoric/vow'; -import { makeHeapZone } from '@agoric/zone'; import { CosmosChainInfoShape, IBCConnectionInfoShape } from '../typeGuards.js'; /** * @import {NameHub} from '@agoric/vats'; * @import {Vow, VowTools} from '@agoric/vow'; + * @import {Zone} from '@agoric/zone'; * @import {CosmosAssetInfo, CosmosChainInfo, IBCConnectionInfo} from '../cosmos-api.js'; * @import {ChainInfo, KnownChains} from '../chain-info.js'; * @import {Denom} from '../orchestration-api.js'; @@ -171,18 +171,18 @@ const ChainHubI = M.interface('ChainHub', { }); /** - * Make a new ChainHub in the zone (or in the heap if no zone is provided). + * Make a new ChainHub in the zone. * * The resulting object is an Exo singleton. It has no precious state. It's 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. * + * @param {Zone} zone * @param {Remote} agoricNames * @param {VowTools} vowTools */ -export const makeChainHub = (agoricNames, vowTools) => { - const zone = makeHeapZone(); +export const makeChainHub = (zone, agoricNames, vowTools) => { /** @type {MapStore} */ const chainInfos = zone.mapStore('chainInfos', { keyShape: M.string(), diff --git a/packages/orchestration/src/proposals/start-stakeAtom.js b/packages/orchestration/src/proposals/start-stakeAtom.js index c759790a8d4..f6a245bfc08 100644 --- a/packages/orchestration/src/proposals/start-stakeAtom.js +++ b/packages/orchestration/src/proposals/start-stakeAtom.js @@ -46,8 +46,13 @@ export const startStakeAtom = async ({ const storageNode = await makeStorageNodeChild(chainStorage, VSTORAGE_PATH); const marshaller = await E(board).getPublishingMarshaller(); - const vt = prepareVowTools(makeHeapZone()); - const chainHub = makeChainHub(await agoricNames, vt); + const zone = makeHeapZone(); + const vt = prepareVowTools(zone.subZone('vows')); + const chainHub = makeChainHub( + zone.subZone('chainHub'), + await agoricNames, + vt, + ); const [_, cosmoshub, connectionInfo] = await vt.when( chainHub.getChainsAndConnection('agoric', 'cosmoshub'), diff --git a/packages/orchestration/src/proposals/start-stakeOsmo.js b/packages/orchestration/src/proposals/start-stakeOsmo.js index 0f020a62a89..77bd2d562c8 100644 --- a/packages/orchestration/src/proposals/start-stakeOsmo.js +++ b/packages/orchestration/src/proposals/start-stakeOsmo.js @@ -51,8 +51,13 @@ export const startStakeOsmo = async ({ const storageNode = await makeStorageNodeChild(chainStorage, VSTORAGE_PATH); const marshaller = await E(board).getPublishingMarshaller(); - const vt = prepareVowTools(makeHeapZone()); - const chainHub = makeChainHub(await agoricNames, vt); + const zone = makeHeapZone(); + const vt = prepareVowTools(zone.subZone('vows')); + const chainHub = makeChainHub( + zone.subZone('chainHub'), + await agoricNames, + vt, + ); const [_, osmosis, connectionInfo] = await vt.when( chainHub.getChainsAndConnection('agoric', 'osmosis'), diff --git a/packages/orchestration/src/utils/start-helper.js b/packages/orchestration/src/utils/start-helper.js index e3b2cd7aa9d..7c37457ffa7 100644 --- a/packages/orchestration/src/utils/start-helper.js +++ b/packages/orchestration/src/utils/start-helper.js @@ -61,6 +61,8 @@ export const provideOrchestration = ( asyncFlow: zone.subZone('asyncFlow'), /** system names for orchestration implementation */ orchestration: zone.subZone('orchestration'), + /** system names for chainHub */ + chainHub: zone.subZone('chainHub'), /** system names for vows */ vows: zone.subZone('vows'), /** contract-provided names, and subzones */ @@ -72,7 +74,7 @@ export const provideOrchestration = ( const vowTools = prepareVowTools(zones.vows); - const chainHub = makeChainHub(agoricNames, vowTools); + const chainHub = makeChainHub(zones.chainHub, agoricNames, vowTools); const zoeTools = makeZoeTools(zcf, vowTools); diff --git a/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.md b/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.md index 11710ddf60d..5f4dbdca9a3 100644 --- a/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.md +++ b/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.md @@ -24,6 +24,14 @@ Generated by [AVA](https://avajs.dev). flowForOutcomeVow: {}, unwrapMap: 'Alleged: weakMapStore', }, + chainHub: { + ChainHub_kindHandle: 'Alleged: kind', + ChainHub_singleton: 'Alleged: ChainHub', + brandDenom: {}, + chainInfos: {}, + connectionInfos: {}, + denom: {}, + }, contract: { 'ChainHub Admin_kindHandle': 'Alleged: kind', 'ChainHub Admin_singleton': 'Alleged: ChainHub Admin', diff --git a/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.snap b/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.snap index bbf9e53542d..bab47226e8b 100644 Binary files a/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.snap and b/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.snap differ diff --git a/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.md b/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.md index 926a50924a3..afcd6ed2fd1 100644 --- a/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.md +++ b/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.md @@ -24,6 +24,79 @@ Generated by [AVA](https://avajs.dev). flowForOutcomeVow: {}, unwrapMap: 'Alleged: weakMapStore', }, + chainHub: { + ChainHub_kindHandle: 'Alleged: kind', + ChainHub_singleton: 'Alleged: ChainHub', + brandDenom: { + 'Alleged: BLD brand': 'ubld', + }, + chainInfos: { + agoric: { + chainId: 'agoric-3', + icqEnabled: false, + stakingTokens: [ + { + denom: 'ubld', + }, + ], + }, + cosmoshub: { + chainId: 'cosmoshub-4', + icqEnabled: false, + stakingTokens: [ + { + denom: 'uatom', + }, + ], + }, + }, + connectionInfos: { + 'agoric-3_cosmoshub-4': { + client_id: '07-tendermint-6', + counterparty: { + client_id: '07-tendermint-927', + connection_id: 'connection-649', + }, + id: 'connection-8', + state: 3, + transferChannel: { + channelId: 'channel-5', + counterPartyChannelId: 'channel-405', + counterPartyPortId: 'transfer', + ordering: 0, + portId: 'transfer', + state: 3, + version: 'ics20-1', + }, + }, + 'cosmoshub-4_osmosis-1': { + client_id: '07-tendermint-259', + counterparty: { + client_id: '07-tendermint-1', + connection_id: 'connection-1', + }, + id: 'connection-257', + state: 3, + transferChannel: { + channelId: 'channel-141', + counterPartyChannelId: 'channel-0', + counterPartyPortId: 'transfer', + ordering: 0, + portId: 'transfer', + state: 3, + version: 'ics20-1', + }, + }, + }, + denom: { + ubld: { + baseDenom: 'ubld', + baseName: 'agoric', + brand: Object @Alleged: BLD brand {}, + chainName: 'agoric', + }, + }, + }, contract: { 'ChainHub Admin_kindHandle': 'Alleged: kind', 'ChainHub Admin_singleton': 'Alleged: ChainHub Admin', diff --git a/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.snap b/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.snap index 7a30cfbebf4..406237967cd 100644 Binary files a/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.snap and b/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.snap differ diff --git a/packages/orchestration/test/examples/snapshots/unbond.contract.test.ts.md b/packages/orchestration/test/examples/snapshots/unbond.contract.test.ts.md index 1a7163c5994..2a64227520d 100644 --- a/packages/orchestration/test/examples/snapshots/unbond.contract.test.ts.md +++ b/packages/orchestration/test/examples/snapshots/unbond.contract.test.ts.md @@ -24,6 +24,97 @@ Generated by [AVA](https://avajs.dev). flowForOutcomeVow: {}, unwrapMap: 'Alleged: weakMapStore', }, + chainHub: { + ChainHub_kindHandle: 'Alleged: kind', + ChainHub_singleton: 'Alleged: ChainHub', + brandDenom: {}, + chainInfos: { + agoric: { + chainId: 'agoric-3', + icqEnabled: false, + stakingTokens: [ + { + denom: 'ubld', + }, + ], + }, + osmosis: { + chainId: 'osmosis-1', + icqEnabled: true, + stakingTokens: [ + { + denom: 'uosmo', + }, + ], + }, + stride: { + chainId: 'stride-1', + icqEnabled: false, + stakingTokens: [ + { + denom: 'ustrd', + }, + ], + }, + }, + connectionInfos: { + 'agoric-3_osmosis-1': { + client_id: '07-tendermint-1', + counterparty: { + client_id: '07-tendermint-2109', + connection_id: 'connection-1649', + }, + id: 'connection-1', + state: 3, + transferChannel: { + channelId: 'channel-1', + counterPartyChannelId: 'channel-320', + counterPartyPortId: 'transfer', + ordering: 0, + portId: 'transfer', + state: 3, + version: 'ics20-1', + }, + }, + 'agoric-3_stride-1': { + client_id: '07-tendermint-74', + counterparty: { + client_id: '07-tendermint-129', + connection_id: 'connection-118', + }, + id: 'connection-68', + state: 3, + transferChannel: { + channelId: 'channel-59', + counterPartyChannelId: 'channel-148', + counterPartyPortId: 'transfer', + ordering: 0, + portId: 'transfer', + state: 3, + version: 'ics20-1', + }, + }, + 'osmosis-1_stride-1': { + client_id: '07-tendermint-2119', + counterparty: { + client_id: '07-tendermint-1', + connection_id: 'connection-2', + }, + id: 'connection-1657', + state: 3, + transferChannel: { + channelId: 'channel-326', + counterPartyChannelId: 'channel-5', + counterPartyPortId: 'transfer', + ordering: 0, + portId: 'transfer', + state: 3, + version: 'ics20-1', + }, + }, + }, + denom: {}, + }, contract: { orchestration: { unbondAndTransfer: { diff --git a/packages/orchestration/test/examples/snapshots/unbond.contract.test.ts.snap b/packages/orchestration/test/examples/snapshots/unbond.contract.test.ts.snap index fbf713b1764..9bf82ebc441 100644 Binary files a/packages/orchestration/test/examples/snapshots/unbond.contract.test.ts.snap and b/packages/orchestration/test/examples/snapshots/unbond.contract.test.ts.snap differ diff --git a/packages/orchestration/test/exos/chain-hub.test.ts b/packages/orchestration/test/exos/chain-hub.test.ts index 98e865c3527..fed1602a9ab 100644 --- a/packages/orchestration/test/exos/chain-hub.test.ts +++ b/packages/orchestration/test/exos/chain-hub.test.ts @@ -42,9 +42,9 @@ const connection = { // fresh state for each test const setup = () => { const zone = provideDurableZone('root'); - const vt = prepareSwingsetVowTools(zone); + const vt = prepareSwingsetVowTools(zone.subZone('vows')); const { nameHub, nameAdmin } = makeNameHubKit(); - const chainHub = makeChainHub(nameHub, vt); + const chainHub = makeChainHub(zone.subZone('chainHub'), nameHub, vt); return { chainHub, nameAdmin, vt }; }; diff --git a/packages/orchestration/test/staking-ops.test.ts b/packages/orchestration/test/staking-ops.test.ts index 4b9dc90ff53..9e2f5c79e3c 100644 --- a/packages/orchestration/test/staking-ops.test.ts +++ b/packages/orchestration/test/staking-ops.test.ts @@ -229,6 +229,13 @@ const makeScenario = () => { eventLoopIteration, }); const { nameHub: agoricNames } = makeNameHubKit(); + + const chainHub = makeChainHub( + zone.subZone('chainHub'), + agoricNames, + vowTools, + ); + return { baggage, zone, @@ -238,6 +245,7 @@ const makeScenario = () => { timer, icqConnection, vowTools, + chainHub, ...mockZCF(), agoricNames, }; @@ -247,16 +255,16 @@ test('makeAccount() writes to storage', async t => { const s = makeScenario(); const { account, timer } = s; const { - agoricNames, makeRecorderKit, storageNode, zcf, icqConnection, vowTools, + chainHub, zone, } = s; const make = prepareCosmosOrchestrationAccountKit(zone, { - chainHub: makeChainHub(agoricNames, vowTools), + chainHub, makeRecorderKit, timerService: timer, vowTools, @@ -295,16 +303,16 @@ test('withdrawRewards() on StakingAccountHolder formats message correctly', asyn const s = makeScenario(); const { account, calls, timer } = s; const { - agoricNames, makeRecorderKit, storageNode, zcf, icqConnection, vowTools, + chainHub, zone, } = s; const make = prepareCosmosOrchestrationAccountKit(zone, { - chainHub: makeChainHub(agoricNames, vowTools), + chainHub, makeRecorderKit, timerService: timer, vowTools, @@ -339,17 +347,17 @@ test(`delegate; redelegate using invitationMakers`, async t => { const s = makeScenario(); const { account, calls, timer } = s; const { - agoricNames, makeRecorderKit, storageNode, zcf, zoe, icqConnection, vowTools, + chainHub, zone, } = s; const makeAccountKit = prepareCosmosOrchestrationAccountKit(zone, { - chainHub: makeChainHub(agoricNames, vowTools), + chainHub, makeRecorderKit, timerService: timer, vowTools, @@ -429,17 +437,17 @@ test(`withdraw rewards using invitationMakers`, async t => { const s = makeScenario(); const { account, calls, timer } = s; const { - agoricNames, makeRecorderKit, storageNode, zcf, zoe, icqConnection, vowTools, + chainHub, zone, } = s; const makeAccountKit = prepareCosmosOrchestrationAccountKit(zone, { - chainHub: makeChainHub(agoricNames, vowTools), + chainHub, makeRecorderKit, timerService: timer, vowTools, @@ -477,17 +485,17 @@ test(`undelegate waits for unbonding period`, async t => { const s = makeScenario(); const { account, calls, timer } = s; const { - agoricNames, makeRecorderKit, storageNode, zcf, zoe, icqConnection, vowTools, + chainHub, zone, } = s; const makeAccountKit = prepareCosmosOrchestrationAccountKit(zone, { - chainHub: makeChainHub(agoricNames, vowTools), + chainHub, makeRecorderKit, timerService: timer, vowTools, diff --git a/packages/orchestration/test/supports.ts b/packages/orchestration/test/supports.ts index 21603240711..691eada4312 100644 --- a/packages/orchestration/test/supports.ts +++ b/packages/orchestration/test/supports.ts @@ -164,7 +164,11 @@ export const commonSetup = async (t: ExecutionContext) => { await eventLoopIteration(); }; - const chainHub = makeChainHub(agoricNames, vowTools); + const chainHub = makeChainHub( + rootZone.subZone('chainHub'), + agoricNames, + vowTools, + ); /** * Register BLD if it's not already registered.