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
5e45db76
Unverified
Commit
5e45db76
authored
May 04, 2020
by
Péter Szilágyi
Committed by
GitHub
May 04, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #21021 from karalabe/tests-snapshot-gen-cleanup
tests: cleanup snapshot generator goroutine leak
parents
ab72803e
65cd28aa
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
19 deletions
+30
-19
staterunner.go
cmd/evm/staterunner.go
+1
-1
tracers_test.go
eth/tracers/tracers_test.go
+2
-2
state_test.go
tests/state_test.go
+5
-2
state_test_util.go
tests/state_test_util.go
+13
-13
vm_test_util.go
tests/vm_test_util.go
+9
-1
No files found.
cmd/evm/staterunner.go
View file @
5e45db76
...
@@ -96,7 +96,7 @@ func stateTestCmd(ctx *cli.Context) error {
...
@@ -96,7 +96,7 @@ func stateTestCmd(ctx *cli.Context) error {
for
_
,
st
:=
range
test
.
Subtests
()
{
for
_
,
st
:=
range
test
.
Subtests
()
{
// Run the test and aggregate the result
// Run the test and aggregate the result
result
:=
&
StatetestResult
{
Name
:
key
,
Fork
:
st
.
Fork
,
Pass
:
true
}
result
:=
&
StatetestResult
{
Name
:
key
,
Fork
:
st
.
Fork
,
Pass
:
true
}
state
,
err
:=
test
.
Run
(
st
,
cfg
,
false
)
_
,
state
,
err
:=
test
.
Run
(
st
,
cfg
,
false
)
// print state root for evmlab tracing
// print state root for evmlab tracing
if
ctx
.
GlobalBool
(
MachineFlag
.
Name
)
&&
state
!=
nil
{
if
ctx
.
GlobalBool
(
MachineFlag
.
Name
)
&&
state
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"{
\"
stateRoot
\"
:
\"
%x
\"
}
\n
"
,
state
.
IntermediateRoot
(
false
))
fmt
.
Fprintf
(
os
.
Stderr
,
"{
\"
stateRoot
\"
:
\"
%x
\"
}
\n
"
,
state
.
IntermediateRoot
(
false
))
...
...
eth/tracers/tracers_test.go
View file @
5e45db76
...
@@ -168,7 +168,7 @@ func TestPrestateTracerCreate2(t *testing.T) {
...
@@ -168,7 +168,7 @@ func TestPrestateTracerCreate2(t *testing.T) {
Code
:
[]
byte
{},
Code
:
[]
byte
{},
Balance
:
big
.
NewInt
(
500000000000000
),
Balance
:
big
.
NewInt
(
500000000000000
),
}
}
statedb
:=
tests
.
MakePreState
(
rawdb
.
NewMemoryDatabase
(),
alloc
,
false
)
_
,
statedb
:=
tests
.
MakePreState
(
rawdb
.
NewMemoryDatabase
(),
alloc
,
false
)
// Create the tracer, the EVM environment and run it
// Create the tracer, the EVM environment and run it
tracer
,
err
:=
New
(
"prestateTracer"
)
tracer
,
err
:=
New
(
"prestateTracer"
)
...
@@ -242,7 +242,7 @@ func TestCallTracer(t *testing.T) {
...
@@ -242,7 +242,7 @@ func TestCallTracer(t *testing.T) {
GasLimit
:
uint64
(
test
.
Context
.
GasLimit
),
GasLimit
:
uint64
(
test
.
Context
.
GasLimit
),
GasPrice
:
tx
.
GasPrice
(),
GasPrice
:
tx
.
GasPrice
(),
}
}
statedb
:=
tests
.
MakePreState
(
rawdb
.
NewMemoryDatabase
(),
test
.
Genesis
.
Alloc
,
false
)
_
,
statedb
:=
tests
.
MakePreState
(
rawdb
.
NewMemoryDatabase
(),
test
.
Genesis
.
Alloc
,
false
)
// Create the tracer, the EVM environment and run it
// Create the tracer, the EVM environment and run it
tracer
,
err
:=
New
(
"callTracer"
)
tracer
,
err
:=
New
(
"callTracer"
)
...
...
tests/state_test.go
View file @
5e45db76
...
@@ -66,13 +66,16 @@ func TestState(t *testing.T) {
...
@@ -66,13 +66,16 @@ func TestState(t *testing.T) {
t
.
Run
(
key
+
"/trie"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
key
+
"/trie"
,
func
(
t
*
testing
.
T
)
{
withTrace
(
t
,
test
.
gasLimit
(
subtest
),
func
(
vmconfig
vm
.
Config
)
error
{
withTrace
(
t
,
test
.
gasLimit
(
subtest
),
func
(
vmconfig
vm
.
Config
)
error
{
_
,
err
:=
test
.
Run
(
subtest
,
vmconfig
,
false
)
_
,
_
,
err
:=
test
.
Run
(
subtest
,
vmconfig
,
false
)
return
st
.
checkFailure
(
t
,
name
+
"/trie"
,
err
)
return
st
.
checkFailure
(
t
,
name
+
"/trie"
,
err
)
})
})
})
})
t
.
Run
(
key
+
"/snap"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
key
+
"/snap"
,
func
(
t
*
testing
.
T
)
{
withTrace
(
t
,
test
.
gasLimit
(
subtest
),
func
(
vmconfig
vm
.
Config
)
error
{
withTrace
(
t
,
test
.
gasLimit
(
subtest
),
func
(
vmconfig
vm
.
Config
)
error
{
_
,
err
:=
test
.
Run
(
subtest
,
vmconfig
,
true
)
snaps
,
statedb
,
err
:=
test
.
Run
(
subtest
,
vmconfig
,
true
)
if
_
,
err
:=
snaps
.
Journal
(
statedb
.
IntermediateRoot
(
false
));
err
!=
nil
{
return
err
}
return
st
.
checkFailure
(
t
,
name
+
"/snap"
,
err
)
return
st
.
checkFailure
(
t
,
name
+
"/snap"
,
err
)
})
})
})
})
...
...
tests/state_test_util.go
View file @
5e45db76
...
@@ -147,37 +147,37 @@ func (t *StateTest) Subtests() []StateSubtest {
...
@@ -147,37 +147,37 @@ func (t *StateTest) Subtests() []StateSubtest {
}
}
// Run executes a specific subtest and verifies the post-state and logs
// Run executes a specific subtest and verifies the post-state and logs
func
(
t
*
StateTest
)
Run
(
subtest
StateSubtest
,
vmconfig
vm
.
Config
,
snapshotter
bool
)
(
*
state
.
StateDB
,
error
)
{
func
(
t
*
StateTest
)
Run
(
subtest
StateSubtest
,
vmconfig
vm
.
Config
,
snapshotter
bool
)
(
*
s
napshot
.
Tree
,
*
s
tate
.
StateDB
,
error
)
{
statedb
,
root
,
err
:=
t
.
RunNoVerify
(
subtest
,
vmconfig
,
snapshotter
)
s
naps
,
s
tatedb
,
root
,
err
:=
t
.
RunNoVerify
(
subtest
,
vmconfig
,
snapshotter
)
if
err
!=
nil
{
if
err
!=
nil
{
return
statedb
,
err
return
s
naps
,
s
tatedb
,
err
}
}
post
:=
t
.
json
.
Post
[
subtest
.
Fork
][
subtest
.
Index
]
post
:=
t
.
json
.
Post
[
subtest
.
Fork
][
subtest
.
Index
]
// N.B: We need to do this in a two-step process, because the first Commit takes care
// N.B: We need to do this in a two-step process, because the first Commit takes care
// of suicides, and we need to touch the coinbase _after_ it has potentially suicided.
// of suicides, and we need to touch the coinbase _after_ it has potentially suicided.
if
root
!=
common
.
Hash
(
post
.
Root
)
{
if
root
!=
common
.
Hash
(
post
.
Root
)
{
return
statedb
,
fmt
.
Errorf
(
"post state root mismatch: got %x, want %x"
,
root
,
post
.
Root
)
return
s
naps
,
s
tatedb
,
fmt
.
Errorf
(
"post state root mismatch: got %x, want %x"
,
root
,
post
.
Root
)
}
}
if
logs
:=
rlpHash
(
statedb
.
Logs
());
logs
!=
common
.
Hash
(
post
.
Logs
)
{
if
logs
:=
rlpHash
(
statedb
.
Logs
());
logs
!=
common
.
Hash
(
post
.
Logs
)
{
return
statedb
,
fmt
.
Errorf
(
"post state logs hash mismatch: got %x, want %x"
,
logs
,
post
.
Logs
)
return
s
naps
,
s
tatedb
,
fmt
.
Errorf
(
"post state logs hash mismatch: got %x, want %x"
,
logs
,
post
.
Logs
)
}
}
return
statedb
,
nil
return
s
naps
,
s
tatedb
,
nil
}
}
// RunNoVerify runs a specific subtest and returns the statedb and post-state root
// RunNoVerify runs a specific subtest and returns the statedb and post-state root
func
(
t
*
StateTest
)
RunNoVerify
(
subtest
StateSubtest
,
vmconfig
vm
.
Config
,
snapshotter
bool
)
(
*
state
.
StateDB
,
common
.
Hash
,
error
)
{
func
(
t
*
StateTest
)
RunNoVerify
(
subtest
StateSubtest
,
vmconfig
vm
.
Config
,
snapshotter
bool
)
(
*
s
napshot
.
Tree
,
*
s
tate
.
StateDB
,
common
.
Hash
,
error
)
{
config
,
eips
,
err
:=
getVMConfig
(
subtest
.
Fork
)
config
,
eips
,
err
:=
getVMConfig
(
subtest
.
Fork
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
common
.
Hash
{},
UnsupportedForkError
{
subtest
.
Fork
}
return
nil
,
nil
,
common
.
Hash
{},
UnsupportedForkError
{
subtest
.
Fork
}
}
}
vmconfig
.
ExtraEips
=
eips
vmconfig
.
ExtraEips
=
eips
block
:=
t
.
genesis
(
config
)
.
ToBlock
(
nil
)
block
:=
t
.
genesis
(
config
)
.
ToBlock
(
nil
)
statedb
:=
MakePreState
(
rawdb
.
NewMemoryDatabase
(),
t
.
json
.
Pre
,
snapshotter
)
s
naps
,
s
tatedb
:=
MakePreState
(
rawdb
.
NewMemoryDatabase
(),
t
.
json
.
Pre
,
snapshotter
)
post
:=
t
.
json
.
Post
[
subtest
.
Fork
][
subtest
.
Index
]
post
:=
t
.
json
.
Post
[
subtest
.
Fork
][
subtest
.
Index
]
msg
,
err
:=
t
.
json
.
Tx
.
toMessage
(
post
)
msg
,
err
:=
t
.
json
.
Tx
.
toMessage
(
post
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
common
.
Hash
{},
err
return
nil
,
nil
,
common
.
Hash
{},
err
}
}
context
:=
core
.
NewEVMContext
(
msg
,
block
.
Header
(),
nil
,
&
t
.
json
.
Env
.
Coinbase
)
context
:=
core
.
NewEVMContext
(
msg
,
block
.
Header
(),
nil
,
&
t
.
json
.
Env
.
Coinbase
)
context
.
GetHash
=
vmTestBlockHash
context
.
GetHash
=
vmTestBlockHash
...
@@ -199,14 +199,14 @@ func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapsh
...
@@ -199,14 +199,14 @@ func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapsh
statedb
.
AddBalance
(
block
.
Coinbase
(),
new
(
big
.
Int
))
statedb
.
AddBalance
(
block
.
Coinbase
(),
new
(
big
.
Int
))
// And _now_ get the state root
// And _now_ get the state root
root
:=
statedb
.
IntermediateRoot
(
config
.
IsEIP158
(
block
.
Number
()))
root
:=
statedb
.
IntermediateRoot
(
config
.
IsEIP158
(
block
.
Number
()))
return
statedb
,
root
,
nil
return
s
naps
,
s
tatedb
,
root
,
nil
}
}
func
(
t
*
StateTest
)
gasLimit
(
subtest
StateSubtest
)
uint64
{
func
(
t
*
StateTest
)
gasLimit
(
subtest
StateSubtest
)
uint64
{
return
t
.
json
.
Tx
.
GasLimit
[
t
.
json
.
Post
[
subtest
.
Fork
][
subtest
.
Index
]
.
Indexes
.
Gas
]
return
t
.
json
.
Tx
.
GasLimit
[
t
.
json
.
Post
[
subtest
.
Fork
][
subtest
.
Index
]
.
Indexes
.
Gas
]
}
}
func
MakePreState
(
db
ethdb
.
Database
,
accounts
core
.
GenesisAlloc
,
snapshotter
bool
)
*
state
.
StateDB
{
func
MakePreState
(
db
ethdb
.
Database
,
accounts
core
.
GenesisAlloc
,
snapshotter
bool
)
(
*
snapshot
.
Tree
,
*
state
.
StateDB
)
{
sdb
:=
state
.
NewDatabase
(
db
)
sdb
:=
state
.
NewDatabase
(
db
)
statedb
,
_
:=
state
.
New
(
common
.
Hash
{},
sdb
,
nil
)
statedb
,
_
:=
state
.
New
(
common
.
Hash
{},
sdb
,
nil
)
for
addr
,
a
:=
range
accounts
{
for
addr
,
a
:=
range
accounts
{
...
@@ -225,7 +225,7 @@ func MakePreState(db ethdb.Database, accounts core.GenesisAlloc, snapshotter boo
...
@@ -225,7 +225,7 @@ func MakePreState(db ethdb.Database, accounts core.GenesisAlloc, snapshotter boo
snaps
=
snapshot
.
New
(
db
,
sdb
.
TrieDB
(),
1
,
root
,
false
)
snaps
=
snapshot
.
New
(
db
,
sdb
.
TrieDB
(),
1
,
root
,
false
)
}
}
statedb
,
_
=
state
.
New
(
root
,
sdb
,
snaps
)
statedb
,
_
=
state
.
New
(
root
,
sdb
,
snaps
)
return
statedb
return
s
naps
,
s
tatedb
}
}
func
(
t
*
StateTest
)
genesis
(
config
*
params
.
ChainConfig
)
*
core
.
Genesis
{
func
(
t
*
StateTest
)
genesis
(
config
*
params
.
ChainConfig
)
*
core
.
Genesis
{
...
...
tests/vm_test_util.go
View file @
5e45db76
...
@@ -79,7 +79,15 @@ type vmExecMarshaling struct {
...
@@ -79,7 +79,15 @@ type vmExecMarshaling struct {
}
}
func
(
t
*
VMTest
)
Run
(
vmconfig
vm
.
Config
,
snapshotter
bool
)
error
{
func
(
t
*
VMTest
)
Run
(
vmconfig
vm
.
Config
,
snapshotter
bool
)
error
{
statedb
:=
MakePreState
(
rawdb
.
NewMemoryDatabase
(),
t
.
json
.
Pre
,
snapshotter
)
snaps
,
statedb
:=
MakePreState
(
rawdb
.
NewMemoryDatabase
(),
t
.
json
.
Pre
,
snapshotter
)
if
snapshotter
{
preRoot
:=
statedb
.
IntermediateRoot
(
false
)
defer
func
()
{
if
_
,
err
:=
snaps
.
Journal
(
preRoot
);
err
!=
nil
{
panic
(
err
)
}
}()
}
ret
,
gasRemaining
,
err
:=
t
.
exec
(
statedb
,
vmconfig
)
ret
,
gasRemaining
,
err
:=
t
.
exec
(
statedb
,
vmconfig
)
if
t
.
json
.
GasRemaining
==
nil
{
if
t
.
json
.
GasRemaining
==
nil
{
...
...
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