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
4a1e82cf
Commit
4a1e82cf
authored
Jun 17, 2015
by
Péter Szilágyi
Browse files
Options
Downloads
Patches
Plain Diff
eth/downloader: fix #1280, overlapping (good/bad) delivery hang
parent
dfd18d24
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
eth/downloader/downloader.go
+1
-0
1 addition, 0 deletions
eth/downloader/downloader.go
eth/downloader/downloader_test.go
+34
-0
34 additions, 0 deletions
eth/downloader/downloader_test.go
with
35 additions
and
0 deletions
eth/downloader/downloader.go
+
1
−
0
View file @
4a1e82cf
...
@@ -548,6 +548,7 @@ out:
...
@@ -548,6 +548,7 @@ out:
peer
.
Demote
()
peer
.
Demote
()
peer
.
SetIdle
()
peer
.
SetIdle
()
glog
.
V
(
logger
.
Detail
)
.
Infof
(
"%s: delivery partially failed: %v"
,
peer
,
err
)
glog
.
V
(
logger
.
Detail
)
.
Infof
(
"%s: delivery partially failed: %v"
,
peer
,
err
)
go
d
.
process
()
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
eth/downloader/downloader_test.go
+
34
−
0
View file @
4a1e82cf
...
@@ -708,6 +708,40 @@ func TestBannedChainMemoryExhaustionAttack(t *testing.T) {
...
@@ -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.
// Tests that misbehaving peers are disconnected, whilst behaving ones are not.
func
TestHashAttackerDropping
(
t
*
testing
.
T
)
{
func
TestHashAttackerDropping
(
t
*
testing
.
T
)
{
// Define the disconnection requirement for individual hash fetch errors
// Define the disconnection requirement for individual hash fetch errors
...
...
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