From 3addc2e4217243c112406228b4d040770a74924d Mon Sep 17 00:00:00 2001 From: Green <40367733+greenlucid@users.noreply.github.com> Date: Wed, 20 Apr 2022 15:39:28 +0200 Subject: [PATCH 1/3] init eip --- EIPS/eip-XXXX.md | 67 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 EIPS/eip-XXXX.md diff --git a/EIPS/eip-XXXX.md b/EIPS/eip-XXXX.md new file mode 100644 index 0000000000000..c62a0248c8a69 --- /dev/null +++ b/EIPS/eip-XXXX.md @@ -0,0 +1,67 @@ +--- +eip: XXXX +title: Increase price of SSTORE from zero to non-zero to 40k gas +author: Green (@greenlucid) +status: Draft +type: Standards Track +category: Core +created: 2022-04-20 +discussions-to: https://ethereum-magicians.org/t/eip-proposal-increase-cost-of-sstore-from-20k-to-x-when-creating-new-storage/7614 +--- + +### Abstract + +Increase the price of the SSTORE opcode from `20_000` gas to `NEW_STORAGE_PRICE` gas when the original slot is zero and the resultant slot is non-zero. + +### Motivation + +The cost of creating a piece of new state increases as state is larger. However, the price for creating every new storage slot has not increased. +All resources are merged into the same pricing mechanism. If the price for creating new storage slots is fixed, then it needs to be manually changed. + +One of the main reasons for not increasing gas limit is the increase of state. In that regard, because the cost of creating storage is higher than its price, all the users of all the other opcodes are subsidizing the creation of state. If state creation was more precisely priced, raising gas limit would be more feasible, and would benefit the users. + +## Rationale + +### Why not also raise the cost of non-zero to non-zero? + +Rewriting storage does not affect state growth, which is the main issue this EIP is addressing. Rewriting storage may also be underpriced. +Increasing the price of state growth will, at least, incentivize developers to reuse storage instead. + +### Why not also increase the gas refund from setting non-zero to zero? + +More discussion is needed on this. + +### Why not a better state solution? + +Whereas solutions like state rent, or state expiry have been researched for a long time, they will not be ready on the short to medium term. So, it is desirable to patch pricing for the short term. Opcode repricing has been done before, so it should not impose a large development time investment for clients. + +### Why was that specific amount chosen? + +The current pricing was made off a naive approach of benchmarking opcodes in a laptop. Not only it did not consider the long term problem of having the same price for a resource that costs more over time, the benchmark itself was wrong. This price is closer to what the naive original benchmark should have been. It could go higher, but that may be too disruptive. + +### Is this too distruptive? + +This change will severely impact the gas cost of many applications. The network does not have to subsidize state growth at the expense of more expensive regular transactions, so even if it is too disruptive, it will increase the health of the network. + +### Specification + +| Constant | Value | +| - | - | +| `FORK_BLOCK` | TBD | +| `NEW_STORAGE_PRICE` | `40_000` + +For blocks where `block.number >= FORK_BLOCK`, a new gas schedule applies. Make `SSTORE_SET_GAS`, the price when a slot is set from zero to non-zero, equal `NEW_STORAGE_PRICE`. All other costs remain the same. + +### Backwards compatibility + +Contracts that depend on hardcoded gas costs will break if they create state. + +It is a gas schedule change, so transactions from an epoch before FORK_BLOCK should be treated with previous gas costs. + +## Implementation + +TODO + +## Security considerations + +TODO \ No newline at end of file From 3171018ae17e07d139197c79ba27c92d2175de26 Mon Sep 17 00:00:00 2001 From: Green <40367733+greenlucid@users.noreply.github.com> Date: Wed, 20 Apr 2022 15:43:51 +0200 Subject: [PATCH 2/3] add eip number --- EIPS/{eip-XXXX.md => eip-5022.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename EIPS/{eip-XXXX.md => eip-5022.md} (94%) diff --git a/EIPS/eip-XXXX.md b/EIPS/eip-5022.md similarity index 94% rename from EIPS/eip-XXXX.md rename to EIPS/eip-5022.md index c62a0248c8a69..632745de1c7ad 100644 --- a/EIPS/eip-XXXX.md +++ b/EIPS/eip-5022.md @@ -1,5 +1,5 @@ --- -eip: XXXX +eip: 5022 title: Increase price of SSTORE from zero to non-zero to 40k gas author: Green (@greenlucid) status: Draft @@ -11,7 +11,7 @@ discussions-to: https://ethereum-magicians.org/t/eip-proposal-increase-cost-of-s ### Abstract -Increase the price of the SSTORE opcode from `20_000` gas to `NEW_STORAGE_PRICE` gas when the original slot is zero and the resultant slot is non-zero. +Increase the price of the SSTORE opcode from `20_000` gas to `40_000` gas when the original slot is zero and the resultant slot is non-zero. ### Motivation From d52b9bdaccfe3f6461e61df114788fd762cbb414 Mon Sep 17 00:00:00 2001 From: Green <40367733+greenlucid@users.noreply.github.com> Date: Wed, 20 Apr 2022 18:38:53 +0200 Subject: [PATCH 3/3] add implementation --- EIPS/eip-5022.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-5022.md b/EIPS/eip-5022.md index 632745de1c7ad..dbc10a2c86570 100644 --- a/EIPS/eip-5022.md +++ b/EIPS/eip-5022.md @@ -60,7 +60,7 @@ It is a gas schedule change, so transactions from an epoch before FORK_BLOCK sho ## Implementation -TODO +https://github.com/ethereum/go-ethereum/pull/24725 ## Security considerations