Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1085eb0
chore: replace in memory with sqlite database
SantiagoPittella Feb 11, 2026
3e1b7bb
review: move backoff_has_passed to proper file
SantiagoPittella Feb 12, 2026
a592a18
review: make ID not nullable
SantiagoPittella Feb 12, 2026
b99b2bd
review: re-add test in proper file
SantiagoPittella Feb 12, 2026
1441d16
review: merge Db initialization methods
SantiagoPittella Feb 12, 2026
964302c
review: move to DELETE+INSERT
SantiagoPittella Feb 12, 2026
b491d79
Merge branch 'next' into santiagopittella-ntx-builder-state-mgmt-migr…
SantiagoPittella Feb 12, 2026
325de14
review: use i64 for block_num
SantiagoPittella Feb 13, 2026
15668a7
review: remove bootstrap_sync
SantiagoPittella Feb 13, 2026
c2d18f7
review: remove in memory db for tests
SantiagoPittella Feb 13, 2026
3be6816
Merge branch 'next' into santiagopittella-ntx-builder-state-mgmt-migr…
SantiagoPittella Feb 13, 2026
5a12d65
Merge branch 'next' into santiagopittella-ntx-builder-state-mgmt-migr…
SantiagoPittella Feb 18, 2026
80a84c9
review: remove match with map
SantiagoPittella Feb 19, 2026
6fd47ec
review: rename to get_account
SantiagoPittella Feb 19, 2026
0b0c337
review: rename to add_transaction
SantiagoPittella Feb 19, 2026
b1ba616
review: rename to commit_block
SantiagoPittella Feb 19, 2026
1d6544f
review: rename to revert_transaction
SantiagoPittella Feb 19, 2026
c2ad2a3
chore: rename method in caller sites
SantiagoPittella Feb 19, 2026
ae58069
Merge branch 'next' into santiagopittella-ntx-builder-state-mgmt-migr…
SantiagoPittella Feb 19, 2026
550f449
Merge branch 'next' into santiagopittella-ntx-builder-state-mgmt-migr…
SantiagoPittella Feb 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Refactored NTX Builder actor state into `AccountDeltaTracker` and `NotePool` for clarity, and added tracing instrumentation to event broadcasting ([#1611](https://github.com/0xMiden/miden-node/pull/1611)).
- Add #[track_caller] to tracing/logging helpers ([#1651](https://github.com/0xMiden/miden-node/pull/1651)).
- Improved tracing span fields ([#1650](https://github.com/0xMiden/miden-node/pull/1650))
- Replaced NTX Builder's in-memory state management with SQLite-backed persistence; account states, notes, and transaction effects are now stored in the database and inflight state is purged on startup ([#1662](https://github.com/0xMiden/miden-node/pull/1662)).

## v0.13.5 (TBD)

Expand Down
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bin/node/src/commands/bundled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ impl BundledCommand {
store_ntx_builder_url,
block_producer_url,
validator_url,
&data_directory,
);

let id = join_set
Expand Down
25 changes: 22 additions & 3 deletions bin/node/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::num::NonZeroUsize;
use std::path::{Path, PathBuf};
use std::time::Duration;

use miden_node_block_producer::{
Expand Down Expand Up @@ -78,19 +79,37 @@ pub struct NtxBuilderConfig {
default_value_t = DEFAULT_NTX_SCRIPT_CACHE_SIZE
)]
pub script_cache_size: NonZeroUsize,

/// Directory for the ntx-builder's persistent database.
///
/// If not set, defaults to the node's data directory.
#[arg(long = "ntx-builder.data-directory", value_name = "DIR")]
pub data_directory: Option<PathBuf>,
}

impl NtxBuilderConfig {
/// Converts this CLI config into the ntx-builder's internal config.
///
/// The `node_data_directory` is used as the default location for the ntx-builder's database
/// if `--ntx-builder.data-directory` is not explicitly set.
pub fn into_builder_config(
self,
store_url: Url,
block_producer_url: Url,
validator_url: Url,
node_data_directory: &Path,
) -> miden_node_ntx_builder::NtxBuilderConfig {
miden_node_ntx_builder::NtxBuilderConfig::new(store_url, block_producer_url, validator_url)
.with_tx_prover_url(self.tx_prover_url)
.with_script_cache_size(self.script_cache_size)
let data_dir = self.data_directory.unwrap_or_else(|| node_data_directory.to_path_buf());
let database_filepath = data_dir.join("ntx-builder.sqlite3");

miden_node_ntx_builder::NtxBuilderConfig::new(
store_url,
block_producer_url,
validator_url,
database_filepath,
)
.with_tx_prover_url(self.tx_prover_url)
.with_script_cache_size(self.script_cache_size)
}
}

Expand Down
5 changes: 3 additions & 2 deletions crates/ntx-builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ deadpool-sync = { features = ["tracing"], workspace = true }
diesel = { features = ["numeric", "sqlite"], workspace = true }
diesel_migrations = { features = ["sqlite"], workspace = true }
futures = { workspace = true }
indexmap = { workspace = true }
miden-node-proto = { workspace = true }
miden-node-utils = { workspace = true }
miden-protocol = { default-features = true, workspace = true }
miden-remote-prover-client = { features = ["tx-prover"], workspace = true }
miden-tx = { default-features = true, workspace = true }
prost = { workspace = true }
thiserror = { workspace = true }
tokio = { features = ["rt-multi-thread"], workspace = true }
tokio-stream = { workspace = true }
Expand All @@ -39,5 +39,6 @@ url = { workspace = true }
miden-node-test-macro = { path = "../test-macro" }
miden-node-utils = { features = ["testing"], workspace = true }
miden-protocol = { default-features = true, features = ["testing"], workspace = true }
miden-standards = { workspace = true }
miden-standards = { features = ["testing"], workspace = true }
rand_chacha = { workspace = true }
rstest = { workspace = true }
42 changes: 42 additions & 0 deletions crates/ntx-builder/src/actor/account_effect.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
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(),
}
}
}
Loading
Loading