2

I want to use WEIGHT_PER_SECOND in this code :

parameter_types! {
    pub const BlockHashCount: BlockNumber = 2400;
    pub const Version: RuntimeVersion = VERSION;
    /// We allow for 2 seconds of compute with a 6 second average block time.
    pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights
        ::with_sensible_defaults(2 * WEIGHT_PER_SECOND, NORMAL_DISPATCH_RATIO);
    pub BlockLength: frame_system::limits::BlockLength = frame_system::limits::BlockLength
        ::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
    pub const SS58Prefix: u8 = 42;
}

and I use this code for import WEIGHT_PER_SECOND :

    pub use frame_support::{
    traits::{
        ConstU128, ConstU32, ConstU64, ConstBool,ConstU8, KeyOwnerProofSystem,Nothing, Randomness, StorageInfo,
    },
    weights::{
        constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
    },
};

I used this part of code in previous versions of substrate but in this version I faced this problem.

What's the problem, and how can I solve it?

1 Answer 1

3

It was renamed to WEIGHT_REF_TIME_PER_SECOND since with chromatic weights the weight has two components. Ref time and Proof Size.
There also is WEIGHT_PROOF_SIZE_PER_MB here.

2
  • it show me this error : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct Weight, found u64``
    – Mr Coder
    Feb 1 at 18:03
  • 1
    You can construct a two-dimensional Weight with Weight::from_parts by passing in the ref-time and proof size. So for example Weight::from_parts(2 * WEIGHT_REF_TIME_PER_SECOND, 5 * WEIGHT_PROOF_SIZE_PER_MB). Feb 1 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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