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

Consolidate configs for the EVM chain client for easier external use #12294

Merged
merged 10 commits into from
Mar 13, 2024

Conversation

amit-momin
Copy link
Contributor

  • Created a builder that take in all the configs required to initialize the EVM chain client
  • The input parameters are basic go types to allow easier integrations for external users
  • Moved the EVM client builder method out of the legacyevm package

Copy link
Contributor

github-actions bot commented Mar 5, 2024

I see that you haven't updated any CHANGELOG files. Would it make sense to do so?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Are there plans to reuse this function for Atlas? If not I don't see any point to separate it from chain.go. We should try to avoid the existing pattern we've created with builder files. It's bad for readability and reader has to understand why there are so many files with similar names around.chain.go serves the purpose of a builder file on it's own anyway.

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's the plan and even beyond Atlas hopefully if any other external component needs to eventually integrate. I wanted to minimize the number of imports they would need to do to use our chain client and also didn't want to ask them to import one that has "legacy" in the name if this is a long term solution. I could move this into an existing file but kept it separate thinking a shorter file was better.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not a big fan of adding aliases unless they are needed repeatedly. For example EvmMultiNode is only used once and we introduced a new file and a new alias for the user to remember.

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 was thinking this was ok since it follows the same convention we use in the txmgr package. I could revert EvmMultiNode, but if we keep the file for the EvmNode and EvmSendOnlyNode aliases, I think it'd be better to have all of the type parameters we're using for generics in a centralized place for reference. That being said if it's still better to avoid aliases, I can revert these back and delete this file.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We introduced many aliases back when txm was generalized and now I often find myself looking around for files with similar names trying to figure out where is what. Personally, unless an alias helps with verbosity I avoid it as it adds another layer of abstraction for the reader to remember. But it really depends on the situation, so if you feel this is going to be used in Atlas as well, no problem with keeping it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In that case I'll revert these. Atlas or external components shouldn't need them. I'm trying to position the code in a way they would only need basic go types. This was more so for cleaning up internally since some of them written out with type arguments looked like clutter. It also required redefining the parameters in multiple places. For this PR, it's better I leave this as is. If we ever want to clean things up a certain way, we can do that as a separate effort.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just reverted in the latest commit. Should be good for another look.

Copy link
Collaborator

@dimriou dimriou Mar 12, 2024

Choose a reason for hiding this comment

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

AFAIK it's not ideal to reuse names already used in package's path. Here we have .../evm/client/evm_client and .../evm/client/evm_client_config. It's already in a bad state since we have to maintain two types of clients (client and chain_client due to the deprecation process), I'd like us to try and simplify things. Maybe a simple config.go or config_builder.go sounds better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good to know this best practice for the future! Updated the file name to config_builder.go.

@amit-momin amit-momin marked this pull request as ready for review March 12, 2024 19:09
@amit-momin amit-momin requested a review from a team as a code owner March 12, 2024 19:09
dhaidashenko
dhaidashenko previously approved these changes Mar 12, 2024
Copy link
Collaborator

@dhaidashenko dhaidashenko left a comment

Choose a reason for hiding this comment

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

LGTM

@prashantkumar1982 prashantkumar1982 added this pull request to the merge queue Mar 13, 2024
Merged via the queue into develop with commit 594a7f0 Mar 13, 2024
96 of 97 checks passed
@prashantkumar1982 prashantkumar1982 deleted the poc-atlas-chain-client-2 branch March 13, 2024 21:19
ogtownsend pushed a commit that referenced this pull request Mar 14, 2024
…12294)

* Consolidated configs for easier external use and moved the evm client out of legacyevm

* Reused existing config types and created centralized models for client types

* Removed deprecated client constructor

* Renamed the client config builder file

* Added evm client and config builder tests

* Fixed linting

* Reverted client type aliases
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.

4 participants