mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-20 05:41:35 +00:00
## 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. |
||
|---|---|---|
| .. | ||
| runtime | ||
| testdata | ||
| analysis.go | ||
| analysis_test.go | ||
| common.go | ||
| contract.go | ||
| contracts.go | ||
| contracts.libevm.go | ||
| contracts.libevm_test.go | ||
| contracts_fuzz_test.go | ||
| contracts_pkg_vm.libevm_test.go | ||
| contracts_test.go | ||
| doc.go | ||
| eips.go | ||
| environment.libevm.go | ||
| errors.go | ||
| evm.go | ||
| evm.libevm.go | ||
| evm.libevm_test.go | ||
| gas.go | ||
| gas_table.go | ||
| gas_table_test.go | ||
| hooks.libevm.go | ||
| instructions.go | ||
| instructions_test.go | ||
| interface.go | ||
| interpreter.go | ||
| interpreter_test.go | ||
| jump_table.go | ||
| jump_table_export.go | ||
| jump_table_test.go | ||
| libevm_test.go | ||
| logger.go | ||
| memory.go | ||
| memory_table.go | ||
| memory_test.go | ||
| opcodes.go | ||
| operations_acl.go | ||
| options.libevm.go | ||
| stack.go | ||
| stack.libevm.go | ||
| stack.libevm_test.go | ||
| stack_table.go | ||