From 6052f36fcd136a8f33b48811fd7bda9a2dba57c9 Mon Sep 17 00:00:00 2001 From: cheatfate Date: Thu, 16 Jul 2020 09:59:24 +0300 Subject: [PATCH] Fix #1241. --- beacon_chain/beacon_node.nim | 22 +--------------------- beacon_chain/sync_protocol.nim | 14 ++------------ 2 files changed, 3 insertions(+), 33 deletions(-) diff --git a/beacon_chain/beacon_node.nim b/beacon_chain/beacon_node.nim index 82c2633f6..f62ca2282 100644 --- a/beacon_chain/beacon_node.nim +++ b/beacon_chain/beacon_node.nim @@ -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) = diff --git a/beacon_chain/sync_protocol.nim b/beacon_chain/sync_protocol.nim index a61ff40bf..82d189838 100644 --- a/beacon_chain/sync_protocol.nim +++ b/beacon_chain/sync_protocol.nim @@ -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