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
8a070e8f
Unverified
Commit
8a070e8f
authored
May 07, 2021
by
Martin Holst Swende
Committed by
GitHub
May 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
consensus/clique: add some missing checks (#22836)
parent
a5669ae2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
clique.go
consensus/clique/clique.go
+19
-0
No files found.
consensus/clique/clique.go
View file @
8a070e8f
...
...
@@ -20,6 +20,7 @@ package clique
import
(
"bytes"
"errors"
"fmt"
"io"
"math/big"
"math/rand"
...
...
@@ -293,6 +294,15 @@ func (c *Clique) verifyHeader(chain consensus.ChainHeaderReader, header *types.H
return
errInvalidDifficulty
}
}
// Verify that the gas limit is <= 2^63-1
cap
:=
uint64
(
0x7fffffffffffffff
)
if
header
.
GasLimit
>
cap
{
return
fmt
.
Errorf
(
"invalid gasLimit: have %v, max %v"
,
header
.
GasLimit
,
cap
)
}
// Verify that the gasUsed is <= gasLimit
if
header
.
GasUsed
>
header
.
GasLimit
{
return
fmt
.
Errorf
(
"invalid gasUsed: have %d, gasLimit %d"
,
header
.
GasUsed
,
header
.
GasLimit
)
}
// If all checks passed, validate any special fields for hard forks
if
err
:=
misc
.
VerifyForkHashes
(
chain
.
Config
(),
header
,
false
);
err
!=
nil
{
return
err
...
...
@@ -324,6 +334,15 @@ func (c *Clique) verifyCascadingFields(chain consensus.ChainHeaderReader, header
if
parent
.
Time
+
c
.
config
.
Period
>
header
.
Time
{
return
errInvalidTimestamp
}
// Verify that the gas limit remains within allowed bounds
diff
:=
int64
(
parent
.
GasLimit
)
-
int64
(
header
.
GasLimit
)
if
diff
<
0
{
diff
*=
-
1
}
limit
:=
parent
.
GasLimit
/
params
.
GasLimitBoundDivisor
if
uint64
(
diff
)
>=
limit
||
header
.
GasLimit
<
params
.
MinGasLimit
{
return
fmt
.
Errorf
(
"invalid gas limit: have %d, want %d += %d"
,
header
.
GasLimit
,
parent
.
GasLimit
,
limit
)
}
// Retrieve the snapshot needed to verify this header and cache it
snap
,
err
:=
c
.
snapshot
(
chain
,
number
-
1
,
header
.
ParentHash
,
parents
)
if
err
!=
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