Skip to content

Move database creation to database factory package #3899

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

Merged
merged 10 commits into from
Apr 28, 2025

Conversation

ceyonur
Copy link
Contributor

@ceyonur ceyonur commented Apr 18, 2025

Why this should be merged

It moves database creation function to database/factory pkg to be used from external pkgs/modules (like subnet-evm)

How this works

Database Configuration Refactor:

  • New database/factory package: Introduced a new DatabaseConfig struct and a NewDatabase function in database/factory/factory.go. This function centralizes the creation of LevelDB, MemDB, and PebbleDB instances, as well as their associated wrappers (e.g., corruptable and meter DBs).

Code Simplification in node Package:

  • Refactored database initialization: The initDatabase method in node/node.go now uses the NewDatabase function from the database/factory package, reducing duplicated logic and improving maintainability.

How this was tested

e2e tests should cover this + locally

Need to be documented in RELEASES.md?

No

@ceyonur ceyonur marked this pull request as ready for review April 18, 2025 10:19
metricsPrefix,
)
if err != nil {
return nil, err
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could you create more specific formatted errors to the ones here ?
i.e. fmt.Errorf("failed to MakeAndRegister the metricPrefix %s : %w". metricsPrefix, err)

same for the others error in this function.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with this comment but I don't think it makes sense to block this PR on it because this is a strict refactor.

@joshua-kim joshua-kim added this pull request to the merge queue Apr 28, 2025
@joshua-kim joshua-kim changed the title move database creation to database factory pkg Move database creation to database factory package Apr 28, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 28, 2025
@StephenButtolph StephenButtolph added this pull request to the merge queue Apr 28, 2025
Merged via the queue into master with commit 5188a86 Apr 28, 2025
24 checks passed
@StephenButtolph StephenButtolph deleted the ceyonur/database-factory branch April 28, 2025 18:34
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