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

Cosmos grpc fallbackprovider #3139

Merged
merged 24 commits into from
Feb 5, 2024
Merged

Cosmos grpc fallbackprovider #3139

merged 24 commits into from
Feb 5, 2024

Conversation

daniel-savu
Copy link
Contributor

@daniel-savu daniel-savu commented Jan 9, 2024

Description

Implements grpc fallback provider logic for cosmos

  • initially tried implementing the fallback provider deprioritization logic at middleware level like in the EVM. The difference between ethers and cosmrs is that in the latter, middleware can only live at the transport layer (tower crate level).
    • based on this github issue, that actually doesn't look possible, because the http::Request type isn't Clone so it can't be submitted to multiple providers
  • ended up implementing the fallback provider at the application layer, by keeping an array of grpc channels
    • There is now a call method in hyperlane_core::FallbackProvider which I'm actually really happy with. This method handles the fallbackprovider-specific logic by taking in an async closure, running it on each provider, and iterating providers if the closure call fails. In grpc.rs you can see how this is slightly verbose but I think it's quite manageable. The only part that bugs me is having to duplicate Pin::from(Box::from(future)), but that's need afaict because the regular closure returns an anonymous type
  • adds grpcUrls and customGrpcUrls config items
  • tests the cosmos fallback provider e2e

Drive-by changes

Related issues

Backward compatibility

Testing

Copy link

changeset-bot bot commented Jan 9, 2024

⚠️ No Changeset found

Latest commit: ffa787f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

codecov bot commented Jan 28, 2024

Codecov Report

Merging #3139 (ffa787f) into main (8bfa8c1) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3139   +/-   ##
=======================================
  Coverage   67.65%   67.65%           
=======================================
  Files          99       99           
  Lines        1014     1014           
  Branches      106      106           
=======================================
  Hits          686      686           
  Misses        284      284           
  Partials       44       44           
Components Coverage Δ
core 50.00% <ø> (ø)
hooks 68.79% <ø> (ø)
isms 65.94% <ø> (ø)
token 58.41% <ø> (ø)
middlewares 81.46% <ø> (ø)

@daniel-savu daniel-savu changed the title WIP Cosmos fallbackprovider Cosmos fallbackprovider Jan 30, 2024
@daniel-savu daniel-savu marked this pull request as ready for review January 30, 2024 14:58
@daniel-savu daniel-savu requested a review from tkporter as a code owner January 30, 2024 14:58
@daniel-savu daniel-savu force-pushed the dan/cosmos-fallbackprovider branch from fc876ff to 22cbb09 Compare January 30, 2024 18:07
@daniel-savu daniel-savu changed the title Cosmos fallbackprovider Cosmos grpc fallbackprovider Jan 31, 2024
Copy link
Collaborator

@tkporter tkporter 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 thing I think we should definitely change is the GCP secret stuff

rust/chains/hyperlane-ethereum/Cargo.toml Outdated Show resolved Hide resolved
rust/chains/hyperlane-ethereum/src/rpc_clients/fallback.rs Outdated Show resolved Hide resolved
rust/helm/hyperlane-agent/templates/external-secret.yaml Outdated Show resolved Hide resolved
typescript/sdk/src/metadata/chainMetadataTypes.ts Outdated Show resolved Hide resolved
@daniel-savu daniel-savu enabled auto-merge (squash) February 5, 2024 18:40
@daniel-savu daniel-savu merged commit f2a0e92 into main Feb 5, 2024
20 of 26 checks passed
@daniel-savu daniel-savu deleted the dan/cosmos-fallbackprovider branch February 5, 2024 19:11
ltyu pushed a commit to ltyu/hyperlane-monorepo that referenced this pull request Mar 13, 2024
### Description

Implements grpc fallback provider logic for cosmos

- initially tried implementing the fallback provider deprioritization
logic at middleware level like in the EVM. The difference between ethers
and cosmrs is that in the latter, middleware can only live at the
transport layer (`tower` crate level).
- based on this github
[issue](hyperium/tonic#733), that actually
doesn't look possible, because the http::Request type isn't `Clone` so
it can't be submitted to multiple providers
- ended up implementing the fallback provider at the application layer,
by keeping an array of grpc channels
- There is now a `call` method in `hyperlane_core::FallbackProvider`
which I'm actually really happy with. This method handles the
fallbackprovider-specific logic by taking in an async closure, running
it on each provider, and iterating providers if the closure call fails.
In `grpc.rs` you can see how this is slightly verbose but I think it's
quite manageable. The only part that bugs me is having to duplicate
`Pin::from(Box::from(future))`, but that's need afaict because the
regular closure returns an anonymous type
- adds `grpcUrls` and `customGrpcUrls` config items
- tests the cosmos fallback provider e2e

### Drive-by changes

<!--
Are there any minor or drive-by changes also included?
-->

### Related issues

- Fixes: hyperlane-xyz/issues#998

### Backward compatibility

<!--
Are these changes backward compatible? Are there any infrastructure
implications, e.g. changes that would prohibit deploying older commits
using this infra tooling?

Yes/No
-->

### Testing

<!--
What kind of testing have these changes undergone?

None/Manual/Unit Tests
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants