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
feef1948
Commit
feef1948
authored
Oct 23, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Chnged to use GetOp instead & added error + checking
parent
91c87683
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
6 deletions
+58
-6
main.go
tests/ethtest/main.go
+2
-1
errors.go
vm/errors.go
+51
-0
execution.go
vm/execution.go
+2
-2
vm_debug.go
vm/vm_debug.go
+3
-3
No files found.
tests/ethtest/main.go
View file @
feef1948
...
...
@@ -63,7 +63,7 @@ func RunVmTest(js string) (failed int) {
// When an error is returned it doesn't always mean the tests fails.
// Have to come up with some conditional failing mechanism.
if
err
!=
nil
{
helper
.
Log
.
Info
ln
(
err
)
log
.
Print
ln
(
err
)
}
rexp
:=
helper
.
FromHex
(
test
.
Out
)
...
...
@@ -96,6 +96,7 @@ func RunVmTest(js string) (failed int) {
}
func
main
()
{
helper
.
Logger
.
SetLogLevel
(
5
)
if
len
(
os
.
Args
)
==
1
{
log
.
Fatalln
(
"no json supplied"
)
}
...
...
vm/errors.go
0 → 100644
View file @
feef1948
package
vm
import
(
"fmt"
"math/big"
)
type
OutOfGasError
struct
{
req
,
has
*
big
.
Int
}
func
OOG
(
req
,
has
*
big
.
Int
)
OutOfGasError
{
return
OutOfGasError
{
req
,
has
}
}
func
(
self
OutOfGasError
)
Error
()
string
{
return
fmt
.
Sprintf
(
"out of gas! require %v, have %v"
,
self
.
req
,
self
.
has
)
}
func
IsOOGErr
(
err
error
)
bool
{
_
,
ok
:=
err
.
(
OutOfGasError
)
return
ok
}
type
StackError
struct
{
req
,
has
int
}
func
StackErr
(
req
,
has
int
)
StackError
{
return
StackError
{
req
,
has
}
}
func
(
self
StackError
)
Error
()
string
{
return
fmt
.
Sprintf
(
"stack error! require %v, have %v"
,
self
.
req
,
self
.
has
)
}
func
IsStack
(
err
error
)
bool
{
_
,
ok
:=
err
.
(
StackError
)
return
ok
}
type
DepthError
struct
{}
func
(
self
DepthError
)
Error
()
string
{
return
fmt
.
Sprintf
(
"Max call depth exceeded (%d)"
,
MaxCallDepth
)
}
func
IsDepthErr
(
err
error
)
bool
{
_
,
ok
:=
err
.
(
DepthError
)
return
ok
}
vm/execution.go
View file @
feef1948
...
...
@@ -36,7 +36,7 @@ func (self *Execution) exec(code, caddr []byte, caller ClosureRef) (ret []byte,
snapshot
:=
env
.
State
()
.
Copy
()
defer
func
()
{
if
err
!=
nil
{
if
IsDepthErr
(
err
)
||
IsOOGErr
(
err
)
{
env
.
State
()
.
Set
(
snapshot
)
}
}()
...
...
@@ -76,7 +76,7 @@ func (self *Execution) exec(code, caddr []byte, caller ClosureRef) (ret []byte,
if
self
.
vm
.
Depth
()
==
MaxCallDepth
{
c
.
UseGas
(
self
.
Gas
)
return
c
.
Return
(
nil
),
fmt
.
Errorf
(
"Max call depth exceeded (%d)"
,
MaxCallDepth
)
return
c
.
Return
(
nil
),
DepthError
{}
}
// Executer the closure and get the return value (if any)
...
...
vm/vm_debug.go
View file @
feef1948
...
...
@@ -107,7 +107,7 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
step
++
// Get the memory location of pc
op
=
OpCode
(
closure
.
Get
(
pc
)
.
Uint
(
))
op
=
closure
.
GetOp
(
int
(
pc
.
Uint64
()
))
// XXX Leave this Println intact. Don't change this to the log system.
// Used for creating diffs between implementations
...
...
@@ -246,11 +246,11 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
if
!
closure
.
UseGas
(
gas
)
{
self
.
Endl
()
err
:=
fmt
.
Errorf
(
"Insufficient gas for %v. req %v has %v"
,
op
,
gas
,
closure
.
Gas
)
tmp
:=
new
(
big
.
Int
)
.
Set
(
closure
.
Gas
)
closure
.
UseGas
(
closure
.
Gas
)
return
closure
.
Return
(
nil
),
err
return
closure
.
Return
(
nil
),
OOG
(
gas
,
tmp
)
}
mem
.
Resize
(
newMemSize
.
Uint64
())
...
...
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