-
Notifications
You must be signed in to change notification settings - Fork 758
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
Conversation
- Use coreth libevm branch (2025-03-11, ava-labs/coreth@79c693f) - Use libevm v1.13.14-0.2.0.rc.3
- Use `NonceAt` with `nil` block number instead of `AcceptedNonceAt` - Return and use concrete type `*ethclient.Client`
… coreth/ethclient
- Side effect is coreth has to be upgraded as well to support the newer libevm
"github.com/ava-labs/libevm/rpc" | ||
) | ||
|
||
type ethClient struct { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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?
Does this have any impact on pr 3918? |
This may be closed or significantly reduced, moving this as draft. |
Unneeded so closing this. |
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
NonceAt
withnil
block number instead ofAcceptedNonceAt
*ethclient.Client
or local interfaces, instead of coreth'sethclient.Client
interfaceEthClient
ethClient
since this is used in production and should not be exported, and we should not import tests/e2e from there ideally imoHow this was tested
CI passing + used in the libevm branches for both coreth and subnet-evm
Need to be documented in RELEASES.md?