mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-06 01:05:32 +00:00
8c7d91512b
* Rename `LeafRange` => `NodeTagRange` * Replacing storage slot partition point by interval why: The partition point only allows to describe slots `[point,high(Uint256)]` for fetching interval slot ranges. This has been generalised for any interval. * Replacing `SnapAccountRanges` by `SnapTrieRangeBatch` why: Generalised healing status for accounts, and later for storage slots. * Improve accounts healing loop * Split `snap_db` into accounts and storage modules why: It is cleaner to have separate session descriptors for accounts and storage slots (based on a common base descriptor.) Also, persistent storage handling might be changed in future which requires the storage slot implementation disentangled from the accounts handling. * Re-model worker queues for storage slots why: There is a dynamic list of storage sub-tries, each one has to be treated similar to the accounts database. This applied to slot interval downloads as well as to healing * Compress some return value report lists for snapdb methods why: No need to report all handling details for work items that are filteres out and discarded, anyway. * Remove inner loop frame from healing function why: The healing function runs as a loop body already.
105 lines
2.8 KiB
Nim
105 lines
2.8 KiB
Nim
# Nimbus
|
|
# Copyright (c) 2021 Status Research & Development GmbH
|
|
# Licensed under either of
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
|
# http://opensource.org/licenses/MIT)
|
|
# at your option. This file may not be copied, modified, or distributed
|
|
# except according to those terms.
|
|
|
|
import
|
|
chronos,
|
|
../../../sync_desc
|
|
|
|
const
|
|
comErrorsTimeoutMax* = 2
|
|
## Maximal number of non-resonses accepted in a row. If there are more than
|
|
## `comErrorsTimeoutMax` consecutive errors, the worker will be degraded
|
|
## as zombie.
|
|
|
|
type
|
|
ComErrorStatsRef* = ref object
|
|
## particular error counters so connections will not be cut immediately
|
|
## after a particular error.
|
|
nTimeouts*: uint
|
|
nNetwork*: uint
|
|
|
|
ComError* = enum
|
|
ComNothingSerious
|
|
ComAccountsMaxTooLarge
|
|
ComAccountsMinTooSmall
|
|
ComEmptyAccountsArguments
|
|
ComEmptyPartialRange
|
|
ComEmptyRequestArguments
|
|
ComMissingProof
|
|
ComNetworkProblem
|
|
ComNoAccountsForStateRoot
|
|
ComNoByteCodesAvailable
|
|
ComNoDataForProof
|
|
ComNoHeaderAvailable
|
|
ComNoStorageForAccounts
|
|
ComNoTrieNodesAvailable
|
|
ComResponseTimeout
|
|
ComTooManyByteCodes
|
|
ComTooManyHeaders
|
|
ComTooManyStorageSlots
|
|
ComTooManyTrieNodes
|
|
|
|
# Other errors not directly related to communication
|
|
ComInspectDbFailed
|
|
ComImportAccountsFailed
|
|
|
|
|
|
proc stopAfterSeriousComError*(
|
|
ctrl: BuddyCtrlRef;
|
|
error: ComError;
|
|
stats: ComErrorStatsRef;
|
|
): Future[bool]
|
|
{.async.} =
|
|
## Error handling after data protocol failed.
|
|
case error:
|
|
of ComResponseTimeout:
|
|
stats.nTimeouts.inc
|
|
if comErrorsTimeoutMax < stats.nTimeouts:
|
|
# Mark this peer dead, i.e. avoid fetching from this peer for a while
|
|
ctrl.zombie = true
|
|
else:
|
|
# Otherwise try again some time later. Nevertheless, stop the
|
|
# current action.
|
|
await sleepAsync(5.seconds)
|
|
return true
|
|
|
|
of ComNetworkProblem,
|
|
ComMissingProof,
|
|
ComAccountsMinTooSmall,
|
|
ComAccountsMaxTooLarge:
|
|
stats.nNetwork.inc
|
|
# Mark this peer dead, i.e. avoid fetching from this peer for a while
|
|
ctrl.zombie = true
|
|
return true
|
|
|
|
of ComEmptyAccountsArguments,
|
|
ComEmptyRequestArguments,
|
|
ComEmptyPartialRange,
|
|
ComInspectDbFailed,
|
|
ComImportAccountsFailed,
|
|
ComNoDataForProof,
|
|
ComNothingSerious:
|
|
discard
|
|
|
|
of ComNoAccountsForStateRoot,
|
|
ComNoStorageForAccounts,
|
|
ComNoByteCodesAvailable,
|
|
ComNoHeaderAvailable,
|
|
ComNoTrieNodesAvailable,
|
|
ComTooManyByteCodes,
|
|
ComTooManyHeaders,
|
|
ComTooManyStorageSlots,
|
|
ComTooManyTrieNodes:
|
|
# Mark this peer dead, i.e. avoid fetching from this peer for a while
|
|
ctrl.zombie = true
|
|
return true
|
|
|
|
# End
|