You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The TokenContract.transfer() function produces two account updates: one for the sender of the funds and one for the receiver.
Rather than creating the AccountUpdates from scratch, it can accept a from and toAccountUpdate. In this case, it overwrites the balanceChange field to the amount being transferred.
However, from and to may have non-zero balanceChanges when passed to transfer(). Setting balanceChange overrides whatever the previous value was.
Impact
If users pass an AccountUpdate with an existing balance change to this function generated by another application, they may experience difficult-to-debug prover errors due to the mutation.
Recommendation
Use AccountUpdate.balance.addInPlace() and AccountUpdate.balance.subInPlace() instead of overwriting balances. Note that, if from and to have existing balances, this will require they are negatives of each other
The text was updated successfully, but these errors were encountered:
kantp
added
audit
Addresses findings from the audit
warning
o1js
Issues that require changes in o1js itself, rather than in this repository
labels
Jul 2, 2024
The
TokenContract.transfer()
function produces two account updates: one for the sender of the funds and one for the receiver.Rather than creating the
AccountUpdate
s from scratch, it can accept afrom
andto
AccountUpdate
. In this case, it overwrites thebalanceChange
field to theamount
being transferred.However,
from
andto
may have non-zerobalanceChange
s when passed totransfer()
. SettingbalanceChange
overrides whatever the previous value was.Impact
If users pass an
AccountUpdate
with an existing balance change to this function generated by another application, they may experience difficult-to-debug prover errors due to the mutation.Recommendation
Use
AccountUpdate.balance.addInPlace()
andAccountUpdate.balance.subInPlace()
instead of overwriting balances. Note that, iffrom
andto
have existing balances, this will require they are negatives of each otherThe text was updated successfully, but these errors were encountered: