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
This commit is contained in:
Arkadiy Paronyan
2021-11-12 14:15:01 +01:00
committed by GitHub
parent 112b7dac47
commit 4cbbf0cf43
141 changed files with 532 additions and 17807 deletions
+17 -55
View File
@@ -29,7 +29,7 @@ use sp_runtime::{
use node_primitives::{Balance, Hash};
use node_runtime::{
constants::{currency::*, time::SLOT_DURATION},
Balances, Block, Call, CheckedExtrinsic, Event, Header, Runtime, System, TransactionPayment,
Balances, Call, CheckedExtrinsic, Event, Header, Runtime, System, TransactionPayment,
UncheckedExtrinsic,
};
use node_testing::keyring::*;
@@ -78,7 +78,7 @@ fn set_heap_pages<E: Externalities>(ext: &mut E, heap_pages: u64) {
fn changes_trie_block() -> (Vec<u8>, Hash) {
let time = 42 * 1000;
construct_block(
&mut new_test_ext(compact_code_unwrap(), true),
&mut new_test_ext(compact_code_unwrap()),
1,
GENESIS_HASH.into(),
vec![
@@ -102,7 +102,7 @@ fn changes_trie_block() -> (Vec<u8>, Hash) {
/// are not guaranteed to be deterministic) and to ensure that the correct state is propagated
/// from block1's execution to block2 to derive the correct storage_root.
fn blocks() -> ((Vec<u8>, Hash), (Vec<u8>, Hash)) {
let mut t = new_test_ext(compact_code_unwrap(), false);
let mut t = new_test_ext(compact_code_unwrap());
let time1 = 42 * 1000;
let block1 = construct_block(
&mut t,
@@ -160,7 +160,7 @@ fn blocks() -> ((Vec<u8>, Hash), (Vec<u8>, Hash)) {
fn block_with_size(time: u64, nonce: u32, size: usize) -> (Vec<u8>, Hash) {
construct_block(
&mut new_test_ext(compact_code_unwrap(), false),
&mut new_test_ext(compact_code_unwrap()),
1,
GENESIS_HASH.into(),
vec![
@@ -179,7 +179,7 @@ fn block_with_size(time: u64, nonce: u32, size: usize) -> (Vec<u8>, Hash) {
#[test]
fn panic_execution_with_foreign_code_gives_error() {
let mut t = new_test_ext(bloaty_code_unwrap(), false);
let mut t = new_test_ext(bloaty_code_unwrap());
t.insert(
<frame_system::Account<Runtime>>::hashed_key_for(alice()),
(69u128, 0u32, 0u128, 0u128, 0u128).encode(),
@@ -211,7 +211,7 @@ fn panic_execution_with_foreign_code_gives_error() {
#[test]
fn bad_extrinsic_with_native_equivalent_code_gives_error() {
let mut t = new_test_ext(compact_code_unwrap(), false);
let mut t = new_test_ext(compact_code_unwrap());
t.insert(
<frame_system::Account<Runtime>>::hashed_key_for(alice()),
(0u32, 0u32, 0u32, 69u128, 0u128, 0u128, 0u128).encode(),
@@ -243,7 +243,7 @@ fn bad_extrinsic_with_native_equivalent_code_gives_error() {
#[test]
fn successful_execution_with_native_equivalent_code_gives_ok() {
let mut t = new_test_ext(compact_code_unwrap(), false);
let mut t = new_test_ext(compact_code_unwrap());
t.insert(
<frame_system::Account<Runtime>>::hashed_key_for(alice()),
AccountInfo::<<Runtime as frame_system::Config>::Index, _> {
@@ -296,7 +296,7 @@ fn successful_execution_with_native_equivalent_code_gives_ok() {
#[test]
fn successful_execution_with_foreign_code_gives_ok() {
let mut t = new_test_ext(bloaty_code_unwrap(), false);
let mut t = new_test_ext(bloaty_code_unwrap());
t.insert(
<frame_system::Account<Runtime>>::hashed_key_for(alice()),
AccountInfo::<<Runtime as frame_system::Config>::Index, _> {
@@ -349,7 +349,7 @@ fn successful_execution_with_foreign_code_gives_ok() {
#[test]
fn full_native_block_import_works() {
let mut t = new_test_ext(compact_code_unwrap(), false);
let mut t = new_test_ext(compact_code_unwrap());
let (block1, block2) = blocks();
@@ -529,7 +529,7 @@ fn full_native_block_import_works() {
#[test]
fn full_wasm_block_import_works() {
let mut t = new_test_ext(compact_code_unwrap(), false);
let mut t = new_test_ext(compact_code_unwrap());
let (block1, block2) = blocks();
@@ -679,7 +679,7 @@ fn deploying_wasm_contract_should_work() {
let time = 42 * 1000;
let b = construct_block(
&mut new_test_ext(compact_code_unwrap(), false),
&mut new_test_ext(compact_code_unwrap()),
1,
GENESIS_HASH.into(),
vec![
@@ -712,7 +712,7 @@ fn deploying_wasm_contract_should_work() {
(time / SLOT_DURATION).into(),
);
let mut t = new_test_ext(compact_code_unwrap(), false);
let mut t = new_test_ext(compact_code_unwrap());
executor_call::<NeverNativeValue, fn() -> _>(&mut t, "Core_execute_block", &b.0, false, None)
.0
@@ -727,7 +727,7 @@ fn deploying_wasm_contract_should_work() {
#[test]
fn wasm_big_block_import_fails() {
let mut t = new_test_ext(compact_code_unwrap(), false);
let mut t = new_test_ext(compact_code_unwrap());
set_heap_pages(&mut t.ext(), 4);
@@ -744,7 +744,7 @@ fn wasm_big_block_import_fails() {
#[test]
fn native_big_block_import_succeeds() {
let mut t = new_test_ext(compact_code_unwrap(), false);
let mut t = new_test_ext(compact_code_unwrap());
executor_call::<NeverNativeValue, fn() -> _>(
&mut t,
@@ -759,7 +759,7 @@ fn native_big_block_import_succeeds() {
#[test]
fn native_big_block_import_fails_on_fallback() {
let mut t = new_test_ext(compact_code_unwrap(), false);
let mut t = new_test_ext(compact_code_unwrap());
// We set the heap pages to 8 because we know that should give an OOM in WASM with the given
// block.
@@ -778,7 +778,7 @@ fn native_big_block_import_fails_on_fallback() {
#[test]
fn panic_execution_gives_error() {
let mut t = new_test_ext(bloaty_code_unwrap(), false);
let mut t = new_test_ext(bloaty_code_unwrap());
t.insert(
<frame_system::Account<Runtime>>::hashed_key_for(alice()),
AccountInfo::<<Runtime as frame_system::Config>::Index, _> {
@@ -815,7 +815,7 @@ fn panic_execution_gives_error() {
#[test]
fn successful_execution_gives_ok() {
let mut t = new_test_ext(compact_code_unwrap(), false);
let mut t = new_test_ext(compact_code_unwrap());
t.insert(
<frame_system::Account<Runtime>>::hashed_key_for(alice()),
AccountInfo::<<Runtime as frame_system::Config>::Index, _> {
@@ -874,44 +874,6 @@ fn successful_execution_gives_ok() {
});
}
#[test]
fn full_native_block_import_works_with_changes_trie() {
let block1 = changes_trie_block();
let block_data = block1.0;
let block = Block::decode(&mut &block_data[..]).unwrap();
let mut t = new_test_ext(compact_code_unwrap(), true);
executor_call::<NeverNativeValue, fn() -> _>(
&mut t,
"Core_execute_block",
&block.encode(),
true,
None,
)
.0
.unwrap();
assert!(t.ext().storage_changes_root(&GENESIS_HASH).unwrap().is_some());
}
#[test]
fn full_wasm_block_import_works_with_changes_trie() {
let block1 = changes_trie_block();
let mut t = new_test_ext(compact_code_unwrap(), true);
executor_call::<NeverNativeValue, fn() -> _>(
&mut t,
"Core_execute_block",
&block1.0,
false,
None,
)
.0
.unwrap();
assert!(t.ext().storage_changes_root(&GENESIS_HASH).unwrap().is_some());
}
#[test]
fn should_import_block_with_test_client() {
use node_testing::client::{