Skip to content

Commit c14a650

Browse files
feat: use AccountTree type wrapper (#783)
1 parent bbca6a1 commit c14a650

12 files changed

Lines changed: 168 additions & 197 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Database is now created during bootstrap process instead of on first startup.
99
- Data directory is no longer created but is instead expected to exist.
1010
- The genesis block can no longer be configured which also removes the `store dump-genesis` command.
11+
- [BREAKING] Use `AccountTree` and update account witness proto definitions (#783).
1112

1213
## Unreleased
1314

Cargo.lock

Lines changed: 31 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/block-producer/src/block_builder/mod.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -309,21 +309,14 @@ impl TelemetryInjectorExt for ProposedBlock {
309309
u32::try_from(self.created_nullifiers().len())
310310
.expect("should have less than u32::MAX created nullifiers"),
311311
);
312-
let num_block_created_notes = self
313-
.output_note_batches()
314-
.iter()
315-
.fold(0, |acc, output_notes| acc + output_notes.len());
312+
let num_block_created_notes = self.batches().num_created_notes();
316313
span.set_attribute(
317314
"block.output_notes.count",
318315
u32::try_from(num_block_created_notes)
319316
.expect("should have less than u32::MAX output notes"),
320317
);
321318

322-
let num_batch_created_notes = self
323-
.batches()
324-
.as_slice()
325-
.iter()
326-
.fold(0, |acc, batch| acc + batch.output_notes().len());
319+
let num_batch_created_notes = self.batches().num_created_notes();
327320
span.set_attribute(
328321
"block.batches.output_notes.count",
329322
u32::try_from(num_batch_created_notes)

crates/block-producer/src/test_utils/block.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use miden_objects::{
2-
ACCOUNT_TREE_DEPTH, Digest,
2+
Digest,
33
batch::ProvenBatch,
44
block::{
5-
BlockAccountUpdate, BlockHeader, BlockNoteIndex, BlockNoteTree, OutputNoteBatch,
6-
ProvenBlock,
5+
AccountTree, BlockAccountUpdate, BlockHeader, BlockNoteIndex, BlockNoteTree,
6+
OutputNoteBatch, ProvenBlock,
77
},
8-
crypto::merkle::{Mmr, SimpleSmt},
8+
crypto::merkle::Mmr,
99
note::Nullifier,
1010
transaction::{OrderedTransactionHeaders, OutputNote},
1111
};
@@ -34,7 +34,9 @@ pub async fn build_expected_block_header(
3434
let new_account_root = {
3535
let mut store_accounts = store.accounts.read().await.clone();
3636
for (&account_id, update) in updated_accounts {
37-
store_accounts.insert(account_id.into(), update.final_state_commitment().into());
37+
store_accounts
38+
.insert(account_id, update.final_state_commitment())
39+
.expect("account IDs should be unique");
3840
}
3941

4042
store_accounts.root()
@@ -71,7 +73,7 @@ pub async fn build_expected_block_header(
7173

7274
#[derive(Debug)]
7375
pub struct MockBlockBuilder {
74-
store_accounts: SimpleSmt<ACCOUNT_TREE_DEPTH>,
76+
store_accounts: AccountTree,
7577
store_chain_mmr: Mmr,
7678
last_block_header: BlockHeader,
7779

@@ -105,7 +107,8 @@ impl MockBlockBuilder {
105107
pub fn account_updates(mut self, updated_accounts: Vec<BlockAccountUpdate>) -> Self {
106108
for update in &updated_accounts {
107109
self.store_accounts
108-
.insert(update.account_id().into(), update.final_state_commitment().into());
110+
.insert(update.account_id(), update.final_state_commitment())
111+
.expect("account IDs should be unique");
109112
}
110113

111114
self.updated_accounts = Some(updated_accounts);

0 commit comments

Comments
 (0)