Questions tagged [storage]

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

Filter by
Sorted by
Tagged with
1 vote
1 answer
35 views

How does parachain upgrade works?

Let we have a running parachain on kusama and want to do a runtime upgrade. New runtime is bigger then the old one by 100 kb. New runtime will be stored on the relay chain after runtime upgrade ...
Данила Алексеев's user avatar
2 votes
0 answers
24 views

How to fetch floating no in offchain worker?

I want to fetch the floating value in offchain worker. I'm using lite_json for http request. Api data: { "price": 0.5 } To fetch and store this price from api. I'm defining a struct: pub ...
Deepak Chaudhary's user avatar
1 vote
1 answer
22 views

try_mutate compared to getting & setting

As I understand transactional storage, an error result from an extrinsic reverts any state changes by default (assuming no without_transactional macros or suchlike). Some feel that because of this, ...
Shannon Wells's user avatar
0 votes
1 answer
30 views

Limit and Offset for for storage entries and keys

Following the docs for polkadot js storage we are getting entries and keys from the chain. Is there a way to use limit and offset to implement paging. Any ideas?
donkeydonkey's user avatar
0 votes
0 answers
6 views

How is the performance of the storage layer?

Here are two pieces of code: fn f() { (0..1000).for_each(|_| { let x = <X<T>>::get(); g(x); }); } fn f() { let x = <X<T>>::get(); (0.....
AurevoirXavier's user avatar
2 votes
1 answer
39 views

How to define a storage outside the pallet?

I recall there being a method to create a "const" storage outside of a pallet. You have the flexibility to assign any prefix. However, I can't remember where I came across this information. ...
AurevoirXavier's user avatar
0 votes
0 answers
47 views

move_pallet: What is correct way to verify old pallet storage is deleted

In trying to use a migration implementation for substrate which can be used to rename BagsList to VoterList, using move_pallet a post migration check is failing when testing the migration with try-...
Mokhtar Naamani's user avatar
2 votes
2 answers
83 views

How to Retrieve Value by Single Key from StorageDoubleMap in Substrate?

I'm developing a Substrate-based blockchain and using StorageDoubleMap to store label details. The StorageDoubleMap is defined as follows: #[pallet::storage] #[pallet::unbounded] #[pallet::getter(fn ...
Mr Coder's user avatar
  • 883
0 votes
1 answer
46 views

How to get typed keys when querying a storage map via subxt

The example here https://github.com/paritytech/subxt/blob/master/subxt/examples/storage_iterating.rs use subxt::{OnlineClient, PolkadotConfig}; #[subxt::subxt(runtime_metadata_path = "../...
Damian's user avatar
  • 3
1 vote
1 answer
27 views

Handling Nested Option Types in StorageDoubleMap::iter_prefix Method

I am building a Substrate pallet where I have a storage item defined as a StorageDoubleMap: #[pallet::storage] #[pallet::unbounded] #[pallet::getter(fn labels)] pub(super) type Labels<T: Config> ...
Mr Coder's user avatar
  • 883
1 vote
2 answers
35 views

How many ways are there to get all items stored in custom pallet

I would like to know what are the ways and how we can retrieve the all items stored in a custom pallet I was having data structured in this way #[derive( Clone, Encode, Decode, Eq, PartialEq, ...
Mojo's user avatar
  • 95
1 vote
1 answer
36 views

Storage Migrations on Rococo?

GM everyone, has anyone noticed storage migrations stopped running on rococo? We are on 0.9.43 and can not get migrations to run, both through the pallets or the runtime running trace logs doesn't ...
Sam Elamin's user avatar
  • 1,203
0 votes
1 answer
66 views

how to remove Mapping storage when tuple is used as input

Lets assume we have an ink! smart contract On a vanilla Mapping alpha: Mapping<[u8;32], Astruct> we can use self.alpha.remove(&somehash) My question is this: if we have the following ...
Sokrates's user avatar
  • 409
0 votes
1 answer
21 views

Query Tokens.Accounts storage function using py-substrate-interface

I'm trying to fetch asset balances in accounts for various assets using py-substrate-interface. I know I can query the Tokens.Accounts storage function but I'm not sure which params I need to pass to ...
Pranay's user avatar
  • 141
1 vote
1 answer
18 views

How to get rid unused storage?

Let's say we get rid of a pallet after a runtime upgrade. My question is do the storage keys related to the now removed pallet just get pruned away automatically or is there some kind of manual ...
Purple_Turtle's user avatar
3 votes
1 answer
50 views

Dispatch of extrinsic that has prevalidate function which emits events and modifies storage

TLDR: How to implement a substrate unsigned call, which performs storage modifications and emits events during it's validation? If transaction fails, it seems like it leaves garbage in runtime, due ...
Klapeyron's user avatar
  • 111
1 vote
1 answer
40 views

Preventing Duplicate DB Reads

If an extrinsic performs the same storage read twice (e.g. same storage map read with same key), under which conditions is the duplicate DB read optimized away by substrate's storage layer? Where are ...
mkl's user avatar
  • 420
1 vote
1 answer
30 views

How to entirely clear a pallet storage on a living chain?

Would it be possible to clear a pallet storage with a call on a live chain ? Precisely I would like to remove all contracts and code hash existing on my chain (as sudo).
SailorSnoW's user avatar
3 votes
1 answer
63 views

What is a Storage Deposit?

When developing ink smart contracts, I've often seen a Storage Deposit charge. What is this, and how does it relate to contract storage? My guess is it's a charge related to the size of the contract's ...
goastler's user avatar
  • 549
0 votes
0 answers
22 views

Can a Substrate Runtime bulk-read many storage keys at once?

This question is about the Substrate host functions and storage implementation and is not specific to FRAME (although relevant FRAME-related information is welcome). Imagine that the runtime knows it ...
JoshOrndorff's user avatar
  • 1,125
0 votes
0 answers
15 views

How to compute storage growth after some arbitrary code execution?

I am working on implementing a new feature to limit the storage growth for a Substrate-based chain. As part of this feature, I need to compute the storage growth after executing arbitrary code. What ...
Ahmad's user avatar
  • 1
2 votes
0 answers
30 views

Are onchain storage reads cheaper from offchain worker versus from extrinsic?

Are reads from offchain workers less expensive than reads from extrinsics? I am determining how to do some large, asynchronous processing of data and determining whether the reads in this process see ...
Justin Frevert's user avatar
3 votes
1 answer
47 views

How we can iterate over all items in a storage map?

I have a storage in pallet pub type Users<T: Config> = StorageMap<_, Blake2_128Concat, T::AccountId, User>; I need to iterate over all the storage map to check a field data inside the ...
Pankaj's user avatar
  • 1,896
3 votes
2 answers
39 views

Is it possible to bootstrap a parachain node from pre-existing solo chainstate?

Let's imagine a scenario where a team is running a substrate private network and have all their chainstate that they want to move to a parachain after acquiring a slot. My question is, when the team ...
Purple_Turtle's user avatar
0 votes
1 answer
53 views

How to trace XCM messages for all parachains

Is it possible to trace XCM messages (origin para and account id, destination para and account id, instruction and parameters) just utilizing the relay chain storage? If not, what is the simplest way ...
kukabi's user avatar
  • 543
0 votes
1 answer
35 views

Subscribe to storage map Entries?

On our substrate node using a storage double map. We are trying to subscribe to an entries query. something like const unsub = await api.query.system.balances.entries(ADDR, (res) => { console....
donkeydonkey's user avatar
0 votes
1 answer
20 views

error: Invalid generic declaration, trait is defined with instance but generic use none

I want to make a storage for the pallet but I'm getting this error /// The target parachains to ping. #[pallet::storage] pub type Targets<T:Config> = StorageValue< _, BoundedVec&...
Arunjot Singh's user avatar
1 vote
1 answer
37 views

Is there an `OrderedMapping` storage type available in ink?

I'm new to ink! smart contracts, and trying to figure out how to set up my storage. I have a basic DAO. The DAO has members, and each member has a score (a u128) associated. So far a mapping sounds ...
JoshOrndorff's user avatar
  • 1,125
0 votes
1 answer
70 views

Is there any way to access the storage of another pallet in Substrate-based blockchain?

I'm trying to transfer the collection ID from relay chain to a parachain. I am currently accessing the collectionId from its storage, and I am wondering if there's a way to access the storage of the ...
Arunjot Singh's user avatar
5 votes
1 answer
64 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
  • 549
6 votes
1 answer
23 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
3 votes
1 answer
17 views

Query chain for types in a storagemap

I want to get the meta function description of pallets storage maps. Returning an output like this: { Twox64Concat, [u8; 16], u32 } = query.storagemap(pallet: "template", storagemap: "...
flipchan's user avatar
  • 319
3 votes
1 answer
92 views

Is it possible to use a flat structure storage in the Runtime?

The Runtime storage in Substrate is based on a tree structure rather than a flat structure. While this allows for efficient integrity verification, it incurs data retrieval overhead. According to the ...
Dan's user avatar
  • 31
1 vote
0 answers
31 views

Fetching offchain storage value returns different value than the value fetched using localStorageGet function

I need to get the rpc_url value set initially from the explorer. The localStorageGet rpc function returns the correct value of the rpc_url. This returns https://eth-mainnet.g.alchemy.com/v2/MY_API_KEY ...
strider's user avatar
  • 11
4 votes
1 answer
118 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
  • 395
2 votes
0 answers
56 views

Why Hosts set storage information directly and not through the Runtime

Why Host set storage information directly and not through the Runtime api? (e.g. Grandpa Authorities, Accounts, Code, Heap_Pages) Is this an expected behavior or legacy?
user2862's user avatar
  • 309
4 votes
1 answer
51 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
  • 549
4 votes
1 answer
34 views

What is the best practice to change on-chain storage from asynchronous task?

I want to change some of the on_chain data after running some asynchronous task running in task_manager. What is the best way to achieve this? Thanks
Rusty Pythonic Script's user avatar
4 votes
1 answer
44 views

Change state from a task

I have a asynchronous task running in service.spawn_essential_task(task). Which does some stuff and wants to write data in storage. How can i achieve this? Changing state by making runtime_apis to ...
Guest's user avatar
  • 43
4 votes
1 answer
46 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
3 votes
0 answers
30 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
  • 83
3 votes
1 answer
33 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
  • 413
3 votes
2 answers
28 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
5 votes
1 answer
50 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
  • 549
6 votes
0 answers
70 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
  • 549
3 votes
1 answer
70 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
  • 608
2 votes
1 answer
39 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
4 votes
2 answers
164 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
3 votes
1 answer
48 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
2 votes
1 answer
78 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
  • 8,140

1
2 3 4 5