Skip to content

Commit

Permalink
refactor: keep only domain object changes
Browse files Browse the repository at this point in the history
  • Loading branch information
polydez committed Mar 29, 2024
1 parent fbcfd6b commit 28d44fb
Show file tree
Hide file tree
Showing 30 changed files with 111 additions and 853 deletions.
159 changes: 0 additions & 159 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ exclude = [".github/"]
[workspace.dependencies]
miden-air = { version = "0.8", default-features = false }
miden-lib = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next" }
miden-mock = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next" }
miden-objects = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next" }
miden-processor = { version = "0.8" }
miden-stdlib = { version = "0.8", default-features = false }
Expand Down
17 changes: 6 additions & 11 deletions block-producer/src/batch_builder/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use miden_objects::{
merkle::SimpleSmt,
},
notes::{NoteEnvelope, Nullifier},
transaction::AccountDetails,
Digest, BATCH_OUTPUT_NOTES_TREE_DEPTH, MAX_NOTES_PER_BATCH,
};
use tracing::instrument;
Expand Down Expand Up @@ -56,7 +55,6 @@ impl TransactionBatch {
AccountStates {
initial_state: tx.initial_account_hash(),
final_state: tx.final_account_hash(),
details: tx.account_details().cloned(),
},
)
})
Expand Down Expand Up @@ -110,14 +108,12 @@ impl TransactionBatch {
.map(|(account_id, account_states)| (*account_id, account_states.initial_state))
}

/// Returns an iterator over (account_id, details, new_state_hash) tuples for accounts that were
/// Returns an iterator over (account_id, new_state_hash) tuples for accounts that were
/// modified in this transaction batch.
pub fn updated_accounts(
&self
) -> impl Iterator<Item = (AccountId, Option<AccountDetails>, Digest)> + '_ {
self.updated_accounts.iter().map(|(account_id, account_states)| {
(*account_id, account_states.details.clone(), account_states.final_state)
})
pub fn updated_accounts(&self) -> impl Iterator<Item = (AccountId, Digest)> + '_ {
self.updated_accounts
.iter()
.map(|(account_id, account_states)| (*account_id, account_states.final_state))
}

/// Returns an iterator over produced nullifiers for all consumed notes.
Expand Down Expand Up @@ -151,9 +147,8 @@ impl TransactionBatch {
/// account.
///
/// TODO: should this be moved into domain objects?
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
struct AccountStates {
initial_state: Digest,
final_state: Digest,
details: Option<AccountDetails>,
}
4 changes: 2 additions & 2 deletions block-producer/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use miden_objects::{
accounts::AccountId,
crypto::merkle::{MerklePath, MmrPeaks, SmtProof},
notes::{NoteEnvelope, Nullifier},
transaction::AccountDetails,
BlockHeader, Digest,
};

Expand All @@ -18,10 +17,11 @@ use crate::store::BlockInputsError;
#[derive(Debug, Clone)]
pub struct Block {
pub header: BlockHeader,
pub updated_accounts: Vec<(AccountId, Option<AccountDetails>, Digest)>,
pub updated_accounts: Vec<(AccountId, Digest)>,
pub created_notes: BTreeMap<u64, NoteEnvelope>,
pub produced_nullifiers: Vec<Nullifier>,
// TODO:
// - full states for updated public accounts
// - full states for created public notes
// - zk proof
}
Expand Down
8 changes: 3 additions & 5 deletions block-producer/src/block_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ use std::sync::Arc;

use async_trait::async_trait;
use miden_node_utils::formatting::{format_array, format_blake3_digest};
use miden_objects::{
accounts::AccountId, notes::Nullifier, transaction::AccountDetails, Digest, MAX_NOTES_PER_BATCH,
};
use miden_objects::{accounts::AccountId, notes::Nullifier, Digest, MAX_NOTES_PER_BATCH};
use tracing::{debug, info, instrument};

use crate::{
Expand Down Expand Up @@ -79,7 +77,7 @@ where
batches = %format_array(batches.iter().map(|batch| format_blake3_digest(batch.id()))),
);

let updated_accounts: Vec<(AccountId, Option<AccountDetails>, Digest)> =
let updated_accounts: Vec<(AccountId, Digest)> =
batches.iter().flat_map(TransactionBatch::updated_accounts).collect();
let created_notes = batches
.iter()
Expand All @@ -97,7 +95,7 @@ where
let block_inputs = self
.store
.get_block_inputs(
updated_accounts.iter().map(|(account_id, _, _)| account_id),
updated_accounts.iter().map(|(account_id, _)| account_id),
produced_nullifiers.iter(),
)
.await?;
Expand Down
Loading

0 comments on commit 28d44fb

Please sign in to comment.