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
9bde7fd7
Commit
9bde7fd7
authored
May 20, 2015
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1043 from obscuren/test_fixes
core/vm: optimisation on RETURN and updated tests
parents
8fe8ec84
9617aa8e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
13 deletions
+35
-13
memory.go
core/vm/memory.go
+12
-0
vm.go
core/vm/vm.go
+1
-1
gh_test.go
tests/vm/gh_test.go
+22
-12
No files found.
core/vm/memory.go
View file @
9bde7fd7
...
@@ -49,6 +49,18 @@ func (self *Memory) Get(offset, size int64) (cpy []byte) {
...
@@ -49,6 +49,18 @@ func (self *Memory) Get(offset, size int64) (cpy []byte) {
return
return
}
}
func
(
self
*
Memory
)
GetPtr
(
offset
,
size
int64
)
[]
byte
{
if
size
==
0
{
return
nil
}
if
len
(
self
.
store
)
>
int
(
offset
)
{
return
self
.
store
[
offset
:
offset
+
size
]
}
return
nil
}
func
(
m
*
Memory
)
Len
()
int
{
func
(
m
*
Memory
)
Len
()
int
{
return
len
(
m
.
store
)
return
len
(
m
.
store
)
}
}
...
...
core/vm/vm.go
View file @
9bde7fd7
...
@@ -695,7 +695,7 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
...
@@ -695,7 +695,7 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
self
.
Printf
(
"resume %x (%v)"
,
context
.
Address
(),
context
.
Gas
)
self
.
Printf
(
"resume %x (%v)"
,
context
.
Address
(),
context
.
Gas
)
case
RETURN
:
case
RETURN
:
offset
,
size
:=
stack
.
pop
(),
stack
.
pop
()
offset
,
size
:=
stack
.
pop
(),
stack
.
pop
()
ret
:=
mem
.
Get
(
offset
.
Int64
(),
size
.
Int64
())
ret
:=
mem
.
Get
Ptr
(
offset
.
Int64
(),
size
.
Int64
())
self
.
Printf
(
" => [%v, %v] (%d) 0x%x"
,
offset
,
size
,
len
(
ret
),
ret
)
.
Endl
()
self
.
Printf
(
" => [%v, %v] (%d) 0x%x"
,
offset
,
size
,
len
(
ret
),
ret
)
.
Endl
()
...
...
tests/vm/gh_test.go
View file @
9bde7fd7
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
"bytes"
"bytes"
"io/ioutil"
"io/ioutil"
"math/big"
"math/big"
"os"
"path/filepath"
"path/filepath"
"strconv"
"strconv"
"testing"
"testing"
...
@@ -87,7 +88,7 @@ func RunVmTest(p string, t *testing.T) {
...
@@ -87,7 +88,7 @@ func RunVmTest(p string, t *testing.T) {
vm.Debug = true
vm.Debug = true
glog.SetV(4)
glog.SetV(4)
glog.SetToStderr(true)
glog.SetToStderr(true)
if name != "
stackLimitPush32_1024
" {
if name != "
Call50000_sha256
" {
continue
continue
}
}
*/
*/
...
@@ -128,10 +129,16 @@ func RunVmTest(p string, t *testing.T) {
...
@@ -128,10 +129,16 @@ func RunVmTest(p string, t *testing.T) {
ret
,
logs
,
gas
,
err
=
helper
.
RunState
(
statedb
,
env
,
test
.
Transaction
)
ret
,
logs
,
gas
,
err
=
helper
.
RunState
(
statedb
,
env
,
test
.
Transaction
)
}
}
switch
name
{
// the memory required for these tests (4294967297 bytes) would take too much time.
// on 19 May 2015 decided to skip these tests their output.
case
"mload32bitBound_return"
,
"mload32bitBound_return2"
:
default
:
rexp
:=
helper
.
FromHex
(
test
.
Out
)
rexp
:=
helper
.
FromHex
(
test
.
Out
)
if
bytes
.
Compare
(
rexp
,
ret
)
!=
0
{
if
bytes
.
Compare
(
rexp
,
ret
)
!=
0
{
t
.
Errorf
(
"%s's return failed. Expected %x, got %x
\n
"
,
name
,
rexp
,
ret
)
t
.
Errorf
(
"%s's return failed. Expected %x, got %x
\n
"
,
name
,
rexp
,
ret
)
}
}
}
if
isVmTest
{
if
isVmTest
{
if
len
(
test
.
Gas
)
==
0
&&
err
==
nil
{
if
len
(
test
.
Gas
)
==
0
&&
err
==
nil
{
...
@@ -246,8 +253,7 @@ func TestLogTest(t *testing.T) {
...
@@ -246,8 +253,7 @@ func TestLogTest(t *testing.T) {
}
}
func
TestPerformance
(
t
*
testing
.
T
)
{
func
TestPerformance
(
t
*
testing
.
T
)
{
t
.
Skip
()
const
fn
=
"../files/VMTests/vmPerformanceTest.json"
const
fn
=
"../files/VMTests/vmPerformance.json"
RunVmTest
(
fn
,
t
)
RunVmTest
(
fn
,
t
)
}
}
...
@@ -281,13 +287,13 @@ func TestInputLimitsLight(t *testing.T) {
...
@@ -281,13 +287,13 @@ func TestInputLimitsLight(t *testing.T) {
RunVmTest
(
fn
,
t
)
RunVmTest
(
fn
,
t
)
}
}
func
TestState
Example
(
t
*
testing
.
T
)
{
func
TestState
SystemOperations
(
t
*
testing
.
T
)
{
const
fn
=
"../files/StateTests/st
Example
.json"
const
fn
=
"../files/StateTests/st
SystemOperationsTest
.json"
RunVmTest
(
fn
,
t
)
RunVmTest
(
fn
,
t
)
}
}
func
TestState
SystemOperations
(
t
*
testing
.
T
)
{
func
TestState
Example
(
t
*
testing
.
T
)
{
const
fn
=
"../files/StateTests/st
SystemOperationsTest
.json"
const
fn
=
"../files/StateTests/st
Example
.json"
RunVmTest
(
fn
,
t
)
RunVmTest
(
fn
,
t
)
}
}
...
@@ -342,13 +348,17 @@ func TestMemory(t *testing.T) {
...
@@ -342,13 +348,17 @@ func TestMemory(t *testing.T) {
}
}
func
TestMemoryStress
(
t
*
testing
.
T
)
{
func
TestMemoryStress
(
t
*
testing
.
T
)
{
t
.
Skip
(
"Skipped due to...consuming too much memory :D"
)
if
os
.
Getenv
(
"TEST_VM_COMPLEX"
)
==
""
{
t
.
Skip
()
}
const
fn
=
"../files/StateTests/stMemoryStressTest.json"
const
fn
=
"../files/StateTests/stMemoryStressTest.json"
RunVmTest
(
fn
,
t
)
RunVmTest
(
fn
,
t
)
}
}
func
TestQuadraticComplexity
(
t
*
testing
.
T
)
{
func
TestQuadraticComplexity
(
t
*
testing
.
T
)
{
t
.
Skip
()
// takes too long
if
os
.
Getenv
(
"TEST_VM_COMPLEX"
)
==
""
{
t
.
Skip
()
}
const
fn
=
"../files/StateTests/stQuadraticComplexityTest.json"
const
fn
=
"../files/StateTests/stQuadraticComplexityTest.json"
RunVmTest
(
fn
,
t
)
RunVmTest
(
fn
,
t
)
}
}
...
...
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