Skip to main content

Questions tagged [storage]

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

Filter by
Sorted by
Tagged with
13 votes
2 answers
385 views

Is there a limit to the size of a map in Pallet storage?

If we are using a single or double maps in our pallets to store data on-chain, is there a limit to the number of records or size of one individual map? I understand we should be storing the minimal ...
moolimike's user avatar
  • 345
12 votes
1 answer
73 views

Automatically generating storage setter

When declaring storage items inside the runtime, we can automatically generate getters to query that storage item, for example (https://docs.substrate.io/v3/runtime/storage/#declaring-`storage-items`)`...
Dominik Harz's user avatar
12 votes
1 answer
74 views

Multiple remove_all calls in same block

I stumbled upon an unexpected behavior when doing storage migration. Problem Description I want to clean-up a large DoubleStorageMap in multiple steps. And that works just fine, however I also want to ...
Dinonard's user avatar
  • 597
11 votes
1 answer
323 views

How expensive is it to access storage items?

How expensive are storage reads and writes? Does the cost depend on the size of the item?
Oliver Tale-Yazdi's user avatar
11 votes
2 answers
459 views

How to use bounded vector for storage

I'm trying to use BoundedVec from frame_support for one of my storage items like this, pub(super) type Payloads<T: Config> = StorageMap<_, Blake2_128Concat, T::BlockNumber, Vec<Payload>,...
Faisal Ahmed's user avatar
10 votes
1 answer
138 views

How to manually remove storage items using Sudo?

I'm trying to remove a storage item on the relay chain, specifically a futureCode entry for a parachain. I've seen that there's an extrinsic I can call system.killStorage(keys), however I have some ...
Santiago Balaguer's user avatar
9 votes
3 answers
133 views

How to limit the number of values by prefix in StorageDoubleMap?

Say I have a StorageDoubleMap that stores Data structs for each user and ContextId #[pallet::storage] pub type Info<T: Config> = StorageDoubleMap< _, Blake2_128Concat, ...
Angelo's user avatar
  • 501
9 votes
0 answers
104 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
  • 579
8 votes
2 answers
258 views

What's the overhead associated with the `#[transactional]` macro?

Substrate has a macro, #[transactional], to ensure that any modifications to storage are not persisted in case of an error during execution. I imagine there's some sort of caching done before ...
HCastano's user avatar
  • 1,091
8 votes
2 answers
220 views

How to check if StorageMap is empty?

I have created a simple storage map as follows and I just want to check if it's empty or not. I am comparing it with rust HashMaps, it has the is_empty() method to check. I intend to use this in the ...
salman01z's user avatar
  • 537
8 votes
1 answer
243 views

Generating a Storage Key when making an RPC request

I'm trying to make an RPC call to a Substrate node, but I can't generate a proper Storage Key. The Module and Method parts are fine, the problem is the Twox64Concat part. The sp_core::twox_64 of value ...
Amir Boziev's user avatar
8 votes
3 answers
233 views

Smart contract to IPFS communication

Assuming I was deployed a smart contract in a Parachain EVM wanting to cross out to IPFS to save or read data, what is the best way of achieving this in a decentralised way. For example, doing this ...
Sokrates's user avatar
  • 421
7 votes
1 answer
64 views

How can I check whether a specific storage item was already accessed in the current block?

Inside a FRAME runtime I want to check whether a specific storage item was already read in the current block. Reason is to determine the impact of storage accesses across the extrinsics of a block ...
Alexander Theißen's user avatar
7 votes
1 answer
270 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
7 votes
2 answers
133 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
6 votes
1 answer
122 views

What are good use cases for child tries

After reading the substrate documentation: Child tries are useful when you want your own independent trie with a separate root hash that you can use to verify the specific content in that trie. ...
olanod's user avatar
  • 531
6 votes
1 answer
71 views

Is the full Merkle Trie copied in every block along with updates?

In the example given here: Does each block save a copy of a Storage item? Is the Merkle Trie copied to every block or is it the "diff" of the Merkle Trie that is updated on the new block? ...
Bruno's user avatar
  • 8,455
6 votes
1 answer
148 views

How does `#[codec(mel_bound())]` work?

When declaring types, with generic parameters, to be stored in runtime storage, it’s common to see this pattern #[derive(Encode, Decode, MaxEncodedLen, TypeInfo)] pub struct MyItem<TypeA, TypeB> ...
Angelo's user avatar
  • 501
6 votes
1 answer
86 views

Complexity of StorageDoubleMap::remove_prefix

The official documentation of StorageMaps states An implementation of a map with a two keys. It provides an important ability to efficiently remove all entries that have a common first key. https://...
Bedeho Mender's user avatar
6 votes
1 answer
62 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
  • 579
6 votes
1 answer
75 views

What kind of information is stored in the State Trie?

I have read https://docs.substrate.io/v3/advanced/storage And I am curious what is actually stored in the State Trie. Are extrinsics and events stored in the State Trie?
Bruno's user avatar
  • 8,455
6 votes
1 answer
49 views

How i define a 1 to N relation in storage?

i'm trying to define a 1 to N storage relation in my pallet. I have a Resource (owned by an account ) which will be linked to N Use structs ( kind of a set ) - Account #1 --> Resource #A ...
Dark Forest's user avatar
6 votes
1 answer
26 views

Nested runtime Api's `fn execute_in_transaction` calls no longer supported in v0.9.42?

When upgrading our codebase on top of substrate's polkadot-v0.9.42, we discovered it is no longer possible to make nested request to fn execute_in_transaction(call), from within the call. Given in ...
vanderian's user avatar
5 votes
1 answer
190 views

Migrate keytype of StorageMap without breakin API

Assume we have a StorageMap MyMap of which we want to extend the type of the decoded keys from KeyTypeOld to an enum including the old type as well as a new one. Before pub type MyMap = StorageMap<...
William Freudenberger's user avatar
5 votes
1 answer
139 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
  • 327
5 votes
1 answer
283 views

How to weight `on_initialize`?

Is there any best practice how to count the weights in on_initialize correctly? I read through the Polkadot and Substrate on_initialize weight calculations and couldn't always figure out: When to ...
Chralt's user avatar
  • 543
5 votes
1 answer
153 views

How to create an iterator for a child storage trie?

I have a Storage Map which I am using to to store structs and a Storage Value to use for indexing this: #[pallet::storage] #[pallet::getter(fn consequences)] /// Storage map holding basic Consequence ...
jpataylor's user avatar
  • 321
5 votes
1 answer
84 views

How do I upgrade an ink contract with storage changes?

Let's say I have a simple/contrived ink contract: #[ink(storage) pub struct MyContract { a: u8, b: u8, } Now let's say it's in production and a == 1 and b == 2. I've done some work and ...
goastler's user avatar
  • 579
5 votes
2 answers
455 views

Storage Migration Guide Using #[pallet::storage]

I am new to both substrate and rust so trying to educate myself. I've the read documentation for both and am now going through the various tutorials and guides. I'm currently on the Basic Storage ...
jpataylor's user avatar
  • 321
5 votes
1 answer
44 views

Is the fully constructed State Trie persisted to disk?

On Substrate, is the fully constructed State Trie persisted to disk or only the State Trie root hash?
Bruno's user avatar
  • 8,455
5 votes
1 answer
54 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
  • 579
5 votes
2 answers
83 views

How to determine if a parachain runtime migration is too big?

I want to write runtime storage migration for our parachain. This time it will scan large storage maps with more than 10k entries. This may results in very large PoV block size. I'm wondering what the ...
h4x3rotab's user avatar
  • 732
4 votes
2 answers
396 views

StorageHasher: Blake2 vs Twox

When creating a StorageMap, a hashing algorithm needs to be chosen for the StorageHasher. frame_support provides a few options: Identity Blake2_128 Blake2_128Concat Blake2_256 Twox64Concat Twox128 ...
Bernardo Rodrigues's user avatar
4 votes
2 answers
155 views

Can I return a custom value from an extrinsic call

Looking at the docs, it seems I can only return custom weights in dispatchables I want to be able to create data in storage then return the ID, because we will be calling the chain from a UI/Dapp I am ...
Sam Elamin's user avatar
  • 1,233
4 votes
2 answers
96 views

Does each block save a copy of a Storage item?

This is what I read from the substrate storage docs: https://docs.substrate.io/v3/runtime/storage/ Runtime storage allows you to store data in your blockchain that is persisted between blocks and can ...
Minh Mốc's user avatar
  • 1,009
4 votes
2 answers
254 views

How key-values database and Merkle Tree works together on Substrate

I have been looking deep dive into Substrate and trying to understand things behind the hood, especially storage API. I am really keen to explore more in the Merkle abstraction between Storage API and ...
lucycollins's user avatar
4 votes
2 answers
155 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
4 votes
1 answer
177 views

How do I fix "SpecVersionNeedsToIncrease" error?

I Just clone this https://github.com/OAK-Foundation/substrate-node-template/tree/nicks-v2 for storage migration. After launch on polkadot ,this error shows: I'm using following commands to run: ./...
Deepak Chaudhary's user avatar
4 votes
2 answers
447 views

access storage map from another pallet without trait pallet Config

I have one pallet with a storagemap that I want to use/call with another Pallet. After doing some research I ran over Centrifuge fudge project(https://github.com/centrifuge/fudge/blob/...
flipchan's user avatar
  • 369
4 votes
1 answer
139 views

BTreeMap storage type

I would like to store a large amount of sorted integers, they should be traversable with efficient get and insert. If I can iterate over a storage map, could you let me know how? Or is there a ...
Saman H. Pasha's user avatar
4 votes
1 answer
216 views

How to convert Account ID into Account Bytes in Hex using polkadot js?

I'm following this article about substrate keys. And I was unable to convert the account ID to account bytes in hex as it guides: from this: Account ID ...
Xavier's user avatar
  • 417
4 votes
2 answers
325 views

How to build prefixed key for rocksdb

I would like to know how can the key for the state System Events storage can be built for a given block hash/height
helmeseanu's user avatar
4 votes
1 answer
124 views

Best Decentralised Storage for parachain?

Can anyone please explain what is the best decentralized storage protocol for storing pdf/images data on Polkadot parachain? Actually, I gone through filecoin, Crust and Cess. Now I'm little confused ...
Pankaj's user avatar
  • 2,051
4 votes
1 answer
62 views

How much do data structures contribute towards ink contract storage size?

I've used Mapping, BTreeSet, BTreeMap and Vec for various purposes in our ink contract and have observed the contract size fluctuating based on usage of these four data structures. This leads me to ...
goastler's user avatar
  • 579
4 votes
2 answers
213 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
4 votes
1 answer
103 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 ...
Non-named's user avatar
  • 304
4 votes
1 answer
86 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
  • 543
4 votes
1 answer
112 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
  • 132
4 votes
1 answer
131 views

How do I recover quickly if the number of healthy nodes for my parachain reaches zero?

I'm particularly interested in the role of backups and state stored on disk in the recovery process. In terms of preparations, we are early enough in our project lifecycle to put in place whatever ...
beyond-code's user avatar
4 votes
1 answer
64 views

Are there ways to suppress blockchain growth rate (in terms of storage)?

So during my testing I found out that with just 1 node running, on an npos consensus, my chain grew from 110 Mb to 990 Mb within two days. Is this expected? Are there strategies for controlling the ...
Purple_Turtle's user avatar

1
2 3 4 5