Questions tagged [storage]

Questions about storing and accessing stored data on a Substrate blockchain.

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

Pallet generate store is deprecated how to avoid this warning and compile the code?

I am getting error in #[pallet::generate_store(pub(super) trait Store)] which is showing deprecated warning due to which I could not compile my custom pallet is there any solution
Parth Kohli's user avatar
2 votes
0 answers
14 views

How to migrate / backup & restore ink smart contract storage?

Is there a way to backup ink smart contract storage and later restore on another chain? Lets say we have chain with 3 validators and deployed smart contract containing certain information in its ...
Alex 's user avatar
  • 53
1 vote
1 answer
23 views

Is there a way to render all values of a storage in drop down through Polkadot JS UI?

I have a scenario where I have to enter all values of a storage in drop down through Polkadot JS UI. Suppose I have a pallet TestPallet and an extrinsic rate. There are two storage Items and Rating. ...
Boleng's user avatar
  • 179
1 vote
2 answers
21 views

`BoundedBTreeMap` equivalent for `StorageMap`?

I'd like to set an upper limit on the size of a storage map. Is there a data structure that supports this check within its methods? Or has anyone defined their own wrapper data structure that performs ...
Daniel Savu's user avatar
3 votes
1 answer
27 views

Fixed size array in ink smart contract storage

How can I have a fixed size array in my ink smart contract storage? E.g. // Contract storage #[ink(storage)] pub struct MyContract { myArray: [u8; 64] } I get "the trait ...
goastler's user avatar
  • 186
3 votes
0 answers
23 views

What are the size limits of contract storage in ink?

Whilst reading the docs for ink I came across this warning: CAUTION If any type exhibiting Packed layout gets large enough (an ever-growing Vec might be a prime candidate for this), it will break ...
goastler's user avatar
  • 186
2 votes
1 answer
60 views

Is it safe to use `Const-Generic` structure in runtime storage? [closed]

When declare pubkeys field as generic-const-array here as following #[derive(Clone, PartialEq, Eq, Encode, Decode, TypeInfo, MaxEncodedLen)] pub struct SyncCommitteePrepared<const COMMITTEE_SIZE: ...
Ron's user avatar
  • 552
1 vote
1 answer
25 views

can't use BTreeMap with custom key struct for offchain Local Storage

I'm trying to use sp_std::collections::btree_map::BTreeMap for offchain worker Local Storage. While let foo = StorageValueRef::persistent(b"bar::foo"); foo.get::<BTreeMap<u32, u32>&...
Yury Yukhananov's user avatar
3 votes
2 answers
87 views

Read a value from offchain storage of a node

I want to read a single value from OffchainStorage of a live substrate node. Is it possible? Assume I can not use localStorageGet rpc request because it is an unsafe rpc.
Matt Duncan's user avatar
2 votes
1 answer
28 views

Reading from storage in weight annotation

We have an extrinsic where the complexity is dictated by the number of items held in storage. Is it appropriate to read from storage in the weight annotation? See for example: pub trait Tree<...
Gregory Hill's user avatar
1 vote
1 answer
21 views

What is Dev Mode? And how can I use it?

I heard there is something called Dev Mode in Substrate for pallet development. What is Dev Mode? And how can I use it?
Bruno's user avatar
  • 6,851
4 votes
1 answer
130 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
3 votes
1 answer
43 views

How to iterate a large `StorageMap` over multiple extrinsic calls?

Hey valuable Substrate community, I am running into the problem that I need to iterate over an unbounded StorageMap. So I need an IterationLimit and use an extrinsic which gets called multiple times. ...
Chralt's user avatar
  • 363
0 votes
1 answer
28 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
  • 179
1 vote
1 answer
31 views

How to store offchain mutable values

are there offchain storage options in substrate, like a regular database(like mongodb or mysql), i dont want to use something else and just stick with something supported with substrate stack. the ...
dadzerlaze's user avatar
2 votes
1 answer
34 views

All pallets requires storage deposit to operate extrinsics?

Storage deposit is for economic security as explained here. All storage usage (not only pallet_balances, frame_system account info, pallet_preimage, pallet_contract's contract storage for e.g.) is ...
Shunsuke's user avatar
  • 392
1 vote
1 answer
72 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
  • 3,415
2 votes
1 answer
43 views

What is a storage cell?

Somewhat noob question: I see the term storage cell talked about a lot on here (mostly regarding Mapping and Lazy), however I cannot find any documentation about it. What exactly is a storage cell? ...
goastler's user avatar
  • 186
4 votes
1 answer
47 views

Are Vec<T> stored with unused space in ink?

I'm using a Vec<T> in ink!. When allocating elements to the vec, the underlying array may be resized to provide a constant amortised push complexity of O(1). This means that sometimes the vec ...
goastler's user avatar
  • 186
3 votes
1 answer
19 views

Why do some storage items use the static type and others not?

In the various frame pallets in substrate there are two ways of declaring storage. For example some pallet storage is declared with <T: Config> while others are declared <T: Config<I>, ...
T9b's user avatar
  • 406
2 votes
1 answer
41 views

nextAuthorities() output clarification from Babe storage event

Good evening, I am trying to parse the output hash of nextAuthorities details retrieved by storage function. I would like to know how to parse the output sent per validator, is it an hashproof ...
a_dotter's user avatar
1 vote
1 answer
22 views

TwoX128 hash for rpc.state.metadata pallet names not being a prefix for storage key

Following this tutorial: https://www.shawntabrizi.com/substrate/querying-substrate-storage-via-rpc/ we should have that a pallet named "Members" should have prefix "...
mr_bovo's user avatar
  • 131
1 vote
2 answers
22 views

What is simplest way to get native holders distribution?

I want to setup some democracy on one chain. Democracy is voting with tokens. So it is important to know if tokens distributed well enough. I looked into some tools and indexers, none provided such ...
Dzmitry Lahoda's user avatar
1 vote
1 answer
49 views

How can I store the historical values of something at all prior blocks in my pallet?

I want to implement a history mechanism in my pallet, so that I can access the value that something had at all prior blocks, like in this Extension of ERC20 to support Compound-like voting and ...
deep-ink-mas's user avatar
0 votes
2 answers
25 views

How to access StorageValue without getter function in tests?

I have the following StorageValue: #[pallet::storage] #[pallet::getter(fn something)] pub type Something<T> = StorageValue<_, u32>; With the getter function I can access it like this in ...
Bruno's user avatar
  • 6,851
0 votes
1 answer
39 views

How do you perform a state query in a unit test?

In a custom Substrate pallet unit test, I need to get a list of governance proposals using the chain state. I have used Polkadot JS to query state before but not from within a Substrate unit test in ...
Robert La Ferla's user avatar
1 vote
1 answer
23 views

How to select n random keys from a `StorageMap`?

Assume I have the following storage map: ZAccounts: StorageMap(AccountId -> AccountInfoOf<T>) Is there a simple way to draw n AccountId's randomly. I assume that I already have a secure ...
Chralt's user avatar
  • 363
1 vote
1 answer
46 views

What does `no particular order` mean for storage iterations?

I am always curious what the documentation for the storage means when I see the following. Enumerate all elements in the map in no particular order. https://paritytech.github.io/substrate/master/...
Chralt's user avatar
  • 363
1 vote
1 answer
61 views

Encrypting substrate storage

Is there a way of encrypting substrate storage using the root key pair? Or is there anyway of making on chain data private to everyone but the system. thanks
gatsey's user avatar
  • 141
0 votes
1 answer
29 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
  • 57
1 vote
2 answers
51 views

the trait bound `<T as frame_system::Config>::AccountId: pallet::Config` is not satisfied

I'm trying to design a custom pallet with bounded vectors, but I want to leave the user to define the size of the bounds according to their implementation, so I use the next type: pub trait Config:...
be344's user avatar
  • 31
1 vote
3 answers
212 views

Can I store a HashMap in StorageMap?

I need to use HashMap in my struct that I store in StorageMap. As I searched online and other Substrate pallets, I didn't see that being used. I came across use scale_info::prelude::collections::...
Burak's user avatar
  • 773
1 vote
1 answer
28 views

Is there any alternative for thread_local! in substrate?

I what to use thread_local! in substrate. I aware about Storage ;) I want to store temporary data for unit tests. without thread local it does not work property. thread_local! { static COINS: ...
Rust Dev's user avatar
  • 313
0 votes
2 answers
42 views

Where can I find documentation for `assimilate_storage` function?

[question originally posted on polkadot forum but moved here since it seems to be considered a more appropriate place] I do not find documentation for the assimilate_storage function anywhere in the ...
Hugo Trentesaux's user avatar
1 vote
2 answers
32 views

Number of and writes of StorageMap drain

I was wondering about the number of reads and writes when draining a StorageMap which consists of n items. Is the answer (n, 1) or (n, n)?
0x5hmoo's user avatar
  • 107
2 votes
1 answer
69 views

What is a substate contracts max storage size? using the contracts pallet

Just to clarify, I am not asking about the max upload size of a contract. I am able to upload my contract to my chain no problem. I have two smart contracts (A,B) A calls a transaction on smart ...
BRNHINLT's user avatar
1 vote
2 answers
24 views

How to change one of the two `StorageDoubleMap` keys?

Say I have a StorageDoubleMap like this pub type Users<T: Config> = StorageDoubleMap<_, Twox64Concat, Vec<u8>, Twox64Concat, Compact<u64>, Person<T::AccountId>,>; where ...
Alessandro Baffa's user avatar
0 votes
1 answer
20 views

Build StorageProof for Benchmarks

Having some issues in fabricating a realistic StorageProof in substrate benchmarks. I can't use std and most examples are using std in tests via sp_state_machine. Currently, I've hard coded the (root, ...
nbaztec's user avatar
  • 187
2 votes
1 answer
68 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:...
0x12's user avatar
  • 243
2 votes
1 answer
26 views

FastTrack proposal execution fails with "ProposalMissing" but is stored in democracy.publicProps

I am trying to test Fast Track of proposals via PolkadotJS dashboard, but I'm running into an error I can't explain. Note this is on a local relay chain where we have set up various members of Alice.....
Shannon Wells's user avatar
1 vote
1 answer
31 views

How to specify "register" values for storage reads/writes in a runtime?

Is there such a thing in FRAME or otherwise to have a "register" item similar to C referencing a storage item in working runtime memory? Specifically: I need a storage value in ...
Nuke's user avatar
  • 1,692
1 vote
1 answer
42 views

Ink Contracts: What Data Structures/Situations Are Best Suited To Contract Storage vs Events?

Using events to write data to the chain is great for registering information to the chain, especially information that you want a permanent record of. So my question is: under what circumstances ...
KathrynColleen's user avatar
0 votes
1 answer
36 views

State/storage does not get mutated [duplicate]

I have the following case: let contract = Invoice { origin: from.clone(), to: to.clone(), amount, status: false, id: 17, msg: msg.clone(), }; let mut invoice_vec: Vec<Invoice<T::...
P.E's user avatar
  • 121
3 votes
1 answer
64 views

What are the fees associated with ink! contract deployment?

I see that there are many events emitted during the process of deploying my contract on Substrate local chain (SNOW Network to be specific). 4 ICZ was reserved from deployer account 1 ICZ & 2 ICZ ...
Bukks's user avatar
  • 274
1 vote
2 answers
60 views

The correct way to make a non-extrinsic function execute in a storage layer?

I would like to know how to make non-extrinsic function (trait or otherwise) execute in a storage layer, such that if the function fails with an error, all the storage changes made by the function and ...
Shoeb Siddiqui's user avatar
2 votes
2 answers
91 views

How to write pallet rename data migration?

I want to rename one of our collective pallet instances to be visible in the PolkaddotJs App. I think the best option would be to migrate raw data. I assume that all pallet data has the same trie path ...
Dzmitry Lahoda's user avatar
2 votes
1 answer
52 views

Is it possible to access a specific pallet's storage item in the function `<Runtime as TaggedTransactionQueue<Block>::validate_transaction()`?

I want to access a specific pallet's storage item (for example: a StorageMap or StorageValue) in the function <Runtime as TaggedTransactionQueue<Block>::validate_transaction() (note: this ...
aang114's user avatar
  • 43
1 vote
1 answer
30 views

how to test for storage leaks in pallets

Storage leaks in runtimes can be very damaging and cleaning up with a runtime update migration is non-trivial. I'd like to ensure the absence of storage leaks already in unit testing. My strategy ...
brenzi's user avatar
  • 433
1 vote
0 answers
26 views

Elections phragmen migration

I am working on Substrate-based node upgrades for solo-chain. I stick to Polkadot releases and during the upgrade from polkadot-release-v0.8.27 to polkadot-v0.8.28 I found a storage migration. This ...
Maksim Ramanenkau's user avatar
6 votes
2 answers
88 views

How to identify node update storage migrations?

I am working on Substrate-based node upgrades. I stick to Polkadot releases and start from polkadot-v0.8.25 to the latest versions. While upgrading I need to make sure that I don’t miss any storage ...
Maksim Ramanenkau's user avatar