Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update block gas limits #913

Merged
merged 3 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion builders/build/runtime-upgrades.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The following table contains a list of the runtime upgrades and the block at whi
Not all runtime upgrades are released on each network, as sometimes after releasing the initial runtime upgrade, the need for a subsequent upgrade arises. If a runtime upgrade version has been skipped or hasn't been released yet (only applicable to the latest runtime upgrade), you'll see a `-` in that row.

| Runtime | Moonbeam | Moonriver | Moonbase Alpha |
| :--------------------------------------------------------------------------------------: | :------------------------------------------------------------------: | :-------------------------------------------------------------------: | :------------------------------------------------------------------: |
|:----------------------------------------------------------------------------------------:|:--------------------------------------------------------------------:|:---------------------------------------------------------------------:|:--------------------------------------------------------------------:|
| 40 | - | - | [0](https://moonbase.subscan.io/block/0){target=\_blank} |
| 44 | - | - | [142863](https://moonbase.subscan.io/block/142863){target=\_blank} |
| 47 | - | - | [209144](https://moonbase.subscan.io/block/209144){target=\_blank} |
Expand Down Expand Up @@ -76,3 +76,5 @@ Not all runtime upgrades are released on each network, as sometimes after releas
| [2602](https://forum.moonbeam.network/t/runtime-rt2600-schedule/1372/13){target=\_blank} | [4977160](https://moonbeam.subscan.io/block/4977160){target=\_blank} | [5638536](https://moonriver.subscan.io/block/5638536){target=\_blank} | [5576588](https://moonbase.subscan.io/block/5576588){target=\_blank} |
| [2700](https://forum.moonbeam.network/t/runtime-rt2700-schedule/1441/3){target=\_blank} | [5504531](https://moonbeam.subscan.io/block/5504531){target=\_blank} | [6041969](https://moonriver.subscan.io/block/6041969){target=\_blank} | [5860584](https://moonbase.subscan.io/block/5860584){target=\_blank} |
| [2801](https://forum.moonbeam.network/t/runtime-rt2801-schedule/1616/4){target=\_blank} | [5899847](https://moonbeam.subscan.io/block/5899847){target=\_blank} | [6411588](https://moonriver.subscan.io/block/6411588){target=\_blank} | [6209638](https://moonbase.subscan.io/block/6209638){target=\_blank} |
| [2901](https://forum.moonbeam.network/t/runtime-rt2901-schedule/1695){target=\_blank} | - | - | [6710531](https://moonbase.subscan.io/block/6710531){target=\_blank} |
| 2902 | - | - | [6732678](https://moonbase.subscan.io/block/6732678){target=\_blank} |
59 changes: 56 additions & 3 deletions builders/interoperability/xcm/remote-execution/remote-evm-calls.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,69 @@ Another significant difference is in terms of the gas price. The fee for remote

The last difference is in terms of the gas limit. Ethereum uses a gas-metered system to moderate the amount of execution that can be done in a block. On the contrary, Moonbeam uses a [weight-based system](https://docs.substrate.io/build/tx-weights-fees/){target=\_blank} in which each call is characterized by the time it takes to execute in a block. Each unit of weight corresponds to one picosecond of execution time.

The configuration of the XCM queue suggests that XCM messages should be executable within `20,000,000,000` weight units (that is, `0.02` seconds of block execution time). Suppose the XCM message can't be executed due to the lack of execution time in a given block, and the weight requirement is over `20,000,000,000`. In that case, the XCM message will be marked as `overweight` and will only be executable through democracy.
As of runtime 2900, the configuration of the XCM queue suggests that XCM messages should be executable within the following weight units:

The `20,000,000,000` weight limit per XCM message constrains the gas limit available for remote EVM calls through XCM. For all Moonbeam-based networks, there is a ratio of [`25,000` units of gas per unit of weight](https://github.com/moonbeam-foundation/moonbeam/blob/{{ networks.moonbase.spec_version }}/runtime/moonbase/src/lib.rs#L402){target=\_blank} ([`WEIGHT_REF_TIME_PER_SECOND`](https://paritytech.github.io/substrate/master/frame_support/weights/constants/constant.WEIGHT_REF_TIME_PER_SECOND.html){target=\_blank} / [`GAS_PER_SECOND`](https://github.com/moonbeam-foundation/moonbeam/blob/{{ networks.moonbase.spec_version }}/runtime/moonbase/src/lib.rs#398){target=\_blank}). Considering that you need some of the XCM message weight to execute the XCM instructions themselves. Therefore, a remote EVM call might have around `18,000,000,000` weight left, which is `720,000` gas units. Consequently, the maximum gas limit you can provide for a remote EVM call is around `720,000` gas units. Note that this might change in the future.
=== "Moonbeam"

```text
125,000,000,000 (0.125 seconds of block execution time)
```

=== "Moonriver"

```text
125,000,000,000 (0.125 seconds of block execution time)
```

=== "Moonbase Alpha"

```text
500,000,000,000 (0.5 seconds of block execution time)
```

!!! note
Prior to runtime 2900, the weight limit of XCM messages across all networks was `20,000,000,000` weight units (this is, `0.02` seconds of block execution time).

Suppose the XCM message can't be executed due to the lack of execution time in a given block, and the weight requirement exceeds the above limits. In that case, the XCM message will be marked as `overweight` and only be executable through democracy.

The maximum weight limit per XCM message constrains the gas limit available for remote EVM calls through XCM. For all Moonbeam-based networks, there is a ratio of [`25,000` units of gas per unit of weight](https://github.com/moonbeam-foundation/moonbeam/blob/{{ networks.moonbase.spec_version }}/runtime/moonbase/src/lib.rs#L402){target=\_blank} ([`WEIGHT_REF_TIME_PER_SECOND`](https://paritytech.github.io/substrate/master/frame_support/weights/constants/constant.WEIGHT_REF_TIME_PER_SECOND.html){target=\_blank} / [`GAS_PER_SECOND`](https://github.com/moonbeam-foundation/moonbeam/blob/{{ networks.moonbase.spec_version }}/runtime/moonbase/src/lib.rs#398){target=\_blank}). Considering that you need some XCM message weight to execute the XCM instructions, a remote EVM call might consume 2,000,000,000 units. The following equation can be used to determine the maximum gas units for a remote EVM call:

```text
Maximum Gas Units = (Maximum Weight Units - Remote EVM Weight Units) / 25,000
```

Therefore, the maximum gas limit you can provide for a remote EVM call can be calculated:

=== "Moonbeam"

```text
Maximum Gas Units = (125,000,000,000 - 2,000,000,000) / 25,000
Maximum Gas Units = 4,920,000
```

=== "Moonriver"

```text
Maximum Gas Units = (125,000,000,000 - 2,000,000,000) / 25,000
Maximum Gas Units = 4,920,000
```

=== "Moonbase Alpha"

```text
Maximum Gas Units = (500,000,000,000 - 2,000,000,000) / 25,000
Maximum Gas Units = 19,920,000
```

!!! note
These values are subject to change in the future.

In summary, these are the main differences between regular and remote EVM calls:

- Remote EVM calls use a global nonce (owned by the [Ethereum XCM Pallet](https://github.com/moonbeam-foundation/moonbeam/tree/master/pallets/ethereum-xcm){target=\_blank}) instead of a nonce per account
- The `v-r-s` values of the signature for remote EVM calls are `0x1`. The sender can't be retrieved from the signature through standard methods (for example, through [ECRECOVER](/builders/pallets-precompiles/precompiles/eth-mainnet/#verify-signatures-with-ecrecover){target=\_blank}). Nevertheless, the `from` is included in both the transaction receipt and when getting the transaction by hash (using the Ethereum JSON-RPC)
- The gas price for all remote EVM calls is zero. The EVM execution is charged at an XCM execution level and not at an EVM level
- The current maximum gas limit you can set for a remote EVM call is `720,000` gas units
- The current maximum gas limit you can set for a remote EVM call is different, as outlined above

## Ethereum XCM Pallet Interface {: #ethereum-xcm-pallet-interface}

Expand Down
14 changes: 8 additions & 6 deletions learn/platform/networks/moonbase.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ Moonbase Alpha has the following configuration:
Some important variables/configurations to note include:

=== "General"
| Variable | Value |
|:---------------------:|:-----------------------------------------------------------------------:|
| Minimum gas price | {{ networks.moonbase.min_gas_price }} Gwei |
| Target block time | {{ networks.moonbase.block_time }} seconds |
| Block gas limit | {{ networks.moonbase.gas_block }} (expected to increase by at least 4x) |
| Transaction gas limit | {{ networks.moonbase.gas_tx }} (expected to increase by at least 4x) |
| Variable | Value |
|:---------------------:|:------------------------------------------:|
| Minimum gas price | {{ networks.moonbase.min_gas_price }} Gwei |
| Target block time | {{ networks.moonbase.block_time }} seconds |
| Block gas limit | {{ networks.moonbase.gas_block }} |
| Transaction gas limit | {{ networks.moonbase.gas_tx }} |

=== "Staking"
| Variable | Value |
Expand All @@ -43,6 +43,8 @@ Some important variables/configurations to note include:
| Unbond duration | {{ networks.moonbase.delegator_timings.del_bond_less.rounds }} rounds ({{ networks.moonbase.delegator_timings.del_bond_less.hours }} hours) |

--8<-- 'text/_common/async-backing-moonbase.md'

Additionally, as of runtime 2900, the block and transaction gas limits increased by 4x on Moonbase Alpha.

--8<-- 'text/builders/get-started/networks/moonbase/connect.md'

Expand Down
10 changes: 5 additions & 5 deletions variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ networks:
parachain_release_tag: v0.37.2 # must be in this exact format for links to work
parachain_sha256sum: 71242b8cdf2b97fba4aadb7d6050e0b46eaacafae6bcde9b5f5534aff620d144
tracing_tag: moonbeamfoundation/moonbeam-tracing:v0.37.2-2902-latest
gas_block: 15,000,000
gas_block_numbers_only: 15000000
gas_tx: 12,995,000
gas_block: 60,000,000
gas_block_numbers_only: 60000000
gas_tx: 52,000,000
mbip_5:
block_storage_limit: 40
block_storage_limit: 160
gas_storage_ratio: 366
example_storage: 500
example_addtl_gas: 183000
Expand Down Expand Up @@ -123,7 +123,7 @@ networks:
xcbetadev:
transact_numbers_only: 50000000000000000
erc20_xcm:
transfer_gas_limit: 200,000
transfer_gas_limit: 800,000
conviction:
lock_period:
conviction_1: 1
Expand Down
Loading