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
645e3e86
Unverified
Commit
645e3e86
authored
2 years ago
by
Martin Holst Swende
Committed by
GitHub
2 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core, eth/downloader: make body validation more strict (#26704)
parent
08bf8a60
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
8 deletions
+14
-8
block_validator.go
core/block_validator.go
+3
-0
queue.go
eth/downloader/queue.go
+11
-8
No files found.
core/block_validator.go
View file @
645e3e86
...
...
@@ -76,6 +76,9 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error {
if
hash
:=
types
.
DeriveSha
(
block
.
Withdrawals
(),
trie
.
NewStackTrie
(
nil
));
hash
!=
*
header
.
WithdrawalsHash
{
return
fmt
.
Errorf
(
"withdrawals root hash mismatch (header value %x, calculated %x)"
,
*
header
.
WithdrawalsHash
,
hash
)
}
}
else
if
block
.
Withdrawals
()
!=
nil
{
// Withdrawals are not allowed prior to shanghai fork
return
fmt
.
Errorf
(
"withdrawals present in block body"
)
}
if
!
v
.
bc
.
HasBlockAndState
(
block
.
ParentHash
(),
block
.
NumberU64
()
-
1
)
{
...
...
This diff is collapsed.
Click to expand it.
eth/downloader/queue.go
View file @
645e3e86
...
...
@@ -781,14 +781,17 @@ func (q *queue) DeliverBodies(id string, txLists [][]*types.Transaction, txListH
return
errInvalidBody
}
if
header
.
WithdrawalsHash
==
nil
{
// discard any withdrawals if we don't have a withdrawal hash set
withdrawalLists
[
index
]
=
nil
}
else
if
*
header
.
WithdrawalsHash
==
types
.
EmptyRootHash
&&
withdrawalLists
[
index
]
==
nil
{
// if the withdrawal hash is the emptyRootHash,
// we expect withdrawals to be [] instead of nil
withdrawalLists
[
index
]
=
make
([]
*
types
.
Withdrawal
,
0
)
}
else
if
withdrawalListHashes
[
index
]
!=
*
header
.
WithdrawalsHash
{
return
errInvalidBody
// nil hash means there withdrawals should not be present in body
if
withdrawalLists
[
index
]
!=
nil
{
return
errInvalidBody
}
}
else
{
// non-nil hash: body must have withdrawals
if
withdrawalLists
[
index
]
==
nil
{
return
errInvalidBody
}
if
withdrawalListHashes
[
index
]
!=
*
header
.
WithdrawalsHash
{
return
errInvalidBody
}
}
return
nil
}
...
...
This diff is collapsed.
Click to expand it.
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