-
Notifications
You must be signed in to change notification settings - Fork 100
chore(ntx): replace in memory with sqlite database #1662
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
Mirko-von-Leipzig
merged 20 commits into
next
from
santiagopittella-ntx-builder-state-mgmt-migration-v2
Feb 20, 2026
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
1085eb0
chore: replace in memory with sqlite database
SantiagoPittella 3e1b7bb
review: move backoff_has_passed to proper file
SantiagoPittella a592a18
review: make ID not nullable
SantiagoPittella b99b2bd
review: re-add test in proper file
SantiagoPittella 1441d16
review: merge Db initialization methods
SantiagoPittella 964302c
review: move to DELETE+INSERT
SantiagoPittella b491d79
Merge branch 'next' into santiagopittella-ntx-builder-state-mgmt-migr…
SantiagoPittella 325de14
review: use i64 for block_num
SantiagoPittella 15668a7
review: remove bootstrap_sync
SantiagoPittella c2d18f7
review: remove in memory db for tests
SantiagoPittella 3be6816
Merge branch 'next' into santiagopittella-ntx-builder-state-mgmt-migr…
SantiagoPittella 5a12d65
Merge branch 'next' into santiagopittella-ntx-builder-state-mgmt-migr…
SantiagoPittella 80a84c9
review: remove match with map
SantiagoPittella 6fd47ec
review: rename to get_account
SantiagoPittella 0b0c337
review: rename to add_transaction
SantiagoPittella b1ba616
review: rename to commit_block
SantiagoPittella 1d6544f
review: rename to revert_transaction
SantiagoPittella c2ad2a3
chore: rename method in caller sites
SantiagoPittella ae58069
Merge branch 'next' into santiagopittella-ntx-builder-state-mgmt-migr…
SantiagoPittella 550f449
Merge branch 'next' into santiagopittella-ntx-builder-state-mgmt-migr…
SantiagoPittella 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| use miden_node_proto::domain::account::NetworkAccountId; | ||
| use miden_protocol::account::delta::AccountUpdateDetails; | ||
| use miden_protocol::account::{Account, AccountDelta, AccountId}; | ||
|
|
||
| // NETWORK ACCOUNT EFFECT | ||
| // ================================================================================================ | ||
|
|
||
| /// Represents the effect of a transaction on a network account. | ||
| #[derive(Clone)] | ||
| pub enum NetworkAccountEffect { | ||
| Created(Account), | ||
| Updated(AccountDelta), | ||
| } | ||
|
|
||
| impl NetworkAccountEffect { | ||
| pub fn from_protocol(update: &AccountUpdateDetails) -> Option<Self> { | ||
| let update = match update { | ||
| AccountUpdateDetails::Private => return None, | ||
| AccountUpdateDetails::Delta(update) if update.is_full_state() => { | ||
| NetworkAccountEffect::Created( | ||
| Account::try_from(update) | ||
| .expect("Account should be derivable by full state AccountDelta"), | ||
| ) | ||
| }, | ||
| AccountUpdateDetails::Delta(update) => NetworkAccountEffect::Updated(update.clone()), | ||
| }; | ||
|
|
||
| update.protocol_account_id().is_network().then_some(update) | ||
| } | ||
|
|
||
| pub fn network_account_id(&self) -> NetworkAccountId { | ||
| // SAFETY: This is a network account by construction. | ||
| self.protocol_account_id().try_into().unwrap() | ||
| } | ||
|
|
||
| fn protocol_account_id(&self) -> AccountId { | ||
| match self { | ||
| NetworkAccountEffect::Created(acc) => acc.id(), | ||
| NetworkAccountEffect::Updated(delta) => delta.id(), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use miden_protocol::block::BlockNumber; | ||
|
|
||
| #[rstest::rstest] | ||
| #[test] | ||
| #[case::all_zero(Some(BlockNumber::GENESIS), BlockNumber::GENESIS, 0, true)] | ||
| #[case::no_attempts(None, BlockNumber::GENESIS, 0, true)] | ||
| #[case::one_attempt(Some(BlockNumber::GENESIS), BlockNumber::from(2), 1, true)] | ||
| #[case::three_attempts(Some(BlockNumber::GENESIS), BlockNumber::from(3), 3, true)] | ||
| #[case::ten_attempts(Some(BlockNumber::GENESIS), BlockNumber::from(13), 10, true)] | ||
| #[case::twenty_attempts(Some(BlockNumber::GENESIS), BlockNumber::from(149), 20, true)] | ||
| #[case::one_attempt_false(Some(BlockNumber::GENESIS), BlockNumber::from(1), 1, false)] | ||
| #[case::three_attempts_false(Some(BlockNumber::GENESIS), BlockNumber::from(2), 3, false)] | ||
| #[case::ten_attempts_false(Some(BlockNumber::GENESIS), BlockNumber::from(12), 10, false)] | ||
| #[case::twenty_attempts_false(Some(BlockNumber::GENESIS), BlockNumber::from(148), 20, false)] | ||
| fn backoff_has_passed( | ||
| #[case] last_attempt_block_num: Option<BlockNumber>, | ||
| #[case] current_block_num: BlockNumber, | ||
| #[case] attempt_count: usize, | ||
| #[case] backoff_should_have_passed: bool, | ||
| ) { | ||
| use crate::actor::has_backoff_passed; | ||
|
|
||
| assert_eq!( | ||
| backoff_should_have_passed, | ||
| has_backoff_passed(current_block_num, last_attempt_block_num, attempt_count) | ||
| ); | ||
| } | ||
| } | ||
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.