Commit graph

14979 commits

Author SHA1 Message Date
Arran Schlosberg
bc42e5f29c
chore(ci): consolidate linters (#139)
## Why this should be merged

Branch-protection rules only require the Go linter (erroneously called
`lint`) by mistake. All linters are now dependencies of a single `lint`
job that remains as a PR gate. New linters will now be enforced by
default.

Closes #138 

## How this works

GitHub Actions `need` configuration. The path limitation of running
`yamllint` is removed because it's such a cheap job so is ok to always
run.

## How this was tested

Inspection of CI run and PR's required jobs:


![image](https://github.com/user-attachments/assets/9454ca35-8a7f-4393-bdd8-5029cfaaf7e6)


![image](https://github.com/user-attachments/assets/e92b964d-5a64-415d-b8a3-1e9c84af3060)
2025-02-14 11:48:55 -05:00
Arran Schlosberg
00c10cf539
feat: release-branch automation (#137)
## Why this should be merged

Closes #25 

## How this works

See https://github.com/ava-labs/libevm/discussions/126.

The code is in a new module to (a) avoid polluting the root `go.mod`
file and (b) because `go-git` requires a newer version of Go.
Unfortunately `go-git` doesn't support cherry-picking yet so a Bash
script had to be used for that bit `#!/sad`.

## How this was tested

Inspection of output when running `cherrypick.sh` (with `set -x` added)
from the current branch.

```
...
...
+ CHERRY_PICKS='2bd6bd01d2e8561dd7fc21b631f4a34ac16627a1
99bbbc0277
1e9bf2a09e
69f815f6f5
e4b8058d5a
34b46a2f75
159fb1a1db
da71839a270a353bac92e3108e4b74fb0eefec29'
...
Skipping 2bd6bd01d2 already in history
...
Cherry-picking 99bbbc0277
...
Cherry-picking 1e9bf2a09e
...
Cherry-picking 69f815f6f5
...
Cherry-picking e4b8058d5a
...
Cherry-picking 34b46a2f75
...
Cherry-picking 159fb1a1db
...
Cherry-picking da71839a27
...
+ git cherry-pick 99bbbc0277 1e9bf2a09e 69f815f6f5 e4b8058d5a 34b46a2f75 159fb1a1db da71839a27
```
2025-02-14 16:09:41 +00:00
Arran Schlosberg
3ab3cd2c2b
feat(core/types): Block RLP overriding (#133)
## Why this should be merged

Support for configurable `core/types.Block` with RLP encoding, including
interplay with `Body`.

## How this works

`Block` doesn't export most of its fields so relies on an internal type,
`extblock`, for RLP encoding. This type is modified to implement the
`rlp.Encoder` and `Decoder` methods as a point to inject hooks using
`rlp.Fields` (as in #120 for `Body`).

`Block` shares the same registered extra type as `Body`. Unlike
`Header`, which has its own field in a `Block`, the fields in `Body` are
promoted to be carried directly. This suggests that (at least for pure
data payloads) the modifications might be equivalent (and
`ava-labs/coreth` evidences this). Should different payloads be
absolutely required in the future, we can split the types—the
`RegisterExtras` signature is already too verbose though 😢.

## How this was tested

Explicit inclusion of a backwards-compatibility test for
`NOOPBlockBodyHooks` + implicit testing via the multiple upstream tests
in `block_test.go`. Re implicit testing: default behaviour is now to use
the noop hooks even when no registration is performed, but if we change
this then the tests in `block_test.go` can still be called as subtests
from a test that explicitly registers noops.

---------

Signed-off-by: Arran Schlosberg <519948+ARR4N@users.noreply.github.com>
Co-authored-by: Quentin McGaw <quentin.mcgaw@avalabs.org>
2025-02-13 16:20:17 +00:00
Quentin McGaw
0eb029ad49
chore(core/types): restructure libevm hooks code (#135)
Co-authored-by: Arran Schlosberg <519948+ARR4N@users.noreply.github.com>
2025-02-13 11:32:50 +00:00
Arran Schlosberg
c78db425b8
doc(core/rawdb): fix outdated comment (#134)
Missed in earlier PR:
https://github.com/ava-labs/libevm/pull/132#discussion_r1952593121

Signed-off-by: Arran Schlosberg <519948+ARR4N@users.noreply.github.com>
2025-02-12 17:41:41 +00:00
Quentin McGaw
0c905680f3
chore(core/rawdb): InspectDatabase can receive multiple times the same option (#132) 2025-02-12 12:55:40 +00:00
Quentin McGaw
b2c38ce397
feat(core/types): body RLP hooks registration (#130)
Allow to register body extras in consumers of libevm.

Co-authored-by: Arran Schlosberg <519948+ARR4N@users.noreply.github.com>
2025-02-12 11:38:28 +00:00
Arran Schlosberg
80fbed641e
refactor(core/types): Body backwards-compatibility out of package types_test (#131)
## Why this should be merged

Simplify testing in #130.

## How this works

Backwards-compatibility tests were originally created in `package
types_test` because the first one uses `ethtest` and would have caused a
circular dependency. None of the later tests have this issue so they
were moved into `package types`. The `cmpeth` test utility isn't
currently needed anywhere else so its functionality is collapsed inside
this new file.

## How this was tested

N/A as simply moving existing tests to different files.
2025-02-12 11:04:22 +00:00
Quentin McGaw
67f879ac18
refactor!(core/types): Block method WithBody(Body) signature (#110)
Breaking change refactoring `core/types.Block.WithBody()` method from signature
WithBody(transactions []*Transaction, uncles []*Header) *Block
to signature
WithBody(body Body) *Block
such that block and body extras can be used within `WithBody`.
Note `geth` made the same change in method signature so the deltas introduced in this PR will disappear once we sync.
2025-02-11 14:29:34 +00:00
Quentin McGaw
2580bd1d05
chore(ci): add go_tidy job to go workflow (#127) 2025-02-11 15:28:33 +01:00
Arran Schlosberg
94383c77ad
chore: add label "Priority: With next Geth sync" (#129)
## Why this should be merged

#110 introduces changes that we want to revert as part of the next Geth
sync. This label will be applied to issues that track similar tasks.

## How this works

Magic 🧙 

## How this was tested

Inspecting [CI dry run, which creates the new
label](https://github.com/ava-labs/libevm/actions/runs/13261362433/job/37018526246?pr=129#step:3:99).

Signed-off-by: Arran Schlosberg <519948+ARR4N@users.noreply.github.com>
2025-02-11 12:41:12 +01:00
Quentin McGaw
f6832f23bc
chore!(core/types): change method names of JSON header hooks (#125)
- MarshalJSON -> EncodeJSON
- UnmarshalJSON -> DecodeJSON
- Placates the gopls forced linter
- Aligns with EncodeRLP and DecodeRLP hook functions
2025-02-10 16:48:50 +00:00
Quentin McGaw
9125583d8e
chore(ci): pin goheader golangci-lint action to v6.2.0 (#124)
The action pinned as v6 uses v6.3.1 which is currently misbehaving on the main branch linting all files instead of just the files from the current commit.
2025-02-10 14:05:16 +00:00
Arran Schlosberg
c74b645360
feat: rawdb.InspectDatabaseOption (#111)
## Why this should be merged

Allows for `ava-labs/coreth` equivalent modifications of
`rawdb.InspectDatabase()` through external logic injection.

## How this works

Variadic options to:

1. Record a database statistic;
2. Mark a database statistic as metadata;
3. Filter statistics for printing.

## How this was tested

Testable example acting as a unit test.

---------

Signed-off-by: Arran Schlosberg <519948+ARR4N@users.noreply.github.com>
Co-authored-by: Quentin McGaw <quentin.mcgaw@avalabs.org>
2025-02-07 17:32:51 +00:00
Arran Schlosberg
d210cc4fce
refactor(core/types): simplify Body RLP override (#120)
## Why this should be merged

Simplification of `types.Body` RLP overriding, resulting in reduced code
at both the implementation and consumer ends.

## How this works

Introduction of `rlp.Fields` type, to mirror regular RLP encoding of a
struct. The RLP override hook now only needs to return the fields of
interest, which MAY come from either the `Body` or the registered extra.

This pattern allows for arbitrary modification of upstream fields via
(1) reordering; (2) addition; (3) deletion; and (4) inverting required
vs optional status. While less important for `Body`, this allows for
complete support of `ava-labs/coreth` `Header` modifications, which make
use of 1-3.

## How this was tested

Existing backwards-compatibility tests + new unit tests for introduced
functionality.

---------

Signed-off-by: Arran Schlosberg <519948+ARR4N@users.noreply.github.com>
Co-authored-by: Quentin McGaw <quentin.mcgaw@avalabs.org>
2025-02-07 15:42:25 +00:00
Arran Schlosberg
761c4b40de
fix(ci): module-renaming workflow includes .go.tpl and .proto (#122)
## Why this should be merged

Introduction of breaking upstream changes (inclusion of `.go.tpl` files)
since the workflow was written. Resulted in [failed smoke
tests](https://github.com/ava-labs/libevm/actions/runs/13198798601) due
to ABI-binding templates not being updated.

## How this works

Only (1) is necessary for the fix but the others were added for
convenience as relevant to this PR:

1. Replace module name in `*.go.tpl` files;
2. As above for `*.proto` files (`go_package` option);
3. Remove concurrency limitations as they're unnecessary with a manually
triggered workflow; and
4. Display all tags that point to the source commit as they're useful
for inspection of version.

## How this was tested

[Successful workflow
run](https://github.com/ava-labs/libevm/actions/runs/13199663099/job/36848609786)
at upstream v1.15.0.

For the modifications, respectively:

1. Smoke tests pass and no `.go.tpl` files in [Remnant
references](https://github.com/ava-labs/libevm/actions/runs/13199663099/job/36848609786#step:9:1);
2. As above re remnant references;
3. N/A; and
4. Inspection of [step
output](https://github.com/ava-labs/libevm/actions/runs/13199663099/job/36848609786#step:6:5).
2025-02-07 15:28:53 +00:00
Quentin McGaw
f906679f6f
fix(libevm/legacy): PrecompiledStatefulContract gas and remaining gas handling (#114)
- remaining gas higher than the input gas is not allowed (otherwise it would overflow as well)
- remaining gas can be equal to the input gas
- add new test and `vm.PrecompileEnvironment` stub
2025-02-07 14:29:33 +01:00
Quentin McGaw
a8df623269
chore(ci): restrict each job concurrency except for main branch (#117)
- save some compute minutes 🌱
- Limit concurrency by workflow + ref (except for main branch)
2025-02-06 11:03:26 +00:00
Quentin McGaw
80bdfe7243
chore(ci): use the Go version found in go.mod (#118) 2025-02-06 10:52:45 +00:00
Arran Schlosberg
eda3b59f67
feat(core/types): fine-grained Body RLP override (#109)
## Why this should be merged

Allows for modification of `types.Body` payload data + RLP encoding
without placing the entire RLP burden on the `libevm` user as we did
with `types.HeaderHooks`.

## How this works

RLP encoding of a struct is simply a concatenation of RLP encodings of
fields, encompassed by an RLP "list". The
`AppendRLPFields(rlp.EncoderBuffer, ...)` hook exploits this and plugs
in before all `rlp:"optional"`-tagged fields to allow for inclusion of
any new fields. The `EncoderBuffer` SHOULD be used as the `io.Writer`
passed when encoding each field: `rlp.Encode(buffer, fieldValue)`.

`Body` doesn't have `{En,De}codeRLP` methods so they are implemented to
identically replicate original behaviour when a no-op hook is present.

This pattern is sufficient for the `ava-labs/coreth` modifications of
`Body` but can be modified / extended for more complex scenarios, like
`Header`.

> [!NOTE]
> This PR does not include registration of the hooks as that was not the
initial goal and adding them would create too much PR bloat. There is a
placeholder `var todoRegisteredBodyHooks` global variable that can only
be set in tests.

## How this was tested

- Backwards compatibility: the new methods are fuzzed against a `type
withoutMethods Body` passed directly to `rlp.{En,De}code()`
- `coreth` compatibility: unit test of a local implementation of
`BodyHooks` demonstrating reproducibility of RLP encoding.

---------

Signed-off-by: Arran Schlosberg <519948+ARR4N@users.noreply.github.com>
Co-authored-by: Quentin McGaw <quentin.mcgaw@avalabs.org>
2025-02-05 10:52:28 +00:00
Quentin McGaw
be6e93eedb
chore(ci): linting job changes regarding goheader (#116)
`goheader` only needs to be run on files changed in the current PR as it will otherwise suggest updating copyright years on untouched files. The other linters, however, should be run in the same manner as a local invocation
2025-02-05 09:10:57 +01:00
Quentin McGaw
ee93f60829
feat(core/types): Header hook PostCopy (#106) 2025-02-04 16:56:08 +01:00
Quentin McGaw
e2b0abbe53
chore(ci): automate detection of last auto-rename commit(#99) 2025-01-13 18:12:33 +01:00
Quentin McGaw
d08d0f0510
feat(params): UnmarshalChainJSONConfig and MarshalChainConfigJSON (#92)
- Allow wallets and other clients to parse blocks from both coreth and subnet-evm without registering extra types
- Allow wallets and other clients to make their genesis/chain configurations without registering extra types
2025-01-12 18:35:14 +01:00
Quentin McGaw
c996175b46
chore(ci): yaml linter workflow and fix yaml files (#98)
- New workflow triggering only on yaml file changes using the built-in `yamllint`
- `.yamllint.yml` configuration added at the root of the project
- Fix existing yml files to satisfy ymllint
- Ignore go-ethereum original yml files
2025-01-12 13:56:08 +00:00
Quentin McGaw
ce2cde5662
docs(linter): comment why goheader is only enabled in the CI (#101) 2025-01-09 14:17:06 +01:00
Quentin McGaw
efa14ab5d0
chore(ci): goheader linting only runs in CI on changed or new files (#100) 2025-01-08 08:38:50 +00:00
Quentin McGaw
9e452f2960
chore(github): issue template configuration and update issue templates (#96) 2024-12-30 18:00:05 +01:00
Quentin McGaw
bee85d6171
chore(ci): define Github labels as code with a workflow (#93) 2024-12-23 15:02:52 +01:00
Arran Schlosberg
4575ced555
feat: types.HeaderHooks JSON round-trip support (#94)
## Why this should be merged

JSON equivalent of #89.

## How this works

The check for registered extras, previously used in `{En,De}codeRLP()`
methods is abstracted into a `Header.hooks() HeaderHooks` method that
either returns (a) an instance of the registered type or (b) a
`NOOPHeaderHooks` if no registration was performed. This is then used
for all hooks, new (JSON) and old (RLP).

## How this was tested

Extension of existing unit tests.
2024-12-19 16:30:04 +00:00
Arran Schlosberg
44f23c8869
refactor: PrecompileEnvironment.{,Use,Refund}Gas() in lieu of args (#73)
## Why this should be merged

Aligns precompiled contracts with the pattern used in
`vm.EVMInterpreter` for regular contracts and simplifies gas accounting
by using existing mechanisms. The most notable simplification occurs
when there are multiple error paths that return early and have to
account for consumed gas (any local solution would likely just mirror
this one).

This forms part of a broader, long-term direction of feature parity
between precompiled and bytecode contracts, exposed via
`vm.PrecompileEnvironment`.

The `vm.Contract.Value()` method is also exposed as a natural
accompaniment to this change.

## How this works

The original signature for `vm.PrecompiledStatefulContract` received the
amount of gas available and then returned the amount remaining; this has
been removed in lieu of exposing the existing `vm.Contract.UseGas()`
method via the `vm.PrecompileEnvironment`. A new `legacy` package wraps
the old signature and converts it to a new one so `ava-labs/coreth`
doesn't need to be refactored.

```go
func oldPrecompile(env vm.PrecompileEnvironment, input []byte, gas uint64) ([]byte, uint64, error) {
  // ...
  if err != nil {
    return nil, gas - gasCost, err // pattern susceptible to bugs; should it be `nil, gas, err` ?
  }
  // ...
  return output, gas - gasCost, nil  
}

func newPrecompile(env vm.PrecompileEnvironment, input []byte) ([]byte, error) {
  // The original `gas` argument is still available as `env.Gas()`
  // ...
  if !env.UseGas(gasCost) { // an explicit point at which gas is consumed
    return nil, vm.ErrOutOfGas
  }
  // ...
  if err != nil {
    return nil, err
  }
  // ...
  return output, nil
}
```

## How this was tested

Existing unit test modified to use the `legacy` adaptor.

---------

Signed-off-by: Arran Schlosberg <519948+ARR4N@users.noreply.github.com>
Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>
2024-12-18 13:54:51 +00:00
Arran Schlosberg
43878f4fab
feat: internalise command (#90)
## Why this should be merged

Replaces #86. That approach couldn't be replicated for generated JSON
marshalling, and this once also reduces the upstream delta.

## How this works

AST manipulation of a specified file, which finds specified methods and
modifies their names to be unexported.

## How this was tested

Inspection of the output (`core/types/gen_header_rlp.go` remains
unchanged).
2024-12-17 17:20:02 +01:00
Arran Schlosberg
dc7e27aff4
feat: types.HeaderHooks for RLP overrides (#89)
## Why this should be merged

The `types.Header` fields of both
[`coreth`](https://pkg.go.dev/github.com/ava-labs/coreth/core/types#Header)
and
[`subnet-evm`](https://pkg.go.dev/github.com/ava-labs/subnet-evm/core/types#Header)
have been modified such that their RLP encodings (i.e. block hashes)
aren't compatible with vanilla `geth` nor each other. This PR adds
support for arbitrary RLP encoding coupled with type-safe extra
payloads.

## How this works

Equivalent to #1 (`params`) and #44 (`types.StateAccount`) registration
of pseudo-generic payloads. The only major difference is the guarantee
of a non-nil payload pointer, which means that the payload hooks are
never called on nil pointers as this would make it difficult to decode
RLP into them.

## How this was tested

Round-trip RLP {en,de}coding via a registered stub hook.

---------

Signed-off-by: Arran Schlosberg <519948+ARR4N@users.noreply.github.com>
Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>
2024-12-17 13:54:58 +00:00
Arran Schlosberg
bd44839170
test: lock in types.Header RLP encoding (#87)
## Why this should be merged

We're making changes to very sensitive code that, if broken, can result
in block hashes being different.

## How this works

Change-detector test.

## How this was tested

A randomly filled `types.Header` with expected RLP locked as a constant
in the test.
2024-12-12 13:00:02 +00:00
Arran Schlosberg
aa183c52be
refactor: generate internal Header.encodeRLP() for override (#86)
## Why this should be merged

This is a precursor to being able to override `types.Header` RLP
{en,de}coding. As there is already a `Header.EncodeRLP()` method we
either have to modify the generated code or rename the generated
method—this PR does the latter.

## How this works

The `rlpgen -internal_methods` flag changes the generated methods from
`EncodeRLP()` and `DecodeRLP()` to `encodeRLP()` and `decodeRLP()`,
respectively. A new CI job checks that generated code is up to date. We
can then implement our own `Header.EncodeRLP()` that either overrides or
falls back on the original.

It appears that `core/gen_genesis.go` was out of date but only because
of formatting.

## How this was tested

I deliberately excluded the change to `core/types/gen_header_rlp.go` to
confirm that the new workflow
[detects](https://github.com/ava-labs/libevm/actions/runs/12259667481/job/34202386378?pr=86#step:5:92)
the change and fails. The actual change can be inspected via the code
diff.
2024-12-11 10:20:58 +00:00
Arran Schlosberg
380aa319f9
refactor!: consolidate params and types payload access (#84)
## Why this should be merged

There are 3 places at which we perform the same, sensitive logic to
access registered payloads and as we modify more types this is likely to
expand. (e.g. `types.Header`).

## How this works

Introduces `pseudo.Accessor` to abstract the reusable code.

## How this was tested

Existing unit tests. Note that the `types.StateAccount` tests needed a
minor refactor to provide the assertions with access to the
`ExtraPayloads[T]` without introducing generic types anywhere.
2024-12-09 18:32:15 +00:00
Arran Schlosberg
d71677f141
refactor: consolidate once-only registration of extras (#85)
## Why this should be merged

Consolidates duplicated logic. Similar rationale to #84.

## How this works

New `register.AtMostOnce[T]` type is responsible for limiting calls to
`Register()`.

## How this was tested

Existing unit tests of `params`. Note that the equivalent functionality
in `types` wasn't tested but now is.
2024-12-09 17:43:59 +00:00
Arran Schlosberg
25e5ca3eb1
chore: retract v1.13.14-0.1.0-rc.1 (#81)
## Why this should be merged

I messed up the format of `rc` version tags, resulting in `rc.1` being
considered a later version that `rc.2`.

## How this works

The [release tagging](https://github.com/ava-labs/libevm/discussions/37)
pattern that includes a combination of `geth` and `libevm` semver
triplets (e.g. `1.13.14-0.1.0`) doesn't work well with extra identifiers
like `rc` because more pre-release identifiers (those after `-`) take
higher precedence if all those before them match. We therefore have to
use a `release` suffix (`"release" > "rc"` in ASCII).

This all became too much to expect to be done manually so I chucked it
in code instead.

## How this was tested

Unit test demonstrates expectation of version ordering.
2024-12-03 13:39:19 +00:00
Arran Schlosberg
c2f1269ba3
feat!: types.ExtraPayloads supports SlimAccount (#79)
## Why this should be merged

Provides access to extra payloads registered on `types.SlimAccount`, not
just on regular `types.StateAccount`. This is a breaking syntax change
to have the method reflect the behaviour.

## How this works

Modify existing method to accept the `ExtraPayloadCarrier` interface
instead of `*StateAccount`. The interface is implemented by both
`*StateAccount` and `*SlimAccount`.

## How this was tested

Covered by existing testing.
2024-11-29 08:02:03 -08:00
Arran Schlosberg
7d1b45b841
chore: mark upstream triedb/pathdb test flaky (#78)
## Why this should be merged

Reduce false-positive CI failures.

## How this works

Runs upstream `triedb/pathdb` test sequentially.

## How this was tested

[Inspection of
CI](https://github.com/ava-labs/libevm/actions/runs/12049469376/job/33596276893?pr=78#step:4:17)
2024-11-27 08:17:26 -08:00
Arran Schlosberg
3a754099bf
feat: state.SnapshotTree interface for drop-in replacement (#77)
## Why this should be merged

Allows for a drop-in replacement of `snapshot.Tree` (i.e. one that uses
block hashes instead of state roots). This is intended as a temporary
solution while we investigate having the state root affected by the
block hash to remove path ambiguity.

## How this works

Introduction of:
1. `state.SnapshotTree` interface to match methods required on
`snapshot.Tree` as used by `state.StateDB`; and
2. `stateconf` package for variadic options plumbed by
`StateDB.Commit()` through to `SnapshotTree.Update()`.

Although variadic (to maintain function call-signature compatibility)
only the `stateconf.WithUpdatePayload(any)` is expected to be used.
Recipients of the options can access the payload with
`stateconf.ExtractUpdatePayload()`.

## How this was tested

Unit test demonstrating propagation of `stateconf.UpdateOption` payload.
2024-11-26 17:22:13 +00:00
Arran Schlosberg
4feb960086
feat(core/state): async trie prefetching (#76)
## Why this should be merged

Performs trie prefetching concurrently, required for equivalent
performance with `coreth` / `subnet-evm` implementations.

## How this works

`StateDB.StartPrefetcher()` accepts variadic options (for backwards
compatibility of function signatures). An option to specify a
`WorkerPool` is provided which, if present, is used to call
`Trie.Get{Account,Storage}()`; the pool is responsible for concurrency
but does not need to be able to wait on the work as that is handled by
this change.

## How this was tested

Unit test demonstrating hand-off of work to a `WorkerPool` as well as
API-guaranteed ordering of events.
2024-11-26 08:01:47 -08:00
Arran Schlosberg
44068c8bab
refactor: abstract options package (#74)
## Why this should be merged

Simplifies the creation and application of variadic options; this is
also applicable to many of my other WIP branches (e.g. `snapshot`).

## How this works

See `libevm/options/options.go`, which is very simple.

## How this was tested

Existing tests of `vm.PrecompileEnvironment.Call()`, which itself uses
refactored options.
2024-11-21 13:59:51 -08:00
Arran Schlosberg
594abd9f42
feat: triedb.Config support for arbitrary backend implementations (#70)
## Why this should be merged

Allow `ava-labs/coreth` to use arbitrary `triedb` database
implementations.

## How this works

Introduces `HashBackend` and `PathBackend` interfaces that
`triedb.Database` type-asserts to instead of `hashdb.Database` and
`pathdb.Backend` respectively. Other interfaces are introduced to avoid
having to modify `{hash,path}db.Database.Reader()` return values.

The explicit `DBOverride` field means that we don't have to modify any
of the `triedb` constructor beyond adding a single line immediately
before the return. This leaves all modifications of original files
entirely mechanistic. This is, however, at the expense of compile-time
guarantees of the overriding database being either a `HashBackend` or a
`PathBackend`.

## How this was tested

Unit test demonstrating override + plumbing.

---------

Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>
2024-11-14 16:55:07 +00:00
Arran Schlosberg
41a2592b8c
chore: post-rename cleanup + libevm intro (#68)
## Why this should be merged

Cleans up loose ends after renaming the Go module. Also adds an
introduction to the README to explain the purpose of libevm.

## How this works

The changed hash in the workflow is just a fix (although a no-op). The
spaces after the copyright headers are to stop them from [showing up in
documentation](https://pkg.go.dev/github.com/ava-labs/libevm@v1.13.14-0.1.0-rc.1/params).

## How this was tested

n/a
2024-10-30 09:51:41 -04:00
Arran Schlosberg
dc8fc0308d
chore: run workflows on PRs+push to release branches (#67)
## Why this should be merged

These workflows are required by branch protection for release branches,
but aren't run automatically so release PRs can't currently be merged.

## How this works

Extends the `branches` filters of necessary workflows.

## How this was tested

n/a
2024-10-29 07:29:27 +00:00
Arran Schlosberg
12b8aa5c2e
fix: pre-state tracer logging storage after call from precompile (#64)
## Why this should be merged

Fixes tracing when a stateful precompile calls another contract that
itself accesses storage.

## How this works

The pre-state tracer from `eth/tracers/native` doesn't implement
`CaptureEnter()` (entry of a new context), instead relying on
`CaptureState()` (per-opcode tracing) to detect that a new contract has
been entered. In doing so, it [maintains an
invariant](cb7eb89341/eth/tracers/native/prestate.go (L160))
that is expected when `CaptureState(vm.SLOAD, ...)` is called—breaking
the invariant results in a panic due to a nil map.

The fix involves (a) maintaining the invariant as part of
`CaptureEnter()` (previously a no-op); and (b) calling said method
inside `vm.PrecompileEnvironment.Call()`. The latter has the added
benefit of properly handling all tracing involving an outbound call from
precompiles.

## How this was tested

New integration test demonstrates that the tracer can log the retrieved
storage value.

---------

Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>
2024-10-29 17:26:29 +11:00
Arran Schlosberg
cb7eb89341
fix: state.stateObject.empty() with extra payload (#62)
## Why this should be merged

Fixes invariant broken by introduction of `types.StateAccountExtra`.

## How this works

`state.stateObject.empty()` now also requires that the underlying
account's `Extra` field carries the zero value if a type is registered,
or is itself nil.

## How this was tested

New unit test.

---------

Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>
2024-10-28 11:34:19 -07:00
Arran Schlosberg
5c6635282d
chore: CI updates for renamed module
Linter:
- Block imports of `ethereum/go-ethereum` upstream module
- Disable `goimports` checks on upstream code

Go:
- Update flaky-test regex
- Run flaky and non-flaky tests in different steps as this makes it easier to spot incorrect regex

Upstream delta:
- Use env var in workflow instead of `libevm-base` tag -> base changes atomically with the update commit
2024-10-17 13:09:06 +11:00
Arran Schlosberg
4410f807c2
Merge branch 'auto-rename-module_source-2bd6bd01d2e8561dd7fc21b631f4a34ac16627a1_workflow-c1fc594f020d23958b641a4e5a856b6e52c49d3bece94b95594864db16c1b0fc-main' into arr4n/rename-module 2024-10-17 13:07:28 +11:00