-
-
Notifications
You must be signed in to change notification settings - Fork 410
feat: add lmdb and sqlite backend #8483
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
Draft
wemeetagain
wants to merge
14
commits into
unstable
Choose a base branch
from
cayman/lmdb
base: unstable
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,690
−101
Draft
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
db881c5
feat: add lmdb database from lodestar-bun
wemeetagain 8619a30
chore: fix lmdb usage
wemeetagain 15bdc93
chore: fix entries
wemeetagain 31453a3
chore: more fix
wemeetagain 0a7552a
chore: add bun sqlite db controller
wemeetagain 88ed5b0
Merge branch 'unstable' into cayman/lmdb
wemeetagain a58cf2f
Merge branch 'unstable' into cayman/lmdb
wemeetagain e2d9126
chore: add DatabaseType type
wemeetagain 86742b0
chore: fix build errors
wemeetagain 792e92e
Merge branch 'unstable' into cayman/lmdb
wemeetagain e3c8e70
Merge branch 'unstable' into cayman/lmdb
wemeetagain 96d0a80
Merge branch 'unstable' into cayman/lmdb
wemeetagain 539666b
chore: add lmdb dependency
wemeetagain c1c897a
chore: use lmdb dependency in bun
wemeetagain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| export type DatabaseOptions = { | ||
| name: string; | ||
| type: "level" | "lmdb"; | ||
| }; | ||
|
|
||
| export const defaultDbOptions: DatabaseOptions = { | ||
| name: "./.tmp/lodestar-db", | ||
| type: "level", | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import {Logger} from "@lodestar/utils"; | ||
| import {DatabaseController, DatabaseOptions, DbReqOpts, FilterOptions, KeyValue} from "./interface.ts"; | ||
| import {LevelDbControllerMetrics} from "./metrics.ts"; | ||
|
|
||
| export type LmdbControllerModules = { | ||
| logger: Logger; | ||
| metrics?: LevelDbControllerMetrics | null; | ||
| }; | ||
|
|
||
| export class LmdbController implements DatabaseController<Uint8Array, Uint8Array> { | ||
|
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. This code must be covered with unit tests. May be using same fixture to test different implementations of db controllers. It is important as if something missed goes wrong here make it very difficult to debug on higher layers. |
||
| static async create(options: DatabaseOptions, {metrics}: LmdbControllerModules): Promise<LmdbController> { | ||
| return new LmdbController(); | ||
| } | ||
| static async destroy(_location: string): Promise<void> {} | ||
| close(): Promise<void> { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
| setMetrics(metrics: LevelDbControllerMetrics): void { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
| get(key: Uint8Array<ArrayBufferLike>, opts?: DbReqOpts): Promise<Uint8Array<ArrayBufferLike> | null> { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
| getMany(key: Uint8Array<ArrayBufferLike>[], opts?: DbReqOpts): Promise<(Uint8Array<ArrayBufferLike> | undefined)[]> { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
| put(key: Uint8Array<ArrayBufferLike>, value: Uint8Array<ArrayBufferLike>, opts?: DbReqOpts): Promise<void> { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
| delete(key: Uint8Array<ArrayBufferLike>, opts?: DbReqOpts): Promise<void> { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
| batchPut( | ||
| items: KeyValue<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>[], | ||
| opts?: DbReqOpts | ||
| ): Promise<void> { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
| batchDelete(keys: Uint8Array<ArrayBufferLike>[], opts?: DbReqOpts): Promise<void> { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
| keysStream( | ||
| opts?: FilterOptions<Uint8Array<ArrayBufferLike>> | undefined | ||
| ): AsyncIterable<Uint8Array<ArrayBufferLike>> { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
| keys(opts?: FilterOptions<Uint8Array<ArrayBufferLike>> | undefined): Promise<Uint8Array<ArrayBufferLike>[]> { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
| valuesStream( | ||
| opts?: FilterOptions<Uint8Array<ArrayBufferLike>> | undefined | ||
| ): AsyncIterable<Uint8Array<ArrayBufferLike>> { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
| values(opts?: FilterOptions<Uint8Array<ArrayBufferLike>> | undefined): Promise<Uint8Array<ArrayBufferLike>[]> { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
| entriesStream( | ||
| opts?: FilterOptions<Uint8Array<ArrayBufferLike>> | undefined | ||
| ): AsyncIterable<KeyValue<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>> { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
| entries( | ||
| opts?: FilterOptions<Uint8Array<ArrayBufferLike>> | undefined | ||
| ): Promise<KeyValue<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>[]> { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
| } | ||
wemeetagain marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That logic might go well as static method inside
BeaconDbasBeaconDB.init. This will help us reuse it.