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
86d54770
Unverified
Commit
86d54770
authored
May 06, 2022
by
Marius van der Wijden
Committed by
GitHub
May 06, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/state/snapshot: fix race condition (#24685)
Fixes three race conditions found through fuzzing by David Theodore
parent
345b1fb8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
14 deletions
+26
-14
difflayer.go
core/state/snapshot/difflayer.go
+3
-0
sync.go
eth/protocols/snap/sync.go
+23
-14
No files found.
core/state/snapshot/difflayer.go
View file @
86d54770
...
...
@@ -258,6 +258,9 @@ func (dl *diffLayer) Root() common.Hash {
// Parent returns the subsequent layer of a diff layer.
func
(
dl
*
diffLayer
)
Parent
()
snapshot
{
dl
.
lock
.
RLock
()
defer
dl
.
lock
.
RUnlock
()
return
dl
.
parent
}
...
...
eth/protocols/snap/sync.go
View file @
86d54770
...
...
@@ -422,6 +422,8 @@ type Syncer struct {
storageSynced
uint64
// Number of storage slots downloaded
storageBytes
common
.
StorageSize
// Number of storage trie bytes persisted to disk
extProgress
*
SyncProgress
// progress that can be exposed to external caller.
// Request tracking during healing phase
trienodeHealIdlers
map
[
string
]
struct
{}
// Peers that aren't serving trie node requests
bytecodeHealIdlers
map
[
string
]
struct
{}
// Peers that aren't serving bytecode requests
...
...
@@ -477,6 +479,8 @@ func NewSyncer(db ethdb.KeyValueStore) *Syncer {
trienodeHealReqs
:
make
(
map
[
uint64
]
*
trienodeHealRequest
),
bytecodeHealReqs
:
make
(
map
[
uint64
]
*
bytecodeHealRequest
),
stateWriter
:
db
.
NewBatch
(),
extProgress
:
new
(
SyncProgress
),
}
}
...
...
@@ -633,6 +637,21 @@ func (s *Syncer) Sync(root common.Hash, cancel chan struct{}) error {
s
.
assignTrienodeHealTasks
(
trienodeHealResps
,
trienodeHealReqFails
,
cancel
)
s
.
assignBytecodeHealTasks
(
bytecodeHealResps
,
bytecodeHealReqFails
,
cancel
)
}
// Update sync progress
s
.
lock
.
Lock
()
s
.
extProgress
=
&
SyncProgress
{
AccountSynced
:
s
.
accountSynced
,
AccountBytes
:
s
.
accountBytes
,
BytecodeSynced
:
s
.
bytecodeSynced
,
BytecodeBytes
:
s
.
bytecodeBytes
,
StorageSynced
:
s
.
storageSynced
,
StorageBytes
:
s
.
storageBytes
,
TrienodeHealSynced
:
s
.
trienodeHealSynced
,
TrienodeHealBytes
:
s
.
trienodeHealBytes
,
BytecodeHealSynced
:
s
.
bytecodeHealSynced
,
BytecodeHealBytes
:
s
.
bytecodeHealBytes
,
}
s
.
lock
.
Unlock
()
// Wait for something to happen
select
{
case
<-
s
.
update
:
...
...
@@ -705,6 +724,9 @@ func (s *Syncer) loadSyncStatus() {
}
}
}
s
.
lock
.
Lock
()
defer
s
.
lock
.
Unlock
()
s
.
snapped
=
len
(
s
.
tasks
)
==
0
s
.
accountSynced
=
progress
.
AccountSynced
...
...
@@ -802,25 +824,12 @@ func (s *Syncer) saveSyncStatus() {
func
(
s
*
Syncer
)
Progress
()
(
*
SyncProgress
,
*
SyncPending
)
{
s
.
lock
.
Lock
()
defer
s
.
lock
.
Unlock
()
progress
:=
&
SyncProgress
{
AccountSynced
:
s
.
accountSynced
,
AccountBytes
:
s
.
accountBytes
,
BytecodeSynced
:
s
.
bytecodeSynced
,
BytecodeBytes
:
s
.
bytecodeBytes
,
StorageSynced
:
s
.
storageSynced
,
StorageBytes
:
s
.
storageBytes
,
TrienodeHealSynced
:
s
.
trienodeHealSynced
,
TrienodeHealBytes
:
s
.
trienodeHealBytes
,
BytecodeHealSynced
:
s
.
bytecodeHealSynced
,
BytecodeHealBytes
:
s
.
bytecodeHealBytes
,
}
pending
:=
new
(
SyncPending
)
if
s
.
healer
!=
nil
{
pending
.
TrienodeHeal
=
uint64
(
len
(
s
.
healer
.
trieTasks
))
pending
.
BytecodeHeal
=
uint64
(
len
(
s
.
healer
.
codeTasks
))
}
return
p
rogress
,
pending
return
s
.
extP
rogress
,
pending
}
// cleanAccountTasks removes account range retrieval tasks that have already been
...
...
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