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

fix: fix multi-db env #2755

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions core/rawdb/chain_freezer.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ func newChainFreezer(datadir string, namespace string, readonly bool, offset uin
Freezer: freezer,
quit: make(chan struct{}),
trigger: make(chan chan struct{}),
// After enabling pruneAncient, the ancient data is not retained. In some specific scenarios where it is
// necessary to roll back to blocks prior to the finalized block, it is mandatory to keep the most recent 90,000 blocks in the database to ensure proper functionality and rollback capability.
multiDatabase: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not remove the multiDatabase field & param? It's useless now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure whether the logic of using the finalized block for processing will be used later. For now, to minimize changes, I disable it.

}
cf.threshold.Store(params.FullImmutabilityThreshold)
return &cf, nil
Expand Down
6 changes: 5 additions & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,11 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
}

// startup ancient freeze
if err = chainDb.SetupFreezerEnv(&ethdb.FreezerEnv{
freezeDb := chainDb
if stack.CheckIfMultiDataBase() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if stack.CheckIfMultiDataBase() && chainDb.BlockStore() != nil may be better

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not appropriate to use chainDb.BlockStore() for validation because:

  1. When multi-database mode is enabled, chainDb.BlockStore() will return blockDb.
  2. When multi-database mode is disabled, chainDb.BlockStore() will return chainDb.

freezeDb = chainDb.BlockStore()
}
if err = freezeDb.SetupFreezerEnv(&ethdb.FreezerEnv{
ChainCfg: chainConfig,
BlobExtraReserve: config.BlobExtraReserve,
}); err != nil {
Expand Down
Loading