Self-sufficient account ref-counting (#8221)

* Self-sufficient account ref-counting

* Fixes

* Update frame/system/src/lib.rs

Co-authored-by: Jaco Greeff <jacogr@gmail.com>

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Update frame/system/src/lib.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Update frame/system/src/lib.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Update frame/system/src/lib.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* fix build

* Update frame/system/src/lib.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
Gavin Wood
2021-03-03 22:28:05 +01:00
committed by GitHub
parent 274e7f0652
commit e993f884fc
7 changed files with 260 additions and 53 deletions
+29 -8
View File
@@ -26,7 +26,7 @@ use sp_runtime::{
traits::Hash as HashT,
transaction_validity::InvalidTransaction,
};
use frame_system::{self, EventRecord, Phase};
use frame_system::{self, EventRecord, Phase, AccountInfo};
use node_runtime::{
Header, Block, UncheckedExtrinsic, CheckedExtrinsic, Call, Runtime, Balances,
@@ -227,11 +227,17 @@ fn successful_execution_with_native_equivalent_code_gives_ok() {
let mut t = new_test_ext(compact_code_unwrap(), false);
t.insert(
<frame_system::Account<Runtime>>::hashed_key_for(alice()),
(0u32, 0u32, 0u32, 111 * DOLLARS, 0u128, 0u128, 0u128).encode()
AccountInfo::<<Runtime as frame_system::Config>::Index, _> {
data: (111 * DOLLARS, 0u128, 0u128, 0u128),
.. Default::default()
}.encode(),
);
t.insert(
<frame_system::Account<Runtime>>::hashed_key_for(bob()),
(0u32, 0u32, 0u32, 0 * DOLLARS, 0u128, 0u128, 0u128).encode()
AccountInfo::<<Runtime as frame_system::Config>::Index, _> {
data: (0 * DOLLARS, 0u128, 0u128, 0u128),
.. Default::default()
}.encode(),
);
t.insert(
<pallet_balances::TotalIssuance<Runtime>>::hashed_key().to_vec(),
@@ -270,11 +276,17 @@ fn successful_execution_with_foreign_code_gives_ok() {
let mut t = new_test_ext(bloaty_code_unwrap(), false);
t.insert(
<frame_system::Account<Runtime>>::hashed_key_for(alice()),
(0u32, 0u32, 0u32, 111 * DOLLARS, 0u128, 0u128, 0u128).encode()
AccountInfo::<<Runtime as frame_system::Config>::Index, _> {
data: (111 * DOLLARS, 0u128, 0u128, 0u128),
.. Default::default()
}.encode(),
);
t.insert(
<frame_system::Account<Runtime>>::hashed_key_for(bob()),
(0u32, 0u32, 0u32, 0 * DOLLARS, 0u128, 0u128, 0u128).encode()
AccountInfo::<<Runtime as frame_system::Config>::Index, _> {
data: (0 * DOLLARS, 0u128, 0u128, 0u128),
.. Default::default()
}.encode(),
);
t.insert(
<pallet_balances::TotalIssuance<Runtime>>::hashed_key().to_vec(),
@@ -704,7 +716,10 @@ fn panic_execution_gives_error() {
let mut t = new_test_ext(bloaty_code_unwrap(), false);
t.insert(
<frame_system::Account<Runtime>>::hashed_key_for(alice()),
(0u32, 0u32, 0u32, 0 * DOLLARS, 0u128, 0u128, 0u128).encode()
AccountInfo::<<Runtime as frame_system::Config>::Index, _> {
data: (0 * DOLLARS, 0u128, 0u128, 0u128),
.. Default::default()
}.encode(),
);
t.insert(<pallet_balances::TotalIssuance<Runtime>>::hashed_key().to_vec(), 0_u128.encode());
t.insert(<frame_system::BlockHash<Runtime>>::hashed_key_for(0), vec![0u8; 32]);
@@ -733,11 +748,17 @@ fn successful_execution_gives_ok() {
let mut t = new_test_ext(compact_code_unwrap(), false);
t.insert(
<frame_system::Account<Runtime>>::hashed_key_for(alice()),
(0u32, 0u32, 0u32, 111 * DOLLARS, 0u128, 0u128, 0u128).encode()
AccountInfo::<<Runtime as frame_system::Config>::Index, _> {
data: (111 * DOLLARS, 0u128, 0u128, 0u128),
.. Default::default()
}.encode(),
);
t.insert(
<frame_system::Account<Runtime>>::hashed_key_for(bob()),
(0u32, 0u32, 0u32, 0 * DOLLARS, 0u128, 0u128, 0u128).encode()
AccountInfo::<<Runtime as frame_system::Config>::Index, _> {
data: (0 * DOLLARS, 0u128, 0u128, 0u128),
.. Default::default()
}.encode(),
);
t.insert(
<pallet_balances::TotalIssuance<Runtime>>::hashed_key().to_vec(),