Skip to content

chore(all): libevm phase 2.5 changes needed for subnet-evm #3923

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

Closed
wants to merge 17 commits into from

Conversation

qdm12
Copy link
Contributor

@qdm12 qdm12 commented May 1, 2025

Why this should be merged

This was meant to be merged in the master branch post libevm 2.5 completion on both coreth and subnet-evm, since it was the branch used as the avalanchego base for both coreth and subnet-evm.

How this works

  • Import libevm instead of coreth wherever possible
  • Use libevm ethclient.Client whenever possible
    • Use NonceAt with nil block number instead of AcceptedNonceAt
    • Use libevm's *ethclient.Client or local interfaces, instead of coreth's ethclient.Client interface
  • Define local clients when the libevm (aka geth) ethclient is not enough:
    • tests/e2e EthClient
    • wallet/subnet/primary ethClient since this is used in production and should not be exported, and we should not import tests/e2e from there ideally imo

How this was tested

CI passing + used in the libevm branches for both coreth and subnet-evm

Need to be documented in RELEASES.md?

@qdm12 qdm12 changed the title chore( chore(all): libevm phase 2.5 minor changes needed for coreth and subnet-evm May 1, 2025
@qdm12 qdm12 changed the title chore(all): libevm phase 2.5 minor changes needed for coreth and subnet-evm chore(all): libevm phase 2.5 minor changes needed for subnet-evm May 1, 2025
@qdm12 qdm12 changed the title chore(all): libevm phase 2.5 minor changes needed for subnet-evm chore(all): libevm phase 2.5 changes needed for subnet-evm May 1, 2025
@qdm12 qdm12 marked this pull request as ready for review May 1, 2025 11:56
"github.com/ava-labs/libevm/rpc"
)

type ethClient struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I understand why it would be inappropriate for this to be exported for reuse by the e2e tests. What am I missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wallet/subnet/primary is used in various places in avalanchego (notably examples) which should not have access to this implementation detail.
We could modify the tests/fixture/e2e NewEthClient function to take in a ctx context.Context, nodeURI string and import that, but that seems a bit wrong to import "test" packages in there, and might create cycle dependencies.

Copy link
Contributor

Choose a reason for hiding this comment

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

wallet/subnet/primary is used in various places in avalanchego (notably examples) which should not have access to this implementation detail.

This would appear to be a similar assertion to the one made in the PR description, but I'm still missing the potential harm to making this exportable. 'should not have access' - why not?

Copy link
Contributor Author

@qdm12 qdm12 May 2, 2025

Choose a reason for hiding this comment

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

Generally it's best to keep symbols unexported as long as they are not needed, to reduce API/documentation surface for the developer using the wallet/subnet/primary package, and also to reduce package inter-dependencies.
On top of this, right now the extension from the libevm/geth eth client is smaller in wallet/subnet/primary than in tests/fixture/e2e. If tests/fixture/e2e imports wallet/subnet/primary for its eth client, we would have to add methods to this client to satisfy the e2e tests. A developer using the wallet/subnet/primary would notice these methods and might wonder why they are here. There might be further divergences in the future between the needs of the 2 packages, making the "seemingly unneeded" methods count grow.

Copy link
Contributor

@maru-ava maru-ava May 2, 2025

Choose a reason for hiding this comment

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

Generally it's best to keep symbols unexported as long as they are not needed, to reduce API/documentation surface for the developer using the wallet/subnet/primary package, and also to reduce package inter-dependencies.

I find this argument entirely unpersuasive. To me, complicating the implementation has an immediate impact on maintainability and I don't see any reason to avoid test code depending on non-test code.

On top of this, right now the extension from the libevm/geth eth client is smaller in wallet/subnet/primary than in tests/fixture/e2e. If tests/fixture/e2e imports wallet/subnet/primary for its eth client, we would have to add methods to this client to satisfy the e2e tests. A developer using the wallet/subnet/primary would notice these methods and might wonder why they are here. There might be further divergences in the future between the needs of the 2 packages, making the "seemingly unneeded" methods count grow.

Except it would be trivial to put the common stuff in the wallet and extend it in e2e.

@StephenButtolph StephenButtolph requested a review from Copilot May 1, 2025 19:41
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR migrates various components from using coreth to libevm by replacing coreth ethclient and related types with libevm's alternatives. Key changes include:

  • Introducing and using a new BaseFeeEstimator interface in multiple packages.
  • Replacing direct coreth/ethclient imports with libevm/ethclient and updating related functions.
  • Updating tests and genesis files to use libevm components.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
wallet/subnet/primary/interfaces.go Added BaseFeeEstimator interface definition for primary client usage
wallet/subnet/primary/ethclient.go Introduces a new ethClient implementation using libevm
wallet/subnet/primary/api.go Updated EthState definition and client initialization to use BaseFeeEstimator
wallet/chain/c/wallet.go Replaced coreth/ethclient with BaseFeeEstimator in production wallet
wallet/chain/c/interfaces.go Added BaseFeeEstimator interface for wallet chain client integration
tests/fixture/tmpnet/genesis.go Updated genesis imports from coreth to libevm
tests/fixture/e2e/helpers.go Modified NewEthClient and related functions for libevm integration
tests/e2e/c/dynamic_fees.go Updated params import to use libevm's params
genesis/genesis_test.go Updated genesis test to import libevm core
Comments suppressed due to low confidence (2)

wallet/subnet/primary/ethclient.go:16

  • [nitpick] Consider renaming 'ethClient' to 'EthClient' to follow Go's convention for exported vs unexported types or to avoid potential confusion with similar types in other packages.
type ethClient struct {

wallet/chain/c/interfaces.go:11

  • The BaseFeeEstimator interface is defined in both 'wallet/subnet/primary/interfaces.go' and 'wallet/chain/c/interfaces.go'. Consider consolidating this interface into a shared package to ensure consistency across the codebase.
type BaseFeeEstimator interface {

"math/big"
)

type BaseFeeEstimator interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

As per the comment from chatgpt, why does the identical interface need to be defined twice?

@JuanLeon2
Copy link
Contributor

Does this have any impact on pr 3918?

@qdm12
Copy link
Contributor Author

qdm12 commented May 8, 2025

This may be closed or significantly reduced, moving this as draft.
We have ava-labs/coreth#943 ongoing which would fix the ethclient issues.

@qdm12 qdm12 marked this pull request as draft May 8, 2025 12:13
@qdm12
Copy link
Contributor Author

qdm12 commented May 23, 2025

Unneeded so closing this.

@qdm12 qdm12 closed this May 23, 2025
@github-project-automation github-project-automation bot moved this from Ready 🚦 to Done 🎉 in avalanchego May 23, 2025
@qdm12 qdm12 deleted the qdm12/libevm branch May 23, 2025 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants