go-ethereum/params
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
..
forks eth/catalyst: add timestamp checks to fcu and new payload and improve param checks (#28230) 2024-01-23 16:02:08 +01:00
bootnodes.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
config.go params: print time value instead of pointer in ConfigCompatError (#29514) 2025-06-10 15:08:38 +01:00
config.libevm.go refactor!: temporary extras require proof of global lock (#238) 2025-10-16 14:27:15 +00:00
config.libevm_test.go refactor!: temporary extras require proof of global lock (#238) 2025-10-16 14:27:15 +00:00
config_test.go params: print time value instead of pointer in ConfigCompatError (#29514) 2025-06-10 15:08:38 +01:00
dao.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
denomination.go build: upgrade to go 1.19 (#25726) 2022-09-10 13:25:40 +02:00
example.libevm_test.go refactor!: consolidate params and types payload access (#84) 2024-12-09 18:32:15 +00:00
hooks.libevm.go feat!: disambiguate EVM-semantic and raw caller/self addresses for precompiles (#211) 2025-08-07 23:48:32 +01:00
hooks.libevm_test.go refactor!: consolidate params and types payload access (#84) 2024-12-09 18:32:15 +00:00
json.libevm.go chore: placate goheader (#195) 2025-06-23 15:25:18 +00:00
json.libevm_test.go chore: placate goheader (#195) 2025-06-23 15:25:18 +00:00
network_params.go les: historical data garbage collection (#19570) 2020-07-13 11:02:54 +02:00
protocol_params.go core/vm: implement EIP-7951 - precompile for secp256r1 (#31991) 2025-08-13 16:39:36 -04:00
version.go params: release Geth v1.13.14 2024-02-27 13:50:30 +02:00
version.libevm.go chore: placate goheader (#195) 2025-06-23 15:25:18 +00:00
version.libevm_test.go chore: placate goheader (#195) 2025-06-23 15:25:18 +00:00