Skip to content

Commit aab9fc8

Browse files
Merge branch 'master' into JonathanOppenheimer/cleanup-ptr-to
Signed-off-by: Jonathan Oppenheimer <jonathan.oppenheimer@avalabs.org>
2 parents f1c4a04 + 6c57d8a commit aab9fc8

File tree

18 files changed

+263
-64
lines changed

18 files changed

+263
-64
lines changed

core/evm.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
"github.com/ava-labs/libevm/core/state"
4242
"github.com/ava-labs/libevm/core/types"
4343
"github.com/ava-labs/libevm/core/vm"
44+
"github.com/ava-labs/libevm/libevm"
4445
"github.com/ava-labs/libevm/libevm/stateconf"
4546
"github.com/holiman/uint256"
4647
)
@@ -56,6 +57,16 @@ func RegisterExtras() {
5657
vm.RegisterHooks(hooks{})
5758
}
5859

60+
// WithTempRegisteredExtras runs `fn` with temporary registration otherwise
61+
// equivalent to a call to [RegisterExtras], but limited to the life of `fn`.
62+
//
63+
// This function is not intended for direct use. Use
64+
// `evm.WithTempRegisteredLibEVMExtras()` instead as it calls this along with
65+
// all other temporary-registration functions.
66+
func WithTempRegisteredExtras(lock libevm.ExtrasLock, fn func() error) error {
67+
return vm.WithTempRegisteredHooks(lock, hooks{}, fn)
68+
}
69+
5970
type hooks struct{}
6071

6172
// OverrideNewEVMArgs is a hook that is called in [vm.NewEVM].

core/extstate/statedb.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/ava-labs/libevm/common"
1111
"github.com/ava-labs/libevm/core/state"
1212
"github.com/ava-labs/libevm/core/types"
13+
"github.com/ava-labs/libevm/libevm"
1314
"github.com/ava-labs/libevm/libevm/stateconf"
1415
"github.com/holiman/uint256"
1516

@@ -28,6 +29,16 @@ func RegisterExtras() {
2829
state.RegisterExtras(normalizeStateKeysHook{})
2930
}
3031

32+
// WithTempRegisteredExtras runs `fn` with temporary registration otherwise
33+
// equivalent to a call to [RegisterExtras], but limited to the life of `fn`.
34+
//
35+
// This function is not intended for direct use. Use
36+
// `evm.WithTempRegisteredLibEVMExtras()` instead as it calls this along with
37+
// all other temporary-registration functions.
38+
func WithTempRegisteredExtras(lock libevm.ExtrasLock, fn func() error) error {
39+
return state.WithTempRegisteredExtras(lock, normalizeStateKeysHook{}, fn)
40+
}
41+
3142
type normalizeStateKeysHook struct{}
3243

3344
// TransformStateKey transforms all keys with [normalizeStateKey].
@@ -90,8 +101,8 @@ func (s *StateDB) AddBalanceMultiCoin(addr common.Address, coinID common.Hash, a
90101
return
91102
}
92103

93-
if !state.GetExtra(s.StateDB, customtypes.IsMultiCoinPayloads, addr) {
94-
state.SetExtra(s.StateDB, customtypes.IsMultiCoinPayloads, addr, true)
104+
if !customtypes.IsMultiCoin(s.StateDB, addr) {
105+
customtypes.SetMultiCoin(s.StateDB, addr, true)
95106
}
96107

97108
newAmount := new(big.Int).Add(s.GetBalanceMultiCoin(addr, coinID), amount)
@@ -107,8 +118,8 @@ func (s *StateDB) SubBalanceMultiCoin(addr common.Address, coinID common.Hash, a
107118
// Note: It's not needed to set the IsMultiCoin (extras) flag here, as this
108119
// call would always be preceded by a call to AddBalanceMultiCoin, which would
109120
// set the extra flag. Seems we should remove the redundant code.
110-
if !state.GetExtra(s.StateDB, customtypes.IsMultiCoinPayloads, addr) {
111-
state.SetExtra(s.StateDB, customtypes.IsMultiCoinPayloads, addr, true)
121+
if !customtypes.IsMultiCoin(s.StateDB, addr) {
122+
customtypes.SetMultiCoin(s.StateDB, addr, true)
112123
}
113124
newAmount := new(big.Int).Sub(s.GetBalanceMultiCoin(addr, coinID), amount)
114125
normalizeCoinID(&coinID)

core/extstate/statedb_multicoin_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func TestGenerateMultiCoinAccounts(t *testing.T) {
169169
snap := snaps.Snapshot(root)
170170
snapAccount, err := snap.Account(addrHash)
171171
require.NoError(t, err, "getting account from snapshot")
172-
require.True(t, customtypes.IsMultiCoin(snapAccount), "snap account must be multi-coin")
172+
require.True(t, customtypes.IsAccountMultiCoin(snapAccount), "snap account must be multi-coin")
173173

174174
normalizeCoinID(&assetID)
175175
assetHash := crypto.Keccak256Hash(assetID.Bytes())

core/main_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
package core
55

66
import (
7+
"os"
78
"testing"
89

10+
"github.com/ava-labs/libevm/log"
911
"go.uber.org/goleak"
1012

1113
"github.com/ava-labs/coreth/core/extstate"
@@ -22,6 +24,9 @@ func TestMain(m *testing.M) {
2224
extstate.RegisterExtras()
2325
params.RegisterExtras()
2426

27+
// May of these tests are likely to fail due to `log.Crit` in goroutines.
28+
log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelCrit, true)))
29+
2530
opts := []goleak.Option{
2631
// No good way to shut down these goroutines:
2732
goleak.IgnoreTopFunction("github.com/ava-labs/coreth/core/state/snapshot.(*diskLayer).generate"),

go.mod

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ require (
1818
github.com/VictoriaMetrics/fastcache v1.12.1
1919
github.com/ava-labs/avalanchego v1.13.6-0.20251007213349-63cc1a166a56
2020
github.com/ava-labs/firewood-go-ethhash/ffi v0.0.13
21-
github.com/ava-labs/libevm v1.13.15-0.20251002164226-35926db4d661
21+
github.com/ava-labs/libevm v1.13.15-0.20251016142715-1bccf4f2ddb2
2222
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
2323
github.com/deckarep/golang-set/v2 v2.1.0
2424
github.com/fjl/gencodec v0.1.1
@@ -44,11 +44,11 @@ require (
4444
go.uber.org/goleak v1.3.0
4545
go.uber.org/mock v0.5.0
4646
go.uber.org/zap v1.27.0
47-
golang.org/x/crypto v0.42.0
47+
golang.org/x/crypto v0.43.0
4848
golang.org/x/exp v0.0.0-20241215155358-4a5509556b9e
4949
golang.org/x/sync v0.17.0
5050
golang.org/x/time v0.12.0
51-
golang.org/x/tools v0.37.0
51+
golang.org/x/tools v0.38.0
5252
google.golang.org/protobuf v1.36.8
5353
gopkg.in/natefinch/lumberjack.v2 v2.0.0
5454
)
@@ -163,12 +163,12 @@ require (
163163
go.opentelemetry.io/otel/trace v1.37.0 // indirect
164164
go.opentelemetry.io/proto/otlp v1.7.0 // indirect
165165
go.uber.org/multierr v1.11.0 // indirect
166-
golang.org/x/mod v0.28.0 // indirect
167-
golang.org/x/net v0.44.0 // indirect
166+
golang.org/x/mod v0.29.0 // indirect
167+
golang.org/x/net v0.46.0 // indirect
168168
golang.org/x/oauth2 v0.30.0 // indirect
169-
golang.org/x/sys v0.36.0 // indirect
170-
golang.org/x/term v0.35.0 // indirect
171-
golang.org/x/text v0.29.0 // indirect
169+
golang.org/x/sys v0.37.0 // indirect
170+
golang.org/x/term v0.36.0 // indirect
171+
golang.org/x/text v0.30.0 // indirect
172172
gonum.org/v1/gonum v0.16.0 // indirect
173173
google.golang.org/genproto/googleapis/api v0.0.0-20250707201910-8d1bb00bc6a7 // indirect
174174
google.golang.org/genproto/googleapis/rpc v0.0.0-20250818200422-3122310a409c // indirect

go.sum

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ github.com/ava-labs/avalanchego v1.13.6-0.20251007213349-63cc1a166a56 h1:Q4lnXtj
3030
github.com/ava-labs/avalanchego v1.13.6-0.20251007213349-63cc1a166a56/go.mod h1:EL0MGbL2liE9jp4QtCHR2thkNl8hCkD26DJ+7cmcaqs=
3131
github.com/ava-labs/firewood-go-ethhash/ffi v0.0.13 h1:obPwnVCkF5+B2f8WbTepHj0ZgiW21vKUgFCtATuAYNY=
3232
github.com/ava-labs/firewood-go-ethhash/ffi v0.0.13/go.mod h1:gsGr1ICjokI9CyPaaRHMqDoDCaT1VguC/IyOTx6rJ14=
33-
github.com/ava-labs/libevm v1.13.15-0.20251002164226-35926db4d661 h1:lt4yQE1HMvxWrdD5RFj+h9kWUsZK2rmNohvkeQsbG9M=
34-
github.com/ava-labs/libevm v1.13.15-0.20251002164226-35926db4d661/go.mod h1:ivRC/KojP8sai7j8WnpXIReQpcRklL2bIzoysnjpARQ=
33+
github.com/ava-labs/libevm v1.13.15-0.20251016142715-1bccf4f2ddb2 h1:hQ15IJxY7WOKqeJqCXawsiXh0NZTzmoQOemkWHz7rr4=
34+
github.com/ava-labs/libevm v1.13.15-0.20251016142715-1bccf4f2ddb2/go.mod h1:DqSotSn4Dx/UJV+d3svfW8raR+cH7+Ohl9BpsQ5HlGU=
3535
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
3636
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
3737
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
@@ -578,8 +578,8 @@ golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPh
578578
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
579579
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
580580
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
581-
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
582-
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
581+
golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04=
582+
golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0=
583583
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
584584
golang.org/x/exp v0.0.0-20241215155358-4a5509556b9e h1:4qufH0hlUYs6AO6XmZC3GqfDPGSXHVXUFR6OND+iJX4=
585585
golang.org/x/exp v0.0.0-20241215155358-4a5509556b9e/go.mod h1:qj5a5QZpwLU2NLQudwIN5koi3beDhSAlJwa67PuM98c=
@@ -592,8 +592,8 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
592592
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
593593
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
594594
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
595-
golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U=
596-
golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI=
595+
golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA=
596+
golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w=
597597
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
598598
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
599599
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -618,8 +618,8 @@ golang.org/x/net v0.0.0-20211008194852-3b03d305991f/go.mod h1:9nx3DQGgdP8bBQD5qx
618618
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
619619
golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
620620
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
621-
golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I=
622-
golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
621+
golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4=
622+
golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210=
623623
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
624624
golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
625625
golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=
@@ -671,21 +671,21 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
671671
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
672672
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
673673
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
674-
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
675-
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
674+
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
675+
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
676676
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
677677
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
678-
golang.org/x/term v0.35.0 h1:bZBVKBudEyhRcajGcNc3jIfWPqV4y/Kt2XcoigOWtDQ=
679-
golang.org/x/term v0.35.0/go.mod h1:TPGtkTLesOwf2DE8CgVYiZinHAOuy5AYUYT1lENIZnA=
678+
golang.org/x/term v0.36.0 h1:zMPR+aF8gfksFprF/Nc/rd1wRS1EI6nDBGyWAvDzx2Q=
679+
golang.org/x/term v0.36.0/go.mod h1:Qu394IJq6V6dCBRgwqshf3mPF85AqzYEzofzRdZkWss=
680680
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
681681
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
682682
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
683683
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
684684
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
685685
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
686686
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
687-
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
688-
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
687+
golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k=
688+
golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM=
689689
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
690690
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
691691
golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
@@ -704,8 +704,8 @@ golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4f
704704
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
705705
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
706706
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
707-
golang.org/x/tools v0.37.0 h1:DVSRzp7FwePZW356yEAChSdNcQo6Nsp+fex1SUW09lE=
708-
golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w=
707+
golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ=
708+
golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs=
709709
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
710710
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
711711
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

params/config.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232

3333
"github.com/ava-labs/coreth/params/extras"
3434
"github.com/ava-labs/coreth/utils"
35+
"github.com/ava-labs/libevm/libevm"
3536
ethparams "github.com/ava-labs/libevm/params"
3637
)
3738

@@ -46,7 +47,12 @@ var (
4647
)
4748

4849
func init() {
49-
WithTempRegisteredExtras(initialiseChainConfigs)
50+
libevm.WithTemporaryExtrasLock(func(l libevm.ExtrasLock) error {
51+
return WithTempRegisteredExtras(l, func() error {
52+
initialiseChainConfigs()
53+
return nil
54+
})
55+
})
5056
}
5157

5258
var (

params/config_libevm.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"math/big"
88

99
"github.com/ava-labs/libevm/common"
10+
"github.com/ava-labs/libevm/libevm"
1011

1112
"github.com/ava-labs/coreth/params/extras"
1213
"github.com/ava-labs/coreth/precompile/modules"
@@ -34,16 +35,22 @@ func RegisterExtras() {
3435
}
3536

3637
// WithTempRegisteredExtras runs `fn` with temporary registration otherwise
37-
// equivalent to a call to [RegisterExtras], but limited to the life of `fn`. It
38-
// is not threadsafe.
39-
func WithTempRegisteredExtras(fn func()) {
38+
// equivalent to a call to [RegisterExtras], but limited to the life of `fn`.
39+
//
40+
// This function is not intended for direct use. Use
41+
// `evm.WithTempRegisteredLibEVMExtras()` instead as it calls this along with
42+
// all other temporary-registration functions.
43+
func WithTempRegisteredExtras(lock libevm.ExtrasLock, fn func() error) error {
4044
old := payloads
4145
defer func() { payloads = old }()
4246

43-
ethparams.WithTempRegisteredExtras(extrasToRegister(), func(extras ethparams.ExtraPayloads[*extras.ChainConfig, RulesExtra]) {
44-
payloads = extras
45-
fn()
46-
})
47+
return ethparams.WithTempRegisteredExtras(
48+
lock, extrasToRegister(),
49+
func(extras ethparams.ExtraPayloads[*extras.ChainConfig, RulesExtra]) error {
50+
payloads = extras
51+
return fn()
52+
},
53+
)
4754
}
4855

4956
var payloads ethparams.ExtraPayloads[*extras.ChainConfig, RulesExtra]
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved.
2+
// See the file LICENSE for licensing terms.
3+
4+
package customtypes
5+
6+
import "github.com/ava-labs/libevm/core/types"
7+
8+
// TODO(arr4n) These tests were originally part of the `coreth/core/types`
9+
// package so assume the presence of identifiers. Aliases reduce PR noise during
10+
// the refactoring.
11+
12+
type (
13+
AccessListTx = types.AccessListTx
14+
Block = types.Block
15+
BlockNonce = types.BlockNonce
16+
Bloom = types.Bloom
17+
Body = types.Body
18+
DynamicFeeTx = types.DynamicFeeTx
19+
Header = types.Header
20+
LegacyTx = types.LegacyTx
21+
Log = types.Log
22+
Receipt = types.Receipt
23+
ReceiptForStorage = types.ReceiptForStorage
24+
Receipts = types.Receipts
25+
Transaction = types.Transaction
26+
Transactions = types.Transactions
27+
Withdrawal = types.Withdrawal
28+
Withdrawals = types.Withdrawals
29+
)
30+
31+
var (
32+
// Function aliases in production code MUST be `func` declarations, not
33+
// variables; this is only acceptable in tests.
34+
CopyHeader = types.CopyHeader
35+
MustSignNewTx = types.MustSignNewTx
36+
NewBlock = types.NewBlock
37+
NewLondonSigner = types.NewLondonSigner
38+
NewTransaction = types.NewTransaction
39+
)
40+
41+
const ReceiptStatusSuccessful = types.ReceiptStatusSuccessful

plugin/evm/customtypes/block_ext_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ import (
1919
"github.com/stretchr/testify/require"
2020

2121
"github.com/ava-labs/coreth/utils"
22-
23-
// TODO(arr4n) These tests were originally part of the `coreth/core/types`
24-
// package so assume the presence of identifiers. A dot-import reduces PR
25-
// noise during the refactoring.
26-
. "github.com/ava-labs/libevm/core/types"
22+
"github.com/ava-labs/coreth/utils/utilstest"
2723
)
2824

2925
func TestCopyHeader(t *testing.T) {

0 commit comments

Comments
 (0)