mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
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:
@@ -295,10 +295,7 @@ pub fn testnet_genesis(
|
||||
const STASH: Balance = ENDOWMENT / 1000;
|
||||
|
||||
GenesisConfig {
|
||||
system: SystemConfig {
|
||||
code: wasm_binary_unwrap().to_vec(),
|
||||
changes_trie_config: Default::default(),
|
||||
},
|
||||
system: SystemConfig { code: wasm_binary_unwrap().to_vec() },
|
||||
balances: BalancesConfig {
|
||||
balances: endowed_accounts.iter().cloned().map(|x| (x, ENDOWMENT)).collect(),
|
||||
},
|
||||
|
||||
@@ -338,7 +338,6 @@ pub fn new_full_base(
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
spawn_handle: task_manager.spawn_handle(),
|
||||
import_queue,
|
||||
on_demand: None,
|
||||
block_announce_validator_builder: None,
|
||||
warp_sync: Some(warp_sync),
|
||||
})?;
|
||||
@@ -369,8 +368,6 @@ pub fn new_full_base(
|
||||
rpc_extensions_builder: Box::new(rpc_extensions_builder),
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
task_manager: &mut task_manager,
|
||||
on_demand: None,
|
||||
remote_blockchain: None,
|
||||
system_rpc_tx,
|
||||
telemetry: telemetry.as_mut(),
|
||||
})?;
|
||||
@@ -542,7 +539,7 @@ mod tests {
|
||||
use sc_service_test::TestNetNode;
|
||||
use sc_transaction_pool_api::{ChainEvent, MaintainedTransactionPool};
|
||||
use sp_consensus::{BlockOrigin, Environment, Proposer};
|
||||
use sp_core::{crypto::Pair as CryptoPair, Public, H256};
|
||||
use sp_core::{crypto::Pair as CryptoPair, Public};
|
||||
use sp_inherents::InherentDataProvider;
|
||||
use sp_keyring::AccountKeyring;
|
||||
use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr};
|
||||
@@ -621,7 +618,7 @@ mod tests {
|
||||
None,
|
||||
);
|
||||
|
||||
let mut digest = Digest::<H256>::default();
|
||||
let mut digest = Digest::default();
|
||||
|
||||
// even though there's only one authority some slots might be empty,
|
||||
// so we must keep trying the next slots until we can claim one.
|
||||
|
||||
@@ -53,7 +53,7 @@ const SPEC_VERSION: u32 = node_runtime::VERSION.spec_version;
|
||||
|
||||
const HEAP_PAGES: u64 = 20;
|
||||
|
||||
type TestExternalities<H> = CoreTestExternalities<H, u64>;
|
||||
type TestExternalities<H> = CoreTestExternalities<H>;
|
||||
|
||||
#[derive(Debug)]
|
||||
enum ExecutionMethod {
|
||||
@@ -188,7 +188,7 @@ fn bench_execute_block(c: &mut Criterion) {
|
||||
|
||||
for strategy in execution_methods {
|
||||
group.bench_function(format!("{:?}", strategy), |b| {
|
||||
let genesis_config = node_testing::genesis::config(false, Some(compact_code_unwrap()));
|
||||
let genesis_config = node_testing::genesis::config(Some(compact_code_unwrap()));
|
||||
let (use_native, wasm_method) = match strategy {
|
||||
ExecutionMethod::Native => (true, WasmExecutionMethod::Interpreted),
|
||||
ExecutionMethod::Wasm(wasm_method) => (false, wasm_method),
|
||||
|
||||
@@ -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::{
|
||||
|
||||
@@ -81,7 +81,7 @@ pub const SPEC_VERSION: u32 = node_runtime::VERSION.spec_version;
|
||||
|
||||
pub const TRANSACTION_VERSION: u32 = node_runtime::VERSION.transaction_version;
|
||||
|
||||
pub type TestExternalities<H> = CoreTestExternalities<H, u64>;
|
||||
pub type TestExternalities<H> = CoreTestExternalities<H>;
|
||||
|
||||
pub fn sign(xt: CheckedExtrinsic) -> UncheckedExtrinsic {
|
||||
node_testing::keyring::sign(xt, SPEC_VERSION, TRANSACTION_VERSION, GENESIS_HASH)
|
||||
@@ -123,14 +123,11 @@ pub fn executor_call<
|
||||
executor().call::<R, NC>(&mut t, &runtime_code, method, data, use_native, native_call)
|
||||
}
|
||||
|
||||
pub fn new_test_ext(code: &[u8], support_changes_trie: bool) -> TestExternalities<BlakeTwo256> {
|
||||
let mut ext = TestExternalities::new_with_code(
|
||||
pub fn new_test_ext(code: &[u8]) -> TestExternalities<BlakeTwo256> {
|
||||
let ext = TestExternalities::new_with_code(
|
||||
code,
|
||||
node_testing::genesis::config(support_changes_trie, Some(code))
|
||||
.build_storage()
|
||||
.unwrap(),
|
||||
node_testing::genesis::config(Some(code)).build_storage().unwrap(),
|
||||
);
|
||||
ext.changes_trie_storage().insert(0, GENESIS_HASH.into(), Default::default());
|
||||
ext
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ use self::common::{sign, *};
|
||||
|
||||
#[test]
|
||||
fn fee_multiplier_increases_and_decreases_on_big_weight() {
|
||||
let mut t = new_test_ext(compact_code_unwrap(), false);
|
||||
let mut t = new_test_ext(compact_code_unwrap());
|
||||
|
||||
// initial fee multiplier must be one.
|
||||
let mut prev_multiplier = Multiplier::one();
|
||||
@@ -45,7 +45,7 @@ fn fee_multiplier_increases_and_decreases_on_big_weight() {
|
||||
assert_eq!(TransactionPayment::next_fee_multiplier(), prev_multiplier);
|
||||
});
|
||||
|
||||
let mut tt = new_test_ext(compact_code_unwrap(), false);
|
||||
let mut tt = new_test_ext(compact_code_unwrap());
|
||||
|
||||
let time1 = 42 * 1000;
|
||||
// big one in terms of weight.
|
||||
@@ -151,7 +151,7 @@ fn transaction_fee_is_correct() {
|
||||
// - 1 MILLICENTS in substrate node.
|
||||
// - 1 milli-dot based on current polkadot runtime.
|
||||
// (this baed on assigning 0.1 CENT to the cheapest tx with `weight = 100`)
|
||||
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()), new_account_info(100));
|
||||
t.insert(<frame_system::Account<Runtime>>::hashed_key_for(bob()), new_account_info(10));
|
||||
t.insert(
|
||||
@@ -226,9 +226,9 @@ fn block_weight_capacity_report() {
|
||||
use node_primitives::Index;
|
||||
|
||||
// execution ext.
|
||||
let mut t = new_test_ext(compact_code_unwrap(), false);
|
||||
let mut t = new_test_ext(compact_code_unwrap());
|
||||
// setup ext.
|
||||
let mut tt = new_test_ext(compact_code_unwrap(), false);
|
||||
let mut tt = new_test_ext(compact_code_unwrap());
|
||||
|
||||
let factor = 50;
|
||||
let mut time = 10;
|
||||
@@ -303,9 +303,9 @@ fn block_length_capacity_report() {
|
||||
use node_primitives::Index;
|
||||
|
||||
// execution ext.
|
||||
let mut t = new_test_ext(compact_code_unwrap(), false);
|
||||
let mut t = new_test_ext(compact_code_unwrap());
|
||||
// setup ext.
|
||||
let mut tt = new_test_ext(compact_code_unwrap(), false);
|
||||
let mut tt = new_test_ext(compact_code_unwrap());
|
||||
|
||||
let factor = 256 * 1024;
|
||||
let mut time = 10;
|
||||
|
||||
@@ -28,7 +28,7 @@ use self::common::*;
|
||||
|
||||
#[test]
|
||||
fn should_submit_unsigned_transaction() {
|
||||
let mut t = new_test_ext(compact_code_unwrap(), false);
|
||||
let mut t = new_test_ext(compact_code_unwrap());
|
||||
let (pool, state) = TestTransactionPoolExt::new();
|
||||
t.register_extension(TransactionPoolExt::new(pool));
|
||||
|
||||
@@ -56,7 +56,7 @@ const PHRASE: &str = "news slush supreme milk chapter athlete soap sausage put c
|
||||
|
||||
#[test]
|
||||
fn should_submit_signed_transaction() {
|
||||
let mut t = new_test_ext(compact_code_unwrap(), false);
|
||||
let mut t = new_test_ext(compact_code_unwrap());
|
||||
let (pool, state) = TestTransactionPoolExt::new();
|
||||
t.register_extension(TransactionPoolExt::new(pool));
|
||||
|
||||
@@ -99,7 +99,7 @@ fn should_submit_signed_transaction() {
|
||||
|
||||
#[test]
|
||||
fn should_submit_signed_twice_from_the_same_account() {
|
||||
let mut t = new_test_ext(compact_code_unwrap(), false);
|
||||
let mut t = new_test_ext(compact_code_unwrap());
|
||||
let (pool, state) = TestTransactionPoolExt::new();
|
||||
t.register_extension(TransactionPoolExt::new(pool));
|
||||
|
||||
@@ -156,7 +156,7 @@ fn should_submit_signed_twice_from_the_same_account() {
|
||||
|
||||
#[test]
|
||||
fn should_submit_signed_twice_from_all_accounts() {
|
||||
let mut t = new_test_ext(compact_code_unwrap(), false);
|
||||
let mut t = new_test_ext(compact_code_unwrap());
|
||||
let (pool, state) = TestTransactionPoolExt::new();
|
||||
t.register_extension(TransactionPoolExt::new(pool));
|
||||
|
||||
@@ -220,7 +220,7 @@ fn submitted_transaction_should_be_valid() {
|
||||
transaction_validity::{TransactionSource, TransactionTag},
|
||||
};
|
||||
|
||||
let mut t = new_test_ext(compact_code_unwrap(), false);
|
||||
let mut t = new_test_ext(compact_code_unwrap());
|
||||
let (pool, state) = TestTransactionPoolExt::new();
|
||||
t.register_extension(TransactionPoolExt::new(pool));
|
||||
|
||||
@@ -249,7 +249,7 @@ fn submitted_transaction_should_be_valid() {
|
||||
// check that transaction is valid, but reset environment storage,
|
||||
// since CreateTransaction increments the nonce
|
||||
let tx0 = state.read().transactions[0].clone();
|
||||
let mut t = new_test_ext(compact_code_unwrap(), false);
|
||||
let mut t = new_test_ext(compact_code_unwrap());
|
||||
t.execute_with(|| {
|
||||
let source = TransactionSource::External;
|
||||
let extrinsic = UncheckedExtrinsic::decode(&mut &*tx0).unwrap();
|
||||
|
||||
@@ -57,7 +57,7 @@ pub type Hash = sp_core::H256;
|
||||
pub type Timestamp = u64;
|
||||
|
||||
/// Digest item type.
|
||||
pub type DigestItem = generic::DigestItem<Hash>;
|
||||
pub type DigestItem = generic::DigestItem;
|
||||
/// Header type.
|
||||
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
|
||||
/// Block type.
|
||||
|
||||
@@ -51,18 +51,6 @@ use sp_consensus::SelectChain;
|
||||
use sp_consensus_babe::BabeApi;
|
||||
use sp_keystore::SyncCryptoStorePtr;
|
||||
|
||||
/// Light client extra dependencies.
|
||||
pub struct LightDeps<C, F, P> {
|
||||
/// The client instance to use.
|
||||
pub client: Arc<C>,
|
||||
/// Transaction pool instance.
|
||||
pub pool: Arc<P>,
|
||||
/// Remote access to the blockchain (async).
|
||||
pub remote_blockchain: Arc<dyn sc_client_api::light::RemoteBlockchain<Block>>,
|
||||
/// Fetcher instance.
|
||||
pub fetcher: Arc<F>,
|
||||
}
|
||||
|
||||
/// Extra dependencies for BABE.
|
||||
pub struct BabeDeps {
|
||||
/// BABE protocol config.
|
||||
@@ -183,26 +171,3 @@ where
|
||||
|
||||
Ok(io)
|
||||
}
|
||||
|
||||
/// Instantiate all Light RPC extensions.
|
||||
pub fn create_light<C, P, M, F>(deps: LightDeps<C, F, P>) -> jsonrpc_core::IoHandler<M>
|
||||
where
|
||||
C: sp_blockchain::HeaderBackend<Block>,
|
||||
C: Send + Sync + 'static,
|
||||
F: sc_client_api::light::Fetcher<Block> + 'static,
|
||||
P: TransactionPool + 'static,
|
||||
M: jsonrpc_core::Metadata + Default,
|
||||
{
|
||||
use substrate_frame_rpc_system::{LightSystem, SystemApi};
|
||||
|
||||
let LightDeps { client, pool, remote_blockchain, fetcher } = deps;
|
||||
let mut io = jsonrpc_core::IoHandler::default();
|
||||
io.extend_with(SystemApi::<Hash, AccountId, Index>::to_delegate(LightSystem::new(
|
||||
client,
|
||||
remote_blockchain,
|
||||
fetcher,
|
||||
pool,
|
||||
)));
|
||||
|
||||
io
|
||||
}
|
||||
|
||||
@@ -591,7 +591,6 @@ impl BenchKeyring {
|
||||
/// Generate genesis with accounts from this keyring endowed with some balance.
|
||||
pub fn generate_genesis(&self) -> node_runtime::GenesisConfig {
|
||||
crate::genesis::config_endowed(
|
||||
false,
|
||||
Some(node_runtime::wasm_binary_unwrap()),
|
||||
self.collect_account_ids(),
|
||||
)
|
||||
|
||||
@@ -42,13 +42,11 @@ pub type Transaction = sc_client_api::backend::TransactionFor<Backend, node_prim
|
||||
|
||||
/// Genesis configuration parameters for `TestClient`.
|
||||
#[derive(Default)]
|
||||
pub struct GenesisParameters {
|
||||
support_changes_trie: bool,
|
||||
}
|
||||
pub struct GenesisParameters;
|
||||
|
||||
impl substrate_test_client::GenesisInit for GenesisParameters {
|
||||
fn genesis_storage(&self) -> Storage {
|
||||
crate::genesis::config(self.support_changes_trie, None).build_storage().unwrap()
|
||||
crate::genesis::config(None).build_storage().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,22 +24,17 @@ use node_runtime::{
|
||||
GenesisConfig, GrandpaConfig, IndicesConfig, SessionConfig, SocietyConfig, StakerStatus,
|
||||
StakingConfig, SystemConfig, BABE_GENESIS_EPOCH_CONFIG,
|
||||
};
|
||||
use sp_core::ChangesTrieConfiguration;
|
||||
use sp_keyring::{Ed25519Keyring, Sr25519Keyring};
|
||||
use sp_runtime::Perbill;
|
||||
|
||||
/// Create genesis runtime configuration for tests.
|
||||
pub fn config(support_changes_trie: bool, code: Option<&[u8]>) -> GenesisConfig {
|
||||
config_endowed(support_changes_trie, code, Default::default())
|
||||
pub fn config(code: Option<&[u8]>) -> GenesisConfig {
|
||||
config_endowed(code, Default::default())
|
||||
}
|
||||
|
||||
/// Create genesis runtime configuration for tests with some extra
|
||||
/// endowed accounts.
|
||||
pub fn config_endowed(
|
||||
support_changes_trie: bool,
|
||||
code: Option<&[u8]>,
|
||||
extra_endowed: Vec<AccountId>,
|
||||
) -> GenesisConfig {
|
||||
pub fn config_endowed(code: Option<&[u8]>, extra_endowed: Vec<AccountId>) -> GenesisConfig {
|
||||
let mut endowed = vec![
|
||||
(alice(), 111 * DOLLARS),
|
||||
(bob(), 100 * DOLLARS),
|
||||
@@ -53,11 +48,6 @@ pub fn config_endowed(
|
||||
|
||||
GenesisConfig {
|
||||
system: SystemConfig {
|
||||
changes_trie_config: if support_changes_trie {
|
||||
Some(ChangesTrieConfiguration { digest_interval: 2, digest_levels: 2 })
|
||||
} else {
|
||||
None
|
||||
},
|
||||
code: code.map(|x| x.to_vec()).unwrap_or_else(|| wasm_binary_unwrap().to_vec()),
|
||||
},
|
||||
indices: IndicesConfig { indices: vec![] },
|
||||
|
||||
Reference in New Issue
Block a user