aboutsummaryrefslogtreecommitdiffstats
path: root/vm/vm_debug.go
diff options
context:
space:
mode:
Diffstat (limited to 'vm/vm_debug.go')
-rw-r--r--vm/vm_debug.go26
1 files changed, 14 insertions, 12 deletions
diff --git a/vm/vm_debug.go b/vm/vm_debug.go
index 0a541a769..c0a2d6d98 100644
--- a/vm/vm_debug.go
+++ b/vm/vm_debug.go
@@ -166,13 +166,7 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
case EXP:
require(2)
- exp := new(big.Int).Set(stack.data[stack.Len()-2])
- nbytes := 0
- for exp.Cmp(ethutil.Big0) > 0 {
- nbytes += 1
- exp.Rsh(exp, 8)
- }
- gas.Set(big.NewInt(int64(nbytes + 1)))
+ gas.Set(big.NewInt(int64(len(stack.data[stack.Len()-2].Bytes()) + 1)))
// Gas only
case STOP:
gas.Set(ethutil.Big0)
@@ -260,9 +254,12 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
newMemSize.Mul(newMemSize, u256(32))
switch op {
- // Additional gas usage on *CODPY
case CALLDATACOPY, CODECOPY, EXTCODECOPY:
addStepGasUsage(new(big.Int).Div(newMemSize, u256(32)))
+ case SHA3:
+ g := new(big.Int).Div(newMemSize, u256(32))
+ g.Mul(g, GasSha3Byte)
+ addStepGasUsage(g)
}
if newMemSize.Cmp(u256(int64(mem.Len()))) > 0 {
@@ -744,12 +741,12 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
case LOG0, LOG1, LOG2, LOG3, LOG4:
n := int(op - LOG0)
topics := make([][]byte, n)
- mSize, mStart := stack.Pop().Int64(), stack.Pop().Int64()
- data := mem.Geti(mStart, mSize)
+ mSize, mStart := stack.Popn()
for i := 0; i < n; i++ {
topics[i] = ethutil.LeftPadBytes(stack.Pop().Bytes(), 32)
}
+ data := mem.Geti(mStart.Int64(), mSize.Int64())
log := &Log{closure.Address(), topics, data}
self.env.AddLog(log)
@@ -839,8 +836,13 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
self.Printf("CREATE err %v", err)
} else {
- ref.SetCode(ret)
- msg.Output = ret
+ // gas < len(ret) * CreateDataGas == NO_CODE
+ dataGas := big.NewInt(int64(len(ret)))
+ dataGas.Mul(dataGas, GasCreateByte)
+ if closure.UseGas(dataGas) {
+ ref.SetCode(ret)
+ msg.Output = ret
+ }
stack.Push(ethutil.BigD(addr))
}