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

Support for bidirectional routers #1958

Merged
merged 23 commits into from
Aug 14, 2024
Merged

Support for bidirectional routers #1958

merged 23 commits into from
Aug 14, 2024

Conversation

lemunozm
Copy link
Contributor

@lemunozm lemunozm commented Aug 12, 2024

Description

Support configuring routers for inbound and outbound directions, based on a RouterId that identify it for both directions

Main changes of this PR:

  • Added pallet-axelar-router which connects in both directions with Axelar. It allows the configuration of different domains under Axelar for inbound and outbound messages. It is a mix of axelar-gateway-preocompile and routers/axelar_evm which will be removed.

  • Added RouterId. It is like Domain but with information about by where the message needs to be sent.

  • Added MessageSender trait and MessageReceiver. The middleware parameter represents by where the message must be sent. Normally, it will be the RouterId but not mandatory, it could be any subset of RouterId, i.e: AxelarId.

  • Added a RouterSupport trait (name can change), to allow mapping any Domain in a list of supported routers that can lead the message to that Domain. Will be used by the gateway to obtain the RouterId list for a Domain.

  • Added RouterDispatcher in runtime level to redirect a message to the correct router_id.

Use case we want to support

Suppose gateway is configured with the following (dynamically configured by an operator):

  • AxelarXcm
  • AxelarEvm
  • SnowbridgeEvm

And the chain offers the following routers (statically configured in the runtime):

  • AxelarXcm
  • AxelarEvm
  • SnowbridgeEvm
  • OtherEvm

If a message with Domain::Evm needs to be sent, it must be sent only to AxelarEvm and SnowbridgeEvm.

  • AxelarXcm will not used because that router is not retrieved by for_domain(Domain::Evm)
  • OtherEvm will not used because it's not configured in the gateway

@lemunozm lemunozm added the I6-refactoring Code needs refactoring. label Aug 12, 2024
@lemunozm lemunozm requested a review from cdamian August 12, 2024 14:55
@lemunozm lemunozm self-assigned this Aug 12, 2024
@lemunozm lemunozm force-pushed the ft/pallet-axelar-router branch from ade0460 to 329c861 Compare August 12, 2024 15:45
Copy link
Contributor

@wischli wischli left a comment

Choose a reason for hiding this comment

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

Overall, the design looks really good! I am mostly curious on how to extend this to support message relaying, see my long comment.

libs/traits/src/liquidity_pools.rs Outdated Show resolved Hide resolved
pallets/axelar-router/src/lib.rs Outdated Show resolved Hide resolved
pallets/axelar-router/src/lib.rs Outdated Show resolved Hide resolved
runtime/common/src/routing.rs Show resolved Hide resolved
@cdamian
Copy link
Contributor

cdamian commented Aug 12, 2024

I like how this is implemented, thank you for taking care @lemunozm!

Copy link
Contributor Author

@lemunozm lemunozm left a comment

Choose a reason for hiding this comment

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

List of pendings todos

pallets/axelar-router/src/tests.rs Outdated Show resolved Hide resolved
pallets/liquidity-pools-gateway/src/tests.rs Show resolved Hide resolved
runtime/integration-tests/src/cases.rs Outdated Show resolved Hide resolved
runtime/integration-tests/src/cases.rs Outdated Show resolved Hide resolved
@lemunozm lemunozm force-pushed the ft/pallet-axelar-router branch from c4423aa to 88c6558 Compare August 13, 2024 08:51
@lemunozm lemunozm marked this pull request as ready for review August 13, 2024 08:51
@lemunozm
Copy link
Contributor Author

If nothing wrong CI should be green with the commented sections in the code

@lemunozm lemunozm changed the title Support for bidirectional and multiple routers Support for bidirectional routers Aug 13, 2024
Copy link

codecov bot commented Aug 13, 2024

Codecov Report

Attention: Patch coverage is 50.81967% with 60 lines in your changes missing coverage. Please review.

Project coverage is 47.63%. Comparing base (3def5e9) to head (a59c6aa).

Files Patch % Lines
pallets/axelar-router/src/lib.rs 72.22% 20 Missing ⚠️
pallets/liquidity-pools-gateway/src/lib.rs 0.00% 15 Missing ⚠️
runtime/common/src/routing.rs 0.00% 15 Missing ⚠️
libs/mocks/src/router_message.rs 62.50% 3 Missing ⚠️
runtime/altair/src/lib.rs 0.00% 2 Missing ⚠️
runtime/centrifuge/src/lib.rs 0.00% 2 Missing ⚠️
runtime/development/src/lib.rs 0.00% 2 Missing ⚠️
runtime/common/src/gateway.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1958      +/-   ##
==========================================
- Coverage   48.11%   47.63%   -0.48%     
==========================================
  Files         183      183              
  Lines       12926    12904      -22     
==========================================
- Hits         6219     6147      -72     
- Misses       6707     6757      +50     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lemunozm lemunozm force-pushed the ft/pallet-axelar-router branch from 6c1b30f to a59c6aa Compare August 13, 2024 21:45
Copy link
Contributor

@wischli wischli left a comment

Choose a reason for hiding this comment

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

Super straight-forward and clear - awesome work! A few nits and one question regarding a test.

pallets/axelar-router/src/lib.rs Show resolved Hide resolved
pallets/liquidity-pools-gateway/src/lib.rs Show resolved Hide resolved
pallets/liquidity-pools-gateway/src/lib.rs Show resolved Hide resolved
pallets/liquidity-pools-gateway/src/lib.rs Show resolved Hide resolved
pallets/liquidity-pools-gateway/src/lib.rs Show resolved Hide resolved
pallets/liquidity-pools-gateway/src/lib.rs Show resolved Hide resolved
runtime/common/src/routing.rs Outdated Show resolved Hide resolved
runtime/integration-tests/src/cases.rs Show resolved Hide resolved
Copy link
Contributor

@wischli wischli left a comment

Choose a reason for hiding this comment

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

LS(uper)M(ega)GTM!

Copy link
Contributor

@cdamian cdamian left a comment

Choose a reason for hiding this comment

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

The multi router PR is based on this and I'm super happy with everything so far.

Awesome job @lemunozm!

@lemunozm
Copy link
Contributor Author

Thanks for your reviews! Should be merged once CI passes 🤞🏻

@lemunozm lemunozm enabled auto-merge (squash) August 14, 2024 10:32
@lemunozm lemunozm merged commit 0d29d17 into main Aug 14, 2024
9 of 14 checks passed
@wischli wischli mentioned this pull request Aug 15, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I6-refactoring Code needs refactoring.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants