@@ -12,45 +12,70 @@ export function updateSstoreGasEIP1283(runState: RunState, found: any, value: Bu
12
12
const { original, current } = found
13
13
if ( current . equals ( value ) ) {
14
14
// If current value equals new value (this is a no-op), 200 gas is deducted.
15
- runState . eei . useGas ( new BN ( runState . _common . param ( 'gasPrices' , 'netSstoreNoopGas' ) ) )
15
+ runState . eei . useGas (
16
+ new BN ( runState . _common . param ( 'gasPrices' , 'netSstoreNoopGas' ) ) ,
17
+ 'EIP-1283 -> netSstoreNoopGas'
18
+ )
16
19
return
17
20
}
18
21
// If current value does not equal new value
19
22
if ( original . equals ( current ) ) {
20
23
// If original value equals current value (this storage slot has not been changed by the current execution context)
21
24
if ( original . length === 0 ) {
22
25
// If original value is 0, 20000 gas is deducted.
23
- return runState . eei . useGas ( new BN ( runState . _common . param ( 'gasPrices' , 'netSstoreInitGas' ) ) )
26
+ return runState . eei . useGas (
27
+ new BN ( runState . _common . param ( 'gasPrices' , 'netSstoreInitGas' ) ) ,
28
+ 'EIP-1283 -> netSstoreInitGas'
29
+ )
24
30
}
25
31
if ( value . length === 0 ) {
26
32
// If new value is 0, add 15000 gas to refund counter.
27
- runState . eei . refundGas ( new BN ( runState . _common . param ( 'gasPrices' , 'netSstoreClearRefund' ) ) )
33
+ runState . eei . refundGas (
34
+ new BN ( runState . _common . param ( 'gasPrices' , 'netSstoreClearRefund' ) ) ,
35
+ 'EIP-1283 -> netSstoreClearRefund'
36
+ )
28
37
}
29
38
// Otherwise, 5000 gas is deducted.
30
- return runState . eei . useGas ( new BN ( runState . _common . param ( 'gasPrices' , 'netSstoreCleanGas' ) ) )
39
+ return runState . eei . useGas (
40
+ new BN ( runState . _common . param ( 'gasPrices' , 'netSstoreCleanGas' ) ) ,
41
+ 'EIP-1283 -> netSstoreCleanGas'
42
+ )
31
43
}
32
44
// If original value does not equal current value (this storage slot is dirty), 200 gas is deducted. Apply both of the following clauses.
33
45
if ( original . length !== 0 ) {
34
46
// If original value is not 0
35
47
if ( current . length === 0 ) {
36
48
// If current value is 0 (also means that new value is not 0), remove 15000 gas from refund counter. We can prove that refund counter will never go below 0.
37
- runState . eei . subRefund ( new BN ( runState . _common . param ( 'gasPrices' , 'netSstoreClearRefund' ) ) )
49
+ runState . eei . subRefund (
50
+ new BN ( runState . _common . param ( 'gasPrices' , 'netSstoreClearRefund' ) ) ,
51
+ 'EIP-1283 -> netSstoreClearRefund'
52
+ )
38
53
} else if ( value . length === 0 ) {
39
54
// If new value is 0 (also means that current value is not 0), add 15000 gas to refund counter.
40
- runState . eei . refundGas ( new BN ( runState . _common . param ( 'gasPrices' , 'netSstoreClearRefund' ) ) )
55
+ runState . eei . refundGas (
56
+ new BN ( runState . _common . param ( 'gasPrices' , 'netSstoreClearRefund' ) ) ,
57
+ 'EIP-1283 -> netSstoreClearRefund'
58
+ )
41
59
}
42
60
}
43
61
if ( original . equals ( value ) ) {
44
62
// If original value equals new value (this storage slot is reset)
45
63
if ( original . length === 0 ) {
46
64
// If original value is 0, add 19800 gas to refund counter.
47
65
runState . eei . refundGas (
48
- new BN ( runState . _common . param ( 'gasPrices' , 'netSstoreResetClearRefund' ) )
66
+ new BN ( runState . _common . param ( 'gasPrices' , 'netSstoreResetClearRefund' ) ) ,
67
+ 'EIP-1283 -> netSstoreResetClearRefund'
49
68
)
50
69
} else {
51
70
// Otherwise, add 4800 gas to refund counter.
52
- runState . eei . refundGas ( new BN ( runState . _common . param ( 'gasPrices' , 'netSstoreResetRefund' ) ) )
71
+ runState . eei . refundGas (
72
+ new BN ( runState . _common . param ( 'gasPrices' , 'netSstoreResetRefund' ) ) ,
73
+ 'EIP-1283 -> netSstoreResetRefund'
74
+ )
53
75
}
54
76
}
55
- return runState . eei . useGas ( new BN ( runState . _common . param ( 'gasPrices' , 'netSstoreDirtyGas' ) ) )
77
+ return runState . eei . useGas (
78
+ new BN ( runState . _common . param ( 'gasPrices' , 'netSstoreDirtyGas' ) ) ,
79
+ 'EIP-1283 -> netSstoreDirtyGas'
80
+ )
56
81
}
0 commit comments