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: add ethereum to cosmos relayer module #190

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

gjermundgaraba
Copy link
Contributor

Description

closes: #152


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.

@gjermundgaraba gjermundgaraba linked an issue Dec 30, 2024 that may be closed by this pull request
Copy link

codecov bot commented Dec 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.97%. Comparing base (b77c838) to head (747464b).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #190   +/-   ##
=======================================
  Coverage   96.97%   96.97%           
=======================================
  Files          11       11           
  Lines         562      562           
=======================================
  Hits          545      545           
  Misses         17       17           

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

@gjermundgaraba gjermundgaraba marked this pull request as ready for review December 31, 2024 00:23
@@ -27,6 +27,8 @@ broadcast/*/31337/
target
elf
artifacts
bacon.toml
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A bit unrelated, but added these since I am experimenting with running bacon-ls as a wrapper for rust-analyzer to improve incremental compilation.

@@ -82,13 +86,17 @@ ibc-core-commitment-types = { version = "0.56", default-features = false }
ibc-core-handler-types = { version = "0.56", default-features = false }
ibc-client-tendermint-types = { version = "0.56", default-features = false }

alloy = { version = "0.8", default-features = false }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can discuss this, but I just felt it was a bit much to depend on the whole thing, when we can just pick and choose the bits we need.

Copy link
Member

Choose a reason for hiding this comment

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

This was not being used on contracts or on chain logic. So, here, readability is more important than picking an choosing. Many of the example codes from alloy also doesn't pick and choose.

So I'd prefer if we only picked and chose in wasm contracts or sp1-programs.


// TODO: Remove when we have removed manual relaying and moved to
// common relaying methods that can choose the correct methods
func (s *TestSuite) SkipIfEthTestnetType(testnetType string) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not all the e2e relaying tests work with both pow and pos, so added this for now.
I think it might make sense to get rid of the manual relaying in go and switch to the relayer now, but we can still have the relayer calls behind some functions that can handle the different testnet types - and then we can remove this method.

If we agree on this, I'll create an issue to remove the manual relaying and consolidate relaying in the e2e tests.

Copy link
Member

Choose a reason for hiding this comment

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

I think you should add a mock option in the relayer config so that we don't need to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I still think consolidation the tests would be useful, because I don't want to maintain the manual relayer and a bunch of extra tests if we don't have to. If we can just test everything together it would mean quite a bit less code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But I do like the mock option a lot! :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

packages/ethereum/tree_hash/src/impls.rs Show resolved Hide resolved
Copy link
Member

@srdtrk srdtrk left a comment

Choose a reason for hiding this comment

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

Looks very good. I think you should be very familiar with the relayer now. I have a couple suggestions and questions, so I will approve once those are resolved. And I have a few requests as well:

  • Can you update config.example.json with the new module.
  • Can you update the README.md for the relayer.

@@ -82,13 +86,17 @@ ibc-core-commitment-types = { version = "0.56", default-features = false }
ibc-core-handler-types = { version = "0.56", default-features = false }
ibc-client-tendermint-types = { version = "0.56", default-features = false }

alloy = { version = "0.8", default-features = false }
Copy link
Member

Choose a reason for hiding this comment

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

This was not being used on contracts or on chain logic. So, here, readability is more important than picking an choosing. Many of the example codes from alloy also doesn't pick and choose.

So I'd prefer if we only picked and chose in wasm contracts or sp1-programs.


// TODO: Remove when we have removed manual relaying and moved to
// common relaying methods that can choose the correct methods
func (s *TestSuite) SkipIfEthTestnetType(testnetType string) {
Copy link
Member

Choose a reason for hiding this comment

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

I think you should add a mock option in the relayer config so that we don't need to do this.

"os"
"text/template"
)

// EthToCosmosConfigInfo is a struct that holds the configuration information for the Ethereum to Cosmos config template
type EthToCosmosConfigInfo struct {
type EthCosmosConfigInfo struct {
Copy link
Member

Choose a reason for hiding this comment

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

In order to support mock wasm contract, perhaps we can add a new field?

Comment on lines 72 to 75
beaconAPI := ""
if eth.BeaconAPIClient != nil {
beaconAPI = eth.BeaconAPIClient.GetBeaconAPIURL()
}
Copy link
Member

Choose a reason for hiding this comment

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

This is here because of the pow vs. pos tests right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is correct. I'll add comment.

@@ -299,6 +331,7 @@ func (s *RelayerTestSuite) Test_5_BatchedAckPacketToEth_Plonk() {
func (s *RelayerTestSuite) ICS20TransferERC20TokenBatchedAckTest(
ctx context.Context, proofType operator.SupportedProofType, numOfTransfers int,
) {
s.SkipIfEthTestnetType(testvalues.EthTestnetTypePoS)
Copy link
Member

Choose a reason for hiding this comment

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

Can we create an issue to remove these? I think we can do this my adding a hidden mock option to the relayer module?

It would be good to do this in this PR but I understand if you want to create a separate issue for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I did want to get rid of them, I'll create a placeholder issue for it and with needs-discussion until we decide on the approach. A mock option seems like a good idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Create an issue. I also realized we don't actually have to consolidate the e2e tests at the same time as we fix this, so that issue should be ready to go: #192

let mut headers = vec![];
let mut trusted_slot = ethereum_consensus_state.slot;
let mut prev_pub_agg_key = BlsPublicKey::default();
for update in &light_client_updates {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if this for loop can be done with futures fold instead but this looks good for now

Comment on lines -21 to +22
alloy = { workspace = true, features = ["full", "node-bindings"] }
alloy-network = { workspace = true }
alloy-signer-local = { workspace = true }
Copy link
Member

Choose a reason for hiding this comment

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

This is fine since this is a util library

Comment on lines -24 to +27
alloy = { workspace = true, features = ["full", "node-bindings"] }
alloy-primitives = { workspace = true }
alloy-provider = { workspace = true, features = ["reqwest"] }
alloy-network = { workspace = true }
alloy-transport = { workspace = true }
Copy link
Member

Choose a reason for hiding this comment

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

This is not needed since this compiles to an executable anyway (no on chain logic).

Comment on lines 121 to 122
tracing::info!("Got {} source_tx_ids", inner_req.source_tx_ids.len());
tracing::info!("Got {} timeout_tx_ids", inner_req.timeout_tx_ids.len());
Copy link
Member

Choose a reason for hiding this comment

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

does this format match our logs in other relayer modules? It would be nice to use the same format

Copy link
Contributor Author

Choose a reason for hiding this comment

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

More or less, but the other ones didn't have this logging, so changing them a little and adding it to those as well for consistency.

/// The configuration for the Cosmos to Cosmos relayer module.
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
#[allow(clippy::module_name_repetitions)]
pub struct EthToCosmosConfig {
Copy link
Member

Choose a reason for hiding this comment

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

We can add a mock field here (which we allow to be absent in the actual config file and defaults to false)

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 Ethereum to Cosmos relayer module
2 participants