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

Conversation

jingjunLi
Copy link
Contributor

@jingjunLi jingjunLi commented Nov 18, 2024

Description

When multi-database (multi-db) mode is enabled, the freezer's environment (env) is not properly set for the multi-db configuration. This prevents the multi-db chain_freezer from moving block data from the database (db) to the ancient storage (ancient).

Rationale

tell us why we need these changes...

Example

add an example CLI or API response...

Changes

Notable changes:

  • add each change in a bullet point here
  • ...

@@ -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.

Copy link
Contributor

@flywukong flywukong left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -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.

@zzzckck zzzckck merged commit f6d3203 into bnb-chain:develop Nov 22, 2024
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants