Errors while building with `--features runtime-benchmarks`

error: cannot find macro `list_benchmarks` in this scope
     --> /home/subspace/subspace/cumulus/runtime/src/runtime.rs:406:13
      |                                                                                                                         
  406 |             list_benchmarks!(list, extra);
      |             ^^^^^^^^^^^^^^^
                                                                                                                                
error: cannot find macro `add_benchmarks` in this scope
     --> /home/subspace/subspace/cumulus/runtime/src/runtime.rs:437:13
      |                                                                                                                         
  437 |             add_benchmarks!(params, batches);
      |             ^^^^^^^^^^^^^^

Version: b63028b4d03

I’m surprised it fails to compile, we’ll have to fix that soon to benchmark extrinsics. I think replacing with canonical path should help.

Feel free to submit a PR fixing it, we’ll appreciate it!

I can’t find the define_benchmarks marcos call anywhere, which defines add_benchmarks and list_benchmarks. Could this be the reason?

I tried using it explicitly. New errors.

error[E0433]: failed to resolve: use of undeclared type `TemplateModule`                                                          
    --> /home/subspace/.cargo/git/checkouts/substrate-7bc20b373ca3e834/1a7c287/frame/benchmarking/src/lib.rs:1816:21               
     |                                                                                                                        
1816 |         let benchmarks = $( $location )*::benchmarks($extra);                                                               
     |                           ^^^^^^^^^^^^^ use of undeclared type `TemplateModule`
                                                                                                                                                                      
error[E0433]: failed to resolve: use of undeclared type `TemplateModule`
   --> /home/subspace/subspace-ex/crates/subspace-runtime/src/lib.rs:942:62                                                      
    |                                                                                                                         
942 |             add_benchmark!(params, batches, pallet_template, TemplateModule);                                               
    |                                                              ^^^^^^^^^^^^^^ use of undeclared type `TemplateModule`                                                                                                                                   

error[E0425]: cannot find value `batches` in this scope                                                                          
    --> /home/subspace/subspace-ex/crates/subspace-runtime/src/lib.rs:902:37                                                       
     |                                                                                                                         
 902 |             list_benchmark!(params, batches, pallet_utility, Utility);                                                     
     |                                     ^^^^^^^ not found in this scope                                                                                                                                                                                   

error[E0425]: cannot find value `params` in this scope                                                                           
    --> /home/subspace/subspace-ex/crates/subspace-runtime/src/lib.rs:902:29                                                      
     |                                                                                                                         
 902 |             list_benchmark!(params, batches, pallet_utility, Utility);                                                     
     |                             ^^^^^^ not found in this scope                                                                                                                                                                                            

 Some errors have detailed explanations: E0425, E0433.                                                                         
 For more information about an error, try `rustc --explain E0425`.                                                             
 error: could not compile `subspace-runtime` due to 4 previous errors

I think things might have changed in Substrate and were not reflected in our codebase. Try to look at the subspace-runtime crate or else Polkadot’s codebase and adjust our codebase by analogy.

At least compilation is fixed in EC consensus (part 1) by nazar-pc · Pull Request #929 · subspace/subspace · GitHub

1 Like