-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[pallet-revive] Only fund new accounts with ED #10233
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 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9510ca2
not charging ED in ctor if account already has enough balance
0xRVE c4bd019
removed offchain_worker from dev-node
0xRVE 16a21b2
added test for double ed in case of create2
0xRVE be12d99
remove log
0xRVE ebef496
Update from github-actions[bot] running command 'prdoc --audience run…
github-actions[bot] db0e9c7
format
0xRVE efdcf9a
cleanup
0xRVE 898b6c1
review comment
0xRVE fd99bec
small fix
0xRVE 4d1123a
Merge branch 'master' into rve/scc-179-axelar-balance-mismatch
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,7 @@ | ||
| title: not charging ED in ctor if account already has enough balance | ||
| doc: | ||
| - audience: Runtime Dev | ||
| description: fixes https://github.com/paritytech/contract-issues/issues/179 | ||
| crates: | ||
| - name: pallet-revive | ||
| bump: patch |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5133,3 +5133,36 @@ fn consume_all_gas_works() { | |
| ); | ||
| }); | ||
| } | ||
|
|
||
| #[test] | ||
| fn existential_deposit_shall_not_charged_twice() { | ||
| let (code, code_hash) = compile_module("dummy").unwrap(); | ||
|
|
||
| let salt = [0u8; 32]; | ||
|
|
||
| ExtBuilder::default().build().execute_with(|| { | ||
| let _ = <Test as Config>::Currency::set_balance(&ALICE, 100_000_000_000_000); | ||
| let callee_addr = create2( | ||
| &ALICE_ADDR, | ||
| &code, | ||
| &[0u8; 0], // empty input | ||
| &salt, | ||
| ); | ||
| let callee_account = <Test as Config>::AddressMapper::to_account_id(&callee_addr); | ||
|
|
||
| // first send funds to callee_addr | ||
| let result = builder::bare_call(callee_addr).native_value(666_000_000_000).build(); | ||
| assert_ok!(result.result); | ||
| assert_eq!(get_balance(&callee_account), 666_000_000_000 + Contracts::min_balance()); | ||
|
||
|
|
||
| // then deploy contract to callee_addr using create2 | ||
| let Contract { addr, .. } = builder::bare_instantiate(Code::Upload(code.clone())) | ||
| .salt(Some(salt)) | ||
| .build_and_unwrap_contract(); | ||
|
|
||
| assert_eq!(callee_addr, addr); | ||
|
|
||
| // check we charged ed only 1 time | ||
| assert_eq!(get_balance(&callee_account), 666_000_000_000 + Contracts::min_balance()); | ||
| }); | ||
| } | ||
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.
we should just use
frame_system::Pallet::<T>::account_exists(&account_id), since an account exits only if it has e.dwe do that in a few other places in the pallet