referrerpolicy=no-referrer-when-downgrade

frame_benchmarking_cli/storage/
mod.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18pub mod cmd;
19pub mod read;
20pub mod template;
21pub mod write;
22
23pub use cmd::StorageCmd;
24
25/// Empirically, the maximum batch size for block validation should be no more than 10,000.
26/// Bigger sizes may cause problems with runtime memory allocation.
27pub(crate) const MAX_BATCH_SIZE_FOR_BLOCK_VALIDATION: usize = 10_000;
28
29pub(crate) fn get_wasm_module() -> Box<dyn sc_executor_common::wasm_runtime::WasmModule> {
30	let blob = sc_executor_common::runtime_blob::RuntimeBlob::uncompress_if_needed(
31		frame_storage_access_test_runtime::WASM_BINARY
32			.expect("You need to build the WASM binaries to run the benchmark!"),
33	)
34	.expect("Failed to create runtime blob");
35	let config = sc_executor_wasmtime::Config {
36		allow_missing_func_imports: true,
37		cache_path: None,
38		semantics: sc_executor_wasmtime::Semantics {
39			heap_alloc_strategy: sc_executor_common::wasm_runtime::HeapAllocStrategy::Dynamic {
40				maximum_pages: Some(4096),
41			},
42			instantiation_strategy: sc_executor::WasmtimeInstantiationStrategy::PoolingCopyOnWrite,
43			deterministic_stack_limit: None,
44			canonicalize_nans: false,
45			parallel_compilation: false,
46			wasm_multi_value: false,
47			wasm_bulk_memory: false,
48			wasm_reference_types: false,
49			wasm_simd: false,
50		},
51	};
52
53	Box::new(
54		sc_executor_wasmtime::create_runtime::<sp_io::SubstrateHostFunctions>(blob, config)
55			.expect("Unable to create wasm module."),
56	)
57}