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
367f12f7
Unverified
Commit
367f12f7
authored
Sep 09, 2020
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth/downloader: only roll back light sync if not fully validating
parent
8d35b1eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
11 deletions
+12
-11
downloader.go
eth/downloader/downloader.go
+9
-7
downloader_test.go
eth/downloader/downloader_test.go
+3
-4
No files found.
eth/downloader/downloader.go
View file @
367f12f7
...
@@ -1501,18 +1501,20 @@ func (d *Downloader) processHeaders(origin uint64, pivot uint64, td *big.Int) er
...
@@ -1501,18 +1501,20 @@ func (d *Downloader) processHeaders(origin uint64, pivot uint64, td *big.Int) er
rollbackErr
=
err
rollbackErr
=
err
// If some headers were inserted, track them as uncertain
// If some headers were inserted, track them as uncertain
if
n
>
0
&&
rollback
==
0
{
if
(
mode
==
FastSync
||
frequency
>
1
)
&&
n
>
0
&&
rollback
==
0
{
rollback
=
chunk
[
0
]
.
Number
.
Uint64
()
rollback
=
chunk
[
0
]
.
Number
.
Uint64
()
}
}
log
.
Debug
(
"Invalid header encountered"
,
"number"
,
chunk
[
n
]
.
Number
,
"hash"
,
chunk
[
n
]
.
Hash
(),
"parent"
,
chunk
[
n
]
.
ParentHash
,
"err"
,
err
)
log
.
Warn
(
"Invalid header encountered"
,
"number"
,
chunk
[
n
]
.
Number
,
"hash"
,
chunk
[
n
]
.
Hash
(),
"parent"
,
chunk
[
n
]
.
ParentHash
,
"err"
,
err
)
return
fmt
.
Errorf
(
"%w: %v"
,
errInvalidChain
,
err
)
return
fmt
.
Errorf
(
"%w: %v"
,
errInvalidChain
,
err
)
}
}
// All verifications passed, track all headers within the alloted limits
// All verifications passed, track all headers within the alloted limits
head
:=
chunk
[
len
(
chunk
)
-
1
]
.
Number
.
Uint64
()
if
mode
==
FastSync
{
if
head
-
rollback
>
uint64
(
fsHeaderSafetyNet
)
{
head
:=
chunk
[
len
(
chunk
)
-
1
]
.
Number
.
Uint64
()
rollback
=
head
-
uint64
(
fsHeaderSafetyNet
)
if
head
-
rollback
>
uint64
(
fsHeaderSafetyNet
)
{
}
else
{
rollback
=
head
-
uint64
(
fsHeaderSafetyNet
)
rollback
=
1
}
else
{
rollback
=
1
}
}
}
}
}
// Unless we're doing light chains, schedule the headers for associated content retrieval
// Unless we're doing light chains, schedule the headers for associated content retrieval
...
...
eth/downloader/downloader_test.go
View file @
367f12f7
...
@@ -1020,10 +1020,9 @@ func testShiftedHeaderAttack(t *testing.T, protocol int, mode SyncMode) {
...
@@ -1020,10 +1020,9 @@ func testShiftedHeaderAttack(t *testing.T, protocol int, mode SyncMode) {
// Tests that upon detecting an invalid header, the recent ones are rolled back
// Tests that upon detecting an invalid header, the recent ones are rolled back
// for various failure scenarios. Afterwards a full sync is attempted to make
// for various failure scenarios. Afterwards a full sync is attempted to make
// sure no state was corrupted.
// sure no state was corrupted.
func
TestInvalidHeaderRollback63Fast
(
t
*
testing
.
T
)
{
testInvalidHeaderRollback
(
t
,
63
,
FastSync
)
}
func
TestInvalidHeaderRollback63Fast
(
t
*
testing
.
T
)
{
testInvalidHeaderRollback
(
t
,
63
,
FastSync
)
}
func
TestInvalidHeaderRollback64Fast
(
t
*
testing
.
T
)
{
testInvalidHeaderRollback
(
t
,
64
,
FastSync
)
}
func
TestInvalidHeaderRollback64Fast
(
t
*
testing
.
T
)
{
testInvalidHeaderRollback
(
t
,
64
,
FastSync
)
}
func
TestInvalidHeaderRollback65Fast
(
t
*
testing
.
T
)
{
testInvalidHeaderRollback
(
t
,
65
,
FastSync
)
}
func
TestInvalidHeaderRollback65Fast
(
t
*
testing
.
T
)
{
testInvalidHeaderRollback
(
t
,
65
,
FastSync
)
}
func
TestInvalidHeaderRollback65Light
(
t
*
testing
.
T
)
{
testInvalidHeaderRollback
(
t
,
65
,
LightSync
)
}
func
testInvalidHeaderRollback
(
t
*
testing
.
T
,
protocol
int
,
mode
SyncMode
)
{
func
testInvalidHeaderRollback
(
t
*
testing
.
T
,
protocol
int
,
mode
SyncMode
)
{
t
.
Parallel
()
t
.
Parallel
()
...
...
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