-
Notifications
You must be signed in to change notification settings - Fork 1.2k
revive: Fix dust & child contract calls #10192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
77eda1a
add test
pgherveou cff6c37
fix ignore transfer to self
pgherveou 948a809
Update from github-actions[bot] running command 'prdoc --audience run…
github-actions[bot] a4f6970
Merge branch 'master' into pg/issue-211
pgherveou fbcdeec
fix conflict
pgherveou fac4618
fix
pgherveou 0d74778
fail with transferFailed when account.value < value regardless of to
pgherveou 5b90b78
nit
pgherveou 1d0d91d
add tests
pgherveou 959c7d2
one more test case
pgherveou 3d0628b
extra test
pgherveou b8bed4f
Merge branch 'master' into pg/issue-211
pgherveou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| title: 'revive: Fix dust & child contract calls' | ||
| doc: | ||
| - audience: Runtime Dev | ||
| description: |- | ||
| When transferring to self we should just return early as it's a noop. | ||
| Not doing so cause bug in `transfer_with_dust` | ||
|
|
||
| as we do | ||
| ``` | ||
| from.dust -= from.dust | ||
| to.dust += to.dust | ||
| ``` | ||
|
|
||
| We end up with a value of dust - planck (that we burnt from to create dust amount) on the account | ||
|
|
||
| fix https://github.com/paritytech/contract-issues/issues/211 | ||
| crates: | ||
| - name: pallet-revive-fixtures | ||
| bump: patch | ||
| - name: pallet-revive | ||
| bump: patch |
7 changes: 7 additions & 0 deletions
7
substrate/frame/revive/fixtures/contracts/call_self_with_dust.sol
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| contract CallSelfWithDust { | ||
| function f() external payable {} | ||
|
|
||
| function call() public payable { | ||
| this.f{value: 10}(); | ||
| } | ||
| } | ||
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
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To check, if
fhere contained some code, this code will be executed and the only thing that we have aNOOPfor is just the transfers, is that correct?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this breaks the EVM semantics.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes we short-circuit the logic of the transfer_with_dust fn when from = to or value = 0 the rest does not change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah right we should always check that from.balance > amount is that what you are suggesting @xermicus
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind. I saw that there is already a zero balance check in the transfer function and short-circuited that this is implemented in logic further up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current implementation is wrong i believe we should ensure that the account has enough balance to do the transfer even if to == from
Will patch it when i het back
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah the logic is quite complex with dust. Maybe needs some more tests for these corner cases.