moondance-labs / tanssi

GNU General Public License v3.0
231 stars 48 forks source link

Panicked at 'slot digest should exist' for `slot()` on `AuraDigestSlotBeacon` #388

Closed Chralt98 closed 7 months ago

Chralt98 commented 9 months ago

I use the tanssi-polkadot-v1.1.0 branch right now.

I use this command ./target/release/container-chain-template-simple-node benchmark pallet --chain=dev --steps=50 --repeat=20 --pallet=pallet_timestamp --extrinsic='set' --wasm-execution=compiled --heap-pages=4096 --template=./benchmarking/frame-weight-template.hbs --output=./container-chains/templates/simple/runtime/src/weights/

But then my benchmark for pallet_timestamp errors here.

This is my error output:

2024-01-13 15:04:41 Starting benchmark: pallet_timestamp::set    
2024-01-13 15:04:41 panicked at 'slot digest should exist', /User/project/primitives/consensus/src/lib.rs:86:14    
2024-01-13 15:04:41 1 storage transactions are left open by the runtime. Those will be rolled back.    
2024-01-13 15:04:41 1 storage transactions are left open by the runtime. Those will be rolled back.    
Error: Input("Error executing and verifying runtime benchmark: Execution aborted due to trap: wasm trap: wasm `unreachable` instruction executed\nWASM backtrace:\nerror while executing at wasm backtrace:\n    0: 0x30e755 - <unknown>!rust_begin_unwind\n    1: 0x2c4786 - <unknown>!core::panicking::panic_fmt::hf5c4cd929d4aaa9e\n    2: 0x2c4734 - <unknown>!core::option::expect_failed::hc36a69366777ce0b\n    3: 0x53213 - <unknown>!<tp_consensus::OnTimestampSet<SlotBeacon,SlotDuration> as frame_support::traits::hooks::OnTimestampSet<u64>>::on_timestamp_set::h8a01a7b02758e3d6\n    4: 0x1c8ae3 - <unknown>!frame_support::storage::transactional::with_storage_layer::h7dede3e27201e013\n    5: 0x1c8540 - <unknown>!environmental::local_key::LocalKey<T>::with::h8dbebb25666dfbf0\n    6: 0x58508 - <unknown>!core::ops::function::FnOnce::call_once{{vtable.shim}}::h53d4045e9251c138\n    7: 0x11fab2 - <unknown>!pallet_timestamp::benchmarking::<impl frame_benchmarking::utils::Benchmarking for pallet_timestamp::pallet::Pallet<T>>::run_benchmark::h6846c89c764383cd\n    8: 0x147000 - <unknown>!<container_chain_template_simple_runtime::Runtime as frame_benchmarking::utils::runtime_decl_for_benchmark::BenchmarkV1<sp_runtime::generic::block::Block<sp_runtime::generic::header::Header<u32,sp_runtime::traits::BlakeTwo256>,sp_runtime::generic::unchecked_extrinsic::UncheckedExtrinsic<sp_runtime::multiaddress::MultiAddress<<<sp_runtime::MultiSignature as sp_runtime::traits::Verify>::Signer as sp_runtime::traits::IdentifyAccount>::AccountId,()>,container_chain_template_simple_runtime::RuntimeCall,sp_runtime::MultiSignature,(frame_system::extensions::check_non_zero_sender::CheckNonZeroSender<container_chain_template_simple_runtime::Runtime>,frame_system::extensions::check_spec_version::CheckSpecVersion<container_chain_template_simple_runtime::Runtime>,frame_system::extensions::check_tx_version::CheckTxVersion<container_chain_template_simple_runtime::Runtime>,frame_system::extensions::check_genesis::CheckGenesis<container_chain_template_simple_runtime::Runtime>,frame_system::extensions::check_mortality::CheckMortality<container_chain_template_simple_runtime::Runtime>,frame_system::extensions::check_nonce::CheckNonce<container_chain_template_simple_runtime::Runtime>,frame_system::extensions::check_weight::CheckWeight<container_chain_template_simple_runtime::Runtime>,pallet_asset_tx_payment::ChargeAssetTxPayment<container_chain_template_simple_runtime::Runtime>)>>>>::dispatch_benchmark::ha9389c04d10b2789\n    9: 0x188e9c - <unknown>!Benchmark_dispatch_benchmark")

Background information:

I properly added the timestamp pallet in my benchmark configuration:

use pallet_timestamp::Pallet as TimestampBench;
...
list_benchmark!(list, extra, pallet_timestamp, TimestampBench::<Runtime>);
...
add_benchmark!(params, batches, pallet_timestamp, TimestampBench::<Runtime>);
...
runtime-benchmarks = [ 
...
       "pallet-timestamp/runtime-benchmarks", 
...
]

What can I do to fix it?

girazoki commented 8 months ago

hey @Chralt98 thanks for sending this. Yes it is likely that we can use the unwrap_or_default instead of the expect since the slot is later verified but maybe there are other ways around this that we can explore.

girazoki commented 8 months ago

Likely the proper way to do this would be to implement a set_timestamp_info in the OnTimestampSet trait that we can use for benchmarks. But this is a PR to substrate so it will take more time to do, for now you can probably do the unwrap_or_default instead of the .expect("slot digest should exist");, at least when the benchmark features is enabeld (you can also do a PR with the change)

girazoki commented 8 months ago

https://github.com/moondance-labs/tanssi/pull/389 should fix it. I am going to work to polish it a bit for you to able to benchmark every pallet