## 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.
## 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.
## 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.
## 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.
## 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.
## 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.
## 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
## 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>
## 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>
* feat: `state.{Get,Set}Extra[SA any](*StateDB,types.ExtraPayloads,...)`
* test: `GetExtra()` at each point in `CreateAccount()` + `SetExtra()` lifecycle
* test: reverting extras to snapshot
* test: `GetExtra()` after `StateDB.Copy()` and writes to original
* fix: `vm.WithUNSAFECallerAddressProxying` under `DELEGATECALL`
* test: `vm.WithUNSAFECallerAddressProxying()` effect on outgoing caller addr
* chore: mark `eth/tracers/js` test flaky
* feat: `vm.PrecompileEnvironment.IncomingCallType()`
* chore: minor documentation edit
* doc: `PrecompileEnvironment` example for determining actual caller
* chore: placate the linter
* refactor: abstract `testonly` package
* test: `StateAccount.Extra` via `trie.StateTrie.{Update,Get}Account()`
* chore: `types.TestOnlyClearRegisteredExtras()` at beginning of tests
This is a purely defensive approach in case future tests forget to clean up.
* chore: placate the linter
Some of the changes in the full commit history were merged into `libevm` as part of #43 in `336a289` and then merged back into this branch as `5b15698`. Cherry-picking commits was not possible as some touched both halves of the changes; the squash-merges will, however, make this convoluted history irrelevant.
* feat: `types.StateAccount` pseudo-generic payload
* feat: registration of `StateAccount` payload type
* chore: mark `eth/tracers/logger` flaky
* chore: copyright header + `gci`
* test: lock default `types.SlimAccount` RLP encoding
* feat: `vm.SlimAccount.Extra` from `StateAccount` equiv
* chore: placate the linter
* test: `pseudo.Type.EncodeRLP()`
* test: `pseudo.Type.DecodeRLP()`
* fix: `pseudo.Type.DecodeRLP()` with non-pointer type
* feat: `pseudo.Type.IsZero()` and `Type.Equal(*Type)`
* feat: `types.StateAccountExtra.DecodeRLP()`
* fix: remove unnecessary `StateAccountExtra.clone()`
* refactor: readability
* feat: `pseudo.Type.Format()` implements `fmt.Formatter`
* 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
* 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)
* 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
* 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
* core/txpool: no need to run rotate if no local txs
Signed-off-by: jsvisa <delweng@gmail.com>
* Revert "core/txpool: no need to run rotate if no local txs"
This reverts commit 17fab17388.
Signed-off-by: jsvisa <delweng@gmail.com>
* use Debug if todo is empty
Signed-off-by: jsvisa <delweng@gmail.com>
---------
Signed-off-by: jsvisa <delweng@gmail.com>
* make blobpool reject blob transactions with fee below the minimum
* core/txpool: some minot nitpick polishes and unified error formats
* core/txpool: do less big.Int constructions with the min blob cap
---------
Co-authored-by: Péter Szilágyi <peterke@gmail.com>
This PR fixes an overflow which can could happen if inconsistent blockchain rules were configured. Additionally, it tries to prevent such inconsistencies from occurring by making sure that merge cannot be enabled unless previous fork(s) are also enabled.
* core/txpool, miner: speed up blob pool pending retrievals
* miner: fix test merge issue
* eth: same same
* core/txpool/blobpool: speed up blobtx creation in benchmark a bit
* core/txpool/blobpool: fix linter
---------
Co-authored-by: Martin Holst Swende <martin@swende.se>
This change makes the legacy transaction pool use of `uint256.Int` instead of `big.Int`. The changes are made primarily only on the internal functions of legacypool.
---------
Co-authored-by: Martin Holst Swende <martin@swende.se>
This change adds support for blob-transaction in certain API-endpoints, e.g. eth_fillTransaction. A follow-up PR will add support for signing such transactions.