-
Notifications
You must be signed in to change notification settings - Fork 837
Use libevm instead of coreth #3918
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
7eafc44
use libevm instead of coreth
ceyonur 862a0f1
reduce coreth imports
ceyonur e4ba10f
nit format
ceyonur a5d772e
go mod tidy
ceyonur 17cc4eb
Revert "nit format"
ceyonur c82f832
update coreth
ceyonur 533decf
update imports test
ceyonur 5ed11ee
Merge branch 'master' into fix-coreth-imports
ceyonur f7d96cd
update coreth dep
ceyonur 9946114
Merge branch 'master' into fix-coreth-imports
ceyonur 4d45145
Merge branch 'master' into fix-coreth-imports
ceyonur a2895ec
bump coreth
ceyonur 53d0f1d
move imports test to tests pkg
ceyonur 7aa01ca
reviews
ceyonur 04d0577
fix license
ceyonur c8f1f77
trivial improvemnts
StephenButtolph File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. | ||
| // See the file LICENSE for licensing terms. | ||
|
|
||
| package tests | ||
|
|
||
| import ( | ||
| "path" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "github.com/ava-labs/avalanchego/utils/packages" | ||
| ) | ||
|
|
||
| func TestMustNotImport(t *testing.T) { | ||
| require := require.New(t) | ||
|
|
||
| mustNotImport := map[string][]string{ | ||
| // Importing these packages configures libevm globally. This must not be | ||
| // done to support both coreth and subnet-evm. | ||
| "tests/...": { | ||
| "github.com/ava-labs/coreth/params", | ||
| "github.com/ava-labs/coreth/plugin/evm/customtypes", | ||
| }, | ||
| } | ||
| for packageName, forbiddenImports := range mustNotImport { | ||
| packagePath := path.Join("github.com/ava-labs/avalanchego", packageName) | ||
| imports, err := packages.GetDependencies(packagePath) | ||
| require.NoError(err) | ||
|
|
||
| for _, forbiddenImport := range forbiddenImports { | ||
| require.NotContains(imports, forbiddenImport, "package %s must not import %s, check output of: go list -f '{{ .Deps }}' %q", packageName, forbiddenImport, packagePath) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. | ||
| // See the file LICENSE for licensing terms. | ||
|
|
||
| package packages | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "golang.org/x/tools/go/packages" | ||
|
|
||
| "github.com/ava-labs/avalanchego/utils/set" | ||
| ) | ||
|
|
||
| // GetDependencies takes a fully qualified package name and returns a map of all | ||
| // its recursive package imports (including itself) in the same format. | ||
| func GetDependencies(packageName string) (set.Set[string], error) { | ||
| // Configure the load mode to include dependencies | ||
| cfg := &packages.Config{Mode: packages.NeedImports | packages.NeedName} | ||
| pkgs, err := packages.Load(cfg, packageName) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to load package: %w", err) | ||
| } | ||
|
|
||
| if len(pkgs) == 0 { | ||
| return nil, fmt.Errorf("no packages found for %s", packageName) | ||
| } | ||
|
|
||
| var ( | ||
| deps set.Set[string] | ||
| collectDeps func(pkg *packages.Package) // collectDeps is recursive | ||
| ) | ||
| collectDeps = func(pkg *packages.Package) { | ||
| if deps.Contains(pkg.PkgPath) { | ||
| return // Avoid re-processing the same dependency | ||
| } | ||
| deps.Add(pkg.PkgPath) | ||
| for _, dep := range pkg.Imports { | ||
| collectDeps(dep) | ||
| } | ||
| } | ||
|
|
||
| // Start collecting dependencies | ||
| for _, pkg := range pkgs { | ||
| if pkg.Errors != nil { | ||
| return nil, fmt.Errorf("failed to load package %s, %v", packageName, pkg.Errors) | ||
| } | ||
| collectDeps(pkg) | ||
| } | ||
| return deps, nil | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.