Skip to content

Commit 95741b1

Browse files
s1nafjl
andauthored
core: move genesis alloc types to core/types (#29003)
We want to use these types in public user-facing APIs, so they shouldn't be in core. Co-authored-by: Felix Lange <[email protected]>
1 parent 3c30de2 commit 95741b1

Some content is hidden

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

45 files changed

+328
-287
lines changed

accounts/abi/bind/backends/simulated.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"context"
2121

2222
"github.com/ethereum/go-ethereum/common"
23-
"github.com/ethereum/go-ethereum/core"
23+
"github.com/ethereum/go-ethereum/core/types"
2424
"github.com/ethereum/go-ethereum/ethclient/simulated"
2525
)
2626

@@ -43,7 +43,7 @@ func (b *SimulatedBackend) Fork(ctx context.Context, parentHash common.Hash) err
4343
//
4444
// Deprecated: please use simulated.Backend from package
4545
// github.com/ethereum/go-ethereum/ethclient/simulated instead.
46-
func NewSimulatedBackend(alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBackend {
46+
func NewSimulatedBackend(alloc types.GenesisAlloc, gasLimit uint64) *SimulatedBackend {
4747
b := simulated.NewBackend(alloc, simulated.WithBlockGasLimit(gasLimit))
4848
return &SimulatedBackend{
4949
Backend: b,

accounts/abi/bind/bind_test.go

Lines changed: 50 additions & 50 deletions
Large diffs are not rendered by default.

accounts/abi/bind/util_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525

2626
"github.com/ethereum/go-ethereum/accounts/abi/bind"
2727
"github.com/ethereum/go-ethereum/common"
28-
"github.com/ethereum/go-ethereum/core"
2928
"github.com/ethereum/go-ethereum/core/types"
3029
"github.com/ethereum/go-ethereum/crypto"
3130
"github.com/ethereum/go-ethereum/ethclient/simulated"
@@ -57,7 +56,7 @@ func TestWaitDeployed(t *testing.T) {
5756
t.Parallel()
5857
for name, test := range waitDeployedTests {
5958
backend := simulated.NewBackend(
60-
core.GenesisAlloc{
59+
types.GenesisAlloc{
6160
crypto.PubkeyToAddress(testKey.PublicKey): {Balance: big.NewInt(10000000000000000)},
6261
},
6362
)
@@ -102,7 +101,7 @@ func TestWaitDeployed(t *testing.T) {
102101

103102
func TestWaitDeployedCornerCases(t *testing.T) {
104103
backend := simulated.NewBackend(
105-
core.GenesisAlloc{
104+
types.GenesisAlloc{
106105
crypto.PubkeyToAddress(testKey.PublicKey): {Balance: big.NewInt(10000000000000000)},
107106
},
108107
)

cmd/evm/internal/t8ntool/execution.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ import (
4242
)
4343

4444
type Prestate struct {
45-
Env stEnv `json:"env"`
46-
Pre core.GenesisAlloc `json:"pre"`
45+
Env stEnv `json:"env"`
46+
Pre types.GenesisAlloc `json:"pre"`
4747
}
4848

4949
// ExecutionResult contains the execution status after running a state test, any
@@ -355,7 +355,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
355355
return statedb, execRs, body, nil
356356
}
357357

358-
func MakePreState(db ethdb.Database, accounts core.GenesisAlloc) *state.StateDB {
358+
func MakePreState(db ethdb.Database, accounts types.GenesisAlloc) *state.StateDB {
359359
sdb := state.NewDatabaseWithConfig(db, &triedb.Config{Preimages: true})
360360
statedb, _ := state.New(types.EmptyRootHash, sdb, nil)
361361
for addr, a := range accounts {

cmd/evm/internal/t8ntool/transition.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"github.com/ethereum/go-ethereum/common"
2828
"github.com/ethereum/go-ethereum/common/hexutil"
2929
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
30-
"github.com/ethereum/go-ethereum/core"
3130
"github.com/ethereum/go-ethereum/core/state"
3231
"github.com/ethereum/go-ethereum/core/types"
3332
"github.com/ethereum/go-ethereum/core/vm"
@@ -74,10 +73,10 @@ var (
7473
)
7574

7675
type input struct {
77-
Alloc core.GenesisAlloc `json:"alloc,omitempty"`
78-
Env *stEnv `json:"env,omitempty"`
79-
Txs []*txWithKey `json:"txs,omitempty"`
80-
TxRlp string `json:"txsRlp,omitempty"`
76+
Alloc types.GenesisAlloc `json:"alloc,omitempty"`
77+
Env *stEnv `json:"env,omitempty"`
78+
Txs []*txWithKey `json:"txs,omitempty"`
79+
TxRlp string `json:"txsRlp,omitempty"`
8180
}
8281

8382
func Transition(ctx *cli.Context) error {
@@ -272,7 +271,7 @@ func applyCancunChecks(env *stEnv, chainConfig *params.ChainConfig) error {
272271
return nil
273272
}
274273

275-
type Alloc map[common.Address]core.GenesisAccount
274+
type Alloc map[common.Address]types.Account
276275

277276
func (g Alloc) OnRoot(common.Hash) {}
278277

@@ -288,7 +287,7 @@ func (g Alloc) OnAccount(addr *common.Address, dumpAccount state.DumpAccount) {
288287
storage[k] = common.HexToHash(v)
289288
}
290289
}
291-
genesisAccount := core.GenesisAccount{
290+
genesisAccount := types.Account{
292291
Code: dumpAccount.Code,
293292
Storage: storage,
294293
Balance: balance,

cmd/utils/history_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func TestHistoryImportAndExport(t *testing.T) {
5050
address = crypto.PubkeyToAddress(key.PublicKey)
5151
genesis = &core.Genesis{
5252
Config: params.TestChainConfig,
53-
Alloc: core.GenesisAlloc{address: {Balance: big.NewInt(1000000000000000000)}},
53+
Alloc: types.GenesisAlloc{address: {Balance: big.NewInt(1000000000000000000)}},
5454
}
5555
signer = types.LatestSigner(genesis.Config)
5656
)

consensus/clique/clique_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func TestReimportMirroredState(t *testing.T) {
4747
genspec := &core.Genesis{
4848
Config: params.AllCliqueProtocolChanges,
4949
ExtraData: make([]byte, extraVanity+common.AddressLength+extraSeal),
50-
Alloc: map[common.Address]core.GenesisAccount{
50+
Alloc: map[common.Address]types.Account{
5151
addr: {Balance: big.NewInt(10000000000000000)},
5252
},
5353
BaseFee: big.NewInt(params.InitialBaseFee),

core/bench_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func benchInsertChain(b *testing.B, disk bool, gen func(int, *BlockGen)) {
189189
// generator function.
190190
gspec := &Genesis{
191191
Config: params.TestChainConfig,
192-
Alloc: GenesisAlloc{benchRootAddr: {Balance: benchRootFunds}},
192+
Alloc: types.GenesisAlloc{benchRootAddr: {Balance: benchRootFunds}},
193193
}
194194
_, chain, _ := GenerateChainWithGenesis(gspec, ethash.NewFaker(), b.N, gen)
195195

core/block_validator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func testHeaderVerificationForMerging(t *testing.T, isClique bool) {
106106
gspec = &Genesis{
107107
Config: &config,
108108
ExtraData: make([]byte, 32+common.AddressLength+crypto.SignatureLength),
109-
Alloc: map[common.Address]GenesisAccount{
109+
Alloc: map[common.Address]types.Account{
110110
addr: {Balance: big.NewInt(1)},
111111
},
112112
BaseFee: big.NewInt(params.InitialBaseFee),

core/blockchain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2455,7 +2455,7 @@ func (bc *BlockChain) SetTrieFlushInterval(interval time.Duration) {
24552455
bc.flushInterval.Store(int64(interval))
24562456
}
24572457

2458-
// GetTrieFlushInterval gets the in-memory tries flush interval
2458+
// GetTrieFlushInterval gets the in-memory tries flushAlloc interval
24592459
func (bc *BlockChain) GetTrieFlushInterval() time.Duration {
24602460
return time.Duration(bc.flushInterval.Load())
24612461
}

0 commit comments

Comments
 (0)