5

I am trying to incorporate benchmark overhead command to our parachain. The issue i have is that runtime api methods are not available right away after client is created.

https://github.com/mangata-finance/mangata-node/blob/68b327b9230c248af562a33884e0b72ba0a2496a/node/src/command.rs#L353-L356

                    BenchmarkCmd::Overhead(cmd) => runner.sync_run(|config| {
                        env_logger::try_init();
                        log::info!("overhead command start");
                        let partials = new_partial::<
                            service::mangata_kusama_runtime::RuntimeApi,
                            service::MangataKusamaRuntimeExecutor,
                        >(&config)?;
                        let inherent_data = inherent_benchmark_data().unwrap();
                        let empty_data = sp_inherents::InherentData::new();
                        let at = sp_runtime::generic::BlockId::Number(0u32.into());
                        let api = partials.client.runtime_api();

                        api.can_enqueue_txs(&at).unwrap();

                        api.inherent_extrinsics_with_context(
                            &at,
                            sp_core::ExecutionContext::BlockConstruction,
                            empty_data,
                        )
                        .unwrap();
                        Ok(())

it fails immediately

cargo run --release --features=runtime-benchmarks,mangata-kusama benchmark overhead

Version: 0.1.0-90f07d533ca

   0: sp_panic_handler::set::{{closure}}
   1: std::panicking::rust_panic_with_hook
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/panicking.rs:702:17
   2: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/panicking.rs:588:13
   3: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/sys_common/backtrace.rs:138:18
   4: rust_begin_unwind
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/panicking.rs:584:5
   5: core::panicking::panic_fmt
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/core/src/panicking.rs:142:14
   6: core::result::unwrap_failed
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/core/src/result.rs:1785:5
   7: mangata_node::service::start_node_impl::{{closure}}
   8: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   9: std::thread::local::LocalKey<T>::with
  10: tokio::park::thread::CachedParkThread::block_on
  11: tokio::runtime::Runtime::block_on
  12: sc_cli::runner::Runner<C>::run_node_until_exit
  13: mangata_node::command::run
  14: mangata_node::main
  15: std::sys_common::backtrace::__rust_begin_short_backtrace
  16: std::rt::lang_start::{{closure}}
  17: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/core/src/ops/function.rs:280:13
      std::panicking::try::do_call
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/panicking.rs:492:40
      std::panicking::try
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/panicking.rs:456:19
      std::panic::catch_unwind
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/panic.rs:137:14
      std::rt::lang_start_internal::{{closure}}
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/rt.rs:128:48
      std::panicking::try::do_call
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/panicking.rs:492:40
      std::panicking::try
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/panicking.rs:456:19
      std::panic::catch_unwind
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/panic.rs:137:14
      std::rt::lang_start_internal
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/rt.rs:128:20
  18: main
  19: <unknown>
  20: __libc_start_main
  21: _start
             at /build/glibc/src/glibc/csu/../sysdeps/x86_64/start.S:115


Thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Application(Execution(Other("Exported method VerApi_can_enqueue_txs is not found")))', node/src/service.rs:368

above method is of course implemented

https://github.com/mangata-finance/mangata-node/blob/68b327b9230c248af562a33884e0b72ba0a2496a/runtime/mangata-kusama/src/lib.rs#L1262-L1264

Whats weird is that in the same time node runs fine... But when i modify service command

https://github.com/mangata-finance/mangata-node/blob/d31fa75ea116651419a09e5c9683e088e59434ed/node/src/service.rs#L368-L370

to run some runtime api method (the one that fails for me when setting proper env for running overhead benchmark) immediately after client instance is created it fails as well...

cargo run --release --features=runtime-benchmarks,mangata-kusama -- --chain local  -- --chain kusama-local
====================

Version: 0.1.0-68b327b9230

   0: sp_panic_handler::set::{{closure}}
   1: std::panicking::rust_panic_with_hook
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/panicking.rs:702:17
   2: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/panicking.rs:588:13
   3: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/sys_common/backtrace.rs:138:18
   4: rust_begin_unwind
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/panicking.rs:584:5
   5: core::panicking::panic_fmt
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/core/src/panicking.rs:142:14
   6: core::result::unwrap_failed
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/core/src/result.rs:1785:5
   7: mangata_node::service::start_node_impl::{{closure}}
   8: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   9: std::thread::local::LocalKey<T>::with
  10: tokio::park::thread::CachedParkThread::block_on
  11: tokio::runtime::Runtime::block_on
  12: sc_cli::runner::Runner<C>::run_node_until_exit
  13: mangata_node::command::run
  14: mangata_node::main
  15: std::sys_common::backtrace::__rust_begin_short_backtrace
  16: std::rt::lang_start::{{closure}}
  17: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/core/src/ops/function.rs:280:13
      std::panicking::try::do_call
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/panicking.rs:492:40
      std::panicking::try
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/panicking.rs:456:19
      std::panic::catch_unwind
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/panic.rs:137:14
      std::rt::lang_start_internal::{{closure}}
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/rt.rs:128:48
      std::panicking::try::do_call
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/panicking.rs:492:40
      std::panicking::try
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/panicking.rs:456:19
      std::panic::catch_unwind
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/panic.rs:137:14
      std::rt::lang_start_internal
             at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/rt.rs:128:20
  18: main
  19: <unknown>
  20: __libc_start_main
  21: _start
             at /build/glibc/src/glibc/csu/../sysdeps/x86_64/start.S:115


Thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Application(Execution(AbortedDueToTrap(MessageWithBacktrace { message: "wasm trap: wasm `unreachable` instruction executed", backtrace: Some(Backtrace { backtrace_string: "\n    0: 0x3d54 - <unknown>!rust_begin_unwind\n    1: 0x24f6 - <unknown>!core::panicking::panic_fmt::h8f11323637b4db3b\n    2: 0x4870 - <unknown>!core::panicking::panic_display::h0b0fc4d9da8b83e3\n    3: 0x331f - <unknown>!core::option::expect_failed::h83d8066bdd552df6\n    4: 0x2eb3e1 - <unknown>!BlockBuilder_inherent_extrinsics\n" }) })))', node/src/service.rs:370

This is a bug. Please report it at:

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

but when i just start the node, without any modyfications everything works as expected ... Not sure how is that possible, can it be that some of the client functionalities are not enabled right away after client is created - that doesnt seems right as in reference from substrate repo, it seems to work fine ...

https://github.com/mangata-finance/substrate/blob/73c58904ba958bc9596e7a4624bf8c2afd99f111/bin/node-template/node/src/command.rs#L138-L143

Does anyone have an idea what can be wrong here?

2
  • What do you need the can_enqueue_txs and inherent_extrinsics_with_context for? Sep 30, 2022 at 20:46
  • 1
    Can you confirm that the node is running on a clean DB path? If not, the genesis-hash will still contain the old runtime code without the Runtime API. The --tmp flag is useful for this.
    – rob
    Sep 30, 2022 at 22:26

2 Answers 2

0

What do you need the can_enqueue_txs and inherent_extrinsics_with_context for? –

inherent extrinsics is called in block builder when new block is initialized (to convert inherent data into extrinsics and include these into the block) i need to create new blocks to benchmark block execution overhead

2
  • Combine your two answers to your question to one
    – Simson
    Oct 3, 2022 at 10:37
  • I dont think this is the right approach. You should not build a block yourself. I should probably write an integration guide. Oct 4, 2022 at 11:58
-1

Can you confirm that the node is running on a clean DB path? If not, the genesis-hash will still contain the old runtime code without the Runtime API. The --tmp flag is useful for this. –

now it doesnt complain about can_enqueue_txs but inherent_extrinsics still does not work

Can you confirm that the node is running on a clean DB path? If not, the genesis-hash will still contain the old runtime code without the Runtime API. The --tmp flag is useful for this. –

that solved Exported method is not found problem, thanks

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Oct 3, 2022 at 15:28

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.