Skip to content

Conversation

romac
Copy link
Contributor

@romac romac commented May 17, 2024

Closes: #3940

Running Hermes with multi-hop support

In order to test multi-hop features that have been added in this branch, a chain binary that supports multi-hop channels is required. Feature development and preliminary testing were conducted using the multihop-main branch of Polymer's proof-of-concept multi-hop implementation for ibc-go: https://github.com/polymerdao/ibc-go/tree/polymer/multihop-main

To install the version of Polymer's ibc-go used in the development for this branch:

git clone https://github.com/polymerdao/ibc-go.git polymer-multihop && cd polymer-multihop
git checkout multihop-main
git checkout b5d5877fbe63c187896c5185920a7382340dc30f
make build

The binary for simd will be located in polymer-multihop/build/simd.

* feat: add `--connection-hops` parameter to tx chan-open-init

* Create directory `relayer-types/core/ics33_multihop` for ics33
  definitions

* Define structs `ConnectionHop` and `ConnectionHops`

* Add `connection_hops` field to struct `Channel`

* patch ibc-proto-rs for multihop support

* Add connection hops support to `build_chan_open_init_and_send`

* Enable parsing of multihop `channel_open_init` events

* Add a wrapper struct `ConnectionIds` for Vec<ConnectionId>

* Change `connection_id` type from `ConnectionId` to `ConnectionIds` in
  structs `Attributes`, `OpenInit`, `OpenTry`, `OpenAck`, `OpenConfirm`,
  `CloseInit` and `CloseConfirm`

* Fix clippy warnings

* Apply review suggestions and fix clippy warnings

* Add review suggestions and fix clippy warnings

* Apply suggestions from code review

Co-authored-by: Romain Ruetschi <[email protected]>
Signed-off-by: Joāo Chervinski <[email protected]>

* Change `--connection-hops` type from `Option<Vec<ConnectionId>>` to
`Option<ConnectionIds>`

* Update guide templates

* Fix failing CI tests

* Add tests for tx chan-open-init CLI

* Apply review suggestions

* Add and update FIXMEs

* Replace "/" with "\" for proper line concatenation

* Update guide templates

---------

Signed-off-by: Joāo Chervinski <[email protected]>
Co-authored-by: Romain Ruetschi <[email protected]>
@joaotav joaotav self-assigned this May 17, 2024
@joaotav joaotav added the O: multi-hop Related to ICS 033 Multi-Hop Channel label May 17, 2024
joaotav and others added 27 commits May 29, 2024 17:11
* Add connection hops support to `fn run()`

* Add channel path validation

* Add check to ensure that the channel path specified by the user leads to the expected chain

* Fix oversight that caused `--connection-hops` passed to `tx
  chan-open-init` to be processed in reverse order

* Update guide templates for `tx-chan-open-init`

* Improve error handling in `fn run()` for TxChanOpenTry

* Add `build_multihop_chan_open_try`

* Add validation to ensure counterparty channel end is in INIT state
  before building MsgChannelOpenTry in both single and multihop methods.

* Fix clippy warnings

* Add `connection_hops` field to `ChannelSide`

* Add the `connection_hops` field to struct `ChannelSide`, allowing
  each side of the channel to store their own view of the channel path.

* Remove the `connection_hops` field from struct `Channel`.

* Add `get_global_registry` function to get a `SharedRegistry`

* Add `src_chain_id` and `dst_chain_id` fields to `ConnectionHops`

* Remove `reference_chain_id` field from struct `ConnectionHops` and add
  two new fields, `src_chain_id`, representing the chain where the
  ConnectionId representing the hop lives, and `dst_chain_id`,
  representing the chain the hop leads to.

* Add `update_channel_path_clients()` to struct `Channel`

* Improve `update_channel_path_clients()`

* Add comments for clarity

* Add `Vec<Height>` to the return type of `update_channel_path_clients()` to return heights for subsequent multihop proof queries

* Add `build_update_client_on_last_hop()`

* Add struct `MultihopProofHeights`

* Add `build_multihop_proofs()`

* Fix failing CI tests

* Modify `build_multihop_proofs()` to enable successful `MsgChannelOpenTry`

* Refactor `build_multihop_proofs()` for clarity

* Rename `build_multihop_proofs()` to `build_multihop_channel_proofs()`

* Modify `build_multihop_channel_proofs()` to use iterators instead of indexing to access elements when constructing proofs

* Move struct `MultihopProofHeights` to `relayer-types/src/core/ics33_multihop/proofs.rs`

* Add and improve comments for clarity

* Fix `check-guide` build

* Apply suggestions from code review

Co-authored-by: Romain Ruetschi <[email protected]>
Signed-off-by: Joāo Chervinski <[email protected]>

* Add review suggestions

---------

Signed-off-by: Joāo Chervinski <[email protected]>
Co-authored-by: Romain Ruetschi <[email protected]>
Co-authored-by: Romain Ruetschi <[email protected]>
* Add multihop support for `tx chan-open-ack`

* Replace call to `tx_chan_cmd!` macro with an inline function

* Add `build_multihop_chan_open_ack()`

* Fix failing CI tests

* Replace incorrect call to `build_chan_open_try()` with a call to
  `build_chan_open_ack()` within `do_build_chan_open_ack_and_send()`
  method

* Modify `validated_expected_channel()` to support multiple connection
hops

* Add a more descriptive message to
  `ChannelError::UnexpectedChannelState`

* Improve comments
…4067)

* Fix typo in variable name and add comments

* Add multiple connection hops support to `create channel` command

* Add `--connection-hops` parameter to `CreateChannelCommand`

* Add method `run_multihop_reusing_connection()` to struct
  `CreateChannelCommand`

* Add associated function `new_multihop()` to struct `Channel`

* Update guide templates

* Add unit tests for `-connection-hops` parameter
* Add option to specify connection hops in test-framework init_channel method

* Update Nix flake to include polymer simd with multihop

* Remove unnecessary changes and add test for manual handshake for channel with multihop

* Rename multihop channel test

* Add multihop feature for multihop tests

* Rename client variables in multihop test
* Change `ChannelConnectionClient` with an enum with `SingleHop` and
  `Multihop` variants

* Add structs `ChannelConnectionClientSingleHop` and
  `ChannelConnectionClientMultihop` and new corresponding errors
joaotav and others added 6 commits August 6, 2024 14:25
* Rename variables for consistency
* Add method `is_multihop()` to struct `RelayPath`

* Add frozen client checks to `channel_connection_client()`
* Remove frozen client check from function `channel_connection_client()`
* Add test for a simple transfer on a newly opened multihop channel

* Move multihop IBC transfer inside supervisor block

---------

Co-authored-by: João <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O: multi-hop Related to ICS 033 Multi-Hop Channel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multihop PoC
3 participants