Skip to content

Commit 2198d0f

Browse files
committed
all: rename blockchain option
1 parent 8b9f2d4 commit 2198d0f

36 files changed

+322
-290
lines changed

cmd/utils/flags.go

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2164,36 +2164,36 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
21642164
if err != nil {
21652165
Fatalf("%v", err)
21662166
}
2167-
cache := &core.CacheConfig{
2168-
TrieCleanLimit: ethconfig.Defaults.TrieCleanCache,
2169-
TrieCleanNoPrefetch: ctx.Bool(CacheNoPrefetchFlag.Name),
2170-
TrieDirtyLimit: ethconfig.Defaults.TrieDirtyCache,
2171-
TrieDirtyDisabled: ctx.String(GCModeFlag.Name) == "archive",
2172-
TrieTimeLimit: ethconfig.Defaults.TrieTimeout,
2173-
SnapshotLimit: ethconfig.Defaults.SnapshotCache,
2174-
Preimages: ctx.Bool(CachePreimagesFlag.Name),
2175-
StateScheme: scheme,
2176-
StateHistory: ctx.Uint64(StateHistoryFlag.Name),
2177-
}
2178-
if cache.TrieDirtyDisabled && !cache.Preimages {
2179-
cache.Preimages = true
2167+
options := &core.BlockchainOptions{
2168+
TrieCleanLimit: ethconfig.Defaults.TrieCleanCache,
2169+
NoPrefetch: ctx.Bool(CacheNoPrefetchFlag.Name),
2170+
TrieDirtyLimit: ethconfig.Defaults.TrieDirtyCache,
2171+
ArchiveMode: ctx.String(GCModeFlag.Name) == "archive",
2172+
TrieTimeLimit: ethconfig.Defaults.TrieTimeout,
2173+
SnapshotLimit: ethconfig.Defaults.SnapshotCache,
2174+
Preimages: ctx.Bool(CachePreimagesFlag.Name),
2175+
StateScheme: scheme,
2176+
StateHistory: ctx.Uint64(StateHistoryFlag.Name),
2177+
}
2178+
if options.ArchiveMode && !options.Preimages {
2179+
options.Preimages = true
21802180
log.Info("Enabling recording of key preimages since archive mode is used")
21812181
}
21822182
if !ctx.Bool(SnapshotFlag.Name) {
2183-
cache.SnapshotLimit = 0 // Disabled
2183+
options.SnapshotLimit = 0 // Disabled
21842184
} else if ctx.IsSet(CacheFlag.Name) || ctx.IsSet(CacheSnapshotFlag.Name) {
2185-
cache.SnapshotLimit = ctx.Int(CacheFlag.Name) * ctx.Int(CacheSnapshotFlag.Name) / 100
2185+
options.SnapshotLimit = ctx.Int(CacheFlag.Name) * ctx.Int(CacheSnapshotFlag.Name) / 100
21862186
}
21872187
// If we're in readonly, do not bother generating snapshot data.
21882188
if readonly {
2189-
cache.SnapshotNoBuild = true
2189+
options.SnapshotNoBuild = true
21902190
}
21912191

21922192
if ctx.IsSet(CacheFlag.Name) || ctx.IsSet(CacheTrieFlag.Name) {
2193-
cache.TrieCleanLimit = ctx.Int(CacheFlag.Name) * ctx.Int(CacheTrieFlag.Name) / 100
2193+
options.TrieCleanLimit = ctx.Int(CacheFlag.Name) * ctx.Int(CacheTrieFlag.Name) / 100
21942194
}
21952195
if ctx.IsSet(CacheFlag.Name) || ctx.IsSet(CacheGCFlag.Name) {
2196-
cache.TrieDirtyLimit = ctx.Int(CacheFlag.Name) * ctx.Int(CacheGCFlag.Name) / 100
2196+
options.TrieDirtyLimit = ctx.Int(CacheFlag.Name) * ctx.Int(CacheGCFlag.Name) / 100
21972197
}
21982198
vmcfg := vm.Config{
21992199
EnablePreimageRecording: ctx.Bool(VMEnableDebugFlag.Name),
@@ -2208,8 +2208,10 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
22082208
vmcfg.Tracer = t
22092209
}
22102210
}
2211+
options.VmConfig = vmcfg
2212+
22112213
// Disable transaction indexing/unindexing by default.
2212-
chain, err := core.NewBlockChain(chainDb, cache, gspec, nil, engine, vmcfg, nil)
2214+
chain, err := core.NewBlockChain(options, chainDb, gspec, engine)
22132215
if err != nil {
22142216
Fatalf("Can't create BlockChain: %v", err)
22152217
}

cmd/utils/history_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
"github.com/ethereum/go-ethereum/core"
3232
"github.com/ethereum/go-ethereum/core/rawdb"
3333
"github.com/ethereum/go-ethereum/core/types"
34-
"github.com/ethereum/go-ethereum/core/vm"
3534
"github.com/ethereum/go-ethereum/crypto"
3635
"github.com/ethereum/go-ethereum/internal/era"
3736
"github.com/ethereum/go-ethereum/params"
@@ -78,7 +77,7 @@ func TestHistoryImportAndExport(t *testing.T) {
7877
})
7978

8079
// Initialize BlockChain.
81-
chain, err := core.NewBlockChain(db, nil, genesis, nil, ethash.NewFaker(), vm.Config{}, nil)
80+
chain, err := core.NewBlockChain(nil, db, genesis, ethash.NewFaker())
8281
if err != nil {
8382
t.Fatalf("unable to initialize chain: %v", err)
8483
}
@@ -167,7 +166,7 @@ func TestHistoryImportAndExport(t *testing.T) {
167166
})
168167

169168
genesis.MustCommit(db2, triedb.NewDatabase(db2, triedb.HashDefaults))
170-
imported, err := core.NewBlockChain(db2, nil, genesis, nil, ethash.NewFaker(), vm.Config{}, nil)
169+
imported, err := core.NewBlockChain(nil, db2, genesis, ethash.NewFaker())
171170
if err != nil {
172171
t.Fatalf("unable to initialize chain: %v", err)
173172
}

consensus/clique/clique_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"github.com/ethereum/go-ethereum/core"
2525
"github.com/ethereum/go-ethereum/core/rawdb"
2626
"github.com/ethereum/go-ethereum/core/types"
27-
"github.com/ethereum/go-ethereum/core/vm"
2827
"github.com/ethereum/go-ethereum/crypto"
2928
"github.com/ethereum/go-ethereum/params"
3029
)
@@ -55,7 +54,7 @@ func TestReimportMirroredState(t *testing.T) {
5554
copy(genspec.ExtraData[extraVanity:], addr[:])
5655

5756
// Generate a batch of blocks, each properly signed
58-
chain, _ := core.NewBlockChain(rawdb.NewMemoryDatabase(), nil, genspec, nil, engine, vm.Config{}, nil)
57+
chain, _ := core.NewBlockChain(nil, rawdb.NewMemoryDatabase(), genspec, engine)
5958
defer chain.Stop()
6059

6160
_, blocks, _ := core.GenerateChainWithGenesis(genspec, engine, 3, func(i int, block *core.BlockGen) {
@@ -87,7 +86,7 @@ func TestReimportMirroredState(t *testing.T) {
8786
}
8887
// Insert the first two blocks and make sure the chain is valid
8988
db = rawdb.NewMemoryDatabase()
90-
chain, _ = core.NewBlockChain(db, nil, genspec, nil, engine, vm.Config{}, nil)
89+
chain, _ = core.NewBlockChain(nil, db, genspec, engine)
9190
defer chain.Stop()
9291

9392
if _, err := chain.InsertChain(blocks[:2]); err != nil {
@@ -100,7 +99,7 @@ func TestReimportMirroredState(t *testing.T) {
10099
// Simulate a crash by creating a new chain on top of the database, without
101100
// flushing the dirty states out. Insert the last block, triggering a sidechain
102101
// reimport.
103-
chain, _ = core.NewBlockChain(db, nil, genspec, nil, engine, vm.Config{}, nil)
102+
chain, _ = core.NewBlockChain(nil, db, genspec, engine)
104103
defer chain.Stop()
105104

106105
if _, err := chain.InsertChain(blocks[2:]); err != nil {

consensus/clique/snapshot_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"github.com/ethereum/go-ethereum/core"
2929
"github.com/ethereum/go-ethereum/core/rawdb"
3030
"github.com/ethereum/go-ethereum/core/types"
31-
"github.com/ethereum/go-ethereum/core/vm"
3231
"github.com/ethereum/go-ethereum/crypto"
3332
"github.com/ethereum/go-ethereum/params"
3433
)
@@ -458,7 +457,7 @@ func (tt *cliqueTest) run(t *testing.T) {
458457
batches[len(batches)-1] = append(batches[len(batches)-1], block)
459458
}
460459
// Pass all the headers through clique and ensure tallying succeeds
461-
chain, err := core.NewBlockChain(rawdb.NewMemoryDatabase(), nil, genesis, nil, engine, vm.Config{}, nil)
460+
chain, err := core.NewBlockChain(nil, rawdb.NewMemoryDatabase(), genesis, engine)
462461
if err != nil {
463462
t.Fatalf("failed to create test chain: %v", err)
464463
}

core/bench_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"github.com/ethereum/go-ethereum/consensus/ethash"
2727
"github.com/ethereum/go-ethereum/core/rawdb"
2828
"github.com/ethereum/go-ethereum/core/types"
29-
"github.com/ethereum/go-ethereum/core/vm"
3029
"github.com/ethereum/go-ethereum/crypto"
3130
"github.com/ethereum/go-ethereum/ethdb"
3231
"github.com/ethereum/go-ethereum/ethdb/pebble"
@@ -200,7 +199,7 @@ func benchInsertChain(b *testing.B, disk bool, gen func(int, *BlockGen)) {
200199

201200
// Time the insertion of the new chain.
202201
// State and blocks are stored in the same DB.
203-
chainman, _ := NewBlockChain(db, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil)
202+
chainman, _ := NewBlockChain(nil, db, gspec, ethash.NewFaker())
204203
defer chainman.Stop()
205204
b.ReportAllocs()
206205
b.ResetTimer()
@@ -325,8 +324,8 @@ func benchReadChain(b *testing.B, full bool, count uint64) {
325324
genesis := &Genesis{Config: params.AllEthashProtocolChanges}
326325
makeChainForBench(db, genesis, full, count)
327326
db.Close()
328-
cacheConfig := *defaultCacheConfig
329-
cacheConfig.TrieDirtyDisabled = true
327+
options := *defaultOptions
328+
options.ArchiveMode = true
330329

331330
b.ReportAllocs()
332331
b.ResetTimer()
@@ -338,7 +337,7 @@ func benchReadChain(b *testing.B, full bool, count uint64) {
338337
}
339338
db = rawdb.NewDatabase(pdb)
340339

341-
chain, err := NewBlockChain(db, &cacheConfig, genesis, nil, ethash.NewFaker(), vm.Config{}, nil)
340+
chain, err := NewBlockChain(&options, db, genesis, ethash.NewFaker())
342341
if err != nil {
343342
b.Fatalf("error creating chain: %v", err)
344343
}

core/block_validator_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"github.com/ethereum/go-ethereum/consensus/ethash"
2929
"github.com/ethereum/go-ethereum/core/rawdb"
3030
"github.com/ethereum/go-ethereum/core/types"
31-
"github.com/ethereum/go-ethereum/core/vm"
3231
"github.com/ethereum/go-ethereum/crypto"
3332
"github.com/ethereum/go-ethereum/params"
3433
)
@@ -50,7 +49,8 @@ func testHeaderVerification(t *testing.T, scheme string) {
5049
headers[i] = block.Header()
5150
}
5251
// Run the header checker for blocks one-by-one, checking for both valid and invalid nonces
53-
chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), DefaultCacheConfigWithScheme(scheme), gspec, nil, ethash.NewFaker(), vm.Config{}, nil)
52+
options := BlockchainOptionsWithScheme(scheme)
53+
chain, err := NewBlockChain(options, rawdb.NewMemoryDatabase(), gspec, ethash.NewFaker())
5454
defer chain.Stop()
5555
if err != nil {
5656
t.Fatal(err)
@@ -166,7 +166,7 @@ func testHeaderVerificationForMerging(t *testing.T, isClique bool) {
166166
postHeaders[i] = block.Header()
167167
}
168168
// Run the header checker for blocks one-by-one, checking for both valid and invalid nonces
169-
chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), nil, gspec, nil, engine, vm.Config{}, nil)
169+
chain, err := NewBlockChain(nil, rawdb.NewMemoryDatabase(), gspec, engine)
170170
defer chain.Stop()
171171
if err != nil {
172172
t.Fatal(err)

0 commit comments

Comments
 (0)