good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
8a070e8f
Unverified
Commit
8a070e8f
authored
May 7, 2021
by
Martin Holst Swende
Committed by
GitHub
May 7, 2021
Browse files
Options
Downloads
Patches
Plain Diff
consensus/clique: add some missing checks (#22836)
parent
a5669ae2
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
consensus/clique/clique.go
+19
-0
19 additions, 0 deletions
consensus/clique/clique.go
with
19 additions
and
0 deletions
consensus/clique/clique.go
+
19
−
0
View file @
8a070e8f
...
@@ -20,6 +20,7 @@ package clique
...
@@ -20,6 +20,7 @@ package clique
import
(
import
(
"bytes"
"bytes"
"errors"
"errors"
"fmt"
"io"
"io"
"math/big"
"math/big"
"math/rand"
"math/rand"
...
@@ -293,6 +294,15 @@ func (c *Clique) verifyHeader(chain consensus.ChainHeaderReader, header *types.H
...
@@ -293,6 +294,15 @@ func (c *Clique) verifyHeader(chain consensus.ChainHeaderReader, header *types.H
return
errInvalidDifficulty
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 all checks passed, validate any special fields for hard forks
if
err
:=
misc
.
VerifyForkHashes
(
chain
.
Config
(),
header
,
false
);
err
!=
nil
{
if
err
:=
misc
.
VerifyForkHashes
(
chain
.
Config
(),
header
,
false
);
err
!=
nil
{
return
err
return
err
...
@@ -324,6 +334,15 @@ func (c *Clique) verifyCascadingFields(chain consensus.ChainHeaderReader, header
...
@@ -324,6 +334,15 @@ func (c *Clique) verifyCascadingFields(chain consensus.ChainHeaderReader, header
if
parent
.
Time
+
c
.
config
.
Period
>
header
.
Time
{
if
parent
.
Time
+
c
.
config
.
Period
>
header
.
Time
{
return
errInvalidTimestamp
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
// Retrieve the snapshot needed to verify this header and cache it
snap
,
err
:=
c
.
snapshot
(
chain
,
number
-
1
,
header
.
ParentHash
,
parents
)
snap
,
err
:=
c
.
snapshot
(
chain
,
number
-
1
,
header
.
ParentHash
,
parents
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment