-
Notifications
You must be signed in to change notification settings - Fork 202
Differentiate between Consensus and Cluster Headers storage #8222
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
base: master
Are you sure you want to change the base?
Changes from 12 commits
f3c7603
0fe4007
467b732
585c0e9
6d9c389
927b229
81ffdeb
99a2498
6253765
a22fd0b
ee80525
2ecfee1
6fe94ec
2fbe0b5
f16ccbf
c24be76
e397124
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1186,8 +1186,29 @@ func (fnb *FlowNodeBuilder) initStorageLockManager() error { | |
| return nil | ||
| } | ||
|
|
||
| func (fnb *FlowNodeBuilder) determineChainID() error { | ||
| if ok, _ := badgerState.IsBootstrapped(fnb.ProtocolDB); ok { | ||
| chainID, err := badgerState.GetChainIDFromLatestFinalizedHeader(fnb.ProtocolDB) | ||
| if err == nil { | ||
|
||
| fnb.RootChainID = chainID | ||
| return nil | ||
| } | ||
| } | ||
| // could not read from DB; try reading root snapshot from disk | ||
| fnb.Logger.Info().Msgf("loading root protocol state snapshot from disk") | ||
| rootSnapshot, err := loadRootProtocolSnapshot(fnb.BaseConfig.BootstrapDir) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to read protocol snapshot from disk: %w", err) | ||
| } | ||
| // set root snapshot fields (including RootChainID) | ||
| if err := fnb.setRootSnapshot(rootSnapshot); err != nil { | ||
| return err | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (fnb *FlowNodeBuilder) initStorage() error { | ||
| headers := store.NewHeaders(fnb.Metrics.Cache, fnb.ProtocolDB) | ||
| headers := store.NewHeaders(fnb.Metrics.Cache, fnb.ProtocolDB, fnb.RootChainID) | ||
| guarantees := store.NewGuarantees(fnb.Metrics.Cache, fnb.ProtocolDB, fnb.BaseConfig.guaranteesCacheSize, | ||
| store.DefaultCacheSize) | ||
| seals := store.NewSeals(fnb.Metrics.Cache, fnb.ProtocolDB) | ||
|
|
@@ -2081,6 +2102,10 @@ func (fnb *FlowNodeBuilder) onStart() error { | |
| return err | ||
| } | ||
|
|
||
| if err := fnb.determineChainID(); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| if err := fnb.initStorage(); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ import ( | |
|
|
||
| "github.com/onflow/flow-go/cmd/util/cmd/common" | ||
| "github.com/onflow/flow-go/model/flow" | ||
| badgerstate "github.com/onflow/flow-go/state/protocol/badger" | ||
| "github.com/onflow/flow-go/storage" | ||
| ) | ||
|
|
||
|
|
@@ -28,7 +29,11 @@ var collectionsCmd = &cobra.Command{ | |
| Short: "get collection by collection or transaction ID", | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| return common.WithStorage(flagDatadir, func(db storage.DB) error { | ||
| storages := common.InitStorages(db) | ||
| chainID, err := badgerstate.GetChainIDFromLatestFinalizedHeader(db) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| storages := common.InitStorages(db, chainID) // TODO(4204) - header storage not used | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you want to address this TODO in this PR? |
||
|
|
||
| if flagCollectionID != "" { | ||
| log.Info().Msgf("got flag collection id: %s", flagCollectionID) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.