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
7217ef4c
Unverified
Commit
7217ef4c
authored
Jul 05, 2022
by
Marius van der Wijden
Committed by
GitHub
Jul 05, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
consensus/beacon: verify timestamp is greater than parent timestamp (#25236)
parent
87bb5db6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
consensus.go
consensus/beacon/consensus.go
+6
-1
No files found.
consensus/beacon/consensus.go
View file @
7217ef4c
...
...
@@ -45,6 +45,7 @@ var (
errTooManyUncles
=
errors
.
New
(
"too many uncles"
)
errInvalidNonce
=
errors
.
New
(
"invalid nonce"
)
errInvalidUncleHash
=
errors
.
New
(
"invalid uncle hash"
)
errInvalidTimestamp
=
errors
.
New
(
"invalid timestamp"
)
)
// Beacon is a consensus engine that combines the eth1 consensus and proof-of-stake
...
...
@@ -213,7 +214,7 @@ func (beacon *Beacon) VerifyUncles(chain consensus.ChainReader, block *types.Blo
// - nonce is expected to be 0
// - unclehash is expected to be Hash(emptyHeader)
// to be the desired constants
// (b)
the timestamp is not verified
anymore
// (b)
we don't verify if a block is in the future
anymore
// (c) the extradata is limited to 32 bytes
func
(
beacon
*
Beacon
)
verifyHeader
(
chain
consensus
.
ChainHeaderReader
,
header
,
parent
*
types
.
Header
)
error
{
// Ensure that the header's extra-data section is of a reasonable size
...
...
@@ -227,6 +228,10 @@ func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, pa
if
header
.
UncleHash
!=
types
.
EmptyUncleHash
{
return
errInvalidUncleHash
}
// Verify the timestamp
if
header
.
Time
<=
parent
.
Time
{
return
errInvalidTimestamp
}
// Verify the block's difficulty to ensure it's the default constant
if
beaconDifficulty
.
Cmp
(
header
.
Difficulty
)
!=
0
{
return
fmt
.
Errorf
(
"invalid difficulty: have %v, want %v"
,
header
.
Difficulty
,
beaconDifficulty
)
...
...
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