Questions tagged [frame]
Questions about Substrate's framework for developing custom runtime logic.
114
questions
22
votes
3
answers
695
views
When should I build a Substrate FRAME Pallet versus a Smart Contract?
What are the differences between developing a Substrate FRAME Pallet and a Substrate Smart Contract (for example with the ink! language)?
What are some examples of applications which are best written ...
16
votes
1
answer
239
views
When to use `BoundedVec` vs. `WeakBoundedVec` vs. `Vec`?
Are there any guiding principles that can be applied to decide whether to use Substrate's BoundedVec, WeakBoundedVec, or Vec in a runtime?
Is it a general rule of thumb to use the bounded variant ...
13
votes
2
answers
117
views
What are some good use cases for anonymous proxies?
There are some good conceptual explainers on what anonymous proxies are, yet it's not clear to me which use cases they serve best.
What are some problems that using anonymous proxies would solve? What ...
12
votes
2
answers
571
views
How to fix `parity_scale_codec::MaxEncodedLen` is not implemented for `T`?
When building my pallet, I run into the error:
error[E0277]: the trait bound `T: parity_scale_codec::MaxEncodedLen` is not satisfied
--> pallets/template/src/lib.rs:42:15
|
42 | #[pallet::...
10
votes
2
answers
104
views
How does the AccountData type work in FRAME runtimes?
The FRAME system for runtime development defines an AccountData type, which is coupled with data from the Balances Pallet in the Polkadot runtime.
What other types of data could be tracked using this ...
10
votes
1
answer
177
views
Are Offences ever pruned?
In our runtime we have a custom implementation of offence reporting. I want to write an adapter for grandpa equivocation offences (implementing the ReportOffence trait), and have been using the ...
9
votes
3
answers
114
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,
...
9
votes
1
answer
117
views
Smart Contract blockspace allocation in Hybrid Chains
In Rob Habermeier's blogpost about Hybrid Chains, he mentions allocating contract execution to a limited fraction of the chain's blockspace.
Is that some functionality that pallet-contracts provides?
...
8
votes
1
answer
216
views
How does a Substrate chain set the max total supply?
How does a Substrate chain set the max total supply? Looking at the staking module, each era will increase the total_issuance through the issue. In the issue function, Self::Balance::max_value() is ...
7
votes
2
answers
86
views
What are the differences between using declarative and attribute macros in FRAME?
What's the main difference (besides the code) between using the decl_storage! macro rule and using the [pallet::storage] macro?
I've seen pretty much everyone using macro rules, but on the latest ...
7
votes
2
answers
414
views
Scalability beyond Asynchronous Backing
With the release of Asynchronous Backing, a good performance increase is expected (lower block time, increased block weight).
Which further efforts are being undertaken with regards to Polkadot ...
7
votes
1
answer
61
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 ...
7
votes
2
answers
109
views
How to change the number of heap pages
We are running into an allocator memory error where the number of heap pages appears to be insufficient to run a transaction on our validator (substrate-node).
This is the error in question:
2022-04-...
7
votes
1
answer
37
views
What is the ValidAtTimestamp error supposed to mean?
In pallet-timestamp, what is InherentError::ValidAtTimestamp supposed to mean exactly?
let minimum = (Self::now() + T::MinimumPeriod::get()).saturated_into::<u64>();
if t > *(data + ...
6
votes
2
answers
105
views
Is it possible to use format! in Substrate runtime?
From the link, It seems format! can work in Substrate runtime.
let hello_world = sp_std::fmt::format!("Hello,{}","world");
I want to have a variable hello_world and use it for ...
6
votes
2
answers
283
views
How do treasury accounts compare to end user accounts in FRAME?
I would like to understand how treasury accounts are created and used under the hood. How do they compare to end user accounts? Are they also just an AccountId to AccountInfo map in storage?
6
votes
1
answer
202
views
Why is there no `Default` implementation for `T::AccountId`?
Starting with version 9.17 and greater I started getting these errors for the custom pallets I've made. Could I please get a pointer in resolving this issue? Example output from compiler:
#[derive(...
6
votes
2
answers
68
views
How are Events aggregated
I noticed that every pallet (that i've checked) that has any events uses the following line in the pallets config trait:
type Event: From<Event<Self, I>> + IsType<<Self as ...
6
votes
1
answer
172
views
How do I use storage and functions from one custom pallet in another?
Is there a way for one custom pallet to access the storage or functions from another custom pallet?
For Example:
Pallet 1
#[pallet::storage]
pub(super) type MyValue<T: Config> = StorageValue<...
6
votes
1
answer
119
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> ...
6
votes
1
answer
48
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
...
5
votes
2
answers
174
views
<T::Lookup as StaticLookup>::Source vs T::AccountId?
I noticed https://github.com/paritytech/substrate/issues/6042 was recently resolved, replacing T::AccountId with <T::Lookup as StaticLookup>::Source. Substrate docs don't mention what is the ...
5
votes
1
answer
59
views
Which data to put in a Pallet Event?
In other blockchains I practiced extreme frugality with event data, since it is expensive.
For example only putting an ID into an event which can then be looked up with lookup(ID) -> ...
5
votes
1
answer
87
views
Difference between ReservableCurrency and NamedReservableCurrency?
The docs on the traits ReservableCurrency and NamedReservableCurrency currency are the same, although they clearly have subtle differences between them. When should someone use ReservableCurrency vs ...
5
votes
1
answer
93
views
adding an account
I just want to simply add an account in the development config but have no idea how to do it, i tried simply adding the seed in the development_config function but it dosent work, what can i do to add ...
5
votes
1
answer
31
views
Why does pallet-election-phragmen have a Balance field in it's Genesis Config?
Why does pallet-election-phragmen have a Balance field here?
#[pallet::genesis_config]
pub struct GenesisConfig<T: Config> {
pub members: Vec<(T::AccountId, BalanceOf<T>)&...
5
votes
2
answers
182
views
SignedExtension to mutate Origin
Please see edits 2 and beyond, as they reshape the question a lot.
TLDR: I need a way to mutate an origin for all but some specific calls so that it's dispatched as RawOrigin::Signed to pass ...
5
votes
1
answer
70
views
Trait item implementation is missing: `reserve_withdraw_assets`
I am running the Astar node locally and pointing to the astar-frame repository which is cloned on my local machine. In the Astar node repository, I added the paths-override method to the point all ...
5
votes
0
answers
48
views
How to use sp_tracing?
When I walk through the sp_tracing documents, it's an overview and does not show us how to use it
I have some questions about sp_tracing:
How to use it? What command that we run it? (Debug Mode?)
...
4
votes
2
answers
117
views
What means `PhantomData<T>` in a pallet?
I see that some pallets wrap phantom data:
pub struct Pallet<T>(PhantomData<T>);
and others not:
pub struct Pallet<T>(_);
Why is it there?
Do I need this in my pallet as well?
4
votes
2
answers
101
views
When should I use `ConstU32` to declare a constant value for my pallet?
There seems to be different approaches to declaring constants for a pallet's runtime implementation.
A common approach for example is:
// In pallet/example/src/lib.rs
#[pallet::config]
pub trait ...
4
votes
1
answer
118
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 ...
4
votes
2
answers
42
views
DispatchError::Other(_) always being mapped to DispatchError::Other("")
I'm trying to pass some custom error messages to the frame_system::note_applied_extrinsic() but it seems to be ignoring my message and always using an empty string "".
Adding this test to ...
4
votes
1
answer
134
views
How can I configure genesis state for my pallet's tests without hardcoding it?
I've been writing tests for pallet-kitties and have configured the genesis state inside my mock runtime by setting the storage items for two kitties (one Male and one Female) and their owners (with ...
4
votes
1
answer
86
views
Whitelist a call subset of a pallet
Is there a way to whitelist a call subset of a pallet? And hide the rest from the end user.
// something like
Pallet { fn call_a(){} fn call_b(){} }; // Some Pallet
...
construct_runtime!(
pub ...
4
votes
3
answers
124
views
Basics > Runtime > FRAME > Modules (Runtime, System) / Difference?
I am a curious learner and on my way of understanding the core principles of the Substrate universe + going through the tutorials on substrate.io.
As far as I understood is: there exists a Core ...
4
votes
1
answer
26
views
Why do some storage items use the static type and others not?
In the various frame pallets in substrate there are two ways of declaring storage.
For example some pallet storage is declared with <T: Config> while others are declared <T: Config<I>, ...
4
votes
2
answers
81
views
`runtime::Error` type
Is there any way to tell the construct_runtime! macro to build/export a top-level Error enum type in the same way it provides the top-level Call and Event types?
As far as I can tell the only way to ...
4
votes
1
answer
115
views
Why is `DispatchResultWithPostInfo` expected?
The compiler: expected DispatchResultWithPostInfo
It found: ) -> DispatchResult {
I want to use DispatchResult and do not understand what the problem is.
Additional context:
#[frame_support::...
3
votes
2
answers
237
views
How we can implement Governance in a chain?
I need to implement governance on my chain.
Do we have any references which guide me in development?
3
votes
2
answers
380
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/...
3
votes
2
answers
111
views
What does #[pallet::compact] do?
What does #[pallet::compact] do?
3
votes
1
answer
128
views
Using T::AccountId in a custom map
I would like to map T::AccountId to a custom struct I have Amendments <AccountId:
#[pallet::storage]
#[pallet::getter(fn declaration_map)]
pub(super) type Declarations<T: Config> =...
3
votes
1
answer
74
views
Why do frame calls take a `Vec` parameter instead of `BoundedVec`?
I saw that some of the calls in frame take Vec as a parameter. I haven't found a call that takes BoundedVec, but my impression was that I should basically always use BoundedVec over Vec?
3
votes
1
answer
131
views
Problem running assert_last_event in tests.rs
As the title suggests, I've been trying to call assert_last_event on the tests.rs class without success. The problem first happened when developing the kitties tutorial and after several toolchain ...
3
votes
1
answer
94
views
Storage definition syntax
#[pallet::storage]
pub(super) type ProofMapping<T: Config> = StorageMap<_, Blake2_128Concat, Vec<u8>, (T::AccountId, T::BlockNumber), ValueQuery >;
What does the syntax used to ...
3
votes
1
answer
97
views
Multisig storage showing calls from another one
I figured there seem to be something wrong with a multisig I have on Rococo.
It's this one: 5FRz8z6U87LBXLUuBRRy4JtVAh2jhkDSbR5ntCGM2Ds631dJ
Checking the storage on it with multisig.multisigs("...
3
votes
1
answer
74
views
boxed argument of a dispatchable
there are cases when we want to Box an argument of a dispatchable. One such case is when the type is large, for instance, xcm::MultiLocation and we do not want to blow the size of Call type.
these ...
3
votes
1
answer
57
views
duplicate lang item in crate `ink_env` - astar-frame/astar
Trying to build Astar shibuya-runtime crate is failing after adding the ink_env dependency an astar-frame chain-extension.
Here are the changes to both Astar and astar-frame.
Run: cargo build --...
3
votes
0
answers
101
views
Cannot create a runtime on benchmark run
Using polkadot-v0.9.19 branch I've created benchmarks for a pallet, added it into runtime, compiled.
On run of any of created benchmarks getting this error:
Error:
Service(Client(RuntimeApiError(...