Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
5429fd8
chore: squash `arr4n/libevm` into `libevm` (#7)
ARR4N Sep 10, 2024
b6f3eb9
chore: basic CI (#9)
ARR4N Sep 10, 2024
d9991bb
feat: `params.ChainConfig` extra payload can use root JSON (#8)
ARR4N Sep 11, 2024
72744ce
refactor: abstract `hookstest.Register()` out of `hookstest.Stub.Regi…
ARR4N Sep 11, 2024
d31803a
refactor: params extra types are zero values not nil pointers by defa…
ARR4N Sep 12, 2024
a574ae6
feat: `params.ExtraPayloads.SetOnChainConfig()` + `Rules` equiv (#14)
ARR4N Sep 12, 2024
2d3894f
fix: run flaky upstream tests sequentially (#15)
ARR4N Sep 12, 2024
04543ea
chore: `golangci-lint` CI workflow (#16)
ARR4N Sep 12, 2024
2034f76
chore: PR template (#19)
ARR4N Sep 13, 2024
df32256
chore: workflow to print diffs vs `libevm-base` tag (#18)
ARR4N Sep 14, 2024
58f3883
feat: read-only stateful precompiles (#20)
ARR4N Sep 14, 2024
38eaaab
feat!: RulesHooks.CanCreateContract() accepts and returns gas (#28)
ARR4N Sep 17, 2024
c5da3ca
refactor!: gas consumption for stateful precompiles (#26)
ARR4N Sep 17, 2024
ab357e0
feat: `vm.PrecompileEnvironment` access to block info (#27)
ARR4N Sep 17, 2024
c70b3e3
feat: `CheckConfig{Compatible,ForkOrder}` + `Description` hooks (#29)
ARR4N Sep 17, 2024
df13389
feat: `vm.MutableStack` wrapper (#31)
ARR4N Sep 18, 2024
81e109a
feat: `PrecompileEnvironment.ChainConfig()` (#32)
ARR4N Sep 18, 2024
1a6dd02
feat: override vm.NewEVM() args (#35)
ARR4N Sep 19, 2024
dc61999
doc: licensing of libevm additions and modifications (#34)
ARR4N Sep 19, 2024
53ef071
feat: override `EVM.Reset()` args (#36)
ARR4N Sep 25, 2024
99a755f
feat!: `vm.Hooks.OverrideEVMResetArgs()` receives `params.Rules` (#38)
ARR4N Sep 26, 2024
f1dba53
feat: `params.RulesHooks.ActivePrecompiles` override (#39)
ARR4N Sep 26, 2024
210f8ab
feat: `vm.PrecompiledStatefulContract` can make `CALL`s (#40)
ARR4N Sep 30, 2024
1478c18
fix: `ExtraPayloads.SetOn{ChainConfig,Rules}()` overrides shallow cop…
ARR4N Sep 30, 2024
336a289
feat: `pseudo.Type` RLP round-tripping (#43)
ARR4N Oct 1, 2024
f0ae9c5
feat: `types.StateAccount` pseudo-generic payload (#44)
ARR4N Oct 2, 2024
5ec080f
test: `StateAccount.Extra` via `trie.StateTrie.{Update,Get}Account()`…
ARR4N Oct 2, 2024
51cd795
fix: `vm.WithUNSAFECallerAddressProxying` under `DELEGATECALL` (#50)
ARR4N Oct 7, 2024
3015e74
feat: GitHub action to rename module
ARR4N Oct 8, 2024
6be7303
fix: handle single-import statements
ARR4N Oct 8, 2024
0008c43
chore: disable other workflows (DO NOT MERGE)
ARR4N Oct 8, 2024
b64081e
fix: regex `?` placement + force-push generated branch
ARR4N Oct 8, 2024
a2d0823
chore: `auto-rename-module-<COMMIT>` as generated branch
ARR4N Oct 8, 2024
6ebe4e6
chore: set generated-commit message prefix
ARR4N Oct 8, 2024
20ac77e
chore: smoke-test the rename via `go build`
ARR4N Oct 8, 2024
2b82081
chore: title case for job step
ARR4N Oct 8, 2024
b832097
chore: expand `sed` match and smoke tests
ARR4N Oct 8, 2024
50e3b01
chore: step to report remnant references
ARR4N Oct 8, 2024
77c5571
feat: `state.{Get,Set}Extra[SA any](*StateDB,types.ExtraPayloads,...)…
ARR4N Oct 9, 2024
18d6153
chore: test external push to protected branch
ARR4N Oct 10, 2024
a082971
feat: open PR to primary renaming branch
ARR4N Oct 10, 2024
88c00c6
chore: cleanup after repo and default-branch renames (#55)
ARR4N Oct 11, 2024
93df6d8
Merge branch 'main' into arr4n/rename-go-mod-auto
ARR4N Oct 11, 2024
eec97eb
chore: `ava-labs/libevm` as module name
ARR4N Oct 11, 2024
5254b44
refactor: source commit from workflow input
ARR4N Oct 11, 2024
59b2af5
Merge 5254b44e1dab075fdf842474e8bed843192ad7be into 88c00c6801046a66d…
ARR4N Oct 11, 2024
6b43dc8
[AUTO] rename Go module + update internal import paths
ARR4N Oct 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Why this should be merged

## How this works

## How this was tested
27 changes: 14 additions & 13 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
name: i386 linux tests
name: Go

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
# DO NOT MERGE: disabled while developing auto-renaming
# push:
# branches: [ main ]
# pull_request:
# branches: [ main ]
workflow_dispatch:

jobs:
build:
runs-on: self-hosted
go_test_short:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: 1.21.4
- name: Run tests
run: go test -short ./...
env:
GOOS: linux
GOARCH: 386
run: | # Upstream flakes are race conditions exacerbated by concurrent tests
FLAKY_REGEX='go-ethereum/(eth|eth/tracers/js|eth/tracers/logger|accounts/abi/bind|accounts/keystore|eth/downloader|miner|ethclient|ethclient/gethclient|eth/catalyst)$';
go list ./... | grep -P "${FLAKY_REGEX}" | xargs -n 1 go test -short;
go test -short $(go list ./... | grep -Pv "${FLAKY_REGEX}");
26 changes: 26 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: golangci-lint

on:
# DO NOT MERGE: disabled while developing auto-renaming
# push:
# branches: [ main ]
# pull_request:
# branches: [ main ]
workflow_dispatch:

permissions:
contents: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.60
39 changes: 39 additions & 0 deletions .github/workflows/libevm-delta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: libevm delta

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
diffs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # everything
fetch-tags: true

- name: Color-blindness a11y
run: | # https://davidmathlogic.com/colorblind/#%23D81B60-%231E88E5-%23FFC107-%23004D40:~:text=8%20pairs%20of%20contrasting%20colors
git config color.diff.old "#DC3220";
git config color.diff.new "#005AB5";

- name: git diff libevm-base
run: |
git diff --diff-filter=a --word-diff --unified=0 --color=always \
libevm-base \
':(exclude).golangci.yml' \
':(exclude).github/**' \
':(exclude)README.md';

- name: git diff libevm-base..main
run: |
git checkout main --;
git diff --diff-filter=a --word-diff --unified=0 --color=always \
libevm-base \
':(exclude).golangci.yml' \
':(exclude).github/**' \
':(exclude)README.md';
72 changes: 72 additions & 0 deletions .github/workflows/rename-module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Rename Go module

on:
pull_request: # DO NOT MERGE WITH ANYTHING OTHER THAN workflow_dispatch
branches: [ main ]
workflow_dispatch:
inputs:
source_commit:
description: 'Upstream commit on which to base module renaming'
required: true
type: string
default: '2bd6bd01d2e8561dd7fc21b631f4a34ac16627a1'

jobs:
rename-module:
runs-on: ubuntu-latest
env:
output_branch: "${{ github.ref_name }}_auto-rename-module-${{ inputs.source_commit }}"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # everything
fetch-tags: true

- name: Check out source commit
run: git checkout ${{ inputs.source_commit }}

- name: Globally update module name
run: |
go mod edit -module github.com/ava-labs/libevm;
find . -iname '*.go' -o -iname '*.txt' | xargs sed -i -E \
's|(["`]github\.com/)ethereum/go-ethereum|\1ava-labs/libevm|g';

- name: Remnant references
run: |
find . -type f | \
xargs grep -In github.com/ethereum/go-ethereum | \
grep -v "https://github.com/ethereum/go-ethereum"

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.21.4

- name: Smoke tests
# `go list` shows us the module name
# `go build` is a rudimentary but broad test of correctness
# The explicitly tested packages are edge cases:
# - bind creates generates tests and a go.mod on the fly
# - rlpgen has testdata with imports that need updating
run: |
go list . | grep ava-labs/libevm;
go build ./...;
go test ./accounts/abi/bind ./rlp/rlpgen

- name: Commit to ${{ env.output_branch }} branch
uses: devops-infra/action-commit-push@8bc2ff9f9de7aa2a7581fc7e5b6401c04cab54c7
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
target_branch: ${{ env.output_branch }}
force: true
commit_prefix: "[AUTO] rename Go module + update internal import paths"

- name: Open PR to "renamed-go-module" iff workflow dispatched on "main"
# if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main'
uses: devops-infra/action-pull-request@v0.5.5
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
source_branch: ${{ env.output_branch }}
target_branch: renamed-go-module
title: "[AUTO] Rename upstream Go module at `${{ inputs.source_commit }}`"
body: "_PR generated by GitHub Action_"
139 changes: 100 additions & 39 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,119 @@
run:
timeout: 20m
tests: true
# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true
skip-files:
- core/genesis_alloc.go

linters:
disable-all: true
enable:
# Every available linter at the time of writing was considered (quickly) and
# inclusion was liberal. Linters are good at detecting code smells, but if
# we find that a particular one causes too many false positives then we can
# configure it better or, as a last resort, remove it.
- containedctx
- errcheck
- forcetypeassert
- gci
- gocheckcompilerdirectives
- gofmt
- goheader
- goimports
- gosimple
- gomodguard
- gosec
- govet
- ineffassign
# TODO(arr4n): investigate ireturn
- misspell
- nakedret
- nestif
- nilerr
- nolintlint
- reassign
- revive
- sloglint
- staticcheck
- tagliatelle
- testableexamples
- testifylint
- thelper
- tparallel
- unconvert
- typecheck
- usestdlibvars
- unused
- staticcheck
- bidichk
- durationcheck
- exportloopref
- whitespace

# - structcheck # lots of false positives
# - errcheck #lot of false positives
# - contextcheck
# - errchkjson # lots of false positives
# - errorlint # this check crashes
# - exhaustive # silly check
# - makezero # false positives
# - nilerr # several intentional

linters-settings:
gofmt:
simplify: true
gci:
custom-order: true
sections:
- standard
- default
- localmodule
# The rest of these break developer expections, in increasing order of
# divergence, so are at the end to increase the chance of being seen.
- alias
- dot
- blank
goheader:
values:
template-path: .libevm-header

gomodguard:
blocked:
modules:
- github.com/ava-labs/avalanchego:
- github.com/ava-labs/coreth:
- github.com/ava-labs/subnet-evm:
revive:
rules:
- name: unused-parameter
# Method parameters may be equired by interfaces and forcing them to be
# named _ is of questionable benefit.
disabled: true

issues:
exclude-rules:
- path: crypto/bn256/cloudflare/optate.go
exclude-dirs-use-default: false
exclude-rules:
- path-except: libevm
linters:
- deadcode
# If any issue is flagged in a non-libevm file, add the linter here
# because the problem isn't under our control.
- containedctx
- forcetypeassert
- errcheck
- gci
- gofmt
- goheader
- gosec
- gosimple
- govet
- nakedret
- nestif
- nilerr
- nolintlint
- revive
- staticcheck
- path: internal/build/pgp.go
text: 'SA1019: "golang.org/x/crypto/openpgp" is deprecated: this package is unmaintained except for security fixes.'
- path: core/vm/contracts.go
text: 'SA1019: "golang.org/x/crypto/ripemd160" is deprecated: RIPEMD-160 is a legacy hash and should not be used for new applications.'
- path: accounts/usbwallet/trezor.go
text: 'SA1019: "github.com/golang/protobuf/proto" is deprecated: Use the "google.golang.org/protobuf/proto" package instead.'
- path: accounts/usbwallet/trezor/
text: 'SA1019: "github.com/golang/protobuf/proto" is deprecated: Use the "google.golang.org/protobuf/proto" package instead.'
exclude:
- 'SA1019: event.TypeMux is deprecated: use Feed'
- 'SA1019: strings.Title is deprecated'
- 'SA1019: strings.Title has been deprecated since Go 1.18 and an alternative has been available since Go 1.0: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead.'
- 'SA1029: should not use built-in type string as key for value'
- tagliatelle
- testableexamples
- testifylint
- thelper
- tparallel
- typecheck
- usestdlibvars
- varnamelen
- wastedassign
- whitespace
include:
# Many of the default exclusions are because, verbatim "Annoying issue",
# which defeats the point of a linter.
- EXC0002
- EXC0004
- EXC0005
- EXC0006
- EXC0007
- EXC0008
- EXC0009
- EXC0010
- EXC0011
- EXC0012
- EXC0013
- EXC0014
- EXC0015
15 changes: 15 additions & 0 deletions .libevm-header
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Copyright {{ MOD-YEAR }} the libevm authors.

The libevm additions to go-ethereum are free software: you can redistribute
them and/or modify them under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.

The libevm additions are distributed in the hope that they will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with the go-ethereum library. If not, see
<http://www.gnu.org/licenses/>.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,9 @@ also included in our repository in the `COPYING.LESSER` file.
The go-ethereum binaries (i.e. all code inside of the `cmd` directory) are licensed under the
[GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html), also
included in our repository in the `COPYING` file.

The libevm (i) _additions_ to the go-ethereum library (i.e. all code in files with `libevm` in their full path,
be it a directory or file name); and (ii) _modifications_ to existing go-ethereum code; are licensed under the
[GNU Lesser General Public License v3.0](https://www.gnu.org/licenses/lgpl-3.0.en.html),
also included in our repository in the `COPYING.LESSER` file. A comprehensive outline of _modifications_ is
produced by the [libevm delta workflow](https://github.com/ava-labs/libevm/actions/workflows/libevm-delta.yml).
4 changes: 2 additions & 2 deletions accounts/abi/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,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
6 changes: 3 additions & 3 deletions accounts/abi/abi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,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"
)

const jsondata = `
Expand Down
Loading