Questions tagged [storage]
Questions about storing and accessing stored data on a Substrate blockchain.
209
questions
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, ...
0
votes
1
answer
17
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?
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.....
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. ...
0
votes
0
answers
45
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-...
2
votes
2
answers
80
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 ...
0
votes
1
answer
35
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 = "../...
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> ...
1
vote
2
answers
31
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, ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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).
3
votes
1
answer
59
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 ...
0
votes
0
answers
21
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 ...
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 ...
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 ...
3
votes
1
answer
44
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 ...
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 ...
0
votes
1
answer
51
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 ...
0
votes
1
answer
34
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....
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&...
1
vote
1
answer
35
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 ...
0
votes
1
answer
67
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 ...
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 ...
6
votes
1
answer
22
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 ...
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: "...
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 ...
1
vote
0
answers
30
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
...
4
votes
1
answer
108
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
...
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?
4
votes
1
answer
49
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 ...
4
votes
1
answer
33
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
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 ...
4
votes
1
answer
43
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
3
votes
0
answers
29
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 ...
3
votes
1
answer
32
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.
...
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 ...
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 ...
6
votes
0
answers
67
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 ...
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: ...
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>&...
4
votes
2
answers
155
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.
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<...
2
votes
1
answer
76
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?
6
votes
1
answer
219
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 ...
4
votes
1
answer
66
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.
...