Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: singleton redesign #3753

Closed
Tracked by #4128
LHerskind opened this issue Dec 20, 2023 · 3 comments
Closed
Tracked by #4128

refactor: singleton redesign #3753

LHerskind opened this issue Dec 20, 2023 · 3 comments
Labels
C-aztec.nr Component: Aztec smart contract framework

Comments

@LHerskind
Copy link
Contributor

Singletons currently have get_note and replace functions that both emit nullifiers to ensure that the old value is "up to date". This means that updating the note such that the value at t' is dependent on the value at t is quite a mess.

A description and pointers to where this is encountered can be seen in #3689.

@sirasistant
Copy link
Contributor

One option is to make replace like this:

 pub fn replace<Env>(
        self,
        new_note_builder: fn[Env](old_note: Note) -> Note, // closure
        broadcast: bool,
    ) -> Note {

So it can still be safe and be used like

let new_note = singleton.replace(|old_note| {
  assert(old_note.foo == 27);
  MyNewNote::new(old_note.whatever)
}, true);

@LHerskind
Copy link
Contributor Author

Referring to #3123 for completeness

@rahul-kothari rahul-kothari added the C-aztec.nr Component: Aztec smart contract framework label Jan 3, 2024
@LHerskind
Copy link
Contributor Author

This have been covered through the ordering and squashing work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-aztec.nr Component: Aztec smart contract framework
Projects
Archived in project
Development

No branches or pull requests

3 participants