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
Previously, burning zero units of a nonexisting asset would write that to the storage. This PR ignores zero-amount burns, although it still produces a receipt for them. In addition, when all assets with some specific have been burned, clears the slot instead of writing a zero there.
Checklist
Breaking changes are clearly marked as such in the PR description and changelog
New behavior is reflected in tests
If performance characteristic of an instruction change, update gas costs as well or make a follow-up PR for that
The specification matches the implemented behavior (link update PR if changes are needed)
Before requesting review
I have reviewed the code myself
I have created follow-up issues caused by this PR and linked them here
High Risk
Changes BURN state transition semantics for contract asset balances (skips storage writes for zero-amount burns and deletes entries when balance hits zero), which can affect persisted state and consensus/state roots. Risk is concentrated in opcode execution and storage mutation paths.
Overview
Minimizes contract asset storage writes during the BURN opcode by skipping balance updates when amount == 0 while still emitting a burn receipt.
When a burn brings an asset balance to exactly zero, it now removes the (contract, asset_id) entry instead of persisting a 0 value, via a new ContractsAssetsStorage::contract_asset_id_balance_remove helper. Tests were updated to treat missing balances as 0 (unwrap_or(0)).
Reviewed by Cursor Bugbot for commit bfc2246. Bugbot is set up for automated code reviews on this repo. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, burning zero units of a nonexisting asset would write that to the storage. This PR ignores zero-amount burns, although it still produces a receipt for them. In addition, when all assets with some specific have been burned, clears the slot instead of writing a zero there.
Checklist
Before requesting review