diff --git a/beacon_chain/deposit_contract.nim b/beacon_chain/deposit_contract.nim index 9121316b9..cc1b06bef 100644 --- a/beacon_chain/deposit_contract.nim +++ b/beacon_chain/deposit_contract.nim @@ -165,7 +165,7 @@ proc sendDeposits*(deposits: seq[LaunchPadDeposit], await sleepAsync(delayGenerator()) break - except CatchableError as err: + except CatchableError: await sleepAsync(60.seconds) web3 = await initWeb3(web3Url, privateKey) diff --git a/beacon_chain/eth2_network.nim b/beacon_chain/eth2_network.nim index 993611227..84a499db5 100644 --- a/beacon_chain/eth2_network.nim +++ b/beacon_chain/eth2_network.nim @@ -443,7 +443,7 @@ proc disconnect*(peer: Peer, reason: DisconnectionReason, peer.network.addSeen(peer.info.peerId, seenTime) await peer.network.switch.disconnect(peer.info.peerId) peer.connectionState = Disconnected - except CatchableError as exc: + except CatchableError: # We do not care about exceptions in disconnection procedure. trace "Exception while disconnecting peer", peer = peer.info.peerId, reason = reason @@ -465,11 +465,6 @@ proc getRequestProtoName(fn: NimNode): NimNode = return newLit("") -template raisePeerDisconnected(msg: string, r: DisconnectionReason) = - var e = newException(PeerDisconnected, msg) - e.reason = r - raise e - proc writeChunk*(conn: Connection, responseCode: Option[ResponseCode], payload: Bytes): Future[void] = @@ -991,7 +986,7 @@ proc startListening*(node: Eth2Node) {.async.} = if node.discoveryEnabled: try: node.discovery.open() - except CatchableError as err: + except CatchableError: fatal "Failed to start discovery service. UDP port may be already in use" quit 1 diff --git a/beacon_chain/keystore_management.nim b/beacon_chain/keystore_management.nim index 050d7cbbc..bdf9156de 100644 --- a/beacon_chain/keystore_management.nim +++ b/beacon_chain/keystore_management.nim @@ -202,7 +202,7 @@ proc keyboardGetPassword[T](prompt: string, attempts: int, let passphrase = try: readPasswordFromStdin(prompt) - except IOError as exc: + except IOError: error "Could not read password from stdin" return os.sleep(1000 * counter) diff --git a/beacon_chain/spec/beaconstate.nim b/beacon_chain/spec/beaconstate.nim index b0a5b2107..c0853a564 100644 --- a/beacon_chain/spec/beaconstate.nim +++ b/beacon_chain/spec/beaconstate.nim @@ -320,16 +320,6 @@ proc initialize_hashed_beacon_state_from_eth1*( preset, eth1_block_hash, eth1_timestamp, deposits, flags) HashedBeaconState(data: genesisState[], root: hash_tree_root(genesisState[])) -func is_valid_genesis_state(preset: RuntimePreset, - state: BeaconState, - active_validator_indices: seq[ValidatorIndex]): bool = - if state.genesis_time < preset.MIN_GENESIS_TIME: - return false - # This is an okay get_active_validator_indices(...) for the time being. - if active_validator_indices.lenu64 < preset.MIN_GENESIS_ACTIVE_VALIDATOR_COUNT: - return false - true - func emptyBeaconBlockBody(): BeaconBlockBody = # TODO: This shouldn't be necessary if OpaqueBlob is the default BeaconBlockBody(randao_reveal: ValidatorSig(kind: OpaqueBlob)) diff --git a/beacon_chain/sync_manager.nim b/beacon_chain/sync_manager.nim index 6783ac2ca..df62b9386 100644 --- a/beacon_chain/sync_manager.nim +++ b/beacon_chain/sync_manager.nim @@ -721,9 +721,6 @@ proc getBlocks*[A, B](man: SyncManager[A, B], peer: A, template headAge(): uint64 = wallSlot - headSlot -template peerAge(): uint64 = - if peerSlot > wallSlot: 0'u64 else: wallSlot - peerSlot - template queueAge(): uint64 = wallSlot - man.queue.outSlot @@ -753,7 +750,7 @@ proc syncStep[A, B](man: SyncManager[A, B], index: int, peer: A) {.async.} = local_head_slot = headSlot, peer = peer, index = index, tolerance_value = man.toleranceValue, peer_speed = peer.netKbps(), peer_score = peer.getScore(), topics = "syncman" - let failure = SyncFailure.init(SyncFailureKind.StatusInvalid, peer) + discard SyncFailure.init(SyncFailureKind.StatusInvalid, peer) return # Check if we need to update peer's status information @@ -772,7 +769,7 @@ proc syncStep[A, B](man: SyncManager[A, B], index: int, peer: A) {.async.} = debug "Failed to get remote peer's status, exiting", peer = peer, peer_score = peer.getScore(), peer_head_slot = peerSlot, peer_speed = peer.netKbps(), index = index, topics = "syncman" - let failure = SyncFailure.init(SyncFailureKind.StatusDownload, peer) + discard SyncFailure.init(SyncFailureKind.StatusDownload, peer) return except CatchableError as exc: debug "Unexpected exception while updating peer's status", @@ -826,7 +823,7 @@ proc syncStep[A, B](man: SyncManager[A, B], index: int, peer: A) {.async.} = debug "Failed to get remote peer's status, exiting", peer = peer, peer_score = peer.getScore(), peer_head_slot = peerSlot, peer_speed = peer.netKbps(), index = index, topics = "syncman" - let failure = SyncFailure.init(SyncFailureKind.StatusDownload, peer) + discard SyncFailure.init(SyncFailureKind.StatusDownload, peer) return except CatchableError as exc: debug "Unexpected exception while updating peer's status", @@ -919,7 +916,7 @@ proc syncStep[A, B](man: SyncManager[A, B], index: int, peer: A) {.async.} = request_step = req.step, peer = peer, peer_score = peer.getScore(), peer_speed = peer.netKbps(), index = index, topics = "syncman" - let failure = SyncFailure.init(SyncFailureKind.BadResponse, peer) + discard SyncFailure.init(SyncFailureKind.BadResponse, peer) return # Scoring will happen in `syncUpdate`. @@ -933,7 +930,7 @@ proc syncStep[A, B](man: SyncManager[A, B], index: int, peer: A) {.async.} = request_step = req.step, peer = peer, index = index, peer_score = peer.getScore(), peer_speed = peer.netKbps(), topics = "syncman" - let failure = SyncFailure.init(SyncFailureKind.BlockDownload, peer) + discard SyncFailure.init(SyncFailureKind.BlockDownload, peer) return except CatchableError as exc: @@ -1054,7 +1051,7 @@ proc syncLoop[A, B](man: SyncManager[A, B]) {.async.} = let op1 = man.queue.opcounter await sleepAsync(chronos.seconds(pauseTime)) let op2 = man.queue.opcounter - let (map, sleeping, waiting, pending) = man.getWorkersStats() + let (_, _, _, pending) = man.getWorkersStats() if pending == 0: pauseTime = MinPauseTime else: diff --git a/beacon_chain/validator_duties.nim b/beacon_chain/validator_duties.nim index 94855c536..fcc5d4074 100644 --- a/beacon_chain/validator_duties.nim +++ b/beacon_chain/validator_duties.nim @@ -438,7 +438,6 @@ proc broadcastAggregatedAttestations( # the corresponding one -- whatver they are, they match. let - bs = BlockSlot(blck: aggregationHead, slot: aggregationSlot) epochRef = node.chainDag.getEpochRef(aggregationHead, aggregationSlot.epoch) fork = node.chainDag.headState.data.data.fork genesis_validators_root = diff --git a/beacon_chain/validator_slashing_protection.nim b/beacon_chain/validator_slashing_protection.nim index cb4485827..76c1e86ec 100644 --- a/beacon_chain/validator_slashing_protection.nim +++ b/beacon_chain/validator_slashing_protection.nim @@ -313,7 +313,7 @@ proc get(db: SlashingProtectionDB, dataLen = data.len, expectedSize = ExpectedNodeSszSize discard - except SerializationError as e: + except SerializationError: # If the data can't be deserialized, it could be because it's from a # version of the software that uses a different SSZ encoding warn "Unable to deserialize data, old database?",