3

I'm trying to understand the rationale behind Moonbeam's GAS_PER_SECOND:

/// Current approximation of the gas/s consumption considering
/// EVM execution over compiled WASM (on 4.4Ghz CPU).
/// Given the 500ms Weight, from which 75% only are used for transactions,
/// the total EVM execution gas limit is: GAS_PER_SECOND * 0.500 * 0.75 ~= 15_000_000.
pub const GAS_PER_SECOND: u64 = 40_000_000;

The 75% makes sense, as it's the default NORMAL_DISPATCH_RATIO for most Substrate chains.

But I was puzzled by the 500ms Weight, which didn't seem obvious to me. After some searching, I found this line mentioning that: // Our weight limit is 500ms.

What is rationale behind 500ms?

Also, what is the rationale behind 15_000_000?

1 Answer 1

2

The 500ms weight limit is a suggested time limit (initially in cumulus) used for block production in order to maximize the size and the probability of a block to be accepted.

Currently (before Asynchronous Backing), it is required to build a parachain block on top of the last relay block. However a relay block is produced every 6 seconds, so it means the parachain has 6s to:

  1. import the relay block
  2. produce the parachain block
  3. produce the PoV
  4. send the PoV to the assigned validators (usually 5)
  5. have the validator verify the PoV (by executing the block)
  6. have the validator broadcast its result

Concerning the 15_000_000, it simply reflected (it changed since) the maximum gas allowed in an Ethereum Block.

Our overall goal in that formula was to find a way to convert our target gas (15_000_000) into our target weight (500ms) and by luck, it did match closely using the hardware of reference (7700k intel CPU), allowing us to simply convert gas to weight using a ratio of 40_000_000 (pico seconds) per gas.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.