Skip to content

fix: fix multi-db env#2755

Merged
zzzckck merged 3 commits intobnb-chain:developfrom
jingjunLi:fix-multi-db-freeze-env
Nov 22, 2024
Merged

fix: fix multi-db env#2755
zzzckck merged 3 commits intobnb-chain:developfrom
jingjunLi:fix-multi-db-freeze-env

Conversation

@jingjunLi
Copy link
Copy Markdown
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
  • ...

// startup ancient freeze
if err = chainDb.SetupFreezerEnv(&ethdb.FreezerEnv{
freezeDb := chainDb
if stack.CheckIfMultiDataBase() {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

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
Copy Markdown
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
Copy Markdown
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
@zzzckck zzzckck mentioned this pull request Nov 25, 2024
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