Skip to content

Conversation

ARR4N
Copy link
Collaborator

@ARR4N ARR4N commented Oct 8, 2025

Why this should be merged

How this works

How this was tested

Need to be documented?

Need to update RELEASES.md?

@ARR4N ARR4N self-assigned this Oct 8, 2025
@ARR4N ARR4N force-pushed the arr4n/temp-override-all-extras branch from 5b3787d to ee36ebc Compare October 8, 2025 13:54
@ARR4N ARR4N changed the title feat!: evm.WithTempRegisteredExtras() global override feat!: evm.WithTempRegisteredLibEVMExtras() global override Oct 8, 2025
@ARR4N ARR4N changed the title feat!: evm.WithTempRegisteredLibEVMExtras() global override feat!: evm.WithTempRegisteredLibEVMExtras() Oct 8, 2025
ARR4N added a commit to ava-labs/libevm that referenced this pull request Oct 16, 2025
## 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 ava-labs/coreth#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants