aboutsummaryrefslogtreecommitdiffstats
path: root/vm
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-12-02 18:52:56 +0800
committerobscuren <geffobscura@gmail.com>2014-12-02 18:52:56 +0800
commit64f35ba8d1f31d6821a0a1bf946c71396a996f30 (patch)
tree375a081536c7c0b329a3b0c2e812ff05f81dd64c /vm
parent616066a598933df7ef126186eb9c647094f665ca (diff)
parent99481a245adc2c4814ab6b38d94d63114f7bbb15 (diff)
downloadgo-tangerine-64f35ba8d1f31d6821a0a1bf946c71396a996f30.tar
go-tangerine-64f35ba8d1f31d6821a0a1bf946c71396a996f30.tar.gz
go-tangerine-64f35ba8d1f31d6821a0a1bf946c71396a996f30.tar.bz2
go-tangerine-64f35ba8d1f31d6821a0a1bf946c71396a996f30.tar.lz
go-tangerine-64f35ba8d1f31d6821a0a1bf946c71396a996f30.tar.xz
go-tangerine-64f35ba8d1f31d6821a0a1bf946c71396a996f30.tar.zst
go-tangerine-64f35ba8d1f31d6821a0a1bf946c71396a996f30.zip
merge errors fixed
Diffstat (limited to 'vm')
-rw-r--r--vm/address.go8
-rw-r--r--vm/closure.go2
-rw-r--r--vm/execution.go1
-rw-r--r--vm/vm_debug.go15
4 files changed, 21 insertions, 5 deletions
diff --git a/vm/address.go b/vm/address.go
index 235143b34..06bd35f6b 100644
--- a/vm/address.go
+++ b/vm/address.go
@@ -31,12 +31,16 @@ func sha256Func(in []byte) []byte {
}
func ripemd160Func(in []byte) []byte {
- return ethutil.RightPadBytes(crypto.Ripemd160(in), 32)
+ return ethutil.LeftPadBytes(crypto.Ripemd160(in), 32)
}
func ecrecoverFunc(in []byte) []byte {
// In case of an invalid sig. Defaults to return nil
defer func() { recover() }()
- return crypto.Ecrecover(in)
+ hash := in[:32]
+ v := ethutil.BigD(in[32:64]).Bytes()[0] - 27
+ sig := append(in[64:], v)
+
+ return ethutil.LeftPadBytes(crypto.Sha3(crypto.Ecrecover(append(hash, sig...))[1:])[12:], 32)
}
diff --git a/vm/closure.go b/vm/closure.go
index ef9bbca93..5bd8c1bb8 100644
--- a/vm/closure.go
+++ b/vm/closure.go
@@ -64,7 +64,7 @@ func (c *Closure) GetOp(x int) OpCode {
}
func (c *Closure) GetByte(x int) byte {
- if x < len(c.Code) {
+ if x > -1 && x < len(c.Code) {
return c.Code[x]
}
diff --git a/vm/execution.go b/vm/execution.go
index 514405215..f8a772a1d 100644
--- a/vm/execution.go
+++ b/vm/execution.go
@@ -69,6 +69,7 @@ func (self *Execution) exec(code, caddr []byte, caller ClosureRef) (ret []byte,
if self.Gas.Cmp(p.Gas) >= 0 {
ret = p.Call(self.input)
self.vm.Printf("NATIVE_FUNC(%x) => %x", naddr, ret)
+ self.vm.Endl()
}
} else {
// Create a new callable closure
diff --git a/vm/vm_debug.go b/vm/vm_debug.go
index ce1f31b44..0a95953b0 100644
--- a/vm/vm_debug.go
+++ b/vm/vm_debug.go
@@ -163,7 +163,7 @@ func (self *DebugVm) Run(call Options) (ret []byte, gas *big.Int, err error) {
// Stack checks only
case ISZERO, CALLDATALOAD, POP, JUMP, NOT: // 1
require(1)
- case ADD, SUB, DIV, SDIV, MOD, SMOD, EXP, LT, GT, SLT, SGT, EQ, AND, OR, XOR, BYTE: // 2
+ case ADD, SUB, DIV, SDIV, MOD, SMOD, LT, GT, SLT, SGT, EQ, AND, OR, XOR, BYTE: // 2
require(2)
case ADDMOD, MULMOD: // 3
require(3)
@@ -181,6 +181,16 @@ func (self *DebugVm) Run(call Options) (ret []byte, gas *big.Int, err error) {
reqGs.Set(GasLog)
addStepGasUsage(new(big.Int).Mul(big.NewInt(int64(n)), GasLog))
addStepGasUsage(new(big.Int).Add(mSize, mStart))
+ 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 only
case STOP:
reqGas.Set(ethutil.Big0)
@@ -281,7 +291,6 @@ func (self *DebugVm) Run(call Options) (ret []byte, gas *big.Int, err error) {
addStepGasUsage(memGasUsage)
- mem.Resize(newMemSize.Uint64())
}
}
@@ -295,6 +304,8 @@ func (self *DebugVm) Run(call Options) (ret []byte, gas *big.Int, err error) {
return nil, new(big.Int), OOG(reqGas, gas)
}
+ mem.Resize(newMemSize.Uint64())
+
switch op {
// 0x20 range
case ADD: