smlxl / evm.codes

Source for evm.codes an Ethereum Virtual Machine Opcodes Interactive Reference
https://evm.codes/
MIT License
728 stars 135 forks source link

SSTORE gas estimation incorrectly includes static gas in some cases #247

Closed Czar102 closed 1 year ago

Czar102 commented 1 year ago

When trying to estimate a cost for an SSTORE operation (0x55), for example for (value, current value in storage, original value before the transaction) = (0, 1, 0), the field "State: 'key' is cold?" correctly picks "No" as the answer because the current value in storage is different than the original one, but nevertheless static gas is added if the user previously selected "Yes" as the answer to that question.

How to reproduce:

  1. Set "State: 'key' is cold?" to Yes.
  2. Set "Input: value" to 1.
  3. Set "State: original value before the current transaction" to 1.

The result shows "Static gas + dynamic gas = 2200", which means that 2100 static gas was charged even though the slot was warm.

peroket commented 1 year ago

Thank you, we are going to see how to fix that.