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
63687f04
Commit
63687f04
authored
Mar 07, 2018
by
Kyuntae Ethan Kim
Committed by
Péter Szilágyi
Mar 07, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: check transaction/receipt count match when reconstructing blocks (#16272)
parent
d43ffdbf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
blockchain.go
core/blockchain.go
+8
-2
odr_util.go
light/odr_util.go
+3
-1
No files found.
core/blockchain.go
View file @
63687f04
...
@@ -723,10 +723,13 @@ func (bc *BlockChain) Rollback(chain []common.Hash) {
...
@@ -723,10 +723,13 @@ func (bc *BlockChain) Rollback(chain []common.Hash) {
}
}
// SetReceiptsData computes all the non-consensus fields of the receipts
// SetReceiptsData computes all the non-consensus fields of the receipts
func
SetReceiptsData
(
config
*
params
.
ChainConfig
,
block
*
types
.
Block
,
receipts
types
.
Receipts
)
{
func
SetReceiptsData
(
config
*
params
.
ChainConfig
,
block
*
types
.
Block
,
receipts
types
.
Receipts
)
error
{
signer
:=
types
.
MakeSigner
(
config
,
block
.
Number
())
signer
:=
types
.
MakeSigner
(
config
,
block
.
Number
())
transactions
,
logIndex
:=
block
.
Transactions
(),
uint
(
0
)
transactions
,
logIndex
:=
block
.
Transactions
(),
uint
(
0
)
if
len
(
transactions
)
!=
len
(
receipts
)
{
return
errors
.
New
(
"transaction and receipt count mismatch"
)
}
for
j
:=
0
;
j
<
len
(
receipts
);
j
++
{
for
j
:=
0
;
j
<
len
(
receipts
);
j
++
{
// The transaction hash can be retrieved from the transaction itself
// The transaction hash can be retrieved from the transaction itself
...
@@ -754,6 +757,7 @@ func SetReceiptsData(config *params.ChainConfig, block *types.Block, receipts ty
...
@@ -754,6 +757,7 @@ func SetReceiptsData(config *params.ChainConfig, block *types.Block, receipts ty
logIndex
++
logIndex
++
}
}
}
}
return
nil
}
}
// InsertReceiptChain attempts to complete an already existing header chain with
// InsertReceiptChain attempts to complete an already existing header chain with
...
@@ -794,7 +798,9 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
...
@@ -794,7 +798,9 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
continue
continue
}
}
// Compute all the non-consensus fields of the receipts
// Compute all the non-consensus fields of the receipts
SetReceiptsData
(
bc
.
chainConfig
,
block
,
receipts
)
if
err
:=
SetReceiptsData
(
bc
.
chainConfig
,
block
,
receipts
);
err
!=
nil
{
return
i
,
fmt
.
Errorf
(
"failed to set receipts data: %v"
,
err
)
}
// Write all the data out into the database
// Write all the data out into the database
if
err
:=
WriteBody
(
batch
,
block
.
Hash
(),
block
.
NumberU64
(),
block
.
Body
());
err
!=
nil
{
if
err
:=
WriteBody
(
batch
,
block
.
Hash
(),
block
.
NumberU64
(),
block
.
Body
());
err
!=
nil
{
return
i
,
fmt
.
Errorf
(
"failed to write block body: %v"
,
err
)
return
i
,
fmt
.
Errorf
(
"failed to write block body: %v"
,
err
)
...
...
light/odr_util.go
View file @
63687f04
...
@@ -144,7 +144,9 @@ func GetBlockReceipts(ctx context.Context, odr OdrBackend, hash common.Hash, num
...
@@ -144,7 +144,9 @@ func GetBlockReceipts(ctx context.Context, odr OdrBackend, hash common.Hash, num
genesis
:=
core
.
GetCanonicalHash
(
odr
.
Database
(),
0
)
genesis
:=
core
.
GetCanonicalHash
(
odr
.
Database
(),
0
)
config
,
_
:=
core
.
GetChainConfig
(
odr
.
Database
(),
genesis
)
config
,
_
:=
core
.
GetChainConfig
(
odr
.
Database
(),
genesis
)
core
.
SetReceiptsData
(
config
,
block
,
receipts
)
if
err
:=
core
.
SetReceiptsData
(
config
,
block
,
receipts
);
err
!=
nil
{
return
nil
,
err
}
core
.
WriteBlockReceipts
(
odr
.
Database
(),
hash
,
number
,
receipts
)
core
.
WriteBlockReceipts
(
odr
.
Database
(),
hash
,
number
,
receipts
)
}
}
return
receipts
,
nil
return
receipts
,
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