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
Copy file name to clipboardExpand all lines: EIPS/eip-0000.md
+43-17Lines changed: 43 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,11 +13,11 @@ requires: 2780
13
13
14
14
## Abstract
15
15
16
-
This proposal increases the cost of state creation operations, thus avoiding excessive state growth under increased block gas limits. It sets a unit cost per new state byte that targets an average state growth of 60 GiB per year at a block gas limit of 300M gas units and an average gas utilization for state growth of 30%. Contract deployments get a 10x cost increase while new accounts get a 8.5x increase. To avoid limiting the maximum contract size that can be deployed, it also introduces an independent metering for code deposit costs.
16
+
This proposal increases the cost of state creation operations, thus avoiding excessive state growth under increased block gas limits. It sets a unit cost per new state byte that targets an average state growth of 60 GiB per year at a block gas limit of 300M gas units and an average gas utilization for state growth of 30%. Contract deployments get a 10x cost increase while new accounts get a 8.5x increase. Deployments of duplicated do not pay deposit costs. To avoid limiting the maximum contract size that can be deployed, it also introduces an independent metering for code deposit costs.
17
17
18
18
## Motivation
19
19
20
-
State creation does not have a harmonized cost, with different methods incurring varied costs for creating the same size of new state. For instance, while contract deployment only costs 202 gas units per new byte created, new storage slots cost 625 gas units per new byte created. This proposal establishes a standard to harmonize all state creation operations.
20
+
State creation does not have a harmonized cost, with different methods incurring varied costs for creating the same size of new state. For instance, while contract deployment only costs 202 gas units per new byte created, new storage slots cost 625 gas units per new byte created. Also, deploying duplicated bytecode costs the same as deploying new bytecode, even though clients don't store duplicated code in the database. This proposal establishes a standard to harmonize all state creation operations.
21
21
22
22
Additionally, state growth will become a bottleneck for scaling under higher block limits. As of May 2025, the current database size in a Geth node dedicated to state is ~340 GiB. After the increase in gas limit from 30M to 36M gas units, the median size of new state created each day doubled, from ~102 MiB to ~205 MiB.
23
23
@@ -27,20 +27,37 @@ The relationship we are seeing in this example is not linear as expected. This i
27
27
28
28
## Specification
29
29
30
+
### Parameter changes
31
+
30
32
Upon activation of this EIP, the following parameters of the gas model are updated:
### Multidimensional metering for code deposit gas
45
+
42
46
Besides the parameter changes, this proposal introduces an independent metering for the code deposit costs. The specification is derived from [EIP-8011](./eip-8011.md). However, it only requires two dimensions, namely, `gas` and `code_deposit_gas`.
43
47
48
+
### Contract deployment cost calculation
49
+
50
+
This proposal further changes how contract deployment cost are computed. When a contract creation returns a runtime bytecode `R` (length `L`), first check whether the code already exists in the state trie. Then:
51
+
52
+
- If `CodeExists(keccak256(R), live_state) == false`, charge `code_deposit_cost=GAS_CODE_DEPOSIT*L` and store `R` under its code hash.
53
+
- If `CodeExists(...) == true`, do not charge code-deposit storage gas (`code_deposit_gas=0`); simply link the new account's `codeHash` to the existing code object.
54
+
55
+
In addition, contract creation is also charged a `storage_access_cost = GAS_WARM_ACCESS (if warm) | GAS_COLD_SLOAD (if cold)` and a `hash_cost = GAS_KECCAK256_WORD * code_data_words`, where `code_data_words = ceil(L / 32)`. This accounts for the added execution cost of accessing and verifying for duplicated code.
56
+
57
+
#### `CREATE` vs `CREATE2`
58
+
59
+
`CREATE2` already charges for hashing the init code when deriving the address. That cost remains. Runtime-code deduplication hash (`keccak256(R)`) is separate: even with `CREATE2`, the runtime hash must be computed to determine whether the code is new or already stored.
60
+
44
61
## Rationale
45
62
46
63
### Harmonization across state creation
@@ -61,33 +78,31 @@ This capacity corresponds to an average of $\frac{60 \times 1024^3}{365} = 176,5
61
78
62
79
Now that we have a standardized cost per byte, we can derive the various costs parameters by multiplying the unit cost by the increase in bytes any given operation creates in the database (i.e., 32 bytes per slot, 112 bytes per account and 23 bytes per authorization):
63
80
81
+
-`GAS_CREATE` = 112 x `cost_per_state_byte`= 212,800
-`GAS_STORAGE_SET` = 32 x `cost_per_state_byte` = 60,800
66
84
-`GAS_NEW_ACCOUNT` = 112 x `cost_per_state_byte`= 212,800
67
85
-`GAS_SELF_DESTRUCT_NEW_ACCOUNT` = 112 x `cost_per_state_byte` = 212,800
68
86
-`PER_EMPTY_ACCOUNT_COST` = 112 x `cost_per_state_byte` = 212,800
69
87
-`PER_AUTH_BASE_COST` = 23 x `cost_per_state_byte` = 43,700
70
88
71
-
### Contract creation premium
72
-
73
-
The `GAS_CREATE` parameter is set differently from the remaining parameters. This parameter aims to encode a premium paid for deploying contracts.
74
-
75
-
Between genesis and the pre-Pectra block 22,431,083, 55% of all deployed contracts were never accessed after being deployed. This includes MEV or utility contracts that are created for a single transaction, mass-mint factories that never see adoption or even testing contracts.
76
-
77
-
In addition, contract deployment is done by very few accounts, with only 5.6 million accounts (around 2.3%) having deployed at least one contract since genesis.
78
-
79
-
Finally, compared with the overall costs of developing DApps, the contract deployment cost is fairly low.
80
-
81
-
Thus, **we define the `GAS_CREATE` parameter as a fixed cost representing a 10% premium over the code deposit cost of a 24 kB contract**. With the new pricing, a 24 kB contract pays $1,900 \times 24,576 = 46,694,400$ gas units of code deposit. Ten percent of that is roughly 5,000,000 gas units.
89
+
Note that the fixed cost `GAS_CREATE` for contract deployments assumes the same cost as a new account creation.
82
90
83
91
### Multidimensional metering
84
92
85
-
[EIP-7825](./eip-7825.md) introduces a limit of 16.7M gas units for a single transaction. With the proposed contract creation costs, this cap would limit the maximum contract size that can be deployed to roughly 6kb ((16,777,216 - 21,000 - 5,000,000 - 212,800)/1,900 = 6,075). The limit by transaction was set in place to mitigate DoS attacks that result in uneven load distribution. This is not a concern for contract deployments, specially after the proposed 10x increase in costs.
93
+
[EIP-7825](./eip-7825.md) introduces a limit of 16.7M gas units for a single transaction. With the proposed contract creation costs, this cap would limit the maximum contract size that can be deployed to roughly 6kb ($\frac{16,777,216 - 21,000 - 5,000,000 - 212,800}{1,900} = 6,075$). The limit by transaction was set in place to mitigate DoS attacks that result in uneven load distribution. This is not a concern for contract deployments, specially after the proposed 10x increase in costs.
86
94
87
95
An independent metering of the code deposit costs allows to lift this limit for contract creation transactions, while ensuring that users still pay the fair costs of contract deployment.
88
96
89
97
This proposal is consistent with the multidimensional gas metering introduced in [EIP-8011](./eip-8011.md). However, it only requires two dimensions, namely, `gas` and `code_deposit_gas`. If [EIP-8011](./eip-8011.md) is not implemented, a two-dimensional version of [EIP-8011](./eip-8011.md) is still required.
90
98
99
+
### Duplicated bytecode discount
100
+
101
+
- Ordering & same-block deployments: Sequential transaction execution ensures that a deployment storing new code makes it visible to later transactions in the same block. First transaction paying `code_deposit_cost`; subsequent transactions see the code as present and pay only lookup + hash costs.
102
+
- Hashing cost is necessary: Always charge `hash_cost` for runtime code. Protects against abuse with large constructor outputs.
103
+
- What counts as “same code”? Exact runtime bytecode. Even minor differences produce distinct hashes.
104
+
- Empty code handling: Clients can treat empty code as a special case with a hard-coded hash lookup (`EMPTY_CODE_HASH`), making it effectively free.
105
+
91
106
## Backwards Compatibility
92
107
93
108
This is a backwards-incompatible gas repricing that requires a scheduled network upgrade.
@@ -115,8 +130,15 @@ New slot:
115
130
116
131
24kB contract deployment:
117
132
118
-
- OLD: 0.5 Gwei x (32,000 + 25,000 + 200 × 24,576) x 4,000 USD = 9.9444 USD
119
-
- NEW: 0.5 Gwei x (5,000,000 + 212,800 + 1,900 × 24,576) x 4,000 USD = 103.814 USD
133
+
- OLD: 0.5 Gwei x (32,000 + 200 × 24,576) x 4,000 USD = 9.8944 USD
24kB contract deployment with duplicated bytecode:
137
+
138
+
- OLD: 0.5 Gwei x (32,000 + 200 × 24,576) x 4,000 USD = 9.8944 USD
139
+
- NEW: 0.5 Gwei x (212,800 + 2100 + 6 * 768) x 4,000 USD = 0.439 USD
140
+
141
+
Note that we are ignoring transaction intrinsic costs (21k gas units), call data costs, and the costs of additional opcodes and scaffolding needed to execute such transactions.
120
142
121
143
## Security Considerations
122
144
@@ -128,6 +150,10 @@ One potential concern is the cost of creating a new account (212,800 gas units),
128
150
129
151
[EIP-2780](./eip-2780.md) solves this mispricing by adding a new component to the intrinsic gas cost of transactions. For transactions the sending ETH that send ETH to a fresh account. If a non-create transaction has value > 0 and targets a non-existent account, the `GAS_NEW_ACCOUNT` is added to intrinsic cost.
130
152
153
+
### Independent metering for code deposit costs
154
+
155
+
Contract creation now introduces a cost that is not accounted for in the traditional gas metering and thus doesn't contribute to the block gas limit or the individual transaction limit. This could potentially be exploited by an attacker to create very large contracts that would stress the network. More benchmarking and analysis is needed to understand the potential risks and to determine if additional mitigations are necessary.
156
+
131
157
## Copyright
132
158
133
159
Copyright and related rights waived via [CC0](../LICENSE.md).
0 commit comments