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

New oracle add_note api. #1635

Closed
LeilaWang opened this issue Aug 17, 2023 · 0 comments
Closed

New oracle add_note api. #1635

LeilaWang opened this issue Aug 17, 2023 · 0 comments
Labels
C-aztec.nr Component: Aztec smart contract framework

Comments

@LeilaWang
Copy link
Collaborator

LeilaWang commented Aug 17, 2023

We should let the contracts define what can be stored.

Sometimes the information of notes are shared offline. And the users should be able to either:

  • Call a contract function with the preimage:
fn redeem_a_token(preimage, nonce) {
  let note = Note::new_with_nonce(preimage, nonce);
  set.assert_contains_and_remove(note);
  increase_balance();
}
  • Or add the preimage to the oracle db:
unconstrained claim_a_token(preimage, nonce) {
  let note = Note::new_with_nonce(preimage, nonce);
  oracle.add_note(state_var.storage_slot, note);
}

Because the contract developers will know what data would be shared offline, it makes sense for them to provide the proper apis accordingly.

This should replace the previous proposal of adding addPreimage(contract_address, storage_slot, preimage) api to the AztecRPCServer. Which will require the users to provide the storage_slot. And might not be obvious what's been added.

@github-project-automation github-project-automation bot moved this to Todo in A3 Aug 17, 2023
LeilaWang added a commit that referenced this issue Aug 18, 2023
The previous `Set.assert_contains` can be misleading.
A note in a Set might have been destroyed. But this could still generate
a valid proof:

```rust
set.assert_contains(note);
do_something();
```

However, the ability to check if a note hash exists is useful. Because a
note might not be shared via log. In which case, the user gets the
preimage offline, and should be able to call a contract function with
the preimage to claim a note or do something.

Before we add the [feature](#1635) properly, we can use
`assert_contains_and_remove` to check that the note hash does exist, and
destroy the note right after, to prevent developers making wrong
assumption.

# Checklist:
Remove the checklist to signal you've completed it. Enable auto-merge if
the PR is ready to merge.
- [ ] If the pull request requires a cryptography review (e.g.
cryptographic algorithm implementations) I have added the 'crypto' tag.
- [ ] I have reviewed my diff in github, line by line and removed
unexpected formatting changes, testing logs, or commented-out code.
- [ ] Every change is related to the PR description.
- [ ] I have
[linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
this pull request to relevant issues (if any exist).
@iAmMichaelConnor iAmMichaelConnor added the C-aztec.nr Component: Aztec smart contract framework label Aug 20, 2023
@github-project-automation github-project-automation bot moved this from Todo to Done in A3 Oct 10, 2023
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

2 participants