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
fd072c2f
Commit
fd072c2f
authored
Jun 26, 2019
by
gary rong
Committed by
Péter Szilágyi
Jun 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth: fix sync bloom panic (#19757)
* eth: fix sync bloom panic * eth: delete useless test cases
parent
54fd263b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
16 deletions
+22
-16
handler.go
eth/handler.go
+22
-3
handler_test.go
eth/handler_test.go
+0
-5
sync.go
eth/sync.go
+0
-8
No files found.
eth/handler.go
View file @
fd072c2f
...
...
@@ -121,9 +121,28 @@ func NewProtocolManager(config *params.ChainConfig, mode downloader.SyncMode, ne
txsyncCh
:
make
(
chan
*
txsync
),
quitSync
:
make
(
chan
struct
{}),
}
// If fast sync was requested and our database is empty, grant it
if
mode
==
downloader
.
FastSync
&&
blockchain
.
CurrentBlock
()
.
NumberU64
()
==
0
{
manager
.
fastSync
=
uint32
(
1
)
if
mode
==
downloader
.
FullSync
{
// The database seems empty as the current block is the genesis. Yet the fast
// block is ahead, so fast sync was enabled for this node at a certain point.
// The scenarios where this can happen is
// * if the user manually (or via a bad block) rolled back a fast sync node
// below the sync point.
// * the last fast sync is not finished while user specifies a full sync this
// time. But we don't have any recent state for full sync.
// In these cases however it's safe to reenable fast sync.
fullBlock
,
fastBlock
:=
blockchain
.
CurrentBlock
(),
blockchain
.
CurrentFastBlock
()
if
fullBlock
.
NumberU64
()
==
0
&&
fastBlock
.
NumberU64
()
>
0
{
manager
.
fastSync
=
uint32
(
1
)
log
.
Warn
(
"Switch sync mode from full sync to fast sync"
)
}
}
else
{
if
blockchain
.
CurrentBlock
()
.
NumberU64
()
>
0
{
// Print warning log if database is not empty to run fast sync.
log
.
Warn
(
"Switch sync mode from fast sync to full sync"
)
}
else
{
// If fast sync was requested and our database is empty, grant it
manager
.
fastSync
=
uint32
(
1
)
}
}
// If we have trusted checkpoints, enforce them on the chain
if
checkpoint
,
ok
:=
params
.
TrustedCheckpoints
[
blockchain
.
Genesis
()
.
Hash
()];
ok
{
...
...
eth/handler_test.go
View file @
fd072c2f
...
...
@@ -468,27 +468,22 @@ func TestCheckpointChallenge(t *testing.T) {
// If checkpointing is not enabled locally, don't challenge and don't drop
{
downloader
.
FullSync
,
false
,
false
,
false
,
false
,
false
},
{
downloader
.
FastSync
,
false
,
false
,
false
,
false
,
false
},
{
downloader
.
LightSync
,
false
,
false
,
false
,
false
,
false
},
// If checkpointing is enabled locally and remote response is empty, only drop during fast sync
{
downloader
.
FullSync
,
true
,
false
,
true
,
false
,
false
},
{
downloader
.
FastSync
,
true
,
false
,
true
,
false
,
true
},
// Special case, fast sync, unsynced peer
{
downloader
.
LightSync
,
true
,
false
,
true
,
false
,
false
},
// If checkpointing is enabled locally and remote response mismatches, always drop
{
downloader
.
FullSync
,
true
,
false
,
false
,
false
,
true
},
{
downloader
.
FastSync
,
true
,
false
,
false
,
false
,
true
},
{
downloader
.
LightSync
,
true
,
false
,
false
,
false
,
true
},
// If checkpointing is enabled locally and remote response matches, never drop
{
downloader
.
FullSync
,
true
,
false
,
false
,
true
,
false
},
{
downloader
.
FastSync
,
true
,
false
,
false
,
true
,
false
},
{
downloader
.
LightSync
,
true
,
false
,
false
,
true
,
false
},
// If checkpointing is enabled locally and remote times out, always drop
{
downloader
.
FullSync
,
true
,
true
,
false
,
true
,
true
},
{
downloader
.
FastSync
,
true
,
true
,
false
,
true
,
true
},
{
downloader
.
LightSync
,
true
,
true
,
false
,
true
,
true
},
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
fmt
.
Sprintf
(
"sync %v checkpoint %v timeout %v empty %v match %v"
,
tt
.
syncmode
,
tt
.
checkpoint
,
tt
.
timeout
,
tt
.
empty
,
tt
.
match
),
func
(
t
*
testing
.
T
)
{
...
...
eth/sync.go
View file @
fd072c2f
...
...
@@ -179,14 +179,6 @@ func (pm *ProtocolManager) synchronise(peer *peer) {
if
atomic
.
LoadUint32
(
&
pm
.
fastSync
)
==
1
{
// Fast sync was explicitly requested, and explicitly granted
mode
=
downloader
.
FastSync
}
else
if
currentBlock
.
NumberU64
()
==
0
&&
pm
.
blockchain
.
CurrentFastBlock
()
.
NumberU64
()
>
0
{
// The database seems empty as the current block is the genesis. Yet the fast
// block is ahead, so fast sync was enabled for this node at a certain point.
// The only scenario where this can happen is if the user manually (or via a
// bad block) rolled back a fast sync node below the sync point. In this case
// however it's safe to reenable fast sync.
atomic
.
StoreUint32
(
&
pm
.
fastSync
,
1
)
mode
=
downloader
.
FastSync
}
if
mode
==
downloader
.
FastSync
{
// Make sure the peer's total difficulty we are synchronizing is higher.
...
...
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