import cleanup (#2997)
* import cleanup ...and remove some unused types * add random imports * more imports
This commit is contained in:
parent
c40cc6cec1
commit
df3fc9525f
|
@ -5,7 +5,7 @@
|
|||
# * 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.
|
||||
|
||||
# Common routines for a BeaconNode and a BeaconValidator node
|
||||
# Everything needed to run a full Beacon Node
|
||||
|
||||
import
|
||||
std/osproc,
|
||||
|
@ -15,21 +15,22 @@ import
|
|||
taskpools,
|
||||
|
||||
# Local modules
|
||||
"."/[beacon_clock, beacon_chain_db, beacon_node_types, conf],
|
||||
"."/[beacon_clock, beacon_chain_db, conf],
|
||||
./gossip_processing/[eth2_processor, block_processor, consensus_manager],
|
||||
./networking/eth2_network,
|
||||
./eth1/eth1_monitor,
|
||||
./consensus_object_pools/[
|
||||
blockchain_dag, block_quarantine, exit_pool, attestation_pool],
|
||||
blockchain_dag, block_quarantine, exit_pool, attestation_pool,
|
||||
sync_committee_msg_pool],
|
||||
./spec/datatypes/base,
|
||||
./sync/[sync_manager, request_manager],
|
||||
./validators/action_tracker
|
||||
./validators/[action_tracker, validator_pool]
|
||||
|
||||
export
|
||||
osproc, chronos, httpserver, presto, action_tracker, beacon_clock,
|
||||
beacon_chain_db, conf, attestation_pool, eth2_network, beacon_node_types,
|
||||
eth1_monitor, request_manager, sync_manager, eth2_processor, blockchain_dag,
|
||||
block_quarantine, base, exit_pool
|
||||
beacon_chain_db, conf, attestation_pool, sync_committee_msg_pool,
|
||||
validator_pool, eth2_network, eth1_monitor, request_manager, sync_manager,
|
||||
eth2_processor, blockchain_dag, block_quarantine, base, exit_pool
|
||||
|
||||
type
|
||||
RpcServer* = RpcHttpServer
|
|
@ -1,192 +0,0 @@
|
|||
# beacon_chain
|
||||
# Copyright (c) 2018-2021 Status Research & Development GmbH
|
||||
# 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.
|
||||
|
||||
{.push raises: [Defect].}
|
||||
|
||||
import
|
||||
std/[deques, streams, tables, hashes, options],
|
||||
stew/endians2,
|
||||
./spec/datatypes/[phase0, altair],
|
||||
./spec/keystore,
|
||||
./consensus_object_pools/block_pools_types,
|
||||
./fork_choice/fork_choice_types,
|
||||
./validators/slashing_protection
|
||||
|
||||
export deques, tables, hashes, options, block_pools_types
|
||||
|
||||
const
|
||||
ATTESTATION_LOOKBACK* =
|
||||
min(24'u64, SLOTS_PER_EPOCH) + MIN_ATTESTATION_INCLUSION_DELAY
|
||||
## The number of slots we'll keep track of in terms of "free" attestations
|
||||
## that potentially could be added to a newly created block
|
||||
|
||||
type
|
||||
# #############################################
|
||||
#
|
||||
# Attestation Pool
|
||||
#
|
||||
# #############################################
|
||||
OnAttestationCallback* = proc(data: Attestation) {.gcsafe, raises: [Defect].}
|
||||
|
||||
Validation* = object
|
||||
## Validations collect a set of signatures for a distict attestation - in
|
||||
## eth2, a single bit is used to keep track of which signatures have been
|
||||
## added to the aggregate meaning that only non-overlapping aggregates may
|
||||
## be further combined.
|
||||
aggregation_bits*: CommitteeValidatorsBits
|
||||
aggregate_signature*: AggregateSignature
|
||||
|
||||
AttestationEntry* = object
|
||||
## Each entry holds the known signatures for a particular, distinct vote
|
||||
data*: AttestationData
|
||||
committee_len*: int
|
||||
singles*: Table[int, CookedSig] ## \
|
||||
## On the attestation subnets, only attestations with a single vote are
|
||||
## allowed - these can be collected separately to top up aggregates with -
|
||||
## here we collect them by mapping index in committee to a vote
|
||||
aggregates*: seq[Validation]
|
||||
|
||||
AttestationTable* = Table[Eth2Digest, AttestationEntry]
|
||||
## Depending on the world view of the various validators, they may have
|
||||
## voted on different states - this map keeps track of each vote keyed by
|
||||
## hash_tree_root(AttestationData)
|
||||
|
||||
AttestationPool* = object
|
||||
## The attestation pool keeps track of all attestations that potentially
|
||||
## could be added to a block during block production.
|
||||
## These attestations also contribute to the fork choice, which combines
|
||||
## "free" attestations with those found in past blocks - these votes
|
||||
## are tracked separately in the fork choice.
|
||||
|
||||
candidates*: array[ATTESTATION_LOOKBACK, AttestationTable] ## \
|
||||
## We keep one item per slot such that indexing matches slot number
|
||||
## together with startingSlot
|
||||
|
||||
startingSlot*: Slot ## \
|
||||
## Generally, we keep attestations only until a slot has been finalized -
|
||||
## after that, they may no longer affect fork choice.
|
||||
|
||||
dag*: ChainDAGRef
|
||||
quarantine*: QuarantineRef
|
||||
|
||||
forkChoice*: ForkChoice
|
||||
|
||||
nextAttestationEpoch*: seq[tuple[subnet: Epoch, aggregate: Epoch]] ## \
|
||||
## sequence based on validator indices
|
||||
|
||||
onAttestationAdded*: OnAttestationCallback
|
||||
|
||||
SyncCommitteeMsgKey* = object
|
||||
originator*: ValidatorIndex
|
||||
slot*: Slot
|
||||
committeeIdx*: SyncCommitteeIndex
|
||||
|
||||
TrustedSyncCommitteeMsg* = object
|
||||
slot*: Slot
|
||||
committeeIdx*: SyncCommitteeIndex
|
||||
positionInCommittee*: uint64
|
||||
signature*: CookedSig
|
||||
|
||||
BestSyncSubcommitteeContribution* = object
|
||||
totalParticipants*: int
|
||||
participationBits*: SyncCommitteeAggregationBits
|
||||
signature*: CookedSig
|
||||
|
||||
BestSyncSubcommitteeContributions* = object
|
||||
slot*: Slot
|
||||
subnets*: array[SYNC_COMMITTEE_SUBNET_COUNT,
|
||||
BestSyncSubcommitteeContribution]
|
||||
|
||||
OnSyncContributionCallback* =
|
||||
proc(data: SignedContributionAndProof) {.gcsafe, raises: [Defect].}
|
||||
|
||||
SyncCommitteeMsgPool* = object
|
||||
seenSyncMsgByAuthor*: HashSet[SyncCommitteeMsgKey]
|
||||
seenContributionByAuthor*: HashSet[SyncCommitteeMsgKey]
|
||||
syncMessages*: Table[Eth2Digest, seq[TrustedSyncCommitteeMsg]]
|
||||
bestContributions*: Table[Eth2Digest, BestSyncSubcommitteeContributions]
|
||||
onContributionReceived*: OnSyncContributionCallback
|
||||
|
||||
SyncCommitteeMsgPoolRef* = ref SyncCommitteeMsgPool
|
||||
|
||||
# #############################################
|
||||
#
|
||||
# Validator Pool
|
||||
#
|
||||
# #############################################
|
||||
ValidatorKind* {.pure.} = enum
|
||||
Local, Remote
|
||||
|
||||
ValidatorConnection* = object
|
||||
inStream*: Stream
|
||||
outStream*: Stream
|
||||
pubKeyStr*: string
|
||||
|
||||
ValidatorPrivateItem* = object
|
||||
privateKey*: ValidatorPrivKey
|
||||
description*: Option[string]
|
||||
path*: Option[KeyPath]
|
||||
uuid*: Option[string]
|
||||
version*: Option[uint64]
|
||||
|
||||
AttachedValidator* = ref object
|
||||
pubKey*: ValidatorPubKey
|
||||
case kind*: ValidatorKind
|
||||
of ValidatorKind.Local:
|
||||
data*: ValidatorPrivateItem
|
||||
of ValidatorKind.Remote:
|
||||
connection*: ValidatorConnection
|
||||
|
||||
# The index at which this validator has been observed in the chain -
|
||||
# it does not change as long as there are no reorgs on eth1 - however, the
|
||||
# index might not be valid in all eth2 histories, so it should not be
|
||||
# assumed that a valid index is stored here!
|
||||
index*: Option[ValidatorIndex]
|
||||
|
||||
# Cache the latest slot signature - the slot signature is used to determine
|
||||
# if the validator will be aggregating (in the near future)
|
||||
slotSignature*: Option[tuple[slot: Slot, signature: ValidatorSig]]
|
||||
|
||||
ValidatorPool* = object
|
||||
validators*: Table[ValidatorPubKey, AttachedValidator]
|
||||
slashingProtection*: SlashingProtectionDB
|
||||
|
||||
AttesterDuty* = object
|
||||
subnet*: SubnetId
|
||||
slot*: Slot
|
||||
isAggregator*: bool
|
||||
|
||||
AttestationSubnets* = object
|
||||
enabled*: bool
|
||||
|
||||
subscribedSubnets*: BitArray[ATTESTATION_SUBNET_COUNT] ##\
|
||||
## All subnets we're current subscribed to
|
||||
|
||||
stabilitySubnets*: seq[tuple[subnet_id: SubnetId, expiration: Epoch]] ##\
|
||||
## The subnets on which we listen and broadcast gossip traffic to maintain
|
||||
## the health of the network - these are advertised in the ENR
|
||||
nextCycleEpoch*: Epoch
|
||||
|
||||
# Used to track the next attestation and proposal slots using an
|
||||
# epoch-relative coordinate system. Doesn't need initialization.
|
||||
attestingSlots*: array[2, uint32]
|
||||
proposingSlots*: array[2, uint32]
|
||||
lastCalculatedEpoch*: Epoch
|
||||
|
||||
knownValidators*: Table[ValidatorIndex, Slot]
|
||||
## Validators that we've recently seen - we'll subscribe to one stability
|
||||
## subnet for each such validator - the slot is used to expire validators
|
||||
## that no longer are posting duties
|
||||
|
||||
duties*: seq[AttesterDuty] ##\
|
||||
## Known aggregation duties in the near future - before each such
|
||||
## duty, we'll subscribe to the corresponding subnet to collect
|
||||
|
||||
func shortLog*(v: AttachedValidator): string = shortLog(v.pubKey)
|
||||
|
||||
func hash*(x: SyncCommitteeMsgKey): Hash =
|
||||
hashData(unsafeAddr x, sizeof(x))
|
|
@ -12,15 +12,72 @@ import
|
|||
std/[options, tables, sequtils],
|
||||
# Status libraries
|
||||
metrics,
|
||||
chronicles, stew/byteutils, json_serialization/std/sets as jsonSets,
|
||||
chronicles, stew/byteutils,
|
||||
# Internal
|
||||
../spec/[beaconstate, eth2_merkleization, forks, helpers, validator],
|
||||
../spec/datatypes/[phase0, altair, merge],
|
||||
"."/[spec_cache, blockchain_dag, block_quarantine],
|
||||
".."/[beacon_clock, beacon_node_types],
|
||||
../fork_choice/fork_choice
|
||||
../fork_choice/fork_choice,
|
||||
../beacon_clock
|
||||
|
||||
export beacon_node_types
|
||||
export options, tables, phase0, altair, merge, blockchain_dag, fork_choice
|
||||
|
||||
const
|
||||
ATTESTATION_LOOKBACK* =
|
||||
min(24'u64, SLOTS_PER_EPOCH) + MIN_ATTESTATION_INCLUSION_DELAY
|
||||
## The number of slots we'll keep track of in terms of "free" attestations
|
||||
## that potentially could be added to a newly created block
|
||||
|
||||
type
|
||||
OnAttestationCallback* = proc(data: Attestation) {.gcsafe, raises: [Defect].}
|
||||
|
||||
Validation* = object
|
||||
## Validations collect a set of signatures for a distict attestation - in
|
||||
## eth2, a single bit is used to keep track of which signatures have been
|
||||
## added to the aggregate meaning that only non-overlapping aggregates may
|
||||
## be further combined.
|
||||
aggregation_bits*: CommitteeValidatorsBits
|
||||
aggregate_signature*: AggregateSignature
|
||||
|
||||
AttestationEntry* = object
|
||||
## Each entry holds the known signatures for a particular, distinct vote
|
||||
data*: AttestationData
|
||||
committee_len*: int
|
||||
singles*: Table[int, CookedSig] ## \
|
||||
## On the attestation subnets, only attestations with a single vote are
|
||||
## allowed - these can be collected separately to top up aggregates with -
|
||||
## here we collect them by mapping index in committee to a vote
|
||||
aggregates*: seq[Validation]
|
||||
|
||||
AttestationTable* = Table[Eth2Digest, AttestationEntry]
|
||||
## Depending on the world view of the various validators, they may have
|
||||
## voted on different states - this map keeps track of each vote keyed by
|
||||
## hash_tree_root(AttestationData)
|
||||
|
||||
AttestationPool* = object
|
||||
## The attestation pool keeps track of all attestations that potentially
|
||||
## could be added to a block during block production.
|
||||
## These attestations also contribute to the fork choice, which combines
|
||||
## "free" attestations with those found in past blocks - these votes
|
||||
## are tracked separately in the fork choice.
|
||||
|
||||
candidates*: array[ATTESTATION_LOOKBACK, AttestationTable] ## \
|
||||
## We keep one item per slot such that indexing matches slot number
|
||||
## together with startingSlot
|
||||
|
||||
startingSlot*: Slot ## \
|
||||
## Generally, we keep attestations only until a slot has been finalized -
|
||||
## after that, they may no longer affect fork choice.
|
||||
|
||||
dag*: ChainDAGRef
|
||||
quarantine*: QuarantineRef
|
||||
|
||||
forkChoice*: ForkChoice
|
||||
|
||||
nextAttestationEpoch*: seq[tuple[subnet: Epoch, aggregate: Epoch]] ## \
|
||||
## sequence based on validator indices
|
||||
|
||||
onAttestationAdded*: OnAttestationCallback
|
||||
|
||||
logScope: topics = "attpool"
|
||||
|
||||
|
@ -591,8 +648,8 @@ proc getAttestationsForBlock*(pool: var AttestationPool,
|
|||
|
||||
res
|
||||
|
||||
proc getAttestationsForBlock*(pool: var AttestationPool,
|
||||
state: ForkedHashedBeaconState,
|
||||
proc getAttestationsForBlock*(pool: var AttestationPool,
|
||||
state: ForkedHashedBeaconState,
|
||||
cache: var StateCache): seq[Attestation] =
|
||||
withState(state):
|
||||
pool.getAttestationsForBlock(state, cache)
|
||||
|
|
|
@ -8,27 +8,53 @@
|
|||
{.push raises: [Defect].}
|
||||
|
||||
import
|
||||
std/sets,
|
||||
std/[hashes, sets, tables],
|
||||
chronicles,
|
||||
../spec/digest,
|
||||
../spec/datatypes/altair,
|
||||
../beacon_node_types,
|
||||
./block_pools_types
|
||||
../spec/datatypes/altair
|
||||
|
||||
export
|
||||
BestSyncSubcommitteeContributions,
|
||||
Slot,
|
||||
SyncCommitteeContribution,
|
||||
SyncCommitteeIndex,
|
||||
SyncCommitteeMsgPool,
|
||||
SyncAggregate,
|
||||
TrustedSyncCommitteeMsg
|
||||
export hashes, sets, tables, altair
|
||||
|
||||
const
|
||||
syncCommitteeMsgsRetentionSlots = 3
|
||||
## How many slots to retain sync committee
|
||||
## messsages before discarding them.
|
||||
|
||||
type
|
||||
SyncCommitteeMsgKey* = object
|
||||
originator*: ValidatorIndex
|
||||
slot*: Slot
|
||||
committeeIdx*: SyncCommitteeIndex
|
||||
|
||||
TrustedSyncCommitteeMsg* = object
|
||||
slot*: Slot
|
||||
committeeIdx*: SyncCommitteeIndex
|
||||
positionInCommittee*: uint64
|
||||
signature*: CookedSig
|
||||
|
||||
BestSyncSubcommitteeContribution* = object
|
||||
totalParticipants*: int
|
||||
participationBits*: SyncCommitteeAggregationBits
|
||||
signature*: CookedSig
|
||||
|
||||
BestSyncSubcommitteeContributions* = object
|
||||
slot*: Slot
|
||||
subnets*: array[SYNC_COMMITTEE_SUBNET_COUNT,
|
||||
BestSyncSubcommitteeContribution]
|
||||
|
||||
OnSyncContributionCallback* =
|
||||
proc(data: SignedContributionAndProof) {.gcsafe, raises: [Defect].}
|
||||
|
||||
SyncCommitteeMsgPool* = object
|
||||
seenSyncMsgByAuthor*: HashSet[SyncCommitteeMsgKey]
|
||||
seenContributionByAuthor*: HashSet[SyncCommitteeMsgKey]
|
||||
syncMessages*: Table[Eth2Digest, seq[TrustedSyncCommitteeMsg]]
|
||||
bestContributions*: Table[Eth2Digest, BestSyncSubcommitteeContributions]
|
||||
onContributionReceived*: OnSyncContributionCallback
|
||||
|
||||
func hash*(x: SyncCommitteeMsgKey): Hash =
|
||||
hashData(unsafeAddr x, sizeof(x))
|
||||
|
||||
func init*(T: type SyncCommitteeMsgPool,
|
||||
onSyncContribution: OnSyncContributionCallback = nil
|
||||
): SyncCommitteeMsgPool =
|
||||
|
|
|
@ -19,7 +19,7 @@ import
|
|||
blockchain_dag, block_quarantine, attestation_pool, exit_pool,
|
||||
block_pools_types, spec_cache
|
||||
],
|
||||
".."/[beacon_node_types, beacon_clock]
|
||||
".."/[beacon_clock]
|
||||
|
||||
export BrHmacDrbgContext
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import
|
|||
../spec/[forks],
|
||||
../consensus_object_pools/[block_clearance, blockchain_dag, attestation_pool],
|
||||
./consensus_manager,
|
||||
".."/[beacon_clock, beacon_node_types],
|
||||
".."/[beacon_clock],
|
||||
../sszdump
|
||||
|
||||
export sszdump
|
||||
|
|
|
@ -13,12 +13,13 @@ import
|
|||
chronicles, chronos, metrics,
|
||||
../spec/[helpers, forks],
|
||||
../spec/datatypes/[altair, phase0],
|
||||
../consensus_object_pools/[block_clearance, blockchain_dag, exit_pool, attestation_pool],
|
||||
./gossip_validation, ./block_processor,
|
||||
./batch_validation,
|
||||
../consensus_object_pools/[
|
||||
block_clearance, blockchain_dag, exit_pool, attestation_pool,
|
||||
sync_committee_msg_pool],
|
||||
../validators/validator_pool,
|
||||
../beacon_node_types,
|
||||
../beacon_clock
|
||||
../beacon_clock,
|
||||
"."/[gossip_validation, block_processor, batch_validation]
|
||||
|
||||
|
||||
# Metrics for tracking attestation and beacon block loss
|
||||
declareCounter beacon_attestations_received,
|
||||
|
@ -66,7 +67,7 @@ type
|
|||
dag*: ChainDAGRef
|
||||
attestationPool*: ref AttestationPool
|
||||
validatorPool: ref ValidatorPool
|
||||
syncCommitteeMsgPool: SyncCommitteeMsgPoolRef
|
||||
syncCommitteeMsgPool: ref SyncCommitteeMsgPool
|
||||
|
||||
doppelgangerDetection*: DoppelgangerProtection
|
||||
|
||||
|
@ -99,7 +100,7 @@ proc new*(T: type Eth2Processor,
|
|||
attestationPool: ref AttestationPool,
|
||||
exitPool: ref ExitPool,
|
||||
validatorPool: ref ValidatorPool,
|
||||
syncCommitteeMsgPool: SyncCommitteeMsgPoolRef,
|
||||
syncCommitteeMsgPool: ref SyncCommitteeMsgPool,
|
||||
quarantine: QuarantineRef,
|
||||
rng: ref BrHmacDrbgContext,
|
||||
getBeaconTime: GetBeaconTimeFn,
|
||||
|
|
|
@ -20,7 +20,7 @@ import
|
|||
../consensus_object_pools/[
|
||||
attestation_pool, blockchain_dag, block_quarantine, exit_pool, spec_cache,
|
||||
sync_committee_msg_pool],
|
||||
".."/[beacon_node_types, beacon_clock],
|
||||
".."/[beacon_clock],
|
||||
./batch_validation
|
||||
|
||||
from libp2p/protocols/pubsub/pubsub import ValidationResult
|
||||
|
@ -755,7 +755,7 @@ proc validateVoluntaryExit*(
|
|||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/p2p-interface.md#sync_committee_subnet_id
|
||||
proc validateSyncCommitteeMessage*(
|
||||
dag: ChainDAGRef,
|
||||
syncCommitteeMsgPool: SyncCommitteeMsgPoolRef,
|
||||
syncCommitteeMsgPool: ref SyncCommitteeMsgPool,
|
||||
msg: SyncCommitteeMessage,
|
||||
syncCommitteeIdx: SyncCommitteeIndex,
|
||||
wallTime: BeaconTime,
|
||||
|
@ -837,7 +837,7 @@ proc validateSyncCommitteeMessage*(
|
|||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/p2p-interface.md#sync_committee_contribution_and_proof
|
||||
proc validateSignedContributionAndProof*(
|
||||
dag: ChainDAGRef,
|
||||
syncCommitteeMsgPool: SyncCommitteeMsgPoolRef,
|
||||
syncCommitteeMsgPool: ref SyncCommitteeMsgPool,
|
||||
msg: SignedContributionAndProof,
|
||||
wallTime: BeaconTime,
|
||||
checkSignature: bool):
|
||||
|
|
|
@ -24,8 +24,8 @@ import
|
|||
|
||||
# Local modules
|
||||
"."/[
|
||||
beacon_clock, beacon_chain_db, beacon_node_common, beacon_node_status,
|
||||
beacon_node_types, conf, filepath, interop, nimbus_binary_common, statusbar,
|
||||
beacon_clock, beacon_chain_db, beacon_node, beacon_node_status,
|
||||
conf, filepath, interop, nimbus_binary_common, statusbar,
|
||||
version],
|
||||
./networking/[eth2_discovery, eth2_network, network_metadata],
|
||||
./gossip_processing/[eth2_processor, block_processor, consensus_manager],
|
||||
|
|
|
@ -26,6 +26,8 @@ import
|
|||
when defined(posix):
|
||||
import termios
|
||||
|
||||
export beacon_node_status
|
||||
|
||||
type
|
||||
SlotStartProc*[T] = proc(node: T, wallTime: BeaconTime,
|
||||
lastSlot: Slot): Future[void] {.gcsafe,
|
||||
|
|
|
@ -8,9 +8,7 @@
|
|||
{.push raises: [Defect].}
|
||||
|
||||
import std/[os, strutils, tables]
|
||||
import "."/spec/[digest, crypto],
|
||||
"."/validators/keystore_management,
|
||||
"."/beacon_node_types
|
||||
import "."/validators/[keystore_management]
|
||||
|
||||
{.pop.} # TODO moduletests exceptions
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import
|
|||
chronicles,
|
||||
json_serialization, json_serialization/std/[options, net],
|
||||
nimcrypto/utils as ncrutils,
|
||||
../beacon_node_common, ../networking/eth2_network,
|
||||
../beacon_node, ../networking/eth2_network,
|
||||
../consensus_object_pools/[blockchain_dag, exit_pool, spec_cache],
|
||||
../validators/validator_duties,
|
||||
../spec/[eth2_merkleization, forks, network],
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import stew/[endians2, base10], chronicles,
|
||||
nimcrypto/utils as ncrutils
|
||||
import ".."/beacon_node_common,
|
||||
import ".."/beacon_node,
|
||||
".."/eth1/eth1_monitor,
|
||||
".."/spec/forks,
|
||||
"."/rest_utils
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import std/sequtils
|
||||
import chronicles
|
||||
import ".."/[version, beacon_node_common],
|
||||
import ".."/[version, beacon_node],
|
||||
".."/spec/forks,
|
||||
"."/rest_utils
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import
|
|||
stew/results,
|
||||
chronicles,
|
||||
./rest_utils,
|
||||
../beacon_node_common
|
||||
../beacon_node
|
||||
|
||||
logScope: topics = "rest_eventapi"
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import std/[tables, os, sequtils, strutils]
|
|||
import chronos, chronicles, confutils,
|
||||
stew/[base10, results, byteutils, io2], bearssl, blscurve
|
||||
# Local modules
|
||||
import ".."/[conf, version, filepath, beacon_node_types, beacon_node_common]
|
||||
import ".."/[conf, version, filepath, beacon_node]
|
||||
import ".."/spec/[keystore, crypto]
|
||||
import ".."/rpc/rest_utils
|
||||
import ".."/validators/[keystore_management, validator_pool]
|
||||
|
|
|
@ -14,7 +14,7 @@ import
|
|||
../eth1/eth1_monitor,
|
||||
../validators/validator_duties,
|
||||
../spec/forks,
|
||||
../beacon_node_common, ../nimbus_binary_common
|
||||
../beacon_node, ../nimbus_binary_common
|
||||
|
||||
logScope: topics = "rest_nimbusapi"
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import
|
|||
eth/p2p/discoveryv5/enr,
|
||||
libp2p/[multiaddress, multicodec],
|
||||
nimcrypto/utils as ncrutils,
|
||||
../version, ../beacon_node_common, ../sync/sync_manager,
|
||||
../version, ../beacon_node, ../sync/sync_manager,
|
||||
../networking/[eth2_network, peer_pool],
|
||||
../spec/datatypes/base,
|
||||
../spec/eth2_apis/rpc_types,
|
||||
|
|
|
@ -3,7 +3,7 @@ import std/options,
|
|||
nimcrypto/utils as ncrutils,
|
||||
../spec/[forks],
|
||||
../spec/eth2_apis/[rest_types, eth2_rest_serialization],
|
||||
../beacon_node_common,
|
||||
../beacon_node,
|
||||
../consensus_object_pools/[block_pools_types, blockchain_dag]
|
||||
|
||||
export
|
||||
|
|
|
@ -7,7 +7,7 @@ import std/[typetraits, strutils, sets, sequtils]
|
|||
import stew/[results, base10], chronicles, json_serialization,
|
||||
json_serialization/std/[options, net],
|
||||
nimcrypto/utils as ncrutils
|
||||
import ".."/[beacon_chain_db, beacon_node_common],
|
||||
import ".."/[beacon_chain_db, beacon_node],
|
||||
".."/networking/eth2_network,
|
||||
".."/consensus_object_pools/[blockchain_dag, spec_cache,
|
||||
attestation_pool, sync_committee_msg_pool],
|
||||
|
|
|
@ -13,7 +13,7 @@ import
|
|||
json_rpc/servers/httpserver,
|
||||
chronicles,
|
||||
nimcrypto/utils as ncrutils,
|
||||
../beacon_node_common,
|
||||
../beacon_node,
|
||||
../networking/eth2_network,
|
||||
../validators/validator_duties,
|
||||
../consensus_object_pools/blockchain_dag,
|
||||
|
|
|
@ -12,7 +12,7 @@ import
|
|||
json_rpc/servers/httpserver,
|
||||
chronicles,
|
||||
nimcrypto/utils as ncrutils,
|
||||
../beacon_node_common,
|
||||
../beacon_node,
|
||||
../eth1/eth1_monitor,
|
||||
../spec/forks
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import
|
|||
std/sequtils,
|
||||
json_rpc/servers/httpserver,
|
||||
chronicles,
|
||||
../version, ../beacon_node_common,
|
||||
../version, ../beacon_node,
|
||||
../networking/[eth2_network, peer_pool],
|
||||
../spec/datatypes/phase0,
|
||||
./rpc_utils
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
import
|
||||
json_rpc/servers/httpserver,
|
||||
chronicles,
|
||||
../beacon_node_common
|
||||
../beacon_node
|
||||
|
||||
logScope: topics = "eventapi"
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import
|
|||
libp2p/protocols/pubsub/pubsubpeer,
|
||||
|
||||
".."/[
|
||||
beacon_node_common, nimbus_binary_common, networking/eth2_network,
|
||||
beacon_node, nimbus_binary_common, networking/eth2_network,
|
||||
eth1/eth1_monitor, validators/validator_duties],
|
||||
../spec/datatypes/base,
|
||||
../spec/[forks],
|
||||
|
|
|
@ -13,7 +13,7 @@ import std/options,
|
|||
eth/p2p/discoveryv5/enr,
|
||||
libp2p/[multiaddress, multicodec],
|
||||
nimcrypto/utils as ncrutils,
|
||||
../beacon_node_common, ../version,
|
||||
../beacon_node, ../version,
|
||||
../networking/[eth2_network, peer_pool],
|
||||
../sync/sync_manager,
|
||||
../spec/datatypes/base,
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
import
|
||||
std/[strutils, parseutils],
|
||||
stew/byteutils,
|
||||
../beacon_node_common, ../validators/validator_duties,
|
||||
../beacon_node, ../validators/validator_duties,
|
||||
../consensus_object_pools/[block_pools_types, blockchain_dag],
|
||||
../spec/datatypes/base,
|
||||
../spec/[forks, helpers],
|
||||
|
|
|
@ -21,7 +21,7 @@ import
|
|||
../spec/datatypes/phase0,
|
||||
../spec/eth2_apis/rpc_types,
|
||||
../consensus_object_pools/[blockchain_dag, spec_cache, attestation_pool],
|
||||
../beacon_node_common, ../beacon_node_types,
|
||||
../beacon_node,
|
||||
../validators/validator_duties,
|
||||
../networking/eth2_network,
|
||||
./rpc_utils
|
||||
|
|
|
@ -13,7 +13,6 @@ import
|
|||
../spec/datatypes/[phase0, altair],
|
||||
../spec/forks,
|
||||
../networking/eth2_network,
|
||||
../beacon_node_types,
|
||||
../gossip_processing/block_processor,
|
||||
"."/sync_protocol, "."/sync_manager
|
||||
export sync_manager
|
||||
|
|
|
@ -12,7 +12,7 @@ import
|
|||
chronicles, chronos, stew/ranges/bitranges, libp2p/switch,
|
||||
../spec/datatypes/[phase0, altair, merge],
|
||||
../spec/[helpers, forks, network],
|
||||
".."/[beacon_node_types, beacon_clock],
|
||||
".."/[beacon_clock],
|
||||
../networking/eth2_network,
|
||||
../consensus_object_pools/blockchain_dag
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import
|
||||
../spec/eth2_apis/eth2_rest_serialization,
|
||||
../spec/datatypes/[phase0, altair],
|
||||
common
|
||||
|
||||
export eth2_rest_serialization, common
|
||||
|
||||
type
|
||||
ApiResponse*[T] = Result[T, string]
|
||||
ApiOperation = enum
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import std/[tables, os, sequtils, strutils]
|
||||
import std/[tables, os, sets, sequtils, strutils]
|
||||
import chronos, presto, presto/client as presto_client, chronicles, confutils,
|
||||
json_serialization/std/[options, net],
|
||||
stew/[base10, results, byteutils]
|
||||
|
@ -6,22 +6,20 @@ import chronos, presto, presto/client as presto_client, chronicles, confutils,
|
|||
# Local modules
|
||||
import
|
||||
../spec/datatypes/[phase0, altair],
|
||||
../spec/[eth2_merkleization, helpers, signatures, validator],
|
||||
../spec/eth2_apis/rest_beacon_client,
|
||||
../validators/[keystore_management,
|
||||
validator_pool, slashing_protection],
|
||||
".."/[conf, beacon_clock, version, beacon_node_types,
|
||||
nimbus_binary_common]
|
||||
../spec/[eth2_merkleization, helpers, signatures,
|
||||
validator],
|
||||
../spec/eth2_apis/[eth2_rest_serialization, rest_beacon_client],
|
||||
../validators/[keystore_management, validator_pool, slashing_protection],
|
||||
".."/[conf, beacon_clock, version, nimbus_binary_common]
|
||||
|
||||
export os, tables, sequtils, sequtils, chronos, presto, chronicles, confutils,
|
||||
export os, sets, sequtils, sequtils, chronos, presto, chronicles, confutils,
|
||||
nimbus_binary_common, version, conf, options, tables, results, base10,
|
||||
byteutils, presto_client
|
||||
|
||||
export rest_beacon_client,
|
||||
export eth2_rest_serialization, rest_beacon_client,
|
||||
phase0, altair, helpers, signatures, validator, eth2_merkleization,
|
||||
beacon_clock,
|
||||
keystore_management, slashing_protection, validator_pool,
|
||||
beacon_node_types
|
||||
keystore_management, slashing_protection, validator_pool
|
||||
|
||||
const
|
||||
SYNC_TOLERANCE* = 4'u64
|
||||
|
|
|
@ -15,11 +15,12 @@ import
|
|||
".."/spec/datatypes/base,
|
||||
stew/io2, libp2p/crypto/crypto as lcrypto,
|
||||
nimcrypto/utils as ncrutils,
|
||||
".."/[conf, filepath, beacon_node_types],
|
||||
".."/networking/network_metadata
|
||||
".."/[conf, filepath],
|
||||
".."/networking/network_metadata,
|
||||
./validator_pool
|
||||
|
||||
export
|
||||
keystore
|
||||
keystore, validator_pool
|
||||
|
||||
when defined(windows):
|
||||
import stew/[windows/acl]
|
||||
|
|
|
@ -31,7 +31,7 @@ import
|
|||
../networking/eth2_network,
|
||||
../sszdump, ../sync/sync_manager,
|
||||
../gossip_processing/consensus_manager,
|
||||
".."/[conf, beacon_clock, beacon_node_common, beacon_node_types, version],
|
||||
".."/[conf, beacon_clock, beacon_node, version],
|
||||
"."/[slashing_protection, validator_pool, keystore_management]
|
||||
|
||||
# Metrics for tracking attestation and beacon block loss
|
||||
|
|
|
@ -8,17 +8,59 @@
|
|||
{.push raises: [Defect].}
|
||||
|
||||
import
|
||||
std/[tables, json, streams],
|
||||
std/[options, tables, json, streams],
|
||||
chronos, chronicles, metrics,
|
||||
json_serialization/std/[sets, net],
|
||||
../spec/[signatures, helpers],
|
||||
json_serialization/std/net,
|
||||
../spec/[keystore, signatures, helpers],
|
||||
../spec/datatypes/[phase0, altair],
|
||||
../beacon_node_types,
|
||||
./slashing_protection
|
||||
|
||||
export
|
||||
streams, options, keystore, phase0, altair, tables
|
||||
|
||||
declareGauge validators,
|
||||
"Number of validators attached to the beacon node"
|
||||
|
||||
type
|
||||
ValidatorKind* {.pure.} = enum
|
||||
Local, Remote
|
||||
|
||||
ValidatorConnection* = object
|
||||
inStream*: Stream
|
||||
outStream*: Stream
|
||||
pubKeyStr*: string
|
||||
|
||||
ValidatorPrivateItem* = object
|
||||
privateKey*: ValidatorPrivKey
|
||||
description*: Option[string]
|
||||
path*: Option[KeyPath]
|
||||
uuid*: Option[string]
|
||||
version*: Option[uint64]
|
||||
|
||||
AttachedValidator* = ref object
|
||||
pubKey*: ValidatorPubKey
|
||||
case kind*: ValidatorKind
|
||||
of ValidatorKind.Local:
|
||||
data*: ValidatorPrivateItem
|
||||
of ValidatorKind.Remote:
|
||||
connection*: ValidatorConnection
|
||||
|
||||
# The index at which this validator has been observed in the chain -
|
||||
# it does not change as long as there are no reorgs on eth1 - however, the
|
||||
# index might not be valid in all eth2 histories, so it should not be
|
||||
# assumed that a valid index is stored here!
|
||||
index*: Option[ValidatorIndex]
|
||||
|
||||
# Cache the latest slot signature - the slot signature is used to determine
|
||||
# if the validator will be aggregating (in the near future)
|
||||
slotSignature*: Option[tuple[slot: Slot, signature: ValidatorSig]]
|
||||
|
||||
ValidatorPool* = object
|
||||
validators*: Table[ValidatorPubKey, AttachedValidator]
|
||||
slashingProtection*: SlashingProtectionDB
|
||||
|
||||
func shortLog*(v: AttachedValidator): string = shortLog(v.pubKey)
|
||||
|
||||
func init*(T: type ValidatorPool,
|
||||
slashingProtectionDB: SlashingProtectionDB): T =
|
||||
## Initialize the validator pool and the slashing protection service
|
||||
|
|
|
@ -23,7 +23,7 @@ import
|
|||
../beacon_chain/spec/[
|
||||
beaconstate, forks, helpers, signatures, state_transition],
|
||||
../beacon_chain/spec/datatypes/[phase0, altair, merge],
|
||||
../beacon_chain/[beacon_node_types, beacon_chain_db, beacon_clock],
|
||||
../beacon_chain/[beacon_chain_db, beacon_clock],
|
||||
../beacon_chain/eth1/eth1_monitor,
|
||||
../beacon_chain/validators/validator_pool,
|
||||
../beacon_chain/gossip_processing/gossip_validation,
|
||||
|
|
|
@ -15,7 +15,6 @@ import
|
|||
stew/byteutils,
|
||||
eth/keys, taskpools,
|
||||
# Internal
|
||||
../beacon_chain/[beacon_node_types],
|
||||
../beacon_chain/gossip_processing/[gossip_validation],
|
||||
../beacon_chain/fork_choice/[fork_choice_types, fork_choice],
|
||||
../beacon_chain/consensus_object_pools/[
|
||||
|
|
|
@ -15,7 +15,6 @@ import
|
|||
eth/keys, taskpools,
|
||||
../beacon_chain/spec/datatypes/base,
|
||||
../beacon_chain/spec/[beaconstate, forks, helpers, state_transition],
|
||||
../beacon_chain/beacon_node_types,
|
||||
../beacon_chain/[beacon_chain_db],
|
||||
../beacon_chain/consensus_object_pools/[
|
||||
attestation_pool, blockchain_dag, block_quarantine, block_clearance],
|
||||
|
|
|
@ -15,7 +15,7 @@ import
|
|||
chronicles, chronos,
|
||||
eth/keys, taskpools,
|
||||
# Internal
|
||||
../beacon_chain/[beacon_node_types, beacon_clock],
|
||||
../beacon_chain/[beacon_clock],
|
||||
../beacon_chain/gossip_processing/[gossip_validation, batch_validation],
|
||||
../beacon_chain/fork_choice/[fork_choice_types, fork_choice],
|
||||
../beacon_chain/consensus_object_pools/[
|
||||
|
|
|
@ -13,7 +13,7 @@ import
|
|||
./testutil, ./testdbutil, ./teststateutil,
|
||||
../beacon_chain/spec/datatypes/phase0,
|
||||
../beacon_chain/spec/[forks, helpers],
|
||||
../beacon_chain/[beacon_node_types, statediff],
|
||||
../beacon_chain/statediff,
|
||||
../beacon_chain/consensus_object_pools/[blockchain_dag, block_quarantine]
|
||||
|
||||
when isMainModule:
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
|
||||
import
|
||||
unittest2,
|
||||
../beacon_chain/ssz/bitseqs,
|
||||
../beacon_chain/spec/[beaconstate, crypto, digest, helpers, presets, signatures],
|
||||
../beacon_chain/spec/[beaconstate, helpers, signatures],
|
||||
../beacon_chain/consensus_object_pools/sync_committee_msg_pool,
|
||||
testblockutil
|
||||
./testblockutil
|
||||
|
||||
func aggregate(sigs: openarray[CookedSig]): CookedSig =
|
||||
var agg {.noInit.}: AggregateSignature
|
||||
|
|
Loading…
Reference in New Issue