Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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 @@ -50,6 +50,7 @@
- [BREAKING] Removed `--wallet-filepath` / `--counter-filepath` flags and the `MIDEN_MONITOR_WALLET_FILEPATH` / `MIDEN_MONITOR_COUNTER_FILEPATH` env vars from the network monitor. The monitor now keeps wallet and counter accounts fully in memory and regenerates them on every startup; the dashboard's counter value resets to zero on restart.
- Added `--counter-pending-unhealthy-threshold` (env `MIDEN_MONITOR_COUNTER_PENDING_UNHEALTHY_THRESHOLD`, default `5`) to the network monitor: the Network Transactions card now flips unhealthy when the gap between expected and observed counter values stays above the threshold for three consecutive polls.
- Allowed network transaction submission conditionally via the gRPC `SubmitProvenTx` and `SubmitProvenTxBatch` endpoints: the NTX builder can now send a key in the `x-miden-network-tx-auth` header that enables submitting network transactions ([#2131](https://github.com/0xMiden/node/issues/2131)).
- Added `--tx-expiration-delta` (env `MIDEN_NODE_NTX_BUILDER_TX_EXPIRATION_DELTA`, default `30`) to the network transaction builder: submitted network transactions now expire on-chain after this many blocks, and the builder reuses the same delta as the local window before resubmitting a transaction that has not landed ([#2148](https://github.com/0xMiden/node/pull/2148)).

## v0.14.11 (TBD)

Expand Down
17 changes: 16 additions & 1 deletion bin/ntx-builder/src/actor/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use miden_protocol::transaction::{
TransactionArgs,
TransactionId,
TransactionInputs,
TransactionScript,
};
use miden_protocol::vm::FutureMaybeSend;
use miden_remote_prover_client::RemoteTransactionProver;
Expand Down Expand Up @@ -153,18 +154,27 @@ pub struct NtxContext {
/// Maximum number of VM execution cycles for network transactions.
max_cycles: u32,

/// Pre-compiled transaction script that sets the network tx's on-chain expiration delta. Cloned
/// into the [`TransactionArgs`] of the executed transaction.
expiration_script: TransactionScript,

/// [`ExponentialBuilder`] used to back off retries on transient request failures.
request_backoff: ExponentialBuilder,
}

impl NtxContext {
/// Creates a new [`NtxContext`] instance.
#[expect(
clippy::too_many_arguments,
reason = "execution context aggregates actor resources"
)]
pub fn new(
prover: Option<RemoteTransactionProver>,
rpc: RpcClient,
script_cache: LruCache<Word, NoteScript>,
db: Db,
max_cycles: u32,
expiration_script: TransactionScript,
request_backoff_initial: Duration,
request_backoff_max: Duration,
) -> Self {
Expand All @@ -175,6 +185,7 @@ impl NtxContext {
script_cache,
db,
max_cycles,
expiration_script,
request_backoff,
}
}
Expand Down Expand Up @@ -369,11 +380,15 @@ impl NtxContext {
) -> NtxResult<ExecutedTransaction> {
let executor = self.create_executor(data_store);

// Attach the pre-compiled expiration script so the submitted tx is rejected on-chain if it
// does not land within the configured block delta.
let tx_args = TransactionArgs::default().with_tx_script(self.expiration_script.clone());

Box::pin(executor.execute_transaction(
data_store.account.id(),
data_store.reference_block.block_num(),
notes,
TransactionArgs::default(),
tx_args,
))
.await
.map_err(NtxError::Execution)
Expand Down
Loading
Loading