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

getConnectionInfo in the view of the primary chain #9718

Merged
merged 5 commits into from
Jul 15, 2024
Merged

Conversation

turadg
Copy link
Member

@turadg turadg commented Jul 15, 2024

incidental

Description

Motivated by #9712 (comment)

This fixes up ChainHub to return IBCConnectionInfo in the perspective of the directed edge implied by the chain arguments.

The data is the same in either direction, just reversed, so we store it just once. This adds the logic to normalize on save and denormalize on read.

Security Considerations

none

Scaling Considerations

Some extra compute when saving or reading a chain. Low call rate.

Documentation Considerations

none

Testing Considerations

New tests

Upgrade Considerations

Not yet deployed

@turadg turadg requested review from dckc and 0xpatrickdev July 15, 2024 21:35
Copy link

cloudflare-workers-and-pages bot commented Jul 15, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 646243b
Status: ✅  Deploy successful!
Preview URL: https://f0bff9a7.agoric-sdk.pages.dev
Branch Preview URL: https://ta-fix-chainhub.agoric-sdk.pages.dev

View logs

Comment on lines 305 to 306
* @param {string | { chainId: string }} primary
* @param {string | { chainId: string }} counter
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @param {string | { chainId: string }} primary
* @param {string | { chainId: string }} counter
* @param {string | { chainId: string }} primary the primary chain
* @param {string | { chainId: string }} counter the counterparty chain

counter == counterparty may not be immediately obvious

export const ChainInfoShape = M.any();
/** @type {TypedPattern<ChainInfo>} */
export const ChainInfoShape = M.splitRecord({
chainId: M.string(),
Copy link
Member

Choose a reason for hiding this comment

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

Maybe out of scope, but consider including a CosmosChainInfoShape for the second argument here. It seems we might be expecting a certain shape for IBCConnectionInfo.

icqEnabled: M.boolean() and stakingTokens: M.arrayOf({ denom: M.string() }) seem straight forward to incldue as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Out of scope and I think it won't work

@@ -223,38 +293,48 @@ export const makeChainHub = (agoricNames, vowTools) => {
* @param {IBCConnectionInfo} connectionInfo
*/
registerConnection(chainId1, chainId2, connectionInfo) {
const key = connectionKey(chainId1, chainId2);
connectionInfos.init(key, connectionInfo);
const [key, normalized] = normalizeConnectionInfo(
Copy link
Member

Choose a reason for hiding this comment

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

This I am a little confused by - is it necessary for the hotnewchain scenario, since we can't be certain they will give us noramlizedConnInfo? It would seem orchestration-proposal.js has everything normalized already at this point.

I wonder if it's better to throw if chainId1 > chainId2 so the user knows how they need to specify the perspective of connectionInfo. Alternatively, maybe a parameter name change would do the trick.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder if it's better to throw if chainId1 > chainId2 so the user knows how they need to specify the perspective of connectionInfo.

That would not be reliable.

Alternatively, maybe a parameter name change would do the trick.

Agree, I'll improve the docs.

@0xpatrickdev
Copy link
Member

Forgot to attached this to my ✅ -

Approving assuming feedback & CI failure will be addressed. CI failure seems to be due to stale snapshot, now that // FIXME updates redundantly, twice per edge is fixed.

@turadg turadg added the automerge:rebase Automatically rebase updates, then merge label Jul 15, 2024
@turadg turadg force-pushed the ta/fix-chainHub branch from 691fc54 to 646243b Compare July 15, 2024 22:43
@mergify mergify bot merged commit 76f3e6f into master Jul 15, 2024
79 checks passed
@mergify mergify bot deleted the ta/fix-chainHub branch July 15, 2024 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants