Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit c45c1cb

Browse files
authored
Kill the light client, CHTs and change tries. (#10080)
* Remove light client, change tries and CHTs * Update tests * fmt * Restore changes_root * Fixed benches * Cargo fmt * fmt * fmt
1 parent 5d22361 commit c45c1cb

File tree

141 files changed

+534
-17809
lines changed

Some content is hidden

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

141 files changed

+534
-17809
lines changed

Cargo.lock

-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ members = [
4242
"client/finality-grandpa",
4343
"client/informant",
4444
"client/keystore",
45-
"client/light",
4645
"client/network",
4746
"client/network-gossip",
4847
"client/network/test",

bin/node-template/node/src/chain_spec.rs

-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ fn testnet_genesis(
134134
system: SystemConfig {
135135
// Add Wasm runtime to storage.
136136
code: wasm_binary.to_vec(),
137-
changes_trie_config: Default::default(),
138137
},
139138
balances: BalancesConfig {
140139
// Configure endowed accounts with initial balance of 1 << 60.

bin/node-template/node/src/service.rs

-3
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
194194
transaction_pool: transaction_pool.clone(),
195195
spawn_handle: task_manager.spawn_handle(),
196196
import_queue,
197-
on_demand: None,
198197
block_announce_validator_builder: None,
199198
warp_sync: Some(warp_sync),
200199
})?;
@@ -234,8 +233,6 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
234233
task_manager: &mut task_manager,
235234
transaction_pool: transaction_pool.clone(),
236235
rpc_extensions_builder,
237-
on_demand: None,
238-
remote_blockchain: None,
239236
backend,
240237
system_rpc_tx,
241238
config,

bin/node/cli/src/chain_spec.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,7 @@ pub fn testnet_genesis(
295295
const STASH: Balance = ENDOWMENT / 1000;
296296

297297
GenesisConfig {
298-
system: SystemConfig {
299-
code: wasm_binary_unwrap().to_vec(),
300-
changes_trie_config: Default::default(),
301-
},
298+
system: SystemConfig { code: wasm_binary_unwrap().to_vec() },
302299
balances: BalancesConfig {
303300
balances: endowed_accounts.iter().cloned().map(|x| (x, ENDOWMENT)).collect(),
304301
},

bin/node/cli/src/service.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,6 @@ pub fn new_full_base(
338338
transaction_pool: transaction_pool.clone(),
339339
spawn_handle: task_manager.spawn_handle(),
340340
import_queue,
341-
on_demand: None,
342341
block_announce_validator_builder: None,
343342
warp_sync: Some(warp_sync),
344343
})?;
@@ -369,8 +368,6 @@ pub fn new_full_base(
369368
rpc_extensions_builder: Box::new(rpc_extensions_builder),
370369
transaction_pool: transaction_pool.clone(),
371370
task_manager: &mut task_manager,
372-
on_demand: None,
373-
remote_blockchain: None,
374371
system_rpc_tx,
375372
telemetry: telemetry.as_mut(),
376373
})?;
@@ -542,7 +539,7 @@ mod tests {
542539
use sc_service_test::TestNetNode;
543540
use sc_transaction_pool_api::{ChainEvent, MaintainedTransactionPool};
544541
use sp_consensus::{BlockOrigin, Environment, Proposer};
545-
use sp_core::{crypto::Pair as CryptoPair, Public, H256};
542+
use sp_core::{crypto::Pair as CryptoPair, Public};
546543
use sp_inherents::InherentDataProvider;
547544
use sp_keyring::AccountKeyring;
548545
use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr};
@@ -621,7 +618,7 @@ mod tests {
621618
None,
622619
);
623620

624-
let mut digest = Digest::<H256>::default();
621+
let mut digest = Digest::default();
625622

626623
// even though there's only one authority some slots might be empty,
627624
// so we must keep trying the next slots until we can claim one.

bin/node/executor/benches/bench.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const SPEC_VERSION: u32 = node_runtime::VERSION.spec_version;
5353

5454
const HEAP_PAGES: u64 = 20;
5555

56-
type TestExternalities<H> = CoreTestExternalities<H, u64>;
56+
type TestExternalities<H> = CoreTestExternalities<H>;
5757

5858
#[derive(Debug)]
5959
enum ExecutionMethod {
@@ -188,7 +188,7 @@ fn bench_execute_block(c: &mut Criterion) {
188188

189189
for strategy in execution_methods {
190190
group.bench_function(format!("{:?}", strategy), |b| {
191-
let genesis_config = node_testing::genesis::config(false, Some(compact_code_unwrap()));
191+
let genesis_config = node_testing::genesis::config(Some(compact_code_unwrap()));
192192
let (use_native, wasm_method) = match strategy {
193193
ExecutionMethod::Native => (true, WasmExecutionMethod::Interpreted),
194194
ExecutionMethod::Wasm(wasm_method) => (false, wasm_method),

bin/node/executor/tests/basic.rs

+17-55
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use sp_runtime::{
2929
use node_primitives::{Balance, Hash};
3030
use node_runtime::{
3131
constants::{currency::*, time::SLOT_DURATION},
32-
Balances, Block, Call, CheckedExtrinsic, Event, Header, Runtime, System, TransactionPayment,
32+
Balances, Call, CheckedExtrinsic, Event, Header, Runtime, System, TransactionPayment,
3333
UncheckedExtrinsic,
3434
};
3535
use node_testing::keyring::*;
@@ -78,7 +78,7 @@ fn set_heap_pages<E: Externalities>(ext: &mut E, heap_pages: u64) {
7878
fn changes_trie_block() -> (Vec<u8>, Hash) {
7979
let time = 42 * 1000;
8080
construct_block(
81-
&mut new_test_ext(compact_code_unwrap(), true),
81+
&mut new_test_ext(compact_code_unwrap()),
8282
1,
8383
GENESIS_HASH.into(),
8484
vec![
@@ -102,7 +102,7 @@ fn changes_trie_block() -> (Vec<u8>, Hash) {
102102
/// are not guaranteed to be deterministic) and to ensure that the correct state is propagated
103103
/// from block1's execution to block2 to derive the correct storage_root.
104104
fn blocks() -> ((Vec<u8>, Hash), (Vec<u8>, Hash)) {
105-
let mut t = new_test_ext(compact_code_unwrap(), false);
105+
let mut t = new_test_ext(compact_code_unwrap());
106106
let time1 = 42 * 1000;
107107
let block1 = construct_block(
108108
&mut t,
@@ -160,7 +160,7 @@ fn blocks() -> ((Vec<u8>, Hash), (Vec<u8>, Hash)) {
160160

161161
fn block_with_size(time: u64, nonce: u32, size: usize) -> (Vec<u8>, Hash) {
162162
construct_block(
163-
&mut new_test_ext(compact_code_unwrap(), false),
163+
&mut new_test_ext(compact_code_unwrap()),
164164
1,
165165
GENESIS_HASH.into(),
166166
vec![
@@ -179,7 +179,7 @@ fn block_with_size(time: u64, nonce: u32, size: usize) -> (Vec<u8>, Hash) {
179179

180180
#[test]
181181
fn panic_execution_with_foreign_code_gives_error() {
182-
let mut t = new_test_ext(bloaty_code_unwrap(), false);
182+
let mut t = new_test_ext(bloaty_code_unwrap());
183183
t.insert(
184184
<frame_system::Account<Runtime>>::hashed_key_for(alice()),
185185
(69u128, 0u32, 0u128, 0u128, 0u128).encode(),
@@ -211,7 +211,7 @@ fn panic_execution_with_foreign_code_gives_error() {
211211

212212
#[test]
213213
fn bad_extrinsic_with_native_equivalent_code_gives_error() {
214-
let mut t = new_test_ext(compact_code_unwrap(), false);
214+
let mut t = new_test_ext(compact_code_unwrap());
215215
t.insert(
216216
<frame_system::Account<Runtime>>::hashed_key_for(alice()),
217217
(0u32, 0u32, 0u32, 69u128, 0u128, 0u128, 0u128).encode(),
@@ -243,7 +243,7 @@ fn bad_extrinsic_with_native_equivalent_code_gives_error() {
243243

244244
#[test]
245245
fn successful_execution_with_native_equivalent_code_gives_ok() {
246-
let mut t = new_test_ext(compact_code_unwrap(), false);
246+
let mut t = new_test_ext(compact_code_unwrap());
247247
t.insert(
248248
<frame_system::Account<Runtime>>::hashed_key_for(alice()),
249249
AccountInfo::<<Runtime as frame_system::Config>::Index, _> {
@@ -296,7 +296,7 @@ fn successful_execution_with_native_equivalent_code_gives_ok() {
296296

297297
#[test]
298298
fn successful_execution_with_foreign_code_gives_ok() {
299-
let mut t = new_test_ext(bloaty_code_unwrap(), false);
299+
let mut t = new_test_ext(bloaty_code_unwrap());
300300
t.insert(
301301
<frame_system::Account<Runtime>>::hashed_key_for(alice()),
302302
AccountInfo::<<Runtime as frame_system::Config>::Index, _> {
@@ -349,7 +349,7 @@ fn successful_execution_with_foreign_code_gives_ok() {
349349

350350
#[test]
351351
fn full_native_block_import_works() {
352-
let mut t = new_test_ext(compact_code_unwrap(), false);
352+
let mut t = new_test_ext(compact_code_unwrap());
353353

354354
let (block1, block2) = blocks();
355355

@@ -529,7 +529,7 @@ fn full_native_block_import_works() {
529529

530530
#[test]
531531
fn full_wasm_block_import_works() {
532-
let mut t = new_test_ext(compact_code_unwrap(), false);
532+
let mut t = new_test_ext(compact_code_unwrap());
533533

534534
let (block1, block2) = blocks();
535535

@@ -679,7 +679,7 @@ fn deploying_wasm_contract_should_work() {
679679

680680
let time = 42 * 1000;
681681
let b = construct_block(
682-
&mut new_test_ext(compact_code_unwrap(), false),
682+
&mut new_test_ext(compact_code_unwrap()),
683683
1,
684684
GENESIS_HASH.into(),
685685
vec![
@@ -712,7 +712,7 @@ fn deploying_wasm_contract_should_work() {
712712
(time / SLOT_DURATION).into(),
713713
);
714714

715-
let mut t = new_test_ext(compact_code_unwrap(), false);
715+
let mut t = new_test_ext(compact_code_unwrap());
716716

717717
executor_call::<NeverNativeValue, fn() -> _>(&mut t, "Core_execute_block", &b.0, false, None)
718718
.0
@@ -727,7 +727,7 @@ fn deploying_wasm_contract_should_work() {
727727

728728
#[test]
729729
fn wasm_big_block_import_fails() {
730-
let mut t = new_test_ext(compact_code_unwrap(), false);
730+
let mut t = new_test_ext(compact_code_unwrap());
731731

732732
set_heap_pages(&mut t.ext(), 4);
733733

@@ -744,7 +744,7 @@ fn wasm_big_block_import_fails() {
744744

745745
#[test]
746746
fn native_big_block_import_succeeds() {
747-
let mut t = new_test_ext(compact_code_unwrap(), false);
747+
let mut t = new_test_ext(compact_code_unwrap());
748748

749749
executor_call::<NeverNativeValue, fn() -> _>(
750750
&mut t,
@@ -759,7 +759,7 @@ fn native_big_block_import_succeeds() {
759759

760760
#[test]
761761
fn native_big_block_import_fails_on_fallback() {
762-
let mut t = new_test_ext(compact_code_unwrap(), false);
762+
let mut t = new_test_ext(compact_code_unwrap());
763763

764764
// We set the heap pages to 8 because we know that should give an OOM in WASM with the given
765765
// block.
@@ -778,7 +778,7 @@ fn native_big_block_import_fails_on_fallback() {
778778

779779
#[test]
780780
fn panic_execution_gives_error() {
781-
let mut t = new_test_ext(bloaty_code_unwrap(), false);
781+
let mut t = new_test_ext(bloaty_code_unwrap());
782782
t.insert(
783783
<frame_system::Account<Runtime>>::hashed_key_for(alice()),
784784
AccountInfo::<<Runtime as frame_system::Config>::Index, _> {
@@ -815,7 +815,7 @@ fn panic_execution_gives_error() {
815815

816816
#[test]
817817
fn successful_execution_gives_ok() {
818-
let mut t = new_test_ext(compact_code_unwrap(), false);
818+
let mut t = new_test_ext(compact_code_unwrap());
819819
t.insert(
820820
<frame_system::Account<Runtime>>::hashed_key_for(alice()),
821821
AccountInfo::<<Runtime as frame_system::Config>::Index, _> {
@@ -874,44 +874,6 @@ fn successful_execution_gives_ok() {
874874
});
875875
}
876876

877-
#[test]
878-
fn full_native_block_import_works_with_changes_trie() {
879-
let block1 = changes_trie_block();
880-
let block_data = block1.0;
881-
let block = Block::decode(&mut &block_data[..]).unwrap();
882-
883-
let mut t = new_test_ext(compact_code_unwrap(), true);
884-
executor_call::<NeverNativeValue, fn() -> _>(
885-
&mut t,
886-
"Core_execute_block",
887-
&block.encode(),
888-
true,
889-
None,
890-
)
891-
.0
892-
.unwrap();
893-
894-
assert!(t.ext().storage_changes_root(&GENESIS_HASH).unwrap().is_some());
895-
}
896-
897-
#[test]
898-
fn full_wasm_block_import_works_with_changes_trie() {
899-
let block1 = changes_trie_block();
900-
901-
let mut t = new_test_ext(compact_code_unwrap(), true);
902-
executor_call::<NeverNativeValue, fn() -> _>(
903-
&mut t,
904-
"Core_execute_block",
905-
&block1.0,
906-
false,
907-
None,
908-
)
909-
.0
910-
.unwrap();
911-
912-
assert!(t.ext().storage_changes_root(&GENESIS_HASH).unwrap().is_some());
913-
}
914-
915877
#[test]
916878
fn should_import_block_with_test_client() {
917879
use node_testing::client::{

bin/node/executor/tests/common.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub const SPEC_VERSION: u32 = node_runtime::VERSION.spec_version;
8181

8282
pub const TRANSACTION_VERSION: u32 = node_runtime::VERSION.transaction_version;
8383

84-
pub type TestExternalities<H> = CoreTestExternalities<H, u64>;
84+
pub type TestExternalities<H> = CoreTestExternalities<H>;
8585

8686
pub fn sign(xt: CheckedExtrinsic) -> UncheckedExtrinsic {
8787
node_testing::keyring::sign(xt, SPEC_VERSION, TRANSACTION_VERSION, GENESIS_HASH)
@@ -123,14 +123,11 @@ pub fn executor_call<
123123
executor().call::<R, NC>(&mut t, &runtime_code, method, data, use_native, native_call)
124124
}
125125

126-
pub fn new_test_ext(code: &[u8], support_changes_trie: bool) -> TestExternalities<BlakeTwo256> {
127-
let mut ext = TestExternalities::new_with_code(
126+
pub fn new_test_ext(code: &[u8]) -> TestExternalities<BlakeTwo256> {
127+
let ext = TestExternalities::new_with_code(
128128
code,
129-
node_testing::genesis::config(support_changes_trie, Some(code))
130-
.build_storage()
131-
.unwrap(),
129+
node_testing::genesis::config(Some(code)).build_storage().unwrap(),
132130
);
133-
ext.changes_trie_storage().insert(0, GENESIS_HASH.into(), Default::default());
134131
ext
135132
}
136133

0 commit comments

Comments
 (0)