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
4a1e82cf
Commit
4a1e82cf
authored
Jun 17, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth/downloader: fix #1280, overlapping (good/bad) delivery hang
parent
dfd18d24
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
downloader.go
eth/downloader/downloader.go
+1
-0
downloader_test.go
eth/downloader/downloader_test.go
+34
-0
No files found.
eth/downloader/downloader.go
View file @
4a1e82cf
...
...
@@ -548,6 +548,7 @@ out:
peer
.
Demote
()
peer
.
SetIdle
()
glog
.
V
(
logger
.
Detail
)
.
Infof
(
"%s: delivery partially failed: %v"
,
peer
,
err
)
go
d
.
process
()
}
}
...
...
eth/downloader/downloader_test.go
View file @
4a1e82cf
...
...
@@ -708,6 +708,40 @@ func TestBannedChainMemoryExhaustionAttack(t *testing.T) {
}
}
// Tests a corner case (potential attack) where a peer delivers both good as well
// as unrequested blocks to a hash request. This may trigger a different code
// path than the fully correct or fully invalid delivery, potentially causing
// internal state problems
//
// No, don't delete this test, it actually did happen!
func
TestOverlappingDeliveryAttack
(
t
*
testing
.
T
)
{
// Create an arbitrary batch of blocks ( < cache-size not to block)
targetBlocks
:=
blockCacheLimit
-
23
hashes
:=
createHashes
(
targetBlocks
,
knownHash
)
blocks
:=
createBlocksFromHashes
(
hashes
)
// Register an attacker that always returns non-requested blocks too
tester
:=
newTester
()
tester
.
newPeer
(
"attack"
,
hashes
,
blocks
)
rawGetBlocks
:=
tester
.
downloader
.
peers
.
Peer
(
"attack"
)
.
getBlocks
tester
.
downloader
.
peers
.
Peer
(
"attack"
)
.
getBlocks
=
func
(
request
[]
common
.
Hash
)
error
{
// Add a non requested hash the screw the delivery (genesis should be fine)
return
rawGetBlocks
(
append
(
request
,
hashes
[
0
]))
}
// Test that synchronisation can complete, check for import success
if
err
:=
tester
.
sync
(
"attack"
);
err
!=
nil
{
t
.
Fatalf
(
"failed to synchronise blocks: %v"
,
err
)
}
start
:=
time
.
Now
()
for
len
(
tester
.
ownHashes
)
!=
len
(
hashes
)
&&
time
.
Since
(
start
)
<
time
.
Second
{
time
.
Sleep
(
50
*
time
.
Millisecond
)
}
if
len
(
tester
.
ownHashes
)
!=
len
(
hashes
)
{
t
.
Fatalf
(
"chain length mismatch: have %v, want %v"
,
len
(
tester
.
ownHashes
),
len
(
hashes
))
}
}
// Tests that misbehaving peers are disconnected, whilst behaving ones are not.
func
TestHashAttackerDropping
(
t
*
testing
.
T
)
{
// Define the disconnection requirement for individual hash fetch errors
...
...
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