Skip to content

Commit

Permalink
libevm phase 2: Use libevm statedb from upstream (#1421)
Browse files Browse the repository at this point in the history
Co-authored-by: Arran Schlosberg <[email protected]>
Co-authored-by: Darioush Jalali <[email protected]>
Co-authored-by: Michael Kaplan <[email protected]>
Co-authored-by: Ceyhun Onur <[email protected]>
Co-authored-by: Richard Pringle <[email protected]>
Co-authored-by: Quentin McGaw <[email protected]>
Co-authored-by: Meaghan FitzGerald <[email protected]>
Co-authored-by: Quentin McGaw <[email protected]>
Co-authored-by: mountcount <[email protected]>
Co-authored-by: chuangjinglu <[email protected]>
Co-authored-by: guqicun <[email protected]>
Co-authored-by: Dmytrol <[email protected]>
fix problematic const name and some typos in comment (#1400)
fix some function names in interface comment (#1397)
close database on shutdown (#1403)
fix some function names in comment (#1405)
Fix Typos in Documentation (#1404)
fix test generator (#724)
  • Loading branch information
darioush authored Jan 13, 2025
1 parent 8e744a9 commit 4b8f1dc
Show file tree
Hide file tree
Showing 518 changed files with 4,145 additions and 18,468 deletions.
36 changes: 35 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,40 @@ guidelines:
- Commit messages should be prefixed with the package(s) they modify.
- E.g. "eth, rpc: make trace configs optional"

### Mocks

Mocks are auto-generated using [mockgen](https://pkg.go.dev/go.uber.org/mock/mockgen) and `//go:generate` commands in the code.

- To **re-generate all mocks**, use the command below from the root of the project:

```sh
go generate -run "go.uber.org/mock/mockgen" ./...
```

- To **add** an interface that needs a corresponding mock generated:
- if the file `mocks_generate_test.go` exists in the package where the interface is located, either:
- modify its `//go:generate go run go.uber.org/mock/mockgen` to generate a mock for your interface (preferred); or
- add another `//go:generate go run go.uber.org/mock/mockgen` to generate a mock for your interface according to specific mock generation settings
- if the file `mocks_generate_test.go` does not exist in the package where the interface is located, create it with content (adapt as needed):

```go
// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package mypackage
//go:generate go run go.uber.org/mock/mockgen -package=${GOPACKAGE} -destination=mocks_test.go . YourInterface
```

Notes:
1. Ideally generate all mocks to `mocks_test.go` for the package you need to use the mocks for and do not export mocks to other packages. This reduces package dependencies, reduces production code pollution and forces to have locally defined narrow interfaces.
1. Prefer using reflect mode to generate mocks than source mode, unless you need a mock for an unexported interface, which should be rare.
- To **remove** an interface from having a corresponding mock generated:
1. Edit the `mocks_generate_test.go` file in the directory where the interface is defined
1. If the `//go:generate` mockgen command line:
- generates a mock file for multiple interfaces, remove your interface from the line
- generates a mock file only for the interface, remove the entire line. If the file is empty, remove `mocks_generate_test.go` as well.

## Documentation guidelines

- Code should be well commented, so it is easier to read and maintain.
Expand All @@ -35,7 +69,7 @@ guidelines:
[commentary](https://go.dev/doc/effective_go#commentary) guidelines.
- Changes with user facing impact (e.g., addition or modification of flags and
options) should be accompanied by a link to a pull request to the [avalanche-docs](https://github.com/ava-labs/avalanche-docs)
repository. [example](https://github.com/ava-labs/avalanche-docs/pull/1119/files).
repository. [example](https://github.com/ava-labs/avalanche-docs/pull/1119/files).
- Changes that modify a package significantly or add new features should
either update the existing or include a new `README.md` file in that package.

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jobs:
- uses: actions/setup-go@v4
with:
go-version: "~1.22.8"
check-latest: true
- run: go mod download
shell: bash
- run: ./scripts/build_bench_precompiles.sh
Expand Down
9 changes: 0 additions & 9 deletions .github/workflows/check-clean-branch.sh

This file was deleted.

12 changes: 8 additions & 4 deletions .github/workflows/publish_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ on:

jobs:
publish_docker_image:
name: Publish Docker Image
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Publish image to Dockerhub
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Build and publish images to DockerHub
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
DOCKER_REPO: "avaplatform/subnet-evm"
run: .github/workflows/publish_docker_image.sh ${{ inputs.vm_id }}
VM_ID: ${{ inputs.vm_id }}
PUBLISH: 1
PLATFORMS: "linux/amd64,linux/arm64"
run: scripts/build_docker_image.sh
35 changes: 0 additions & 35 deletions .github/workflows/publish_docker_image.sh

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
inputs:
tag:
description: "Tag to include in artifact name"
description: "Tag to checkout & release"
required: true
push:
tags:
Expand All @@ -20,11 +20,11 @@ jobs:
with:
fetch-depth: 0
path: subnet-evm
ref: ${{ github.event.inputs.tag }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "~1.22.8"
check-latest: true
- name: Set up arm64 cross compiler
run: |
sudo apt-get -y update
Expand Down
36 changes: 14 additions & 22 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- run: ./scripts/lint_allowed_geth_imports.sh
- run: ./scripts/lint_allowed_eth_imports.sh
shell: bash
- uses: actions/setup-go@v5
with:
go-version: ${{ env.min_go_version }}
check-latest: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
Expand All @@ -36,6 +35,10 @@ jobs:
- name: Run actionlint
shell: bash
run: scripts/actionlint.sh
- name: go mod tidy
run: |
go mod tidy
git diff --exit-code
unit_test:
name: Golang Unit Tests (${{ matrix.os }})
Expand All @@ -49,13 +52,19 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version: ${{ env.min_go_version }}
check-latest: true
- name: Set timeout on Windows # Windows UT run slower and need a longer timeout
shell: bash
if: matrix.os == 'windows-latest'
run: echo "TIMEOUT=1200s" >> "$GITHUB_ENV"
- run: go mod download
shell: bash
- name: Mocks are up to date
shell: bash
run: |
grep -lr -E '^// Code generated by MockGen\. DO NOT EDIT\.$' . | xargs -r rm
go generate -run "go.uber.org/mock/mockgen" ./...
git add --intent-to-add --all
git diff --exit-code
- run: ./scripts/build.sh
shell: bash
- run: ./scripts/build_test.sh
Expand All @@ -77,7 +86,6 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.min_go_version }}
check-latest: true
- name: Use Node.js
uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -119,7 +127,6 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.min_go_version }}
check-latest: true
- name: Use Node.js
uses: actions/setup-node@v4
with:
Expand All @@ -140,7 +147,7 @@ jobs:
shell: bash
run: ./scripts/build.sh
- name: Run Warp E2E Tests
uses: ava-labs/avalanchego/.github/actions/[email protected].11-monitoring-url
uses: ava-labs/avalanchego/.github/actions/[email protected].13
with:
run: AVALANCHEGO_BUILD_PATH=/tmp/e2e-test/avalanchego ./scripts/run_ginkgo_warp.sh
prometheus_id: ${{ secrets.PROMETHEUS_ID || '' }}
Expand All @@ -164,15 +171,14 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.min_go_version }}
check-latest: true
- name: Install AvalancheGo Release
shell: bash
run: BASEDIR=/tmp/e2e-test AVALANCHEGO_BUILD_PATH=/tmp/e2e-test/avalanchego ./scripts/install_avalanchego_release.sh
- name: Build Subnet-EVM Plugin Binary
shell: bash
run: ./scripts/build.sh
- name: Run E2E Load Tests
uses: ava-labs/avalanchego/.github/actions/[email protected].11-monitoring-url
uses: ava-labs/avalanchego/.github/actions/[email protected].13
with:
run: AVALANCHEGO_BUILD_PATH=/tmp/e2e-test/avalanchego ./scripts/run_ginkgo_load.sh
prometheus_id: ${{ secrets.PROMETHEUS_ID || '' }}
Expand All @@ -184,19 +190,6 @@ jobs:
if: always()
with:
name: load-tmpnet-data
mock_gen:
name: MockGen Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: ${{ env.min_go_version }}
check-latest: true
- shell: bash
run: scripts/mock.gen.sh
- shell: bash
run: .github/workflows/check-clean-branch.sh
test_build_image:
name: Image build
runs-on: ubuntu-latest
Expand All @@ -213,7 +206,6 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version: ${{ env.min_go_version }}
check-latest: true
- name: Install AvalancheGo Release
shell: bash
run: BASEDIR=/tmp/e2e-test AVALANCHEGO_BUILD_PATH=/tmp/e2e-test/avalanchego ./scripts/install_avalanchego_release.sh
Expand Down
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ builds:
overrides:
- goos: linux
goarch: arm64
goarm64: v8.0
env:
- CC=aarch64-linux-gnu-gcc
- goos: darwin
goarch: arm64
goarm64: v8.0
env:
- CC=oa64-clang
- goos: darwin
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ The Subnet EVM runs in a separate process from the main AvalancheGo process and
[v0.6.9] [email protected] (Protocol Version: 37)
[v0.6.10] [email protected] (Protocol Version: 37)
[v0.6.11] [email protected] (Protocol Version: 37)
[v0.6.12] [email protected]/v1.12.0 (Protocol Version: 38)
[v0.7.0] [email protected] (Protocol Version: 38)
[v0.7.1] [email protected] (Protocol Version: 38)
```

## API
Expand Down
12 changes: 12 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

## Pending Release

* Refactored trie_prefetcher.go to be structurally similar to upstream.

## [v0.7.0](https://github.com/ava-labs/subnet-evm/releases/tag/v0.7.0)

### Updates

- Changed default write option from `Sync` to `NoSync` in PebbleDB

### Fixes

- Fixed database close on shutdown

## [v0.6.11](https://github.com/ava-labs/subnet-evm/releases/tag/v0.6.11)

This release focuses on Standalone DB and database configs.
Expand Down
4 changes: 2 additions & 2 deletions accounts/abi/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import (
"io"
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ava-labs/libevm/common"
"github.com/ava-labs/libevm/crypto"
)

// The ABI holds information about a contract's context and available
Expand Down
2 changes: 1 addition & 1 deletion accounts/abi/abi_extra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"
"testing"

"github.com/ethereum/go-ethereum/common"
"github.com/ava-labs/libevm/common"
"github.com/stretchr/testify/require"
)

Expand Down
6 changes: 3 additions & 3 deletions accounts/abi/abi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ import (
"strings"
"testing"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ava-labs/libevm/common"
"github.com/ava-labs/libevm/common/math"
"github.com/ava-labs/libevm/crypto"
"github.com/stretchr/testify/assert"
)

Expand Down
12 changes: 6 additions & 6 deletions accounts/abi/bind/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ import (
"io"
"math/big"

"github.com/ava-labs/libevm/accounts"
"github.com/ava-labs/libevm/accounts/external"
"github.com/ava-labs/libevm/accounts/keystore"
"github.com/ava-labs/libevm/common"
"github.com/ava-labs/libevm/crypto"
"github.com/ava-labs/libevm/log"
"github.com/ava-labs/subnet-evm/core/types"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/external"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
)

// ErrNoChainID is returned whenever the user failed to specify a chain id.
Expand Down
2 changes: 1 addition & 1 deletion accounts/abi/bind/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import (
"errors"
"math/big"

"github.com/ava-labs/libevm/common"
"github.com/ava-labs/subnet-evm/core/types"
"github.com/ava-labs/subnet-evm/interfaces"
"github.com/ethereum/go-ethereum/common"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ package backends
import (
"context"

"github.com/ava-labs/libevm/common"
"github.com/ava-labs/subnet-evm/accounts/abi/bind"
"github.com/ava-labs/subnet-evm/core/types"
"github.com/ava-labs/subnet-evm/ethclient/simulated"
"github.com/ava-labs/subnet-evm/interfaces"
"github.com/ethereum/go-ethereum/common"
)

// Verify that SimulatedBackend implements required interfaces
Expand Down
6 changes: 3 additions & 3 deletions accounts/abi/bind/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ import (
"strings"
"sync"

"github.com/ava-labs/libevm/common"
"github.com/ava-labs/libevm/crypto"
"github.com/ava-labs/libevm/event"
"github.com/ava-labs/subnet-evm/accounts/abi"
"github.com/ava-labs/subnet-evm/core/types"
"github.com/ava-labs/subnet-evm/interfaces"
"github.com/ava-labs/subnet-evm/rpc"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/event"
)

const basefeeWiggleMultiplier = 2
Expand Down
Loading

0 comments on commit 4b8f1dc

Please sign in to comment.