Fix #1241.
This commit is contained in:
parent
3dfbc311ad
commit
6052f36fcd
|
@ -263,27 +263,7 @@ proc init*(T: type BeaconNode,
|
|||
|
||||
# This merely configures the BeaconSync
|
||||
# The traffic will be started when we join the network.
|
||||
network.initBeaconSync(blockPool, enrForkId.forkDigest,
|
||||
proc(signedBlock: SignedBeaconBlock) =
|
||||
if signedBlock.message.slot.isEpoch:
|
||||
# TODO this is a hack to make sure that lmd ghost is run regularly
|
||||
# while syncing blocks - it's poor form to keep it here though -
|
||||
# the logic should be moved elsewhere
|
||||
# TODO why only when syncing? well, because the way the code is written
|
||||
# we require a connection to a boot node to start, and that boot
|
||||
# node will start syncing as part of connection setup - it looks
|
||||
# like it needs to finish syncing before the slot timer starts
|
||||
# ticking which is a problem: all the synced blocks will be added
|
||||
# to the block pool without any periodic head updates while this
|
||||
# process is ongoing (during a blank start for example), which
|
||||
# leads to an unhealthy buildup of blocks in the non-finalized part
|
||||
# of the block pool
|
||||
# TODO is it a problem that someone sending us a block can force
|
||||
# a potentially expensive head resolution?
|
||||
discard res.updateHead()
|
||||
|
||||
onBeaconBlock(res, signedBlock))
|
||||
|
||||
network.initBeaconSync(blockPool, enrForkId.forkDigest)
|
||||
return res
|
||||
|
||||
proc onAttestation(node: BeaconNode, attestation: Attestation) =
|
||||
|
|
|
@ -37,7 +37,6 @@ type
|
|||
BeaconSyncNetworkState* = ref object
|
||||
blockPool*: BlockPool
|
||||
forkDigest*: ForkDigest
|
||||
onBeaconBlock*: BeaconBlockCallback
|
||||
|
||||
BeaconSyncPeerState* = ref object
|
||||
initialStatusReceived*: bool
|
||||
|
@ -66,12 +65,6 @@ func disconnectReasonName(reason: uint64): string =
|
|||
elif reason == uint64(FaultOrError): "Fault or error"
|
||||
else: "Disconnected (" & $reason & ")"
|
||||
|
||||
proc importBlocks(state: BeaconSyncNetworkState,
|
||||
blocks: openarray[SignedBeaconBlock]) {.gcsafe.} =
|
||||
for blk in blocks:
|
||||
state.onBeaconBlock(blk)
|
||||
info "Forward sync imported blocks", len = blocks.len
|
||||
|
||||
proc getCurrentStatus*(state: BeaconSyncNetworkState): StatusMsg {.gcsafe.} =
|
||||
let
|
||||
blockPool = state.blockPool
|
||||
|
@ -236,11 +229,8 @@ proc handleStatus(peer: Peer,
|
|||
|
||||
peer.setStatusMsg(theirStatus)
|
||||
|
||||
proc initBeaconSync*(network: Eth2Node,
|
||||
blockPool: BlockPool,
|
||||
forkDigest: ForkDigest,
|
||||
onBeaconBlock: BeaconBlockCallback) =
|
||||
proc initBeaconSync*(network: Eth2Node, blockPool: BlockPool,
|
||||
forkDigest: ForkDigest) =
|
||||
var networkState = network.protocolState(BeaconSync)
|
||||
networkState.blockPool = blockPool
|
||||
networkState.forkDigest = forkDigest
|
||||
networkState.onBeaconBlock = onBeaconBlock
|
||||
|
|
Loading…
Reference in New Issue