go-ethereum/core/vm
Arran Schlosberg 1bccf4f2dd
refactor!: temporary extras require proof of global lock (#238)
## Why this should be merged

The `temporary.WithTempRegisteredExtras()` global lock introduced in
#234 wasn't fit for purpose when used in `coreth` as it required central
coordination of registration, types, and usage of the payload accessor.

## How this works

Instead of a central registration point, the new
`libevm.WithTemporaryExtrasLock()` function takes out a global lock and
provides the caller with a handle that proves the lock is held. All of
the override functions, e.g. `params.WithTempRegisteredExtras()` now
require a current lock, which will be propagated by the respective
`coreth` functions.

See https://github.com/ava-labs/coreth/pull/1328 for intended usage in
`coreth` and `subnet-evm`. A consumer of both of these can then safely
do the following:

```go
import (
    "github.com/ava-labs/libevm/libevm"

    coreth "github.com/ava-labs/coreth/plugin/evm"
    subnet "github.com/ava-labs/subnet-evm/plugin/evm"
)

// asCChain calls `fn` while emulating `coreth`. It is safe for concurrent usage with [asSubnetEVM].
func asCChain(fn func() error) error {
    return libevm.WithTemporaryExtrasLock(func(l libevm.ExtrasLock) error {
        return coreth.WithTempRegisteredLibEVMExtras(l, fn)
    })
}

// asSubnetEVM calls `fn` while emulating `subnet-evm`. It is safe for concurrent usage with [asCChain].
func asSubnetEVM(fn func() error) error {
    return libevm.WithTemporaryExtrasLock(func(l libevm.ExtrasLock) error {
        return subnet.WithTempRegisteredLibEVMExtras(l, fn)
    })
}
```

## How this was tested

Unit test of the new function plus existing integration tests of all
modified code.
2025-10-16 14:27:15 +00:00
..
runtime [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
testdata core/vm: implement EIP-7951 - precompile for secp256r1 (#31991) 2025-08-13 16:39:36 -04:00
analysis.go core/vm: clarify comment (#27045) 2023-04-04 02:59:40 -04:00
analysis_test.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
common.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
contract.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
contracts.go core/vm: implement EIP-7951 - precompile for secp256r1 (#31991) 2025-08-13 16:39:36 -04:00
contracts.libevm.go feat: reentrancy.Guard for stateful precompiles (#212) 2025-10-03 19:56:29 +00:00
contracts.libevm_test.go test: PrecompileEnvironment.Value() under DELEGATECALL (#216) 2025-09-25 15:19:03 +01:00
contracts_fuzz_test.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
contracts_pkg_vm.libevm_test.go feat: export P256Verify precompile (#222) 2025-09-04 18:01:42 +00:00
contracts_test.go core/vm: implement EIP-7951 - precompile for secp256r1 (#31991) 2025-08-13 16:39:36 -04:00
doc.go core/vm: remove JIT VM codes (#16362) 2018-03-26 13:48:04 +03:00
eips.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
environment.libevm.go refactor: set EVM.readOnly and depth before running stateful precompile (#210) 2025-08-12 01:35:13 +01:00
errors.go core/vm: implement EIP-3860: Limit and meter initcode (#23847) 2023-01-11 04:05:47 -05:00
evm.go feat: enable invalidating txs (#208) 2025-08-01 13:43:47 -04:00
evm.libevm.go feat!: disambiguate EVM-semantic and raw caller/self addresses for precompiles (#211) 2025-08-07 23:48:32 +01:00
evm.libevm_test.go refactor!: temporary extras require proof of global lock (#238) 2025-10-16 14:27:15 +00:00
gas.go core/vm: use uint256 in EVM implementation (#20787) 2020-06-08 15:24:40 +03:00
gas_table.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
gas_table_test.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
hooks.libevm.go refactor!: temporary extras require proof of global lock (#238) 2025-10-16 14:27:15 +00:00
instructions.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
instructions_test.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
interface.go feat: state-key transformation w/ override (#205) 2025-07-22 13:08:53 -04:00
interpreter.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
interpreter_test.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
jump_table.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
jump_table_export.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
jump_table_test.go all: fix typos in comments (#28881) 2024-02-05 22:16:32 +01:00
libevm_test.go refactor: PrecompileEnvironment.{,Use,Refund}Gas() in lieu of args (#73) 2024-12-18 13:54:51 +00:00
logger.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
memory.go core/vm: implement EIP-5656, mcopy instruction (#26181) 2023-07-11 03:55:34 -04:00
memory_table.go core/vm: implement EIP-5656, mcopy instruction (#26181) 2023-07-11 03:55:34 -04:00
memory_test.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
opcodes.go eth/tracers/js: fix isPush for push0 (#28520) 2023-11-14 13:14:38 +01:00
operations_acl.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
options.libevm.go refactor: abstract options package (#74) 2024-11-21 13:59:51 -08:00
stack.go core/vm: clean up some dead functions (#24851) 2022-05-11 08:03:35 +03:00
stack.libevm.go feat: override EVM.Reset() args (#36) 2024-09-25 15:03:36 +01:00
stack.libevm_test.go Merge branch 'auto-rename-module_source-2bd6bd01d2e8561dd7fc21b631f4a34ac16627a1_workflow-c1fc594f020d23958b641a4e5a856b6e52c49d3bece94b95594864db16c1b0fc-main' into arr4n/rename-module 2024-10-17 13:07:28 +11:00
stack_table.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00