ntx-builder: move to sqlite framework#2353
Open
SantiagoPittella wants to merge 1 commit into
Open
Conversation
Comment on lines
+17
to
+18
| .into_iter() | ||
| .next()) |
Collaborator
There was a problem hiding this comment.
Perhaps we should add a row.first() -> Option<T>
Comment on lines
+41
to
+52
| /// Serializes a [`BlockNumber`] to the `i64` used by the `block_num`/`committed_at`/`last_attempt` | ||
| /// columns. | ||
| pub(crate) fn block_num_to_i64(block_num: BlockNumber) -> i64 { | ||
| i64::from(block_num.as_u32()) | ||
| } | ||
|
|
||
| /// Deserializes a `block_num`/`committed_at`/`last_attempt` column value back into a | ||
| /// [`BlockNumber`]. | ||
| #[expect(clippy::cast_sign_loss)] | ||
| pub(crate) fn block_num_from_i64(val: i64) -> BlockNumber { | ||
| BlockNumber::from(val as u32) | ||
| } |
Collaborator
There was a problem hiding this comment.
These should be covered with the SQLite codec trait?
Collaborator
There was a problem hiding this comment.
Some thoughts, leaving inline so we can discuss more easily.
First some organizational ones:
- I think we should wrap the db crate's read and write tx again here, and then expose the queries / writes as methods instead of free functions.
- I would prefer separate folder per sqlite query i.e. not bundling multiple per file, and no
sqlfolder.
More important though:
- Everywhere still has access to the
Databasestruct.- This means everywhere can still write if they so choose.
- I think the
SQLiteframework should not give back theDatabasestruct on construction.- Instead return:
(WriteTx, Pool<ReadTx>). - That way we cannot mix and match.
- Instead return:
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Migrates the ntx-builder database layer off Diesel and onto the shared
miden-node-db SQLite framework.Why:
How:
Dieselquery modules with plain query functions overReadTx/WriteTxand hand-written SQL indb/sql/.001_initial.sqlschema), so existing databases stay compatible.Changelog