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

[EVM] Resolve ambiguous import #5006

Merged
merged 3 commits into from
Nov 10, 2023

Conversation

sideninja
Copy link
Member

@sideninja sideninja commented Nov 10, 2023

This PR introduces a temporary solution to an issue producing the error:

cd integration; go mod tidy -v
github.com/onflow/flow-go/integration/dkg imports
        github.com/onflow/flow-go/fvm imports
        github.com/onflow/flow-go/fvm/evm imports
        github.com/onflow/flow-go/fvm/evm/emulator imports
        github.com/ethereum/go-ethereum/crypto imports
        github.com/btcsuite/btcd/btcec/v2/ecdsa tested by
        github.com/btcsuite/btcd/btcec/v2/ecdsa.test imports
        github.com/btcsuite/btcd/chaincfg/chainhash: ambiguous import: found package github.com/btcsuite/btcd/chaincfg/chainhash in multiple modules:
        github.com/btcsuite/btcd v0.21.0-beta (/Users/ramtinmehdizadehseraj/go/pkg/mod/github.com/btcsuite/btcd@v0.21.0-beta/chaincfg/chainhash)
        github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 (/Users/ramtinmehdizadehseraj/go/pkg/mod/github.com/btcsuite/btcd/chaincfg/chainhash@v1.0.2)

The way I understand the problem, this is caused because the package github.com/btcsuite/btcd/chaincfg/chainhash has two definitions. When chainhash was first created it was part of the btcd as a package (this is part of the v0.21.0-beta btcd module), at a later point it was created as a submodule, but that was not done according to the recommendations https://github.com/zchee/golang-wiki/blob/master/Modules.md#is-it-possible-to-add-a-module-to-a-multi-module-repository
This issue was introduced when go-ethereum was updated to 1.20 from evm and for the first time referenced by fvm, which bubbled the problem to the integration and insecure modules. The next problem becomes in specifying a version of chainhash to resolve this issue, but we can not specify the version in go.mod because we don't directly use this package and thus it gets removed by running go mod tidy.
This solution adds a reference to chainhash so it becomes direct dependency and allows us to specify the concrete version and resolve the conflict.
If someone finds a better solution to this I would be very happy to hear what it is but also good luck. This was a day I will never get back 😄

What makes me believe this is an actual issue is also an open issue on go talking about this: golang/go#27899

@sideninja sideninja changed the title ] [EVM] Resolve ambiguous import Nov 10, 2023
@sideninja sideninja self-assigned this Nov 10, 2023
@sideninja sideninja changed the base branch from master to ramtin/evm-integrate-into-fvm November 10, 2023 18:22
@sideninja sideninja marked this pull request as ready for review November 10, 2023 18:22
@ramtinms ramtinms merged commit 18a0039 into ramtin/evm-integrate-into-fvm Nov 10, 2023
@ramtinms ramtinms deleted the gregor/evm/import-fix branch November 10, 2023 18:58
This pull request was closed.
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.

3 participants