From e0b6091d7ef709902f534c1a4b57151f0171e03c Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 24 Mar 2014 13:20:34 +0100 Subject: Test fixes and removed old code. Added VM gas fees --- ethchain/stack.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ethchain/stack.go') diff --git a/ethchain/stack.go b/ethchain/stack.go index 3c2899e62..57165c432 100644 --- a/ethchain/stack.go +++ b/ethchain/stack.go @@ -202,7 +202,7 @@ func (st *Stack) Push(d *big.Int) { st.data = append(st.data, d) } func (st *Stack) Print() { - fmt.Println("### STACK ###") + fmt.Println("### stack ###") if len(st.data) > 0 { for i, val := range st.data { fmt.Printf("%-3d %v\n", i, val) @@ -242,15 +242,15 @@ func (m *Memory) Len() int { } func (m *Memory) Print() { - fmt.Println("### MEM ###") + fmt.Printf("### mem %d bytes ###\n", len(m.store)) if len(m.store) > 0 { addr := 0 - for i := 0; i+32 < len(m.store); i += 32 { + for i := 0; i+32 <= len(m.store); i += 32 { fmt.Printf("%03d %v\n", addr, m.store[i:i+32]) addr++ } } else { fmt.Println("-- empty --") } - fmt.Println("###########") + fmt.Println("####################") } -- cgit From 205e33bc831bb44f41dc899ae41bbfe0e44ddc5d Mon Sep 17 00:00:00 2001 From: obscuren Date: Sun, 30 Mar 2014 18:55:51 +0200 Subject: Fixed bug in stack to expand beyond expectations. Fixed EQ and NOT opcode --- ethchain/stack.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'ethchain/stack.go') diff --git a/ethchain/stack.go b/ethchain/stack.go index 57165c432..e3fc4b684 100644 --- a/ethchain/stack.go +++ b/ethchain/stack.go @@ -173,21 +173,25 @@ func NewStack() *Stack { } func (st *Stack) Pop() *big.Int { - str := st.data[0] - st.data = st.data[1:] + str := st.data[len(st.data)-1] + + copy(st.data[:len(st.data)-1], st.data[:len(st.data)-1]) + st.data = st.data[:len(st.data)-1] return str } func (st *Stack) Popn() (*big.Int, *big.Int) { - ints := st.data[:2] - st.data = st.data[2:] + ints := st.data[len(st.data)-2:] + + copy(st.data[:len(st.data)-2], st.data[:len(st.data)-2]) + st.data = st.data[:len(st.data)-2] return ints[0], ints[1] } func (st *Stack) Peek() *big.Int { - str := st.data[0] + str := st.data[len(st.data)-1] return str } -- cgit