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
18 changes: 2 additions & 16 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
# Changelog

## 0.14.0 (TBD)

### Features

- Enable `CodeBuilder` to add advice map entries to compiled scripts ([#2275](https://github.com/0xMiden/miden-base/pull/2275)).
- Added `BlockNumber::MAX` constant to represent the maximum block number ([#2324](https://github.com/0xMiden/miden-base/pull/2324)).

### Changes

- [BREAKING] Renamed `WellKnownComponent` to `StandardAccountComponent`, `WellKnownNote` to `StandardNote`, and `WellKnownNoteAttachment` to `StandardNoteAttachment` ([#2332](https://github.com/0xMiden/miden-base/pull/2332)).
- Skip requests to the `DataStore` for asset vault witnesses which are already in transaction inputs ([#2298](https://github.com/0xMiden/miden-base/pull/2298)).
- [BREAKING] refactored `TransactionAuthenticator::get_public_key()` method to return `Arc<PublicKey> `instead of `&PublicKey` ([#2304](https://github.com/0xMiden/miden-base/pull/2304)).
- [BREAKING] Renamed `NoteInputs` to `NoteStorage` to better reflect that values are stored data associated with a note rather than inputs ([#1662](https://github.com/0xMiden/miden-base/issues/1662), [#2316](https://github.com/0xMiden/miden-base/issues/2316)).
- Removed `NoteType::Encrypted` ([#2315](https://github.com/0xMiden/miden-base/pull/2315)).

# 0.13.3 (TBD)
## 0.13.3 (2026-01-27)

- Added standards for working with `NetworkAccountTarget` attachments ([#2338](https://github.com/0xMiden/miden-base/pull/2338)).
- Fixed `PartialBlockchain::add_block()` not adding block headers to the `blocks` map when `track=true`, which caused `prune_to()` to never untrack old blocks, leading to unbounded memory growth ([#2353](https://github.com/0xMiden/miden-base/pull/2353)).

## 0.13.2 (2026-01-21)

Expand Down
16 changes: 8 additions & 8 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ homepage = "https://miden.xyz"
license = "MIT"
repository = "https://github.com/0xMiden/miden-base"
rust-version = "1.90"
version = "0.13.2"
version = "0.13.3"

[profile.release]
codegen-units = 1
Expand Down
53 changes: 52 additions & 1 deletion crates/miden-protocol/src/transaction/partial_blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,18 @@ impl PartialBlockchain {
/// provided block header is for the next block in the chain.
///
/// If `track` parameter is set to true, the authentication path for the provided block header
/// will be added to this partial blockchain.
/// will be added to this partial blockchain, and the block header will be stored for later
/// retrieval.
///
/// # Panics
/// Panics if the `block_header.block_num` is not equal to the current chain length (i.e., the
/// provided block header is not the next block in the chain).
pub fn add_block(&mut self, block_header: &BlockHeader, track: bool) {
assert_eq!(block_header.block_num(), self.chain_length());
self.mmr.add(block_header.commitment(), track);
if track {
self.blocks.insert(block_header.block_num(), block_header.clone());
}
}

/// Drop every block header whose number is strictly less than `to.end`.
Expand Down Expand Up @@ -492,4 +496,51 @@ mod tests {
assert!(!chain.mmr().is_tracked(block_num as usize));
}
}

#[test]
fn add_block_with_track_adds_to_blocks() {
let mut blockchain = PartialBlockchain::default();
let header = int_to_block_header(0);

blockchain.add_block(&header, true);

assert!(blockchain.contains_block(0.into()));
assert_eq!(blockchain.num_tracked_blocks(), 1);
}

#[test]
fn add_block_without_track_does_not_add_to_blocks() {
let mut blockchain = PartialBlockchain::default();
let header = int_to_block_header(0);

blockchain.add_block(&header, false);

assert!(!blockchain.contains_block(0.into()));
assert_eq!(blockchain.num_tracked_blocks(), 0);
}

#[test]
fn prune_to_removes_tracked_blocks() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's simple enough but could also check that the MMR's internal node count decreases when pruning.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added assert!(!blockchain.mmr().is_tracked(i as usize)); checks

let mut blockchain = PartialBlockchain::default();
// Add 10 blocks with tracking
for i in 0..10u32 {
let header = int_to_block_header(i);
blockchain.add_block(&header, true);
}
assert_eq!(blockchain.num_tracked_blocks(), 10);

// Prune to keep only last 4
blockchain.prune_to(..6.into());

assert_eq!(blockchain.num_tracked_blocks(), 4);
for i in 0u32..6 {
assert!(!blockchain.contains_block(i.into()));
// Verify the underlying MMR also untracked the block
assert!(!blockchain.mmr().is_tracked(i as usize));
}
for i in 6u32..10 {
assert!(blockchain.contains_block(i.into()));
assert!(blockchain.mmr().is_tracked(i as usize));
}
}
}