Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Database is now created during bootstrap process instead of on first startup.
- Data directory is no longer created but is instead expected to exist.
- The genesis block can no longer be configured which also removes the `store dump-genesis` command.
- [BREAKING] Use `AccountTree` and update account witness proto definitions (#783).

## v0.8.0 (2025-03-26)

Expand Down
28 changes: 14 additions & 14 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ assert_matches = { version = "1.5" }
http = { version = "1.3" }
itertools = { version = "0.14" }
miden-air = { version = "0.13" }
miden-lib = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next" }
miden-lib = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "pgackst-account-tree" }
miden-node-block-producer = { path = "crates/block-producer", version = "0.9" }
miden-node-proto = { path = "crates/proto", version = "0.9" }
miden-node-proto-build = { path = "proto", version = "0.9" }
miden-node-rpc = { path = "crates/rpc", version = "0.9" }
miden-node-store = { path = "crates/store", version = "0.9" }
miden-node-test-macro = { path = "crates/test-macro" }
miden-node-utils = { path = "crates/utils", version = "0.9" }
miden-objects = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next" }
miden-objects = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "pgackst-account-tree" }
miden-processor = { version = "0.13" }
miden-tx = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next" }
miden-tx = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "pgackst-account-tree" }
prost = { version = "0.13" }
rand = { version = "0.9" }
thiserror = { version = "2.0", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion bin/stress-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ workspace = true
anyhow = { workspace = true }
clap = { version = "4.5", features = ["derive", "string"] }
miden-air = { workspace = true }
miden-block-prover = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next", features = [
miden-block-prover = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "pgackst-account-tree", features = [
"testing",
] }
miden-lib = { workspace = true }
Expand Down
6 changes: 3 additions & 3 deletions crates/block-producer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ tracing-forest = ["miden-node-utils/tracing-forest"]
async-trait = { version = "0.1" }
futures = { version = "0.3" }
itertools = { workspace = true }
miden-block-prover = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next" }
miden-block-prover = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "pgackst-account-tree" }
miden-lib = { workspace = true }
miden-node-proto = { workspace = true }
miden-node-utils = { workspace = true }
miden-objects = { workspace = true }
miden-processor = { workspace = true }
miden-proving-service-client = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next", features = [
miden-proving-service-client = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "pgackst-account-tree", features = [
"batch-prover",
"block-prover",
] }
miden-tx = { workspace = true }
miden-tx-batch-prover = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next" }
miden-tx-batch-prover = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "pgackst-account-tree" }
rand = { version = "0.9" }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["macros", "net", "rt-multi-thread", "sync", "time"] }
Expand Down
11 changes: 2 additions & 9 deletions crates/block-producer/src/block_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,21 +309,14 @@ impl TelemetryInjectorExt for ProposedBlock {
u32::try_from(self.created_nullifiers().len())
.expect("should have less than u32::MAX created nullifiers"),
);
let num_block_created_notes = self
.output_note_batches()
.iter()
.fold(0, |acc, output_notes| acc + output_notes.len());
let num_block_created_notes = self.batches().num_created_notes();
span.set_attribute(
"block.output_notes.count",
u32::try_from(num_block_created_notes)
.expect("should have less than u32::MAX output notes"),
);

let num_batch_created_notes = self
.batches()
.as_slice()
.iter()
.fold(0, |acc, batch| acc + batch.output_notes().len());
let num_batch_created_notes = self.batches().num_created_notes();
Comment on lines +312 to +319
Copy link
Collaborator

@igamigo igamigo Apr 18, 2025

Choose a reason for hiding this comment

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

Is this right? Seems like there is no difference between num_block_created_notes and num_batch_created_notes and so num_erased_notes will always be 0

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah yeah nice catch. It looks like the block variant is incorrect now.

ProposedBlock::output_note_batches should be used there it seems, though the naming is a bit confusing :)

I'll create an issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch!

span.set_attribute(
"block.batches.output_notes.count",
u32::try_from(num_batch_created_notes)
Expand Down
17 changes: 10 additions & 7 deletions crates/block-producer/src/test_utils/block.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use miden_objects::{
ACCOUNT_TREE_DEPTH, Digest,
Digest,
batch::ProvenBatch,
block::{
BlockAccountUpdate, BlockHeader, BlockNoteIndex, BlockNoteTree, OutputNoteBatch,
ProvenBlock,
AccountTree, BlockAccountUpdate, BlockHeader, BlockNoteIndex, BlockNoteTree,
OutputNoteBatch, ProvenBlock,
},
crypto::merkle::{Mmr, SimpleSmt},
crypto::merkle::Mmr,
note::Nullifier,
transaction::{OrderedTransactionHeaders, OutputNote},
};
Expand Down Expand Up @@ -34,7 +34,9 @@ pub async fn build_expected_block_header(
let new_account_root = {
let mut store_accounts = store.accounts.read().await.clone();
for (&account_id, update) in updated_accounts {
store_accounts.insert(account_id.into(), update.final_state_commitment().into());
store_accounts
.insert(account_id, update.final_state_commitment())
.expect("account IDs should be unique");
}

store_accounts.root()
Expand Down Expand Up @@ -71,7 +73,7 @@ pub async fn build_expected_block_header(

#[derive(Debug)]
pub struct MockBlockBuilder {
store_accounts: SimpleSmt<ACCOUNT_TREE_DEPTH>,
store_accounts: AccountTree,
store_chain_mmr: Mmr,
last_block_header: BlockHeader,

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

self.updated_accounts = Some(updated_accounts);
Expand Down
45 changes: 19 additions & 26 deletions crates/block-producer/src/test_utils/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use std::{
};

use miden_objects::{
ACCOUNT_TREE_DEPTH, Digest, EMPTY_WORD, ZERO,
Digest, EMPTY_WORD, Word, ZERO,
account::AccountId,
batch::ProvenBatch,
block::{BlockHeader, BlockNumber, OutputNoteBatch, ProvenBlock},
crypto::merkle::{Mmr, SimpleSmt, Smt},
block::{AccountTree, BlockHeader, BlockNumber, OutputNoteBatch, ProvenBlock},
crypto::merkle::{Mmr, Smt},
note::{NoteId, NoteInclusionProof},
transaction::ProvenTransaction,
};
Expand All @@ -26,7 +26,7 @@ use crate::{
/// Builds a [`MockStoreSuccess`]
#[derive(Debug)]
pub struct MockStoreSuccessBuilder {
accounts: Option<SimpleSmt<ACCOUNT_TREE_DEPTH>>,
accounts: Option<AccountTree>,
notes: Option<Vec<OutputNoteBatch>>,
produced_nullifiers: Option<BTreeSet<Digest>>,
chain_mmr: Option<Mmr>,
Expand All @@ -36,16 +36,13 @@ pub struct MockStoreSuccessBuilder {
impl MockStoreSuccessBuilder {
pub fn from_batches<'a>(batches_iter: impl Iterator<Item = &'a ProvenBatch> + Clone) -> Self {
let accounts_smt = {
let accounts = batches_iter
.clone()
.flat_map(|batch| {
batch
.account_updates()
.iter()
.map(|(account_id, update)| (account_id, update.initial_state_commitment()))
})
.map(|(account_id, commitment)| (account_id.prefix().into(), commitment.into()));
SimpleSmt::<ACCOUNT_TREE_DEPTH>::with_leaves(accounts).unwrap()
let accounts = batches_iter.clone().flat_map(|batch| {
batch
.account_updates()
.iter()
.map(|(account_id, update)| (*account_id, update.initial_state_commitment()))
});
AccountTree::with_entries(accounts).unwrap()
};

Self {
Expand All @@ -58,12 +55,7 @@ impl MockStoreSuccessBuilder {
}

pub fn from_accounts(accounts: impl Iterator<Item = (AccountId, Digest)>) -> Self {
let accounts_smt = {
let accounts = accounts
.map(|(account_id, commitment)| (account_id.prefix().into(), commitment.into()));

SimpleSmt::<ACCOUNT_TREE_DEPTH>::with_leaves(accounts).unwrap()
};
let accounts_smt = AccountTree::with_entries(accounts).unwrap();

Self {
accounts: Some(accounts_smt),
Expand Down Expand Up @@ -107,7 +99,7 @@ impl MockStoreSuccessBuilder {

pub fn build(self) -> MockStoreSuccess {
let block_num = self.block_num.unwrap_or(1.into());
let accounts_smt = self.accounts.unwrap_or(SimpleSmt::new().unwrap());
let accounts_smt = self.accounts.unwrap_or_default();
let notes = self.notes.unwrap_or_default();
let block_note_tree = note_created_smt_from_note_batches(notes.iter());
let note_root = block_note_tree.root();
Expand Down Expand Up @@ -168,7 +160,7 @@ impl MockStoreSuccessBuilder {

pub struct MockStoreSuccess {
/// Map account id -> account commitment
pub accounts: Arc<RwLock<SimpleSmt<ACCOUNT_TREE_DEPTH>>>,
pub accounts: Arc<RwLock<AccountTree>>,

/// Stores the nullifiers of the notes that were consumed
pub produced_nullifiers: Arc<RwLock<Smt>>,
Expand Down Expand Up @@ -202,7 +194,8 @@ impl MockStoreSuccess {
// update accounts
for update in block.updated_accounts() {
locked_accounts
.insert(update.account_id().into(), update.final_state_commitment().into());
.insert(update.account_id(), update.final_state_commitment())
.expect("TODO: what should we do with this error?");
Comment on lines -205 to +198
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Mirko-von-Leipzig What should we do with this one? This is test code, so panicking might be fine? Otherwise I'll have to add a new variant to StoreError that is only used in tests.

Copy link
Collaborator

Choose a reason for hiding this comment

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

panic is fine 👍

}
let header = block.header();
debug_assert_eq!(locked_accounts.root(), header.account_root());
Expand Down Expand Up @@ -254,12 +247,12 @@ impl MockStoreSuccess {
let locked_produced_nullifiers = self.produced_nullifiers.read().await;

let account_commitment = {
let account_commitment = locked_accounts.get_leaf(&proven_tx.account_id().into());
let account_commitment = locked_accounts.get(proven_tx.account_id());

if account_commitment == EMPTY_WORD {
if Word::from(account_commitment) == EMPTY_WORD {
None
} else {
Some(account_commitment.into())
Some(account_commitment)
}
};

Expand Down
15 changes: 3 additions & 12 deletions crates/proto/src/domain/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use miden_objects::{
Digest,
account::{Account, AccountHeader, AccountId},
block::BlockNumber,
crypto::{hash::rpo::RpoDigest, merkle::MerklePath},
crypto::{hash::rpo::RpoDigest, merkle::SmtProof},
utils::{Deserializable, Serializable},
};

Expand Down Expand Up @@ -155,16 +155,14 @@ impl TryInto<StorageMapKeysProof> for proto::requests::get_account_proofs_reques
#[derive(Clone, Debug)]
pub struct AccountWitnessRecord {
pub account_id: AccountId,
pub initial_state_commitment: Digest,
pub proof: MerklePath,
pub proof: SmtProof,
}

impl From<AccountWitnessRecord> for proto::responses::AccountWitness {
fn from(from: AccountWitnessRecord) -> Self {
Self {
account_id: Some(from.account_id.into()),
initial_state_commitment: Some(from.initial_state_commitment.into()),
proof: Some(Into::into(&from.proof)),
proof: Some(from.proof.into()),
}
}
}
Expand All @@ -180,15 +178,8 @@ impl TryFrom<proto::responses::AccountWitness> for AccountWitnessRecord {
.account_id
.ok_or(proto::responses::AccountWitness::missing_field(stringify!(account_id)))?
.try_into()?,
initial_state_commitment: account_witness_record
.initial_state_commitment
.ok_or(proto::responses::AccountWitness::missing_field(stringify!(
account_commitment
)))?
.try_into()?,
proof: account_witness_record
.proof
.as_ref()
.ok_or(proto::responses::AccountWitness::missing_field(stringify!(proof)))?
.try_into()?,
})
Expand Down
Loading