go-ethereum/core
Arran Schlosberg 9021836d7d
feat: vm.Hooks.PreprocessingGasCharge() (#235)
## Why this should be merged

In lieu of modifications to `core.IntrinsicGas()`, required for support
of Warp in SAE.

If we were to introduce variadic `options.Option`s to `IntrinsicGas()`,
it's impossible to guarantee that they would always be passed. The
`types.Transaction` itself isn't actually passed to `IntrinsicGas()`
either, so we can't rely on it to carry payloads/hooks.

## How this works

`vm.Hooks` are extended to include `PreprocessingGasCharge(tx
common.Hash) (uint64, error)`, which returns the amount of gas to be
charged between `core.IntrinsicGas` and `vm.EVM` execution charges. The
two entry points to execution, `vm.EVM.Call()` and `vm.EVM.Create()` are
modified to first spend said charge before running upstream logic.

The new hook is defined on a separate interface definition, embedded in
`vm.Hooks`, to allow types to implement just that method and enforce it
with the `var _ vm.Preprocessor = (*impl)(nil)` pattern.

## How this was tested

Integration tests via both `core.ApplyTransaction()` and
`core.ApplyMessage()`. The former is more comprehensive, while the
latter allows for inspection of interim error values.

---------

Signed-off-by: Arran Schlosberg <519948+ARR4N@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Austin Larson <78000745+alarso16@users.noreply.github.com>
2025-12-15 20:49:13 +00:00
..
asm chore: Go 1.24 (#232) 2025-10-13 14:07:33 -04:00
bloombits [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
forkid [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
rawdb chore: Go 1.24 (#232) 2025-10-13 14:07:33 -04:00
state refactor: move pseudo to internal (#250) 2025-12-12 21:11:23 +00:00
txpool crypto/kz4844: pass blobs by ref (#29050) 2025-06-25 11:14:37 +01:00
types refactor: move pseudo to internal (#250) 2025-12-12 21:11:23 +00:00
vm feat: vm.Hooks.PreprocessingGasCharge() (#235) 2025-12-15 20:49:13 +00:00
.gitignore Renamed chain => core 2014-12-04 10:28:02 +01:00
bench_test.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
block_validator.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
block_validator_test.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
blockchain.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
blockchain_insert.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
blockchain_reader.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
blockchain_repair_test.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
blockchain_sethead_test.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
blockchain_snapshot_test.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
blockchain_test.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
blocks.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
bloom_indexer.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
chain_indexer.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
chain_indexer_test.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
chain_makers.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
chain_makers_test.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
dao_test.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
error.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
events.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
evm.go Merge branch 'auto-rename-module_source-2bd6bd01d2e8561dd7fc21b631f4a34ac16627a1_workflow-c1fc594f020d23958b641a4e5a856b6e52c49d3bece94b95594864db16c1b0fc-main' into arr4n/rename-module 2024-10-17 13:07:28 +11:00
forkchoice.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
gaspool.go core, miner: revert block gas counter in case of invalid transaction (#26799) 2023-03-07 05:23:52 -05:00
gen_genesis.go refactor: generate internal Header.encodeRLP() for override (#86) 2024-12-11 10:20:58 +00:00
genesis.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
genesis_alloc.go cmd, core, params: add support for the Holesky testnet (#28007) 2023-08-25 18:11:40 +03:00
genesis_test.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
headerchain.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
headerchain_test.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
mkalloc.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
rlp_test.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
sender_cacher.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
state_prefetcher.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
state_processor.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
state_processor_test.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
state_transition.go feat: enable invalidating txs (#208) 2025-08-01 13:43:47 -04:00
state_transition.libevm.go feat: enable invalidating txs (#208) 2025-08-01 13:43:47 -04:00
state_transition.libevm_test.go chore: placate goheader (#195) 2025-06-23 15:25:18 +00:00
txindexer.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
txindexer_test.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
types.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00