Skip to content

Conversation

sekisamu
Copy link
Contributor

fix issue: paritytech/contract-issues#141

Corrects the condition for minting a new currency unit when transferring dust. The condition was incorrectly checking to_info.dust.saturating_add(dust) >= plank which could lead to unexpected minting behavior. It now correctly checks if to_info.dust >= plank before minting.

Corrects the condition for minting a new currency unit when transferring dust.
The condition was incorrectly checking `to_info.dust.saturating_add(dust) >= plank` which
could lead to unexpected minting behavior. It now correctly checks if `to_info.dust >= plank`
before minting.

Adds a test case to ensure the correct behavior when the receiver's dust balance is less than one plank.
Comment on lines 1451 to +1453
transfer_dust::<T>(&mut from_info, &mut to_info, dust)?;

if to_info.dust.saturating_add(dust) >= plank {
if to_info.dust >= plank {
Copy link
Member

@athei athei Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the bug here is that we are adding it twice as it was already added in transfer_dust?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, exactly.

Copy link
Member

@athei athei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this.

@athei
Copy link
Member

athei commented Jul 31, 2025

/cmd fmt

@athei athei added the T7-smart_contracts This PR/Issue is related to smart contracts. label Jul 31, 2025
Copy link
Contributor

Command "fmt" has failed ❌! See logs here

@athei
Copy link
Member

athei commented Aug 1, 2025

You don't allow changes by maintainers. Please run cargo +nightly fmt locally and add a PRdoc.

- add prdoc
- run `cargo +nightly fmt`
@github-actions github-actions bot requested review from athei and pgherveou August 3, 2025 04:10
Copy link
Contributor

github-actions bot commented Aug 3, 2025

Review required! Latest push from author must always be reviewed

@sekisamu
Copy link
Contributor Author

sekisamu commented Aug 3, 2025

You don't allow changes by maintainers. Please run cargo +nightly fmt locally and add a PRdoc.

@athei updated.

Copy link
Member

@athei athei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Unfortunately, we need to approve after every change for external contributors. cc @pgherveou

@athei athei added this pull request to the merge queue Aug 4, 2025
Merged via the queue into paritytech:master with commit 59fb2e7 Aug 4, 2025
240 of 245 checks passed
athei pushed a commit that referenced this pull request Aug 14, 2025
fix issue: paritytech/contract-issues#141

Corrects the condition for minting a new currency unit when transferring
dust. The condition was incorrectly checking
`to_info.dust.saturating_add(dust) >= plank` which could lead to
unexpected minting behavior. It now correctly checks if `to_info.dust >=
plank` before minting.
@athei athei mentioned this pull request Aug 14, 2025
athei added a commit that referenced this pull request Aug 15, 2025
- #9112
- #9101
- #9416
- #9357
- #9441
- #9267

Those are all the changes we want to get onto the next Kusama release.
The new gas mapping and EVM backend will not make it.

---------

Co-authored-by: PG Herveou <[email protected]>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Francisco Aguirre <[email protected]>
Co-authored-by: Oliver Tale-Yazdi <[email protected]>
Co-authored-by: sekiseki <[email protected]>
Co-authored-by: Michael Müller <[email protected]>
alvicsam pushed a commit that referenced this pull request Oct 17, 2025
fix issue: paritytech/contract-issues#141

Corrects the condition for minting a new currency unit when transferring
dust. The condition was incorrectly checking
`to_info.dust.saturating_add(dust) >= plank` which could lead to
unexpected minting behavior. It now correctly checks if `to_info.dust >=
plank` before minting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T7-smart_contracts This PR/Issue is related to smart contracts.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants