## Why this should be merged
Improved clarity.
## How this works
Semantically equivalent refactor. These values aren't accessible /
needed during execution of a stateful precompile, but are important when
making outgoing calls so were originally only set in the
`PrecompileEnvironment.Call()` implementation. This was confusing and
led to a false-positive bug report.
## How this was tested
Existing tests.
## Why this should be merged
Provides precompiles with unambiguous access to contextual addresses,
without the consumer needing to understand how they change under
different call types.
## How this works
The `libevm.AddressContext` type, which used to carry 3 addresses, now
provides different versions of `Caller` and `Self`. The EVM-semantic
versions are as defined by the rules of the EVM (and available before
this change). The raw versions are the unmodified caller and self.
## How this was tested
Extension of existing UTs to include raw addresses in addition to
existing, EVM-semantic ones.
## Why this should be merged
In case a tx's execution (specifically a registered precompile) should
be invalidated, this allows the EVM to find this error.
## How this works
Adds a setter and getter that can be called from a precompile.
## How this was tested
UT
## Why this should be merged
`ava-labs/coreth` has a partitioned state-address space, achieved by
setting or clearing a specific bit in the hash used to key the space.
This change allows such behaviour to be achieved with pure `libevm`
instead of the `StateDB` wrapping that `coreth` currently uses.
## How this works
Introduction of `state.StateDBHooks` interface, including a
`TransformStateKey()` method that allows for arbitrary change of state
key. If registered, this hook will be honoured by
`StateDB.{Get,GetCommitted,State}Key()` methods unless they receive a
`stateconf.SkipStateKeyTransformation` option.
## How this was tested
Unit test of `SetState() -> GetState() + GetCommittedState()` round trip
with and without options to skip.
## Why this should be merged
Coreth and Subnet-EVM require access to the current tx hash in the Warp
precompile (for selecting the correct predicate results).
This can not be exposed as a wrapper through the `OverrideEVMResetArgs`
because `SetTxContext` is called _prior_ to resetting the EVM instance.
Therefore, the `SetTxContext` function on any DB wrapper would never be
called.
## How this works
Exposes the existing `txHash` through a `TxHash()` function.
## How this was tested
Added a trivial unit test.
## Why this should be merged
Avoids false positives from `goheader`.
## How this works
Checks out entire history to give the linter a reference point for new
issues only.
## How this was tested
With great frustration by waiting for CI.
## Why this should be merged
`goheader` linter apparently hasn't been running but now decided to and
is blocking another PR. It's not worth the time to investigatie why
(probably a version update).
## How this works
Update header comments as required.
## How this was tested
N/A
## Why this should be merged
Addition of recent, functionality constitutes a bump to the minor
version. Doing this on `main` first for consistency and will cut a
release candidate after.
## How this works
Magic
## How this was tested
Super magic
## Why this should be merged
To allow more thorough handling of duplicate state roots (or any other
info other users would like), additional information can be provided to
a call of `statedb.Commit`. This change allows arbitrary types to be
sent to `triedb` as well as the `SnapshotTree`. However, this is a
breaking change for those using the functionality already, since the
snapshot commit option is wrapped with another call.
## How this works
See the edited libevm test for usage.
## How this was tested
Edited test case to include `TrieDBUpdateOption` and ensures the payload
is sent.
## Why this should be merged
#185 was allowed to merge despite CI requiring the `lint` job.
## How this works
Fix linter issues.
## How this was tested
The first commit is an empty commit, expected to fail CI, to confirm
that the job is in fact required.
## Why this should be merged
Required for
[ACP-194](https://github.com/avalanche-foundation/ACPs/tree/main/ACPs/194-streaming-asynchronous-execution#gas-charged)
$\lambda$ bound on gas consumption.
## How this works
Hook into `core.StateTransition.TransitionDb()` as this is the bottom of
all execution paths (e.g. `core.ApplyTransaction()` as used in SAE,
`core.StateProcessor.Process(*Block,...)`, etc.). Once consumed gas is
no longer changing (i.e. after all spends and refunds), the transaction
limit is passed to the hook to determine the minimum consumption, which
is applied.
## How this was tested
Unit test via `core.ApplyTransaction()` as this is our entry point in
SAE.
---------
Signed-off-by: Arran Schlosberg <519948+ARR4N@users.noreply.github.com>
Co-authored-by: Stephen Buttolph <stephen@avalabs.org>
## Why this should be merged
Our old strategy of only cherry-picking on release branches made the
`main` branch incompatible with dependent repos.
## How this works
The goal of the old strategy was to avoid cherry-picking on the same
branch to which we would later merge the duplicated, upstream commit.
This can instead be achieved by tracking the cherry-picked commits and
reverting them as part of the geth sync. Since we already do this for
our own changes and a single cherry-pick (see #128), there's no need to
use the two approaches simultaneously.
This PR deletes the cherry-picking mechanism and removes the
release-branch test that enforced its proper usage. It will be followed
up by a series of PRs, one per cherry-pick that would have otherwise
been placed on release branches.
## How this was tested
n/a
## Why this should be merged
To override the standard trie behavior for custom databases in
`core/state/database.go`, custom methods may need to be defined on the
backend database.
## How this works
Exposes `backend` interface for the API
## How this was tested
No tests necessary - isn't used in `libevm`.
## Why this should be merged
Exposes API implementations for use by SAE.
## How this works
Type aliases and constructor propagation.
## How this was tested
N/A
## Why this should be merged
Importing some `avalanchego` test fixtures automatically imports
`coreth` packages that register extras, which affects testing of other
VMs that depend on `libevm`. All other registered extras can be cleared
with the pattern in this PR.
## How this works
Uses the `register.AtMostOnce` type already used in `params` and
`types`. I forgot to update the `vm` package when implementing the type.
## How this was tested
Existing unit tests.
## Why this should be merged
This enforces an assumption that is currently made by
`VerifyRangeProof`. If a key is a prefix of another key, the current
code can panic.
## How this works
Enforces all keys have the same length.
## How this was tested
Added a unit test.
## Why this should be merged
The release-branch CI job tests branch properties of the `git` DAG but
GitHub's `actions/checkout` by default creates a speculative merge
commit against which PR CI is run. Running against this hypothetical
situation makes the tests fail.
## How this works
[`actions/checkout` uses PR
tip](https://github.com/actions/checkout?tab=readme-ov-file#checkout-pull-request-head-commit-instead-of-merge-commit)
## How this was tested
Future run against a release branch.
---------
Signed-off-by: Quentin McGaw <quentin.mcgaw@gmail.com>
- Use grep `-E` flag instead of `-P` flag so it works on all platforms
- Add `-S` flag to `git cherry-pick` since it doesn't always sign all commits after resolving conflicts
## Why this should be merged
Debugging release-branch test failures in CI but not locally.
## How this works
Logs `HEAD` before testing branch properties.
## How this was tested
NA
## Why this should be merged
The `metrics.Enabled` global is misleadingly named and disables
_constructors_, not individual metrics when they're used. This resulted
in all `ava-labs/coreth` metrics being no-ops because it was only set to
`true` after they were all constructed. As the majority of metrics are
globals, they're created during package initialisation so simply setting
`metrics.Enabled = true` somewhere in `coreth` isn't a guarantee of
ordering. The old `coreth/metrics` package simply set the global to
`true` by default.
## How this works
`metrics.Enabled = true` at the point of declaration.
## How this was tested
Local inspection of metrics on a running binary.
## Why this should be merged
The CI job in #145 requires a local (to the runner) `main` branch and
since `actions/checkout` doesn't check it out, the workflow creates the
branch off `origin/main`. However, after merge of a PR to `main`, the
workflow is run on `main` itself and that step [fails because the branch
already
exists](https://github.com/ava-labs/libevm/actions/runs/13908218530/job/38916101218).
## How this works
Only call `git branch main origin/main` if `main` doesn't exist.
## How this was tested
We'll see once it's merged 🤷
> [!NOTE]
> This will be merged into `main` once the current target branch has
been merged.
## Why this should be merged
My original implementation was back to front and it's been bugging me.
## How this works
Originally `params.LibEVMVersion` was a `var` (because it needed to be
computed) and the test used a `const`. This change simply inverts the
two and moves some code around without any change in logic.
I bumped the minor version to 2 (a no-op when not on a release branch)
to bring it in line with the latest release candidate and to avoid
forgetting to do so when performing an actual release.
## How this was tested
Unit test of version-string constant.
## Why this should be merged
Safer release process by enforcing invariants of `release/*` branches as
automated in #137 to fulfil #25.
## How this works
New test for `go_tooling` CI job.
If the PR target branch is `main` then only the `params.ReleaseType` is
checked. If the target is neither `main` nor a release branch then the
test is skipped. The checks performed on `release/*` branches are
described in the test.
## How this was tested
Locally against a dummy release branch with deliberate problems created
by (a) including this PR's changes in the final commit and (b) not
updating the libevm version.
```
$ go test -v ./... --target_branch="release/v1.13.14-0.1.0.rc.3"
=== RUN TestCherryPicksFormat
--- PASS: TestCherryPicksFormat (0.39s)
=== RUN TestBranchProperties
=== RUN TestBranchProperties/branch_name
release_test.go:172:
Error Trace: .../ava-labs/libevm/libevm/tooling/release/release_test.go:172
Error: Not equal:
expected: "release/v1.13.14-0.1.0.beta"
actual : "release/v1.13.14-0.1.0.rc.3"
Diff:
--- Expected
+++ Actual
@@ -1 +1 @@
-release/v1.13.14-0.1.0.beta
+release/v1.13.14-0.1.0.rc.3
Test: TestBranchProperties/branch_name
release_test.go:175: On release branch; params.LibEVMReleaseType = "beta", which is unsuitable for release branches
=== RUN TestBranchProperties/commit_history
release_test.go:192: Forked from "main" at commit 4c6e50e7d1 (chore: module-renaming workflow inverts between `libevm` and `geth` (#152))
release_test.go:314: ### History since fork from default branch (8 commits):
release_test.go:316: internal/build, rpc: add missing HTTP response body Close() calls (#29223) by Shiming Zhang <wzshiming@hotmail.com>
release_test.go:316: core/state: fix bug in statedb.Copy and remove unnecessary preallocation (#29563) by Aaron Chen <aaronchen.lisp@gmail.com>
release_test.go:316: params: print time value instead of pointer in ConfigCompatError (#29514) by Nathan <Nathan.l@nodereal.io>
release_test.go:316: eth/gasprice: add query limit for FeeHistory to defend DDOS attack (#29644) by Nathan <Nathan.l@nodereal.io>
release_test.go:316: core/state/snapshot: add a missing lock (#30001) by maskpp <maskpp266@gmail.com>
release_test.go:316: crypto: add IsOnCurve check (#31100) by Felix Lange <fjl@twurst.com>
release_test.go:316: internal/ethapi: fix panic in debug methods (#31157) by Sina M <1591639+s1na@users.noreply.github.com>
release_test.go:316: x by Arran Schlosberg <me@arranschlosberg.com>
=== RUN TestBranchProperties/commit_history/cherry_picked_commits
release_test.go:314: ### Expected cherry-picks (7 commits):
release_test.go:316: internal/build, rpc: add missing HTTP response body Close() calls (#29223) by Shiming Zhang <wzshiming@hotmail.com>
release_test.go:316: core/state: fix bug in statedb.Copy and remove unnecessary preallocation (#29563) by Aaron Chen <aaronchen.lisp@gmail.com>
release_test.go:316: params: print time value instead of pointer in ConfigCompatError (#29514) by Nathan <Nathan.l@nodereal.io>
release_test.go:316: eth/gasprice: add query limit for FeeHistory to defend DDOS attack (#29644) by Nathan <Nathan.l@nodereal.io>
release_test.go:316: core/state/snapshot: add a missing lock (#30001) by maskpp <maskpp266@gmail.com>
release_test.go:316: crypto: add IsOnCurve check (#31100) by Felix Lange <fjl@twurst.com>
release_test.go:316: internal/ethapi: fix panic in debug methods (#31157) by Sina M <1591639+s1na@users.noreply.github.com>
=== RUN TestBranchProperties/commit_history/final_commit
release_test.go:365: Modified disallowed file "go.yml"
release_test.go:365: Modified disallowed file "go.mod"
release_test.go:365: Modified disallowed file "go.sum"
release_test.go:365: Modified disallowed file "release_test.go"
--- FAIL: TestBranchProperties (2.07s)
--- FAIL: TestBranchProperties/branch_name (0.00s)
--- FAIL: TestBranchProperties/commit_history (2.07s)
--- PASS: TestBranchProperties/commit_history/cherry_picked_commits (1.81s)
--- FAIL: TestBranchProperties/commit_history/final_commit (0.01s)
FAIL
FAIL github.com/ava-labs/libevm/libevm/tooling/release 2.712s
FAIL
```
## Why this should be merged
Allows `core/types/hashing.go` to be deleted from `coreth`.
## How this works
Exported function acts as a proxy for unexported upstream function.
## How this was tested
NA
## Why this should be merged
Originally I'd planned on doing an upstream sync by running the rename
workflow on the incoming commit and then merging it to `main` however
this resulted in hundreds of merge commits that were solely due to Go
imports. Renaming the module from `ava-labs/libevm` to
`ethereum/go-ethereum` removed 90% of conflicts (H/T @darioush). The
module will then need to be named `ava-labs/libevm` again, so the commit
history will probably[^1] look like this after an update:
```mermaid
---
config:
gitGraph:
mainBranchName: main
parallelCommits: true
---
gitGraph TB:
branch geth order:2
commit id:"geth@v1.15.2"
checkout main
commit id:"libevm@v1.13.14"
branch sync/v1.15.2
commit id:"[AUTO] rename to ethereum/go-ethereum"
merge geth
commit id:"[AUTO] rename to ava-labs/libevm"
checkout main
merge sync/v1.15.2 id:"libevm@v1.15.2"
```
[^1]: Specifics of and rationale behind the merge strategy are beyond
the scope of this PR.
## How this works
The current module name is determined with `go list -m` and the rename
from/to patterns are no longer hard-coded.
## How this was tested
Inspection of runs and resulting branch. Although these were the
bc8e5015694707ff682c444afff52a3801b35a53 workflow, the only other commit
in this PR is cosmetic (as seen in [this
run](https://github.com/ava-labs/libevm/actions/runs/13433886428) to
create f2cecaff9c01c86053644aafc9b7196229a84cbc).
1. Run on `main` @ d32c7e0090 changes from
`libevm` to `go-ethereum`:
a.
[Run](https://github.com/ava-labs/libevm/actions/runs/13432588947/job/37527588744)
b.
[Commit](6288df93f7)
c. Created branch `arr4n/auto/test-invertible-rename`
2. Re-run on `arr4n/auto/test-invertible-rename` changes back to
`libevm`:
a. [Run](https://github.com/ava-labs/libevm/actions/runs/13432810657)
b.
[Commit](6f4f94edd9)
c. [Auto-generated branch is identical to `main` at the time of
running](d32c7e0090...6f4f94edd9)
## Why this should be merged
To be able to generate RLP code using type aliases (defined e.g. in
`coreth`).
This can and should be PR-ed upstream as well I think.
## How this works
Call `types.Unalias()` at the start of `buildContext.makeOp()`. The
alternative of adding a `case` to the switch statement adds unnecessary
recursive calls while `types.Unalias()` is a no-op if not an alias.
## How this was tested
New `rlpgen` unit test with aliases of well-known types that have
special handling—these make their proper handling easy to spot when
inspecting generated code. A recursive alias in the same test also
demonstrates full alias resolution.
---------
Co-authored-by: Arran Schlosberg <me@arranschlosberg.com>
## Why this should be merged
We'll be building with Go 1.23 via `avalanchego` so should align
versions. Also unblocks #154.
## How this works
Bump `go.mod` version and run `go mod tidy`.
## How this was tested
CI on existing tests.
## Why this should be merged
`memsize` blocks usage of Go 1.23. We'll be building with 1.23 via
`avalanchego` anyway (which doesn't transitively import `memsize`) so we
want to run tests with the correct version. It will also unblock #154.
## How this works
✂️
We already cherry-pick the upstream commit
(e4675771ed) that removes `memsize` when
on release branches so we instead do it ourselves and no longer
cherry-pick. To avoid conflicts at the next `geth` sync, this PR should
be reverted before performing the merge. See #128.
## How this was tested
Existing tests.
## Why this should be merged
Adds logging of `libevm` modification of default behaviour.
## How this works
1. Introduces `log.Lazy` functions to allow expensive logging operations
to be computed i.f.f. required by the logging level.
2. Adds `Info` logging for registration of types and `Debug` logging for
all else.
3. Only paths that change behaviour in a potentially unpredictable
manner are logged; of note, RLP / JSON encoding is _not_ considered
unpredictable given that registered extras are logged.
4. The minimal viable package, `set`, was necessary because we don't
want to depend on `avalanchego` and the `hashicorp/go-set` latest
version requires a later version of Go. #153 tracks a swap to the latter
when possible.
The `eth/tracers/internal/tracetest` test flaked at least twice
(unrelated to these changes) so I've marked it as such since it's not
worth a separate PR.
## How this was tested
New unit test on `log.Lazy` + `set` methods. Existing CI for the rest as
it's a refactor.
## Why this should be merged
A separately cherry-picked commit, the fix for `StateDB.Copy()`,
requires Go 1.23 for use of the `maps` package. This, however, breaks
`memsize`, which was later removed later from `geth` for the same
reason.
## How this works
All release branches will now cherry-pick ethereum/go-ethereum#30253.
## How this was tested
Updated list of cherry-picks applied to #142, which [passed
tests](https://github.com/ava-labs/libevm/actions/runs/13371460014/job/37340683594).
- Pin golangci-lint action to v6 now that goheader doesn't run on the default branch pushes
- This addresses the goheader step misbehaving and linting all files on pushes