1

Maybe a little bit weird question, but can the amount of gas, when:

SSTORE

is used(for changing an existing variable), be lesser than 5000 gas? If no, are there discussions in community to reduce these costs?

1

Kind of. SSTORE has a few "gotchas" about its pricing, here they are:

  1. If SSTORE changes a zero value to nonzero, it costs 20k
  2. If SSTORE changes a nonzero value to nonzero, it costs 5k
  3. If SSTORE changes a nonzero value to zero, it costs 5k, but also adds 15k refund counter, which is refunded (up to half the transaction's total gas) at the end of the transaction.

There's also the net gas metering EIP that was originally in the Constantinople fork but was removed last month due to worries about changing invariants. Essentially, that EIP would drastically lower gas costs for multiple changes in one transaction, since multiple changes don't all need to be committed to the state.

  • So basically what I found here: eips.ethereum.org/EIPS/eip-1087, is what you are saying. Why is it removed from Constantinople fork, do you have some infos, logical reasons(maybe because of miners) or to be clear, what are these "worries about changing invariants"? – gorpen Feb 18 at 14:35
  • That was an earlier version. The version that was in Constantinople was this one: eips.ethereum.org/EIPS/eip-1283. It was removed because people rely on the high costs of state modification to avoid reentrancy, but lowering the lowest state change cost to 200 gas would break that usage and make many existing contracts vulnerable. There will likely be a work around within the EIP to make it secure and added to the next fork (hopefully later this year) – flygoing Feb 18 at 14:37
  • I understand, thanks for the explanation, it helped a lot. – gorpen Feb 18 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.