Skip to content

Do not write to storage when minting zero tokens - #1009

Merged
Dentosal merged 6 commits into
masterfrom
dento/mint-storage-cleanup
Apr 29, 2026
Merged

Dentosal merged 6 commits into
masterfrom
dento/mint-storage-cleanup

Conversation

@Dentosal

@Dentosal Dentosal commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #1008.

Previously, minting zero units of a nonexisting asset would write that to the storage. This PR ignores zero-amount mints, although it still produces a receipt for them. The change should be mostly inconsequential, but makes the behavior consistent with burn opcode.

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

@Dentosal Dentosal self-assigned this Apr 29, 2026
@cursor

cursor Bot commented Apr 29, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Small, well-scoped change to mint balance mutation semantics for the amount == 0 edge case, with test coverage updates and no new data paths.

Overview
Updates the mint opcode handling to skip reading/updating contract asset balances and charging new-storage gas when amount == 0, preventing creation of zero-balance entries for previously-nonexistent assets while still emitting a Receipt::Mint.

Adjusts mint-related tests to treat missing balances as 0 (via unwrap_or(0)) to reflect the new no-write behavior, and adds a changelog entry documenting the semantic change.

Reviewed by Cursor Bugbot for commit 5f17257. Bugbot is set up for automated code reviews on this repo. Configure here.

@Dentosal
Dentosal marked this pull request as ready for review April 29, 2026 12:22
@Dentosal
Dentosal added this pull request to the merge queue Apr 29, 2026
Merged via the queue into master with commit 5e76477 Apr 29, 2026
45 checks passed
@Dentosal
Dentosal deleted the dento/mint-storage-cleanup branch April 29, 2026 13:13
@github-actions github-actions Bot mentioned this pull request Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants