aboutsummaryrefslogtreecommitdiffstats
path: root/vm
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-12-19 04:58:26 +0800
committerobscuren <geffobscura@gmail.com>2014-12-19 04:58:26 +0800
commit198cc69357a0f25ae486a041786e1239c6f5ab0f (patch)
tree39f4b8c4a8b8360d2fe2fc5583438f948e095524 /vm
parent5ad473d7581b92811c3a3e035274a82fc5568f57 (diff)
downloadgo-tangerine-198cc69357a0f25ae486a041786e1239c6f5ab0f.tar.gz
go-tangerine-198cc69357a0f25ae486a041786e1239c6f5ab0f.tar.zst
go-tangerine-198cc69357a0f25ae486a041786e1239c6f5ab0f.zip
Gas corrections and vm fixes
Diffstat (limited to 'vm')
-rw-r--r--vm/common.go2
-rw-r--r--vm/vm_debug.go20
2 files changed, 11 insertions, 11 deletions
diff --git a/vm/common.go b/vm/common.go
index 3d6d377ca..529bbdeb1 100644
--- a/vm/common.go
+++ b/vm/common.go
@@ -37,7 +37,7 @@ var (
GasLog = big.NewInt(32)
GasSha256 = big.NewInt(50)
GasRipemd = big.NewInt(50)
- GasEcrecover = big.NewInt(100)
+ GasEcrecover = big.NewInt(500)
Pow256 = ethutil.BigPow(2, 256)
diff --git a/vm/vm_debug.go b/vm/vm_debug.go
index 9da832a79..d78aff4ce 100644
--- a/vm/vm_debug.go
+++ b/vm/vm_debug.go
@@ -2,6 +2,7 @@ package vm
import (
"fmt"
+ "math"
"math/big"
"github.com/ethereum/go-ethereum/crypto"
@@ -112,7 +113,7 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
return closure.Return(nil), nil
}
- vmlogger.Debugf("(%d) %x gas: %v (d) %x\n", self.env.Depth(), closure.Address(), closure.Gas, callData)
+ vmlogger.Debugf("(%d) (%x) %x gas: %v (d) %x\n", self.env.Depth(), caller.Address()[:4], closure.Address(), closure.Gas, callData)
for {
prevStep = step
@@ -185,11 +186,11 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
// 0 => non 0
mult = ethutil.Big3
} else if val.BigInt().Cmp(ethutil.Big0) != 0 && len(y.Bytes()) == 0 {
- statedb.Refund(closure.caller.Address(), GasSStoreRefund, closure.Price)
+ statedb.Refund(caller.Address(), GasSStoreRefund)
mult = ethutil.Big0
} else {
- // non 0 => non 0
+ // non 0 => non 0 (or 0 => 0)
mult = ethutil.Big1
}
gas.Set(new(big.Int).Mul(mult, GasSStore))
@@ -660,7 +661,7 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
cOff = 0
l = 0
} else if cOff+l > size {
- l = 0
+ l = uint64(math.Min(float64(cOff+l), float64(size)))
}
codeCopy := code[cOff : cOff+l]
@@ -776,10 +777,7 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
val, loc := stack.Popn()
statedb.SetState(closure.Address(), loc.Bytes(), val)
- // Debug sessions are allowed to run without message
- if closure.message != nil {
- closure.message.AddStorageChange(loc.Bytes())
- }
+ closure.message.AddStorageChange(loc.Bytes())
self.Printf(" {0x%x : 0x%x}", loc.Bytes(), val.Bytes())
case JUMP:
@@ -898,10 +896,12 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
return closure.Return(ret), nil
case SUICIDE:
-
receiver := statedb.GetOrNewStateObject(stack.Pop().Bytes())
+ balance := statedb.GetBalance(closure.Address())
+
+ self.Printf(" => (%x) %v", receiver.Address()[:4], balance)
- receiver.AddAmount(statedb.GetBalance(closure.Address()))
+ receiver.AddAmount(balance)
statedb.Delete(closure.Address())
fallthrough