-
Notifications
You must be signed in to change notification settings - Fork 840
chore: Create shared evm module
#4690
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
Changes from all commits
7409e3e
f0e25fc
9937990
71346d0
4718ca8
0c3d4d4
95251aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| name: EVM Shared | ||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| pull_request: | ||
| merge_group: | ||
| types: [checks_requested] | ||
|
|
||
| jobs: | ||
| lint_test: | ||
| name: Lint | ||
| runs-on: ubuntu-latest | ||
| defaults: | ||
| run: | ||
| working-directory: ./graft/evm | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: ./.github/actions/setup-go-for-project | ||
| - name: Run all lint checks | ||
| run: ../../scripts/run_task.sh lint-all-ci | ||
| - name: Check go.mod and go.sum are up-to-date | ||
| run: ../../scripts/run_task.sh check-go-mod-tidy | ||
|
|
||
| unit_test: | ||
| name: Unit Tests (${{ matrix.os }}) | ||
| runs-on: ${{ matrix.os }} | ||
| defaults: | ||
| run: | ||
| working-directory: ./graft/evm | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: [macos-latest, ubuntu-22.04, ubuntu-latest] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: ./.github/actions/setup-go-for-project | ||
| - run: ../../scripts/run_task.sh build-test | ||
| - run: ../../scripts/run_task.sh coverage |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| version: "2" | ||
alarso16 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| run: | ||
| tests: true | ||
|
|
||
| linters: | ||
| default: none | ||
| enable: | ||
| - bidichk | ||
| - copyloopvar | ||
| - durationcheck | ||
| - gocheckcompilerdirectives | ||
| - govet | ||
| - ineffassign | ||
| - mirror | ||
| - misspell | ||
| - reassign | ||
| # - revive # only certain checks enabled | ||
| - staticcheck | ||
| - unconvert | ||
| - unused | ||
| - whitespace | ||
| settings: | ||
| goconst: | ||
| min-len: 3 # minimum length of string constant | ||
| min-occurrences: 6 # minimum number of occurrences | ||
| staticcheck: | ||
| checks: | ||
| - all | ||
|
|
||
| # There's a lot of legacy code that triggers these warnings after upgrading golangci-lint. | ||
| # These checks are removed. | ||
| - -QF1001 # Apply De Morgan’s law | ||
| - -QF1002 # Convert an untagged switch comparing the same variable into a “tagged” switch | ||
| - -QF1003 # Convert if / else-if chains comparing the same variable into a tagged switch | ||
| - -QF1006 # Lift if + break into loop condition | ||
| - -QF1008 # Omit embedded fields from selector expression | ||
| - -QF1010 # Convert slice of bytes to string when printing it | ||
| - -SA1019 # Use of deprecated identifiers: triggers when you import or use something marked deprecated. | ||
| - -SA4009 # A function argument is overwritten before its first use. | ||
| - -SA9003 # Empty body in an if or else branch. | ||
| - -ST1003 # Poorly chosen identifier. | ||
| - -ST1008 # A function’s error value should be its last return value. | ||
| - -ST1016 # Use consistent method receiver names (e.g. avoid mixing `s *S`, `s S`, `t *T` in same type). | ||
|
|
||
| exclusions: | ||
| generated: lax | ||
| presets: | ||
| - comments | ||
| - common-false-positives | ||
| - legacy | ||
| - std-error-handling | ||
| rules: | ||
| - linters: | ||
| - unused | ||
| # Exclude unused geth symbols from ethclient/ethclient.go to simplify upgrading Geth to a newer version. | ||
| path: ethclient\/ethclient\.go | ||
| text: (type `rpcProgress`|func `\(\*rpcProgress\)\.toSyncProgress`) is unused | ||
| - linters: | ||
| - goconst | ||
| path: (.+)_test\.go | ||
| paths: | ||
| - third_party$ | ||
| - builtin$ | ||
| - examples$ | ||
|
|
||
| formatters: | ||
| enable: | ||
| - goimports | ||
| settings: | ||
| gofmt: | ||
| simplify: true | ||
| exclusions: | ||
| generated: lax | ||
| paths: | ||
| - third_party$ | ||
| - builtin$ | ||
| - examples$ | ||
alarso16 marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # https://taskfile.dev | ||
alarso16 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # To run on a system without task installed, `./scripts/run_task.sh` will execute it with `go run`. | ||
| # If in the nix dev shell, `task` is available. | ||
|
|
||
| version: '3' | ||
|
|
||
| env: | ||
| AVALANCHEGO_BUILD_PATH: '{{.AVALANCHEGO_BUILD_PATH | default (printf "%s/avalanchego/build" .TASKFILE_DIR) }}' | ||
|
|
||
| tasks: | ||
| default: ./scripts/run_task.sh --list | ||
|
|
||
| build-test: | ||
| desc: Run all Go tests with retry logic for flaky tests, race detection, and coverage reporting | ||
| cmd: ./scripts/build_test.sh # ci.yml | ||
|
|
||
| check-clean-branch: | ||
| desc: Checks that the git working tree is clean | ||
| cmds: | ||
| - cmd: git add --all | ||
| - cmd: git update-index --really-refresh >> /dev/null | ||
| - cmd: git status --short # Show the status of the working tree. | ||
| - cmd: git diff-index --quiet HEAD # Exits if any uncommitted changes are found. | ||
|
|
||
| check-go-mod-tidy: | ||
| desc: Checks that all go.mod and go.sum files are up-to-date (requires a clean git working tree) | ||
| cmds: | ||
| - cmd: go mod tidy | ||
| - task: check-clean-branch | ||
|
|
||
| coverage: | ||
| desc: Display test coverage statistics from coverage.out file | ||
| cmd: ./scripts/coverage.sh # ci.yml | ||
|
|
||
| lint: | ||
| desc: Run golangci-lint and check for allowed Ethereum imports in Go code | ||
| cmd: ./scripts/lint.sh | ||
|
|
||
| lint-all-ci: | ||
maru-ava marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| desc: Runs all lint checks one-by-one | ||
| cmds: | ||
| - task: lint | ||
|
|
||
| lint-fix: | ||
| desc: Run golangci-lint with auto-fix where possible | ||
| cmd: ./scripts/lint_fix.sh | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| module github.com/ava-labs/avalanchego/graft/evm | ||
|
|
||
| go 1.24.9 | ||
|
|
||
| require github.com/ava-labs/libevm v1.13.15-0.20251016142715-1bccf4f2ddb2 | ||
|
|
||
| require ( | ||
| github.com/holiman/uint256 v1.2.4 // indirect | ||
| golang.org/x/crypto v0.45.0 // indirect | ||
| golang.org/x/sys v0.38.0 // indirect | ||
| ) | ||
|
|
||
| replace github.com/ava-labs/avalanchego => ../../ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we don't currently depend on avalanchego, this replace looks weird... But this is presumably in place for when this does depend on avalanchego.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah true! This is leftover from a rebase where it does... in any case it will soon |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| github.com/ava-labs/libevm v1.13.15-0.20251016142715-1bccf4f2ddb2 h1:hQ15IJxY7WOKqeJqCXawsiXh0NZTzmoQOemkWHz7rr4= | ||
| github.com/ava-labs/libevm v1.13.15-0.20251016142715-1bccf4f2ddb2/go.mod h1:DqSotSn4Dx/UJV+d3svfW8raR+cH7+Ohl9BpsQ5HlGU= | ||
| github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU= | ||
| github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= | ||
| golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q= | ||
| golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4= | ||
| golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= | ||
| golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| REPO_ROOT=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd ../../../ && pwd ) | ||
| # shellcheck disable=SC1091 | ||
| source "$REPO_ROOT"/scripts/constants.sh | ||
|
|
||
| # We pass in the arguments to this script directly to enable easily passing parameters such as enabling race detection, | ||
| # parallelism, and test coverage. | ||
| # DO NOT RUN tests from the top level "tests" directory since they are run by ginkgo | ||
| race="-race" | ||
| if [[ -n "${NO_RACE:-}" ]]; then | ||
| race="" | ||
| fi | ||
|
|
||
| cd "$REPO_ROOT/graft/evm" | ||
| # shellcheck disable=SC2046 | ||
| go test -shuffle=on ${race:-} -timeout="${TIMEOUT:-600s}" -coverprofile=coverage.out -covermode=atomic "$@" ./... |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/usr/bin/env bash | ||
alarso16 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| set -o errexit | ||
| set -o nounset | ||
| set -o pipefail | ||
|
|
||
| if [ ! -f "coverage.out" ]; then | ||
| echo "no coverage file" | ||
| exit 0 | ||
| fi | ||
|
|
||
| totalCoverage=$(go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+') | ||
| echo "Current test coverage : $totalCoverage %" | ||
| echo "========================================" | ||
|
|
||
| go tool cover -func=coverage.out | ||
Uh oh!
There was an error while loading. Please reload this page.