Skip to content

Commit f02e5c7

Browse files
committed
Merge branch 'ceyonur/acp-226-min-block-delay-builder' of github.com:ava-labs/coreth into ceyonur/acp-226-min-block-delay-builder
2 parents ebfa1a5 + ce38349 commit f02e5c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+910
-847
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobs:
100100
with:
101101
go-version-file: "go.mod"
102102
- name: Run e2e tests
103-
uses: ava-labs/avalanchego/.github/actions/run-monitored-tmpnet-cmd@8b8ac94577fec62b1dbd6636e116452b8b4208a5
103+
uses: ava-labs/avalanchego/.github/actions/run-monitored-tmpnet-cmd@3f91f67b9b4c0a99e75c572bae7a67334e73a289
104104
with:
105105
run: ./scripts/run_task.sh test-e2e-ci
106106
prometheus_url: ${{ secrets.PROMETHEUS_URL || '' }}
@@ -132,7 +132,7 @@ jobs:
132132
ref: ${{ github.event.inputs.avalanchegoBranch }}
133133
path: avalanchego
134134
- name: Run Warp E2E Tests
135-
uses: ava-labs/avalanchego/.github/actions/run-monitored-tmpnet-cmd@8b8ac94577fec62b1dbd6636e116452b8b4208a5
135+
uses: ava-labs/avalanchego/.github/actions/run-monitored-tmpnet-cmd@3f91f67b9b4c0a99e75c572bae7a67334e73a289
136136
with:
137137
run: ./scripts/run_task.sh test-e2e-warp-ci
138138
artifact_prefix: warp

accounts/abi/bind/bind_extra_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package bind_test
66
import (
77
"bytes"
88
"math/big"
9+
"os"
910
"testing"
1011

1112
"github.com/ava-labs/libevm/common"
@@ -16,12 +17,21 @@ import (
1617
"github.com/ava-labs/coreth/accounts/abi"
1718
"github.com/ava-labs/coreth/accounts/abi/bind"
1819
"github.com/ava-labs/coreth/accounts/abi/bind/backends"
20+
"github.com/ava-labs/coreth/core"
1921
"github.com/ava-labs/coreth/eth/ethconfig"
2022
"github.com/ava-labs/coreth/ethclient/simulated"
2123
"github.com/ava-labs/coreth/node"
2224
"github.com/ava-labs/coreth/params"
25+
"github.com/ava-labs/coreth/plugin/evm/customtypes"
2326
)
2427

28+
func TestMain(m *testing.M) {
29+
core.RegisterExtras()
30+
customtypes.Register()
31+
params.RegisterExtras()
32+
os.Exit(m.Run())
33+
}
34+
2535
// TestGetSenderNativeAssetCall checks that the NativeAssetCall proxies the
2636
// caller address This behavior is disabled on the network and is only to test
2737
// previous behavior. Note the test uses [params.TestApricotPhase2Config].

accounts/abi/bind/bind_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,10 +2156,21 @@ func golangBindings(t *testing.T, overload bool) {
21562156
21572157
import (
21582158
"testing"
2159+
2160+
"github.com/ava-labs/coreth/params"
2161+
"github.com/ava-labs/coreth/plugin/evm/customtypes"
2162+
libevmparams "github.com/ava-labs/libevm/params"
2163+
libevmtypes "github.com/ava-labs/libevm/core/types"
2164+
21592165
%s
21602166
)
21612167
21622168
func Test%s(t *testing.T) {
2169+
customtypes.Register()
2170+
t.Cleanup(libevmtypes.TestOnlyClearRegisteredExtras)
2171+
params.RegisterExtras()
2172+
t.Cleanup(libevmparams.TestOnlyClearRegisteredExtras)
2173+
21632174
%s
21642175
}
21652176
`, tt.imports, tt.name, tt.tester)

core/evm.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,14 @@ import (
4545
"github.com/holiman/uint256"
4646
)
4747

48-
func init() {
48+
// RegisterExtras registers hooks with libevm to achieve Avalanche behaviour of
49+
// the EVM. It MUST NOT be called more than once and therefore is only allowed
50+
// to be used in tests and `package main`, to avoid polluting other packages
51+
// that transitively depend on this one but don't need registration.
52+
func RegisterExtras() {
53+
// Although the registration function refers to just Hooks (not Extras) this
54+
// will be changed in the future to standardise across libevm, hence the
55+
// name of the function we're in.
4956
vm.RegisterHooks(hooks{})
5057
}
5158

core/extstate/statedb.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ import (
1717
"github.com/ava-labs/coreth/plugin/evm/customtypes"
1818
)
1919

20-
// Register the state key normalization to libevm's [state.StateDB]. This will
21-
// normalize all state keys passing through the implementation unless
22-
// [stateconf.SkipStateKeyTransformation] is provided as an option.
23-
func init() {
20+
// RegisterExtras registers hooks with libevm to achieve Avalanche state
21+
// management. It MUST NOT be called more than once and therefore is only
22+
// allowed to be used in tests and `package main`, to avoid polluting other
23+
// packages that transitively depend on this one but don't need registration.
24+
//
25+
// Of note, a call to RegisterExtras will result in state-key normalization
26+
// unless [stateconf.SkipStateKeyTransformation] is used.
27+
func RegisterExtras() {
2428
state.RegisterExtras(normalizeStateKeysHook{})
2529
}
2630

core/extstate/statedb_multicoin_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package extstate
55

66
import (
77
"math/big"
8+
"os"
89
"testing"
910

1011
"github.com/ava-labs/libevm/common"
@@ -20,6 +21,11 @@ import (
2021
"github.com/ava-labs/coreth/plugin/evm/customtypes"
2122
)
2223

24+
func TestMain(m *testing.M) {
25+
customtypes.Register()
26+
os.Exit(m.Run())
27+
}
28+
2329
func TestMultiCoinOperations(t *testing.T) {
2430
memdb := rawdb.NewMemoryDatabase()
2531
db := state.NewDatabase(memdb)

core/main_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,21 @@ import (
77
"testing"
88

99
"go.uber.org/goleak"
10+
11+
"github.com/ava-labs/coreth/core/extstate"
12+
"github.com/ava-labs/coreth/params"
13+
"github.com/ava-labs/coreth/plugin/evm/customtypes"
1014
)
1115

1216
// TestMain uses goleak to verify tests in this package do not leak unexpected
1317
// goroutines.
1418
func TestMain(m *testing.M) {
19+
RegisterExtras()
20+
21+
customtypes.Register()
22+
extstate.RegisterExtras()
23+
params.RegisterExtras()
24+
1525
opts := []goleak.Option{
1626
// No good way to shut down these goroutines:
1727
goleak.IgnoreTopFunction("github.com/ava-labs/coreth/core/state/snapshot.(*diskLayer).generate"),

core/state/snapshot/generate_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
"testing"
3434
"time"
3535

36+
"github.com/ava-labs/coreth/plugin/evm/customtypes"
3637
"github.com/ava-labs/coreth/triedb/hashdb"
3738
"github.com/ava-labs/coreth/triedb/pathdb"
3839
"github.com/ava-labs/libevm/common"
@@ -48,6 +49,11 @@ import (
4849
"golang.org/x/crypto/sha3"
4950
)
5051

52+
func TestMain(m *testing.M) {
53+
customtypes.Register()
54+
os.Exit(m.Run())
55+
}
56+
5157
var testBlockHash = common.HexToHash("0xdeadbeef")
5258

5359
func hashData(input []byte) common.Hash {

core/txpool/blobpool/blobpool_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ var (
7373
var testChainConfig *params.ChainConfig
7474

7575
func init() {
76+
params.RegisterExtras()
77+
7678
testChainConfig = new(params.ChainConfig)
7779
*testChainConfig = params.Copy(params.TestChainConfig)
7880

core/txpool/legacypool/legacypool_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ var (
6262
eip1559Config *params.ChainConfig
6363
)
6464

65+
func TestMain(m *testing.M) {
66+
params.RegisterExtras()
67+
os.Exit(m.Run())
68+
}
69+
6570
func init() {
6671
cpy := *params.TestChainConfig
6772
eip1559Config = &cpy

0 commit comments

Comments
 (0)