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

Token: privateToPublic + changePartialNote #10286

Open
Tracked by #10225
nventuro opened this issue Nov 28, 2024 · 0 comments
Open
Tracked by #10225

Token: privateToPublic + changePartialNote #10286

nventuro opened this issue Nov 28, 2024 · 0 comments
Labels
C-aztec.nr Component: Aztec smart contract framework S-needs-discussion Status: Still needs more discussion before work can start. team-fairies Nico's team

Comments

@nventuro
Copy link
Contributor

nventuro commented Nov 28, 2024

#10153 showcased a new token interaction pattern: transferring tokens from private into a contract that later returns some change in public, requiring a partial note. The contract needs to wait until public execution because during private it lacks some of the information required (e.g. current balances for the AMM, or gas used for an FPC).

The desired behavior is achieved by making two calls:

Token::at(token_in)
  .transfer_to_public(sender, context.this_address(), amount_in_max, nonce)
  .call(&mut context);

let change_token_in_hiding_point_slot =
  Token::at(token_in).prepare_private_balance_increase(sender, sender).call(&mut context);

This is subpar because each call is relatively expensive, not just due to arg packing etc but also because of the extra kernel iteration. We should consider implementing a variant of transfer that also returns a partial note, which would reduce the gate count significantly, at the expense of a larger API surface. An alternative would be to add a paramater to transfer which indicates whether to produce a partial note, but this would increase the gate count of regular transfers, which is likely undesirable.

@nventuro nventuro added C-aztec.nr Component: Aztec smart contract framework team-fairies Nico's team S-needs-discussion Status: Still needs more discussion before work can start. labels Nov 28, 2024
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 S-needs-discussion Status: Still needs more discussion before work can start. team-fairies Nico's team
Projects
None yet
Development

No branches or pull requests

1 participant