Questions tagged [storage]
Questions about storing and accessing stored data on a Substrate blockchain.
237 questions
0
votes
1
answer
87
views
Definition of storage map for stored items
In the tutorial of learning substrate, a storage map for stored items is defined as follows, in which the symbol => appears, but this specification is not in the standard syntax of rust. How to ...
0
votes
2
answers
80
views
Are both of them same StorageMap?
I found this puzzle in my last question, which is from one answer of my question.
There are at least two StorageMap structs in substrate framework.Their links are listed below:
https://paritytech....
0
votes
1
answer
62
views
How to access storage items using polkadot js, javascript playground [closed]
As when i try to to do api.query.templatemodule.get_something() it shows errors in the console
0
votes
1
answer
18
views
the trait bound `I: scale_info::TypeInfo` is not satisfied
I am writing Pallet which has generic parameter T and static parameter I, but as soon as I wish to create storage for Struct with generic parameter T I receive tons of errors. What am I doing wrong?
...
0
votes
2
answers
68
views
How to get the validators list?
Is it possible to get the list of validators which validate a particular block?
For instance, let's say we have at block 10 and if this block is finalised then I need to find the list of validators ...
0
votes
1
answer
56
views
How to use Mapping with Sha2x256 in ink smart contracts
I want to try and use Mapping with Sha2x256 or any other value that is large enough so that each of these will be unique.
I want mapping to be like this:
unique_ids: Mapping <Sha2x256 ,u128>
...
0
votes
1
answer
79
views
Query returning all instances of a contract based on it's code hash?
Looking to write a call that could return all the contract addresses of ink contracts matching a code hash of the contract via RPC.
What would be the best way to go about getting the list of contract ...
0
votes
1
answer
167
views
What is the best practice for storing a hash?
I am about to make the decision on how to store some hash value inside the blockchain. A hash value is the best practice to minimise the size of the blockchain, but still allows people to verify ...
0
votes
1
answer
76
views
Whats the correct way of purging StorageDoubleMap
I`m looking for an efficient way to purge StorageDoubleMap.
so lets assume I have some collection:
#[pallet::storage]
#[pallet::getter(fn provisions)]
pub type Provisions<T: Config> =
...
0
votes
1
answer
40
views
getReadProof for specific event
I want to generate a StorageProof for a specific event that is stored in storage. I have found System_Events but this returns me all events of a block, instead of a specific one. I stumbled on ...
0
votes
1
answer
103
views
Runtime API to collect values in StorageMap
I'm trying to retrieve all values in my StorageMap defined as such in my pallet:
#[pallet::storage]
#[pallet::getter(fn submitted_tasks)]
pub type SubmittedTasks<T: Config> =
StorageMap<_,...
0
votes
1
answer
23
views
Substrate storage query response does not seems to be correct for System.digests
I am developing a series of Java tools for Substrate based chains, polkadot4j (it is currently under heavy development). I have problem in querying the storage for the pallet system and storage entry ...
0
votes
1
answer
54
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
2
answers
42
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 ...
0
votes
1
answer
64
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 ...
0
votes
1
answer
52
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 ...
0
votes
1
answer
125
views
How to get access to pallet storage from tests
I have approvals map in my pallet
So when i try to get value from my storage, I'm getting this error
So how to properly use pallet storage in tests?
0
votes
1
answer
104
views
Is Substrate Storage Queries exploitable for a DDoS attack?
I have some pallet that provide storage SomeValue, and this storage was exposed through #[pallet::getter(fn some_value)]. Having removed this getter in favour of a paged RPC API, I was thinking that ...
0
votes
2
answers
123
views
How to query for All Pallets StorageVersions
Is there an easy way to get a list of all pallets storage versions? An output like this:
[
Palletname, StorageVersion
]
Is it possible to query using curl and the rpc for the storage version of all ...
0
votes
1
answer
63
views
Is using `put_storage_value` on a storage map while iterating over the same map using `storage_iter` undefined behavior?
The IterableStorageMap API explicitly forbids altering the map while iterating: https://paritytech.github.io/substrate/master/src/frame_support/storage/mod.rs.html#270-272
The frame_support::storage::...
0
votes
2
answers
119
views
How to store a enumerations in smart contracts with ink?
How to store enumeration in smart contract with ink!
I have a field in smart contract with type Mapping<AccountId, Enum>, I tried to use guide https://ink.substrate.io/datastructures/custom-...
0
votes
1
answer
97
views
`try-runtime` doesn't start with a proper state
Context:
Testing try-runtime::follow-chain utility with a local live chain.
Problem:
RemoteExternalities doesn't create a perfect copy of the state.
After follow-chain connects to a node, it starts ...
0
votes
1
answer
109
views
Get value *AND KEY* from iter_prefix_values
I have a StorageNMap
#[pallet::storage]
#[pallet::getter(fn resources)]
/// Stores resource info
pub type Resources<T: Config> = StorageNMap<
_,
(
...
0
votes
0
answers
4
views
Are storage reads in the pre-dispatch cached?
Are storage reads in the pre-dispatch cached?
Example, I'm doing a storage read in the pre-dispatch. Now the same storage read happens when executing the given extrinsic. Do I benefit from caching ...
0
votes
0
answers
13
views
Substrate: function can be called only from offchain workers
i just made a pallet where there is a function callable from users, this function will save some input data inside a storageMap, then offchain worker take the input data, do some operations and should ...
0
votes
0
answers
4
views
Would it be possible to show historical on-chain storage state for a particular block number?
Is there any way to present historical on-chain storage state for a particular block number?
I couldn't find way to do this. Can someone please help me to answer this?
0
votes
0
answers
19
views
how to use substrate-rpc-client query storage
I am trying to use substrate-rpc-client for querying a storage item in our chain, the documentation is very sparse on how to go about this. just says
client.storage(StorageKey(vec![]), Some(H256::...
0
votes
1
answer
27
views
What are the "values" in the substrate Merkle Patricia tree?
I've read Shawn's substrate storage deep dive recently. It is very informative and I roughly understand different key systems exist and how the keys are caclulated.
However, one thing that puzzles me ...
0
votes
0
answers
52
views
How to mutate a Vec<u16> in a struct in a DoubleStorageMap?
How do I mutate a DoubleStorageMap with a Vec<T::AccountId> as a value using a struct?
Data::<T>::mutate(
id.clone(),
user_id.clone(),
|params: &mut DataParams<T::AccountId>...
0
votes
0
answers
39
views
Updating SLOT_DURATION on Mainnet - Seeking Assistance!
We are facing a challenge regarding our mainnet and we need the guidance and expertise of the community. Currently, we are looking to update the SLOT_DURATION to optimize the performance of our ...
0
votes
0
answers
25
views
Uncaught runtime errors: [u8;16]:: Expected input with 16 bytes (128 bits), found 21 bytes
I created a value id by this:
let encoded_payload = (owner.clone(), task_description.clone()).encode();
let id = frame_support::Hashable::blake2_128(&encoded_payload);// hashvalue of combined ...
0
votes
1
answer
71
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
38
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 ...
0
votes
1
answer
45
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
23
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&...
0
votes
1
answer
43
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::...
0
votes
0
answers
35
views
Do extrinsic respect changes to storage due on call?
I have pretty simple extrinsic code which stores data to substrate storage hashmap and tries to load it after from another nested function. But result looks like nothing stored.
In pseudo:
storage[&...