cosmology-tech / starship

A k8s based unified development environment for Cosmos Ecosystem (and beyond)
https://docs.cosmology.zone/starship
MIT License
74 stars 24 forks source link

Registry reports wrong connection_id #546

Open Buckram123 opened 1 month ago

Buckram123 commented 1 month ago

I have a config with 4 chains and 3 relayers between them and /ibc/{chain_1}/{chain_2} request returns incorrect connection id randomly. For reproduction here's the config I'm using:

chains:
  - id: juno-1
    name: juno
    numValidators: 1
    ports:
      rest: 1313
      rpc: 26653
      grpc: 30658
      faucet: 8000
  - id: junotwo-1
    name: juno
    numValidators: 1
    ports:
      rest: 1317
      rpc: 26659
      grpc: 30660
      faucet: 8004
  - id: junothree-1
    name: juno
    numValidators: 1
    ports:
      rest: 1323
      rpc: 26657
      grpc: 30657
      faucet: 8001
  - id: junofour-1
    name: juno
    numValidators: 1
    ports:
      rest: 1328
      rpc: 26658
      grpc: 30659
      faucet: 8003

relayers:
  - name: juno-juno2
    type: hermes
    replicas: 1
    chains:
      - juno-1
      - junotwo-1
    config:
      event_source:
        mode: "pull"
  - name: juno2-juno3
    type: hermes
    replicas: 1
    chains:
      - junotwo-1
      - junothree-1
    config:
      event_source:
        mode: "pull"
  - name: juno3-juno4
    type: hermes
    replicas: 1
    chains:
      - junothree-1
      - junofour-1
    config:
      event_source:
        mode: "pull"

registry:
  enabled: true
  ports:
    rest: 8081

When it's running I create one channel betwenn each of them:

kubectl exec hermes-juno-juno2-0 -- hermes create channel --order unordered --a-chain juno-1 --a-connection connection-0 --a-port  transfer --b-port transfer
kubectl exec hermes-juno2-juno3-0 -- hermes create channel --order unordered --a-chain junotwo-1 --a-connection connection-0 --a-port  transfer --b-port transfer
kubectl exec hermes-juno3-juno4-0 -- hermes create channel --order unordered --a-chain junothree-1 --a-connection connection-0 --a-port  transfer --b-port transfer

After that I'm doing couple of GET requests to get connection_id between chains:

$ curl -s GET 'http://localhost:8081/ibc/juno-1/junotwo-1' | jq ".chain_1.connection_id" && curl -s GET 'http://localhost:8081/ibc/junotwo-1/junothree-1' | jq ".chain_1.connection_id" && curl -s GET 'http://localhost:8081/ibc/junothree-1/junofour-1' | jq ".chain_1.connection_id"
"connection-0"
"connection-0"
"connection-0"

If you repeat running this command eventually you will get something like that instead of correct result:

"connection-0"
"connection-0"
"connection-1"

Where one of the connection ids incorrect.

Why it's bad: We use this endpoint to determine command for opening channels in hermes and when incorrect connection_id passed inside hermes it errors that it does not have config for the chain_b

Anmol1696 commented 1 month ago

Ahh i think this is cuz there can be multiple connections between the chains, maybe some are not active or invalid even. This is a good bug to report thanks.

I think issue could be here: https://github.com/cosmology-tech/starship/blob/main/starship/registry/chain.go#L247 Maybe we need to update the way we fetch connection information between the chains

Buckram123 commented 1 month ago

Ahh i think this is cuz there can be multiple connections between the chains, maybe some are not active or invalid even. This is a good bug to report thanks.

I think issue could be here: https://github.com/cosmology-tech/starship/blob/main/starship/registry/chain.go#L247 Maybe we need to update the way we fetch connection information between the chains

Great, thanks for active maintaining of this awesome tool!

Yeah it seems like connection_id just swaps on ibc/chain1/chain2 (in case of incorrect result), so:

For some time and then it gets back to normal until flips again. Can't say for sure tho, as I only observed the results