Skip to content

Commit b78b4ae

Browse files
committed
move enableStorehouse to caller
1 parent ac6da2b commit b78b4ae

3 files changed

Lines changed: 7 additions & 84 deletions

File tree

cmd/execution_builder.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,14 +883,19 @@ func (exeNode *ExecutionNode) LoadStopControl(
883883
func (exeNode *ExecutionNode) LoadRegisterStore(
884884
node *NodeConfig,
885885
) error {
886+
if !exeNode.exeConf.enableStorehouse {
887+
node.Logger.Info().Msg("register store disabled")
888+
exeNode.registerStore = nil
889+
return nil
890+
}
891+
886892
registerStore, closer, err := storehouse.LoadRegisterStore(
887893
node.Logger,
888894
node.State,
889895
node.Storage.Headers,
890896
node.ProtocolEvents,
891897
node.LastFinalizedHeader.Height,
892898
exeNode.collector,
893-
exeNode.exeConf.enableStorehouse,
894899
exeNode.exeConf.registerDir,
895900
exeNode.exeConf.triedir,
896901
exeNode.exeConf.importCheckpointWorkerCount,

engine/execution/storehouse/background_indexer_factory.go

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -39,43 +39,6 @@ type ImportRegistersFromCheckpoint func(logger zerolog.Logger, checkpointFile st
3939
// LoadRegisterStore creates and initializes a RegisterStore.
4040
// It handles opening the pebble database, bootstrapping if needed, and creating the RegisterStore.
4141
func LoadRegisterStore(
42-
log zerolog.Logger,
43-
state protocol.State,
44-
headers storageerr.Headers,
45-
protocolEvents *events.Distributor,
46-
lastFinalizedHeight uint64,
47-
collector module.ExecutionMetrics,
48-
enableStorehouse bool,
49-
registerDir string,
50-
triedir string,
51-
importCheckpointWorkerCount int,
52-
importFunc ImportRegistersFromCheckpoint,
53-
) (
54-
*RegisterStore,
55-
io.Closer,
56-
error,
57-
) {
58-
if !enableStorehouse {
59-
log.Info().Msg("register store disabled")
60-
return nil, nil, nil
61-
}
62-
return loadRegisterStore(
63-
log,
64-
state,
65-
headers,
66-
protocolEvents,
67-
lastFinalizedHeight,
68-
collector,
69-
registerDir,
70-
triedir,
71-
importCheckpointWorkerCount,
72-
importFunc,
73-
)
74-
}
75-
76-
// loadRegisterStore is an internal function that creates and initializes a RegisterStore.
77-
// it is reused by both LoadRegisterStore and LoadBackgroundIndexerEngine.
78-
func loadRegisterStore(
7942
log zerolog.Logger,
8043
state protocol.State,
8144
headers storageerr.Headers,
@@ -205,7 +168,7 @@ func LoadBackgroundIndexerEngine(
205168
// and not block the component initialization
206169
bootstrapper := func(ctx context.Context) (*BackgroundIndexer, io.Closer, error) {
207170
// Load register store for background indexing
208-
registerStore, closer, err := loadRegisterStore(
171+
registerStore, closer, err := LoadRegisterStore(
209172
log,
210173
state,
211174
headers,

engine/execution/storehouse/background_indexer_factory_test.go

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -35,47 +35,11 @@ import (
3535
"github.com/onflow/flow-go/utils/unittest"
3636
)
3737

38-
// TestLoadRegisterStore_Disabled tests that LoadRegisterStore returns nil when enableStorehouse is false
39-
func TestLoadRegisterStore_Disabled(t *testing.T) {
40-
t.Parallel()
41-
42-
log := unittest.Logger()
43-
state := protocolmock.NewState(t)
44-
headers := storagemock.NewHeaders(t)
45-
protocolEvents := events.NewDistributor()
46-
lastFinalizedHeight := uint64(100)
47-
collector := &metrics.NoopCollector{}
48-
enableStorehouse := false
49-
registerDir := t.TempDir()
50-
triedir := t.TempDir()
51-
importCheckpointWorkerCount := 1
52-
var importFunc storehouse.ImportRegistersFromCheckpoint = nil
53-
54-
registerStore, closer, err := storehouse.LoadRegisterStore(
55-
log,
56-
state,
57-
headers,
58-
protocolEvents,
59-
lastFinalizedHeight,
60-
collector,
61-
enableStorehouse,
62-
registerDir,
63-
triedir,
64-
importCheckpointWorkerCount,
65-
importFunc,
66-
)
67-
68-
require.NoError(t, err)
69-
require.Nil(t, registerStore)
70-
require.Nil(t, closer)
71-
}
72-
7338
// TestLoadBackgroundIndexerEngine_StorehouseEnabled tests that LoadBackgroundIndexerEngine returns nil when enableStorehouse is true
7439
func TestLoadBackgroundIndexerEngine_StorehouseEnabled(t *testing.T) {
7540
t.Parallel()
7641

7742
log := unittest.Logger()
78-
enableStorehouse := true
7943
enableBackgroundStorehouseIndexing := true
8044
state := protocolmock.NewState(t)
8145
headers := storagemock.NewHeaders(t)
@@ -93,7 +57,6 @@ func TestLoadBackgroundIndexerEngine_StorehouseEnabled(t *testing.T) {
9357
heightsPerSecond := uint64(10)
9458
engine, created, err := storehouse.LoadBackgroundIndexerEngine(
9559
log,
96-
enableStorehouse,
9760
enableBackgroundStorehouseIndexing,
9861
state,
9962
headers,
@@ -121,7 +84,6 @@ func TestLoadBackgroundIndexerEngine_BackgroundIndexingDisabled(t *testing.T) {
12184
t.Parallel()
12285

12386
log := unittest.Logger()
124-
enableStorehouse := false
12587
enableBackgroundStorehouseIndexing := false
12688
state := protocolmock.NewState(t)
12789
headers := storagemock.NewHeaders(t)
@@ -139,7 +101,6 @@ func TestLoadBackgroundIndexerEngine_BackgroundIndexingDisabled(t *testing.T) {
139101
heightsPerSecond := uint64(10)
140102
engine, created, err := storehouse.LoadBackgroundIndexerEngine(
141103
log,
142-
enableStorehouse,
143104
enableBackgroundStorehouseIndexing,
144105
state,
145106
headers,
@@ -173,7 +134,6 @@ func TestLoadBackgroundIndexerEngine_Bootstrap(t *testing.T) {
173134
)
174135

175136
log := unittest.Logger()
176-
enableStorehouse := false
177137
enableBackgroundStorehouseIndexing := true
178138

179139
// Set up protocol state with finalized blocks
@@ -255,7 +215,6 @@ func TestLoadBackgroundIndexerEngine_Bootstrap(t *testing.T) {
255215
// Create background indexer engine
256216
engine, created, err := storehouse.LoadBackgroundIndexerEngine(
257217
log,
258-
enableStorehouse,
259218
enableBackgroundStorehouseIndexing,
260219
state,
261220
headers,
@@ -321,7 +280,6 @@ func TestLoadBackgroundIndexerEngine_Bootstrap(t *testing.T) {
321280
protocolEvents,
322281
registerStoreStart,
323282
collector,
324-
true, // enableStorehouse
325283
registerDir,
326284
triedir,
327285
importCheckpointWorkerCount,
@@ -356,7 +314,6 @@ func TestLoadBackgroundIndexerEngine_Indexing(t *testing.T) {
356314
)
357315

358316
log := unittest.Logger()
359-
enableStorehouse := false
360317
enableBackgroundStorehouseIndexing := true
361318

362319
// Set up protocol state
@@ -503,7 +460,6 @@ func TestLoadBackgroundIndexerEngine_Indexing(t *testing.T) {
503460
// Create background indexer engine
504461
engine, created, err := storehouse.LoadBackgroundIndexerEngine(
505462
log,
506-
enableStorehouse,
507463
enableBackgroundStorehouseIndexing,
508464
state,
509465
headers,
@@ -616,7 +572,6 @@ indexingComplete:
616572
protocolEvents,
617573
targetHeight, // Use targetHeight instead of registerStoreStart so FinalizedReader knows about all blocks
618574
collector,
619-
true, // enableStorehouse
620575
registerDir,
621576
triedir,
622577
importCheckpointWorkerCount,

0 commit comments

Comments
 (0)