-
Notifications
You must be signed in to change notification settings - Fork 96
feat: Validator database #1614
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
Open
sergerad
wants to merge
77
commits into
next
Choose a base branch
from
sergerad-validator-db
base: next
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.
Open
feat: Validator database #1614
Changes from 2 commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
9ed9c7a
Initial validator db impl
sergerad 560c79a
Add basic validation logic
sergerad 77b1616
Simplify schema
sergerad 0636937
Changelog, toml
sergerad 6f4b0d3
Merge branch 'next' of github.com:0xMiden/miden-node into sergerad-va…
sergerad 71c90b8
Fix comment
sergerad 7bdd615
Add error case
sergerad 4e76c2e
Fix standalone validator setup alongside bundled components
sergerad c01448e
Merge branch 'next' of github.com:0xMiden/miden-node into sergerad-va…
sergerad 2b8008f
Merge branch 'next' of github.com:0xMiden/miden-node into sergerad-va…
sergerad 4fe9890
RM row affected check
sergerad f3aaeba
Fix comment
sergerad 405737e
Add UnvalidatedTransactions err
sergerad 2d7a3ba
Rename insecure key
sergerad d3c8770
Move to kv store
sergerad 1ec03ef
Misc cleanup
sergerad 4735bd1
Undo pub changes to store crate
sergerad 147b0aa
Changelog
sergerad 1596c50
Missing file
sergerad 92b16f5
Update dockerfile
sergerad 411c8e8
Merge branch 'next' of github.com:0xMiden/miden-node into sergerad-va…
sergerad ae5510c
Fix test
sergerad 15b9899
Revert "Fix test"
sergerad bed51da
Revert "Merge branch 'next' of github.com:0xMiden/miden-node into ser…
sergerad 57b1671
Revert "ci(docker): use `cargo chef` and cache to github (#1631)"
sergerad 4d1baee
Revert "Update dockerfile"
sergerad 6230ce8
Revert "Missing file"
sergerad e75e486
Revert "Changelog"
sergerad 2de6f00
Revert "Undo pub changes to store crate"
sergerad 189ad4b
Revert "Misc cleanup"
sergerad 62d0cd2
Revert "Move to kv store"
sergerad 74aa074
Add find_unvalidated_ fn
sergerad 2db6985
Refactor for tx summary
sergerad 41e27b5
Impl todo for tx summary
sergerad 06bb151
Revert workflow
sergerad 5d76a80
Fix var name
sergerad a468514
Revert dockerfile
sergerad c0c692b
Fix merge issues
sergerad 2e92e72
Fix more merge issues
sergerad 88624e5
More merge issues
sergerad 60e1e1f
Another merge issue
sergerad 81db1de
Fix comment
sergerad 59858c7
Fix unvalidated logic
sergerad 37eab16
Add missing build.rs
sergerad 4fcc6c8
machete
sergerad 072dbe3
Use tempdir
sergerad 3073aa4
Merge branch 'next' of github.com:0xMiden/miden-node into sergerad-va…
sergerad e639c97
UnvalidatedTransactions wording
sergerad cff7f1b
err as report
sergerad 4cb0459
Rm order query
sergerad 6885616
RM deadcode
sergerad e612a98
Align sql add comments
sergerad 624c581
Add raw sql comment
sergerad 2289a42
Fix validator key var name
sergerad 78030a7
Added explanatory comment for store validator key arg
sergerad 425f645
ValidatorConfig::to_addresses()
sergerad 025cc93
Rm pub
sergerad 6fa8f46
Add ValidatedTransactionInfo
sergerad 3af9c0a
Missing file
sergerad a6bf55d
Fix comment
sergerad a7a2455
Fix var name
sergerad e60ab9b
Fix changelog
sergerad 28ca16f
Merge branch 'next' of github.com:0xMiden/miden-node into sergerad-va…
sergerad adb60b3
Toml
sergerad 00e45be
Revert dockerfile
sergerad 5ca7001
Add block_num col and index + ValidatedTransactionInfoBlob
sergerad 0081637
Fix comment
sergerad c341458
Merge branch 'next' of github.com:0xMiden/miden-node into sergerad-va…
sergerad f3d1cfd
Update changelog wording
sergerad 7937a7f
Refactor validated tx info
sergerad 65b5af0
Source errors
sergerad 61a9548
Missing file
sergerad d032732
Merge branch 'next' of github.com:0xMiden/miden-node into sergerad-va…
sergerad 806ec05
Instrument for errors, on conflict do nothing, WAL and timeout
sergerad 959f7e0
Instrument db fns
sergerad 528a265
RM unnecessary src
sergerad 4f46477
Add 5s pragma
sergerad 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
sergerad marked this conversation as resolved.
Show resolved
Hide resolved
|
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,9 @@ | ||
| // This build.rs is required to trigger the `diesel_migrations::embed_migrations!` proc-macro in | ||
| // `validator/src/db/migrations.rs` to include the latest version of the migrations into the binary, see <https://docs.rs/diesel_migrations/latest/diesel_migrations/macro.embed_migrations.html#automatic-rebuilds>. | ||
| fn main() { | ||
| println!("cargo:rerun-if-changed=./src/db/migrations"); | ||
| // If we do one re-write, the default rules are disabled, | ||
| // hence we need to trigger explicitly on `Cargo.toml`. | ||
| // <https://doc.rust-lang.org/cargo/reference/build-scripts.html#rerun-if-changed> | ||
| println!("cargo:rerun-if-changed=Cargo.toml"); | ||
| } |
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,5 @@ | ||
| # For documentation on how to configure this file, | ||
| # see https://diesel.rs/guides/configuring-diesel-cli | ||
|
|
||
| [print_schema] | ||
| file = "src/db/schema.rs" |
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,25 @@ | ||
| use diesel::SqliteConnection; | ||
| use diesel_migrations::{EmbeddedMigrations, MigrationHarness, embed_migrations}; | ||
| use miden_node_store::DatabaseError; | ||
| use tracing::instrument; | ||
|
|
||
| use crate::COMPONENT; | ||
|
|
||
| // The rebuild is automatically triggered by `build.rs` as described in | ||
| // <https://docs.rs/diesel_migrations/latest/diesel_migrations/macro.embed_migrations.html#automatic-rebuilds>. | ||
| pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!("src/db/migrations"); | ||
|
|
||
| #[instrument(level = "debug", target = COMPONENT, skip_all, err)] | ||
| pub fn apply_migrations(conn: &mut SqliteConnection) -> std::result::Result<(), DatabaseError> { | ||
| let migrations = conn.pending_migrations(MIGRATIONS).expect("In memory migrations never fail"); | ||
| tracing::info!(target = COMPONENT, "Applying {} migration(s)", migrations.len()); | ||
|
|
||
| let Err(e) = conn.run_pending_migrations(MIGRATIONS) else { | ||
| return Ok(()); | ||
| }; | ||
| tracing::warn!(target = COMPONENT, "Failed to apply migration: {e:?}"); | ||
| conn.revert_last_migration(MIGRATIONS) | ||
| .expect("Duality is maintained by the developer"); | ||
|
|
||
| Ok(()) | ||
| } | ||
drahnr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Empty file.
15 changes: 15 additions & 0 deletions
15
crates/validator/src/db/migrations/2025062000000_setup/up.sql
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,15 @@ | ||
| CREATE TABLE transactions ( | ||
| transaction_id BLOB NOT NULL, | ||
| account_id BLOB NOT NULL, | ||
| block_num INTEGER NOT NULL, -- Block number in which the transaction was included. | ||
| initial_state_commitment BLOB NOT NULL, -- State of the account before applying the transaction. | ||
| final_state_commitment BLOB NOT NULL, -- State of the account after applying the transaction. | ||
| input_notes BLOB NOT NULL, -- Serialized vector with the Nullifier of the input notes. | ||
| output_notes BLOB NOT NULL, -- Serialized vector with the NoteId of the output notes. | ||
| size_in_bytes INTEGER NOT NULL, -- Estimated size of the row in bytes, considering the size of the input and output notes. | ||
|
|
||
| PRIMARY KEY (transaction_id) | ||
| ) WITHOUT ROWID; | ||
sergerad marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| CREATE INDEX idx_transactions_account_id ON transactions(account_id); | ||
| CREATE INDEX idx_transactions_block_num ON transactions(block_num); | ||
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.
Uh oh!
There was an error while loading. Please reload this page.