-
Notifications
You must be signed in to change notification settings - Fork 208
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
9068 close account e2e #9864
9068 close account e2e #9864
Conversation
Deploying agoric-sdk with Cloudflare Pages
|
38b8834
to
16dd28b
Compare
794c23e
to
bed93f0
Compare
fe0211e
to
9cc6ae2
Compare
bed93f0
to
c287b86
Compare
1063d9b
to
e1fcfae
Compare
b808d43
to
440401d
Compare
dd2c20f
to
6ca41fa
Compare
440401d
to
b18263a
Compare
3e75a73
to
a1b4f9a
Compare
I removed the "auto reopen" test scenario for now, as we need #9891 to complete it: unintentionalCloseAccountScenario (auto reopen)/** The channel is closed for an unexpected reason and should automatically reopen */
const unintentionalCloseAccountScenario = test.macro({
title: (_, chainName: string) =>
`Automatically reopen closed channel on ${chainName}`,
exec: async (t, chainName: string) => {
const config = chainConfig[chainName];
if (!config) return t.fail(`Unknown chain: ${chainName}`);
const {
wallets,
provisionSmartWallet,
vstorageClient,
retryUntilCondition,
useChain,
hermes,
} = t.context;
const agoricAddr = wallets[chainName];
const wdUser1 = await provisionSmartWallet(agoricAddr, {
BLD: 100n,
IST: 100n,
});
t.log(`provisioning agoric smart wallet for ${agoricAddr}`);
const doOffer = makeDoOffer(wdUser1);
t.log(`${chainName} makeAccount offer`);
const offerId = `${chainName}-makeAccount-${Date.now()}`;
await doOffer({
id: offerId,
invitationSpec: {
source: 'agoricContract',
instancePath: [contractName],
callPipe: [['makeOrchAccountInvitation']],
},
offerArgs: { chainName },
proposal: {},
});
const currentWalletRecord = await retryUntilCondition(
() => vstorageClient.queryData(`published.wallet.${agoricAddr}.current`),
({ offerToPublicSubscriberPaths }) =>
Object.fromEntries(offerToPublicSubscriberPaths)[offerId],
`${offerId} continuing invitation is in vstorage`,
);
const offerToPublicSubscriberMap = Object.fromEntries(
currentWalletRecord.offerToPublicSubscriberPaths,
);
const accountStoragePath = offerToPublicSubscriberMap[offerId]?.account;
t.assert(accountStoragePath, 'account storage path returned');
const address = accountStoragePath.split('.').pop();
t.log('Got address:', address);
const {
remoteAddress,
localAddress,
}: CosmosOrchestrationAccountStorageState =
await vstorageClient.queryData(accountStoragePath);
const { rPortID, rChannelID } = parseRemoteAddress(remoteAddress);
const { lPortID, lChannelID, lConnectionID } =
parseLocalAddress(localAddress);
const dst = {
chainId: chainInfo['agoric'].chainId,
channelID: lChannelID,
portID: lPortID,
connectionID: lConnectionID,
};
const src = {
chainId: useChain(chainName).chainInfo.chain.chain_id,
channelID: rChannelID,
portID: rPortID,
};
console.log(
`Initiating channelCloseInit for dst: ${JSON.stringify(dst)} src: ${JSON.stringify(src)}`,
);
const closeChannelTx = hermes.channelCloseInit(chainName, dst, src);
console.log('closeChannelExec', closeChannelTx);
const remoteQueryClient = makeQueryClient(
await useChain(chainName).getRestEndpoint(),
);
const { channel } = await retryUntilCondition(
() => remoteQueryClient.queryChannel(rPortID, rChannelID),
// @ts-expect-error ChannelSDKType.state is a string not a number
({ channel }) => channel?.state === 'STATE_CLOSED',
'ICA channel closed from Hermes closeChannelInit',
{
retryIntervalMs: 300,
maxRetries: 10,
},
);
t.is(
channel?.state,
// @ts-expect-error ChannelSDKType.state is a string not a number
'STATE_CLOSED',
'closed state is observed',
);
const { channels } = await retryUntilCondition(
() => remoteQueryClient.queryChannels(),
// @ts-expect-error ChannelSDKType.state is a string not a number
({ channels }) => findNewChannel(channels, { rPortID, lPortID }),
`ICA channel is reopened on ${chainName} Host`,
);
const newChannel = findNewChannel(channels, { rPortID, lPortID });
t.log('New Channel after Reopen', newChannel);
if (!newChannel) throw new Error('Channel not found');
const newAddress = JSON.parse(newChannel.version).address;
t.is(newAddress, address, `same chain address is returned - ${chainName}`);
t.is(
newChannel.state,
// @ts-expect-error ChannelSDKType.state is a string not a number
'STATE_OPEN',
`channel is open on ${chainName} Host`,
);
t.not(newChannel.channel_id, rChannelID, 'remote channel id changed');
t.not(
newChannel.counterparty.channel_id,
lChannelID,
'local channel id changed',
);
},
});
test.serial(unintentionalCloseAccountScenario, 'cosmoshub');
test.serial(unintentionalCloseAccountScenario, 'osmosis'); This path is currently covered by unit tests with a Most importantly, |
ad1ab81
to
3692790
Compare
b18263a
to
01094e3
Compare
3692790
to
b7988b3
Compare
f04fcb7
to
89bae79
Compare
closes: #9068 closes: #9192 ## Description - enables `deactivate()` on `CosmosOrchestrationAccount` to close a channel (deactivate an account). Performs state cleanup (#9192) but preserves `Port` object and `ChainAddress` in case a holder wants to `reactivate()` the channel (account). - adds `reactivate()` method to `IcaAccountKit` to allow a holder to reactivate an account (reestablish the connection with a new channel) they chose to `.deactivate()`. The original `Port` and `requestedRemoteAddress` are reused to ensure the same ChainAddress is assigned. - adds logic to automatically reopen a channel that's closed for external factors (e.g. packet timeout) (#9068) and perform state cleanup (#9192) - updates testing harness to ensure we can simulate ICA Channel Closure/Reopening in unit tests ### Security Considerations n/a ### Scaling Considerations n/a ### Documentation Considerations Includes add'l JSDoc + mermaid diagram updates ### Testing Considerations Includes unit tests with high fidelity mocks from observed behavior on sim chains. See #9864 for e2e tests. ### Upgrade Considerations We are looking to land this in the initial release of `vat-orchestration`.
b7988b3
to
eebe943
Compare
/** The account holder chooses to close their ICA account (channel) */ | ||
const intentionalCloseAccountScenario = test.macro({ | ||
title: (_, chainName: string) => `Close and reopen account on ${chainName}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exemplary macro
eebe943
to
e47cc4d
Compare
- publishes remoteAddress (RemoteIBCAddress) and localAddress (LocalIBCAddress) to vstorage for CosmosOrchestrationAccount - goal is to faciliate off-chain clients, which need portId, connectionId, and channelId for the host and controller to perform queries - a better design might publish these values individually, versus putting the burden of parsing on the client - refs: #9066
- helper functions for extracting connectionID, portID, and channelID from a negotiated (Local|Remote)IBCAddress string
- helper function to install a contract from a proposal builder - queries vstorage and skips installation and CoreEval if instance is found
- CosmosOrchAccount (IcaAccout) holder can deactivate their account (close channel) - CosmosOrchAccount (IcaAccount) holder can reactivate their account (open new channel w same portID)
- ensures clients cannot initiate channelCloseInit
e47cc4d
to
bb6d53d
Compare
refs: #9068
refs: #9192
Description
Automatically reopen a closed ICA channel (e.g. a packet timed out)requires e2e testing capabilities for packet timeout scenarios #9891 to complete. See 9068 close account e2e #9864 (comment)CosmosOrchestrationAccount
(IcaAccout
) holder can close their accountCosmosOrchestrationAccount
(IcaAccount
) holder can reopen their accountpublish local and remote ibc addresses to vstorage
to facilitate querying the ICA account (channel) info from an off-chain client.CosmosOrchestrationAccountKit
's exo state. The ChainAddress will be the same, but the full address strings will contain new channelIDs. This is tech debt being taken on until story: developers can observe the progress of their ICA transactions #9066.MsgChanCloseInit
for ICA and Transfer channelsSecurity Considerations
n/a
Scaling Considerations
n/a
Documentation Considerations
n/a
Testing Considerations
This PR includes high fidelity tests with simulated chains.
Upgrade Considerations
n/a