AleoNet / snarkVM

A Virtual Machine for Zero-Knowledge Executions
https://snarkvm.org
Apache License 2.0
1.08k stars 1.5k forks source link

No need to create a credits with microcredits =0 #2445

Closed 0xsaya closed 4 months ago

0xsaya commented 6 months ago

When a user transfers all of their microcredits to the "to" address, in addition to creating a credits record for the "to" address, a credits record with microcredits set to 0 is also created for the "from" address. Generating a large number of credits records with microcredits set to 0 can cause wastage of network resources.

https://github.com/AleoHQ/snarkVM/blob/1485bdd42a6156e09dc09066b262302df9252bf0/synthesizer/program/src/resources/credits.aleo#L792

damons commented 5 months ago

Need to know the impact of the "wastage." Still, wouldn't block mainnet for this.

Can you demonstrate the impact of the waste?

raychu86 commented 4 months ago

These 0 balance records are necessary to preserve privacy. A transfer_private call should always have the same number of inputs and outputs in order to reveal as little information about the amounts/data as possible, even if a record is considered "wasted" due to a balance of 0.

I am closing this due because this is a desired property of our system.