Skip to content

improvement(tendermint): safer IBC channel handler#2298

Merged
shamardy merged 15 commits intodevfrom
safer-ibc
May 5, 2025
Merged

improvement(tendermint): safer IBC channel handler#2298
shamardy merged 15 commits intodevfrom
safer-ibc

Conversation

@onur-ozkan
Copy link
Copy Markdown

@onur-ozkan onur-ozkan commented Dec 18, 2024

This change removes the logic that parses the chain-registry repository to find IBC channels, as that approach often included outdated or unreliable information. Instead, with this PR, we embed only a highly reliable and trusted IBC channels into our coins file. KDF will now look the coins file to find the channel ID and validate it (for now it only checks if channel is available). If it can't find the channel in coins file, it will return an error:
IBC channel could not be found in the coins file for $address. Please provide it manually by including ibc_source_channel in the request. See https://ibc.iobscan.io/channels for reference.

Example of ibc_channels usage in coins file:

{
  "coin":"IRIS",
  "avg_blocktime": 5,
  "protocol":{
    "type":"TENDERMINT",
    "protocol_data":{
      "decimals":6,
      "denom":"uiris",
      "account_prefix":"iaa",
      "chain_id":"irishub-1",
      "ibc_channels": {
          "cosmos": 0
      }
    }
  }
},
{
  "coin": "ATOM",
  "avg_blocktime": 7,
  "name": "cosmos",
  "fname": "Cosmos",
  "mm2": 1,
  "protocol": {
    "type": "TENDERMINT",
    "protocol_data": {
      "decimals": 6,
      "denom": "uatom",
      "account_prefix": "cosmos",
      "chain_id": "cosmoshub-4",
      "ibc_channels": {
          "iaa": 91
      }
    }
  }
}

The ibc_channels fields above allow KDF to determine the IRIS channel from ATOM and the ATOM channel from IRIS during IBC operations. The list of IDs can be extended to support fallback strategies (e.g., from "iaa": [91, $some_other_ID] KDF will try to use $some_other_ID when 91 isn't healhty/available), and the list of address prefixes can also be expanded to discover IBC channels on other networks without any limitation on all Tendermint assets. https://ibc.iobscan.io/channels should be used for finding most reliable channels for the Tendermint assets in coins file.

Note: We need to update coins file before merging this (PR is up), otherwise IBC operations will not work if ibc_source_channel isn't provided manually.

Please be aware of these breaking changes (cc @KomodoPlatform/gui):

Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Comment on lines -247 to -248
"ibc_chains" => handle_mmrpc(ctx, request, ibc_chains).await,
"ibc_transfer_channels" => handle_mmrpc(ctx, request, ibc_transfer_channels).await,
Copy link
Copy Markdown
Author

@onur-ozkan onur-ozkan Apr 7, 2025

Choose a reason for hiding this comment

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

Breakage 1: I am confident enough to say that none of our clients are using these. 😄

Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
memo: Option<String>,
/// Tendermint specific field used for manually providing the IBC channel IDs.
ibc_source_channel: Option<String>,
ibc_source_channel: Option<ChannelId>,
Copy link
Copy Markdown
Author

@onur-ozkan onur-ozkan Apr 9, 2025

Choose a reason for hiding this comment

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

Breakage 2: This now expects a numeric value (previously it accepted any String value without validation by hoping it was using in the channel-$id format) to align with the logic used in the coins file.

@onur-ozkan onur-ozkan changed the title improvement(tendermint): robust IBC channel handling improvement(tendermint): safer IBC channel handling Apr 9, 2025
Signed-off-by: onur-ozkan <work@onurozkan.dev>
@onur-ozkan onur-ozkan changed the title improvement(tendermint): safer IBC channel handling improvement(tendermint): safer IBC channel handler Apr 10, 2025
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Copy link
Copy Markdown

@borngraced borngraced left a comment

Choose a reason for hiding this comment

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

Well done. I have a note and a question

Copy link
Copy Markdown

@laruh laruh left a comment

Choose a reason for hiding this comment

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

Looks good in general, I have small notes

Signed-off-by: onur-ozkan <work@onurozkan.dev>
borngraced
borngraced previously approved these changes Apr 16, 2025
laruh
laruh previously approved these changes Apr 16, 2025
Copy link
Copy Markdown

@laruh laruh left a comment

Choose a reason for hiding this comment

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

LGTM!

shamardy
shamardy previously approved these changes Apr 17, 2025
Copy link
Copy Markdown
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

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

LGTM! Only a nit! Does this need testing first or can be tested in dev?

Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Copy link
Copy Markdown
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

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

Awaiting 2.4.0-beta release to merge this.

@onur-ozkan
Copy link
Copy Markdown
Author

I assume we can land this now?

@shamardy shamardy merged commit bccdb93 into dev May 5, 2025
21 of 24 checks passed
@shamardy shamardy deleted the safer-ibc branch May 5, 2025 16:15
@shamardy
Copy link
Copy Markdown
Collaborator

shamardy commented May 5, 2025

@onur-ozkan @smk762 is the docs issue or PR already opened for these changes, if not, this is just a reminder.

Edit: Nevermind, found docs and coins issues/PRs mentioned

dimxy pushed a commit to dimxy/komodo-defi-framework that referenced this pull request May 13, 2025
* dev: (26 commits)
  chore(deps): remove base58 and replace it completely with bs58 (GLEECBTC#2427)
  feat(tron): initial groundwork for full TRON integration (GLEECBTC#2425)
  fix(UTXO): improve tx fee calculation and min relay fee handling (GLEECBTC#2316)
  deps(timed-map): bump to 1.3.1 (GLEECBTC#2413)
  improvement(tendermint): safer IBC channel handler (GLEECBTC#2298)
  chore(release): complete v2.4.0-beta changelogs  (GLEECBTC#2436)
  fix(event-streaming): initial addresses registration in utxo balance streaming (GLEECBTC#2431)
  improvement(watchers): re-write use-watchers handling (GLEECBTC#2430)
  fix(evm): make withdraw_nft work in HD mode (GLEECBTC#2424)
  feat(taproot): support parsing taproot output address types
  chore(RPC): use consistent param name for QTUM delegation (GLEECBTC#2419)
  fix(makerbot): add LiveCoinWatch price provider (GLEECBTC#2416)
  chore(release): add changelog entries for v2.4.0-beta (GLEECBTC#2415)
  fix(wallets): prevent path traversal in `wallet_file_path` and update file extension (GLEECBTC#2400)
  fix(nft): make `update_nft` work with hd wallets using the enabled address (GLEECBTC#2386)
  fix(wasm): unify error handling for mm2_main (GLEECBTC#2389)
  fix(tx-history): token information and query (GLEECBTC#2404)
  test(electrums): fix failing test_one_unavailable_electrum_proto_version (GLEECBTC#2412)
  improvement(network): remove static IPs from seed lists (GLEECBTC#2407)
  improvement(best-orders): return an rpc error when we can't find best orders (GLEECBTC#2318)
  ...
dimxy pushed a commit that referenced this pull request May 28, 2025
* dev: (29 commits)
  fix(p2pk): validate expected pubkey correctly for p2pk inputs (#2408)
  chore(docs): update old urls referencing atomicdex or old docs pages (#2428)
  improvement(p2p): remove hardcoded seeds (#2439)
  fix(evm-api): find enabled erc20 token using platform ticker (#2445)
  chore(docs): add DeepWiki badge to README (#2463)
  chore(core): organize deps using workspace.dependencies (#2449)
  feat(db-arch): more dbdir to address_dir replacements (#2398)
  chore(build-artifacts): remove duplicated mm2 build artifacts (#2448)
  feat(pubkey-banning): expirable bans (#2455)
  fix(eth-balance-events): serialize eth address using AddrToString (#2440)
  chore(deps): remove base58 and replace it completely with bs58 (#2427)
  feat(tron): initial groundwork for full TRON integration (#2425)
  fix(UTXO): improve tx fee calculation and min relay fee handling (#2316)
  deps(timed-map): bump to 1.3.1 (#2413)
  improvement(tendermint): safer IBC channel handler (#2298)
  chore(release): complete v2.4.0-beta changelogs  (#2436)
  fix(event-streaming): initial addresses registration in utxo balance streaming (#2431)
  improvement(watchers): re-write use-watchers handling (#2430)
  fix(evm): make withdraw_nft work in HD mode (#2424)
  feat(taproot): support parsing taproot output address types
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants