Questions tagged [boundedvec]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
1 answer
26 views

Data structure to choose for ordered items?

Can someone help me understand the difference b/w using a Vec (BoundedVec) instead of a StorageMap for storing ordered items? Basically inside a vector, the index would be an indicator of order ...
Purple_Turtle's user avatar
2 votes
1 answer
28 views

How to convert a u32 into a BoundedVec compatible format?

I am using a BoundedVec as the id for a storage map, and intend to transform a u32 value into a compatible format. Is there a streamlined way to accomplish this, or should I split the u32 into smaller ...
frkmnt's user avatar
  • 55
1 vote
2 answers
39 views

Update the way to limit a boundedvec

I've developing a pallet where I'm using the following custom data type to save a CID: types.rs pub type CID = BoundedVec<u8, ConstU32<100>>; I want to change the way I limit that ...
Didier M's user avatar
1 vote
1 answer
58 views

Substrate BoundedVec Error Cannot Borrow as mutable

I have substrate pallet structure as follows #[derive( Encode, Decode, CloneNoBound, PartialEqNoBound, Eq, RuntimeDebugNoBound, TypeInfo, MaxEncodedLen, ...
not 0x12's user avatar
  • 343
6 votes
1 answer
197 views

Prepare pallets for Weights v2

I am trying to prepare the pallets for Weights v2 at Encointer and a couple of questions arose. Where can I find documentation on what exactly has to be done in terms of bounded types? What is the ...
pifragile's user avatar
4 votes
2 answers
84 views

What should be the maximum size of a `BoundedVec`?

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, ...
Chralt's user avatar
  • 483
2 votes
1 answer
46 views

Does it make sense to convert Vec<Vec<u8>> to Vec<BoundedVec<u8, DescriptionLimit>>? [duplicate]

I have a scenario where I have to store multiple strings. For single string, we can use BoundedVec<u8, DescriptionLimit>, that's why I converted Vec<u8> into BoundedVec<u8, ...
Boleng's user avatar
  • 403
2 votes
1 answer
85 views

BoundedVec on ink!

BoundedVec is a vector where the length of the queue is always bounded, which is better than Vec for storage because it has a defined a maximum length. I recommend this StackExchange questions to ...
Alex Bean's user avatar
  • 5,014
1 vote
1 answer
47 views

How to store a bounded map inside `StorageValue`?

I need to query a specific account id associated with a Balance in a pool of 10_000 account ids. But I also need to iterate over all account ids in a reasonable amount of computation time. So my ...
Chralt's user avatar
  • 483
0 votes
1 answer
42 views

frame_benchmarking convert Vec to BoundedVec

I am unable to get benchmarks to work after changing an extrinsic argument from Vec<u8> to a custom type which is a BoundedVec defined in the pallet pallets config. Can someone provide me with ...
DJJ's user avatar
  • 53
0 votes
1 answer
37 views

How to benchmark huge bounded vectors?

I want to have a queue system in a pallet using a storage value and a bounded vector. /// Data related to tranmission queues. #[pallet::storage] #[pallet::getter(fn at_block_queue)] pub type ...
Leouarz's user avatar
  • 177
1 vote
2 answers
416 views

How to create a bounded vec from a normal vec?

Some pallet that I am configuring requires it's genesis configuration to have a BoundedVec. The problem I'm facing is getting to cast a Vec as a BoundedVec. How can I do this? I have taken care of ...
b0zero's user avatar
  • 502
3 votes
1 answer
56 views

What happens when a bounded vec in storage is fully populated and then its bound is reduced?

Consider the following scenario, where I have a BoundedVec which has bound parameter MaxItems. Now this MaxItems parameter would be configured in the runtime. pub type StorageItem<T: Config<I>...
Shoeb Siddiqui's user avatar
3 votes
1 answer
90 views

Error defining BoundedVec as a Pallet Storage the trait `Decode` is not implemented for `sp_runtime::BoundedVec

I have a StorageValue defined as follows #[pallet::storage] #[pallet::getter(fn reg_students)] pub type RegStudents<T: Config> = StorageValue<_, BoundedVec<StudentId, T:...
not 0x12's user avatar
  • 343
1 vote
0 answers
18 views

BoundedBTreeMap error with Debug trait

Consider the following snippet #[weight = 100_000_000] //TODO: update weights pub fn test( _origin, _outputs: frame_support::BoundedBTreeSet<JoyBalanceOf<...
mr_bovo's user avatar
  • 161
2 votes
1 answer
70 views

Why BoundedVec does not implement a Decode trait

A clear explanation will be appreciated as to why Decode trait is not implemented while encode is. What are the design reason for this?
Mrisho Lukamba's user avatar
2 votes
1 answer
76 views

Use BoundedVec in benchmark

I have some code that benchmarks one of my extrinsic. benchmarks! { create_supersig { let z in 0 .. 10; let alice: T::AccountId = get_account::<T>("ALICE"); ...
Timothée Delabrouille's user avatar
1 vote
0 answers
53 views

Extrinsic's string parameter lower bound validation

I want to validate the extrinsic string parameters like name, title, cid, etc. The type should be capable of min/max length validation. And checking the lower bound is impossible with the current ...
vovacha's user avatar
  • 148
5 votes
1 answer
95 views

Issue with #[pallet::generate_storage_info]

I was digging into substrate's storage_info macro https://docs.substrate.io/v3/runtime/macros/#palletgenerate_storage_info. To get hands dirty checked code from https://github.com/yourarj/substrate-...
Arjun's user avatar
  • 317
5 votes
2 answers
114 views

How to implement BoundedVec inside an extrinsic?

I need to check if an extrinsic matches "default" inside an extrinsic. The following works: let bv: BoundedVec<u8, T::StringLimit> = "default".as_bytes().to_vec().try_into()....
Brandon Macer's user avatar