Skip to content

Commit 48125a2

Browse files
committed
Added missing requires on SSTORE SLOAD
1 parent 7849b7e commit 48125a2

2 files changed

Lines changed: 17 additions & 12 deletions

File tree

‎vm/common.go‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@ const (
1919
)
2020

2121
var (
22-
GasStep = big.NewInt(1)
23-
GasSha = big.NewInt(20)
24-
GasSLoad = big.NewInt(20)
25-
GasSStore = big.NewInt(100)
26-
GasBalance = big.NewInt(20)
27-
GasCreate = big.NewInt(100)
28-
GasCall = big.NewInt(20)
29-
GasMemory = big.NewInt(1)
30-
GasData = big.NewInt(5)
31-
GasTx = big.NewInt(500)
32-
GasLog = big.NewInt(32)
22+
GasStep = big.NewInt(1)
23+
GasSha = big.NewInt(20)
24+
GasSLoad = big.NewInt(20)
25+
GasSStore = big.NewInt(100)
26+
GasSStoreRefund = big.NewInt(100)
27+
GasBalance = big.NewInt(20)
28+
GasCreate = big.NewInt(100)
29+
GasCall = big.NewInt(20)
30+
GasMemory = big.NewInt(1)
31+
GasData = big.NewInt(5)
32+
GasTx = big.NewInt(500)
33+
GasLog = big.NewInt(32)
3334

3435
Pow256 = ethutil.BigPow(2, 256)
3536

‎vm/vm_debug.go‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,21 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
169169

170170
gas.Set(ethutil.Big0)
171171
case SLOAD:
172+
require(1)
173+
172174
gas.Set(GasSLoad)
173175
// Memory resize & Gas
174176
case SSTORE:
177+
require(2)
178+
175179
var mult *big.Int
176180
y, x := stack.Peekn()
177181
val := closure.GetStorage(x)
178182
if val.BigInt().Cmp(ethutil.Big0) == 0 && len(y.Bytes()) > 0 {
179183
// 0 => non 0
180184
mult = ethutil.Big3
181185
} else if val.BigInt().Cmp(ethutil.Big0) != 0 && len(y.Bytes()) == 0 {
182-
state.Refund(closure.caller.Address(), big.NewInt(100), closure.Price)
186+
state.Refund(closure.caller.Address(), GasSStoreRefund, closure.Price)
183187

184188
mult = ethutil.Big0
185189
} else {

0 commit comments

Comments
 (0)