namada icon indicating copy to clipboard operation
namada copied to clipboard

Masp client invalidates spent notes

Open grarco opened this issue 1 year ago • 0 comments

Describe your changes

Modifies the client to invalidate the spend notes after their usage, to allow the construction of consecutive valid masp transactions (mandatory requirement for fee unshielding and masp tx with the same source key).

The ShieldedContext can now be in two states: Confirmed or Speculative. A Confirmed state is one coming from a sync operation, meaning that the data in the context comes from transaction that have been accepted by the protocol. When calling gen_shielded_transfer, instead, the context invalidates any spend notes used and transitions to a Speculative state (i.e. not that is not guaranteed to che coherent with the protocol). The speculative state is stored in a separate file and is always reload instead of the confirmed one when present. When calling fetch the Confirmed state is reloaded from disk to discard any possible speculative state and the fetch operates on this. Finally, when saving the newly synced confirmed state to storage, the file of the speculative state is removed if found.

Improved previous integration tests to be more strict and added new ones.

Indicate on which release or other PRs this topic is based on

#2458 rebased on v0.31.1

Checklist before merging to draft

  • [x] I have added a changelog
  • [x] Git history is in acceptable state

grarco avatar Feb 06 '24 15:02 grarco