You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Revive] Add configuration to set Ethereum gas scale (#10393)
This PR is based on
#10166 (i.e., it merges
into the branch `torsten/gas-fixes`).
This PR adds a new configuration parameter (`GasScale`) to pallet-revive
that allows to change the scale of the Ethereum gas and of the Ethereum
gas price.
Before this PR, the Ethereum gas price is simply the next fee multiplier
of pallet-transaction-payment multiplied by `NativeToEthRatio`. Thus, on
Polkadot this is 100_000_000 when the multiplier has its default value
of 1.
The required gas of a transaction is its total cost divided by the gas
price, where the total cost is the sum of the transaction fee and the
storage deposit.
This leads to a situation where the required gas for a transaction on
revive is usually orders of magnitude larger than the required amount of
gas on Ethereum. This can lead to issues with tools or systems that
interact with revive and hard code expected gas amounts or upper limits
of gas amounts.
Setting `GasScale` has two effects:
- revive's Ethereum gas price is scaled up by the factor `GasScale`
- resulting used/estimated gas amounts get scaled down by the factor
`GasScale`.
## Technical Details
Internally, revive uses exactly the same gas price and gas units as
before. Only at the interface these amounts and prices get scaled by
`GasScale`.
**The actual logical changes are almost trivial and I use `GasScale` at
only three places: in `evm_base_fee` to scale the gas price and in the
functions `from_ethereum_gas` and `to_ethereum_gas`.**
## Recommended
This PR sets `GasScale` for the dev-node to 50_000.
This is motivated by the fact that storing a value in a contract storage
slot costs `DepositPerChildTrieItem + DepositPerByte * 32`, which is
`2_000_000_000 + 10_000_000 * 32` (= `2_320_000_000`) plancks. Before
this change the gas price was 1_000_000 wei, so that this
equated to 2_320_000_000 gas units. In EVM this operation requires
22_100 gas only.
Thus, `GasScale` would need to be about 100_000 in order for `SSTORE` to
have similar worst case gas requirements.
## Resolved Issues
- fixesparitytech/contract-issues#221
This PR addresses
paritytech/contract-issues#18 but we also need
to find an appropriate `GasScale` for a mainnet installment of
pallet-revive (see [this
comment](paritytech/contract-issues#18 (comment))).
---------
Co-authored-by: Alexander Theißen <[email protected]>
Co-authored-by: PG Herveou <[email protected]>
Co-authored-by: Omar Abdulla <[email protected]>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
title: Add configuration to set Ethereum gas scale
2
+
doc:
3
+
- audience: Runtime Dev
4
+
description: |-
5
+
This PR adds a new configuration parameter (`GasScale`) to pallet-revive that allows to change the scale of the Ethereum gas and of the Ethereum gas price.
6
+
7
+
Before this PR, the Ethereum gas price is simply the next fee multiplier of pallet-transaction-payment multiplied by `NativeToEthRatio`. Thus, on Polkadot this is 100_000_000 when the multiplier has its default value of 1.
8
+
9
+
The required gas of a transaction is its total cost divided by the gas price, where the total cost is the sum of the transaction fee and the storage deposit.
10
+
11
+
This leads to a situation where the required gas for a transaction on revive is usually orders of magnitude larger than the required amount of gas on Ethereum. This can lead to issues with tools or systems that interact with revive and hard code expected gas amounts or upper limits of gas amounts.
12
+
13
+
Setting `GasScale` has two effects:
14
+
- revive's Ethereum gas price is scaled up by the factor `GasScale`
15
+
- resulting used/estimated gas amounts get scaled down by the factor `GasScale`.
16
+
17
+
## Technical Details
18
+
Internally, revive uses exactly the same gas price and gas units as before. Only at the interface these amounts and prices get scaled by `GasScale`.
19
+
20
+
## Recommended
21
+
This PR sets `GasScale` for the dev-node to 50_000.
22
+
23
+
This is motivated by the fact that storing a value in a contract storage slot costs `DepositPerChildTrieItem + DepositPerByte * 32`, which is `2_000_000_000 + 10_000_000 * 32` (= `2_320_000_000`) plancks. Before this change the gas price was 1_000_000 wei, so that this
24
+
equated to 2_320_000_000 gas units. In EVM this operation requires 22_100 gas only.
25
+
26
+
Thus, `GasScale` would need to be about 100_000 in order for `SSTORE` to have similar worst case gas requirements.
27
+
28
+
## Resolved Issues
29
+
30
+
This PR addresses https://github.com/paritytech/contract-issues/issues/18 but we also need to find an appropriate `GasScale` for a mainnet installment of pallet-revive.
0 commit comments