Costos de almacenamiento de gas en el mapeo, inicial vs posterior

Tengo el siguiente código de almacenamiento simple:

pragma solidity ^0.4.17;

//The Oracle contract provides the reference prices for the contracts.  Currently the Oracle is updated by an off chain calculation by DDA.  Methodology can be found at www.github.com/DecentralizedDerivatives/Oracles
contract Test_Oracle {

  /*Variables*/
  //Mapping of documents stored in the oracle
  mapping(uint => uint) oracle_values;

  //Allows the owner of the Oracle to store a document in the oracle_values mapping. Documents
  //represent underlying values at a specified date (key).
  function StoreDocument(uint _key, uint _value) public {
    oracle_values[_key] = _value;
  }

  //Allows for the viewing of oracle data
  function RetrieveData(uint _date) public constant returns (uint data) {
    return oracle_values[_date];
  }
}

Ahora creo Test Oracle y hago las siguientes transacciones:

a)StoreDocument(1,1000)
b)SotreDocument(1,1000)
c)StoreDocument(1,1000)
d)StoreDocument(2,999999999999)

Se registran los siguientes costos de transacción y ejecución:

a)42024,20304
b)27024,5034
c)27024,5034
d)42216,20304

Algunas preguntas... ¿Por qué ayb son diferentes? ¿Por qué a y d son diferentes en el costo de transacción pero no en el costo de ejecución?

Tal vez alguien un poco más familiarizado con el EVM de bajo nivel sepa una respuesta. ¡Gracias por cualquier ayuda de antemano!

Respuestas (1)

https://github.com/djrtwo/evm-opcode-gas-costs/blob/master/opcode-gas-costs_EIP-150_revision-1e18248_2017-04-12.csv es útil.

En resumen, SSTORE (almacenar un valor) cuesta 20 000 de gas si está almacenando un valor distinto de cero donde antes había un cero (como en su primer ejemplo), y cuesta 5000 de gas si está almacenando un valor distinto de cero valor donde ya había un valor distinto de cero.