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

Serve a single endpoint for all modules #224

Closed
gjermundgaraba opened this issue Jan 17, 2025 · 4 comments · Fixed by #279
Closed

Serve a single endpoint for all modules #224

gjermundgaraba opened this issue Jan 17, 2025 · 4 comments · Fixed by #279
Assignees
Labels
enhancement Improvements needs discussion This issue needs more discussion before its implementation relayer Issues related to the relayer

Comments

@gjermundgaraba
Copy link
Contributor

gjermundgaraba commented Jan 17, 2025

Implement a unified endpoint for all configured modules that is able to route to the correct module without having to configure and find the correct ports and module names. The API should be expressive enough to input intuitive values that should make it as easy to use as possible.

Current proposal would entail the changes below (see comments in this issue for more context):

{
  "server": {
    "log_level": "info",
    "address": "127.0.0.1"
  },
  "modules": [
    {
      "name": "cosmos_to_eth",
-      "port": 3000,
+      "src_chain": "cosmoshub-4",
+.     "dst_chain": "eth-1",
      "config": {
        "tm_rpc_url": "http://public-celestia-mocha4-consensus.numia.xyz/",
        "ics26_address": "0x1234567890abcdef1234567890abcdef",
        "eth_rpc_url": "https://ethereum-holesky-rpc.publicnode.com",
        "sp1_private_key": "0x1234567890abcdef1234567890abcdef"
      }
    },
    {
      "name": "eth_to_cosmos",
-      "port": 3001,
+      "src_chain": "eth-1",
+.     "dst_chain": "cosmoshub-4",
      "config": {
        "tm_rpc_url": "http://public-celestia-mocha4-consensus.numia.xyz/",
        "ics26_address": "0x1234567890abcdef1234567890abcdef",
        "eth_rpc_url": "https://ethereum-holesky-rpc.publicnode.com",
        "eth_beacon_api_url": "https://ethereum-holesky-beacon-api.publicnode.com",
        "signer_address": "cosmos1abcdef1234567890abcdef1234567890"
      }
    },
    {
      "name": "cosmos_to_cosmos",
-      "port": 3002,
+      "src_chain": "cosmoshub-4",
+.     "dst_chain": "osmosis-1",
      "config": {
        "src_rpc_url": "https://noble-testnet-rpc.polkachu.com:443",
        "target_rpc_url": "http://public-celestia-mocha5-consensus.numia.xyz/",
        "signer_address": "cosmos1abcdef1234567890abcdef1234567890"
      }
    }
  ]
}

And the relay request would change to:

// The request message
message RelayByTxRequest {
+    // The identifier of the source chain (i.e. chain-id)
+    string src_chain = 1;
+    // The identifier of the destination chain (i.e. chain-id)
+    string dst_chain = 2;
    // The identifiers for the IBC transactions to be relayed
    // This is usually the transaction hash
    repeated bytes source_tx_ids = 3;
    // The identifiers for the IBC transactions on the target chain to be timed out
    repeated bytes timeout_tx_ids = 4;
    // The identifier for the target channel
    // Used for event filtering
    string target_channel_id = 5;
}
@gjermundgaraba gjermundgaraba added needs discussion This issue needs more discussion before its implementation relayer Issues related to the relayer labels Jan 17, 2025
@srdtrk
Copy link
Member

srdtrk commented Jan 21, 2025

Description

The critical design decision that needs to be made here is how the user should identify which module a given request should be routed to. The most natural instinct here is to make use of the chain-ids of the two chains that a given module connects. However, this approach has a couple challenges.

  1. Each module is a single sided relayer. Therefore, to have a complete IBC relayer between two chain's IBC implementations, it takes two modules. Thus, whatever identification scheme we use, it must at least contain two chain id's (source chain-id is not enough)

  2. Multiple modules may connect the same chain or chain pairs. This is because there might be multiple IBC implementations for a single chain such as ibc-go, cosmwasm-ibc, or union-ibc. Therefore, identifying each module with a pair of chain-ids would be a artificial limitation.

Proposal

Since identifying each module seems to introduce certain limitations to the relayer, I think we should leave the identification up to the user. This proposes allowing the user to assign an id to each module (instead of a port) in the config file. This also means that the user would have the freedom to identify each module using chain-ids if they think this limitation is reasonable.

For instance, the example config file would change in the following manner:

{
  "server": {
    "log_level": "info",
    "address": "127.0.0.1"
  },
  "modules": [
    {
      "name": "cosmos_to_eth",
-      "port": 3000,
+      "id": "cosmoshub-4-eth-1"
      "config": {
        "tm_rpc_url": "http://public-celestia-mocha4-consensus.numia.xyz/",
        "ics26_address": "0x1234567890abcdef1234567890abcdef",
        "eth_rpc_url": "https://ethereum-holesky-rpc.publicnode.com",
        "sp1_private_key": "0x1234567890abcdef1234567890abcdef"
      }
    },
    {
      "name": "eth_to_cosmos",
-      "port": 3001,
+      "id": "eth-1-cosmoshub-4"
      "config": {
        "tm_rpc_url": "http://public-celestia-mocha4-consensus.numia.xyz/",
        "ics26_address": "0x1234567890abcdef1234567890abcdef",
        "eth_rpc_url": "https://ethereum-holesky-rpc.publicnode.com",
        "eth_beacon_api_url": "https://ethereum-holesky-beacon-api.publicnode.com",
        "signer_address": "cosmos1abcdef1234567890abcdef1234567890"
      }
    },
    {
      "name": "cosmos_to_cosmos",
-      "port": 3002,
+      "id": "cosmoshub-4-osmosis-1"
      "config": {
        "src_rpc_url": "https://noble-testnet-rpc.polkachu.com:443",
        "target_rpc_url": "http://public-celestia-mocha5-consensus.numia.xyz/",
        "signer_address": "cosmos1abcdef1234567890abcdef1234567890"
      }
    }
  ]
}

And the relay request would change to:

// The request message
message RelayByTxRequest {
+    // The identifier for the relayer module to handle this request
+    string relayer_module_id = 1;
    // The identifiers for the IBC transactions to be relayed
    // This is usually the transaction hash
    repeated bytes source_tx_ids = 2;
    // The identifiers for the IBC transactions on the target chain to be timed out
    repeated bytes timeout_tx_ids = 3;
    // The identifier for the target channel
    // Used for event filtering
    string target_channel_id = 4;
}

@srdtrk srdtrk added the enhancement Improvements label Jan 21, 2025
@gjermundgaraba
Copy link
Contributor Author

gjermundgaraba commented Jan 22, 2025

It is true that it could in theory be multiple implementations of IBC on a single chain, I am not sure it is a limitation we need to worry too much about. Unless we have a clear use case where this is very important, I would not optimize for it, especially not at the cost of user experience.

With an arbitrary ID assigned to the relayer, the user will need to keep a mapping of which chain pairs goes with which ID, which seems unnecessary if that could be simply configured with something like:

modules": [
    {
      "src_chain": "cosmos-hub-4",
      "dst_chain": "eth-1",
      ...

And when you relay, all you need to do is provide those chain ID's which I assume you will have readily available (if not, this argument might not be very strong).

// The request message
message RelayByTxRequest {
    src_chain = 1;
    dst_chain = 2;
    ...
}

At least to me, this feels more intuitive, than even needing to know that they are different modules that are wired up. If the user don't have to know, it seems like it might be better abstraction.


EDIT: Changed from src/dst_chain_id to src/dst_chain after internal discussion.
This allows for a bit more flexibility, as you could just use whatever identifier makes most sense to your own usage (which might just be chain-id, but if you want to use some internal database ID or whatever, you could). It also enables you to target multiple IBC implementations if you would need that.

@srdtrk
Copy link
Member

srdtrk commented Jan 23, 2025

I think this looks good after the edit. Happy to go with this.

@srdtrk srdtrk removed the needs discussion This issue needs more discussion before its implementation label Jan 23, 2025
@srdtrk srdtrk self-assigned this Jan 24, 2025
@gjermundgaraba gjermundgaraba added the needs discussion This issue needs more discussion before its implementation label Feb 12, 2025
@gjermundgaraba
Copy link
Contributor Author

We had a discussion on how adding IBC classic relaying would impact the design, so we need to look at that before we fully implement this, but we should do that asap and get this work started.

@srdtrk srdtrk moved this from Backlog to In progress in IBC-GO Eureka Feb 13, 2025
@srdtrk srdtrk moved this from In progress to In review in IBC-GO Eureka Feb 13, 2025
@github-project-automation github-project-automation bot moved this from In review to Done in IBC-GO Eureka Feb 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvements needs discussion This issue needs more discussion before its implementation relayer Issues related to the relayer
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants