2018-11-23 23:58:49 +00:00
|
|
|
import
|
2019-01-14 12:19:44 +00:00
|
|
|
std_shims/[os_shims, objects], net, sequtils, options, tables,
|
2018-11-29 01:08:34 +00:00
|
|
|
asyncdispatch2, chronicles, confutils, eth_p2p, eth_keys,
|
2018-12-28 16:51:40 +00:00
|
|
|
spec/[datatypes, digest, crypto, beaconstate, helpers], conf, time,
|
|
|
|
state_transition, fork_choice, ssz, beacon_chain_db, validator_pool, extras,
|
2019-01-08 17:28:21 +00:00
|
|
|
mainchain_monitor, sync_protocol, gossipsub_protocol, trusted_state_snapshots,
|
2019-01-14 12:19:44 +00:00
|
|
|
eth_trie/db, eth_trie/backends/rocksdb_backend
|
2018-11-23 23:58:49 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
BeaconNode* = ref object
|
|
|
|
beaconState*: BeaconState
|
|
|
|
network*: EthereumNode
|
|
|
|
db*: BeaconChainDB
|
2018-11-29 01:08:34 +00:00
|
|
|
config*: BeaconNodeConf
|
2018-11-23 23:58:49 +00:00
|
|
|
keys*: KeyPair
|
2018-11-26 13:33:06 +00:00
|
|
|
attachedValidators: ValidatorPool
|
2018-12-28 16:51:40 +00:00
|
|
|
attestationPool: AttestationPool
|
2018-11-26 13:33:06 +00:00
|
|
|
mainchainMonitor: MainchainMonitor
|
2019-01-09 01:01:07 +00:00
|
|
|
lastScheduledEpoch: uint64
|
2019-01-05 21:01:26 +00:00
|
|
|
headBlock: BeaconBlock
|
|
|
|
headBlockRoot: Eth2Digest
|
2019-01-08 17:28:21 +00:00
|
|
|
blocksChildren: Table[Eth2Digest, seq[Eth2Digest]]
|
2018-11-23 23:58:49 +00:00
|
|
|
|
|
|
|
const
|
2018-11-29 01:08:34 +00:00
|
|
|
version = "v0.1" # TODO: read this from the nimble file
|
2018-11-23 23:58:49 +00:00
|
|
|
clientId = "nimbus beacon node " & version
|
2018-11-26 13:33:06 +00:00
|
|
|
|
|
|
|
topicBeaconBlocks = "ethereum/2.1/beacon_chain/blocks"
|
|
|
|
topicAttestations = "ethereum/2.1/beacon_chain/attestations"
|
2018-11-23 23:58:49 +00:00
|
|
|
|
2019-01-05 21:01:26 +00:00
|
|
|
func shortHash(x: auto): string = ($x)[0..7]
|
|
|
|
|
2018-11-23 23:58:49 +00:00
|
|
|
proc ensureNetworkKeys*(dataDir: string): KeyPair =
|
|
|
|
# TODO:
|
|
|
|
# 1. Check if keys already exist in the data dir
|
|
|
|
# 2. Generate new ones and save them in the directory
|
|
|
|
# if necessary
|
|
|
|
return newKeyPair()
|
|
|
|
|
2018-11-29 01:08:34 +00:00
|
|
|
proc init*(T: type BeaconNode, conf: BeaconNodeConf): T =
|
2018-11-23 23:58:49 +00:00
|
|
|
new result
|
|
|
|
result.config = conf
|
2018-12-19 12:58:53 +00:00
|
|
|
|
2018-12-28 16:51:40 +00:00
|
|
|
result.attachedValidators = ValidatorPool.init
|
|
|
|
init result.attestationPool, 0
|
|
|
|
init result.mainchainMonitor, "", Port(0) # TODO: specify geth address and port
|
|
|
|
|
2019-01-14 12:19:44 +00:00
|
|
|
let trieDB = trieDB newChainDb(string conf.dataDir)
|
|
|
|
result.db = BeaconChainDB.init(trieDB)
|
2018-11-29 01:08:34 +00:00
|
|
|
result.keys = ensureNetworkKeys(string conf.dataDir)
|
2018-11-23 23:58:49 +00:00
|
|
|
|
|
|
|
var address: Address
|
2018-12-28 16:51:40 +00:00
|
|
|
address.ip = parseIpAddress("127.0.0.1")
|
2018-11-23 23:58:49 +00:00
|
|
|
address.tcpPort = Port(conf.tcpPort)
|
|
|
|
address.udpPort = Port(conf.udpPort)
|
2018-12-19 12:58:53 +00:00
|
|
|
|
2018-12-28 16:51:40 +00:00
|
|
|
result.network = newEthereumNode(result.keys, address, 0, nil, clientId, minPeers = 1)
|
2018-11-23 23:58:49 +00:00
|
|
|
|
2018-12-19 12:58:53 +00:00
|
|
|
writeFile(string(conf.dataDir) / "beacon_node.address",
|
|
|
|
$result.network.listeningAddress)
|
|
|
|
|
|
|
|
proc connectToNetwork(node: BeaconNode) {.async.} =
|
|
|
|
var bootstrapNodes = newSeq[ENode]()
|
|
|
|
|
|
|
|
for node in node.config.bootstrapNodes:
|
|
|
|
bootstrapNodes.add initENode(node)
|
|
|
|
|
|
|
|
let bootstrapFile = string node.config.bootstrapNodesFile
|
|
|
|
if bootstrapFile.len > 0:
|
|
|
|
for ln in lines(bootstrapFile):
|
|
|
|
bootstrapNodes.add initENode(string ln)
|
|
|
|
|
|
|
|
if bootstrapNodes.len > 0:
|
2018-12-28 16:51:40 +00:00
|
|
|
info "Connecting to bootstrap nodes", bootstrapNodes
|
2018-12-19 12:58:53 +00:00
|
|
|
await node.network.connectToNetwork(bootstrapNodes)
|
|
|
|
else:
|
2018-12-28 16:51:40 +00:00
|
|
|
info "Waiting for connections"
|
2018-12-19 12:58:53 +00:00
|
|
|
node.network.startListening()
|
|
|
|
|
2018-11-23 23:58:49 +00:00
|
|
|
proc sync*(node: BeaconNode): Future[bool] {.async.} =
|
|
|
|
let persistedState = node.db.lastFinalizedState()
|
|
|
|
if persistedState.isNil or
|
2019-01-09 01:01:07 +00:00
|
|
|
persistedState[].slotDistanceFromNow() > WEAK_SUBJECTVITY_PERIOD.int64:
|
2018-12-19 12:58:53 +00:00
|
|
|
if node.config.stateSnapshot.isSome:
|
|
|
|
node.beaconState = node.config.stateSnapshot.get
|
|
|
|
else:
|
|
|
|
node.beaconState = await obtainTrustedStateSnapshot(node.db)
|
2018-11-23 23:58:49 +00:00
|
|
|
else:
|
|
|
|
node.beaconState = persistedState[]
|
|
|
|
var targetSlot = toSlot timeSinceGenesis(node.beaconState)
|
|
|
|
|
2019-01-09 01:01:07 +00:00
|
|
|
while node.beaconState.finalized_slot < targetSlot:
|
2018-11-29 01:08:34 +00:00
|
|
|
var (peer, changeLog) = await node.network.getValidatorChangeLog(
|
2018-12-03 21:41:24 +00:00
|
|
|
node.beaconState.validator_registry_delta_chain_tip)
|
2018-11-23 23:58:49 +00:00
|
|
|
|
|
|
|
if peer == nil:
|
|
|
|
error "Failed to sync with any peer"
|
|
|
|
return false
|
|
|
|
|
|
|
|
if applyValidatorChangeLog(changeLog, node.beaconState):
|
2018-11-29 01:08:34 +00:00
|
|
|
node.db.persistBlock(node.beaconState, changeLog.signedBlock)
|
2018-11-23 23:58:49 +00:00
|
|
|
else:
|
|
|
|
warn "Ignoring invalid validator change log", sentFrom = peer
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
2018-12-05 13:58:41 +00:00
|
|
|
template findIt(s: openarray, predicate: untyped): int =
|
|
|
|
var res = -1
|
|
|
|
for i, it {.inject.} in s:
|
|
|
|
if predicate:
|
|
|
|
res = i
|
|
|
|
break
|
|
|
|
res
|
|
|
|
|
2018-12-28 16:51:40 +00:00
|
|
|
template isSameKey(lhs, rhs: ValidatorPubKey): bool =
|
|
|
|
# TODO: operator `==` for ValidatorPubKey doesn't work properly at the moment
|
|
|
|
$lhs == $rhs
|
|
|
|
|
2018-11-23 23:58:49 +00:00
|
|
|
proc addLocalValidators*(node: BeaconNode) =
|
2018-12-19 12:58:53 +00:00
|
|
|
for validator in node.config.validators:
|
|
|
|
let
|
|
|
|
privKey = validator.privKey
|
|
|
|
pubKey = privKey.pubKey()
|
|
|
|
randao = validator.randao
|
|
|
|
|
2018-12-28 16:51:40 +00:00
|
|
|
let idx = node.beaconState.validator_registry.findIt(isSameKey(it.pubKey, pubKey))
|
2018-12-05 13:58:41 +00:00
|
|
|
if idx == -1:
|
|
|
|
warn "Validator not in registry", pubKey
|
|
|
|
else:
|
2018-12-08 14:17:47 +00:00
|
|
|
node.attachedValidators.addLocalValidator(idx, pubKey, privKey, randao)
|
2018-12-05 13:58:41 +00:00
|
|
|
|
2018-12-28 16:51:40 +00:00
|
|
|
info "Local validators attached ", count = node.attachedValidators.count
|
2018-11-23 23:58:49 +00:00
|
|
|
|
2018-11-26 13:33:06 +00:00
|
|
|
proc getAttachedValidator(node: BeaconNode, idx: int): AttachedValidator =
|
2018-12-03 21:41:24 +00:00
|
|
|
let validatorKey = node.beaconState.validator_registry[idx].pubkey
|
2018-11-26 13:33:06 +00:00
|
|
|
return node.attachedValidators.getValidator(validatorKey)
|
|
|
|
|
2018-11-29 01:08:34 +00:00
|
|
|
proc makeAttestation(node: BeaconNode,
|
2018-12-28 16:51:40 +00:00
|
|
|
validator: AttachedValidator,
|
|
|
|
slot: uint64,
|
|
|
|
shard: uint64,
|
|
|
|
committeeLen: int,
|
|
|
|
indexInCommittee: int) {.async.} =
|
|
|
|
doAssert node != nil
|
|
|
|
doAssert validator != nil
|
|
|
|
|
2019-01-05 21:01:26 +00:00
|
|
|
let justifiedBlockRoot = get_block_root(node.beaconState, node.beaconState.justified_slot)
|
2018-12-28 16:51:40 +00:00
|
|
|
|
|
|
|
var attestationData = AttestationData(
|
|
|
|
slot: slot,
|
|
|
|
shard: shard,
|
2019-01-05 21:01:26 +00:00
|
|
|
beacon_block_root: node.headBlockRoot,
|
2018-12-28 16:51:40 +00:00
|
|
|
epoch_boundary_root: Eth2Digest(), # TODO
|
|
|
|
shard_block_root: Eth2Digest(), # TODO
|
|
|
|
latest_crosslink_root: Eth2Digest(), # TODO
|
|
|
|
justified_slot: node.beaconState.justified_slot,
|
|
|
|
justified_block_root: justifiedBlockRoot)
|
|
|
|
|
|
|
|
let validatorSignature = await validator.signAttestation(attestationData)
|
|
|
|
|
|
|
|
var participationBitfield = repeat(0'u8, ceil_div8(committeeLen))
|
|
|
|
bitSet(participationBitfield, indexInCommittee)
|
|
|
|
|
|
|
|
var attestation = Attestation(
|
|
|
|
data: attestationData,
|
|
|
|
aggregate_signature: validatorSignature,
|
|
|
|
participation_bitfield: participationBitfield)
|
2018-11-26 13:33:06 +00:00
|
|
|
|
2018-11-29 01:08:34 +00:00
|
|
|
await node.network.broadcast(topicAttestations, attestation)
|
2018-11-26 13:33:06 +00:00
|
|
|
|
2018-12-28 16:51:40 +00:00
|
|
|
info "Attestation sent", slot = slot,
|
|
|
|
shard = shard,
|
2019-01-05 21:01:26 +00:00
|
|
|
validator = validator.idx,
|
|
|
|
signature = shortHash(validatorSignature)
|
2018-12-28 16:51:40 +00:00
|
|
|
|
2018-11-29 01:08:34 +00:00
|
|
|
proc proposeBlock(node: BeaconNode,
|
|
|
|
validator: AttachedValidator,
|
2018-12-28 16:51:40 +00:00
|
|
|
slot: uint64) {.async.} =
|
|
|
|
doAssert node != nil
|
|
|
|
doAssert validator != nil
|
|
|
|
doAssert validator.idx < node.beaconState.validator_registry.len
|
|
|
|
|
2019-01-05 21:01:26 +00:00
|
|
|
var state = node.beaconState
|
|
|
|
|
|
|
|
for s in node.beaconState.slot + 1 ..< slot:
|
|
|
|
info "Skipping block", slot = s
|
|
|
|
let ok = updateState(state, node.headBlockRoot, none[BeaconBlock](), {})
|
|
|
|
doAssert ok
|
|
|
|
|
2018-12-28 16:51:40 +00:00
|
|
|
let
|
|
|
|
randaoCommitment = node.beaconState.validator_registry[validator.idx].randao_commitment
|
|
|
|
randaoReveal = await validator.randaoReveal(randaoCommitment)
|
|
|
|
|
|
|
|
var blockBody = BeaconBlockBody(
|
|
|
|
attestations: node.attestationPool.getAttestationsForBlock(node.beaconState, slot))
|
|
|
|
|
|
|
|
var newBlock = BeaconBlock(
|
|
|
|
slot: slot,
|
2019-01-05 21:01:26 +00:00
|
|
|
parent_root: node.headBlockRoot,
|
2018-12-28 16:51:40 +00:00
|
|
|
randao_reveal: randaoReveal,
|
2019-01-16 10:21:06 +00:00
|
|
|
deposit_root: node.mainchainMonitor.getBeaconBlockRef(),
|
2018-12-28 16:51:40 +00:00
|
|
|
signature: ValidatorSig(), # we need the rest of the block first!
|
|
|
|
body: blockBody)
|
|
|
|
|
2019-01-05 21:01:26 +00:00
|
|
|
let ok = updateState(state, node.headBlockRoot, some(newBlock), {skipValidation})
|
2018-12-28 16:51:40 +00:00
|
|
|
doAssert ok # TODO: err, could this fail somehow?
|
2018-11-26 13:33:06 +00:00
|
|
|
|
2018-12-28 16:51:40 +00:00
|
|
|
newBlock.state_root = Eth2Digest(data: hash_tree_root(state))
|
2018-11-26 13:33:06 +00:00
|
|
|
|
2018-12-28 16:51:40 +00:00
|
|
|
var signedData = ProposalSignedData(
|
|
|
|
slot: slot,
|
|
|
|
shard: BEACON_CHAIN_SHARD_NUMBER,
|
|
|
|
blockRoot: hash_tree_root_final(newBlock))
|
2018-11-26 13:33:06 +00:00
|
|
|
|
2018-12-28 16:51:40 +00:00
|
|
|
newBlock.signature = await validator.signBlockProposal(signedData)
|
2018-11-26 13:33:06 +00:00
|
|
|
|
2018-12-28 16:51:40 +00:00
|
|
|
await node.network.broadcast(topicBeaconBlocks, newBlock)
|
2018-11-26 13:33:06 +00:00
|
|
|
|
2018-12-28 16:51:40 +00:00
|
|
|
info "Block proposed", slot = slot,
|
2019-01-05 21:01:26 +00:00
|
|
|
stateRoot = shortHash(newBlock.state_root),
|
2018-12-28 16:51:40 +00:00
|
|
|
validator = validator.idx
|
2018-11-26 13:33:06 +00:00
|
|
|
|
2018-12-28 16:51:40 +00:00
|
|
|
proc scheduleBlockProposal(node: BeaconNode,
|
2019-01-09 01:01:07 +00:00
|
|
|
slot: uint64,
|
2018-12-28 16:51:40 +00:00
|
|
|
validator: AttachedValidator) =
|
|
|
|
# TODO:
|
|
|
|
# This function exists only to hide a bug with Nim's closures.
|
2019-01-09 01:01:07 +00:00
|
|
|
# If you inline it in `scheduleEpochActions`, you'll see the
|
2018-12-28 16:51:40 +00:00
|
|
|
# internal `doAssert` starting to fail.
|
|
|
|
doAssert validator != nil
|
|
|
|
|
|
|
|
addTimer(node.beaconState.slotStart(slot)) do (p: pointer):
|
|
|
|
doAssert validator != nil
|
|
|
|
asyncCheck proposeBlock(node, validator, slot.uint64)
|
|
|
|
|
|
|
|
proc scheduleAttestation(node: BeaconNode,
|
|
|
|
validator: AttachedValidator,
|
2019-01-09 01:01:07 +00:00
|
|
|
slot: uint64,
|
2018-12-28 16:51:40 +00:00
|
|
|
shard: uint64,
|
|
|
|
committeeLen: int,
|
|
|
|
indexInCommittee: int) =
|
|
|
|
# TODO:
|
|
|
|
# This function exists only to hide a bug with Nim's closures.
|
2019-01-09 01:01:07 +00:00
|
|
|
# If you inline it in `scheduleEpochActions`, you'll see the
|
2018-12-28 16:51:40 +00:00
|
|
|
# internal `doAssert` starting to fail.
|
|
|
|
doAssert validator != nil
|
|
|
|
|
|
|
|
addTimer(node.beaconState.slotMiddle(slot)) do (p: pointer):
|
|
|
|
doAssert validator != nil
|
|
|
|
asyncCheck makeAttestation(node, validator, slot.uint64,
|
|
|
|
shard, committeeLen, indexInCommittee)
|
2018-11-26 13:33:06 +00:00
|
|
|
|
2019-01-09 01:01:07 +00:00
|
|
|
proc scheduleEpochActions(node: BeaconNode, epoch: uint64) =
|
2018-11-23 23:58:49 +00:00
|
|
|
## This schedules the required block proposals and
|
|
|
|
## attestations from our attached validators.
|
2018-12-28 16:51:40 +00:00
|
|
|
doAssert node != nil
|
|
|
|
|
|
|
|
# TODO: this copy of the state shouldn't be necessary, but please
|
|
|
|
# see the comments in `get_beacon_proposer_index`
|
|
|
|
var nextState = node.beaconState
|
2018-11-23 23:58:49 +00:00
|
|
|
|
2019-01-09 01:01:07 +00:00
|
|
|
for i in 1.uint64 ..< EPOCH_LENGTH:
|
2018-11-26 13:33:06 +00:00
|
|
|
# Schedule block proposals
|
2019-01-09 01:01:07 +00:00
|
|
|
let slot = epoch * EPOCH_LENGTH + i
|
|
|
|
nextState.slot = slot
|
|
|
|
let proposerIdx = get_beacon_proposer_index(nextState, slot)
|
|
|
|
let validator = node.getAttachedValidator(proposerIdx)
|
2018-11-23 23:58:49 +00:00
|
|
|
|
2018-12-28 16:51:40 +00:00
|
|
|
if validator != nil:
|
2018-11-23 23:58:49 +00:00
|
|
|
# TODO:
|
|
|
|
# Warm-up the proposer earlier to try to obtain previous
|
|
|
|
# missing blocks if necessary
|
2018-12-28 16:51:40 +00:00
|
|
|
scheduleBlockProposal(node, slot, validator)
|
2018-11-23 23:58:49 +00:00
|
|
|
|
2018-11-26 13:33:06 +00:00
|
|
|
# Schedule attestations
|
|
|
|
let
|
2019-01-09 01:01:07 +00:00
|
|
|
committeesIdx = get_shard_committees_index(nextState, slot)
|
2018-11-26 13:33:06 +00:00
|
|
|
|
2018-12-06 02:07:04 +00:00
|
|
|
for shard in node.beaconState.shard_committees_at_slots[committees_idx]:
|
2018-12-28 16:51:40 +00:00
|
|
|
for i, validatorIdx in shard.committee:
|
|
|
|
let validator = node.getAttachedValidator(validatorIdx)
|
|
|
|
if validator != nil:
|
|
|
|
scheduleAttestation(node, validator, slot, shard.shard, shard.committee.len, i)
|
|
|
|
|
2019-01-09 01:01:07 +00:00
|
|
|
node.lastScheduledEpoch = epoch
|
|
|
|
let nextEpoch = epoch + 1
|
2018-11-23 23:58:49 +00:00
|
|
|
|
2019-01-09 01:01:07 +00:00
|
|
|
addTimer(node.beaconState.slotMiddle(nextEpoch * EPOCH_LENGTH)) do (p: pointer):
|
|
|
|
if node.lastScheduledEpoch != nextEpoch:
|
|
|
|
node.scheduleEpochActions(nextEpoch)
|
2018-11-23 23:58:49 +00:00
|
|
|
|
2018-12-28 16:51:40 +00:00
|
|
|
proc processBlocks*(node: BeaconNode) =
|
2019-01-05 21:01:26 +00:00
|
|
|
node.network.subscribe(topicBeaconBlocks) do (newBlock: BeaconBlock):
|
|
|
|
info "Block received", slot = newBlock.slot,
|
|
|
|
stateRoot = shortHash(newBlock.state_root)
|
|
|
|
|
|
|
|
let newBlockRoot = hash_tree_root_final(newBlock)
|
|
|
|
|
|
|
|
for slot in node.beaconState.slot + 1 ..< newBlock.slot:
|
|
|
|
info "Skipping block", slot
|
|
|
|
let ok = updateState(node.beaconState, node.headBlockRoot, none[BeaconBlock](), {})
|
|
|
|
|
|
|
|
let ok = updateState(node.beaconState, node.headBlockRoot, some(newBlock), {})
|
|
|
|
doAssert ok
|
|
|
|
|
|
|
|
node.headBlock = newBlock
|
|
|
|
node.headBlockRoot = newBlockRoot
|
2018-12-28 16:51:40 +00:00
|
|
|
|
2018-11-23 23:58:49 +00:00
|
|
|
# TODO:
|
|
|
|
#
|
|
|
|
# 1. Check for missing blocks and obtain them
|
2018-11-26 13:33:06 +00:00
|
|
|
#
|
|
|
|
# 2. Apply fork-choice rule (update node.headBlock)
|
|
|
|
#
|
|
|
|
# 3. Peform block processing / state recalculation / etc
|
|
|
|
#
|
2018-11-23 23:58:49 +00:00
|
|
|
|
2019-01-09 01:01:07 +00:00
|
|
|
let epoch = newBlock.slot.epoch
|
|
|
|
if epoch != node.lastScheduledEpoch:
|
|
|
|
node.scheduleEpochActions(epoch)
|
2018-11-26 13:33:06 +00:00
|
|
|
|
|
|
|
node.network.subscribe(topicAttestations) do (a: Attestation):
|
2018-12-28 16:51:40 +00:00
|
|
|
info "Attestation received", slot = a.data.slot,
|
2019-01-05 21:01:26 +00:00
|
|
|
shard = a.data.shard,
|
|
|
|
signature = shortHash(a.aggregate_signature)
|
2018-12-28 16:51:40 +00:00
|
|
|
|
|
|
|
node.attestationPool.add(a, node.beaconState)
|
|
|
|
|
2019-01-05 21:01:26 +00:00
|
|
|
dynamicLogScope(node = node.config.tcpPort - 50000):
|
2019-01-09 01:01:07 +00:00
|
|
|
let epoch = node.beaconState.slot.epoch
|
|
|
|
node.scheduleEpochActions(epoch)
|
2018-12-28 16:51:40 +00:00
|
|
|
|
2019-01-05 21:01:26 +00:00
|
|
|
runForever()
|
2018-11-23 23:58:49 +00:00
|
|
|
|
2018-12-19 12:58:53 +00:00
|
|
|
var gPidFile: string
|
|
|
|
proc createPidFile(filename: string) =
|
|
|
|
createDir splitFile(filename).dir
|
|
|
|
writeFile filename, $getCurrentProcessId()
|
|
|
|
gPidFile = filename
|
|
|
|
addQuitProc proc {.noconv.} = removeFile gPidFile
|
|
|
|
|
2018-11-23 23:58:49 +00:00
|
|
|
when isMainModule:
|
2018-12-28 16:51:40 +00:00
|
|
|
let config = load BeaconNodeConf
|
2018-12-19 12:58:53 +00:00
|
|
|
case config.cmd
|
|
|
|
of createChain:
|
2018-12-28 16:51:40 +00:00
|
|
|
createStateSnapshot(config.chainStartupData, config.outputStateFile.string)
|
2018-12-19 12:58:53 +00:00
|
|
|
quit 0
|
|
|
|
|
|
|
|
of noCommand:
|
|
|
|
waitFor syncrhronizeClock()
|
2018-12-28 16:51:40 +00:00
|
|
|
createPidFile(config.dataDir.string / "beacon_node.pid")
|
2018-12-19 12:58:53 +00:00
|
|
|
|
|
|
|
var node = BeaconNode.init config
|
|
|
|
waitFor node.connectToNetwork()
|
|
|
|
|
|
|
|
if not waitFor node.sync():
|
|
|
|
quit 1
|
|
|
|
|
|
|
|
node.addLocalValidators()
|
2018-12-28 16:51:40 +00:00
|
|
|
node.processBlocks()
|
2018-11-23 23:58:49 +00:00
|
|
|
|