Skip to content
Merged
46 changes: 0 additions & 46 deletions src/it/scala/io/iohk/ethereum/sync/FastSyncItSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -233,52 +233,6 @@ class FastSyncItSpec extends FlatSpecBase with Matchers with BeforeAndAfterAll {
.getBestBlockNumber() == peer3.blockchainReader.getBestBlockNumber() - peer3.testSyncConfig.pivotBlockOffset
)
}

it should "blacklist peer on Invalid batch last header number" in customTestCaseResourceM(
FakePeer.start3FakePeersRes()
) { case (peer1, peer2, peer3) =>
for {
_ <- peer2.importBlocksUntil(1000)(IdentityUpdate)
_ <- peer3.importInvalidBlockNumbers(201, 1200)(IdentityUpdate)

_ <- peer1.connectToPeers(Set(peer2.node, peer3.node))
_ <- peer1.startFastSync().delayExecution(50.milliseconds)
_ <- peer1.waitForFastSyncFinish()
} yield {
// Peer3 is blacklisted
val blacklistedPeer = PeerId(peer3.node.toUri.getUserInfo)
val blacklistReason = peer1.blacklist.cache.getIfPresent(blacklistedPeer)

assert(peer1.blacklist.isBlacklisted(blacklistedPeer))
assert(blacklistReason.get == BlacklistReasonType.BlockHeaderValidationFailedType)
}
}

it should "sync blockchain when peer responds with invalid batch last header hash" in customTestCaseResourceM(
FakePeer.start4FakePeersRes()
) { case (peer1, peer2, peer3, peer4) =>
for {
_ <- peer1.importBlocksUntil(400)(IdentityUpdate)
_ <- peer2.importBlocksUntil(1000)(IdentityUpdate)

_ <- peer3.importInvalidBlocks(600, 800)(IdentityUpdate)
_ <- peer3.importBlocksUntil(1200)(updateStateAtBlock(1000))

_ <- peer4.importBlocksUntil(1100)(IdentityUpdate)

_ <- peer1.connectToPeers(Set(peer2.node, peer3.node, peer4.node)).delayExecution(5.seconds)
_ <- peer1.startFastSync().delayExecution(50.millis)
_ <- peer2.importBlocksUntil(1200)(IdentityUpdate)
_ <- peer1.waitForFastSyncFinish()
} yield {
// Peer3 is blacklisted
val blacklistedPeer = PeerId(peer3.node.toUri.getUserInfo)
val blacklistReason = peer1.blacklist.cache.getIfPresent(blacklistedPeer)

assert(peer1.blacklist.isBlacklisted(blacklistedPeer))
assert(blacklistReason.get == BlacklistReasonType.BlockHeaderValidationFailedType)
}
}
}

object FastSyncItSpec {
Expand Down
10 changes: 6 additions & 4 deletions src/main/resources/conf/base.conf
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,9 @@ mantis {
# Also retry interval in regular sync: for picking blocks batch and retrying requests
sync-retry-interval = 0.5 seconds

# Delay between finishing fast sync and starting regular sync
sync-switch-delay = 0.5 seconds

# Response time-out from peer during sync. If a peer fails to respond within this limit, it will be blacklisted
peer-response-timeout = 30.seconds

Expand Down Expand Up @@ -475,10 +478,6 @@ mantis {
# On reaching this limit, it will perform branch resolving.
fast-sync-max-batch-retries = 5

# If the expected pivot block cannot be confirmed from `min-peers-to-choose-pivot-block`,
# the pivot block number is pushed back by the follwing number of blocks and the confirmation process repeats.
pivot-block-number-reset-delta = 50

# Max number of times a pivot block is checked against available best peers before the whole process is restarted.
max-pivot-block-failures-count = 5
}
Expand Down Expand Up @@ -571,6 +570,9 @@ mantis {

# Define which database to use [rocksdb]
data-source = "rocksdb"

# Run database checks every 10 mins and shut down when an inconsistency is found
periodic-consistency-check = false
}

filter {
Expand Down
Loading