Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ mantis {
max-mpt-components-per-message = 200

# Maximum number of peers this node can connect to
max-outgoing-peers = 80
max-outgoing-peers = 45

# Maximum number of peers that can connect to this node
max-incoming-peers = 5
max-incoming-peers = 15

# Maximum number of peers that can be connecting to this node
max-pending-peers = 5
max-pending-peers = 20

# Initial delay before connecting to nodes
update-nodes-initial-delay = 5.seconds
Expand Down Expand Up @@ -343,9 +343,7 @@ mantis {

# When we receive a branch that is not rooted in our chain (we don't have a parent for the first header), it means
# we found a fork. To resolve it, we need to query the same peer for previous headers, to find a common ancestor.
# This setting determines how many additional headers we request. The default of 12 may be regarded as confirmation
# depth in ethereum (https://www.reddit.com/r/ethereum/comments/4eplsv/how_many_confirms_is_considered_safe_in_ethereum/)
branch-resolution-request-size = 12
branch-resolution-request-size = 30

# TODO investigate proper value to handle ETC reorgs correctly
# threshold for storing non-main-chain blocks in queue.
Expand Down
6 changes: 4 additions & 2 deletions src/main/resources/chains/testnet-internal-genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
"extraData": "0x00",
"nonce": "0x0000000000000042",
"gasLimit": "0x2fefd8",
"difficulty": "0x400",
"_commentAboutDifficulty": "Set to 1000000",
"difficulty": "0xF4240",
"ommersHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"timestamp": "0x00",
"_commentAboutTimestamp": "Set to 11/05/2020 @ 12:00am (UTC)",
"timestamp": "0x5FA34080",
"coinbase": "0x0000000000000000000000000000000000000000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"alloc": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class BlockFetcher(
private def handleNewBlockMessages(state: BlockFetcherState): Receive = {
case MessageFromPeer(NewBlockHashes(hashes), _) =>
log.debug("Received NewBlockHashes numbers {}", hashes.map(_.number).mkString(", "))
val newState = state.validatedHashes(hashes) match {
val newState = state.validateNewBlockHashes(hashes) match {
case Left(_) => state
case Right(validHashes) => state.withPossibleNewTopAt(validHashes.lastOption.map(_.number))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,10 @@ case class BlockFetcherState(
.ensure("Given headers should form a sequence without gaps")(HeadersSeq.areChain)
}

def validatedHashes(hashes: Seq[BlockHash]): Either[String, Seq[BlockHash]] =
def validateNewBlockHashes(hashes: Seq[BlockHash]): Either[String, Seq[BlockHash]] =
hashes
.asRight[String]
.ensure("Hashes are empty")(_.nonEmpty)
.ensure("Hashes are too new")(_.head.number == nextToLastBlock)
.ensure("Hashes should form a chain")(hashes =>
hashes.zip(hashes.tail).forall { case (a, b) =>
a.number + 1 == b.number
Expand Down