Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@

* @ava-labs/platform-avalanchego
/graft/coreth @ava-labs/platform-evm
/graft/evm @ava-labs/platform-evm
/graft/subnet-evm @ava-labs/platform-evm
39 changes: 39 additions & 0 deletions .github/workflows/evm-ci.yml
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
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ COPY go.mod .
COPY go.sum .
COPY graft/coreth ./graft/coreth
COPY graft/subnet-evm ./graft/subnet-evm
COPY graft/evm ./graft/evm
RUN go mod download

# Copy the code into the container
Expand Down
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ require (
k8s.io/utils v0.0.0-20230726121419-3b25d923346b
)

require github.com/ava-labs/avalanchego/graft/evm v0.0.0-00010101000000-000000000000 // indirect

require (
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
Expand Down Expand Up @@ -209,3 +211,5 @@ tool (
replace github.com/ava-labs/avalanchego/graft/coreth => ./graft/coreth

replace github.com/ava-labs/avalanchego/graft/subnet-evm => ./graft/subnet-evm

replace github.com/ava-labs/avalanchego/graft/evm => ./graft/evm
4 changes: 2 additions & 2 deletions graft/coreth/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ tasks:

lint:
desc: Run golangci-lint and check for allowed Ethereum imports in Go code
cmd: ../evm-shared/scripts/lint.sh
cmd: ../evm/scripts/lint.sh

lint-all:
desc: Runs all lint checks in parallel
Expand All @@ -92,7 +92,7 @@ tasks:

lint-fix:
desc: Run golangci-lint with auto-fix where possible
cmd: ../evm-shared/scripts/lint_fix.sh
cmd: ../evm/scripts/lint_fix.sh

shellcheck:
desc: Run shellcheck static analysis on all shell scripts with version management
Expand Down
2 changes: 1 addition & 1 deletion graft/coreth/ethclient/simulated/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"time"

"github.com/ava-labs/avalanchego/graft/coreth/consensus/dummy"
"github.com/ava-labs/avalanchego/graft/coreth/constants"
"github.com/ava-labs/avalanchego/graft/coreth/core"
"github.com/ava-labs/avalanchego/graft/coreth/eth"
"github.com/ava-labs/avalanchego/graft/coreth/eth/ethconfig"
Expand All @@ -42,6 +41,7 @@ import (
"github.com/ava-labs/avalanchego/graft/coreth/node"
"github.com/ava-labs/avalanchego/graft/coreth/params"
"github.com/ava-labs/avalanchego/graft/coreth/rpc"
"github.com/ava-labs/avalanchego/graft/evm/constants"
"github.com/ava-labs/avalanchego/utils/timer/mockable"
ethereum "github.com/ava-labs/libevm"
"github.com/ava-labs/libevm/common"
Expand Down
3 changes: 3 additions & 0 deletions graft/coreth/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ go 1.24.9
require (
github.com/VictoriaMetrics/fastcache v1.12.1
github.com/ava-labs/avalanchego v1.14.1-0.20251120155522-df4a8e531761
github.com/ava-labs/avalanchego/graft/evm v0.0.0-00010101000000-000000000000
github.com/ava-labs/firewood-go-ethhash/ffi v0.0.16
github.com/ava-labs/libevm v1.13.15-0.20251016142715-1bccf4f2ddb2
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
Expand Down Expand Up @@ -184,3 +185,5 @@ tool (
)

replace github.com/ava-labs/avalanchego => ../../

replace github.com/ava-labs/avalanchego/graft/evm => ../evm
2 changes: 1 addition & 1 deletion graft/coreth/plugin/evm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import (
"github.com/ava-labs/avalanchego/database"
"github.com/ava-labs/avalanchego/database/versiondb"
"github.com/ava-labs/avalanchego/graft/coreth/consensus/dummy"
"github.com/ava-labs/avalanchego/graft/coreth/constants"
"github.com/ava-labs/avalanchego/graft/coreth/core"
"github.com/ava-labs/avalanchego/graft/coreth/core/txpool"
"github.com/ava-labs/avalanchego/graft/coreth/eth"
Expand All @@ -65,6 +64,7 @@ import (
"github.com/ava-labs/avalanchego/graft/coreth/sync/handlers"
"github.com/ava-labs/avalanchego/graft/coreth/triedb/hashdb"
"github.com/ava-labs/avalanchego/graft/coreth/warp"
"github.com/ava-labs/avalanchego/graft/evm/constants"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/network/p2p"
"github.com/ava-labs/avalanchego/network/p2p/acp118"
Expand Down
2 changes: 1 addition & 1 deletion graft/coreth/plugin/evm/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/ava-labs/avalanchego/database"
"github.com/ava-labs/avalanchego/database/memdb"
"github.com/ava-labs/avalanchego/graft/coreth/consensus/dummy"
"github.com/ava-labs/avalanchego/graft/coreth/constants"
"github.com/ava-labs/avalanchego/graft/coreth/core"
"github.com/ava-labs/avalanchego/graft/coreth/eth"
"github.com/ava-labs/avalanchego/graft/coreth/miner"
Expand All @@ -45,6 +44,7 @@ import (
"github.com/ava-labs/avalanchego/graft/coreth/rpc"
"github.com/ava-labs/avalanchego/graft/coreth/utils"
"github.com/ava-labs/avalanchego/graft/coreth/utils/utilstest"
"github.com/ava-labs/avalanchego/graft/evm/constants"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow/snowtest"
"github.com/ava-labs/avalanchego/upgrade"
Expand Down
2 changes: 1 addition & 1 deletion graft/coreth/plugin/evm/vmtest/test_syncervm.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (

"github.com/ava-labs/avalanchego/database/prefixdb"
"github.com/ava-labs/avalanchego/graft/coreth/consensus/dummy"
"github.com/ava-labs/avalanchego/graft/coreth/constants"
"github.com/ava-labs/avalanchego/graft/coreth/core"
"github.com/ava-labs/avalanchego/graft/coreth/core/coretest"
"github.com/ava-labs/avalanchego/graft/coreth/params/paramstest"
Expand All @@ -32,6 +31,7 @@ import (
"github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/vmsync"
"github.com/ava-labs/avalanchego/graft/coreth/sync/statesync/statesynctest"
"github.com/ava-labs/avalanchego/graft/coreth/utils/utilstest"
"github.com/ava-labs/avalanchego/graft/evm/constants"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow"
"github.com/ava-labs/avalanchego/snow/engine/enginetest"
Expand Down
2 changes: 1 addition & 1 deletion graft/coreth/plugin/evm/wrapped_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/ava-labs/libevm/rlp"
"github.com/ava-labs/libevm/trie"

"github.com/ava-labs/avalanchego/graft/coreth/constants"
"github.com/ava-labs/avalanchego/graft/coreth/core"
"github.com/ava-labs/avalanchego/graft/coreth/params"
"github.com/ava-labs/avalanchego/graft/coreth/params/extras"
Expand All @@ -28,6 +27,7 @@ import (
"github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap0"
"github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap1"
"github.com/ava-labs/avalanchego/graft/coreth/precompile/precompileconfig"
"github.com/ava-labs/avalanchego/graft/evm/constants"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow/consensus/snowman"
"github.com/ava-labs/avalanchego/snow/engine/snowman/block"
Expand Down
2 changes: 1 addition & 1 deletion graft/coreth/precompile/modules/registerer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

"github.com/ava-labs/libevm/common"

"github.com/ava-labs/avalanchego/graft/coreth/constants"
"github.com/ava-labs/avalanchego/graft/coreth/utils"
"github.com/ava-labs/avalanchego/graft/evm/constants"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion graft/coreth/precompile/modules/registerer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/ava-labs/libevm/common"
"github.com/stretchr/testify/require"

"github.com/ava-labs/avalanchego/graft/coreth/constants"
"github.com/ava-labs/avalanchego/graft/evm/constants"
)

func TestInsertSortedByAddress(t *testing.T) {
Expand Down
77 changes: 77 additions & 0 deletions graft/evm/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
version: "2"
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$
46 changes: 46 additions & 0 deletions graft/evm/Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# https://taskfile.dev
# 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:
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
13 changes: 13 additions & 0 deletions graft/evm/go.mod
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 => ../../
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

8 changes: 8 additions & 0 deletions graft/evm/go.sum
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=
19 changes: 19 additions & 0 deletions graft/evm/scripts/build_test.sh
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 "$@" ./...
16 changes: 16 additions & 0 deletions graft/evm/scripts/coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

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
Loading