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