Skip to main content

Questions tagged [storage]

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

Filter by
Sorted by
Tagged with
0 votes
1 answer
16 views

Remove undecodable storage keys from StorageDoubleMap

I want to remove keys from the storage which cannot be decoded by using unhashed. I know there are undecodable keys because when counting the number of storage keys via MyStorage::<T>::iter_keys(...
0x5hmoo's user avatar
  • 189
1 vote
2 answers
27 views

EnsureOriginBy using an account set on a pallet's storage

I'm working on a feature that requires pallet-nfts ForceOrigin to only be callable by an account configured inside a separated pallet's storage. For example in pallet-A I have the following #[pallet::...
Valentin Fernandez's user avatar
0 votes
1 answer
22 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 ...
Kailai's user avatar
  • 373
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>...
bobby dy's user avatar
0 votes
0 answers
36 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 ...
Lucas Cardeal's user avatar
2 votes
1 answer
49 views

The necessity of bitfields in Polkadot, and potential replacement with threshold signatures

My question is related to the usage of bitfields in data availability system, described in https://spec.polkadot.network/chapter-anv. Polkadot uses bitfields to know if a relay-chain block is stored ...
Oguzhan Ersoy's user avatar
0 votes
2 answers
62 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 ...
Deepak Chaudhary's user avatar
3 votes
1 answer
73 views

Feeding state from one parachain to another

I am interested in developing a pallet into which data from another parachain can be fed. For instance, consider two parachains: Para A and Para B. Para B implements the collectives pallet, and for ...
Szegoo's user avatar
  • 657
2 votes
1 answer
55 views

How to update the pallet's storage from the runtime api?

Is it possible to update the storage of pallets through runtime api? Is yes. Do we have any resources for this same?
Deepak Chaudhary's user avatar
3 votes
0 answers
25 views

Difficulty Storing Consensus-Derived Value in Storage: Observing Value in Pallet Log but Not in Storage

I'm trying to store a value obtained from the consensus, specifically sc_consensus_babe::fn import_block. While I can observe the value in the pallet through the log, it doesn't seem to be stored in ...
Deepak Chaudhary's user avatar
1 vote
1 answer
35 views

How to change the NextAuthorities set from custom pallet?

The NextAuthorities is only updated in function enact_epoch_change() in pallet_babe and this function is called in Trait EpochChangeTrigger (pallet_babe) and OnSessionHandler so, in the ...
MinhK's user avatar
  • 125
1 vote
1 answer
24 views

Is it possible to define a storage inside the pallet without config trait?

Actually I want to define a storage without config trait but if I'm doing this then I'm getting lot of error. Is it possible? /// Author of current block. #[pallet::storage] pub type Author<...
Deepak Chaudhary's user avatar
0 votes
0 answers
22 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 ...
MinhK's user avatar
  • 125
1 vote
1 answer
38 views

query storage to front-end

In the pallet-template, I have this storage: #[pallet::storage] #[pallet::getter(fn getscoreboard)] pub(super) type ScoreBoard<T: Config> = StorageMap <_, Twox64Concat, T::...
MinhK's user avatar
  • 125
1 vote
1 answer
34 views

Mutual value among pallets

How to access value X in pallet A from another pallet? For example, I saw a few pallets define type Currency = Balance, is it truly the value Balance in pallet_balances? If not, how to define a ...
MinhK's user avatar
  • 125
1 vote
1 answer
19 views

How to store and query the raw text?

I want to query the task from storage. Here is the Task struct and StorageMap #[derive(Clone, Encode, Decode, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen, Default)] #[scale_info(...
MinhK's user avatar
  • 125
1 vote
1 answer
42 views

Concerns about returning all elements from a `StorageDoubleMap`

I defined a storage item as StorageDoubleMap, and I need to provide a method that returns the list of elements with the first key (k1). This getter method has to be provided by the pallet. I found a ...
magecnion's user avatar
  • 242
2 votes
1 answer
27 views

Difference Between Using Preimage Pallet and Hash Storage with T::Hashing in Substrate

I'm working on a project using Substrate and have encountered a technical question regarding data storage. I would like to understand the fundamental difference between using the Preimage pallet and ...
SailorSnoW's user avatar
1 vote
1 answer
51 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
31 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
45 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
47 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
8 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
  • 10.4k
2 votes
1 answer
60 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
  • 10.4k
0 votes
0 answers
58 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
100 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
  • 923
1 vote
1 answer
85 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
  • 13
1 vote
1 answer
30 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
  • 923
1 vote
2 answers
44 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
38 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,223
0 votes
1 answer
69 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
  • 421
0 votes
1 answer
33 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
21 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
66 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
  • 136
1 vote
1 answer
43 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
  • 432
1 vote
1 answer
35 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
123 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
  • 569
0 votes
0 answers
24 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,191
0 votes
0 answers
21 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
88 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
  • 2,021
3 votes
2 answers
45 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
0 answers
63 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
42 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
22 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
41 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,191
1 vote
1 answer
84 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
81 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
  • 569
6 votes
1 answer
25 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
19 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
  • 369

1
2 3 4 5