无法解决:使用未声明的类型“MaximumBlockWeight”

问题描述

我正在学习教程 https://substrate.dev/docs/en/tutorials/upgrade-a-chain/sudo-upgrade

但是,当我尝试构建版本时,它给了我以下错误。有谁知道可能导致问题的原因是什么?

     Compiling node-template-runtime v3.0.0 (/home/bill/substrate-node-template/runtime)
  error[E0433]: Failed to resolve: use of undeclared type `MaximumBlockWeight`
     --> /home/bill/substrate-node-template/runtime/src/lib.rs:302:70
      |
  302 |     pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * MaximumBlockWeight::get();
      |                                                                      ^^^^^^^^^^^^^^^^^^ use of undeclared type `MaximumBlockWeight`

  error[E0308]: mismatched types
     --> /home/bill/substrate-node-template/runtime/src/lib.rs:302:42
      |
  302 |     pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * MaximumBlockWeight::get();
      |                                 ------   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u64`,found struct `Perbill`
      |                                 |
      |                                 expected `u64` because of return type

  error[E0277]: the trait bound `Perbill: num_traits::sign::Unsigned` is not satisfied
     --> /home/bill/substrate-node-template/runtime/src/lib.rs:302:68
      |
  302 |     pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * MaximumBlockWeight::get();
      |                                                                    ^ the trait `num_traits::sign::Unsigned` is not implemented for `Perbill`
      |
      = note: required because of the requirements on the impl of `Mul` for `Perbill`

  error[E0277]: the trait bound `Perbill: From<u32>` is not satisfied

解决方法

将此更改应用于您的代码。

https://github.com/paritytech/substrate/commit/332399d16668a6c769f1a7db154bb9ea3b50e61c

每天都有大量更新,如果你想进行运行时升级,请继续关注上游。

这是最新的节点模板 https://github.com/paritytech/substrate/blob/master/bin/node-template/runtime/src/lib.rs