mirror of https://github.com/status-im/EIPs.git
Automatically merged updates to draft EIP(s) 1087
Hi, I'm a bot! This change was automatically merged because: - It only modifies existing Draft or Last Call EIP(s) - The PR was approved or written by at least one author of each modified EIP - The build is passing
This commit is contained in:
parent
a7e495c2c7
commit
c950f128f8
|
@ -15,9 +15,9 @@ This EIP proposes a change to how gas is charged for EVM SSTORE operations, in o
|
||||||
## Motivation
|
## Motivation
|
||||||
Presently, SSTORE operations are charged as follows:
|
Presently, SSTORE operations are charged as follows:
|
||||||
|
|
||||||
- 20000 gas to set a slot from 0 to non-0
|
- 20,000 gas to set a slot from 0 to non-0
|
||||||
- 5,000 gas for any other change
|
- 5,000 gas for any other change
|
||||||
- A 10000 gas refund when a slot is set from non-0 to 0. Refunds are applied at the end of the transaction.
|
- A 10,000 gas refund when a slot is set from non-0 to 0. Refunds are applied at the end of the transaction.
|
||||||
|
|
||||||
In situations where a single update is made to a storage value in a transaction, these gas costs have been determined to fairly reflect the resources consumed by the operation. However, this results in excessive gas costs for sequences of operations that make multiple updates.
|
In situations where a single update is made to a storage value in a transaction, these gas costs have been determined to fairly reflect the resources consumed by the operation. However, this results in excessive gas costs for sequences of operations that make multiple updates.
|
||||||
|
|
||||||
|
@ -32,8 +32,9 @@ Addressing this issue would also enable new use-cases that are currently cost-pr
|
||||||
## Specification
|
## Specification
|
||||||
The following changes are made to the EVM:
|
The following changes are made to the EVM:
|
||||||
|
|
||||||
- An EVM-global 'dirty map' is maintained, tracking all storage slots in all contracts that have been modified in the current transaction.
|
- A 'dirty map' for each transaction is maintained, tracking all storage slots in all contracts that have been modified in the current transaction. The dirty map is scoped in the same manner as updates to storage, meaning that changes to the dirty map in a call that later reverts are not retained.
|
||||||
- When a storage slot is written to for the first time, the slot is marked as dirty. If the slot was previously set to 0, 20000 gas is deducted; otherwise, 5000 gas is deducted. If the slot was previously set to 0, and is being set to 0, only 200 gas is deducted.
|
- When a storage slot is written to with the value it already contains, 200 gas is deducted.
|
||||||
|
- When a storage slot's value is changed for the first time, the slot is marked as dirty. If the slot was previously set to 0, 20000 gas is deducted; otherwise, 5000 gas is deducted.
|
||||||
- When a storage slot that is already in the dirty map is written to, 200 gas is deducted.
|
- When a storage slot that is already in the dirty map is written to, 200 gas is deducted.
|
||||||
- At the end of the transaction, for each slot in the dirty map:
|
- At the end of the transaction, for each slot in the dirty map:
|
||||||
- If the slot was 0 before the transaction and is 0 now, refund 19800 gas.
|
- If the slot was 0 before the transaction and is 0 now, refund 19800 gas.
|
||||||
|
@ -59,7 +60,19 @@ This EIP requires a hard fork to implement.
|
||||||
No contract should see an increase in gas cost for this change, and many will see decreased gas consumption, so no contract-layer backwards compatibility issues are anticipated.
|
No contract should see an increase in gas cost for this change, and many will see decreased gas consumption, so no contract-layer backwards compatibility issues are anticipated.
|
||||||
|
|
||||||
## Test Cases
|
## Test Cases
|
||||||
TBD
|
|
||||||
|
- Writing x to a storage slot that contains 0, where x != 0 (20k gas, no refund)
|
||||||
|
- Writing y to a storage slot that contained x, where x != y and x != 0 (5k gas, no refund)
|
||||||
|
- Writing 0 to a storage slot that contains x, where x != 0 (5k gas, 10k refund)
|
||||||
|
- Writing 0 to a storage slot that already contains zero (200 gas, no refund)
|
||||||
|
- Writing x to a storage slot that already contains x, where x != 0 (200 gas, no refund)
|
||||||
|
- Writing x, then y to a storage slot that contains 0, where x != y (20200 gas, no refund)
|
||||||
|
- Writing x, then y to a storage slot that contains 0, where x != y != z and x != 0 (5200 gas, no refund)
|
||||||
|
- Writing x, then 0 to a storage slot that contains 0, where x != 0 (20200 gas, 19800 refund)
|
||||||
|
- Writing x, then y to a storage slot that contains y, where x != y != 0 (5200 gas, 4800 refund)
|
||||||
|
- Writing x, then 0 to a storage slot that contains 0, then reverting the stack frame in which the writes occurred (20200 gas, no refund)
|
||||||
|
- Writing x, then y to a storage slot that contains y, then reverting the stack frame in which the writes occurred (5200 gas, no refund)
|
||||||
|
- In a nested frame, writing x to a storage slot that contains 0, then returning, and writing 0 to that slot (20200 gas, 19800 refund)
|
||||||
|
|
||||||
## Implementation
|
## Implementation
|
||||||
TBD
|
TBD
|
||||||
|
|
Loading…
Reference in New Issue