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
e5b480b6
Commit
e5b480b6
authored
Jan 11, 2016
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix invalid state reuse in chain maker based tests
parent
0ab8a175
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
12 deletions
+7
-12
chain_makers.go
core/chain_makers.go
+7
-12
No files found.
core/chain_makers.go
View file @
e5b480b6
...
...
@@ -91,15 +91,10 @@ func (b *BlockGen) AddTx(tx *types.Transaction) {
b
.
SetCoinbase
(
common
.
Address
{})
}
b
.
statedb
.
StartRecord
(
tx
.
Hash
(),
common
.
Hash
{},
len
(
b
.
txs
))
_
,
gas
,
err
:=
ApplyMessage
(
NewEnv
(
b
.
statedb
,
nil
,
tx
,
b
.
header
),
tx
,
b
.
gasPool
)
receipt
,
_
,
_
,
err
:=
ApplyTransaction
(
nil
,
b
.
gasPool
,
b
.
statedb
,
b
.
header
,
tx
,
b
.
header
.
GasUsed
)
if
err
!=
nil
{
panic
(
err
)
}
root
:=
b
.
statedb
.
IntermediateRoot
()
b
.
header
.
GasUsed
.
Add
(
b
.
header
.
GasUsed
,
gas
)
receipt
:=
types
.
NewReceipt
(
root
.
Bytes
(),
b
.
header
.
GasUsed
)
receipt
.
Logs
=
b
.
statedb
.
GetLogs
(
tx
.
Hash
())
receipt
.
Bloom
=
types
.
CreateBloom
(
types
.
Receipts
{
receipt
})
b
.
txs
=
append
(
b
.
txs
,
tx
)
b
.
receipts
=
append
(
b
.
receipts
,
receipt
)
}
...
...
@@ -169,12 +164,8 @@ func (b *BlockGen) OffsetTime(seconds int64) {
// values. Inserting them into BlockChain requires use of FakePow or
// a similar non-validating proof of work implementation.
func
GenerateChain
(
parent
*
types
.
Block
,
db
ethdb
.
Database
,
n
int
,
gen
func
(
int
,
*
BlockGen
))
([]
*
types
.
Block
,
[]
types
.
Receipts
)
{
statedb
,
err
:=
state
.
New
(
parent
.
Root
(),
db
)
if
err
!=
nil
{
panic
(
err
)
}
blocks
,
receipts
:=
make
(
types
.
Blocks
,
n
),
make
([]
types
.
Receipts
,
n
)
genblock
:=
func
(
i
int
,
h
*
types
.
Header
)
(
*
types
.
Block
,
types
.
Receipts
)
{
genblock
:=
func
(
i
int
,
h
*
types
.
Header
,
statedb
*
state
.
StateDB
)
(
*
types
.
Block
,
types
.
Receipts
)
{
b
:=
&
BlockGen
{
parent
:
parent
,
i
:
i
,
chain
:
blocks
,
header
:
h
,
statedb
:
statedb
}
if
gen
!=
nil
{
gen
(
i
,
b
)
...
...
@@ -188,8 +179,12 @@ func GenerateChain(parent *types.Block, db ethdb.Database, n int, gen func(int,
return
types
.
NewBlock
(
h
,
b
.
txs
,
b
.
uncles
,
b
.
receipts
),
b
.
receipts
}
for
i
:=
0
;
i
<
n
;
i
++
{
statedb
,
err
:=
state
.
New
(
parent
.
Root
(),
db
)
if
err
!=
nil
{
panic
(
err
)
}
header
:=
makeHeader
(
parent
,
statedb
)
block
,
receipt
:=
genblock
(
i
,
header
)
block
,
receipt
:=
genblock
(
i
,
header
,
statedb
)
blocks
[
i
]
=
block
receipts
[
i
]
=
receipt
parent
=
block
...
...
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