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.
|
|
|
|
|
2021-10-19 16:09:26 +02:00
|
|
|
# Everything needed to run a full Beacon Node
|
2020-05-06 15:23:45 +02:00
|
|
|
|
|
|
|
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-10-19 16:09:26 +02:00
|
|
|
"."/[beacon_clock, beacon_chain_db, conf],
|
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-10-18 18:37:27 +02:00
|
|
|
./consensus_object_pools/[
|
2021-10-19 16:09:26 +02:00
|
|
|
blockchain_dag, block_quarantine, exit_pool, attestation_pool,
|
|
|
|
sync_committee_msg_pool],
|
2021-06-21 08:35:24 +00:00
|
|
|
./spec/datatypes/base,
|
2021-10-18 11:11:44 +02:00
|
|
|
./sync/[sync_manager, request_manager],
|
2022-01-05 16:49:10 +02:00
|
|
|
./validators/[action_tracker, validator_monitor, validator_pool],
|
|
|
|
./rpc/state_ttl_cache
|
2020-05-06 15:23:45 +02:00
|
|
|
|
2020-10-28 08:55:36 +01:00
|
|
|
export
|
2021-10-18 11:11:44 +02:00
|
|
|
osproc, chronos, httpserver, presto, action_tracker, beacon_clock,
|
2021-10-19 16:09:26 +02:00
|
|
|
beacon_chain_db, conf, attestation_pool, sync_committee_msg_pool,
|
|
|
|
validator_pool, eth2_network, eth1_monitor, request_manager, sync_manager,
|
2021-12-20 20:20:31 +01:00
|
|
|
eth2_processor, blockchain_dag, block_quarantine, base, exit_pool,
|
2022-02-11 21:40:49 +01:00
|
|
|
validator_monitor, consensus_manager
|
2020-05-22 20:04:52 +03:00
|
|
|
|
2020-05-06 15:23:45 +02:00
|
|
|
type
|
|
|
|
RpcServer* = RpcHttpServer
|
|
|
|
|
|
|
|
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
|
2021-12-06 10:49:01 +01:00
|
|
|
quarantine*: ref Quarantine
|
2020-08-20 18:30:47 +02:00
|
|
|
attestationPool*: ref AttestationPool
|
2021-08-28 22:27:51 +00:00
|
|
|
syncCommitteeMsgPool*: ref SyncCommitteeMsgPool
|
2022-05-23 14:02:54 +02:00
|
|
|
lightClientPool*: ref LightClientPool
|
2020-09-14 14:26:31 +00:00
|
|
|
exitPool*: ref ExitPool
|
2020-11-03 03:21:07 +02:00
|
|
|
eth1Monitor*: Eth1Monitor
|
2021-03-17 20:46:45 +02:00
|
|
|
restServer*: RestServerRef
|
2021-12-22 14:37:31 +02:00
|
|
|
keymanagerServer*: RestServerRef
|
|
|
|
keymanagerToken*: Option[string]
|
2021-09-22 15:17:15 +03:00
|
|
|
eventBus*: AsyncEventBus
|
2020-09-01 16:44:40 +03:00
|
|
|
vcProcess*: Process
|
2020-08-12 12:29:11 +03:00
|
|
|
requestManager*: RequestManager
|
2022-04-08 18:22:49 +02:00
|
|
|
syncManager*: SyncManager[Peer, PeerId]
|
|
|
|
backfiller*: SyncManager[Peer, PeerId]
|
2020-07-02 18:14:11 +03:00
|
|
|
genesisSnapshotContent*: string
|
2021-10-18 11:11:44 +02:00
|
|
|
actionTracker*: ActionTracker
|
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
|
2021-10-14 13:38:38 +03:00
|
|
|
restKeysCache*: Table[ValidatorPubKey, ValidatorIndex]
|
2021-12-20 20:20:31 +01:00
|
|
|
validatorMonitor*: ref ValidatorMonitor
|
2022-01-05 16:49:10 +02:00
|
|
|
stateTtlCache*: StateTtlCache
|
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
|