Skip to content

Commit

Permalink
feat: add check nullifiers request
Browse files Browse the repository at this point in the history
  • Loading branch information
tomyrd committed Mar 5, 2025
1 parent 02eb0de commit 3dc16d5
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 136 deletions.
12 changes: 0 additions & 12 deletions crates/rust-client/src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ use miden_objects::{
block::{BlockHeader, BlockNumber},
crypto::merkle::{InOrderIndex, MmrPeaks},
note::{NoteId, NoteTag, Nullifier},
transaction::TransactionId,
Digest, Word,
};

use crate::{
note::NoteUpdates,
sync::{NoteTagRecord, StateSyncUpdate},
transaction::{TransactionRecord, TransactionStoreUpdate},
};
Expand Down Expand Up @@ -313,16 +311,6 @@ pub trait Store: Send + Sync {
/// - Storing new MMR authentication nodes.
/// - Updating the tracked public accounts.
async fn apply_state_sync(&self, state_sync_update: StateSyncUpdate) -> Result<(), StoreError>;

/// Applies nullifier updates to database.
/// Nullifiers are retrieved after completing a `StateSync`.
///
/// This operation is temporary, to be removed as part of miden-client/650.
async fn apply_nullifiers(
&self,
note_updates: NoteUpdates,
transactions_to_discard: Vec<TransactionId>,
) -> Result<(), StoreError>;
}

// CHAIN MMR NODE FILTER
Expand Down
13 changes: 0 additions & 13 deletions crates/rust-client/src/store/sqlite_store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use miden_objects::{
block::{BlockHeader, BlockNumber},
crypto::merkle::{InOrderIndex, MmrPeaks},
note::{NoteTag, Nullifier},
transaction::TransactionId,
Digest, Word,
};
use rusqlite::{types::Value, vtab::array, Connection};
Expand All @@ -28,7 +27,6 @@ use super::{
OutputNoteRecord, Store, TransactionFilter,
};
use crate::{
note::NoteUpdates,
store::StoreError,
sync::{NoteTagRecord, StateSyncUpdate},
transaction::{TransactionRecord, TransactionStoreUpdate},
Expand Down Expand Up @@ -329,17 +327,6 @@ impl Store for SqliteStore {
self.interact_with_connection(SqliteStore::get_unspent_input_note_nullifiers)
.await
}

async fn apply_nullifiers(
&self,
note_updates: NoteUpdates,
transactions_to_discard: Vec<TransactionId>,
) -> Result<(), StoreError> {
self.interact_with_connection(move |conn| {
SqliteStore::apply_nullifiers(conn, &note_updates, &transactions_to_discard)
})
.await
}
}

// UTILS
Expand Down
19 changes: 1 addition & 18 deletions crates/rust-client/src/store/sqlite_store/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

use alloc::{collections::BTreeSet, vec::Vec};

use miden_objects::{block::BlockNumber, note::NoteTag, transaction::TransactionId};
use miden_objects::{block::BlockNumber, note::NoteTag};
use miden_tx::utils::{Deserializable, Serializable};
use rusqlite::{params, Connection, Transaction};

use super::SqliteStore;
use crate::{
note::NoteUpdates,
store::{
sqlite_store::{
account::{lock_account, update_account},
Expand Down Expand Up @@ -172,22 +171,6 @@ impl SqliteStore {

Ok(())
}

pub(super) fn apply_nullifiers(
conn: &mut Connection,
note_updates: &NoteUpdates,
transactions_to_discard: &[TransactionId],
) -> Result<(), StoreError> {
let tx = conn.transaction()?;

apply_note_updates_tx(&tx, note_updates)?;

Self::mark_transactions_as_discarded(&tx, transactions_to_discard)?;

tx.commit()?;

Ok(())
}
}

pub(super) fn add_note_tag_tx(tx: &Transaction<'_>, tag: &NoteTagRecord) -> Result<(), StoreError> {
Expand Down
10 changes: 0 additions & 10 deletions crates/rust-client/src/store/web_store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use miden_objects::{
block::{BlockHeader, BlockNumber},
crypto::merkle::{InOrderIndex, MmrPeaks},
note::Nullifier,
transaction::TransactionId,
Digest, Word,
};
use tonic::async_trait;
Expand All @@ -26,7 +25,6 @@ use super::{
OutputNoteRecord, Store, StoreError, TransactionFilter,
};
use crate::{
note::NoteUpdates,
sync::{NoteTagRecord, StateSyncUpdate},
transaction::{TransactionRecord, TransactionStoreUpdate},
};
Expand Down Expand Up @@ -87,14 +85,6 @@ impl Store for WebStore {
self.apply_state_sync(state_sync_update).await
}

async fn apply_nullifiers(
&self,
note_updates: NoteUpdates,
transactions_to_discard: Vec<TransactionId>,
) -> Result<(), StoreError> {
self.apply_nullifiers(note_updates, transactions_to_discard).await
}

// TRANSACTIONS
// --------------------------------------------------------------------------------------------

Expand Down
10 changes: 0 additions & 10 deletions crates/rust-client/src/store/web_store/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use miden_objects::{
account::AccountId,
block::BlockNumber,
note::{NoteId, NoteTag},
transaction::TransactionId,
};
use miden_tx::utils::{Deserializable, Serializable};
use serde_wasm_bindgen::from_value;
Expand All @@ -20,7 +19,6 @@ use super::{
WebStore,
};
use crate::{
note::NoteUpdates,
store::StoreError,
sync::{NoteTagRecord, NoteTagSource, StateSyncUpdate},
};
Expand Down Expand Up @@ -195,12 +193,4 @@ impl WebStore {

Ok(())
}

pub(super) async fn apply_nullifiers(
&self,
note_updates: NoteUpdates,
_transactions_to_discard: Vec<TransactionId>,
) -> Result<(), StoreError> {
apply_note_updates_tx(&note_updates).await
}
}
Loading

0 comments on commit 3dc16d5

Please sign in to comment.