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

feat(orch)!: opt-in publishing of account info #10718

Merged
merged 1 commit into from
Feb 11, 2025
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
6 changes: 1 addition & 5 deletions packages/boot/test/fast-usdc/fast-usdc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,7 @@ test.serial('writes account addresses to vstorage', async t => {
showValue: JSON.parse,
pattern: /published\.fastUsdc\.(feeConfig|feedPolicy|poolMetrics)/,
replacement: '',
note: `Under "published", the "fastUsdc" node is delegated to FastUSDC contract.
Note: published.fastUsdc.[settleAcctAddr], published.fastUsdc.[poolAcctAddr],
and published.fastUsdc.[intermediateAcctAddr] are published by @agoric/orchestration
via 'withOrchestration' and (local|cosmos)-orch-account-kit.js.
`,
note: 'Under "published", the "fastUsdc" node is delegated to FastUSDC contract.',
};

await documentStorageSchema(t, storage, doc);
Expand Down
25 changes: 0 additions & 25 deletions packages/boot/test/fast-usdc/snapshots/fast-usdc.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,6 @@ Generated by [AVA](https://avajs.dev).
## writes account addresses to vstorage

> Under "published", the "fastUsdc" node is delegated to FastUSDC contract.
> Note: published.fastUsdc.[settleAcctAddr], published.fastUsdc.[poolAcctAddr],
> and published.fastUsdc.[intermediateAcctAddr] are published by @agoric/orchestration
> via 'withOrchestration' and (local|cosmos)-orch-account-kit.js.
>
> The example below illustrates the schema of the data published there.
>
> See also board marshalling conventions (_to appear_).
Expand All @@ -147,27 +143,6 @@ Generated by [AVA](https://avajs.dev).
settlementAccount: 'agoric1qyqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqc09z0g',
},
],
[
'published.fastUsdc.agoric1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqp7zqht',
{
body: '#""',
slots: [],
},
],
[
'published.fastUsdc.agoric1qyqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqc09z0g',
{
body: '#""',
slots: [],
},
],
[
'published.fastUsdc.noble1test',
{
body: '#{"localAddress":"/ibc-port/icacontroller-1/ordered/{\\"version\\":\\"ics27-1\\",\\"controllerConnectionId\\":\\"connection-72\\",\\"hostConnectionId\\":\\"connection-40\\",\\"address\\":\\"noble1test\\",\\"encoding\\":\\"proto3\\",\\"txType\\":\\"sdk_multi_msg\\"}/ibc-channel/channel-1","remoteAddress":"/ibc-hop/connection-72/ibc-port/icahost/ordered/{\\"version\\":\\"ics27-1\\",\\"controllerConnectionId\\":\\"connection-72\\",\\"hostConnectionId\\":\\"connection-40\\",\\"address\\":\\"noble1test\\",\\"encoding\\":\\"proto3\\",\\"txType\\":\\"sdk_multi_msg\\"}/ibc-channel/channel-1"}',
slots: [],
},
],
]

## makes usdc advance
Expand Down
Binary file modified packages/boot/test/fast-usdc/snapshots/fast-usdc.test.ts.snap
Binary file not shown.
1 change: 1 addition & 0 deletions packages/fast-usdc/src/fast-usdc.contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ const publishAddresses = (contractNode, addresses) => {
* feeConfig: FeeConfig;
* marshaller: Marshaller;
* poolMetricsNode: Remote<StorageNode>;
* storageNode: Remote<StorageNode>;
* }} privateArgs
* @param {Zone} zone
* @param {OrchestrationTools} tools
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const contract = async (
return { publicFacet, creatorFacet };
};

export const start = withOrchestration(contract);
export const start = withOrchestration(contract, { publishAccountInfo: true });
harden(start);

/** @typedef {typeof start} AutoStakeItSF */
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const contract = async (
return { publicFacet };
};

export const start = withOrchestration(contract);
export const start = withOrchestration(contract, { publishAccountInfo: true });
harden(start);

/** @typedef {typeof start} BasicFlowsSF */
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as flows from './send-anywhere.flows.js';
import * as sharedFlows from './shared.flows.js';

/**
* @import {Vow} from '@agoric/vow';
* @import {Remote, Vow} from '@agoric/vow';
* @import {Zone} from '@agoric/zone';
* @import {OrchestrationPowers, OrchestrationTools} from '../utils/start-helper.js';
* @import {CosmosChainInfo, Denom, DenomDetail} from '@agoric/orchestration';
Expand All @@ -28,9 +28,10 @@ harden(SingleNatAmountRecord);
*
* @param {ZCF} zcf
* @param {OrchestrationPowers & {
* marshaller: Marshaller;
* chainInfo?: Record<string, CosmosChainInfo>;
* assetInfo?: [Denom, DenomDetail & { brandKey?: string }][];
* chainInfo?: Record<string, CosmosChainInfo>;
* marshaller: Marshaller;
* storageNode: Remote<StorageNode>;
* }} privateArgs
* @param {Zone} zone
* @param {OrchestrationTools} tools
Expand Down Expand Up @@ -97,5 +98,5 @@ export const contract = async (
};
harden(contract);

export const start = withOrchestration(contract);
export const start = withOrchestration(contract, { publishAccountInfo: true });
harden(start);
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,5 @@ const contract = async (
return harden({ publicFacet, creatorFacet });
};

export const start = withOrchestration(contract);
export const start = withOrchestration(contract, { publishAccountInfo: true });
harden(start);
2 changes: 1 addition & 1 deletion packages/orchestration/src/examples/swap.contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,5 @@ const contract = async (
return harden({ publicFacet });
};

export const start = withOrchestration(contract);
export const start = withOrchestration(contract, { publishAccountInfo: true });
harden(start);
2 changes: 1 addition & 1 deletion packages/orchestration/src/examples/unbond.contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ const contract = async (
return harden({ publicFacet });
};

export const start = withOrchestration(contract);
export const start = withOrchestration(contract, { publishAccountInfo: true });
harden(start);
31 changes: 18 additions & 13 deletions packages/orchestration/src/exos/cosmos-orchestration-account.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,20 @@ const trace = makeTracer('CosmosOrchAccount');
const { Vow$ } = NetworkShape; // TODO #9611

/**
* @typedef {object} ComosOrchestrationAccountNotification
* @typedef {object} CosmosOrchestrationAccountNotification
* @property {ChainAddress} chainAddress
*/

/**
* @private
* @typedef {{
* topicKit: RecorderKit<ComosOrchestrationAccountNotification>;
* account: IcaAccount;
* chainAddress: ChainAddress;
* icqConnection: ICQConnection | undefined;
* localAddress: LocalIbcAddress;
* remoteAddress: RemoteIbcAddress;
* icqConnection: ICQConnection | undefined;
* timer: Remote<TimerService>;
* topicKit: RecorderKit<CosmosOrchestrationAccountNotification> | undefined;
* }} State
* Internal to the IcaAccountHolder exo
*/
Expand Down Expand Up @@ -291,26 +291,29 @@ export const prepareCosmosOrchestrationAccountKit = (
* @param {RemoteIbcAddress} info.remoteAddress
* @param {object} io
* @param {IcaAccount} io.account
* @param {Remote<StorageNode>} io.storageNode
* @param {ICQConnection | undefined} io.icqConnection
* @param {Remote<StorageNode>} [io.storageNode]
* @param {ICQConnection} [io.icqConnection]
* @param {Remote<TimerService>} io.timer
* @returns {State}
*/
({ chainAddress, localAddress, remoteAddress }, io) => {
const { storageNode } = io;
// must be the fully synchronous maker because the kit is held in durable state
const topicKit = makeRecorderKit(storageNode, PUBLIC_TOPICS.account[1]);
const topicKit = storageNode
? makeRecorderKit(storageNode, PUBLIC_TOPICS.account[1])
: undefined;
// TODO determine what goes in vstorage https://github.com/Agoric/agoric-sdk/issues/9066
// XXX consider parsing local/remoteAddr to portId, channelId, counterpartyPortId, counterpartyChannelId, connectionId, counterpartyConnectionId
// FIXME these values will not update if IcaAccount gets new values after reopening.
// consider having IcaAccount responsible for the owning the writer. It might choose to share it with COA.
void E(topicKit.recorder).write(
/** @type {CosmosOrchestrationAccountStorageState} */ ({
localAddress,
remoteAddress,
}),
);

if (topicKit) {
void E(topicKit.recorder).write(
/** @type {CosmosOrchestrationAccountStorageState} */ ({
localAddress,
remoteAddress,
}),
);
}
const { account, icqConnection, timer } = io;
return {
account,
Expand All @@ -333,6 +336,7 @@ export const prepareCosmosOrchestrationAccountKit = (
return account;
},
getUpdater() {
if (!this.state.topicKit) throw Fail`no topicKit`;
return this.state.topicKit.recorder;
},
/**
Expand Down Expand Up @@ -731,6 +735,7 @@ export const prepareCosmosOrchestrationAccountKit = (
return asVow(async () => {
await null;
const { topicKit } = this.state;
if (!topicKit) throw Fail`No topicKit; storageNode not provided`;
return harden({
account: {
description: PUBLIC_TOPICS.account[0],
Expand Down
16 changes: 9 additions & 7 deletions packages/orchestration/src/exos/local-chain-facade.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { chainFacadeMethods, TypedJsonShape } from '../typeGuards.js';
* @typedef {{
* makeLocalOrchestrationAccountKit: MakeLocalOrchestrationAccountKit;
* orchestration: Remote<CosmosInterchainService>;
* storageNode: Remote<StorageNode>;
* storageNode: Remote<StorageNode> | undefined;
* agoricNames: Remote<NameHub>;
* timer: Remote<TimerService>;
* localchain: Remote<LocalChain>;
Expand Down Expand Up @@ -79,7 +79,7 @@ const prepareLocalChainFacadeKit = (
.returns(VowShape),
}),
makeChildNodeWatcher: M.interface('makeChildNodeWatcher', {
onFulfilled: M.call(M.remotable())
onFulfilled: M.call(M.or(M.remotable(), M.undefined()))
.optional({ account: M.remotable(), address: M.string() }) // empty context
.returns(M.remotable()),
}),
Expand Down Expand Up @@ -145,11 +145,13 @@ const prepareLocalChainFacadeKit = (
* @param {[LocalChainAccount, ChainAddress['value']]} results
*/
onFulfilled([account, address]) {
return watch(
E(storageNode).makeChildNode(address),
this.facets.makeChildNodeWatcher,
{ account, address },
);
const optionalStorageNode = storageNode
? E(storageNode).makeChildNode(address)
: undefined;
return watch(optionalStorageNode, this.facets.makeChildNodeWatcher, {
account,
address,
});
},
},
makeChildNodeWatcher: {
Expand Down
16 changes: 11 additions & 5 deletions packages/orchestration/src/exos/local-orchestration-account.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const EVow$ = shape => M.or(Vow$(shape), M.promise(/* shape */));
/**
* @private
* @typedef {{
* topicKit: RecorderKit<LocalChainAccountNotification>;
* topicKit: RecorderKit<LocalChainAccountNotification> | undefined;
* packetTools: PacketTools;
* account: LocalChainAccount;
* address: ChainAddress;
Expand Down Expand Up @@ -181,17 +181,22 @@ export const prepareLocalOrchestrationAccountKit = (
* @param {object} initState
* @param {LocalChainAccount} initState.account
* @param {ChainAddress} initState.address
* @param {Remote<StorageNode>} initState.storageNode
* @param {Remote<StorageNode>} [initState.storageNode]
* @returns {State}
*/
({ account, address, storageNode }) => {
// must be the fully synchronous maker because the kit is held in durable state
const topicKit = makeRecorderKit(storageNode, PUBLIC_TOPICS.account[1]);
const topicKit = storageNode
? makeRecorderKit(storageNode, PUBLIC_TOPICS.account[1])
: undefined;
// TODO determine what goes in vstorage https://github.com/Agoric/agoric-sdk/issues/9066
void E(topicKit.recorder).write('');
if (topicKit) {
void E(topicKit.recorder).write('');
}

const packetTools = makePacketTools(account);

return { account, address, topicKit, packetTools };
return { account, address, packetTools, topicKit };
},
{
helper: {
Expand Down Expand Up @@ -548,6 +553,7 @@ export const prepareLocalOrchestrationAccountKit = (
return asVow(async () => {
await null;
const { topicKit } = this.state;
if (!topicKit) throw Fail`No topicKit; storageNode not provided`;
return harden({
account: {
description: PUBLIC_TOPICS.account[0],
Expand Down
20 changes: 12 additions & 8 deletions packages/orchestration/src/exos/remote-chain-facade.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const trace = makeTracer('RemoteChainFacade');
* typeof prepareCosmosOrchestrationAccount
* >;
* orchestration: Remote<CosmosInterchainService>;
* storageNode: Remote<StorageNode>;
* storageNode: Remote<StorageNode> | undefined;
* timer: Remote<TimerService>;
* vowTools: VowTools;
* }} RemoteChainFacadePowers
Expand Down Expand Up @@ -94,7 +94,7 @@ const prepareRemoteChainFacadeKit = (
).returns(VowShape),
}),
makeChildNodeWatcher: M.interface('makeChildNodeWatcher', {
onFulfilled: M.call(M.remotable(), {
onFulfilled: M.call(M.or(M.remotable(), M.undefined()), {
account: M.remotable(),
chainAddress: ChainAddressShape,
localAddress: M.string(),
Expand Down Expand Up @@ -210,16 +210,20 @@ const prepareRemoteChainFacadeKit = (
* @param {IcaAccount} account
*/
onFulfilled([chainAddress, localAddress, remoteAddress], account) {
return watch(
E(storageNode).makeChildNode(chainAddress.value),
this.facets.makeChildNodeWatcher,
{ account, chainAddress, localAddress, remoteAddress },
);
const optionalStorageNode = storageNode
? E(storageNode).makeChildNode(chainAddress.value)
: undefined;
return watch(optionalStorageNode, this.facets.makeChildNodeWatcher, {
account,
chainAddress,
localAddress,
remoteAddress,
});
},
},
makeChildNodeWatcher: {
/**
* @param {Remote<StorageNode>} childNode
* @param {Remote<StorageNode> | undefined} childNode
* @param {{
* account: IcaAccount;
* chainAddress: ChainAddress;
Expand Down
11 changes: 2 additions & 9 deletions packages/orchestration/src/facade.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
import { assertAllDefined, deepMapObject } from '@agoric/internal';

/**
* @import {AsyncFlowTools, GuestInterface, HostArgs, HostOf} from '@agoric/async-flow';
* @import {AsyncFlowTools, GuestInterface, HostArgs} from '@agoric/async-flow';
* @import {Zone} from '@agoric/zone';
* @import {Vow, VowTools} from '@agoric/vow';
* @import {TimerService} from '@agoric/time';
* @import {RecorderKit, MakeRecorderKit} from '@agoric/zoe/src/contractSupport/recorder.js'.
* @import {HostOrchestrator} from './exos/orchestrator.js';
* @import {Remote} from '@agoric/internal';
* @import {CosmosInterchainService} from './exos/exo-interfaces.js';
* @import {Chain, ChainInfo, CosmosChainInfo, IBCConnectionInfo, OrchestrationAccount, OrchestrationFlow, Orchestrator} from './types.js';
* @import {OrchestrationFlow, Orchestrator} from './types.js';
*/

/**
Expand All @@ -31,9 +30,7 @@ import { assertAllDefined, deepMapObject } from '@agoric/internal';
* zone: Zone;
* timerService: Remote<TimerService>;
* zcf: ZCF;
* storageNode: Remote<StorageNode>;
* orchestrationService: Remote<CosmosInterchainService>;
* makeRecorderKit: MakeRecorderKit;
* makeOrchestrator: () => HostOrchestrator;
* vowTools: VowTools;
* asyncFlowTools: AsyncFlowTools;
Expand All @@ -43,9 +40,7 @@ export const makeOrchestrationFacade = ({
zone,
timerService,
zcf,
storageNode,
orchestrationService,
makeRecorderKit,
makeOrchestrator,
vowTools,
asyncFlowTools,
Expand All @@ -54,9 +49,7 @@ export const makeOrchestrationFacade = ({
zone,
timerService,
zcf,
storageNode,
orchestrationService,
makeRecorderKit,
makeOrchestrator,
vowTools,
asyncFlowTools,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const contract = async (zcf, _privateArgs, zone, { orchestrateAll }) => {
return { publicFacet };
};

export const start = withOrchestration(contract);
export const start = withOrchestration(contract, { publishAccountInfo: true });
harden(start);

/** @typedef {typeof start} QueryFlowsSF */
Loading
Loading