paritytech / polkadot

Polkadot Node Implementation
GNU General Public License v3.0
7.12k stars 1.58k forks source link

Panic when attempting to run benchmark on `frame_system` `remarks` on polkadot + westend #2103

Closed s3krit closed 3 years ago

s3krit commented 3 years ago

When attempting to run the benchmark for the extrinsic remark in the frame_system pallet, rather than the benchmark running, it simply panics and exits. This only occurs for the remark extrinsic. Other extrinsics in the frame_system pallet are unaffected. This also only occurs in the Polkadot and Westend runtimes - it does not seemingly affect Kusama.

A git bisect leads me to believe this change was introduced in this PR: https://github.com/paritytech/polkadot/pull/1420 (or more likely, its companion Substrate changes).

Due to the fact that this affects polkadot and westend, but not kusama or running the benchmark against the substrate repo itself, I have opted to file the issue here. As with my last benchmark issue, feel free to move it if this is not the best place.

/cc @tomusdrw @shawntabrizi

Example command + output:

cargo run --release --features=runtime-benchmarks -- benchmark --chain=polkadot-dev --pallet="frame_system" --execution=native --wasm-execution=compiled --heap-pages=4096 --extrinsic="remark"

    Finished release [optimized] target(s) in 0.34s                                                                                                                                                                                                                                                                                                                [30/1378]
     Running `target/release/polkadot benchmark --chain=polkadot-dev --pallet=frame_system --execution=native --wasm-execution=compiled --heap-pages=4096 --extrinsic=remark`                                                                                                                                                                                               
2020-12-09 20:20:51  💸 new validator set of size 1 has been elected via ElectionCompute::OnChain for era 0                                                                                                                                                                                                                                                                 

====================                                                                                                                                                                                                                                                                                                                                                        

Version: 0.8.27-7a0fcb07-x86_64-linux-gnu                                                                                                                                                                                                                                                                                                                                   

   0: sp_panic_handler::set::{{closure}}                                                                                                                                                                                                                                                                                                                                    
   1: std::panicking::rust_panic_with_hook                                                                                                                                                                                                                                                                                                                                  
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:581                                                                                                                                                                                                                                                                            
   2: std::panicking::begin_panic_handler::{{closure}}                                                                                                                                                                                                                                                                                                                      
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:484                                                                                                                                                                                                                                                                            
   3: std::sys_common::backtrace::__rust_end_short_backtrace                                                                                                                                                                                                                                                                                                                
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:153                                                                                                                                                                                                                                                                 
   4: rust_begin_unwind                                                                                                                                                                                                                                                                                                                                                     
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:483                                                                                                                                                                                                                                                                            
   5: core::panicking::panic_fmt                                                                                                                                                                                                                                                                                                                                            
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/panicking.rs:85                                                                                                                                                                                                                                                                            
   6: core::option::expect_none_failed                                                                                                                                                                                                                                                                                                                                      
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/option.rs:1234                                                                                                                                                                                                                                                                             
   7: tracing::span::Span::in_scope                                                                                                                                                                                                                                                                                                                                         
   8: <<sp_io::allocator::HostFunctions as sp_wasm_interface::HostFunctions>::host_functions::ExtAllocatorMallocVersion1 as sp_wasm_interface::Function>::execute                                                                                                                                                                                                           
   9: wasmtime::func::Func::new::{{closure}}                                                                                                                                                                                                                                                                                                                                
  10: wasmtime::trampoline::func::stub_fn                                                                                                                                                                                                                                                                                                                                   
  11: <unknown>                                                                                                                                                                                                                                                                                                                                                             
  12: <unknown>                                                                                                                                                                                                                                                                                                                                                             
  13: <unknown>                                                                                                                                                                                                                                                                                                                                                             
  14: <unknown>                                                                                                                                                                                                                                                                                                                                                             
  15: <unknown>                                                                                                                                                                                                                                                                                                                                                             
  16: <unknown>                                                                                                                                                                                                                                                                                                                                                               17: <unknown>                                                                                                                                                                                                                                                                                                                                                               18: <unknown>                                                                                                                                                                                        
  19: <unknown>                                                                                                                                                                                                                                                                                                                                                               20: RegisterSetjmp                                                                                                                                                                                                                                                                                                                                                          21: wasmtime_runtime::traphandlers::catch_traps                                                                                                                                                                                                                                                                                                                             22: wasmtime::func::Func::call                                                                                                
  23: sc_executor_wasmtime::instance_wrapper::EntryPoint::call                                                                                                                                                                                                                                                                                                                24: scoped_tls::ScopedKey<T>::set                                                                                                                                                                                                       
  25: <sc_executor_wasmtime::runtime::WasmtimeInstance as sc_executor_common::wasm_runtime::WasmInstance>::call                                                                                                                                                                                                                                                               26: sc_executor_common::wasm_runtime::WasmInstance::call_export                                                                                                                                                                                                                                                                                                             27: std::panicking::try                                                                                                                                                                                                                                                                                                                                                     28: std::thread::local::LocalKey<T>::with                                                                                                                             
  29: sc_executor::native_executor::WasmExecutor::with_instance::{{closure}}                                                                                                                                                                                                                                                                                                  30: sc_executor::wasm_runtime::RuntimeCache::with_instance                                                                                                                                                                                                                                                                                                                  31: <sc_executor::native_executor::NativeExecutor<D> as sp_core::traits::CodeExecutor>::call                                                                                                                                                                                                                                                                                32: sp_state_machine::execution::StateMachine<B,H,N,Exec>::execute_aux                                                                                                                                                                                                                                                                                                      33: sp_state_machine::execution::StateMachine<B,H,N,Exec>::execute                                                                                                                                                                                                                                                                                                          34: frame_benchmarking_cli::command::<impl frame_benchmarking_cli::BenchmarkCmd>::run                                                                                                                                                                                                                                                                                       35: polkadot_cli::command::run                                                                                                                                                                                                                                                                                                                                              36: polkadot::main                                                                                                                                                                                                                                                                                                                                                          37: std::sys_common::backtrace::__rust_begin_short_backtrace                                                                                                                                                                                                                                                                                                                38: std::rt::lang_start::{{closure}}                                                                                                                                                                                                                                                                                                                                        39: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once                                                                                                                                                                                                                                                                                                at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/ops/function.rs:259                                                                                                                                                                                                                                                                              std::panicking::try::do_call                                                                                                                                                                                                                                                                                                                                                       at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:381                                                                        
      std::panicking::try                                                                                                                                                                                                                                                                                                             
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:345
  40: main
  41: __libc_start_main
  42: _start

Thread 'main' panicked at 'Failed to allocate memory: "Requested allocation size is too large"', /home/martin/.cargo/git/checkouts/substrate-7e08433d4c370a21/be8fd05/primitives/io/src/lib.rs:1001

This is a bug. Please report it at:

        https://github.com/paritytech/polkadot/issues/new

Error: 
   0: Invalid input: Error executing runtime benchmark: Other("Wasm execution trapped: Failed to allocate memory: \"Requested allocation size is too large\"\nwasm backtrace:\n  0: 0x2805a2 - <unknown>!sp_io::allocator::extern_host_function_impls::malloc::hfa68d6a0e2bf64eb\n  1: 0x1a66 - <unknown>!__rg_alloc\n  2: 0x1a5f - <unknown>!__rust_alloc\n  3: 0x2626a4 - <unknown>!<frame_system_benchmarking::Module<T> as frame_benchmarking::utils::Benchmarking<frame_benchmarking::utils::BenchmarkResults>>::run_benchmark::{{closure}}::h1ddcc57c6f5a72d7\n  4: 0x208b49 - <unknown>!<frame_system_benchmarking::Module<T> as frame_benchmarking::utils::Benchmarking<frame_benchmarking::utils::BenchmarkResults>>::run_benchmark::he11606b3cb46a6f8\n  5: 0x2023cc - <unknown>!<polkadot_runtime::Runtime as frame_benchmarking::utils::runtime_decl_for_Benchmark::Benchmark<sp_runtime::generic::block::Block<sp_runtime::generic::header::Header<u32,sp_runtime::traits::BlakeTwo256>,sp_runtime::generic::unchecked_extrinsic::UncheckedExtrinsic<<<sp_runtime::MultiSignature as sp_runtime::traits::Verify>::Signer as sp_runtime::traits::IdentifyAccount>::AccountId,polkadot_runtime::Call,sp_runtime::MultiSignature,(frame_system::extensions::check_spec_version::CheckSpecVersion<polkadot_runtime::Runtime>,frame_system::extensions::check_tx_version::CheckTxVersion<polkadot_runtime::Runtime>,frame_system::extensions::check_genesis::CheckGenesis<polkadot_runtime::Runtime>,frame_system::extensions::check_mortality::CheckMortality<polkadot_runtime::Runtime>,frame_system::extensions::check_nonce::CheckNonce<polkadot_runtime::Runtime>,frame_system::extensions::check_weight::CheckWeight<polkadot_runtime::Runtime>,pallet_transaction_payment::ChargeTransactionPayment<polkadot_runtime::Runtime>,polkadot_runtime_common::claims::PrevalidateAttests<polkadot_runtime::Runtime>)>>>>::dispatch_benchmark::h5bb6beb47cadc480\n  6: 0x25de26 - <unknown>!Benchmark_dispatch_benchmark\n")

Location:
   src/main.rs:25
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                                ⋮ 2 frames hidden ⋮                               
   3: polkadot::main::hf21d63258a98fc85
      at <unknown source file>:<unknown line>
   4: std::sys_common::backtrace::__rust_begin_short_backtrace::he5ced9e7cc62f1b8
      at <unknown source file>:<unknown line>
   5: std::rt::lang_start::{{closure}}::h2fb86c3ebf11d9fe
      at <unknown source file>:<unknown line>
   6: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::he179d32a5d10d957
      at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/ops/function.rs:259
   7: std::panicking::try::do_call::hcb3d5e7be089b2b4
      at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:381
   8: std::panicking::try::h7ac93b0cd56fb701
      at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:345
   9: std::panic::catch_unwind::h7b40e396c93a4fcd
      at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panic.rs:382
  10: std::rt::lang_start_internal::h142b9cc66267fea1
      at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/rt.rs:51
  11: main<unknown>
      at <unknown source file>:<unknown line>
  12: __libc_start_main<unknown>
      at <unknown source file>:<unknown line>
  13: _start<unknown>
      at <unknown source file>:<unknown line>
tomusdrw commented 3 years ago

Could be this change: https://github.com/paritytech/polkadot/pull/1420/files#diff-6d8082b4f8457cf69627e4dd8221b79aad63061aa8619da2bb9c580f5efe5b6fR329

I'll take a closer look first thing in the morning tomorrow.