Skip to content

Commit 1d12c70

Browse files
gavofyorkshawntabrizignunicorn
authored andcommitted
Lazy reaping (paritytech#4895)
* Squash and rebase from gav-lazy-reaping * Bump version * Bump runtime again * Docs. * Remove old functions * Update frame/balances/src/lib.rs Co-Authored-By: Shawn Tabrizi <[email protected]> * Update frame/contracts/src/lib.rs Co-Authored-By: Shawn Tabrizi <[email protected]> * Warnings * Bump runtime version * Update frame/democracy/src/lib.rs Co-Authored-By: Shawn Tabrizi <[email protected]> * Update frame/system/src/lib.rs * Clean up OnReapAccount * Use frame_support debug * Bump spec * Renames and fix * Fix * Fix rename * Fix * Increase time for test Co-authored-by: Shawn Tabrizi <[email protected]> Co-authored-by: Benjamin Kampmann <[email protected]>
1 parent 3957d97 commit 1d12c70

File tree

62 files changed

+597
-280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+597
-280
lines changed

bin/node-template/pallets/template/src/mock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl system::Trait for Test {
4141
type ModuleToIndex = ();
4242
type AccountData = ();
4343
type OnNewAccount = ();
44-
type OnReapAccount = ();
44+
type OnKilledAccount = ();
4545
}
4646
impl Trait for Test {
4747
type Event = ();

bin/node-template/runtime/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl system::Trait for Runtime {
164164
/// What to do if a new account is created.
165165
type OnNewAccount = ();
166166
/// What to do if an account is fully reaped from the system.
167-
type OnReapAccount = Balances;
167+
type OnKilledAccount = ();
168168
/// The data to be stored in an account.
169169
type AccountData = balances::AccountData<Balance>;
170170
}

bin/node/cli/src/chain_spec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ pub fn testnet_genesis(
243243
}),
244244
pallet_session: Some(SessionConfig {
245245
keys: initial_authorities.iter().map(|x| {
246-
(x.0.clone(), session_keys(x.2.clone(), x.3.clone(), x.4.clone(), x.5.clone()))
246+
(x.0.clone(), x.0.clone(), session_keys(x.2.clone(), x.3.clone(), x.4.clone(), x.5.clone()))
247247
}).collect::<Vec<_>>(),
248248
}),
249249
pallet_staking: Some(StakingConfig {

bin/node/cli/tests/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,5 @@ pub fn run_command_for_a_while(base_path: &Path, dev: bool) {
6060

6161
// Stop the process
6262
kill(Pid::from_raw(cmd.id().try_into().unwrap()), SIGINT).unwrap();
63-
assert!(wait_for(&mut cmd, 20).map(|x| x.success()).unwrap_or_default());
63+
assert!(wait_for(&mut cmd, 40).map(|x| x.success()).unwrap_or_default());
6464
}

bin/node/executor/tests/basic.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ fn panic_execution_with_foreign_code_gives_error() {
164164
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(BLOATY_CODE, Storage {
165165
top: map![
166166
<frame_system::Account<Runtime>>::hashed_key_for(alice()) => {
167-
(69u128, 0u128, 0u128, 0u128).encode()
167+
(69u128, 0u8, 0u128, 0u128, 0u128).encode()
168168
},
169169
<pallet_balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
170170
69_u128.encode()
@@ -200,7 +200,7 @@ fn bad_extrinsic_with_native_equivalent_code_gives_error() {
200200
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(COMPACT_CODE, Storage {
201201
top: map![
202202
<frame_system::Account<Runtime>>::hashed_key_for(alice()) => {
203-
(0u32, 69u128, 0u128, 0u128, 0u128).encode()
203+
(0u32, 0u8, 69u128, 0u128, 0u128, 0u128).encode()
204204
},
205205
<pallet_balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
206206
69_u128.encode()
@@ -236,7 +236,7 @@ fn successful_execution_with_native_equivalent_code_gives_ok() {
236236
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(COMPACT_CODE, Storage {
237237
top: map![
238238
<frame_system::Account<Runtime>>::hashed_key_for(alice()) => {
239-
(0u32, 111 * DOLLARS, 0u128, 0u128, 0u128).encode()
239+
(0u32, 0u8, 111 * DOLLARS, 0u128, 0u128, 0u128).encode()
240240
},
241241
<pallet_balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
242242
(111 * DOLLARS).encode()
@@ -278,7 +278,7 @@ fn successful_execution_with_foreign_code_gives_ok() {
278278
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(BLOATY_CODE, Storage {
279279
top: map![
280280
<frame_system::Account<Runtime>>::hashed_key_for(alice()) => {
281-
(0u32, 111 * DOLLARS, 0u128, 0u128, 0u128).encode()
281+
(0u32, 0u8, 111 * DOLLARS, 0u128, 0u128, 0u128).encode()
282282
},
283283
<pallet_balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
284284
(111 * DOLLARS).encode()
@@ -734,7 +734,7 @@ fn successful_execution_gives_ok() {
734734
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(COMPACT_CODE, Storage {
735735
top: map![
736736
<frame_system::Account<Runtime>>::hashed_key_for(alice()) => {
737-
(0u32, 111 * DOLLARS, 0u128, 0u128, 0u128).encode()
737+
(0u32, 0u8, 111 * DOLLARS, 0u128, 0u128, 0u128).encode()
738738
},
739739
<pallet_balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
740740
(111 * DOLLARS).encode()

bin/node/executor/tests/fees.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ fn transaction_fee_is_correct_ultimate() {
139139
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(COMPACT_CODE, Storage {
140140
top: map![
141141
<frame_system::Account<Runtime>>::hashed_key_for(alice()) => {
142-
(0u32, 100 * DOLLARS, 0 * DOLLARS, 0 * DOLLARS, 0 * DOLLARS).encode()
142+
(0u32, 0u8, 100 * DOLLARS, 0 * DOLLARS, 0 * DOLLARS, 0 * DOLLARS).encode()
143143
},
144144
<frame_system::Account<Runtime>>::hashed_key_for(bob()) => {
145-
(0u32, 10 * DOLLARS, 0 * DOLLARS, 0 * DOLLARS, 0 * DOLLARS).encode()
145+
(0u32, 0u8, 10 * DOLLARS, 0 * DOLLARS, 0 * DOLLARS, 0 * DOLLARS).encode()
146146
},
147147
<pallet_balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
148148
(110 * DOLLARS).encode()

bin/node/executor/tests/submit_transaction.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,9 @@ fn submitted_transaction_should_be_valid() {
167167
// add balance to the account
168168
let author = extrinsic.signature.clone().unwrap().0;
169169
let address = Indices::lookup(author).unwrap();
170-
let account = pallet_balances::AccountData { free: 5_000_000_000_000, ..Default::default() };
171-
<frame_system::Account<Runtime>>::insert(&address, (0u32, account));
170+
let data = pallet_balances::AccountData { free: 5_000_000_000_000, ..Default::default() };
171+
let account = frame_system::AccountInfo { nonce: 0u32, refcount: 0u8, data };
172+
<frame_system::Account<Runtime>>::insert(&address, account);
172173

173174
// check validity
174175
let res = Executive::validate_transaction(extrinsic);

bin/node/runtime/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
8181
// and set impl_version to 0. If only runtime
8282
// implementation changes and behavior does not, then leave spec_version as
8383
// is and increment impl_version.
84-
spec_version: 224,
85-
impl_version: 2,
84+
spec_version: 225,
85+
impl_version: 0,
8686
apis: RUNTIME_API_VERSIONS,
8787
};
8888

@@ -131,7 +131,7 @@ impl frame_system::Trait for Runtime {
131131
type ModuleToIndex = ModuleToIndex;
132132
type AccountData = pallet_balances::AccountData<Balance>;
133133
type OnNewAccount = ();
134-
type OnReapAccount = (Balances, Staking, Contracts, Session, Recovery);
134+
type OnKilledAccount = ();
135135
}
136136

137137
parameter_types! {

bin/node/testing/src/genesis.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ pub fn config_endowed(
6969
}),
7070
pallet_session: Some(SessionConfig {
7171
keys: vec![
72-
(alice(), to_session_keys(
72+
(dave(), alice(), to_session_keys(
7373
&Ed25519Keyring::Alice,
7474
&Sr25519Keyring::Alice,
7575
)),
76-
(bob(), to_session_keys(
76+
(eve(), bob(), to_session_keys(
7777
&Ed25519Keyring::Bob,
7878
&Sr25519Keyring::Bob,
7979
)),
80-
(charlie(), to_session_keys(
80+
(ferdie(), charlie(), to_session_keys(
8181
&Ed25519Keyring::Charlie,
8282
&Sr25519Keyring::Charlie,
8383
)),

frame/assets/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ mod tests {
295295
type ModuleToIndex = ();
296296
type AccountData = ();
297297
type OnNewAccount = ();
298-
type OnReapAccount = ();
298+
type OnKilledAccount = ();
299299
}
300300
impl Trait for Test {
301301
type Event = ();

0 commit comments

Comments
 (0)