diff --git a/crates/block-producer/src/batch_builder/batch.rs b/crates/block-producer/src/batch_builder/batch.rs index f973d213b..14e181f81 100644 --- a/crates/block-producer/src/batch_builder/batch.rs +++ b/crates/block-producer/src/batch_builder/batch.rs @@ -61,7 +61,10 @@ impl TransactionBatch { produced_nullifiers.push(note.nullifier()); if let Some(header) = note.header() { if !unauthenticated_input_notes.insert(header.id()) { - return Err(BuildBatchError::DuplicatedNoteId(header.id(), txs)); + return Err(BuildBatchError::DuplicateUnauthenticatedNote( + header.id(), + txs, + )); } } } diff --git a/crates/block-producer/src/batch_builder/mod.rs b/crates/block-producer/src/batch_builder/mod.rs index 6ade496c9..24e54b626 100644 --- a/crates/block-producer/src/batch_builder/mod.rs +++ b/crates/block-producer/src/batch_builder/mod.rs @@ -157,10 +157,11 @@ where let dangling_notes = self.find_dangling_notes(&txs).await; if !dangling_notes.is_empty() { - let stored_notes = match self.store.get_note_paths(dangling_notes.iter()).await { - Ok(stored_notes) => stored_notes, - Err(err) => return Err(BuildBatchError::NotePathsError(err, txs)), - }; + let stored_notes = + match self.store.get_note_authentication_info(dangling_notes.iter()).await { + Ok(stored_notes) => stored_notes, + Err(err) => return Err(BuildBatchError::NotePathsError(err, txs)), + }; let missing_notes: Vec<_> = dangling_notes .into_iter() .filter(|note_id| !stored_notes.contains_key(note_id)) diff --git a/crates/block-producer/src/errors.rs b/crates/block-producer/src/errors.rs index 6d360ec84..6093be290 100644 --- a/crates/block-producer/src/errors.rs +++ b/crates/block-producer/src/errors.rs @@ -81,7 +81,7 @@ pub enum BuildBatchError { NotePathsError(NotePathsError, Vec), #[error("Duplicated note ID in the batch: {0}")] - DuplicatedNoteId(NoteId, Vec), + DuplicateUnauthenticatedNote(NoteId, Vec), #[error("Unauthenticated transaction notes not found in the store: {0:?}")] UnauthenticatedNotesNotFound(Vec, Vec), @@ -93,7 +93,7 @@ impl BuildBatchError { BuildBatchError::TooManyNotesCreated(_, txs) => txs, BuildBatchError::NotesSmtError(_, txs) => txs, BuildBatchError::NotePathsError(_, txs) => txs, - BuildBatchError::DuplicatedNoteId(_, txs) => txs, + BuildBatchError::DuplicateUnauthenticatedNote(_, txs) => txs, BuildBatchError::UnauthenticatedNotesNotFound(_, txs) => txs, } } diff --git a/crates/block-producer/src/store/mod.rs b/crates/block-producer/src/store/mod.rs index 3f03468cc..b7bbc633f 100644 --- a/crates/block-producer/src/store/mod.rs +++ b/crates/block-producer/src/store/mod.rs @@ -52,7 +52,14 @@ pub trait Store: ApplyBlock { notes: impl Iterator + Send, ) -> Result; - async fn get_note_paths( + /// Returns note authentication information for the set of specified notes. + /// + /// If authentication info could for a note does not exist in the store, the note is omitted + /// from the returned set of notes. + /// + /// TODO: right now this return only Merkle paths per note, but this will need to be updated to + /// return full authentication info. + async fn get_note_authentication_info( &self, notes: impl Iterator + Send, ) -> Result, NotePathsError>; @@ -230,7 +237,7 @@ impl Store for DefaultStore { Ok(store_response.try_into()?) } - async fn get_note_paths( + async fn get_note_authentication_info( &self, notes: impl Iterator + Send, ) -> Result, NotePathsError> { diff --git a/crates/block-producer/src/test_utils/store.rs b/crates/block-producer/src/test_utils/store.rs index 0acf9efce..3280e515f 100644 --- a/crates/block-producer/src/test_utils/store.rs +++ b/crates/block-producer/src/test_utils/store.rs @@ -276,7 +276,7 @@ impl Store for MockStoreSuccess { }) } - async fn get_note_paths( + async fn get_note_authentication_info( &self, _notes: impl Iterator + Send, ) -> Result, NotePathsError> { @@ -312,7 +312,7 @@ impl Store for MockStoreFailure { Err(BlockInputsError::GrpcClientError(String::new())) } - async fn get_note_paths( + async fn get_note_authentication_info( &self, _notes: impl Iterator + Send, ) -> Result, NotePathsError> {