4

What is the recommended maximum number of bytes to store within a BoundedVec?

I am currently having the following struct:

#[derive(
    parity_scale_codec::Decode,
    parity_scale_codec::Encode,
    parity_scale_codec::MaxEncodedLen,
    scale_info::TypeInfo,
    Clone,
    Debug,
    PartialEq,
    Eq,
)]
pub struct JurorPoolItem<AccountId, Balance> {
    pub(crate) stake: Balance,
    pub(crate) juror: AccountId,
    pub(crate) consumed_stake: Balance,
}

And a BoundedVec:

pub(crate) type JurorPoolItemOf<T> = JurorPoolItem<AccountIdOf<T>, BalanceOf<T>>;
pub(crate) type JurorPoolOf<T> = BoundedVec<JurorPoolItemOf<T>, <T as Config>::MaxJurors>;

With the config parameter:

pub const MaxJurors: u32 = 10_000;

Is that too much for a block to handle if I iterate through this for example three times?

2 Answers 2

4

Is that too much for a block to handle if I iterate through this for example three times?

The answer to this question is benchmarking, the result of running such benchmarks will give a value that you can use to decide if the cost of those operations are bigger than expected.

Here a few links on benchmarking:

What is the recommended maximum number of bytes to store within a BoundedVec?

For this questions my understanding is that, when working with Wasm, 32bit, you can at maximum have an array of u32 max elements.

3

Just to add one thing into Alejandro's answer, the new Weights V2 has added a field into Weights: proof_size:

    pub struct Weight {
      /// The weight of computational time used based on 
      /// some reference hardware.
       ref_time: u64,
      /// The weight of storage space used by proof of validity.
      proof_size: u64,
    }

So the Weights now are not only measuring the computational time used, is measuring the storage space used by proof of validity.

In case you have a parachain, the proper parameter to set for the max proof size comes from the relay chain. In Polkadot you can see it here:

    pub const MAX_POV_SIZE: u32 = 5 * 1024 * 1024;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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