2021-12-08 21:15:29 +00:00
|
|
|
# beacon_chain
|
2024-01-06 14:26:56 +00:00
|
|
|
# Copyright (c) 2018-2024 Status Research & Development GmbH
|
2021-12-08 21:15:29 +00:00
|
|
|
# Licensed and distributed under either of
|
|
|
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
|
|
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
|
2023-01-20 14:14:37 +00:00
|
|
|
{.push raises: [].}
|
2021-12-08 21:15:29 +00:00
|
|
|
|
|
|
|
const
|
2022-01-26 12:20:08 +00:00
|
|
|
NewPeerScore* = 300
|
2022-09-28 18:56:04 +00:00
|
|
|
## Score which will be assigned to newly connected peer
|
2022-01-26 12:20:08 +00:00
|
|
|
PeerScoreLowLimit* = 0
|
|
|
|
## Score after which peer will be kicked
|
|
|
|
PeerScoreHighLimit* = 1000
|
|
|
|
## Max value of peer's score
|
2023-05-19 12:01:27 +00:00
|
|
|
PeerScorePoorRequest* = -50
|
|
|
|
## This peer is not responding on time or behaving improperly otherwise
|
2022-01-26 12:20:08 +00:00
|
|
|
PeerScoreInvalidRequest* = -500
|
|
|
|
## This peer is sending malformed or nonsensical data
|
|
|
|
|
2021-12-08 21:15:29 +00:00
|
|
|
PeerScoreNoStatus* = -100
|
|
|
|
## Peer did not answer `status` request.
|
|
|
|
PeerScoreStaleStatus* = -50
|
2022-09-28 18:56:04 +00:00
|
|
|
## Peer's `status` answer did not progress in time.
|
2021-12-08 21:15:29 +00:00
|
|
|
PeerScoreUseless* = -10
|
|
|
|
## Peer's latest head is lower then ours.
|
|
|
|
PeerScoreGoodStatus* = 50
|
|
|
|
## Peer's `status` answer is fine.
|
2022-11-11 11:34:28 +00:00
|
|
|
PeerScoreNoValues* = -100
|
2022-09-28 18:56:04 +00:00
|
|
|
## Peer did not respond in time to a request.
|
2024-03-24 08:41:47 +00:00
|
|
|
PeerScoreGoodBatchValue* = 5
|
|
|
|
## Individual portion of peer's multi-step answer is fine.
|
2022-11-11 11:34:28 +00:00
|
|
|
PeerScoreGoodValues* = 100
|
2022-09-28 18:56:04 +00:00
|
|
|
## Peer's answer to our request is fine.
|
2022-11-11 11:34:28 +00:00
|
|
|
PeerScoreBadValues* = -1000
|
2022-09-28 18:56:04 +00:00
|
|
|
## Peer's response contains incorrect data.
|
2021-12-08 21:15:29 +00:00
|
|
|
PeerScoreBadResponse* = -1000
|
2024-11-12 04:51:49 +00:00
|
|
|
## Peer's response is not in requested range.
|
2022-11-11 11:34:28 +00:00
|
|
|
PeerScoreMissingValues* = -25
|
2022-09-28 18:56:04 +00:00
|
|
|
## Peer response contains too much missing data - this can happen either
|
2022-01-26 12:20:08 +00:00
|
|
|
## because a long reorg happened or the peer is falsely trying to convince
|
|
|
|
## us that a long reorg happened.
|
|
|
|
PeerScoreUnviableFork* = -200
|
2022-09-28 18:56:04 +00:00
|
|
|
## Peer responded with data from an unviable fork - are they on a
|
2022-01-26 12:20:08 +00:00
|
|
|
## different chain?
|
2022-09-19 09:37:42 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
SyncResponseKind* {.pure.} = enum
|
|
|
|
Good, Empty
|
|
|
|
|
|
|
|
SyncResponseStats* = array[int(high(SyncResponseKind)) + 1, uint64]
|
|
|
|
|
|
|
|
template get*(a: SyncResponseStats, index: SyncResponseKind): uint64 =
|
|
|
|
a[int(index)]
|
|
|
|
|
|
|
|
template update*(a: var SyncResponseStats, index: SyncResponseKind,
|
|
|
|
value: uint64) =
|
|
|
|
a[int(index)] += value
|