From ab8a41403b8b46905cf2db8b57fe6a35bfeb1534 Mon Sep 17 00:00:00 2001 From: Vadim Smirnov Date: Sun, 29 Oct 2023 18:18:22 +0800 Subject: [PATCH 1/2] fix(frame-benchmarking-cli): Pass heap_pages param to WasmExecutor --- .../benchmarking-cli/src/pallet/command.rs | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs index 99f77866f8d0..e98a19a2036b 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs @@ -25,7 +25,9 @@ use frame_support::traits::StorageInfo; use linked_hash_map::LinkedHashMap; use sc_cli::{execution_method_from_cli, CliConfiguration, Result, SharedParams}; use sc_client_db::BenchmarkingState; -use sc_executor::WasmExecutor; +use sc_executor::{ + HeapAllocStrategy, NativeElseWasmExecutor, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY, +}; use sc_service::Configuration; use serde::Serialize; use sp_core::{ @@ -219,15 +221,21 @@ impl PalletCmd { let method = execution_method_from_cli(self.wasm_method, self.wasmtime_instantiation_strategy); - let executor = WasmExecutor::<( - sp_io::SubstrateHostFunctions, - frame_benchmarking::benchmarking::HostFunctions, - ExtraHostFunctions, - )>::builder() - .with_execution_method(method) - .with_max_runtime_instances(2) - .with_runtime_cache_size(2) - .build(); + let heap_pages = + self.heap_pages + .map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |p| HeapAllocStrategy::Static { + extra_pages: p as _, + }); + + let executor = NativeElseWasmExecutor::::new_with_wasm_executor( + WasmExecutor::builder() + .with_execution_method(method) + .with_onchain_heap_alloc_strategy(heap_pages) + .with_offchain_heap_alloc_strategy(heap_pages) + .with_max_runtime_instances(2) + .with_runtime_cache_size(2) + .build(), + ); let extensions = || -> Extensions { let mut extensions = Extensions::default(); From 43ead0d417bed51e2ba1c768bb45ef2d070455ed Mon Sep 17 00:00:00 2001 From: Vadim Smirnov Date: Sun, 29 Oct 2023 18:39:32 +0800 Subject: [PATCH 2/2] update from master --- .../benchmarking-cli/src/pallet/command.rs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs index e98a19a2036b..5c76ca68e85f 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs @@ -25,9 +25,7 @@ use frame_support::traits::StorageInfo; use linked_hash_map::LinkedHashMap; use sc_cli::{execution_method_from_cli, CliConfiguration, Result, SharedParams}; use sc_client_db::BenchmarkingState; -use sc_executor::{ - HeapAllocStrategy, NativeElseWasmExecutor, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY, -}; +use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY}; use sc_service::Configuration; use serde::Serialize; use sp_core::{ @@ -227,15 +225,17 @@ impl PalletCmd { extra_pages: p as _, }); - let executor = NativeElseWasmExecutor::::new_with_wasm_executor( - WasmExecutor::builder() - .with_execution_method(method) - .with_onchain_heap_alloc_strategy(heap_pages) - .with_offchain_heap_alloc_strategy(heap_pages) - .with_max_runtime_instances(2) - .with_runtime_cache_size(2) - .build(), - ); + let executor = WasmExecutor::<( + sp_io::SubstrateHostFunctions, + frame_benchmarking::benchmarking::HostFunctions, + ExtraHostFunctions, + )>::builder() + .with_execution_method(method) + .with_onchain_heap_alloc_strategy(heap_pages) + .with_offchain_heap_alloc_strategy(heap_pages) + .with_max_runtime_instances(2) + .with_runtime_cache_size(2) + .build(); let extensions = || -> Extensions { let mut extensions = Extensions::default();