The purpose of adding a nonce to the note hash is to make each note unique. Allowing notes in a storage slot (a Set or a Singleton) to have the same preimages. So that nullifying note{ value: 1, asset: A } won't invalidate dup_note{ value: 1, asset: A } because they will have different nonces, so their nullifier will be hash(nonce_1, contract_address, storage_slot, 1, A) and hash(nonce_2, contract_address, storage_slot, 1, A) respectively.
But currently when we try to recover the nonce for a decrypted note, we always find the first match. Which means if those two notes are in the same tx, the note processor will assign them the same nonce and end up saving two identical notes to the db.
The purpose of adding a nonce to the note hash is to make each note unique. Allowing notes in a storage slot (a Set or a Singleton) to have the same preimages. So that nullifying
note{ value: 1, asset: A }won't invalidatedup_note{ value: 1, asset: A }because they will have different nonces, so their nullifier will behash(nonce_1, contract_address, storage_slot, 1, A)andhash(nonce_2, contract_address, storage_slot, 1, A)respectively.But currently when we try to recover the nonce for a decrypted note, we always find the first match. Which means if those two notes are in the same tx, the note processor will assign them the same nonce and end up saving two identical notes to the db.