Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
59d8dc39
Commit
59d8dc39
authored
Mar 20, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed issue with stack where it sliced of the wrong values
parent
38ea6a6d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
5 deletions
+63
-5
stack.go
ethchain/stack.go
+63
-5
No files found.
ethchain/stack.go
View file @
59d8dc39
...
@@ -2,6 +2,7 @@ package ethchain
...
@@ -2,6 +2,7 @@ package ethchain
import
(
import
(
"fmt"
"fmt"
"github.com/ethereum/eth-go/ethutil"
"math/big"
"math/big"
)
)
...
@@ -60,6 +61,10 @@ const (
...
@@ -60,6 +61,10 @@ const (
oBALANCE
=
0x3c
oBALANCE
=
0x3c
oMKTX
=
0x3d
oMKTX
=
0x3d
oSUICIDE
=
0x3f
oSUICIDE
=
0x3f
// TODO FIX OPCODES
oCALL
=
0x40
oRETURN
=
0x41
)
)
// Since the opcodes aren't all in order we can't use a regular slice
// Since the opcodes aren't all in order we can't use a regular slice
...
@@ -114,6 +119,9 @@ var opCodeToString = map[OpCode]string{
...
@@ -114,6 +119,9 @@ var opCodeToString = map[OpCode]string{
oBALANCE
:
"BALANCE"
,
oBALANCE
:
"BALANCE"
,
oMKTX
:
"MKTX"
,
oMKTX
:
"MKTX"
,
oSUICIDE
:
"SUICIDE"
,
oSUICIDE
:
"SUICIDE"
,
oCALL
:
"CALL"
,
oRETURN
:
"RETURN"
,
}
}
func
(
o
OpCode
)
String
()
string
{
func
(
o
OpCode
)
String
()
string
{
...
@@ -141,6 +149,56 @@ func NewStack() *Stack {
...
@@ -141,6 +149,56 @@ func NewStack() *Stack {
}
}
func
(
st
*
Stack
)
Pop
()
*
big
.
Int
{
func
(
st
*
Stack
)
Pop
()
*
big
.
Int
{
str
:=
st
.
data
[
0
]
st
.
data
=
st
.
data
[
1
:
]
return
str
}
func
(
st
*
Stack
)
Popn
()
(
*
big
.
Int
,
*
big
.
Int
)
{
ints
:=
st
.
data
[
:
2
]
st
.
data
=
st
.
data
[
2
:
]
return
ints
[
0
],
ints
[
1
]
}
func
(
st
*
Stack
)
Peek
()
*
big
.
Int
{
str
:=
st
.
data
[
0
]
return
str
}
func
(
st
*
Stack
)
Peekn
()
(
*
big
.
Int
,
*
big
.
Int
)
{
ints
:=
st
.
data
[
:
2
]
return
ints
[
0
],
ints
[
1
]
}
func
(
st
*
Stack
)
Push
(
d
*
big
.
Int
)
{
st
.
data
=
append
(
st
.
data
,
d
)
}
func
(
st
*
Stack
)
Print
()
{
fmt
.
Println
(
"### STACK ###"
)
if
len
(
st
.
data
)
>
0
{
for
i
,
val
:=
range
st
.
data
{
fmt
.
Printf
(
"%-3d %v
\n
"
,
i
,
val
)
}
}
else
{
fmt
.
Println
(
"-- empty --"
)
}
fmt
.
Println
(
"#############"
)
}
////////////// TODO this will eventually become the main stack once the big ints are removed from the VM
type
ValueStack
struct
{
data
[]
*
ethutil
.
Value
}
func
NewValueStack
()
*
ValueStack
{
return
&
ValueStack
{}
}
func
(
st
*
ValueStack
)
Pop
()
*
ethutil
.
Value
{
s
:=
len
(
st
.
data
)
s
:=
len
(
st
.
data
)
str
:=
st
.
data
[
s
-
1
]
str
:=
st
.
data
[
s
-
1
]
...
@@ -149,7 +207,7 @@ func (st *Stack) Pop() *big.Int {
...
@@ -149,7 +207,7 @@ func (st *Stack) Pop() *big.Int {
return
str
return
str
}
}
func
(
st
*
Stack
)
Popn
()
(
*
big
.
Int
,
*
big
.
Int
)
{
func
(
st
*
ValueStack
)
Popn
()
(
*
ethutil
.
Value
,
*
ethutil
.
Value
)
{
s
:=
len
(
st
.
data
)
s
:=
len
(
st
.
data
)
ints
:=
st
.
data
[
s
-
2
:
]
ints
:=
st
.
data
[
s
-
2
:
]
...
@@ -158,7 +216,7 @@ func (st *Stack) Popn() (*big.Int, *big.Int) {
...
@@ -158,7 +216,7 @@ func (st *Stack) Popn() (*big.Int, *big.Int) {
return
ints
[
0
],
ints
[
1
]
return
ints
[
0
],
ints
[
1
]
}
}
func
(
st
*
Stack
)
Peek
()
*
big
.
Int
{
func
(
st
*
ValueStack
)
Peek
()
*
ethutil
.
Value
{
s
:=
len
(
st
.
data
)
s
:=
len
(
st
.
data
)
str
:=
st
.
data
[
s
-
1
]
str
:=
st
.
data
[
s
-
1
]
...
@@ -166,7 +224,7 @@ func (st *Stack) Peek() *big.Int {
...
@@ -166,7 +224,7 @@ func (st *Stack) Peek() *big.Int {
return
str
return
str
}
}
func
(
st
*
Stack
)
Peekn
()
(
*
big
.
Int
,
*
big
.
Int
)
{
func
(
st
*
ValueStack
)
Peekn
()
(
*
ethutil
.
Value
,
*
ethutil
.
Value
)
{
s
:=
len
(
st
.
data
)
s
:=
len
(
st
.
data
)
ints
:=
st
.
data
[
s
-
2
:
]
ints
:=
st
.
data
[
s
-
2
:
]
...
@@ -174,10 +232,10 @@ func (st *Stack) Peekn() (*big.Int, *big.Int) {
...
@@ -174,10 +232,10 @@ func (st *Stack) Peekn() (*big.Int, *big.Int) {
return
ints
[
0
],
ints
[
1
]
return
ints
[
0
],
ints
[
1
]
}
}
func
(
st
*
Stack
)
Push
(
d
*
big
.
Int
)
{
func
(
st
*
ValueStack
)
Push
(
d
*
ethutil
.
Value
)
{
st
.
data
=
append
(
st
.
data
,
d
)
st
.
data
=
append
(
st
.
data
,
d
)
}
}
func
(
st
*
Stack
)
Print
()
{
func
(
st
*
Value
Stack
)
Print
()
{
fmt
.
Println
(
"### STACK ###"
)
fmt
.
Println
(
"### STACK ###"
)
if
len
(
st
.
data
)
>
0
{
if
len
(
st
.
data
)
>
0
{
for
i
,
val
:=
range
st
.
data
{
for
i
,
val
:=
range
st
.
data
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment