2020-05-06 15:23:45 +02:00
|
|
|
# beacon_chain
|
2021-05-20 10:44:13 +00:00
|
|
|
# Copyright (c) 2018-2021 Status Research & Development GmbH
|
2020-05-06 15:23:45 +02: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.
|
|
|
|
|
|
|
|
# Common routines for a BeaconNode and a BeaconValidator node
|
|
|
|
|
|
|
|
import
|
2020-10-28 08:55:36 +01:00
|
|
|
std/osproc,
|
2020-05-22 20:04:52 +03:00
|
|
|
|
2020-05-06 15:23:45 +02:00
|
|
|
# Nimble packages
|
2021-03-26 19:57:02 +02:00
|
|
|
chronos, json_rpc/servers/httpserver, presto,
|
2020-05-06 15:23:45 +02:00
|
|
|
|
|
|
|
# Local modules
|
2021-03-05 14:12:00 +01:00
|
|
|
./conf, ./beacon_clock, ./beacon_chain_db,
|
2021-03-03 07:23:05 +01:00
|
|
|
./beacon_node_types,
|
2021-05-28 18:34:00 +02:00
|
|
|
./gossip_processing/[eth2_processor, block_processor, consensus_manager],
|
2021-03-05 14:12:00 +01:00
|
|
|
./networking/eth2_network,
|
2021-03-03 07:23:05 +01:00
|
|
|
./eth1/eth1_monitor,
|
2021-03-04 10:13:44 +01:00
|
|
|
./consensus_object_pools/[blockchain_dag, block_quarantine, attestation_pool],
|
2021-06-21 08:35:24 +00:00
|
|
|
./spec/datatypes/base,
|
2021-03-02 11:27:45 +01:00
|
|
|
./sync/[sync_manager, request_manager]
|
2020-05-06 15:23:45 +02:00
|
|
|
|
2020-10-28 08:55:36 +01:00
|
|
|
export
|
2021-08-03 17:17:11 +02:00
|
|
|
osproc, chronos, httpserver, presto, conf, beacon_clock, beacon_chain_db,
|
2020-11-03 21:02:43 +02:00
|
|
|
attestation_pool, eth2_network, beacon_node_types, eth1_monitor,
|
2021-03-04 10:13:44 +01:00
|
|
|
request_manager, sync_manager, eth2_processor, blockchain_dag, block_quarantine,
|
2021-06-21 08:35:24 +00:00
|
|
|
base
|
2020-05-22 20:04:52 +03:00
|
|
|
|
2020-05-06 15:23:45 +02:00
|
|
|
type
|
|
|
|
RpcServer* = RpcHttpServer
|
|
|
|
|
2021-08-09 12:54:45 +00:00
|
|
|
GossipState* = enum
|
|
|
|
Disconnected
|
|
|
|
ConnectedToPhase0
|
|
|
|
InTransitionToAltair
|
|
|
|
ConnectedToAltair
|
|
|
|
|
2020-05-06 15:23:45 +02:00
|
|
|
BeaconNode* = ref object
|
|
|
|
nickname*: string
|
2020-06-29 20:30:19 +03:00
|
|
|
graffitiBytes*: GraffitiBytes
|
2020-05-06 15:23:45 +02:00
|
|
|
network*: Eth2Node
|
2021-03-19 04:22:45 +02:00
|
|
|
netKeys*: NetKeyPair
|
2020-05-06 15:23:45 +02:00
|
|
|
db*: BeaconChainDB
|
|
|
|
config*: BeaconNodeConf
|
2021-02-22 17:17:48 +01:00
|
|
|
attachedValidators*: ref ValidatorPool
|
2021-06-01 13:13:40 +02:00
|
|
|
dag*: ChainDAGRef
|
2020-07-31 17:49:06 +03:00
|
|
|
quarantine*: QuarantineRef
|
2020-08-20 18:30:47 +02:00
|
|
|
attestationPool*: ref AttestationPool
|
2021-08-28 22:27:51 +00:00
|
|
|
syncCommitteeMsgPool*: ref SyncCommitteeMsgPool
|
2020-09-14 14:26:31 +00:00
|
|
|
exitPool*: ref ExitPool
|
2020-11-03 03:21:07 +02:00
|
|
|
eth1Monitor*: Eth1Monitor
|
2020-05-06 15:23:45 +02:00
|
|
|
rpcServer*: RpcServer
|
2021-03-17 20:46:45 +02:00
|
|
|
restServer*: RestServerRef
|
2020-09-01 16:44:40 +03:00
|
|
|
vcProcess*: Process
|
2020-08-12 12:29:11 +03:00
|
|
|
requestManager*: RequestManager
|
2020-06-03 11:46:29 +03:00
|
|
|
syncManager*: SyncManager[Peer, PeerID]
|
2020-07-02 18:14:11 +03:00
|
|
|
genesisSnapshotContent*: string
|
2020-08-12 17:48:31 +00:00
|
|
|
attestationSubnets*: AttestationSubnets
|
2020-08-20 18:30:47 +02:00
|
|
|
processor*: ref Eth2Processor
|
2021-05-28 18:34:00 +02:00
|
|
|
blockProcessor*: ref BlockProcessor
|
2021-03-11 11:10:57 +01:00
|
|
|
consensusManager*: ref ConsensusManager
|
2020-11-29 23:35:39 +02:00
|
|
|
attachedValidatorBalanceTotal*: uint64
|
2021-08-09 12:54:45 +00:00
|
|
|
gossipState*: GossipState
|
2021-08-20 08:58:15 +00:00
|
|
|
beaconClock*: BeaconClock
|
2020-05-06 15:23:45 +02:00
|
|
|
|
2020-05-22 20:04:52 +03:00
|
|
|
const
|
|
|
|
MaxEmptySlotCount* = uint64(10*60) div SECONDS_PER_SLOT
|
2020-05-06 15:23:45 +02:00
|
|
|
|
2020-09-07 15:04:33 +00:00
|
|
|
# TODO stew/sequtils2
|
2020-10-28 20:35:31 +02:00
|
|
|
template findIt*(s: openArray, predicate: untyped): int =
|
2020-05-27 20:06:28 +03:00
|
|
|
var res = -1
|
|
|
|
for i, it {.inject.} in s:
|
|
|
|
if predicate:
|
|
|
|
res = i
|
|
|
|
break
|
|
|
|
res
|
2020-10-27 10:00:57 +01:00
|
|
|
|
|
|
|
proc currentSlot*(node: BeaconNode): Slot =
|
|
|
|
node.beaconClock.now.slotOrZero
|