From c51db4c940a5ea679aee580a673a4ccdd2421b9a Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 8 Aug 2014 14:36:59 +0100 Subject: [PATCH] Fixed stack issue --- ethchain/state_manager.go | 7 ++++--- ethpipe/config.go | 1 - ethvm/stack.go | 2 +- ethvm/vm.go | 26 +++++++++++++------------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go index 226b2fe73..f06622fcb 100644 --- a/ethchain/state_manager.go +++ b/ethchain/state_manager.go @@ -4,15 +4,16 @@ import ( "bytes" "container/list" "fmt" + "math/big" + "sync" + "time" + "github.com/ethereum/eth-go/ethcrypto" "github.com/ethereum/eth-go/ethlog" "github.com/ethereum/eth-go/ethreact" "github.com/ethereum/eth-go/ethstate" "github.com/ethereum/eth-go/ethutil" "github.com/ethereum/eth-go/ethwire" - "math/big" - "sync" - "time" ) var statelogger = ethlog.NewLogger("STATE") diff --git a/ethpipe/config.go b/ethpipe/config.go index 1e246c7b4..6c24df640 100644 --- a/ethpipe/config.go +++ b/ethpipe/config.go @@ -18,7 +18,6 @@ func (self *Config) Get(name string) *Object { case "DnsReg": objectAddr := configCtrl.GetStorage(ethutil.BigD([]byte{0})) domainAddr := (&Object{self.pipe.World().safeGet(objectAddr.Bytes())}).StorageString("DnsReg").Bytes() - return &Object{self.pipe.World().safeGet(domainAddr)} default: addr = ethutil.RightPadBytes([]byte(name), 32) diff --git a/ethvm/stack.go b/ethvm/stack.go index c06d63652..f4b0be393 100644 --- a/ethvm/stack.go +++ b/ethvm/stack.go @@ -59,7 +59,7 @@ func (st *Stack) Peek() *big.Int { } func (st *Stack) Peekn() (*big.Int, *big.Int) { - ints := st.data[:2] + ints := st.data[len(st.data)-2:] return ints[0], ints[1] } diff --git a/ethvm/vm.go b/ethvm/vm.go index 995fd897b..a3c273f62 100644 --- a/ethvm/vm.go +++ b/ethvm/vm.go @@ -129,14 +129,14 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) { fmt.Printf("%x %x\n", new(big.Int).SetBytes([]byte(key)).Bytes(), value.Bytes()) }) } - - b := pc.Bytes() - if len(b) == 0 { - b = []byte{0} - } - - fmt.Printf("%x %x %x %x\n", closure.Address(), b, []byte{byte(op)}, closure.Gas.Bytes()) */ + + b := pc.Bytes() + if len(b) == 0 { + b = []byte{0} + } + + fmt.Printf("%x %x %x %x\n", closure.Address(), b, []byte{byte(op)}, closure.Gas.Bytes()) } gas := new(big.Int) @@ -856,12 +856,12 @@ func (self *Vm) Endl() *Vm { } func ensure256(x *big.Int) { - maxInt, _ := new(big.Int).SetString("115792089237316195423570985008687907853269984665640564039457584007913129639935", 0) - if x.Cmp(maxInt) >= 0 { - x.SetInt64(0) - - return - } + //max, _ := big.NewInt(0).SetString("115792089237316195423570985008687907853269984665640564039457584007913129639936", 0) + //if x.Cmp(max) >= 0 { + d := big.NewInt(1) + d.Lsh(d, 256).Sub(d, big.NewInt(1)) + x.And(x, d) + //} // Could have done this with an OR, but big ints are costly.