Skip to main content
21 votes
Accepted

What's the impact of underestimating Weights?

Basically the same as what happened in Ethereum's Shanghai Attacks. An "attacker" would submit a lot of transactions with the underestimated weights. They would effectively underpay the ...
Gav's user avatar
  • 2,681
18 votes
Accepted

How expensive is it to access storage items?

Substrate itself is not concerned with Cost but with Weight. How Weight is translated to Cost depends on the specific chain. Weight is the time to complete a specific task. This will be updated to a ...
Oliver Tale-Yazdi's user avatar
13 votes
Accepted

Are weights really neccessary?

During block authorship, the execution time of each transaction is measured, rather than weights right? We don't measure the execution time per extrinsic. Each block has a fixed slot for proposing/...
bkchr's user avatar
  • 11.5k
10 votes
Accepted

How do extrinsic weights apply to Raspbery Pi full-nodes?

The Weight system is not about block production, but actually about block import. Remember that the high level story around weights is that we are trying to protect the network from blocks that are ...
Shawn Tabrizi's user avatar
  • 16.1k
10 votes
Accepted

How to generate `WeightInfo` for pallets?

On a production chain, you should always re-calculate your weights by running benchmarks on the final runtime. The point of benchmarking is that your runtime can be configured in different ways, and ...
Shawn Tabrizi's user avatar
  • 16.1k
9 votes
Accepted

What prevents unsigned transactions from filling up a block?

Unsigned transactions should include some ValidateUnsigned logic which is used in the transaction queue to determine if an unsigned transaction should even be included in the block. You can find an ...
Shawn Tabrizi's user avatar
  • 16.1k
9 votes
Accepted

Maximum weight in a block?

The various weight configurations on a Substrate chain are all collected in a blockWeights configuration constant which can be found in the System Pallet. You can see in the image above the Kusama ...
Shawn Tabrizi's user avatar
  • 16.1k
9 votes
Accepted

How are the costs of XCM messages designed?

Since XCM is configurable, this can depend from chain to chain. However, most(if not all) Dotsama chains adopt the same approach. We rely on parity's implementation of XcmExecutor (here) and various ...
Dinonard's user avatar
  • 587
9 votes

Are weights really neccessary?

The main reason is it is impossible to deterministically determine the execution time of a transaction without heavy overhead (e.g. gas metering). For example, user send a transaction, the execution ...
Bryan Chen's user avatar
8 votes
Accepted

How do I get weight for my pallet?

Weight Weight is an absolute unit of execution time. The longer your extrinsic runs, the more Weight it has. Substrate uses this to know in advance how many transactions fit in a block. This is ...
Oliver Tale-Yazdi's user avatar
8 votes

Maximum weight in a block?

How many seconds are available per block comes down to computation power aka the underlying hardware that is supporting the blockchain. So you are right: pub const WEIGHT_PER_SECOND: Weight = ...
Bruno's user avatar
  • 8,315
7 votes

What's the impact of underestimating Weights?

Great question! You don't really need an adversary as even normal chain usage can cause problems in such a scenario. The speed of block finalization in Substrate relies on the assumption that each ...
Oliver Tale-Yazdi's user avatar
7 votes

How do I pass a sp_runtime::traits::Hash value into benchmark function

You can use the Decode trait in order to create a frame_system::pallet::Config::Hash from bytes: let hash = T::Hash::decode( hex!("...
Alexander Theißen's user avatar
7 votes
Accepted

Signed Extensions and Weights

There is an ExtrinsicBaseWeight which is added to the weight of all extrinsics. This is done to account for any weight that is not measured by the pallet benchmarks, like inherents or signature ...
Oliver Tale-Yazdi's user avatar
7 votes
Accepted

Calculating actual weights for extrinsics

First, the transaction_payment pallet does this for you with compute_actual_fee from the post_dispatch and configuring it in your runtime with the ChargeTransactionPayment signed extension via ...
Daan van der Plas's user avatar
7 votes

How to calculate fee for XCM transfer?

In fact, it is almost impossible to have an algorithm to calculate the XCM fees for all chains. This is because the calculation of XCM fees is related to the following points, and each chain may have ...
Guantong's user avatar
  • 1,848
6 votes
Accepted

Transaction fee paying fund

There are a ton of approaches to this, but you usually need to apply some kind of logic ensure the transactions can't get spammed or used as a DDOS attack vector - this applies whether the fees are ...
ashneverdawn's user avatar
6 votes
Accepted

fee economics around remark

Every extrinsic has an ExtrinsicBaseWeight which is defined in FRAME System. So even if a benchmark for a particular extrinsic says 0, there will still be the ExtrinsicBaseWeight included on top of it....
Shawn Tabrizi's user avatar
  • 16.1k
6 votes
Accepted

Where should pallet migrations be executed?

What is the current best practice to execute migrations? What should devs put their attention towards when applying this method? Are there pitfalls? When you are developing a Pallet for external ...
bkchr's user avatar
  • 11.5k
6 votes

What's the impact of underestimating Weights?

They can flood your chain with spam transactions and worse they can bloat your state. If your state is very large then it is more time consuming to sync and costly to store. Ideally state growth ...
Squirrel's user avatar
  • 3,849
6 votes
Accepted

Benchmark FRAME pallets

Answering your questions one by one: Benchmarking the Pallets is always necessary since the results depend on your runtime configuration. Each variable that you change in the runtime config can lead ...
Oliver Tale-Yazdi's user avatar
6 votes

Substrate weight limits and block production

Your understanding is correct, if max_total is reached for a particular Dispatch Class, no more transactions of that class will be attempted to be included in the block. Substrate is flexible about ...
NachoPal's user avatar
  • 514
6 votes

Proof Skipped in benchmark

Good question and sorry for the confusion - the comment is poorly chosen. It indicates that the worst-case Proof Size limit could not be estimated. This can come from either: The pallet of the ...
Oliver Tale-Yazdi's user avatar
6 votes
Accepted

What is proof size?

What is the definition of proof size? Proof size is the size, in bytes, required to be able to successfully execute a block of a parachain during the parachains protocol. This is commonly referred to ...
Shawn Tabrizi's user avatar
  • 16.1k
5 votes

How to generate `WeightInfo` for pallets?

Write benchmarks and do benchmarks, see https://docs.substrate.io/v3/runtime/benchmarking/ . The following commands will do benchmarks in specified pallet and generate weights.rs. ./target/release/...
Chino Chang's user avatar
5 votes
Accepted

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

Benchmark results for the #[transactional] overhead can be found here: https://github.com/paritytech/substrate/pull/10809 The key takeaways: Spawning a transactional layer is quite cheap; just 50 ...
Shawn Tabrizi's user avatar
  • 16.1k
5 votes
Accepted

Pre-dispatch Error

The transaction is not really put back if verification fails with InvalidTransaction::ExhaustsResources, it is just kept in the transaction pool. You can find some notes about it here: https://github....
NachoPal's user avatar
  • 514
5 votes
Accepted

construct_runtime_integrity_test failing

Good question! The reason for this is the recent introduction of a new component in the Weight struct; the proof size. This makes it mandatory to slightly adjust your definition of BlockWeights to ...
Oliver Tale-Yazdi's user avatar
5 votes
Accepted

what is the maximum size of a block?

The block size is controlled in different ways. From the runtime you can set the maximum block size by setting the BlockLength. The block builder is also tracking the block size and by default aborts ...
bkchr's user avatar
  • 11.5k
4 votes
Accepted

Using another pallet calls for FRAME-based benchmarking

Your code assumes that the pallet you are benchmarking has a tight coupling with pallet_nft, however this is an assumption that you must satsify within the rust trait bounds. The solution, as the ...
Shawn Tabrizi's user avatar
  • 16.1k

Only top scored, non community-wiki answers of a minimum length are eligible