Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v0.14.1 (2025-04-02)

- Fixed batch building issue with unauthenticated notes consumed in the same batch as they were created ([#1875](https://github.com/0xMiden/node/issues/1875)).

## v0.14.0 (2025-04-01)

### Enhancements
Expand Down
11 changes: 9 additions & 2 deletions crates/block-producer/src/mempool/graph/batch.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::HashMap;
use std::collections::{HashMap, HashSet};
use std::sync::Arc;

use miden_protocol::Word;
Expand Down Expand Up @@ -29,7 +29,14 @@ impl GraphNode for SelectedBatch {
}

fn unauthenticated_notes(&self) -> Box<dyn Iterator<Item = Word> + '_> {
Box::new(self.transactions().iter().flat_map(|tx| tx.unauthenticated_note_commitments()))
// Filter notes that are produced within this batch.
let output_notes: HashSet<Word> = self.output_notes().collect();
Box::new(
self.transactions()
.iter()
.flat_map(|tx| tx.unauthenticated_note_commitments())
.filter(move |note| !output_notes.contains(note)),
)
}

fn account_updates(
Expand Down
37 changes: 37 additions & 0 deletions crates/block-producer/src/mempool/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,3 +406,40 @@ fn pass_through_txs_with_note_dependencies() {

assert_eq!(uut, reference);
}

/// Tests that a batch containing transactions with intra-batch unauthenticated note dependencies
/// can be appended to the batch graph.
#[test]
fn intra_batch_unauthenticated_note() {
let (mut uut, _) = Mempool::for_tests();

let tx_final = MockProvenTxBuilder::with_account_index(0).build();
let account_update = tx_final.account_update();

let tx_pass_through = MockProvenTxBuilder::with_account(
account_update.account_id(),
account_update.initial_state_commitment(),
account_update.initial_state_commitment(),
);

// Transaction A creates note.
let tx_a = tx_pass_through
.clone()
.nullifiers_range(0..2)
.private_notes_created_range(3..4)
.build();
let tx_a = Arc::new(AuthenticatedTransaction::from_inner(tx_a));

// Transaction B consumes the note (unauthenticated).
let tx_b = tx_pass_through.unauthenticated_notes_range(3..4).build();
let tx_b = Arc::new(AuthenticatedTransaction::from_inner(tx_b));

// Add both transactions before selecting a batch so they end up in the same batch.
uut.add_transaction(tx_a.clone()).unwrap();
uut.add_transaction(tx_b.clone()).unwrap();

let batch = uut.select_batch().unwrap();

assert!(batch.transactions().contains(&tx_a));
assert!(batch.transactions().contains(&tx_b));
}
Loading