Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Pebble Database for storing protocol data (Proof of concept) #6161

Closed
wants to merge 165 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
70cb38c
add pebble headers
zhangchiqing Jun 7, 2024
0dfd427
tmp
zhangchiqing Jun 7, 2024
02cd4d3
lint
zhangchiqing Jun 10, 2024
c7ec67f
rename
zhangchiqing Jun 10, 2024
5cef3b0
fix header tests
zhangchiqing Jun 10, 2024
0b7ad06
update headers
zhangchiqing Jun 12, 2024
d2fd02c
fix children
zhangchiqing Jun 13, 2024
570fb11
fix headers
zhangchiqing Jun 13, 2024
ae98ec8
add approvals
zhangchiqing Jun 13, 2024
3465410
add jobs
zhangchiqing Jun 13, 2024
b6ed8aa
update PebbleReaderWriter interfaces
zhangchiqing Jun 13, 2024
407d818
add chunk locators
zhangchiqing Jun 13, 2024
700edb4
update chunks queue tests
zhangchiqing Jun 13, 2024
afa7ad8
refactor batch writer
zhangchiqing Jun 13, 2024
5fbea68
refactor batch
zhangchiqing Jun 13, 2024
f1d5ec2
add computation result
zhangchiqing Jun 13, 2024
8b3765f
add computation result tests
zhangchiqing Jun 14, 2024
ddf9fe8
add consume progress
zhangchiqing Jun 14, 2024
781a950
add dkg
zhangchiqing Jun 14, 2024
b8679db
add tests
zhangchiqing Jun 14, 2024
caa66bb
fix dkg_state_test
zhangchiqing Jun 14, 2024
1b36259
add epoch.go
zhangchiqing Jun 14, 2024
ddea07c
add epoch setup
zhangchiqing Jun 14, 2024
25fb056
add epoch setup
zhangchiqing Jun 14, 2024
85699ee
add epoch protocol state
zhangchiqing Jun 15, 2024
3776a9d
lint
zhangchiqing Jun 15, 2024
3c6ca55
lint
zhangchiqing Jun 17, 2024
a24b5c6
lint
zhangchiqing Jun 17, 2024
27df2a6
add guarantees
zhangchiqing Jun 17, 2024
65c7268
add pebble qcs
zhangchiqing Jun 17, 2024
ed427e3
fix qcs StoreTx
zhangchiqing Jun 18, 2024
075475c
results
zhangchiqing Jun 18, 2024
2967683
fix mock
zhangchiqing Jun 18, 2024
7e54af8
add batch
zhangchiqing Jun 18, 2024
e01567e
add batch
zhangchiqing Jun 19, 2024
a6b999c
implement results
zhangchiqing Jun 19, 2024
033948e
add receipts
zhangchiqing Jun 19, 2024
bf0b8f1
add receipts
zhangchiqing Jun 19, 2024
5fa066f
add seals
zhangchiqing Jun 19, 2024
ac3dfb0
add transactions
zhangchiqing Jun 19, 2024
e95c8cc
version beacon
zhangchiqing Jun 19, 2024
ba3558a
add version beacon and my receipts
zhangchiqing Jun 19, 2024
eea46a5
light transactions
zhangchiqing Jun 20, 2024
6f610a1
movee tests
zhangchiqing Jun 20, 2024
2ada9f4
add removeByPrefix
zhangchiqing Jun 20, 2024
6607ce0
fix lint
zhangchiqing Jun 20, 2024
57db945
fix removeByPrefix
zhangchiqing Jun 20, 2024
05dc8d2
add collections
zhangchiqing Jun 21, 2024
5b4c787
add collections
zhangchiqing Jun 21, 2024
95162dc
add index
zhangchiqing Jun 21, 2024
ce3b06b
add payloads
zhangchiqing Jun 22, 2024
b84ed2b
update index
zhangchiqing Jun 22, 2024
d932e3d
fix collections
zhangchiqing Jun 22, 2024
123d883
add epoch commits tests
zhangchiqing Jun 22, 2024
6d10a5c
add epoch status
zhangchiqing Jun 22, 2024
495ef0d
add guarantees_test
zhangchiqing Jun 22, 2024
70899cf
add index_test
zhangchiqing Jun 22, 2024
a0e3a4a
add init_test
zhangchiqing Jun 22, 2024
e8ba9ea
add light_transaction_results_test
zhangchiqing Jun 22, 2024
f3bb381
add cluster
zhangchiqing Jun 24, 2024
672399e
fix tests
zhangchiqing Jun 24, 2024
f667ecd
lint
zhangchiqing Jun 24, 2024
318dc4b
add test cases
zhangchiqing Jun 24, 2024
4b8f48f
remove benchmark
zhangchiqing Jun 24, 2024
3f90e8c
add events
zhangchiqing Jun 24, 2024
04282a1
add executed
zhangchiqing Jun 24, 2024
acf4231
add cluster blocks
zhangchiqing Jun 24, 2024
a81ae6e
add PebbleDBWrapper
zhangchiqing Jun 24, 2024
a4bd794
batch reader and writer
zhangchiqing Jun 24, 2024
5579cea
update payloads
zhangchiqing Jun 25, 2024
c204a6f
add mapper
zhangchiqing Jun 25, 2024
25d13c1
fix blocks
zhangchiqing Jun 25, 2024
1bad526
add events
zhangchiqing Jun 25, 2024
492a3a6
add transaction results
zhangchiqing Jun 25, 2024
7cde3f9
update commit
zhangchiqing Jun 25, 2024
064401d
fix traverse
zhangchiqing Jun 25, 2024
2808e1f
fix tests
zhangchiqing Jun 25, 2024
79b72ce
fix tests
zhangchiqing Jun 25, 2024
a498560
add pebble state
zhangchiqing Jun 25, 2024
2ddebcf
add protocol pebble
zhangchiqing Jun 25, 2024
c247157
fix protocol state tests
zhangchiqing Jun 26, 2024
7299683
fix tests
zhangchiqing Jun 26, 2024
46345b9
fix version beacon operations
zhangchiqing Jun 26, 2024
f08d26d
fix all pebble protocol state tests
zhangchiqing Jun 26, 2024
39fd0a7
fix qc tests
zhangchiqing Jun 26, 2024
c289172
fix chunk data packs tests
zhangchiqing Jun 26, 2024
3868327
add builder
zhangchiqing Jun 26, 2024
391a686
add builder pebble tests
zhangchiqing Jun 26, 2024
6658fe9
add iterate function
zhangchiqing Jun 26, 2024
e9ddc0d
add cluster tests
zhangchiqing Jun 26, 2024
c0e1d0d
fix collection finalizer
zhangchiqing Jun 26, 2024
c540efb
add finalizer pebble
zhangchiqing Jun 26, 2024
31b8adf
add collection finalizer
zhangchiqing Jun 26, 2024
9355248
add cluster blocks
zhangchiqing Jun 26, 2024
4761496
add cluster pebble
zhangchiqing Jun 26, 2024
8678046
fix collection pebble finalizer
zhangchiqing Jun 26, 2024
d76186b
update scafold
zhangchiqing Jun 26, 2024
17fb7da
update execution state
zhangchiqing Jun 26, 2024
e74b3ab
fix tests
zhangchiqing Jun 26, 2024
40f61c6
fix storehouse tests
zhangchiqing Jun 26, 2024
b830946
fix NewFinalizer
zhangchiqing Jun 26, 2024
7c907b1
fix builder
zhangchiqing Jun 26, 2024
52f99a2
fix bootstrap
zhangchiqing Jun 26, 2024
c02c125
fix scafold
zhangchiqing Jun 26, 2024
6b6452b
add verifier
zhangchiqing Jun 26, 2024
facfc4e
remove tests
zhangchiqing Jun 26, 2024
b48a2d4
fix approvals
zhangchiqing Jun 27, 2024
b3474de
update access node builder
zhangchiqing Jun 27, 2024
ee4c457
fix collection builder
zhangchiqing Jun 27, 2024
bce0c8d
fix consensus
zhangchiqing Jun 27, 2024
8cdc126
fix colleciton main
zhangchiqing Jun 27, 2024
11e8924
fix epoch
zhangchiqing Jun 27, 2024
a4eec54
fix hotstuff
zhangchiqing Jun 27, 2024
9b9c4c6
fix observer
zhangchiqing Jun 27, 2024
1dbf1ed
fix tests
zhangchiqing Jun 27, 2024
6a4bcab
remove rollback
zhangchiqing Jun 27, 2024
e7a5df0
fix linting
zhangchiqing Jun 27, 2024
839dc7a
update testing utils
zhangchiqing Jun 27, 2024
76252c0
fix consenesus follower
zhangchiqing Jun 27, 2024
6c94f72
make state
zhangchiqing Jun 27, 2024
880869e
fix defer db.Close()
zhangchiqing Jun 27, 2024
8b5f356
fix tests
zhangchiqing Jun 27, 2024
696e544
use pebble in pebble tests
zhangchiqing Jun 27, 2024
c8c480f
fix verificaition tests
zhangchiqing Jun 27, 2024
9209cc2
fix access tests
zhangchiqing Jun 27, 2024
2fa6abf
fix rpc backend tests
zhangchiqing Jun 27, 2024
263630c
fix integration tests
zhangchiqing Jun 27, 2024
9fb53b9
fix tests
zhangchiqing Jun 27, 2024
60bb371
fix finalizedreader tests
zhangchiqing Jun 27, 2024
78b68b7
fix follower integration tests
zhangchiqing Jun 27, 2024
88d79d6
fix jobqueue tests
zhangchiqing Jun 27, 2024
fbc18a6
fix protocol inmem convert test
zhangchiqing Jun 27, 2024
087df86
fix mocks
zhangchiqing Jun 27, 2024
f0f1f87
fix lint
zhangchiqing Jun 27, 2024
0ab8f88
fix badger protocol state
zhangchiqing Jun 27, 2024
ec97eab
fix init
zhangchiqing Jun 27, 2024
f3f8d73
fix collection integration tests
zhangchiqing Jun 27, 2024
872756f
fix cohort3 integration tests
zhangchiqing Jun 27, 2024
c0847e3
fix dkg integration tests
zhangchiqing Jun 27, 2024
0bb914d
fix traverse
zhangchiqing Jun 28, 2024
a5e765c
check already exists
zhangchiqing Jul 2, 2024
b1edca7
chunk locator tests
zhangchiqing Jul 2, 2024
d93e8c6
update interface
zhangchiqing Jul 5, 2024
56b91de
add callback
zhangchiqing Jul 5, 2024
d401ff5
fix headers
zhangchiqing Jul 5, 2024
870eb22
refactor headers
zhangchiqing Jul 5, 2024
93ee13c
fix cluster blocks
zhangchiqing Jul 5, 2024
fc9e4c4
update cluster payloads
zhangchiqing Jul 5, 2024
b5b4166
update mocks
zhangchiqing Jul 5, 2024
a627358
remove seals.Store
zhangchiqing Jul 5, 2024
d753bd4
add PutPebble
zhangchiqing Jul 5, 2024
0aca1f0
use PutPebble
zhangchiqing Jul 5, 2024
ea3f326
update mocks
zhangchiqing Jul 5, 2024
3e8bbd5
fix receipts
zhangchiqing Jul 5, 2024
39eb71c
add onlywriter
zhangchiqing Jul 5, 2024
551aff7
use new store
zhangchiqing Jul 5, 2024
acd5b34
fix payloads
zhangchiqing Jul 5, 2024
0e4f272
fix payloads
zhangchiqing Jul 5, 2024
fff4b2e
fix payloads
zhangchiqing Jul 6, 2024
168b02e
remove require error in tests
zhangchiqing Jul 6, 2024
0aa3331
update mocks
zhangchiqing Jul 6, 2024
4e77bf6
fix flakey
zhangchiqing Jul 9, 2024
b65f639
reproduce failure
zhangchiqing Jul 9, 2024
2e1a3f2
fix chunk queues
zhangchiqing Jul 9, 2024
ed8a55c
fix tests
zhangchiqing Jul 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions admin/commands/storage/read_range_cluster_blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import (
"context"
"fmt"

"github.com/dgraph-io/badger/v2"
"github.com/cockroachdb/pebble"
"github.com/rs/zerolog/log"

"github.com/onflow/flow-go/admin"
"github.com/onflow/flow-go/admin/commands"
"github.com/onflow/flow-go/cmd/util/cmd/read-light-block"
"github.com/onflow/flow-go/model/flow"
storage "github.com/onflow/flow-go/storage/badger"
storage "github.com/onflow/flow-go/storage/pebble"
)

var _ commands.AdminCommand = (*ReadRangeClusterBlocksCommand)(nil)
Expand All @@ -21,12 +21,12 @@ var _ commands.AdminCommand = (*ReadRangeClusterBlocksCommand)(nil)
const Max_Range_Cluster_Block_Limit = uint64(10001)

type ReadRangeClusterBlocksCommand struct {
db *badger.DB
db *pebble.DB
headers *storage.Headers
payloads *storage.ClusterPayloads
}

func NewReadRangeClusterBlocksCommand(db *badger.DB, headers *storage.Headers, payloads *storage.ClusterPayloads) commands.AdminCommand {
func NewReadRangeClusterBlocksCommand(db *pebble.DB, headers *storage.Headers, payloads *storage.ClusterPayloads) commands.AdminCommand {
return &ReadRangeClusterBlocksCommand{
db: db,
headers: headers,
Expand Down
32 changes: 16 additions & 16 deletions cmd/access/node_builder/access_node_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ import (
"github.com/onflow/flow-go/network/underlay"
"github.com/onflow/flow-go/network/validator"
"github.com/onflow/flow-go/state/protocol"
badgerState "github.com/onflow/flow-go/state/protocol/badger"
"github.com/onflow/flow-go/state/protocol/blocktimer"
pebbleState "github.com/onflow/flow-go/state/protocol/pebble"
"github.com/onflow/flow-go/storage"
bstorage "github.com/onflow/flow-go/storage/badger"
pStorage "github.com/onflow/flow-go/storage/pebble"
pstorage "github.com/onflow/flow-go/storage/pebble"
"github.com/onflow/flow-go/utils/grpcutils"
)

Expand Down Expand Up @@ -250,7 +250,7 @@ func DefaultAccessNodeConfig() *AccessNodeConfig {
scriptExecutorConfig: query.NewDefaultConfig(),
scriptExecMinBlock: 0,
scriptExecMaxBlock: math.MaxUint64,
registerCacheType: pStorage.CacheTypeTwoQueue.String(),
registerCacheType: pstorage.CacheTypeTwoQueue.String(),
registerCacheSize: 0,
programCacheSize: 0,
}
Expand Down Expand Up @@ -320,12 +320,12 @@ func (builder *FlowAccessNodeBuilder) buildFollowerState() *FlowAccessNodeBuilde
builder.Module("mutable follower state", func(node *cmd.NodeConfig) error {
// For now, we only support state implementations from package badger.
// If we ever support different implementations, the following can be replaced by a type-aware factory
state, ok := node.State.(*badgerState.State)
state, ok := node.State.(*pebbleState.State)
if !ok {
return fmt.Errorf("only implementations of type badger.State are currently supported but read-only state has type %T", node.State)
}

followerState, err := badgerState.NewFollowerState(
followerState, err := pebbleState.NewFollowerState(
node.Logger,
node.Tracer,
node.ProtocolEvents,
Expand Down Expand Up @@ -383,7 +383,7 @@ func (builder *FlowAccessNodeBuilder) buildFollowerCore() *FlowAccessNodeBuilder
builder.Component("follower core", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
// create a finalizer that will handle updating the protocol
// state when the follower detects newly finalized blocks
final := finalizer.NewFinalizer(node.DB, node.Storage.Headers, builder.FollowerState, node.Tracer)
final := finalizer.NewFinalizerPebble(node.DB, node.Storage.Headers, builder.FollowerState, node.Tracer)

packer := signature.NewConsensusSigDataPacker(builder.Committee)
// initialize the verifier for the protocol consensus
Expand Down Expand Up @@ -725,27 +725,27 @@ func (builder *FlowAccessNodeBuilder) BuildExecutionSyncComponents() *FlowAccess
}).
Module("indexed block height consumer progress", func(node *cmd.NodeConfig) error {
// Note: progress is stored in the MAIN db since that is where indexed execution data is stored.
indexedBlockHeight = bstorage.NewConsumerProgress(builder.DB, module.ConsumeProgressExecutionDataIndexerBlockHeight)
indexedBlockHeight = pstorage.NewConsumerProgress(builder.DB, module.ConsumeProgressExecutionDataIndexerBlockHeight)
return nil
}).
Module("transaction results storage", func(node *cmd.NodeConfig) error {
builder.Storage.LightTransactionResults = bstorage.NewLightTransactionResults(node.Metrics.Cache, node.DB, bstorage.DefaultCacheSize)
builder.Storage.LightTransactionResults = pstorage.NewLightTransactionResults(node.Metrics.Cache, node.DB, pstorage.DefaultCacheSize)
return nil
}).
DependableComponent("execution data indexer", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
// Note: using a DependableComponent here to ensure that the indexer does not block
// other components from starting while bootstrapping the register db since it may
// take hours to complete.

pdb, err := pStorage.OpenRegisterPebbleDB(builder.registersDBPath)
pdb, err := pstorage.OpenRegisterPebbleDB(builder.registersDBPath)
if err != nil {
return nil, fmt.Errorf("could not open registers db: %w", err)
}
builder.ShutdownFunc(func() error {
return pdb.Close()
})

bootstrapped, err := pStorage.IsBootstrapped(pdb)
bootstrapped, err := pstorage.IsBootstrapped(pdb)
if err != nil {
return nil, fmt.Errorf("could not check if registers db is bootstrapped: %w", err)
}
Expand Down Expand Up @@ -777,7 +777,7 @@ func (builder *FlowAccessNodeBuilder) BuildExecutionSyncComponents() *FlowAccess
}

rootHash := ledger.RootHash(builder.RootSeal.FinalState)
bootstrap, err := pStorage.NewRegisterBootstrap(pdb, checkpointFile, checkpointHeight, rootHash, builder.Logger)
bootstrap, err := pstorage.NewRegisterBootstrap(pdb, checkpointFile, checkpointHeight, rootHash, builder.Logger)
if err != nil {
return nil, fmt.Errorf("could not create registers bootstrap: %w", err)
}
Expand All @@ -790,18 +790,18 @@ func (builder *FlowAccessNodeBuilder) BuildExecutionSyncComponents() *FlowAccess
}
}

registers, err := pStorage.NewRegisters(pdb)
registers, err := pstorage.NewRegisters(pdb)
if err != nil {
return nil, fmt.Errorf("could not create registers storage: %w", err)
}

if builder.registerCacheSize > 0 {
cacheType, err := pStorage.ParseCacheType(builder.registerCacheType)
cacheType, err := pstorage.ParseCacheType(builder.registerCacheType)
if err != nil {
return nil, fmt.Errorf("could not parse register cache type: %w", err)
}
cacheMetrics := metrics.NewCacheCollector(builder.RootChainID)
registersCache, err := pStorage.NewRegistersCache(registers, cacheType, builder.registerCacheSize, cacheMetrics)
registersCache, err := pstorage.NewRegistersCache(registers, cacheType, builder.registerCacheSize, cacheMetrics)
if err != nil {
return nil, fmt.Errorf("could not create registers cache: %w", err)
}
Expand Down Expand Up @@ -1406,7 +1406,7 @@ func (builder *FlowAccessNodeBuilder) Initialize() error {

builder.EnqueueTracer()
builder.PreInit(cmd.DynamicStartPreInit)
builder.ValidateRootSnapshot(badgerState.ValidRootSnapshotContainsEntityExpiryRange)
builder.ValidateRootSnapshot(pebbleState.ValidRootSnapshotContainsEntityExpiryRange)

return nil
}
Expand Down Expand Up @@ -1596,7 +1596,7 @@ func (builder *FlowAccessNodeBuilder) Build() (cmd.Node, error) {
return nil
}).
Module("events storage", func(node *cmd.NodeConfig) error {
builder.Storage.Events = bstorage.NewEvents(node.Metrics.Cache, node.DB)
builder.Storage.Events = pstorage.NewEvents(node.Metrics.Cache, node.DB)
return nil
}).
Module("events index", func(node *cmd.NodeConfig) error {
Expand Down
20 changes: 10 additions & 10 deletions cmd/collection/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ import (
"github.com/onflow/flow-go/module/metrics"
"github.com/onflow/flow-go/network/channels"
"github.com/onflow/flow-go/state/protocol"
badgerState "github.com/onflow/flow-go/state/protocol/badger"
"github.com/onflow/flow-go/state/protocol/blocktimer"
"github.com/onflow/flow-go/state/protocol/events/gadgets"
"github.com/onflow/flow-go/storage/badger"
pebbleState "github.com/onflow/flow-go/state/protocol/pebble"
"github.com/onflow/flow-go/storage/pebble"
"github.com/onflow/flow-go/utils/grpcutils"
)

Expand Down Expand Up @@ -182,10 +182,10 @@ func main() {
nodeBuilder.
PreInit(cmd.DynamicStartPreInit).
AdminCommand("read-range-cluster-blocks", func(conf *cmd.NodeConfig) commands.AdminCommand {
clusterPayloads := badger.NewClusterPayloads(&metrics.NoopCollector{}, conf.DB)
headers, ok := conf.Storage.Headers.(*badger.Headers)
clusterPayloads := pebble.NewClusterPayloads(&metrics.NoopCollector{}, conf.DB)
headers, ok := conf.Storage.Headers.(*pebble.Headers)
if !ok {
panic("fail to initialize admin tool, conf.Storage.Headers can not be casted as badger headers")
panic("fail to initialize admin tool, conf.Storage.Headers can not be casted as pebble headers")
}
return storageCommands.NewReadRangeClusterBlocksCommand(conf.DB, headers, clusterPayloads)
}).
Expand All @@ -195,13 +195,13 @@ func main() {
return nil
}).
Module("mutable follower state", func(node *cmd.NodeConfig) error {
// For now, we only support state implementations from package badger.
// For now, we only support state implementations from package pebble.
// If we ever support different implementations, the following can be replaced by a type-aware factory
state, ok := node.State.(*badgerState.State)
state, ok := node.State.(*pebbleState.State)
if !ok {
return fmt.Errorf("only implementations of type badger.State are currently supported but read-only state has type %T", node.State)
return fmt.Errorf("only implementations of type pebble.State are currently supported but read-only state has type %T", node.State)
}
followerState, err = badgerState.NewFollowerState(
followerState, err = pebbleState.NewFollowerState(
node.Logger,
node.Tracer,
node.ProtocolEvents,
Expand Down Expand Up @@ -287,7 +287,7 @@ func main() {
Component("follower core", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
// create a finalizer for updating the protocol
// state when the follower detects newly finalized blocks
finalizer := confinalizer.NewFinalizer(node.DB, node.Storage.Headers, followerState, node.Tracer)
finalizer := confinalizer.NewFinalizerPebble(node.DB, node.Storage.Headers, followerState, node.Tracer)
finalized, pending, err := recovery.FindLatest(node.State, node.Storage.Headers)
if err != nil {
return nil, fmt.Errorf("could not find latest finalized block and pending blocks to recover consensus follower: %w", err)
Expand Down
22 changes: 11 additions & 11 deletions cmd/consensus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ import (
"github.com/onflow/flow-go/module/validation"
"github.com/onflow/flow-go/network/channels"
"github.com/onflow/flow-go/state/protocol"
badgerState "github.com/onflow/flow-go/state/protocol/badger"
"github.com/onflow/flow-go/state/protocol/blocktimer"
"github.com/onflow/flow-go/state/protocol/events/gadgets"
pebbleState "github.com/onflow/flow-go/state/protocol/pebble"
"github.com/onflow/flow-go/storage"
bstorage "github.com/onflow/flow-go/storage/badger"
bstorage "github.com/onflow/flow-go/storage/pebble"
"github.com/onflow/flow-go/utils/io"
)

Expand Down Expand Up @@ -209,7 +209,7 @@ func main() {

nodeBuilder.
PreInit(cmd.DynamicStartPreInit).
ValidateRootSnapshot(badgerState.ValidRootSnapshotContainsEntityExpiryRange).
ValidateRootSnapshot(pebbleState.ValidRootSnapshotContainsEntityExpiryRange).
Module("consensus node metrics", func(node *cmd.NodeConfig) error {
conMetrics = metrics.NewConsensusCollector(node.Tracer, node.MetricsRegisterer)
return nil
Expand Down Expand Up @@ -244,11 +244,11 @@ func main() {
return err
}).
Module("mutable follower state", func(node *cmd.NodeConfig) error {
// For now, we only support state implementations from package badger.
// For now, we only support state implementations from package pebble.
// If we ever support different implementations, the following can be replaced by a type-aware factory
state, ok := node.State.(*badgerState.State)
state, ok := node.State.(*pebbleState.State)
if !ok {
return fmt.Errorf("only implementations of type badger.State are currently supported but read-only state has type %T", node.State)
return fmt.Errorf("only implementations of type pebble.State are currently supported but read-only state has type %T", node.State)
}

chunkAssigner, err = chmodule.NewChunkAssigner(chunkAlpha, node.State)
Expand Down Expand Up @@ -278,7 +278,7 @@ func main() {
return err
}

mutableState, err = badgerState.NewFullConsensusState(
mutableState, err = pebbleState.NewFullConsensusState(
node.Logger,
node.Tracer,
node.ProtocolEvents,
Expand Down Expand Up @@ -559,12 +559,12 @@ func main() {
}).
Component("hotstuff modules", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
// initialize the block finalizer
finalize := finalizer.NewFinalizer(
finalize := finalizer.NewFinalizerPebble(
node.DB,
node.Storage.Headers,
mutableState,
node.Tracer,
finalizer.WithCleanup(finalizer.CleanupMempools(
finalizer.WithCleanupPebble(finalizer.CleanupMempools(
node.Metrics.Mempool,
conMetrics,
node.Storage.Payloads,
Expand Down Expand Up @@ -605,7 +605,7 @@ func main() {
notifier.AddFollowerConsumer(followerDistributor)

// initialize the persister
persist := persister.New(node.DB, node.RootChainID)
persist := persister.NewPersisterPebble(node.DB, node.RootChainID)

finalizedBlock, err := node.State.Final().Head()
if err != nil {
Expand Down Expand Up @@ -722,7 +722,7 @@ func main() {
Component("consensus participant", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
// initialize the block builder
var build module.Builder
build, err = builder.NewBuilder(
build, err = builder.NewBuilderPebble(
node.Metrics.Mempool,
node.DB,
mutableState,
Expand Down
4 changes: 2 additions & 2 deletions cmd/dynamic_startup.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/onflow/flow-go/crypto"
"github.com/onflow/flow-go/model/bootstrap"
"github.com/onflow/flow-go/state/protocol"
badgerstate "github.com/onflow/flow-go/state/protocol/badger"
pebblestate "github.com/onflow/flow-go/state/protocol/pebble"
utilsio "github.com/onflow/flow-go/utils/io"

"github.com/onflow/flow-go/model/flow"
Expand Down Expand Up @@ -152,7 +152,7 @@ func DynamicStartPreInit(nodeConfig *NodeConfig) error {
log := nodeConfig.Logger.With().Str("component", "dynamic-startup").Logger()

// skip dynamic startup if the protocol state is bootstrapped
isBootstrapped, err := badgerstate.IsBootstrapped(nodeConfig.DB)
isBootstrapped, err := pebblestate.IsBootstrapped(nodeConfig.DB)
if err != nil {
return fmt.Errorf("could not check if state is boostrapped: %w", err)
}
Expand Down
Loading
Loading