diff options
author | obscuren <geffobscura@gmail.com> | 2014-03-31 00:55:51 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-03-31 00:55:51 +0800 |
commit | 205e33bc831bb44f41dc899ae41bbfe0e44ddc5d (patch) | |
tree | ce6c3dcafa0d02417058fe5ea0a6091f16a90fc0 /ethchain/vm.go | |
parent | 6625b6ffbdb93a47de2187198d6e826fb32c1ba6 (diff) | |
download | dexon-205e33bc831bb44f41dc899ae41bbfe0e44ddc5d.tar dexon-205e33bc831bb44f41dc899ae41bbfe0e44ddc5d.tar.gz dexon-205e33bc831bb44f41dc899ae41bbfe0e44ddc5d.tar.bz2 dexon-205e33bc831bb44f41dc899ae41bbfe0e44ddc5d.tar.lz dexon-205e33bc831bb44f41dc899ae41bbfe0e44ddc5d.tar.xz dexon-205e33bc831bb44f41dc899ae41bbfe0e44ddc5d.tar.zst dexon-205e33bc831bb44f41dc899ae41bbfe0e44ddc5d.zip |
Fixed bug in stack to expand beyond expectations. Fixed EQ and NOT opcode
Diffstat (limited to 'ethchain/vm.go')
-rw-r--r-- | ethchain/vm.go | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/ethchain/vm.go b/ethchain/vm.go index aefc8ff0c..18b7fe607 100644 --- a/ethchain/vm.go +++ b/ethchain/vm.go @@ -2,7 +2,7 @@ package ethchain import ( _ "bytes" - _ "fmt" + "fmt" "github.com/ethereum/eth-go/ethutil" _ "github.com/obscuren/secp256k1-go" _ "math" @@ -213,10 +213,17 @@ func (vm *Vm) RunClosure(closure *Closure) []byte { } else { stack.Push(ethutil.BigFalse) } - case oNOT: + case oEQ: x, y := stack.Popn() - // x != y - if x.Cmp(y) != 0 { + // x == y + if x.Cmp(y) == 0 { + stack.Push(ethutil.BigTrue) + } else { + stack.Push(ethutil.BigFalse) + } + case oNOT: + x := stack.Pop() + if x.Cmp(ethutil.BigFalse) == 0 { stack.Push(ethutil.BigTrue) } else { stack.Push(ethutil.BigFalse) @@ -300,8 +307,8 @@ func (vm *Vm) RunClosure(closure *Closure) []byte { case oJUMP: pc = stack.Pop() case oJUMPI: - pos, cond := stack.Popn() - if cond.Cmp(big.NewInt(0)) > 0 { + cond, pos := stack.Popn() + if cond.Cmp(ethutil.BigTrue) == 0 { pc = pos } case oPC: @@ -314,6 +321,7 @@ func (vm *Vm) RunClosure(closure *Closure) []byte { retSize, retOffset := stack.Popn() // Pop input size and offset inSize, inOffset := stack.Popn() + fmt.Println(inSize, inOffset) // Get the arguments from the memory args := mem.Get(inOffset.Int64(), inSize.Int64()) // Pop gas and value of the stack. |