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

9281 chainHub exo #9538

Merged
merged 2 commits into from
Jun 19, 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
2 changes: 1 addition & 1 deletion packages/orchestration/src/chain-info.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { registerChain } from './utils/chainHub.js';
import { registerChain } from './exos/chain-hub.js';

// Refresh with scripts/refresh-chain-info.ts
import fetchedChainInfo from './fetched-chain-info.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/orchestration/src/examples/stakeBld.contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { E } from '@endo/far';
import { deeplyFulfilled } from '@endo/marshal';
import { M } from '@endo/patterns';
import { prepareLocalOrchestrationAccountKit } from '../exos/local-orchestration-account.js';
import { makeChainHub } from '../utils/chainHub.js';
import { makeChainHub } from '../exos/chain-hub.js';

/**
* @import {NameHub} from '@agoric/vats';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,38 @@ export const connectionKey = (chainId1, chainId2) => {
return [chainId1, chainId2].sort().join(CHAIN_ID_SEPARATOR);
};

const ChainIdArgShape = M.or(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider:

Suggested change
const ChainIdArgShape = M.or(
/** accepts `chainId` or `ChainAddress` object */
const ChainIdArgShape = M.or(

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea. I'll make a note to get that into a future PR

M.string(),
M.splitRecord(
{
chainId: M.string(),
},
undefined,
M.any(),
),
);

const ChainHubI = M.interface('ChainHub', {
registerChain: M.call(M.string(), CosmosChainInfoShape).returns(),
getChainInfo: M.callWhen(M.string()).returns(CosmosChainInfoShape),
registerConnection: M.callWhen(
M.string(),
M.string(),
IBCConnectionInfoShape,
).returns(),
getConnectionInfo: M.callWhen(ChainIdArgShape, ChainIdArgShape).returns(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

callWhen is OK in asyncFlow after all?

I can imagine waiting for tests that show that it's not, but in that case, why not wait for tests that show that chainHub has to be an exo in the 1st place?

Copy link
Member Author

@turadg turadg Jun 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, I learned last night it's not.

We did hit a test failure with the object itself not being durable but only in another branch that had a higher fidelity asyncFlow

IBCConnectionInfoShape,
),
});

/**
* Make a new ChainHub in the zone (or in the heap if no zone is provided).
*
* 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 {Remote<NameHub>} agoricNames
* @param {Zone} [zone]
*/
Expand All @@ -70,7 +101,7 @@ export const makeChainHub = (agoricNames, zone = makeHeapZone()) => {
valueShape: IBCConnectionInfoShape,
});

const chainHub = harden({
const chainHub = zone.exo('ChainHub', ChainHubI, {
/**
* Register a new chain. The name will override a name in well known chain
* names.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { dateInSeconds, makeTimestampHelper } from '../utils/time.js';
* @import {TimerService, TimerBrand, TimestampRecord} from '@agoric/time';
* @import {PromiseVow, VowTools} from '@agoric/vow';
* @import {TypedJson} from '@agoric/cosmic-proto';
* @import {ChainHub} from '../utils/chainHub.js';
* @import {ChainHub} from './chain-hub.js';
*/

const trace = makeTracer('LOA');
Expand Down
2 changes: 1 addition & 1 deletion packages/orchestration/src/exos/orchestrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {

/**
* @import {Zone} from '@agoric/base-zone';
* @import {ChainHub} from '../utils/chainHub.js';
* @import {ChainHub} from './chain-hub.js';
* @import {AsyncFlowTools} from '@agoric/async-flow';
* @import {Vow} from '@agoric/vow';
* @import {TimerService} from '@agoric/time';
Expand Down
2 changes: 1 addition & 1 deletion packages/orchestration/src/facade.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { prepareOrchestrator } from './exos/orchestrator.js';
* storageNode: Remote<StorageNode>;
* orchestrationService: Remote<OrchestrationService>;
* localchain: Remote<LocalChain>;
* chainHub: import('./utils/chainHub.js').ChainHub;
* chainHub: import('./exos/chain-hub.js').ChainHub;
* makeLocalOrchestrationAccountKit: MakeLocalOrchestrationAccountKit;
* makeRecorderKit: MakeRecorderKit;
* makeCosmosOrchestrationAccount: any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { E, Far } from '@endo/far';
import { makeMarshal } from '@endo/marshal';
import { Fail } from '@agoric/assert';
import { registerChainNamespace } from '../chain-info.js';
import { CHAIN_KEY, CONNECTIONS_KEY } from '../utils/chainHub.js';
import { CHAIN_KEY, CONNECTIONS_KEY } from '../exos/chain-hub.js';

const trace = makeTracer('CoreEvalOrchestration', true);

Expand Down
2 changes: 1 addition & 1 deletion packages/orchestration/src/proposals/start-stakeAtom.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { makeTracer } from '@agoric/internal';
import { makeStorageNodeChild } from '@agoric/internal/src/lib-chainStorage.js';
import { E } from '@endo/far';
import { getChainsAndConnection, makeChainHub } from '../utils/chainHub.js';
import { getChainsAndConnection, makeChainHub } from '../exos/chain-hub.js';

/**
* @import {IBCConnectionID} from '@agoric/vats';
Expand Down
2 changes: 1 addition & 1 deletion packages/orchestration/src/proposals/start-stakeOsmo.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { makeTracer } from '@agoric/internal';
import { makeStorageNodeChild } from '@agoric/internal/src/lib-chainStorage.js';
import { E } from '@endo/far';
import { getChainsAndConnection, makeChainHub } from '../utils/chainHub.js';
import { getChainsAndConnection, makeChainHub } from '../exos/chain-hub.js';

/**
* @import {IBCConnectionID} from '@agoric/vats';
Expand Down
2 changes: 1 addition & 1 deletion packages/orchestration/src/utils/start-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { prepareRecorderKitMakers } from '@agoric/zoe/src/contractSupport/record
import { makeDurableZone } from '@agoric/zone/durable.js';
import { prepareLocalOrchestrationAccountKit } from '../exos/local-orchestration-account.js';
import { makeOrchestrationFacade } from '../facade.js';
import { makeChainHub } from './chainHub.js';
import { makeChainHub } from '../exos/chain-hub.js';
import { prepareRemoteChainFacade } from '../exos/remote-chain-facade.js';
import { prepareCosmosOrchestrationAccount } from '../exos/cosmos-orchestration-account.js';
import { prepareLocalChainFacade } from '../exos/local-chain-facade.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { makeIssuerKit } from '@agoric/ertp';
import { CosmosChainInfo, IBCConnectionInfo } from '../../src/cosmos-api.js';
import { commonSetup } from '../supports.js';
import { SingleAmountRecord } from '../../src/examples/sendAnywhere.contract.js';
import { registerChain } from '../../src/utils/chainHub.js';
import { registerChain } from '../../src/exos/chain-hub.js';

const dirname = path.dirname(new URL(import.meta.url).pathname);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import test from '@endo/ses-ava/prepare-endo.js';

import { makeNameHubKit } from '@agoric/vats';
import { makeChainHub } from '../../src/utils/chainHub.js';
import { makeChainHub } from '../../src/exos/chain-hub.js';

const connection = {
id: 'connection-1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { prepareRecorderKitMakers } from '@agoric/zoe/src/contractSupport/record
import { Far } from '@endo/far';
import { prepareLocalOrchestrationAccountKit } from '../../src/exos/local-orchestration-account.js';
import { ChainAddress } from '../../src/orchestration-api.js';
import { makeChainHub } from '../../src/utils/chainHub.js';
import { makeChainHub } from '../../src/exos/chain-hub.js';
import { NANOSECONDS_PER_SECOND } from '../../src/utils/time.js';
import { commonSetup } from '../supports.js';

Expand Down
Loading