2

for some reason running overhead benchmarks fails in our parachain.

cargo run --release --features=runtime-benchmarks benchmark overhead --chain local

results with following stacktrace

Error: Client(Application(Application(Execution(AbortedDueToTrap(MessageWithBacktrace { message: "wasm trap: wasm `unreachable` instruction executed", backtrace: Some(Backtrace { backtrace_string: "
    0: 0x3fe0f6 - <unknown>!rust_begin_unwind
    1: 0x664b - <unknown>!core::panicking::panic_fmt::h0a20ba97f16cb738
    2: 0x660c - <unknown>!core::panicking::panic::h20cc6242ae6ad8e6
    3: 0x26732d - <unknown>!<mangata_kusama_runtime::Runtime as sp_block_builder::runtime_decl_for_BlockBuilder::BlockBuilder<sp_runtime::generic::block::Block<sp_runtime::generic::header_ver::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,()>,mangata_kusama_runtime::Call,sp_runtime::MultiSignature,(frame_system::extensions::check_spec_version::CheckSpecVersion<mangata_kusama_runtime::Runtime>,frame_system::extensions::check_tx_version::CheckTxVersion<mangata_kusama_runtime::Runtime>,frame_system::extensions::check_genesis::CheckGenesis<mangata_kusama_runtime::Runtime>,frame_system::extensions::check_mortality::CheckMortality<mangata_kusama_runtime::Runtime>,frame_system::extensions::check_nonce::CheckNonce<mangata_kusama_runtime::Runtime>,frame_system::extensions::check_weight::CheckWeight<mangata_kusama_runtime::Runtime>,pallet_transaction_payment::ChargeTransactionPayment<mangata_kusama_runtime::Runtime>)>>>>::inherent_extrinsics::heebd5e387a87c636
    4: 0x398ecb - <unknown>!BlockBuilder_inherent_extrinsics
" }) })))))


Backtrace seems to pointing out to [BlockBuilderApi::inherent_extrinsics][1] runtime api call in [BlockBuilder::create_inherents][2]

    /// Create the inherents for the block.
    ///
    /// Returns the inherents created by the runtime or an error if something failed.
    pub fn create_inherents(
        &mut self,
        inherent_data: sp_inherents::InherentData,
    ) -> Result<Vec<Block::Extrinsic>, Error> {
        let block_id = self.block_id;
        self.api
            .execute_in_transaction(move |api| {
                // `create_inherents` should not change any state, to ensure this we always rollback
                // the transaction.
                TransactionOutcome::Rollback(api.inherent_extrinsics_with_context(
                    &block_id,
                    ExecutionContext::BlockConstruction,
                    inherent_data,
                ))
            })
            .map_err(|e| Error::Application(Box::new(e)))
    }

which seems to be very weird because both in [origin substrate runtime][3] and [our runtime][4] is same and depends on macro generated impl of [create_extrinsics][5]

    impl sp_block_builder::BlockBuilder<Block> for Runtime {
        fn inherent_extrinsics(data: InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
            data.create_extrinsics()
        }
    }

What is even more weird when i replace runtime impl of [BlockBuilder::inherent_extrinsics][0] with just some panic

it still produces the same error

  git diff
diff --git a/runtime/mangata-kusama/src/lib.rs b/runtime/mangata-kusama/src/lib.rs
index 087ece535..826cf78f5 100644
--- a/runtime/mangata-kusama/src/lib.rs
+++ b/runtime/mangata-kusama/src/lib.rs
@@ -1444,6 +1444,7 @@ impl_runtime_apis! {
                }
 
                fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
+                       panic!("blah blah");
                        data.create_extrinsics()
                }
 
  cargo run --release --features=runtime-benchmarks benchmark overhead --chain local
 ...
warning: `mangata-node` (lib) generated 15 warnings
    Finished release [optimized] target(s) in 2.67s
     Running `target/release/mangata-node benchmark overhead --chain local`
Error: Client(Application(Application(Execution(AbortedDueToTrap(MessageWithBacktrace { message: "wasm trap: wasm `unreachable` instruction executed", backtrace: Some(Backtrace { backtrace_string: "
    0: 0x3fe0f6 - <unknown>!rust_begin_unwind
    1: 0x664b - <unknown>!core::panicking::panic_fmt::h0a20ba97f16cb738
    2: 0x660c - <unknown>!core::panicking::panic::h20cc6242ae6ad8e6
    3: 0x26732d - <unknown>!<mangata_kusama_runtime::Runtime as sp_block_builder::runtime_decl_for_BlockBuilder::BlockBuilder<sp_runtime::generic::block::Block<sp_runtime::generic::header_ver::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,()>,mangata_kusama_runtime::Call,sp_runtime::MultiSignature,(frame_system::extensions::check_spec_version::CheckSpecVersion<mangata_kusama_runtime::Runtime>,frame_system::extensions::check_tx_version::CheckTxVersion<mangata_kusama_runtime::Runtime>,frame_system::extensions::check_genesis::CheckGenesis<mangata_kusama_runtime::Runtime>,frame_system::extensions::check_mortality::CheckMortality<mangata_kusama_runtime::Runtime>,frame_system::extensions::check_nonce::CheckNonce<mangata_kusama_runtime::Runtime>,frame_system::extensions::check_weight::CheckWeight<mangata_kusama_runtime::Runtime>,pallet_transaction_payment::ChargeTransactionPayment<mangata_kusama_runtime::Runtime>)>>>>::inherent_extrinsics::heebd5e387a87c636
    4: 0x398ecb - <unknown>!BlockBuilder_inherent_extrinsics
" }) })))))
cargo run --release --features=runtime-benchmarks benchmark overhead --chain   16.96s user 1.19s system 417% cpu 4.351 total


so it feels like some problem with [sp_inherents::InherentData::create_inherents call][5] but with dispatching of runtime api calls?

and yes i tried purging local chain data, purging cargo cache etc...

How to reproduce?

git clone [email protected]:mangata-finance/mangata-node.git
git checkout 35b5c154fe75f94c611f6e4d7f85e775d56c68ee
cargo run --release --features=runtime-benchmarks benchmark overhead --chain local

It works fine when i force wasm method in benchmark config to be WasmExecutionMethod::Interpreted instead of Compiled { instantiation_strategy: PoolingCopyOnWrite } but im not sure if its good enough for benchmarking overhead ?

[1]: https://github.com/mangata-finance/substrate/blob/73c58904ba958bc9596e7a4624bf8c2afd99f111/primitives/block-builder/src/lib.rs#L45-L47ill go with interpreter for now to proceed with benchmarks, and try to [2]: https://github.com/mangata-finance/substrate/blob/73c58904ba958bc9596e7a4624bf8c2afd99f111/client/block-builder/src/lib.rs#L279-L295 [3]: https://github.com/mangata-finance/substrate/blob/73c58904ba958bc9596e7a4624bf8c2afd99f111/bin/node/runtime/src/lib.rs#L1774-L1776 [4]: https://github.com/mangata-It works fine when i force wasm method in benchmark config to be WasmExecutionMethod::Interpreted instead of Compiled { instantiation_strategy: PoolingCopyOnWrite } but im not sure if its good enough for benchmarking overhead ?finance/mangata-node/blob/35b5c154fe75f94c611f6e4d7f85e775d56c68ee/runtime/mangata-kusama/src/lib.rs#L1446-L1448 [5]: https://github.com/mangata-finance/substrate/blob/73c58904ba958bc9596e7a4624bf8c2afd99f111/frame/support/procedural/src/construct_runtime/expand/inherent.rs#L48-L52

3
  • 1
    Thanks for putting in an exact commit hash and some commands on how to reproduce it. Otherwise the question would be very difficult to answer. Oct 4, 2022 at 12:07
  • 1
    ahhh thank you! --native swtich was the thing! i can manage the other errors on my own Oct 4, 2022 at 13:09
  • Please consider to mark the question as "Answered" if this solved your problem, thanks. Oct 4, 2022 at 17:21

1 Answer 1

2

There is inherent data missing that the parachain-system pallet expects.
It needs to be added in your inherent_benchmark_data function which currently only injects timestamp data. The exact inherent data that is needed depends on your chain config.
Polkadot for example needs the para inherent data for a relay chain, whereas you need the para inherent data for a parachain.
Running the benchmarks with --execution native gets rid of any error stripping that happens in WASM.
If you add the changes below it will error on the next missing inherent data Could not find AuRa author index. So you also need to inject inherent data or a pre-runtime digest for Aura, not sure which of those.

/// Generates inherent data for the `benchmark overhead` command.
pub fn inherent_benchmark_data() -> Result<InherentData> {
    let mut inherent_data = InherentData::new();
    let d = Duration::from_millis(0);
    let timestamp = sp_timestamp::InherentDataProvider::new(d.into());

    timestamp
        .provide_inherent_data(&mut inherent_data)
        .map_err(|e| format!("creating inherent data: {:?}", e))?;

    // ADDED
    let mock_para_inherent_provider = cumulus_primitives_parachain_inherent::MockValidationDataInherentDataProvider {
        current_para_block: 0,
        relay_offset: 0,
        relay_blocks_per_para_block: 2,
        xcm_config: Default::default(),
        raw_downward_messages: Default::default(),
        raw_horizontal_messages: Default::default(),
    };

    mock_para_inherent_provider.provide_inherent_data(&mut inherent_data).expect("Mock must provide inherent data; qed");
    // END ADDED

    Ok(inherent_data)
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.