Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage requirements using BoundedVec by default #782

Open
sacha-l opened this issue Jan 20, 2022 · 0 comments
Open

Storage requirements using BoundedVec by default #782

sacha-l opened this issue Jan 20, 2022 · 0 comments
Assignees
Labels
new content 💡✍️ New Devhub content required.

Comments

@sacha-l
Copy link

sacha-l commented Jan 20, 2022

We need to document the change in Substrate that's just been merged: paritytech/substrate#10662

Pallets require that all vectors in runtime storage are bounded, meaning that they must use the BoundedVec type and specify a max value constant. For example:

	/// The description of each child-bounty.
	#[pallet::storage]
	#[pallet::getter(fn child_bounty_descriptions)]
	pub type ChildBountyDescriptions<T: Config> =
		StorageMap<_, Twox64Concat, BountyIndex, BoundedVec<u8, T::MaximumReasonLength>>;

To override this default behaviour, developers must add the without_storage_info attribute to their pallets:

	#[pallet::pallet]
	#[pallet::generate_store(pub(super) trait Store)]
	#[pallet::without_storage_info] 
	pub struct Pallet<T>(_);

Bounded storage items is important because if any Vec gets too big it can lead to:

  • Running out of wasm memory loading that vec for a solo chain / relay chain (which happened with staking on Polkadot a while back)
  • Running out of PoV space for a parachain validation block (only 5mb available per block)

Just like computation, memory / storage space is also a bottleneck for blockchains. For relay chains, bounded vectors are used to compute the PoV proof size and to ensure that the size of a proof-of-membership set in a vector doesn't grow unbounded. Users can still opt out of writing things bounded using the without_storage_info attribute. However they are encouraged by the compiler to ensure their storage is bounded.

@sacha-l sacha-l added the new content 💡✍️ New Devhub content required. label Jan 20, 2022
@sacha-l sacha-l self-assigned this Jan 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new content 💡✍️ New Devhub content required.
Projects
None yet
Development

No branches or pull requests

1 participant