1

I have updated rust version. when i try to build the frontier template i am getting the below error:

*

error[E0599]: no function or associated item named `set_block_number` found for struct `frame_system::Pallet` in the current scope
     --> /home/faraz/.cargo/git/checkouts/substrate-7e08433d4c370a21/1db34ff/frame/system/benchmarking/src/lib.rs:35:1
      |
  35  | / benchmarks! {
  36  | |     remark {
  37  | |         let b in 0 .. *T::BlockLength::get().max.get(DispatchClass::Normal) as u32;
  38  | |         let remark_message = vec![1; b as usize];
  ...   |
  127 | |     impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test);
  128 | | }
      | | ^
      | | |
      | |_function or associated item not found in `frame_system::Pallet<T>`
      |   help: there is an associated function with a similar name: `block_number`
      |
      = note: this error originates in the macro `$crate::impl_benchmark` (in Nightly builds, run with -Z macro-backtrace for more info)
  For more information about this error, try `rustc --explain E0599`.
  error: could not compile `frame-system-benchmarking` due to previous error

I am using the following version of rustc:

Default host: x86_64-unknown-linux-gnu
rustup home:  /home/faraz/.rustup

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu (default)
nightly-x86_64-unknown-linux-gnu

active toolchain
----------------

stable-x86_64-unknown-linux-gnu (default)
rustc 1.60.0 (7737e0b5c 2022-04-04)

1 Answer 1

1

The set_block_numer function is only available when running tests or executing runtime-benchmarks.

/// Set the block number to something in particular. Can be used as an alternative to
/// `initialize` for tests that don't need to bother with the other environment entries.
#[cfg(any(feature = "std", feature = "runtime-benchmarks", test))]
pub fn set_block_number(n: T::BlockNumber) {
    <Number<T>>::put(n);
}

It seems this error would appear if you are trying to access this function outside of these feature gated contexts.

Make sure that you are building the code you want with the appropriate feature flags, and that your Cargo.toml has the appropriate feature gates setup too.

EDIT:

Doing a closer look, the solution is: https://github.com/paritytech/frontier/commit/b95c5da38652c2253f906c77d097060f7f86d142

You should remove the lines:

'frame-benchmarking/std',
'frame-system-benchmarking/std',

If they exist. This is simply a mistake in the configuration.

1
  • The solution works like a charm. Thank you Commented Apr 29, 2022 at 8:52

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.