Questions tagged [runtime]

Questions that have to do with the FRAME runtime

Filter by
Sorted by
Tagged with
4 votes
1 answer
153 views

Why not `mem::drop(self)` here?

I feel a little confused about the usage of mem::forget(...) when reading impl Imbalance<T::Balance> for PositiveImbalance<T, I> in pallet-balances pallet. Accord the forget docs: Takes ...
user avatar
1 vote
1 answer
39 views

How do I know if I will need a storage migration along a forkless upgrade?

I have a blockchain running a version of Frontier from september 2021, and want to upgrade it to the latest commits. I'm prepared to do a forkless upgrade, but who do I know if I will need storage ...
user avatar
  • 53
3 votes
2 answers
124 views

How key-values database and Merkle Tree works together on Substrate

I have been looking deep dive into Substrate and trying to understand things behind the hood, especially storage API. I am really keen to explore more in the Merkle abstraction between Storage API and ...
user avatar
2 votes
1 answer
21 views

How can I set the max byte size extrinsic/transaction?

I will like to play with limiting the max size of transactions? I cannot find in substrate where those configurations go.
user avatar
  • 207
3 votes
0 answers
25 views

Multiple instances of Treasury pallet

I wondered how to create multiple instances of the pallet Treasury and couldn't find any examples so far. One example is pallet Membership, which doesn't have any dependencies, while the Treasury ...
user avatar
  • 83
2 votes
1 answer
46 views

Dispatching a runtime call from an ink! smart contract

Disc: I know about the existence of ChainExtension feature. Here I would like to ask about the other way. There is this CallFilter thing in Config for pallet-contracts and IIUC it defines what kind of ...
user avatar
  • 58
1 vote
1 answer
47 views

Calculating code hash for an authorize-enact style runtime upgrade?

How to calculate the code hash for fn authorize_upgrade of cumulus_pallet_parachain_system? As per crate substrate-runtime-proposal-hash been trying BLAKE2B32(0x0103 | BLAKE2B32(wasm_bytes)) with no ...
user avatar
2 votes
2 answers
34 views

Runtime upgrade error: parachainSystem.ValidationDataNotAvailable

Follow this doc: https://docs.substrate.io/tutorials/v3/forkless-upgrades/#upgrade-the-runtime-1. Scheduled and set_code show an error: ValidationDataNotAvailable. Do I miss something? How to fix this ...
user avatar
0 votes
1 answer
16 views

Clarification on state_version and transaction_version change in Cumulus parachain template

I have some simple question. What state_version stands for, and when it should be changed? As I can see, in Cumulus parachain template on polkadot-v0.9.18 tag the state_version was changed to 1. Also,...
user avatar
  • 23
0 votes
1 answer
22 views

Setting static parameter types in benchmarks

There is very little information to be found on static parameter types. All I could find is a docstring that says: In testing, StaticArgument can be altered later: StaticArgument::set(8). I need to ...
user avatar
  • 175
2 votes
2 answers
67 views

How to enable `std` features in pallets?

I'm trying to implement simple PoW for my node. After debugging all other stuff I've encountered the problem where finality-grandpa and storage do not get compiled because standard library macros are (...
user avatar
  • 134
6 votes
2 answers
159 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 ...
user avatar
  • 61
2 votes
1 answer
25 views

How to easily port the code for V3 pallets (early V3 syntax) to new syntax (4.0.0-dev)?

We have a lot of pallets that have early V3 syntax, example here: https://github.com/threefoldtech/tfchain/blob/development/substrate-node/pallets/pallet-burning/src/lib.rs We want to port them to the ...
user avatar
1 vote
0 answers
15 views

Failed to do runtime upgrade: FailedToExtractRuntimeVersion

When trying to migrate the runtime from a very early version of substrate 3 (aug 2021) to polkadot 0.9.18 we are getting the following error: Failed to extract the runtime version from the new ...
user avatar
2 votes
0 answers
30 views

Using 2 consensus algorithms

I'm trying to implement Layer 2 to Substrate. Substrate node runs BABE and GRANDPA to produce blocks and finalize. Layer 2 comes built into the Substrate (planning to develop this way). It will have a ...
user avatar
  • 497
2 votes
1 answer
37 views

Run parachain as local regular chain

Working on a parachain, the executable that is build is a collator node. It will run both the parachain and the relay-chain nodes. For pallet development (pure product, unrelated to the chain being a ...
user avatar
2 votes
1 answer
41 views

How to get caller and block number using Polkadot/Kusama Runtime modules and SubSquid

I'm trying to make my very first indexer. I want to pull the caller (initiator's address) of a runtime system.remark, as well as the block number. What is the best way to do this via hooking into the ...
user avatar
  • 111
0 votes
2 answers
48 views

Manually implement `Default` for `AccountId`

I am creating a parachain with a custom pallet, where i have this set up in storage: pub type AccountIdOf<T> = <T as frame_system::Config>::AccountId; pub type NeuronMetadataOf<...
user avatar
2 votes
2 answers
45 views

What could happen if the `BlockWeights` is set HIGHER than `MILLISECS_PER_BLOCK` (block time)?

In Substrate docs, it's said: "The maximum block weight should be equivalent to one-third of the target block time, allocating one third for block construction, one third for network propagation, ...
user avatar
  • 53
5 votes
1 answer
63 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(...
user avatar
9 votes
1 answer
71 views

What is the difference between Extrinsic and Dispatchable?

What is the difference between an Extrinsic and a Dispatchable?
user avatar
0 votes
1 answer
24 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<_,...
user avatar
6 votes
1 answer
75 views

How can I make my runtime as light client friendly as possible?

Substrate Storage reads and writes are expensive and the runtime should always be optimized around minimizing such cost, which is quantified in terms of runtime computation for traversing the Merkle ...
user avatar
  • 1,597
1 vote
1 answer
38 views

Collator panicked at 'Storage root must match that calculated.'

We have a few collators for the Kintsugi parachain actively syncing and producing blocks when they suddenly fall-over due to the following error: Apr 02 21:06:00 ubuntu-s-2vcpu-4gb-amd-fra1-01 ...
user avatar
6 votes
1 answer
60 views

What happens if I implement `MaxEncodedLen` lower than the actual max length?

What is the consequence if I implement MaxEncodedLen lower than the actual max length of the type? Will the bytes which are above the length just not be written to storage?
user avatar
6 votes
1 answer
58 views

What is the relationship between `sandbox`, `executor` and `runtime`?

I was recently reading the code for Substrate wasmtime, but I ran into some problems. I don't really understand the difference between runtime and sandbox. For example, in the runtime.rs file, we can ...
user avatar
4 votes
1 answer
45 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 ...
user avatar
5 votes
1 answer
32 views

Mitigation strategies if a chain would reach `BlockNumber::MAX`?

Let's say a Substrate chain had a long and prosper life and is about to reach a block number of BlockNumber::MAX (lucky chain!). Short of a reincarnation as a new chain with the genesis block ...
user avatar
  • 1,104
3 votes
1 answer
35 views

Is it possible to set up a call filter based on the call arguments?

Is it possible to set up a call filter (BaseCallFilter) so that the filtering is done based on the parameters of the call? So if the extrinsic parameters match a certain criterion they should either ...
user avatar
2 votes
1 answer
31 views

Migrating to new code base

We have a prototype of substrate-based blockchain running with few nodes. After some time running and testing we came up with new version of code-base, which consists of the same runtime, pallets and ...
user avatar
6 votes
1 answer
61 views

Performance of same logic with a contract using pallet-contracts vs. a native pallet (excluding metering)

I'm wondering what is current state of the art of Substrate's pallet-contracts performance as compared to the same functional implementation as a pallet. I acknowledge that different logic can have ...
user avatar
  • 315
3 votes
1 answer
29 views

What is the role of `#[scale_info(skip_type_params(T))]`?

#[derive(Encode,Decode,TypeInfo) #[scale_info(skip_type_params(T))] Pub struct Asset<T:Config> { Id:### Name:## } So in the above example if you dont include the second macro. The compiler will ...
user avatar
2 votes
1 answer
37 views

What is the benefit of using Serde::Serialize/Deserialize on defined types?

As an example, in the Kitties tutorial : #[derive(Clone, Encode, Decode, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub ...
user avatar
5 votes
2 answers
87 views

How do I test a chain extension used in the runtime?

I am aware of this example that shows how to create a mock chain extension and test that. However, I do not know how to test the chain extension that is used by the runtime and calling functions from ...
user avatar
2 votes
2 answers
37 views

Attempting to build multiple runtimes, stopped by `AccountNonceApi_account_nonce` is already defined

Polkadot is capable of allowing you to defining the native runtimes you want included within the final node binary (with flags like polkadot-native, kusama-native and so on..). Attempting to port the ...
user avatar
3 votes
1 answer
29 views

What optimizations and programing paradigms make the most impact in FRAME Runtime development?

Branchless Programming: Why "If" is Sloowww... and what we can do about it! is an example of low level optimizations that you might pursue in a blockchain system to reduce the overhead of ...
user avatar
  • 1,232
3 votes
2 answers
48 views

How to build prefixed key for rocksdb

I would like to know how can the key for the state System Events storage can be built for a given block hash/height
user avatar
6 votes
2 answers
52 views

What's the overhead associated with the `#[transactional]` macro?

Substrate has a macro, #[transactional], to ensure that any modifications to storage are not persisted in case of an error during execution. I imagine there's some sort of caching done before ...
user avatar
  • 140
4 votes
1 answer
43 views

What's the logic behind Polkadot's choice in pallet indexing?

In most runtimes in production, each pallet has a specific index but its not clear what the logic behind ordering them really is. For example, in Polkadot we can see a comment in the construct_runtime ...
user avatar
  • 1,597
10 votes
1 answer
59 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 ...
user avatar
  • 1,104
3 votes
2 answers
25 views

How to set up `BaseCallFilter` to only allow a limited set of calls of one pallet to be executed?

Are there examples how to set up a call filter in Substrate to allow only certain calls of a particular pallet to be executed?
user avatar
  • 1,104
9 votes
2 answers
86 views

How can I build a price feed oracle for my Substrate chain? [closed]

What components do I need to implement an oracle for a Substrate chain, such as a price feed? I'm looking to understand the general steps and considerations I should make. What libraries or projects ...
user avatar
  • 1,597
1 vote
1 answer
31 views

Basics > Runtime > FRAME > Substrate FRAME Pallets

as a learner and beginner, I have 2 questions about the FRAME Pallets and especially to that overview: https://docs.substrate.io/v3/runtime/frame/--> Substrate FRAME PALLETS: The highlighted ...
user avatar
  • 75
4 votes
3 answers
56 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 ...
user avatar
  • 75
1 vote
1 answer
73 views

Substrate validators election failing and connectivy lost

Hey so I have been running a custom substrate chain with 3 validators. But recently the chain got crashed with a log election provider failed due to ElectionError::Fallback("NoFallback.") ...
user avatar
  • 15
0 votes
2 answers
45 views

The node template can't fetch the accounts from chain-spec.rs

pub fn development_config() -> Result<ChainSpec, String> { let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?; Ok(ChainSpec::...
user avatar
1 vote
1 answer
32 views

Constant `MaxNominations` is removed from the Kusama runtime starting from 9170

I just noticed that staking.MaxNominations constant is removed from Kusama's runtime metadata starting from 9170. However, I did not find any proper replacement neither in constants nor in storage. ...
user avatar
1 vote
1 answer
29 views

What is a runtime as a data structure?

After a runtime is complete and all the macros are expanded, what kind of data structure is the runtime? e.g. Is the Runtime a struct? If so, what are some of the fields? I want to be able to build a ...
user avatar
3 votes
1 answer
23 views

Is there a standard for generating system public keys?

I have noticed the entropy for system public key generation is prefixed with patterns like modlpy/proxy____. Is there a documented standard for the length or format of these prefixes? What is the ...
user avatar
3 votes
2 answers
40 views

Debugging with a visual debugger - getting lost in WASM?

I'm trying to debug the code with a visual debugger (IntelliJ Idea, but I suspect this question applies generally). I can get the debugger to stop on break points while the runtime is initialising ...
user avatar