Skip to content

Conversation

JonathanOppenheimer
Copy link
Member

Why this should be merged

How this works

How this was tested

karalabe and others added 30 commits November 14, 2023 15:02
all: release go-ethereum v1.13.12
* feat: pseudo-generic extra payloads in `params.ChainConfig` and `params.Rules`

* feat: `params.ExtraPayloadGetter` for end-user type safety

* refactor: payloads only available through `params.ExtraPayloadGetter`

* chore: make `libevm/examples/extraparams` a `params` testable example

* doc: `libevm/pseudo` package comments and improved readability

* doc: `params.*Extra*` comments and improved readability

* doc: `params.ExtraPayloadGetter` comments and improved readability

* doc: `params/config.libevm_test.go` comments and improved readability

* refactor: simplify `params.ChainConfig.UnmarshalJSON()`

* refactor: abstract new/nil-pointer creation into `pseudo.Constructor`s

* feat: precompile override via `params.Extras` hooks

* doc: flesh out `PrecompileOverride()` in example

* doc: complete commentary and improve readability

* refactor: `ChainConfig.Hooks()` + `Rules` equivalent

* chore: rename precompiles test file in keeping with geth equivalent

* feat: stateful precompiles + allowlist hooks

The allowlist hooks are included in this commit because they allow for the same functionality as stateful precompiles in `ava-labs/coreth` and `ava-labs/subnet-evm`.

* fix: `StateTransition.canExecuteTransaction()` used `msg.From` instead of `To`

* test: `params.RulesHooks.CanCreateContract` integration

* test: `params.RulesHooks.CanExecuteTransaction` integration

* test: `vm.NewStatefulPrecompile()` integration

* refactor: simplify test of `CanCreateContract`

* refactor: abstract generation of random `Address`/`Hash` values

* doc: full documentation + readability refactoring/renaming

* fix: remove circular dependency in tests
* chore: Go CI runs on `libevm` branch

* fix: stop using `reflect.TypeFor[T]()`

* chore: rename job, remove flaky tests, and clear `GOOS`+`GOARCH`

* fix: PR branch was `libem`

* chore: rename workflow

* chore: disable flaky `accounts/keystore` test
* feat: `params.ChainConfig` extra payload can use root JSON

* refactor: simplify `ChainConfig.UnmarshalJSON()` branches

* fix: change redundant `assert` to `require` for simplicity
…ult (#13)

* refactor: extra types `C` + `R` are never plumbed as `*C` / `*R`

* refactor: force use of `pseudo.Constructor.Zero()` instead of `NilPointer()`

* feat: `pseudo.PointerTo()`

* feat: `params.ExtraPayloadGetter[C,R].PointerFromChainConfig(...) *C` and `Rules => *R` equiv

* test: shallow copy of `ChainConfig`/`Rules` includes extras
* feat: `params.ExtraPayloadGetter.SetOnChainConfig()` + `Rules` equiv

* refactor: rename `ExtraPayloadsGetter` to `ExtraPayloads`
* fix: run flaky upstream tests sequentially

* chore: run flaky tests first to fail early

There are fewer of them so they'll fail quickly and allow the CI run to just be restarted.
* chore: `golangci-lint` CI workflow

* fix: make `golangci-lint` happy

* chore: bump `actions/{checkout,setup-go}` versions

* chore: overhaul `.golanci.yml` config

* fix: all linter issues

* chore: exclude non-libevm linters + change deprecated option

* fix: add overflow check in example

* fix: try again; different local version?

* chore: this is trying my patience

* chore: enable `gci` and fix ordering

* chore: mark `ethclient/gethclient` test as flaky

* chore: mark `eth/catalyst` test as flaky
* chore: workflow to print diffs vs `libevm-base` tag

* fix: job name

* fix: use `${{ github.ref_name }}` instead of `HEAD`

* fix: use `github.sha` instead of `github.ref_name`

* fix: `fetch-tags: true`

* chore: fml

* fix: `fetch-depth: 0` for more than just 1 commit

* fix: check out branch before performing diff

* chore: `set -x` to aid debugging

* fix: add `--` suffix to `git checkout`

* fix: use `github.ref_name` instead of `github.sha`

* refactor: move all actions inside workflow

* fix: use `github.ref` for full name

* fix: only use explicit diff for `libevm`

* chore: `git diff --color=always`

* feat: color-blindness a11y
* feat: read-only argument to stateful precompiles

* refactor: group `PrecompiledStatefulRun()` args except input

* test: read-only status of all `EVM.*Call*()` methods

* feat: `PrecompileEnvironment.ReadOnlyStateDB()`

* doc: warning about allowing recursive calling

* test: precompile call from within read-only env

* refactor: introduce `{inherit,force}ReadOnly` consts

* fix: `nolint` verbose if statement
* refactor!: `RulesHooks.CanCreateContract()` via `defer`

`TestCanCreateContract` is unchanged and merely moved to the appropriate file.

* feat!: `RulesHooks.CanCreateContract()` accepts and returns gas

* chore: move `TestCanCreateContract` to original file

Simplifies code review

* chore: pacify linter

* refactor!: revert to non-deferred call (not at start)
* refactor!: gas consumption for stateful precompiles

* chore: remove receiver & arg names on `statefulPrecompile.RequiredGas()`

* doc: `vm.statefulPrecompile`
* feat: `CheckConfig{Compatible,ForkOrder}` + `Description` hooks

* doc: comments on `NOOPHooks` methods

* test: all new hooks

* chore: `gci`

* doc: fix `hookstest.Stub.Description` comment

Co-authored-by: Darioush Jalali <[email protected]>
Signed-off-by: Arran Schlosberg <[email protected]>

---------

Signed-off-by: Arran Schlosberg <[email protected]>
Co-authored-by: Darioush Jalali <[email protected]>
* feat: `vm.MutableStack` wrapper

* refactor: use `require.Empty()`
* feat: override `vm.NewEVM()` args

* test: `vm.Hooks.OverrideNewEVMArgs`

* refactor: use `NewEVMArgs struct` in hook

* chore: `gci`

* fix: clear `vm.Hooks` at end of test
* doc: licensing of libevm extensions and modifications

* chore: add license headers via linter

* chore: `golangci-lint run --fix`

* chore: `golangci-lint run --fix`

* chore: fix `libevm/libevm.go` header

* chore: `s/extensions/additions/`

* chore: add missing headers
NathanBSC and others added 28 commits June 10, 2025 15:08
…thereum#29644)

* eth/gasprice: add query limit for FeeHistory to defend DDOS attack

* fix return values after cherry-pick

---------

Co-authored-by: Eric <[email protected]>
* upgrade lock usage

* revert unnecessary change
Fixes an error when the block is not found in debug methods.
## 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

Implementation for
[ACP-204](avalanche-foundation/ACPs#204).

## How this works

Implements
[RIP-7212](https://github.com/ethereum/RIPs/blob/master/RIPS/rip-7212.md)
and an additional `Pack(hash,r,s,key)` function with
precompile-compatible output.

## How this was tested

Unit tests including fuzzing, test case from the proposed but unmerged
geth implementation, and vectors from [Project
Wycheproof](https://github.com/C2SP/wycheproof).
## 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 <[email protected]>
Co-authored-by: Stephen Buttolph <[email protected]>
## 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

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

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

`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

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.
Updates the libsecp256k1 dependency to commit:
c0d9480fbbf8eccbd4be23ed27f6f2af6f3b211e

PR:
```
BenchmarkSign-24    	   57756	     21214 ns/op	     164 B/op	       3 allocs/op
BenchmarkRecover-24    	   37156	     33044 ns/op	      80 B/op	       1 allocs/op
BenchmarkEcrecoverSignature-24    	   36889	     32935 ns/op	      80 B/op	       1 allocs/op
BenchmarkVerifySignature-24    	   41163	     29207 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecompressPubkey-24    	  318624	      4062 ns/op	     304 B/op	       6 allocs/op
```

Master:
```
BenchmarkSign-24    	   34509	     35330 ns/op	     164 B/op	       3 allocs/op
BenchmarkRecover-24    	   25418	     47725 ns/op	      80 B/op	       1 allocs/op
BenchmarkEcrecoverSignature-24    	   25735	     47591 ns/op	      80 B/op	       1 allocs/op
BenchmarkVerifySignature-24    	   29108	     41097 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecompressPubkey-24    	  294747	      4143 ns/op	     304 B/op	       6 allocs/op
```

Performance seems to be improved significantly:
```
Sign-24      34.86µ ± 3%   21.66µ ± 2%  -37.86% (p=0.000 n=10)
Recover-24   46.14µ ± 3%   33.24µ ± 2%  -27.95% (p=0.000 n=10)
```
This change makes use of the following underlying changes to the kzg-libraries in order to avoid passing large things on the stack:

- c-kzg: ethereum/c-kzg-4844#393 and
- go-kzg: https://github.com/crate-crypto/go-kzg-4844/pull/63
## 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

`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

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
…ecompiles (#211)

## 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.
…ompile (#210)

## 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
This PR removes the custom secp256 implementation in a single, seperate
commit, as requested in #214
## Why this should be merged

As described in ava-labs/coreth#1137, database
inspection of a Coreth chain database fails because `InspectDatabase()`
expects for freezers to be used. This PR fixes this bug by adding an
option to skip freezer inspection.

This PR should be followed with a downstream PR in Coreth to pass in an
option to skip freezer inspection during database inspection.

## How this works

Extends `inspectDatabaseConfig` with a `skipFreezers` field and adds the
associated option function for it.

## How this was tested

CI + ran `InspectDatabase()` against Coreth locally
## Why this should be merged

The need for examples to be in `package rawdb_test` made it difficult to
test other code that relied on non-exported `rawdb` identifiers.

## How this works

1. Move all testable examples from `database.libevm_test.go` to
`examples.libevm_test.go` _without any change_.
2. Change `database.libevm_test.go` to be in `package rawdb` and extend
the `WithSkipFreezers()` test.

## How this was tested

No change at all to testable examples. The `WithSkipFreezers()` test now
touches both the happy and (specific) error paths to demonstrate exact
behaviour (under the old approach it could have just been that there was
no error, even without the option).
## Why this should be merged

Allows direct access to the P-256 verification precompile. Currently the
only alternative is to rely on the planned but not guaranteed address
that Ethereum will use.

## How this works

Embed the non-exported `p256verify` type in an exported struct to allow
its methods to be exposed.

## How this was tested

Run the test suite for `p256verify` on `P256Verify`.
## Why this should be merged

Adds default-value support to the `options` package, which could
previously only create configured types from zero values.

## How this works

Exposes the option-application loop as the `ApplyTo()` function and
refactors `As()` to share this code path.

## How this was tested

Testable example acting as a unit test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.