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

feat: added a cosmos-to-cosmos relayer module with basic tests #170

Merged
merged 30 commits into from
Dec 13, 2024

Conversation

srdtrk
Copy link
Member

@srdtrk srdtrk commented Dec 12, 2024

Description

closes: #153


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Linked to GitHub issue with discussion and accepted design, OR link to spec that describes this work.
  • Wrote unit and integration tests.
  • Added relevant natspec and godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

Copy link

codecov bot commented Dec 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.83%. Comparing base (8bf9e5c) to head (519a72c).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #170   +/-   ##
=======================================
  Coverage   96.83%   96.83%           
=======================================
  Files          11       11           
  Lines         537      537           
=======================================
  Hits          520      520           
  Misses         17       17           

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

@srdtrk srdtrk changed the title feat: added a cosmos-to-cosmos relayer module (only chain info) feat: added a cosmos-to-cosmos relayer module with basic tests Dec 13, 2024
@srdtrk srdtrk marked this pull request as ready for review December 13, 2024 10:20
Copy link
Contributor

@gjermundgaraba gjermundgaraba left a comment

Choose a reason for hiding this comment

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

Looks mostly good to me! I think we can clean up the long functions a bit to make them more readable.

e2e/interchaintestv8/cosmos_relayer_test.go Outdated Show resolved Hide resolved
e2e/interchaintestv8/ibc_eureka_test.go Show resolved Hide resolved
packages/relayer-lib/src/tx_builder/cosmos_to_cosmos.rs Outdated Show resolved Hide resolved
})
.map(|e| async {
match e {
EurekaEvent::SendPacket(se) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

To make this a bit more readable and less indented, I think it might make sense to pull out the event handling into a separate function like handle_send_packet_timeout or something like more precise if you prefer.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this whole function is too long. I will refactor this once it is actually working. No need to create an issue I think since I wouldn't forget this as it is very annoying.

Copy link
Member Author

Choose a reason for hiding this comment

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

created an issue #173

let _recv_msgs = future::try_join_all(src_send_events.into_iter().map(|e| async {
match e {
EurekaEvent::SendPacket(se) => {
let ibc_path = se.packet.commitment_path();
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, I think it would be nice to pull this into a separate function

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this whole function is too long. I will refactor this once it is actually working. No need to create an issue I think since I wouldn't forget this as it is very annoying.

Copy link
Member Author

Choose a reason for hiding this comment

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

created an issue #173

let _ack_msgs = future::try_join_all(src_ack_events.into_iter().map(|e| async {
match e {
EurekaEvent::WriteAcknowledgement(we) => {
let ibc_path = we.packet.ack_commitment_path();
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto here

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this whole function is too long. I will refactor this once it is actually working. No need to create an issue I think since I wouldn't forget this as it is very annoying.

Copy link
Member Author

Choose a reason for hiding this comment

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

created an issue #173

#[async_trait::async_trait]
impl TxBuilderService<CosmosSdk, CosmosSdk> for TxBuilder {
#[allow(clippy::too_many_lines)]
async fn relay_events(
Copy link
Contributor

Choose a reason for hiding this comment

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

In general, I think this function should be split up more. I would say separate functions for each type of tx, or potentially target vs src events you are looking for + each event handling.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should also be done for eth_eureka, probably, but you could do that in a separate PR if you prefer.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this whole function is too long. I will refactor this once it is actually working. I can create an issue for this

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Great, thanks!

.chain_id()
.await
.map_err(|e| tonic::Status::from_error(e.to_string().into()))?,
ibc_version: "2".to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we only support version 2, do we have any checks anywhere to fail during setup if version 1 comes in?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure what I wanna do with this field. Can remove if you'd like

@@ -100,7 +99,7 @@ impl RelayerService for CosmosToEthRelayerModuleServer {
.await
.map_err(|e| tonic::Status::from_error(e.to_string().into()))?,
ibc_version: "2".to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this also be like an enum or number or something? Feels a bit strange to use a string for this

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this interface isn't finalized enough yet to warrant an enum. Might even fully remove it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, makes sense. When things are a bit more finalized, we can do a review again of the whole thing to make sure we don't miss stuff like this 👍

@gjermundgaraba
Copy link
Contributor

LGTM! 🚀

@srdtrk srdtrk merged commit 5eb7b03 into main Dec 13, 2024
54 checks passed
@srdtrk srdtrk deleted the serdar/153-cosmos-to-cosmos branch December 13, 2024 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a Cosmos to Cosmos relayer module with only with chain info
2 participants