Skip to content

Commit 6b5c7cf

Browse files
authored
Update EIP-7623: Clarify the gas refunds handling
Merged by EIP-Bot.
1 parent c63e59d commit 6b5c7cf

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

EIPS/eip-7623.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,42 +25,45 @@ By introducing a floor cost dependent on the ratio of gas spent on EVM operation
2525

2626
## Specification
2727

28-
| Parameter | Value |
29-
| - | - |
30-
| `STANDARD_TOKEN_COST` | `4` |
31-
| `TOTAL_COST_FLOOR_PER_TOKEN` | `10` |
28+
| Parameter | Value |
29+
|------------------------------|-------|
30+
| `STANDARD_TOKEN_COST` | `4` |
31+
| `TOTAL_COST_FLOOR_PER_TOKEN` | `10` |
3232

3333

3434
Let `tokens_in_calldata = zero_bytes_in_calldata + nonzero_bytes_in_calldata * 4`.
3535

3636
Let `isContractCreation` be a boolean indicating the respective event.
3737

38-
The current formula for determining the gas used per transaction, typically described as `nonzero_bytes_in_calldata * 16 + zero_bytes_in_calldata * 4`, is equivalent to:
38+
Let `execution_gas_used` be the gas used for EVM execution with the gas refund subtracted.
39+
40+
The current formula for determining the total gas used per transaction (`tx.gasUsed`) is equivalent to:
3941

4042
```python
4143
tx.gasUsed = (
4244
21000
43-
+ STANDARD_TOKEN_COST * tokens_in_calldata
44-
+ evm_gas_used
45-
+ isContractCreation * (32000 + InitCodeWordGas * words(calldata))
45+
+ STANDARD_TOKEN_COST * tokens_in_calldata
46+
+ execution_gas_used
47+
+ isContractCreation * (32000 + INITCODE_WORD_COST * words(calldata))
4648
)
4749
```
4850

4951
The formula for determining the gas used per transaction changes to:
5052

5153
```python
52-
tx.gasUsed = {
54+
tx.gasUsed = (
5355
21000
54-
+
55-
max (
56+
+
57+
max(
5658
STANDARD_TOKEN_COST * tokens_in_calldata
57-
+ evm_gas_used
58-
+ isContractCreation * (32000 + InitCodeWordGas * words(calldata)),
59+
+ execution_gas_used
60+
+ isContractCreation * (32000 + INITCODE_WORD_COST * words(calldata)),
5961
TOTAL_COST_FLOOR_PER_TOKEN * tokens_in_calldata
6062
)
63+
)
6164
```
6265

63-
Any transaction with a gas limit below `21000 + TOTAL_COST_FLOOR_PER_TOKEN * tokens_in_calldata` or below it's intrinsic gas cost (take the maximum of these two calculations) is considered invalid. This limitation exists because transactions must cover the floor price of their calldata without relying on the execution of the transaction. There are valid cases where `gasUsed` will be below this floor price, but the floor price needs to be reserved in the transaction gas limit.
66+
Any transaction with a gas limit below `21000 + TOTAL_COST_FLOOR_PER_TOKEN * tokens_in_calldata` or below its intrinsic gas cost (take the maximum of these two calculations) is considered invalid. This limitation exists because transactions must cover the floor price of their calldata without relying on the execution of the transaction. There are valid cases where `gasUsed` will be below this floor price, but the floor price needs to be reserved in the transaction gas limit.
6467

6568
## Rationale
6669

0 commit comments

Comments
 (0)