smlxl / evm.codes

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

SSTORE behaviour typo or wrong description #312

Closed Gealber closed 2 months ago

Gealber commented 5 months ago

In the description of SSTORE the following code snippet it's displayed as the behavior for the computation of the base_dynamic_gas:

static_gas = 0

if value == current_value
    if key is warm
        base_dynamic_gas = 100
    else
        base_dynamic_gas = 100
else if current_value == original_value
    if original_value == 0
        base_dynamic_gas = 20000
    else
        base_dynamic_gas = 2900
else
    base_dynamic_gas = 100

Specially in the first if-else condition, the assignment in else condition seems to be incorrect, given that it's given the same base as the if condition, assigning base_dynamic_gas = 100.

if value == current_value
    if key is warm
        base_dynamic_gas = 100
    else
        base_dynamic_gas = 100

If this it's correct, then there's no point on checking that it's warm, just assigning base_dynamic_gas = 100. I think that maybe this is a typo, and in the else condition, maybe should go base_dynamic_gas = 2100, as it's described later.