From c211a3849e62e06a1cc93afaeddd25b0a90a2020 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Fri, 25 Aug 2023 11:29:07 +0200 Subject: [PATCH] remove `{.raises: [Defect].}` Nim 1.2 compatibility (#5352) In Nim 1.6, `{.raises: [Defect].}` is no longer necessary. Remove it. --- beacon_chain/beacon_chain_db.nim | 2 +- beacon_chain/beacon_clock.nim | 2 +- beacon_chain/conf.nim | 36 ++++---- .../attestation_pool.nim | 2 +- .../block_pools_types.nim | 10 +- .../block_pools_types_light_client.nim | 4 +- .../consensus_object_pools/exit_pool.nim | 2 +- .../sync_committee_msg_pool.nim | 2 +- .../vanity_logs/vanity_logs.nim | 2 +- beacon_chain/deposits.nim | 2 +- beacon_chain/el/deposit_contract.nim | 2 +- beacon_chain/el/el_conf.nim | 6 +- beacon_chain/el/el_manager.nim | 8 +- beacon_chain/future_combinators.nim | 2 +- .../light_client_processor.nim | 6 +- .../optimistic_processor.nim | 2 +- beacon_chain/light_client.nim | 4 +- beacon_chain/networking/eth2_network.nim | 22 ++--- .../networking/libp2p_json_serialization.nim | 4 +- beacon_chain/networking/peer_pool.nim | 16 ++-- beacon_chain/nimbus_beacon_node.nim | 28 +++--- beacon_chain/nimbus_binary_common.nim | 6 +- beacon_chain/rpc/rest_key_management_api.nim | 6 +- beacon_chain/spec/beacon_time.nim | 2 +- beacon_chain/spec/crypto.nim | 8 +- beacon_chain/spec/datatypes/base.nim | 10 +- beacon_chain/spec/datatypes/bellatrix.nim | 8 +- beacon_chain/spec/datatypes/capella.nim | 2 +- beacon_chain/spec/datatypes/deneb.nim | 2 +- beacon_chain/spec/digest.nim | 4 +- .../eth2_apis/eth2_rest_serialization.nim | 92 +++++++++---------- beacon_chain/spec/eth2_apis/rest_common.nim | 4 +- .../spec/eth2_apis/rest_event_calls.nim | 2 +- .../spec/eth2_apis/rest_keymanager_calls.nim | 2 +- .../spec/eth2_apis/rest_nimbus_calls.nim | 2 +- beacon_chain/spec/eth2_ssz_serialization.nim | 4 +- beacon_chain/spec/forks.nim | 2 +- beacon_chain/spec/keystore.nim | 14 +-- beacon_chain/spec/network.nim | 2 +- beacon_chain/spec/presets.nim | 10 +- beacon_chain/spec/ssz_codec.nim | 2 +- beacon_chain/spec/state_transition.nim | 4 +- beacon_chain/statusbar.nim | 13 ++- beacon_chain/sync/light_client_manager.nim | 16 ++-- beacon_chain/sync/sync_queue.nim | 6 +- .../validator_client/fork_service.nim | 4 +- .../validators/keystore_management.nim | 48 +++++----- beacon_chain/validators/message_router.nim | 2 +- .../validators/slashing_protection.nim | 9 +- .../validators/slashing_protection_common.nim | 10 +- .../validators/slashing_protection_v2.nim | 6 +- beacon_chain/wallets.nim | 2 +- ncli/logtrace.nim | 6 +- ncli/ncli_testnet.nim | 4 +- nfuzz/libnfuzz.nim | 18 ++-- tests/test_deposit_snapshots.nim | 9 +- tests/test_discovery.nim | 2 +- tests/test_keymanager_api.nim | 6 +- 58 files changed, 259 insertions(+), 254 deletions(-) diff --git a/beacon_chain/beacon_chain_db.nim b/beacon_chain/beacon_chain_db.nim index 12e307911..4c3e716b6 100644 --- a/beacon_chain/beacon_chain_db.nim +++ b/beacon_chain/beacon_chain_db.nim @@ -108,7 +108,7 @@ type immutableValidatorsDb*: DbSeq[ImmutableValidatorDataDb2] immutableValidators*: seq[ImmutableValidatorData2] - checkpoint*: proc() {.gcsafe, raises: [Defect].} + checkpoint*: proc() {.gcsafe, raises: [].} keyValues: KvStoreRef # Random stuff using DbKeyKind - suitable for small values mainly! blocks: array[ConsensusFork, KvStoreRef] # BlockRoot -> TrustedSignedBeaconBlock diff --git a/beacon_chain/beacon_clock.nim b/beacon_chain/beacon_clock.nim index 8c3eea0db..07d50fd79 100644 --- a/beacon_chain/beacon_clock.nim +++ b/beacon_chain/beacon_clock.nim @@ -32,7 +32,7 @@ type # https://ethresear.ch/t/network-adjusted-timestamps/4187 genesis: Time - GetBeaconTimeFn* = proc(): BeaconTime {.gcsafe, raises: [Defect].} + GetBeaconTimeFn* = proc(): BeaconTime {.gcsafe, raises: [].} proc init*(T: type BeaconClock, genesis_time: uint64): T = # ~290 billion years into the future diff --git a/beacon_chain/conf.nim b/beacon_chain/conf.nim index 37e5b69db..19dd6a80d 100644 --- a/beacon_chain/conf.nim +++ b/beacon_chain/conf.nim @@ -1093,39 +1093,39 @@ proc createDumpDirs*(config: BeaconNodeConf) = path = config.dumpDirOutgoing, err = ioErrorMsg(res.error) func parseCmdArg*(T: type Eth2Digest, input: string): T - {.raises: [ValueError, Defect].} = + {.raises: [ValueError].} = Eth2Digest.fromHex(input) func completeCmdArg*(T: type Eth2Digest, input: string): seq[string] = return @[] func parseCmdArg*(T: type GraffitiBytes, input: string): T - {.raises: [ValueError, Defect].} = + {.raises: [ValueError].} = GraffitiBytes.init(input) func completeCmdArg*(T: type GraffitiBytes, input: string): seq[string] = return @[] func parseCmdArg*(T: type BlockHashOrNumber, input: string): T - {.raises: [ValueError, Defect].} = + {.raises: [ValueError].} = init(BlockHashOrNumber, input) func completeCmdArg*(T: type BlockHashOrNumber, input: string): seq[string] = return @[] func parseCmdArg*(T: type Uri, input: string): T - {.raises: [ValueError, Defect].} = + {.raises: [ValueError].} = parseUri(input) func completeCmdArg*(T: type Uri, input: string): seq[string] = return @[] func parseCmdArg*(T: type PubKey0x, input: string): T - {.raises: [ValueError, Defect].} = + {.raises: [ValueError].} = PubKey0x(hexToPaddedByteArray[RawPubKeySize](input)) func parseCmdArg*(T: type ValidatorPubKey, input: string): T - {.raises: [ValueError, Defect].} = + {.raises: [ValueError].} = let res = ValidatorPubKey.fromHex(input) if res.isErr(): raise (ref ValueError)(msg: $res.error()) res.get() @@ -1134,7 +1134,7 @@ func completeCmdArg*(T: type PubKey0x, input: string): seq[string] = return @[] func parseCmdArg*(T: type Checkpoint, input: string): T - {.raises: [ValueError, Defect].} = + {.raises: [ValueError].} = let sepIdx = find(input, ':') if sepIdx == -1 or sepIdx == input.len - 1: raise newException(ValueError, @@ -1149,7 +1149,7 @@ func completeCmdArg*(T: type Checkpoint, input: string): seq[string] = return @[] func parseCmdArg*(T: type Epoch, input: string): T - {.raises: [ValueError, Defect].} = + {.raises: [ValueError].} = Epoch parseBiggestUInt(input) func completeCmdArg*(T: type Epoch, input: string): seq[string] = @@ -1163,7 +1163,7 @@ func isPrintable(rune: Rune): bool = rune == Rune(0x20) or unicodeCategory(rune) notin ctgC+ctgZ func parseCmdArg*(T: type WalletName, input: string): T - {.raises: [ValueError, Defect].} = + {.raises: [ValueError].} = if input.len == 0: raise newException(ValueError, "The wallet name should not be empty") if input[0] == '_': @@ -1254,31 +1254,31 @@ template raiseUnexpectedValue(r: var TomlReader, msg: string) = raise newException(SerializationError, msg) proc readValue*(r: var TomlReader, value: var Epoch) - {.raises: [Defect, SerializationError, IOError].} = + {.raises: [SerializationError, IOError].} = value = Epoch r.parseInt(uint64) proc readValue*(r: var TomlReader, value: var GraffitiBytes) - {.raises: [Defect, SerializationError, IOError].} = + {.raises: [SerializationError, IOError].} = try: value = GraffitiBytes.init(r.readValue(string)) except ValueError: r.raiseUnexpectedValue("A printable string or 0x-prefixed hex-encoded raw bytes expected") proc readValue*(r: var TomlReader, val: var NatConfig) - {.raises: [Defect, IOError, SerializationError].} = + {.raises: [IOError, SerializationError].} = val = try: parseCmdArg(NatConfig, r.readValue(string)) except CatchableError as err: raise newException(SerializationError, err.msg) proc readValue*(r: var TomlReader, a: var Eth2Digest) - {.raises: [Defect, IOError, SerializationError].} = + {.raises: [IOError, SerializationError].} = try: a = fromHex(type(a), r.readValue(string)) except ValueError: r.raiseUnexpectedValue("Hex string expected") proc readValue*(reader: var TomlReader, value: var ValidatorPubKey) - {.raises: [Defect, IOError, SerializationError].} = + {.raises: [IOError, SerializationError].} = let keyAsString = try: reader.readValue(string) except CatchableError: @@ -1292,21 +1292,21 @@ proc readValue*(reader: var TomlReader, value: var ValidatorPubKey) raiseUnexpectedValue(reader, "Valid hex-encoded public key expected") proc readValue*(r: var TomlReader, a: var PubKey0x) - {.raises: [Defect, IOError, SerializationError].} = + {.raises: [IOError, SerializationError].} = try: a = parseCmdArg(PubKey0x, r.readValue(string)) except CatchableError: r.raiseUnexpectedValue("a 0x-prefixed hex-encoded string expected") proc readValue*(r: var TomlReader, a: var WalletName) - {.raises: [Defect, IOError, SerializationError].} = + {.raises: [IOError, SerializationError].} = try: a = parseCmdArg(WalletName, r.readValue(string)) except CatchableError: r.raiseUnexpectedValue("string expected") proc readValue*(r: var TomlReader, a: var Address) - {.raises: [Defect, IOError, SerializationError].} = + {.raises: [IOError, SerializationError].} = try: a = parseCmdArg(Address, r.readValue(string)) except CatchableError: @@ -1314,7 +1314,7 @@ proc readValue*(r: var TomlReader, a: var Address) proc loadEth2Network*( eth2Network: Option[string] -): Eth2NetworkMetadata {.raises: [Defect, IOError].} = +): Eth2NetworkMetadata {.raises: [IOError].} = const defaultName = when const_preset == "gnosis": "gnosis" diff --git a/beacon_chain/consensus_object_pools/attestation_pool.nim b/beacon_chain/consensus_object_pools/attestation_pool.nim index 7574bb71e..efa4fc40d 100644 --- a/beacon_chain/consensus_object_pools/attestation_pool.nim +++ b/beacon_chain/consensus_object_pools/attestation_pool.nim @@ -33,7 +33,7 @@ const ## that potentially could be added to a newly created block type - OnAttestationCallback* = proc(data: Attestation) {.gcsafe, raises: [Defect].} + OnAttestationCallback* = proc(data: Attestation) {.gcsafe, raises: [].} Validation* = object ## Validations collect a set of signatures for a distict attestation - in diff --git a/beacon_chain/consensus_object_pools/block_pools_types.nim b/beacon_chain/consensus_object_pools/block_pools_types.nim index 7c938abe0..b21ea8db2 100644 --- a/beacon_chain/consensus_object_pools/block_pools_types.nim +++ b/beacon_chain/consensus_object_pools/block_pools_types.nim @@ -50,13 +50,13 @@ type ## We've seen this value already, can't add again OnBlockCallback* = - proc(data: ForkedTrustedSignedBeaconBlock) {.gcsafe, raises: [Defect].} + proc(data: ForkedTrustedSignedBeaconBlock) {.gcsafe, raises: [].} OnHeadCallback* = - proc(data: HeadChangeInfoObject) {.gcsafe, raises: [Defect].} + proc(data: HeadChangeInfoObject) {.gcsafe, raises: [].} OnReorgCallback* = - proc(data: ReorgInfoObject) {.gcsafe, raises: [Defect].} + proc(data: ReorgInfoObject) {.gcsafe, raises: [].} OnFinalizedCallback* = - proc(dag: ChainDAGRef, data: FinalizationInfoObject) {.gcsafe, raises: [Defect].} + proc(dag: ChainDAGRef, data: FinalizationInfoObject) {.gcsafe, raises: [].} KeyedBlockRef* = object # Special wrapper for BlockRef used in ChainDAG.blocks that allows lookup @@ -281,7 +281,7 @@ type OnBlockAdded[T] = proc( blckRef: BlockRef, blck: T, epochRef: EpochRef, - unrealized: FinalityCheckpoints) {.gcsafe, raises: [Defect].} + unrealized: FinalityCheckpoints) {.gcsafe, raises: [].} OnPhase0BlockAdded* = OnBlockAdded[phase0.TrustedSignedBeaconBlock] OnAltairBlockAdded* = OnBlockAdded[altair.TrustedSignedBeaconBlock] OnBellatrixBlockAdded* = OnBlockAdded[bellatrix.TrustedSignedBeaconBlock] diff --git a/beacon_chain/consensus_object_pools/block_pools_types_light_client.nim b/beacon_chain/consensus_object_pools/block_pools_types_light_client.nim index a74d491ff..d6f1813b9 100644 --- a/beacon_chain/consensus_object_pools/block_pools_types_light_client.nim +++ b/beacon_chain/consensus_object_pools/block_pools_types_light_client.nim @@ -26,9 +26,9 @@ type ## Like `full`, but import on demand instead of on start. OnLightClientFinalityUpdateCallback* = - proc(data: ForkedLightClientFinalityUpdate) {.gcsafe, raises: [Defect].} + proc(data: ForkedLightClientFinalityUpdate) {.gcsafe, raises: [].} OnLightClientOptimisticUpdateCallback* = - proc(data: ForkedLightClientOptimisticUpdate) {.gcsafe, raises: [Defect].} + proc(data: ForkedLightClientOptimisticUpdate) {.gcsafe, raises: [].} CachedLightClientData* = object ## Cached data from historical non-finalized states to improve speed when diff --git a/beacon_chain/consensus_object_pools/exit_pool.nim b/beacon_chain/consensus_object_pools/exit_pool.nim index cfa3a3b67..9cb8ffe34 100644 --- a/beacon_chain/consensus_object_pools/exit_pool.nim +++ b/beacon_chain/consensus_object_pools/exit_pool.nim @@ -29,7 +29,7 @@ const type OnVoluntaryExitCallback = - proc(data: SignedVoluntaryExit) {.gcsafe, raises: [Defect].} + proc(data: SignedVoluntaryExit) {.gcsafe, raises: [].} ValidatorChangePool* = object ## The validator change pool tracks attester slashings, proposer slashings, diff --git a/beacon_chain/consensus_object_pools/sync_committee_msg_pool.nim b/beacon_chain/consensus_object_pools/sync_committee_msg_pool.nim index c9848be60..66e238622 100644 --- a/beacon_chain/consensus_object_pools/sync_committee_msg_pool.nim +++ b/beacon_chain/consensus_object_pools/sync_committee_msg_pool.nim @@ -46,7 +46,7 @@ type BestSyncSubcommitteeContribution] OnSyncContributionCallback* = - proc(data: SignedContributionAndProof) {.gcsafe, raises: [Defect].} + proc(data: SignedContributionAndProof) {.gcsafe, raises: [].} # Messages from different slots / forks may sign the same beacon block root. # Messages across slots are compatible, but not across forks (signing root). diff --git a/beacon_chain/consensus_object_pools/vanity_logs/vanity_logs.nim b/beacon_chain/consensus_object_pools/vanity_logs/vanity_logs.nim index 05b289eb3..f629810d9 100644 --- a/beacon_chain/consensus_object_pools/vanity_logs/vanity_logs.nim +++ b/beacon_chain/consensus_object_pools/vanity_logs/vanity_logs.nim @@ -12,7 +12,7 @@ import chronicles type - LogProc = proc() {.gcsafe, raises: [Defect].} + LogProc = proc() {.gcsafe, raises: [].} VanityLogs* = object # Upon the merge activating, these get displayed, at least once when the diff --git a/beacon_chain/deposits.nim b/beacon_chain/deposits.nim index 9c39d1bea..703888c63 100644 --- a/beacon_chain/deposits.nim +++ b/beacon_chain/deposits.nim @@ -333,7 +333,7 @@ proc handleValidatorExitCommand(config: BeaconNodeConf) {.async.} = await restValidatorExit(config) proc doDeposits*(config: BeaconNodeConf, rng: var HmacDrbgContext) {. - raises: [Defect, CatchableError].} = + raises: [CatchableError].} = case config.depositsCmd of DepositsCmd.createTestnetDeposits: if config.eth2Network.isNone: diff --git a/beacon_chain/el/deposit_contract.nim b/beacon_chain/el/deposit_contract.nim index 752110f4f..f40ec10d4 100644 --- a/beacon_chain/el/deposit_contract.nim +++ b/beacon_chain/el/deposit_contract.nim @@ -143,7 +143,7 @@ proc sendEth(web3: Web3, to: Eth1Address, valueEth: int): Future[TxHash] = web3.send(tr) type - DelayGenerator* = proc(): chronos.Duration {.gcsafe, raises: [Defect].} + DelayGenerator* = proc(): chronos.Duration {.gcsafe, raises: [].} proc ethToWei(eth: UInt256): UInt256 = eth * 1000000000000000000.u256 diff --git a/beacon_chain/el/el_conf.nim b/beacon_chain/el/el_conf.nim index 31f583341..5f96105ca 100644 --- a/beacon_chain/el/el_conf.nim +++ b/beacon_chain/el/el_conf.nim @@ -75,7 +75,7 @@ template raiseError(reader: var JsonReader, msg: string) = raiseTomlErr(reader.lex, msg) proc readValue*(reader: var TomlReader, value: var EngineApiRoles) - {.raises: [Defect, SerializationError, IOError].} = + {.raises: [SerializationError, IOError].} = let roles = reader.readValue seq[string] if roles.len == 0: reader.raiseError "At least one role should be provided" @@ -100,7 +100,7 @@ proc writeValue*( writer.writeValue strRoles proc parseCmdArg*(T: type EngineApiUrlConfigValue, input: string): T - {.raises: [ValueError, Defect].} = + {.raises: [ValueError].} = var uri = parseUri(input) jwtSecret: Option[string] @@ -140,7 +140,7 @@ proc parseCmdArg*(T: type EngineApiUrlConfigValue, input: string): T roles: roles) proc readValue*(reader: var TomlReader, value: var EngineApiUrlConfigValue) - {.raises: [Defect, SerializationError, IOError].} = + {.raises: [SerializationError, IOError].} = if reader.lex.readable and reader.lex.peekChar in ['\'', '"']: # If the input is a string, we'll reuse the command-line parsing logic value = try: parseCmdArg(EngineApiUrlConfigValue, reader.readValue(string)) diff --git a/beacon_chain/el/el_manager.nim b/beacon_chain/el/el_manager.nim index 37f9ec036..38c3320cb 100644 --- a/beacon_chain/el/el_manager.nim +++ b/beacon_chain/el/el_manager.nim @@ -224,7 +224,7 @@ type CorruptDataProvider* = object of DataProviderFailure DataProviderTimeout* = object of DataProviderFailure - DisconnectHandler* = proc () {.gcsafe, raises: [Defect].} + DisconnectHandler* = proc () {.gcsafe, raises: [].} DepositEventHandler* = proc ( pubkey: PubKeyBytes, @@ -232,7 +232,7 @@ type amount: Int64LeBytes, signature: SignatureBytes, merkleTreeIndex: Int64LeBytes, - j: JsonNode) {.gcsafe, raises: [Defect].} + j: JsonNode) {.gcsafe, raises: [].} BlockProposalEth1Data* = object vote*: Eth1Data @@ -795,7 +795,7 @@ proc forkchoiceUpdated(rpcClient: RpcClient, else: static: doAssert false -func computeBlockValue(blk: ExecutionPayloadV1): UInt256 {.raises: [RlpError, Defect].} = +func computeBlockValue(blk: ExecutionPayloadV1): UInt256 {.raises: [RlpError].} = for transactionBytes in blk.transactions: var rlp = rlpFromBytes distinctBase(transactionBytes) let transaction = rlp.read(eth_types.Transaction) @@ -1473,7 +1473,7 @@ proc fetchTimestamp(connection: ELConnection, blk.timestamp = Eth1BlockTimestamp web3block.timestamp func depositEventsToBlocks(depositsList: JsonNode): seq[Eth1Block] {. - raises: [Defect, CatchableError].} = + raises: [CatchableError].} = if depositsList.kind != JArray: raise newException(CatchableError, "Web3 provider didn't return a list of deposit events") diff --git a/beacon_chain/future_combinators.nim b/beacon_chain/future_combinators.nim index 37ef9f66b..7c0d7c5d9 100644 --- a/beacon_chain/future_combinators.nim +++ b/beacon_chain/future_combinators.nim @@ -92,7 +92,7 @@ proc firstCompleted*[T](futs: varargs[Future[T]]): Future[T] = retFuture.fail(subFuture.error) return retFuture - proc cb(udata: pointer) {.gcsafe, raises: [Defect].} = + proc cb(udata: pointer) {.gcsafe, raises: [].} = let subFuture = cast[Future[FutureBase]](udata) if subFuture.completed: retFuture.complete(Future[T](subFuture.read).read) diff --git a/beacon_chain/gossip_processing/light_client_processor.nim b/beacon_chain/gossip_processing/light_client_processor.nim index 39f04ecbf..be5aadd8a 100644 --- a/beacon_chain/gossip_processing/light_client_processor.nim +++ b/beacon_chain/gossip_processing/light_client_processor.nim @@ -29,12 +29,12 @@ type Nothing = object GetTrustedBlockRootCallback* = - proc(): Option[Eth2Digest] {.gcsafe, raises: [Defect].} + proc(): Option[Eth2Digest] {.gcsafe, raises: [].} VoidCallback* = - proc() {.gcsafe, raises: [Defect].} + proc() {.gcsafe, raises: [].} ValueObserver[V] = - proc(v: V) {.gcsafe, raises: [Defect].} + proc(v: V) {.gcsafe, raises: [].} BootstrapObserver* = ValueObserver[ForkedLightClientBootstrap] UpdateObserver* = diff --git a/beacon_chain/gossip_processing/optimistic_processor.nim b/beacon_chain/gossip_processing/optimistic_processor.nim index 4178d3713..1cd228b58 100644 --- a/beacon_chain/gossip_processing/optimistic_processor.nim +++ b/beacon_chain/gossip_processing/optimistic_processor.nim @@ -30,7 +30,7 @@ const type MsgTrustedBlockProcessor* = proc(signedBlock: ForkedMsgTrustedSignedBeaconBlock): Future[void] {. - gcsafe, raises: [Defect].} + gcsafe, raises: [].} OptimisticProcessor* = ref object getBeaconTime: GetBeaconTimeFn diff --git a/beacon_chain/light_client.nim b/beacon_chain/light_client.nim index 81d5757a4..d7c7f151a 100644 --- a/beacon_chain/light_client.nim +++ b/beacon_chain/light_client.nim @@ -23,10 +23,10 @@ logScope: topics = "lightcl" type LightClientHeaderCallback* = proc(lightClient: LightClient, header: ForkedLightClientHeader) {. - gcsafe, raises: [Defect].} + gcsafe, raises: [].} LightClientValueObserver[V] = - proc(lightClient: LightClient, v: V) {.gcsafe, raises: [Defect].} + proc(lightClient: LightClient, v: V) {.gcsafe, raises: [].} LightClientBootstrapObserver* = LightClientValueObserver[ForkedLightClientBootstrap] LightClientUpdateObserver* = diff --git a/beacon_chain/networking/eth2_network.nim b/beacon_chain/networking/eth2_network.nim index 5787ad9a0..3c50f2c64 100644 --- a/beacon_chain/networking/eth2_network.nim +++ b/beacon_chain/networking/eth2_network.nim @@ -163,13 +163,13 @@ type ServerError ResourceUnavailable - PeerStateInitializer* = proc(peer: Peer): RootRef {.gcsafe, raises: [Defect].} - NetworkStateInitializer* = proc(network: EthereumNode): RootRef {.gcsafe, raises: [Defect].} - OnPeerConnectedHandler* = proc(peer: Peer, incoming: bool): Future[void] {.gcsafe, raises: [Defect].} - OnPeerDisconnectedHandler* = proc(peer: Peer): Future[void] {.gcsafe, raises: [Defect].} + PeerStateInitializer* = proc(peer: Peer): RootRef {.gcsafe, raises: [].} + NetworkStateInitializer* = proc(network: EthereumNode): RootRef {.gcsafe, raises: [].} + OnPeerConnectedHandler* = proc(peer: Peer, incoming: bool): Future[void] {.gcsafe, raises: [].} + OnPeerDisconnectedHandler* = proc(peer: Peer): Future[void] {.gcsafe, raises: [].} ThunkProc* = LPProtoHandler - MounterProc* = proc(network: Eth2Node) {.gcsafe, raises: [Defect, CatchableError].} - MessageContentPrinter* = proc(msg: pointer): string {.gcsafe, raises: [Defect].} + MounterProc* = proc(network: Eth2Node) {.gcsafe, raises: [CatchableError].} + MessageContentPrinter* = proc(msg: pointer): string {.gcsafe, raises: [].} # https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/p2p-interface.md#goodbye DisconnectionReason* = enum @@ -1793,7 +1793,7 @@ proc new(T: type Eth2Node, switch: Switch, pubsub: GossipSub, ip: Option[ValidIpAddress], tcpPort, udpPort: Option[Port], privKey: keys.PrivateKey, discovery: bool, - rng: ref HmacDrbgContext): T {.raises: [Defect, CatchableError].} = + rng: ref HmacDrbgContext): T {.raises: [CatchableError].} = when not defined(local_testnet): let connectTimeout = chronos.minutes(1) @@ -2275,7 +2275,7 @@ func gossipId( proc newBeaconSwitch(config: BeaconNodeConf | LightClientConf, seckey: PrivateKey, address: MultiAddress, - rng: ref HmacDrbgContext): Switch {.raises: [Defect, CatchableError].} = + rng: ref HmacDrbgContext): Switch {.raises: [CatchableError].} = var sb = if config.enableYamux: SwitchBuilder.new().withYamux() @@ -2302,7 +2302,7 @@ proc createEth2Node*(rng: ref HmacDrbgContext, forkDigests: ref ForkDigests, getBeaconTime: GetBeaconTimeFn, genesis_validators_root: Eth2Digest): Eth2Node - {.raises: [Defect, CatchableError].} = + {.raises: [CatchableError].} = let enrForkId = getENRForkID( cfg, getBeaconTime().slotOrZero.epoch, genesis_validators_root) @@ -2438,7 +2438,7 @@ proc newValidationResultFuture(v: ValidationResult): Future[ValidationResult] = proc addValidator*[MsgType](node: Eth2Node, topic: string, msgValidator: proc(msg: MsgType): - ValidationResult {.gcsafe, raises: [Defect].} ) = + ValidationResult {.gcsafe, raises: [].} ) = # Message validators run when subscriptions are enabled - they validate the # data and return an indication of whether the message should be broadcast # or not - validation is `async` but implemented without the macro because @@ -2473,7 +2473,7 @@ proc addValidator*[MsgType](node: Eth2Node, proc addAsyncValidator*[MsgType](node: Eth2Node, topic: string, msgValidator: proc(msg: MsgType): - Future[ValidationResult] {.gcsafe, raises: [Defect].} ) = + Future[ValidationResult] {.gcsafe, raises: [].} ) = proc execValidator(topic: string, message: GossipMsg): Future[ValidationResult] {.raises: [].} = inc nbc_gossip_messages_received diff --git a/beacon_chain/networking/libp2p_json_serialization.nim b/beacon_chain/networking/libp2p_json_serialization.nim index 7283987aa..6fbe93a25 100644 --- a/beacon_chain/networking/libp2p_json_serialization.nim +++ b/beacon_chain/networking/libp2p_json_serialization.nim @@ -15,7 +15,7 @@ proc writeValue*( writer.writeValue $value proc readValue*(reader: var JsonReader, value: var PeerId) {. - raises: [Defect, IOError, SerializationError].} = + raises: [IOError, SerializationError].} = let res = PeerId.init reader.readValue(string) if res.isOk: value = res.get() @@ -27,7 +27,7 @@ proc writeValue*( writer.writeValue $value proc readValue*(reader: var JsonReader, value: var MultiAddress) {. - raises: [Defect, IOError, SerializationError].} = + raises: [IOError, SerializationError].} = let res = MultiAddress.init reader.readValue(string) if res.isOk: value = res.value diff --git a/beacon_chain/networking/peer_pool.nim b/beacon_chain/networking/peer_pool.nim index ee799fe7e..36c7dd158 100644 --- a/beacon_chain/networking/peer_pool.nim +++ b/beacon_chain/networking/peer_pool.nim @@ -37,13 +37,13 @@ type PeerIndex = object data: int - cmp: proc(a, b: PeerIndex): bool {.gcsafe, raises: [Defect].} + cmp: proc(a, b: PeerIndex): bool {.gcsafe, raises: [].} - PeerScoreCheckCallback*[T] = proc(peer: T): bool {.gcsafe, raises: [Defect].} + PeerScoreCheckCallback*[T] = proc(peer: T): bool {.gcsafe, raises: [].} - PeerCounterCallback* = proc() {.gcsafe, raises: [Defect].} + PeerCounterCallback* = proc() {.gcsafe, raises: [].} - PeerOnDeleteCallback*[T] = proc(peer: T) {.gcsafe, raises: [Defect].} + PeerOnDeleteCallback*[T] = proc(peer: T) {.gcsafe, raises: [].} PeerPool*[A, B] = ref object incNotEmptyEvent*: AsyncEvent @@ -54,7 +54,7 @@ type outQueue: HeapQueue[PeerIndex] registry: Table[B, PeerIndex] storage: seq[PeerItem[A]] - cmp: proc(a, b: PeerIndex): bool {.gcsafe, raises: [Defect].} + cmp: proc(a, b: PeerIndex): bool {.gcsafe, raises: [].} scoreCheck: PeerScoreCheckCallback[A] onDeletePeer: PeerOnDeleteCallback[A] peerCounter: PeerCounterCallback @@ -544,7 +544,7 @@ proc acquire*[A, B](pool: PeerPool[A, B], proc acquireNoWait*[A, B](pool: PeerPool[A, B], filter = {PeerType.Incoming, PeerType.Outgoing} - ): A {.raises: [PeerPoolError, Defect].} = + ): A {.raises: [PeerPoolError].} = doAssert(filter != {}, "Filter must not be empty") if pool.lenAvailable(filter) < 1: raise newException(PeerPoolError, "Not enough peers in pool") @@ -686,12 +686,12 @@ iterator acquiredPeers*[A, B](pool: PeerPool[A, B], let pindex = sorted.pop().data yield pool.storage[pindex].data -proc `[]`*[A, B](pool: PeerPool[A, B], key: B): A {.inline, raises: [Defect, KeyError].} = +proc `[]`*[A, B](pool: PeerPool[A, B], key: B): A {.inline, raises: [KeyError].} = ## Retrieve peer with key ``key`` from PeerPool ``pool``. let pindex = pool.registry[key] pool.storage[pindex.data] -proc `[]`*[A, B](pool: var PeerPool[A, B], key: B): var A {.inline, raises: [Defect, KeyError].} = +proc `[]`*[A, B](pool: var PeerPool[A, B], key: B): var A {.inline, raises: [KeyError].} = ## Retrieve peer with key ``key`` from PeerPool ``pool``. let pindex = pool.registry[key] pool.storage[pindex.data].data diff --git a/beacon_chain/nimbus_beacon_node.nim b/beacon_chain/nimbus_beacon_node.nim index bcc16c28c..c5e685706 100644 --- a/beacon_chain/nimbus_beacon_node.nim +++ b/beacon_chain/nimbus_beacon_node.nim @@ -463,7 +463,7 @@ proc init*(T: type BeaconNode, rng: ref HmacDrbgContext, config: BeaconNodeConf, metadata: Eth2NetworkMetadata): BeaconNode - {.raises: [Defect, CatchableError].} = + {.raises: [CatchableError].} = var taskpool: TaskPoolPtr template cfg: auto = metadata.cfg @@ -1592,7 +1592,7 @@ proc startBackfillTask(node: BeaconNode) {.async.} = await sleepAsync(chronos.seconds(2)) -proc run(node: BeaconNode) {.raises: [Defect, CatchableError].} = +proc run(node: BeaconNode) {.raises: [CatchableError].} = bnStatus = BeaconNodeStatus.Running if not isNil(node.restServer): @@ -1651,7 +1651,7 @@ proc run(node: BeaconNode) {.raises: [Defect, CatchableError].} = node.stop() var gPidFile: string -proc createPidFile(filename: string) {.raises: [Defect, IOError].} = +proc createPidFile(filename: string) {.raises: [IOError].} = writeFile filename, $os.getCurrentProcessId() gPidFile = filename addQuitProc proc {.noconv.} = discard io2.removeFile(gPidFile) @@ -1667,7 +1667,7 @@ proc initializeNetworking(node: BeaconNode) {.async.} = await node.network.start() -proc start*(node: BeaconNode) {.raises: [Defect, CatchableError].} = +proc start*(node: BeaconNode) {.raises: [CatchableError].} = let head = node.dag.head finalizedHead = node.dag.finalizedHead @@ -1719,7 +1719,7 @@ func formatGwei(amount: uint64): string = result.setLen(result.len - 1) when not defined(windows): - proc initStatusBar(node: BeaconNode) {.raises: [Defect, ValueError].} = + proc initStatusBar(node: BeaconNode) {.raises: [ValueError].} = if not isatty(stdout): return if not node.config.statusBarEnabled: return @@ -1728,7 +1728,7 @@ when not defined(windows): except Exception as exc: # TODO Exception error "Couldn't enable colors", err = exc.msg - proc dataResolver(expr: string): string {.raises: [Defect].} = + proc dataResolver(expr: string): string {.raises: [].} = template justified: untyped = node.dag.head.atEpochStart( getStateField( node.dag.headState, current_justified_checkpoint).epoch) @@ -1812,7 +1812,7 @@ when not defined(windows): let tmp = defaultChroniclesStream.outputs[0].writer defaultChroniclesStream.outputs[0].writer = - proc (logLevel: LogLevel, msg: LogOutputStr) {.raises: [Defect].} = + proc (logLevel: LogLevel, msg: LogOutputStr) {.raises: [].} = try: # p.hidePrompt erase statusBar @@ -1835,7 +1835,7 @@ when not defined(windows): asyncSpawn statusBarUpdatesPollingLoop() -proc doRunBeaconNode(config: var BeaconNodeConf, rng: ref HmacDrbgContext) {.raises: [Defect, CatchableError].} = +proc doRunBeaconNode(config: var BeaconNodeConf, rng: ref HmacDrbgContext) {.raises: [CatchableError].} = info "Launching beacon node", version = fullVersionStr, bls_backend = $BLS_BACKEND, @@ -1907,7 +1907,7 @@ proc doRunBeaconNode(config: var BeaconNodeConf, rng: ref HmacDrbgContext) {.rai node.start() proc doRecord(config: BeaconNodeConf, rng: var HmacDrbgContext) {. - raises: [Defect, CatchableError].} = + raises: [CatchableError].} = case config.recordCmd: of RecordCmd.create: let netKeys = getPersistentNetKeys(rng, config) @@ -1935,7 +1935,7 @@ proc doRecord(config: BeaconNodeConf, rng: var HmacDrbgContext) {. echo $config.recordPrint proc doWeb3Cmd(config: BeaconNodeConf, rng: var HmacDrbgContext) - {.raises: [Defect, CatchableError].} = + {.raises: [CatchableError].} = case config.web3Cmd: of Web3Cmd.test: let metadata = config.loadEth2Network() @@ -1944,7 +1944,7 @@ proc doWeb3Cmd(config: BeaconNodeConf, rng: var HmacDrbgContext) metadata.cfg.DEPOSIT_CONTRACT_ADDRESS, rng.loadJwtSecret(config, allowCreate = true)) -proc doSlashingExport(conf: BeaconNodeConf) {.raises: [IOError, Defect].}= +proc doSlashingExport(conf: BeaconNodeConf) {.raises: [IOError].}= let dir = conf.validatorsDir() filetrunc = SlashingDbName @@ -1955,7 +1955,7 @@ proc doSlashingExport(conf: BeaconNodeConf) {.raises: [IOError, Defect].}= db.exportSlashingInterchange(interchange, conf.exportedValidators) echo "Export finished: '", dir/filetrunc & ".sqlite3" , "' into '", interchange, "'" -proc doSlashingImport(conf: BeaconNodeConf) {.raises: [SerializationError, IOError, Defect].} = +proc doSlashingImport(conf: BeaconNodeConf) {.raises: [SerializationError, IOError].} = let dir = conf.validatorsDir() filetrunc = SlashingDbName @@ -1990,14 +1990,14 @@ proc doSlashingImport(conf: BeaconNodeConf) {.raises: [SerializationError, IOErr echo "Import finished: '", interchange, "' into '", dir/filetrunc & ".sqlite3", "'" -proc doSlashingInterchange(conf: BeaconNodeConf) {.raises: [Defect, CatchableError].} = +proc doSlashingInterchange(conf: BeaconNodeConf) {.raises: [CatchableError].} = case conf.slashingdbCmd of SlashProtCmd.`export`: conf.doSlashingExport() of SlashProtCmd.`import`: conf.doSlashingImport() -proc handleStartUpCmd(config: var BeaconNodeConf) {.raises: [Defect, CatchableError].} = +proc handleStartUpCmd(config: var BeaconNodeConf) {.raises: [CatchableError].} = # Single RNG instance for the application - will be seeded on construction # and avoid using system resources (such as urandom) after that let rng = HmacDrbgContext.new() diff --git a/beacon_chain/nimbus_binary_common.nim b/beacon_chain/nimbus_binary_common.nim index edf8f4e68..2a019ba7f 100644 --- a/beacon_chain/nimbus_binary_common.nim +++ b/beacon_chain/nimbus_binary_common.nim @@ -38,7 +38,7 @@ export type SlotStartProc*[T] = proc(node: T, wallTime: BeaconTime, lastSlot: Slot): Future[bool] {.gcsafe, - raises: [Defect].} + raises: [].} # silly chronicles, colors is a compile-time property proc stripAnsi(v: string): string = @@ -76,7 +76,7 @@ proc stripAnsi(v: string): string = res -proc updateLogLevel*(logLevel: string) {.raises: [Defect, ValueError].} = +proc updateLogLevel*(logLevel: string) {.raises: [ValueError].} = # Updates log levels (without clearing old ones) let directives = logLevel.split(";") try: @@ -388,7 +388,7 @@ type proc initKeymanagerServer*( config: AnyConf, existingRestServer: RestServerRef = nil): KeymanagerInitResult - {.raises: [Defect].} = + {.raises: [].} = var token: string let keymanagerServer = if config.keymanagerEnabled: diff --git a/beacon_chain/rpc/rest_key_management_api.nim b/beacon_chain/rpc/rest_key_management_api.nim index 8e9335639..b6f9f5b99 100644 --- a/beacon_chain/rpc/rest_key_management_api.nim +++ b/beacon_chain/rpc/rest_key_management_api.nim @@ -24,7 +24,7 @@ func validateKeymanagerApiQueries*(key: string, value: string): int = return 0 proc listLocalValidators*(validatorPool: ValidatorPool): seq[KeystoreInfo] {. - raises: [Defect].} = + raises: [].} = var validators: seq[KeystoreInfo] for item in validatorPool: if item.kind == ValidatorKind.Local: @@ -37,7 +37,7 @@ proc listLocalValidators*(validatorPool: ValidatorPool): seq[KeystoreInfo] {. proc listRemoteValidators*( validatorPool: ValidatorPool): seq[RemoteKeystoreInfo] {. - raises: [Defect].} = + raises: [].} = var validators: seq[RemoteKeystoreInfo] for item in validatorPool: if item.kind == ValidatorKind.Remote and item.data.remotes.len == 1: @@ -49,7 +49,7 @@ proc listRemoteValidators*( proc listRemoteDistributedValidators*( validatorPool: ValidatorPool): seq[DistributedKeystoreInfo] {. - raises: [Defect].} = + raises: [].} = var validators: seq[DistributedKeystoreInfo] for item in validatorPool: if item.kind == ValidatorKind.Remote and item.data.remotes.len > 1: diff --git a/beacon_chain/spec/beacon_time.nim b/beacon_chain/spec/beacon_time.nim index 9fc0200f6..cd854edda 100644 --- a/beacon_chain/spec/beacon_time.nim +++ b/beacon_chain/spec/beacon_time.nim @@ -97,7 +97,7 @@ template ethTimeUnit*(typ: type) {.dirty.} = writeValue(writer, uint64 value) proc readValue*(reader: var JsonReader, value: var typ) - {.raises: [IOError, SerializationError, Defect].} = + {.raises: [IOError, SerializationError].} = value = typ reader.readValue(uint64) ethTimeUnit Slot diff --git a/beacon_chain/spec/crypto.nim b/beacon_chain/spec/crypto.nim index b9a01ca3e..05c3334f1 100644 --- a/beacon_chain/spec/crypto.nim +++ b/beacon_chain/spec/crypto.nim @@ -456,7 +456,7 @@ template `<`*(x, y: ValidatorPubKey): bool = # Serialization # ---------------------------------------------------------------------- -{.pragma: serializationRaises, raises: [SerializationError, IOError, Defect].} +{.pragma: serializationRaises, raises: [SerializationError, IOError].} proc writeValue*( writer: var JsonWriter, value: ValidatorPubKey | CookedPubKey @@ -532,21 +532,21 @@ func shortLog*(x: TrustedSig): string = # TODO more specific exceptions? don't raise? # For confutils -func init*(T: typedesc[ValidatorPrivKey], hex: string): T {.noinit, raises: [ValueError, Defect].} = +func init*(T: typedesc[ValidatorPrivKey], hex: string): T {.noinit, raises: [ValueError].} = let v = T.fromHex(hex) if v.isErr: raise (ref ValueError)(msg: $v.error) v[] # For mainchain monitor -func init*(T: typedesc[ValidatorPubKey], data: array[RawPubKeySize, byte]): T {.noinit, raises: [ValueError, Defect].} = +func init*(T: typedesc[ValidatorPubKey], data: array[RawPubKeySize, byte]): T {.noinit, raises: [ValueError].} = let v = T.fromRaw(data) if v.isErr: raise (ref ValueError)(msg: $v.error) v[] # For mainchain monitor -func init*(T: typedesc[ValidatorSig], data: array[RawSigSize, byte]): T {.noinit, raises: [ValueError, Defect].} = +func init*(T: typedesc[ValidatorSig], data: array[RawSigSize, byte]): T {.noinit, raises: [ValueError].} = let v = T.fromRaw(data) if v.isErr: raise (ref ValueError)(msg: $v.error) diff --git a/beacon_chain/spec/datatypes/base.nim b/beacon_chain/spec/datatypes/base.nim index b1e7fb9e5..ab294570c 100644 --- a/beacon_chain/spec/datatypes/base.nim +++ b/beacon_chain/spec/datatypes/base.nim @@ -566,7 +566,7 @@ template makeLimitedUInt*(T: untyped, limit: SomeUnsignedInt) = writeValue(writer, distinctBase value) proc readValue*(reader: var JsonReader, value: var T) - {.raises: [IOError, SerializationError, Defect].} = + {.raises: [IOError, SerializationError].} = let v = T.init(reader.readValue(uint64)) if v.isSome(): value = v.get() @@ -637,7 +637,7 @@ template writeValue*( proc readValue*( reader: var JsonReader, value: var (Version | ForkDigest | DomainType)) - {.raises: [IOError, SerializationError, Defect].} = + {.raises: [IOError, SerializationError].} = let hex = reader.readValue(string) try: hexToByteArray(hex, distinctBase(value)) @@ -649,7 +649,7 @@ func `$`*(x: JustificationBits): string = "0x" & toHex(uint64(uint8(x))) proc readValue*(reader: var JsonReader, value: var JustificationBits) - {.raises: [IOError, SerializationError, Defect].} = + {.raises: [IOError, SerializationError].} = let hex = reader.readValue(string) try: value = JustificationBits(hexToByteArray(hex, 1)[0]) @@ -847,7 +847,7 @@ func toPrettyString*(bytes: openArray[byte]): string = func `$`*(value: GraffitiBytes): string = toPrettyString(distinctBase value) func init*(T: type GraffitiBytes, input: string): GraffitiBytes - {.raises: [ValueError, Defect].} = + {.raises: [ValueError].} = if input.len > 2 and input[0] == '0' and input[1] == 'x': if input.len > sizeof(GraffitiBytes) * 2 + 2: raise newException(ValueError, "The graffiti bytes should be less than 32") @@ -891,7 +891,7 @@ template `==`*(lhs, rhs: GraffitiBytes): bool = distinctBase(lhs) == distinctBase(rhs) proc readValue*(r: var JsonReader, T: type GraffitiBytes): T - {.raises: [IOError, SerializationError, Defect].} = + {.raises: [IOError, SerializationError].} = try: init(GraffitiBytes, r.readValue(string)) except ValueError as err: diff --git a/beacon_chain/spec/datatypes/bellatrix.nim b/beacon_chain/spec/datatypes/bellatrix.nim index e78c1a3f8..23847e44f 100644 --- a/beacon_chain/spec/datatypes/bellatrix.nim +++ b/beacon_chain/spec/datatypes/bellatrix.nim @@ -95,7 +95,7 @@ type transactions_root*: Eth2Digest ExecutePayload* = proc( - execution_payload: ExecutionPayload): bool {.gcsafe, raises: [Defect].} + execution_payload: ExecutionPayload): bool {.gcsafe, raises: [].} # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/bellatrix/fork-choice.md#powblock PowBlock* = object @@ -363,11 +363,11 @@ func initHashedBeaconState*(s: BeaconState): HashedBeaconState = HashedBeaconState(data: s) func fromHex*(T: typedesc[BloomLogs], s: string): T {. - raises: [Defect, ValueError].} = + raises: [ValueError].} = hexToByteArray(s, result.data) func fromHex*(T: typedesc[ExecutionAddress], s: string): T {. - raises: [Defect, ValueError].} = + raises: [ValueError].} = hexToByteArray(s, result.data) proc writeValue*( @@ -375,7 +375,7 @@ proc writeValue*( writer.writeValue to0xHex(value.data) proc readValue*(reader: var JsonReader, value: var ExecutionAddress) {. - raises: [Defect, IOError, SerializationError].} = + raises: [IOError, SerializationError].} = try: hexToByteArray(reader.readValue(string), value.data) except ValueError: diff --git a/beacon_chain/spec/datatypes/capella.nim b/beacon_chain/spec/datatypes/capella.nim index 22ed48cbc..cb8a59422 100644 --- a/beacon_chain/spec/datatypes/capella.nim +++ b/beacon_chain/spec/datatypes/capella.nim @@ -117,7 +117,7 @@ type ## [New in Capella] ExecutePayload* = proc( - execution_payload: ExecutionPayload): bool {.gcsafe, raises: [Defect].} + execution_payload: ExecutionPayload): bool {.gcsafe, raises: [].} ExecutionBranch* = array[log2trunc(EXECUTION_PAYLOAD_INDEX), Eth2Digest] diff --git a/beacon_chain/spec/datatypes/deneb.nim b/beacon_chain/spec/datatypes/deneb.nim index 4a473a7ec..4e393f9c6 100644 --- a/beacon_chain/spec/datatypes/deneb.nim +++ b/beacon_chain/spec/datatypes/deneb.nim @@ -134,7 +134,7 @@ type excess_blob_gas*: uint64 # [New in Deneb] ExecutePayload* = proc( - execution_payload: ExecutionPayload): bool {.gcsafe, raises: [Defect].} + execution_payload: ExecutionPayload): bool {.gcsafe, raises: [].} # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/light-client/sync-protocol.md#modified-lightclientheader LightClientHeader* = object diff --git a/beacon_chain/spec/digest.nim b/beacon_chain/spec/digest.nim index ebfd73c05..8d216c438 100644 --- a/beacon_chain/spec/digest.nim +++ b/beacon_chain/spec/digest.nim @@ -148,14 +148,14 @@ func isZero*(x: Eth2Digest): bool = proc writeValue*(w: var JsonWriter, a: Eth2Digest) {.raises: [IOError].} = w.writeValue $a -proc readValue*(r: var JsonReader, a: var Eth2Digest) {.raises: [Defect, IOError, SerializationError].} = +proc readValue*(r: var JsonReader, a: var Eth2Digest) {.raises: [IOError, SerializationError].} = try: a = fromHex(type(a), r.readValue(string)) except ValueError: raiseUnexpectedValue(r, "Hex string expected") func strictParse*(T: type Eth2Digest, hexStr: openArray[char]): T - {.raises: [Defect, ValueError].} = + {.raises: [ValueError].} = ## TODO We use this local definition because the string parsing functions ## provided by nimcrypto are currently too lax in their requirements ## for the input string. Invalid strings are silently ignored. diff --git a/beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim b/beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim index a27be8bf1..423405a8e 100644 --- a/beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim +++ b/beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim @@ -578,7 +578,7 @@ proc writeValue*( writeValue(w, Base10.toString(value)) proc readValue*(reader: var JsonReader[RestJson], value: var uint64) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = let svalue = reader.readValue(string) let res = Base10.decode(uint64, svalue) if res.isOk(): @@ -592,7 +592,7 @@ proc writeValue*( writeValue(w, Base10.toString(value)) proc readValue*(reader: var JsonReader[RestJson], value: var uint8) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = let svalue = reader.readValue(string) let res = Base10.decode(uint8, svalue) if res.isOk(): @@ -607,7 +607,7 @@ proc writeValue*( w.writeValue hexOriginal([uint8(value)]) proc readValue*(reader: var JsonReader[RestJson], value: var JustificationBits) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = let hex = reader.readValue(string) try: value = JustificationBits(hexToByteArray(hex, 1)[0]) @@ -621,7 +621,7 @@ proc writeValue*( writeValue(w, toString(value)) proc readValue*(reader: var JsonReader[RestJson], value: var UInt256) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = let svalue = reader.readValue(string) try: value = parse(svalue, UInt256, 10) @@ -635,7 +635,7 @@ proc writeValue*( writeValue(writer, Base10.toString(uint64(value))) proc readValue*(reader: var JsonReader[RestJson], value: var Slot) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = let svalue = reader.readValue(string) let res = Base10.decode(uint64, svalue) if res.isOk(): @@ -649,7 +649,7 @@ proc writeValue*( writeValue(writer, Base10.toString(uint64(value))) proc readValue*(reader: var JsonReader[RestJson], value: var Epoch) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = let svalue = reader.readValue(string) let res = Base10.decode(uint64, svalue) if res.isOk(): @@ -666,7 +666,7 @@ proc writeValue*( proc readValue*(reader: var JsonReader[RestJson], epochFlags: var EpochParticipationFlags) - {.raises: [SerializationError, IOError, Defect].} = + {.raises: [SerializationError, IOError].} = for e in reader.readArray(string): let parsed = try: parseBiggestUInt(e) @@ -689,7 +689,7 @@ proc writeValue*( writeValue(writer, Base10.toString(uint64(value))) proc readValue*(reader: var JsonReader[RestJson], value: var ValidatorIndex) - {.raises: [IOError, SerializationError, Defect].} = + {.raises: [IOError, SerializationError].} = let svalue = reader.readValue(string) let res = Base10.decode(uint64, svalue) if res.isOk(): @@ -709,7 +709,7 @@ proc writeValue*( writeValue(writer, Base10.toString(distinctBase(value))) proc readValue*(reader: var JsonReader[RestJson], value: var IndexInSyncCommittee) - {.raises: [IOError, SerializationError, Defect].} = + {.raises: [IOError, SerializationError].} = let svalue = reader.readValue(string) let res = Base10.decode(uint64, svalue) if res.isOk(): @@ -730,7 +730,7 @@ proc writeValue*( proc readValue*(reader: var JsonReader[RestJson], value: var RestValidatorIndex) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = let svalue = reader.readValue(string) let res = Base10.decode(uint64, svalue) if res.isOk(): @@ -746,7 +746,7 @@ proc writeValue*( writeValue(writer, value.asUInt64) proc readValue*(reader: var JsonReader[RestJson], value: var CommitteeIndex) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = var v: uint64 reader.readValue(v) @@ -763,7 +763,7 @@ proc writeValue*( writeValue(writer, hexOriginal(toRaw(value))) proc readValue*(reader: var JsonReader[RestJson], value: var ValidatorSig) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = let hexValue = reader.readValue(string) let res = ValidatorSig.fromHex(hexValue) if res.isOk(): @@ -778,7 +778,7 @@ proc writeValue*( writeValue(writer, hexOriginal(toRaw(value))) proc readValue*(reader: var JsonReader[RestJson], value: var TrustedSig) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = let hexValue = reader.readValue(string) let res = ValidatorSig.fromHex(hexValue) if res.isOk(): @@ -793,7 +793,7 @@ proc writeValue*( writeValue(writer, hexOriginal(toRaw(value))) proc readValue*(reader: var JsonReader[RestJson], value: var ValidatorPubKey) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = let hexValue = reader.readValue(string) let res = ValidatorPubKey.fromHex(hexValue) if res.isOk(): @@ -803,7 +803,7 @@ proc readValue*(reader: var JsonReader[RestJson], value: var ValidatorPubKey) {. ## BitSeq proc readValue*(reader: var JsonReader[RestJson], value: var BitSeq) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = try: value = BitSeq hexToSeqByte(reader.readValue(string)) except ValueError: @@ -815,7 +815,7 @@ proc writeValue*( ## BitList proc readValue*(reader: var JsonReader[RestJson], value: var BitList) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = type T = type(value) value = T readValue(reader, BitSeq) @@ -825,7 +825,7 @@ proc writeValue*( ## BitArray proc readValue*(reader: var JsonReader[RestJson], value: var BitArray) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = try: hexToByteArray(readValue(reader, string), value.bytes) except ValueError: @@ -838,7 +838,7 @@ proc writeValue*( ## BlockHash proc readValue*(reader: var JsonReader[RestJson], value: var BlockHash) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = try: hexToByteArray(reader.readValue(string), distinctBase(value)) except ValueError: @@ -851,7 +851,7 @@ proc writeValue*( ## Eth2Digest proc readValue*(reader: var JsonReader[RestJson], value: var Eth2Digest) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = try: hexToByteArray(reader.readValue(string), value.data) except ValueError: @@ -864,7 +864,7 @@ proc writeValue*( ## BloomLogs proc readValue*(reader: var JsonReader[RestJson], value: var BloomLogs) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = try: hexToByteArray(reader.readValue(string), value.data) except ValueError: @@ -877,7 +877,7 @@ proc writeValue*( ## HashArray proc readValue*(reader: var JsonReader[RestJson], value: var HashArray) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = readValue(reader, value.data) proc writeValue*( @@ -886,7 +886,7 @@ proc writeValue*( ## HashList proc readValue*(reader: var JsonReader[RestJson], value: var HashList) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = readValue(reader, value.data) value.resetCache() @@ -896,7 +896,7 @@ proc writeValue*( ## Eth1Address proc readValue*(reader: var JsonReader[RestJson], value: var Eth1Address) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = try: hexToByteArray(reader.readValue(string), distinctBase(value)) except ValueError: @@ -915,7 +915,7 @@ proc writeValue*( writeValue(writer, hexOriginal(distinctBase(value))) proc readValue*(reader: var JsonReader[RestJson], T: type GraffitiBytes): T - {.raises: [IOError, SerializationError, Defect].} = + {.raises: [IOError, SerializationError].} = try: init(GraffitiBytes, reader.readValue(string)) except ValueError as err: @@ -925,7 +925,7 @@ proc readValue*(reader: var JsonReader[RestJson], T: type GraffitiBytes): T proc readValue*( reader: var JsonReader[RestJson], value: var (Version | ForkDigest | DomainType | GraffitiBytes)) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = try: hexToByteArray(reader.readValue(string), distinctBase(value)) except ValueError: @@ -980,7 +980,7 @@ template prepareForkedBlockReading( proc readValue*[BlockType: ForkedBeaconBlock]( reader: var JsonReader[RestJson], - value: var BlockType) {.raises: [IOError, SerializationError, Defect].} = + value: var BlockType) {.raises: [IOError, SerializationError].} = var version: Option[ConsensusFork] data: Option[JsonString] @@ -1051,7 +1051,7 @@ proc readValue*[BlockType: ForkedBeaconBlock]( proc readValue*[BlockType: ProduceBlockResponseV2]( reader: var JsonReader[RestJson], - value: var BlockType) {.raises: [IOError, SerializationError, Defect].} = + value: var BlockType) {.raises: [IOError, SerializationError].} = var version: Option[ConsensusFork] data: Option[JsonString] @@ -1128,7 +1128,7 @@ proc readValue*[BlockType: ProduceBlockResponseV2]( proc readValue*[BlockType: ForkedBlindedBeaconBlock]( reader: var JsonReader[RestJson], value: var BlockType - ) {.raises: [IOError, SerializationError, Defect].} = + ) {.raises: [IOError, SerializationError].} = var version: Option[ConsensusFork] data: Option[JsonString] @@ -1190,7 +1190,7 @@ proc readValue*[BlockType: ForkedBlindedBeaconBlock]( proc readValue*[BlockType: Web3SignerForkedBeaconBlock]( reader: var JsonReader[RestJson], - value: var BlockType) {.raises: [IOError, SerializationError, Defect].} = + value: var BlockType) {.raises: [IOError, SerializationError].} = var version: Option[ConsensusFork] data: Option[JsonString] @@ -1253,7 +1253,7 @@ proc writeValue*[BlockType: ForkedBeaconBlock]( ## RestPublishedBeaconBlockBody proc readValue*(reader: var JsonReader[RestJson], value: var RestPublishedBeaconBlockBody) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = var randao_reveal: Option[ValidatorSig] eth1_data: Option[Eth1Data] @@ -1490,7 +1490,7 @@ proc readValue*(reader: var JsonReader[RestJson], ## RestPublishedBeaconBlock proc readValue*(reader: var JsonReader[RestJson], value: var RestPublishedBeaconBlock) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = var slot: Option[Slot] proposer_index: Option[uint64] @@ -1597,7 +1597,7 @@ proc readValue*(reader: var JsonReader[RestJson], ## RestPublishedSignedBeaconBlock proc readValue*(reader: var JsonReader[RestJson], value: var RestPublishedSignedBeaconBlock) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = var signature: Option[ValidatorSig] var message: Option[RestPublishedBeaconBlock] for fieldName in readObjectFields(reader): @@ -1662,7 +1662,7 @@ proc readValue*(reader: var JsonReader[RestJson], proc readValue*(reader: var JsonReader[RestJson], value: var RestPublishedSignedBlockContents) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = var signature: Option[ValidatorSig] var message: Option[RestPublishedBeaconBlock] var signed_message: Option[RestPublishedSignedBeaconBlock] @@ -1786,7 +1786,7 @@ proc readValue*(reader: var JsonReader[RestJson], ## ForkedSignedBeaconBlock proc readValue*(reader: var JsonReader[RestJson], value: var ForkedSignedBeaconBlock) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = var version: Option[ConsensusFork] data: Option[JsonString] @@ -1914,7 +1914,7 @@ proc writeValue*( # be used, mainly because caching the hash early on is easier to do proc readValue*(reader: var JsonReader[RestJson], value: var ForkedHashedBeaconState) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = var version: Option[ConsensusFork] data: Option[JsonString] @@ -2037,7 +2037,7 @@ proc writeValue*( ## SomeForkedLightClientObject proc readValue*[T: SomeForkedLightClientObject]( reader: var JsonReader[RestJson], value: var T) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = var version: Opt[ConsensusFork] data: Opt[JsonString] @@ -2180,7 +2180,7 @@ proc writeValue*( proc readValue*(reader: var JsonReader[RestJson], value: var Web3SignerRequest) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = var requestKind: Option[Web3SignerRequestKind] forkInfo: Option[Web3SignerForkInfo] @@ -2458,7 +2458,7 @@ proc writeValue*( proc readValue*(reader: var JsonReader[RestJson], value: var RemoteKeystoreStatus) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = var message: Option[string] var status: Option[KeystoreStatus] @@ -2501,7 +2501,7 @@ proc readValue*(reader: var JsonReader[RestJson], ## ScryptSalt proc readValue*(reader: var JsonReader[RestJson], value: var ScryptSalt) {. - raises: [SerializationError, IOError, Defect].} = + raises: [SerializationError, IOError].} = let res = ncrutils.fromHex(reader.readValue(string)) if len(res) == 0: reader.raiseUnexpectedValue("Invalid scrypt salt value") @@ -2519,7 +2519,7 @@ proc writeValue*( writer.endRecord() proc readValue*(reader: var JsonReader[RestJson], value: var Pbkdf2Params) {. - raises: [SerializationError, IOError, Defect].} = + raises: [SerializationError, IOError].} = var dklen: Option[uint64] c: Option[uint64] @@ -2580,7 +2580,7 @@ proc writeValue*( writer.endRecord() proc readValue*(reader: var JsonReader[RestJson], value: var ScryptParams) {. - raises: [SerializationError, IOError, Defect].} = + raises: [SerializationError, IOError].} = var dklen: Option[uint64] n, p, r: Option[int] @@ -2673,7 +2673,7 @@ proc writeValue*( proc readValue*(reader: var JsonReader[RestJson], value: var KeystoresAndSlashingProtection) {. - raises: [SerializationError, IOError, Defect].} = + raises: [SerializationError, IOError].} = var strKeystores: seq[string] passwords: seq[string] @@ -2743,7 +2743,7 @@ proc writeValue*( proc readValue*(reader: var JsonReader[RestJson], value: var RestActivityItem) {. - raises: [SerializationError, IOError, Defect].} = + raises: [SerializationError, IOError].} = var index: Option[ValidatorIndex] var epoch: Option[Epoch] var active: Option[bool] @@ -2789,7 +2789,7 @@ proc writeValue*( proc readValue*(reader: var JsonReader[RestJson], value: var RestLivenessItem) {. - raises: [SerializationError, IOError, Defect].} = + raises: [SerializationError, IOError].} = var index: Option[ValidatorIndex] var isLive: Option[bool] @@ -2893,7 +2893,7 @@ proc writeValue*( ## RestErrorMessage proc readValue*(reader: var JsonReader[RestJson], value: var RestErrorMessage) {. - raises: [SerializationError, IOError, Defect].} = + raises: [SerializationError, IOError].} = var code: Opt[int] message: Opt[string] @@ -2950,7 +2950,7 @@ proc readValue*(reader: var JsonReader[RestJson], ## VCRuntimeConfig proc readValue*(reader: var JsonReader[RestJson], value: var VCRuntimeConfig) {. - raises: [SerializationError, IOError, Defect].} = + raises: [SerializationError, IOError].} = for fieldName in readObjectFields(reader): let fieldValue = reader.readValue(string) if value.hasKeyOrPut(toUpperAscii(fieldName), fieldValue): diff --git a/beacon_chain/spec/eth2_apis/rest_common.nim b/beacon_chain/spec/eth2_apis/rest_common.nim index 15027b5e3..f0bcd8380 100644 --- a/beacon_chain/spec/eth2_apis/rest_common.nim +++ b/beacon_chain/spec/eth2_apis/rest_common.nim @@ -16,7 +16,7 @@ from std/times import Time, DateTime, toTime, fromUnix, now, utc, `-`, export chronos, client, rest_types, eth2_rest_serialization proc raiseGenericError*(resp: RestPlainResponse) {. - noreturn, raises: [RestError, Defect].} = + noreturn, raises: [RestError].} = let error = block: let res = decodeBytes(RestErrorMessage, resp.data, resp.contentType) @@ -29,7 +29,7 @@ proc raiseGenericError*(resp: RestPlainResponse) {. raise newException(RestError, msg) proc raiseUnknownStatusError*(resp: RestPlainResponse) {. - noreturn, raises: [RestError, Defect].} = + noreturn, raises: [RestError].} = let msg = "Unknown response status error (" & $resp.status & ")" raise newException(RestError, msg) diff --git a/beacon_chain/spec/eth2_apis/rest_event_calls.nim b/beacon_chain/spec/eth2_apis/rest_event_calls.nim index 15144ed9d..e086ee855 100644 --- a/beacon_chain/spec/eth2_apis/rest_event_calls.nim +++ b/beacon_chain/spec/eth2_apis/rest_event_calls.nim @@ -4,7 +4,7 @@ # * 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. -{.push raises: [Defect].} +{.push raises: [].} import chronos, presto/client, diff --git a/beacon_chain/spec/eth2_apis/rest_keymanager_calls.nim b/beacon_chain/spec/eth2_apis/rest_keymanager_calls.nim index af0c27a95..396f8e483 100644 --- a/beacon_chain/spec/eth2_apis/rest_keymanager_calls.nim +++ b/beacon_chain/spec/eth2_apis/rest_keymanager_calls.nim @@ -21,7 +21,7 @@ KeyPath.serializesAsBaseIn RestJson WalletName.serializesAsBaseIn RestJson proc raiseKeymanagerGenericError*(resp: RestPlainResponse) {. - noreturn, raises: [RestError, Defect].} = + noreturn, raises: [RestError].} = let error = block: let res = decodeBytes(KeymanagerGenericError, resp.data, resp.contentType) diff --git a/beacon_chain/spec/eth2_apis/rest_nimbus_calls.nim b/beacon_chain/spec/eth2_apis/rest_nimbus_calls.nim index a3a275fc3..c351b0b05 100644 --- a/beacon_chain/spec/eth2_apis/rest_nimbus_calls.nim +++ b/beacon_chain/spec/eth2_apis/rest_nimbus_calls.nim @@ -4,7 +4,7 @@ # * 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. -{.push raises: [Defect].} +{.push raises: [].} import chronos, chronicles, presto/client, diff --git a/beacon_chain/spec/eth2_ssz_serialization.nim b/beacon_chain/spec/eth2_ssz_serialization.nim index 6bb3bd6c5..94cb9325f 100644 --- a/beacon_chain/spec/eth2_ssz_serialization.nim +++ b/beacon_chain/spec/eth2_ssz_serialization.nim @@ -21,7 +21,7 @@ from ./datatypes/deneb import SignedBeaconBlock, TrustedSignedBeaconBlock export phase0, altair, ssz_codec, ssz_serialization, eth2_merkleization proc readAndUpdateRoot(data: openArray[byte], val: var auto, updateRoot = true) {. - raises: [Defect, MalformedSszError, SszSizeMismatchError].} = + raises: [MalformedSszError, SszSizeMismatchError].} = readSszValue(data, val) if updateRoot: val.root = hash_tree_root(val.message) @@ -65,7 +65,7 @@ template readSszBytes*( readSszValue(data, val) func readSszBytes(T: type, data: openArray[byte], updateRoot = true): T {. - raises: [Defect, MalformedSszError, SszSizeMismatchError].} = + raises: [MalformedSszError, SszSizeMismatchError].} = var res: T readSszBytes(data, res, updateRoot) res diff --git a/beacon_chain/spec/forks.nim b/beacon_chain/spec/forks.nim index 55fc08d4c..9953964a2 100644 --- a/beacon_chain/spec/forks.nim +++ b/beacon_chain/spec/forks.nim @@ -963,7 +963,7 @@ type func readSszForkedHashedBeaconState*( consensusFork: ConsensusFork, data: openArray[byte]): - ForkedHashedBeaconState {.raises: [Defect, SszError].} = + ForkedHashedBeaconState {.raises: [SszError].} = # TODO https://github.com/nim-lang/Nim/issues/19357 result = ForkedHashedBeaconState(kind: consensusFork) diff --git a/beacon_chain/spec/keystore.nim b/beacon_chain/spec/keystore.nim index 4dbc489fd..b68e46fd9 100644 --- a/beacon_chain/spec/keystore.nim +++ b/beacon_chain/spec/keystore.nim @@ -518,13 +518,13 @@ proc shaChecksum(key, cipher: openArray[byte]): Sha256Digest = ctx.clear() proc writeJsonHexString(s: OutputStream, data: openArray[byte]) - {.raises: [IOError, Defect].} = + {.raises: [IOError].} = s.write '"' s.write ncrutils.toHex(data, {HexFlags.LowerCase}) s.write '"' proc readValue*(r: var JsonReader, value: var Pbkdf2Salt) - {.raises: [SerializationError, IOError, Defect].} = + {.raises: [SerializationError, IOError].} = let s = r.readValue(string) if s.len == 0 or s.len mod 16 != 0: @@ -538,7 +538,7 @@ proc readValue*(r: var JsonReader, value: var Pbkdf2Salt) "The Pbkdf2Salt must be a valid hex string") proc readValue*(r: var JsonReader, value: var Aes128CtrIv) - {.raises: [SerializationError, IOError, Defect].} = + {.raises: [SerializationError, IOError].} = let s = r.readValue(string) if s.len != 32: @@ -551,7 +551,7 @@ proc readValue*(r: var JsonReader, value: var Aes128CtrIv) "The aes-128-ctr IV must be a valid hex string") proc readValue*[T: SimpleHexEncodedTypes](r: var JsonReader, value: var T) {. - raises: [SerializationError, IOError, Defect].} = + raises: [SerializationError, IOError].} = value = T ncrutils.fromHex(r.readValue(string)) if len(seq[byte](value)) == 0: r.raiseUnexpectedValue("Valid hex string expected") @@ -688,7 +688,7 @@ proc readValue*(r: var JsonReader, value: var (Checksum|Cipher|Kdf)) = # HttpHostUri proc readValue*(reader: var JsonReader, value: var HttpHostUri) {. - raises: [IOError, SerializationError, Defect].} = + raises: [IOError, SerializationError].} = let svalue = reader.readValue(string) let res = parseUri(svalue) if res.scheme != "http" and res.scheme != "https": @@ -726,7 +726,7 @@ template writeValue*(w: var JsonWriter, writeJsonHexString(w.stream, distinctBase value) proc readValue*(reader: var JsonReader, value: var RemoteKeystore) - {.raises: [SerializationError, IOError, Defect].} = + {.raises: [SerializationError, IOError].} = var version: Option[uint64] description: Option[string] @@ -1181,7 +1181,7 @@ proc writeValue*( {HexFlags.LowerCase})) proc readValue*(reader: var JsonReader, value: var lcrypto.PublicKey) {. - raises: [SerializationError, IOError, Defect].} = + raises: [SerializationError, IOError].} = let res = init(lcrypto.PublicKey, reader.readValue(string)) if res.isOk(): value = res.get() diff --git a/beacon_chain/spec/network.nim b/beacon_chain/spec/network.nim index 1d46a7b21..a71f18ef0 100644 --- a/beacon_chain/spec/network.nim +++ b/beacon_chain/spec/network.nim @@ -205,7 +205,7 @@ func nearSyncCommitteePeriod*(epoch: Epoch): Opt[uint64] = func getSyncSubnets*( nodeHasPubkey: proc(pubkey: ValidatorPubKey): - bool {.noSideEffect, raises: [Defect].}, + bool {.noSideEffect, raises: [].}, syncCommittee: SyncCommittee): SyncnetBits = var res: SyncnetBits for i, pubkey in syncCommittee.pubkeys: diff --git a/beacon_chain/spec/presets.nim b/beacon_chain/spec/presets.nim index 6a037f030..277d017b5 100644 --- a/beacon_chain/spec/presets.nim +++ b/beacon_chain/spec/presets.nim @@ -428,7 +428,7 @@ else: const SLOTS_PER_SYNC_COMMITTEE_PERIOD* = SLOTS_PER_EPOCH * EPOCHS_PER_SYNC_COMMITTEE_PERIOD -func parse(T: type uint64, input: string): T {.raises: [ValueError, Defect].} = +func parse(T: type uint64, input: string): T {.raises: [ValueError].} = var res: BiggestUInt if input.len > 2 and input[0] == '0' and input[1] == 'x': if parseHex(input, res) != input.len: @@ -443,7 +443,7 @@ template parse(T: type byte, input: string): T = byte parse(uint64, input) func parse(T: type Version, input: string): T - {.raises: [ValueError, Defect].} = + {.raises: [ValueError].} = Version hexToByteArray(input, 4) template parse(T: type Slot, input: string): T = @@ -465,12 +465,12 @@ template parse(T: type UInt256, input: string): T = parse(input, UInt256, 10) func parse(T: type DomainType, input: string): T - {.raises: [ValueError, Defect].} = + {.raises: [ValueError].} = DomainType hexToByteArray(input, 4) proc readRuntimeConfig*( fileContent: string, path: string): (RuntimeConfig, seq[string]) {. - raises: [IOError, PresetFileError, PresetIncompatibleError, Defect].} = + raises: [IOError, PresetFileError, PresetIncompatibleError].} = var lineNum = 0 cfg = defaultRuntimeConfig @@ -612,7 +612,7 @@ proc readRuntimeConfig*( proc readRuntimeConfig*( path: string): (RuntimeConfig, seq[string]) {. - raises: [IOError, PresetFileError, PresetIncompatibleError, Defect].} = + raises: [IOError, PresetFileError, PresetIncompatibleError].} = readRuntimeConfig(readFile(path), path) template name*(cfg: RuntimeConfig): string = diff --git a/beacon_chain/spec/ssz_codec.nim b/beacon_chain/spec/ssz_codec.nim index ea63f946b..e03f740f4 100644 --- a/beacon_chain/spec/ssz_codec.nim +++ b/beacon_chain/spec/ssz_codec.nim @@ -6,7 +6,7 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. {.push raises: [].} -{.pragma: raisesssz, raises: [Defect, MalformedSszError, SszSizeMismatchError].} +{.pragma: raisesssz, raises: [MalformedSszError, SszSizeMismatchError].} import std/[typetraits], diff --git a/beacon_chain/spec/state_transition.nim b/beacon_chain/spec/state_transition.nim index 99e2eac4a..7be206c92 100644 --- a/beacon_chain/spec/state_transition.nim +++ b/beacon_chain/spec/state_transition.nim @@ -89,9 +89,9 @@ func verifyStateRoot( ok() type - RollbackProc* = proc() {.gcsafe, noSideEffect, raises: [Defect].} + RollbackProc* = proc() {.gcsafe, noSideEffect, raises: [].} RollbackHashedProc*[T] = - proc(state: var T) {.gcsafe, noSideEffect, raises: [Defect].} + proc(state: var T) {.gcsafe, noSideEffect, raises: [].} RollbackForkedHashedProc* = RollbackHashedProc[ForkedHashedBeaconState] func noRollback*() = diff --git a/beacon_chain/statusbar.nim b/beacon_chain/statusbar.nim index 0887079d0..276b945dc 100644 --- a/beacon_chain/statusbar.nim +++ b/beacon_chain/statusbar.nim @@ -22,7 +22,7 @@ type cellsRight: seq[StatusBarCell] DataItemResolver* = proc (dataItem: string): string {. - gcsafe, raises: [Defect].} + gcsafe, raises: [].} StatusBarView* = object model: DataItemResolver @@ -40,11 +40,11 @@ const foregroundColor = colWhiteSmoke func loadFragmentsLayout(contentLayout: string): ContentFragments {. - raises: [Defect, ValueError].} = + raises: [ValueError].} = toSeq(interpolatedFragments(strip contentLayout)) func loadCellsLayout(cellsLayout: string): seq[StatusBarCell] {. - raises: [Defect, ValueError].} = + raises: [ValueError].} = let cells = cellsLayout.split(';') for cell in cells: let columns = cell.split(':', maxSplit = 1) @@ -56,7 +56,7 @@ func loadCellsLayout(cellsLayout: string): seq[StatusBarCell] {. result.add StatusBarCell( contentFragments: loadFragmentsLayout(columns[0])) -func loadLayout(layout: string): Layout {.raises: [Defect, ValueError].} = +func loadLayout(layout: string): Layout {.raises: [ValueError].} = let sections = layout.split('|', maxSplit = 1) result.cellsLeft = loadCellsLayout(sections[0]) if sections.len == 2: result.cellsRight = loadCellsLayout(sections[1]) @@ -107,7 +107,7 @@ proc renderCells(cells: seq[StatusBarCell], sep: string) = stdout.write cell.content, " " stdout.resetAttributes() -proc render*(s: var StatusBarView) {.raises: [Defect, ValueError].} = +proc render*(s: var StatusBarView) {.raises: [ValueError].} = doAssert s.consumedLines == 0 let @@ -135,6 +135,5 @@ proc erase*(s: var StatusBarView) = func init*(T: type StatusBarView, layout: string, - model: DataItemResolver): T {.raises: [Defect, ValueError].} = + model: DataItemResolver): T {.raises: [ValueError].} = StatusBarView(model: model, consumedLines: 1, layout: loadLayout(layout)) - diff --git a/beacon_chain/sync/light_client_manager.nim b/beacon_chain/sync/light_client_manager.nim index dfc2f067b..e096d6a44 100644 --- a/beacon_chain/sync/light_client_manager.nim +++ b/beacon_chain/sync/light_client_manager.nim @@ -35,7 +35,7 @@ type Endpoint[Nothing, ForkedLightClientOptimisticUpdate] ValueVerifier[V] = - proc(v: V): Future[Result[void, VerifierError]] {.gcsafe, raises: [Defect].} + proc(v: V): Future[Result[void, VerifierError]] {.gcsafe, raises: [].} BootstrapVerifier* = ValueVerifier[ForkedLightClientBootstrap] UpdateVerifier* = @@ -46,11 +46,11 @@ type ValueVerifier[ForkedLightClientOptimisticUpdate] GetTrustedBlockRootCallback* = - proc(): Option[Eth2Digest] {.gcsafe, raises: [Defect].} + proc(): Option[Eth2Digest] {.gcsafe, raises: [].} GetBoolCallback* = - proc(): bool {.gcsafe, raises: [Defect].} + proc(): bool {.gcsafe, raises: [].} GetSyncCommitteePeriodCallback* = - proc(): SyncCommitteePeriod {.gcsafe, raises: [Defect].} + proc(): SyncCommitteePeriod {.gcsafe, raises: [].} LightClientManager* = object network: Eth2Node @@ -116,7 +116,7 @@ proc doRequest( peer: Peer, blockRoot: Eth2Digest ): Future[NetRes[ForkedLightClientBootstrap]] {. - raises: [Defect, IOError].} = + raises: [IOError].} = peer.lightClientBootstrap(blockRoot) # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#lightclientupdatesbyrange @@ -127,7 +127,7 @@ proc doRequest( peer: Peer, key: tuple[startPeriod: SyncCommitteePeriod, count: uint64] ): Future[LightClientUpdatesByRangeResponse] {. - async, raises: [Defect, IOError].} = + async, raises: [IOError].} = let (startPeriod, count) = key doAssert count > 0 and count <= MAX_REQUEST_LIGHT_CLIENT_UPDATES let response = await peer.lightClientUpdatesByRange(startPeriod, count) @@ -143,7 +143,7 @@ proc doRequest( e: typedesc[FinalityUpdate], peer: Peer ): Future[NetRes[ForkedLightClientFinalityUpdate]] {. - raises: [Defect, IOError].} = + raises: [IOError].} = peer.lightClientFinalityUpdate() # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#getlightclientoptimisticupdate @@ -151,7 +151,7 @@ proc doRequest( e: typedesc[OptimisticUpdate], peer: Peer ): Future[NetRes[ForkedLightClientOptimisticUpdate]] {. - raises: [Defect, IOError].} = + raises: [IOError].} = peer.lightClientOptimisticUpdate() template valueVerifier[E]( diff --git a/beacon_chain/sync/sync_queue.nim b/beacon_chain/sync/sync_queue.nim index 58413a40a..9e1f306cb 100644 --- a/beacon_chain/sync/sync_queue.nim +++ b/beacon_chain/sync/sync_queue.nim @@ -23,11 +23,11 @@ logScope: topics = "syncqueue" type - GetSlotCallback* = proc(): Slot {.gcsafe, raises: [Defect].} - ProcessingCallback* = proc() {.gcsafe, raises: [Defect].} + GetSlotCallback* = proc(): Slot {.gcsafe, raises: [].} + ProcessingCallback* = proc() {.gcsafe, raises: [].} BlockVerifier* = proc(signedBlock: ForkedSignedBeaconBlock, blobs: Opt[BlobSidecars], maybeFinalized: bool): - Future[Result[void, VerifierError]] {.gcsafe, raises: [Defect].} + Future[Result[void, VerifierError]] {.gcsafe, raises: [].} SyncQueueKind* {.pure.} = enum Forward, Backward diff --git a/beacon_chain/validator_client/fork_service.nim b/beacon_chain/validator_client/fork_service.nim index 5d595c726..d2970df5f 100644 --- a/beacon_chain/validator_client/fork_service.nim +++ b/beacon_chain/validator_client/fork_service.nim @@ -14,7 +14,7 @@ const logScope: service = ServiceName -proc validateForkSchedule(forks: openArray[Fork]): bool {.raises: [Defect].} = +proc validateForkSchedule(forks: openArray[Fork]): bool {.raises: [].} = # Check if `forks` list is linked list. var current_version = forks[0].current_version for index, item in forks: @@ -28,7 +28,7 @@ proc validateForkSchedule(forks: openArray[Fork]): bool {.raises: [Defect].} = true proc sortForks(forks: openArray[Fork]): Result[seq[Fork], cstring] {. - raises: [Defect].} = + raises: [].} = proc cmp(x, y: Fork): int {.closure.} = if uint64(x.epoch) == uint64(y.epoch): return 0 if uint64(x.epoch) < uint64(y.epoch): return -1 diff --git a/beacon_chain/validators/keystore_management.nim b/beacon_chain/validators/keystore_management.nim index 185f38435..3fcd97004 100644 --- a/beacon_chain/validators/keystore_management.nim +++ b/beacon_chain/validators/keystore_management.nim @@ -71,12 +71,12 @@ type ValidatorPubKeyToDataFn* = proc (pubkey: ValidatorPubKey): Opt[ValidatorAndIndex] - {.raises: [Defect], gcsafe.} + {.raises: [], gcsafe.} GetForkFn* = - proc (epoch: Epoch): Opt[Fork] {.raises: [Defect], gcsafe.} + proc (epoch: Epoch): Opt[Fork] {.raises: [], gcsafe.} GetGenesisFn* = - proc (): Eth2Digest {.raises: [Defect], gcsafe.} + proc (): Eth2Digest {.raises: [], gcsafe.} KeymanagerHost* = object validatorPool*: ref ValidatorPool @@ -140,7 +140,7 @@ proc echoP*(msg: string) = func init*(T: type KeystoreData, privateKey: ValidatorPrivKey, - keystore: Keystore, handle: FileLockHandle): T {.raises: [Defect].} = + keystore: Keystore, handle: FileLockHandle): T {.raises: [].} = KeystoreData( kind: KeystoreKind.Local, privateKey: privateKey, @@ -153,7 +153,7 @@ func init*(T: type KeystoreData, ) func init(T: type KeystoreData, keystore: RemoteKeystore, - handle: FileLockHandle): Result[T, cstring] {.raises: [Defect].} = + handle: FileLockHandle): Result[T, cstring] {.raises: [].} = let cookedKey = keystore.pubkey.load().valueOr: return err("Invalid validator's public key") @@ -193,10 +193,10 @@ func init(T: type KeystoreData, cookedKey: CookedPubKey, ) func init(T: type AddValidatorFailure, status: AddValidatorStatus, - msg = ""): AddValidatorFailure {.raises: [Defect].} = + msg = ""): AddValidatorFailure {.raises: [].} = AddValidatorFailure(status: status, message: msg) -func toKeystoreKind(kind: ValidatorKind): KeystoreKind {.raises: [Defect].} = +func toKeystoreKind(kind: ValidatorKind): KeystoreKind {.raises: [].} = case kind of ValidatorKind.Local: KeystoreKind.Local @@ -351,7 +351,7 @@ proc keyboardCreatePassword(prompt: string, proc keyboardGetPassword[T](prompt: string, attempts: int, pred: proc(p: string): KsResult[T] {. - gcsafe, raises: [Defect].}): KsResult[T] = + gcsafe, raises: [].}): KsResult[T] = var remainingAttempts = attempts counter = 1 @@ -373,7 +373,7 @@ proc keyboardGetPassword[T](prompt: string, attempts: int, err("Failed to decrypt keystore") proc loadSecretFile(path: string): KsResult[KeystorePass] {. - raises: [Defect].} = + raises: [].} = let res = readAllChars(path) if res.isErr(): return err(ioErrorMsg(res.error())) @@ -532,7 +532,7 @@ proc loadKeystore*(validatorsDir, secretsDir, keyName: string, proc removeValidatorFiles*(validatorsDir, secretsDir, keyName: string, kind: KeystoreKind ): KmResult[RemoveValidatorStatus] {. - raises: [Defect].} = + raises: [].} = let keystoreDir = validatorsDir / keyName keystoreFile = @@ -584,7 +584,7 @@ proc removeValidator*(pool: var ValidatorPool, validatorsDir, secretsDir: string, publicKey: ValidatorPubKey, kind: KeystoreKind): KmResult[RemoveValidatorStatus] {. - raises: [Defect].} = + raises: [].} = let validator = pool.getValidator(publicKey).valueOr: return ok(RemoveValidatorStatus.notFound) if validator.kind.toKeystoreKind() != kind: @@ -610,7 +610,7 @@ func checkKeyName(keyName: string): bool = true proc existsKeystore(keystoreDir: string, keyKind: KeystoreKind): bool {. - raises: [Defect].} = + raises: [].} = case keyKind of KeystoreKind.Local: fileExists(keystoreDir / KeystoreFileName) @@ -618,7 +618,7 @@ proc existsKeystore(keystoreDir: string, keyKind: KeystoreKind): bool {. fileExists(keystoreDir / RemoteKeystoreFileName) proc existsKeystore(keystoreDir: string, - keysMask: set[KeystoreKind]): bool {.raises: [Defect].} = + keysMask: set[KeystoreKind]): bool {.raises: [].} = if KeystoreKind.Local in keysMask: if existsKeystore(keystoreDir, KeystoreKind.Local): return true @@ -925,7 +925,7 @@ proc createLocalValidatorFiles*( secretsDir, validatorsDir, keystoreDir, secretFile, passwordAsString, keystoreFile, encodedStorage: string - ): Result[void, KeystoreGenerationError] {.raises: [Defect].} = + ): Result[void, KeystoreGenerationError] {.raises: [].} = var success = false # becomes true when everything is created successfully @@ -972,7 +972,7 @@ proc createLockedLocalValidatorFiles( secretsDir, validatorsDir, keystoreDir, secretFile, passwordAsString, keystoreFile, encodedStorage: string - ): Result[FileLockHandle, KeystoreGenerationError] {.raises: [Defect].} = + ): Result[FileLockHandle, KeystoreGenerationError] {.raises: [].} = var success = false # becomes true when everything is created successfully @@ -1018,7 +1018,7 @@ proc createLockedLocalValidatorFiles( proc createRemoteValidatorFiles*( validatorsDir, keystoreDir, keystoreFile, encodedStorage: string - ): Result[void, KeystoreGenerationError] {.raises: [Defect].} = + ): Result[void, KeystoreGenerationError] {.raises: [].} = var success = false # becomes true when everything is created successfully @@ -1044,7 +1044,7 @@ proc createRemoteValidatorFiles*( proc createLockedRemoteValidatorFiles( validatorsDir, keystoreDir, keystoreFile, encodedStorage: string - ): Result[FileLockHandle, KeystoreGenerationError] {.raises: [Defect].} = + ): Result[FileLockHandle, KeystoreGenerationError] {.raises: [].} = var success = false # becomes true when everything is created successfully @@ -1077,7 +1077,7 @@ proc saveKeystore*( password: string, salt: openArray[byte] = @[], mode = Secure - ): Result[void, KeystoreGenerationError] {.raises: [Defect].} = + ): Result[void, KeystoreGenerationError] {.raises: [].} = let keypass = KeystorePass.init(password) keyName = signingPubKey.fsName @@ -1117,7 +1117,7 @@ proc saveLockedKeystore( signingKeyPath: KeyPath, password: string, mode = Secure - ): Result[FileLockHandle, KeystoreGenerationError] {.raises: [Defect].} = + ): Result[FileLockHandle, KeystoreGenerationError] {.raises: [].} = let keypass = KeystorePass.init(password) keyName = signingPubKey.fsName @@ -1158,7 +1158,7 @@ proc saveKeystore( flags: set[RemoteKeystoreFlag] = {}, remoteType = RemoteSignerType.Web3Signer, desc = "" - ): Result[void, KeystoreGenerationError] {.raises: [Defect].} = + ): Result[void, KeystoreGenerationError] {.raises: [].} = let keyName = publicKey.fsName keystoreDir = validatorsDir / keyName @@ -1200,7 +1200,7 @@ proc saveLockedKeystore( flags: set[RemoteKeystoreFlag] = {}, remoteType = RemoteSignerType.Web3Signer, desc = "" - ): Result[FileLockHandle, KeystoreGenerationError] {.raises: [Defect].} = + ): Result[FileLockHandle, KeystoreGenerationError] {.raises: [].} = let keyName = publicKey.fsName keystoreDir = validatorsDir / keyName @@ -1238,14 +1238,14 @@ proc saveKeystore*( validatorsDir: string, publicKey: ValidatorPubKey, url: HttpHostUri - ): Result[void, KeystoreGenerationError] {.raises: [Defect].} = + ): Result[void, KeystoreGenerationError] {.raises: [].} = let remoteInfo = RemoteSignerInfo(url: url, id: 0) saveKeystore(validatorsDir, publicKey, @[remoteInfo], 1) proc importKeystore*(pool: var ValidatorPool, validatorsDir: string, keystore: RemoteKeystore): ImportResult[KeystoreData] - {.raises: [Defect].} = + {.raises: [].} = let publicKey = keystore.pubkey keyName = publicKey.fsName @@ -1278,7 +1278,7 @@ proc importKeystore*(pool: var ValidatorPool, validatorsDir, secretsDir: string, keystore: Keystore, password: string): ImportResult[KeystoreData] {. - raises: [Defect].} = + raises: [].} = let keypass = KeystorePass.init(password) let privateKey = block: diff --git a/beacon_chain/validators/message_router.nim b/beacon_chain/validators/message_router.nim index d6b5b3008..0528c2bdc 100644 --- a/beacon_chain/validators/message_router.nim +++ b/beacon_chain/validators/message_router.nim @@ -62,7 +62,7 @@ type network*: Eth2Node # TODO this belongs somewhere else, ie sync committee pool - onSyncCommitteeMessage*: proc(slot: Slot) {.gcsafe, raises: [Defect].} + onSyncCommitteeMessage*: proc(slot: Slot) {.gcsafe, raises: [].} func isGoodForSending(validationResult: ValidationRes): bool = # When routing messages from REST, it's possible that these have already diff --git a/beacon_chain/validators/slashing_protection.nim b/beacon_chain/validators/slashing_protection.nim index 4c2c15dd5..44d6317f2 100644 --- a/beacon_chain/validators/slashing_protection.nim +++ b/beacon_chain/validators/slashing_protection.nim @@ -115,7 +115,7 @@ proc init*( proc loadUnchecked*( T: type SlashingProtectionDB, basePath, dbname: string, readOnly: bool - ): SlashingProtectionDB {.raises:[Defect, IOError].}= + ): SlashingProtectionDB {.raises:[IOError].}= ## Load a slashing protection DB ## Note: This is for CLI tool usage ## this doesn't check the genesis validator root @@ -269,18 +269,18 @@ proc registerSyntheticAttestation*(db: SlashingProtectionDB, db.db_v2.registerSyntheticAttestation(validator, source, target) proc inclSPDIR*(db: SlashingProtectionDB, spdir: SPDIR): SlashingImportStatus - {.raises: [SerializationError, IOError, Defect].} = + {.raises: [SerializationError, IOError].} = db.db_v2.inclSPDIR(spdir) proc toSPDIR*(db: SlashingProtectionDB): SPDIR - {.raises: [IOError, Defect].} = + {.raises: [IOError].} = db.db_v2.toSPDIR() proc exportSlashingInterchange*( db: SlashingProtectionDB, path: string, validatorsWhiteList: seq[PubKey0x] = @[], - prettify = true) {.raises: [Defect, IOError].} = + prettify = true) {.raises: [IOError].} = ## Export a database to the Slashing Protection Database Interchange Format # We could modify toSPDIR to do the filtering directly # but this is not a performance sensitive operation. @@ -302,4 +302,3 @@ proc exportSlashingInterchange*( Json.saveFile(path, spdir, prettify) echo "Exported slashing protection DB to '", path, "'" - diff --git a/beacon_chain/validators/slashing_protection_common.nim b/beacon_chain/validators/slashing_protection_common.nim index 6e46f6e06..8d9dc4147 100644 --- a/beacon_chain/validators/slashing_protection_common.nim +++ b/beacon_chain/validators/slashing_protection_common.nim @@ -201,7 +201,7 @@ proc writeValue*( writer.writeValue("0x" & value.PubKeyBytes.toHex()) proc readValue*(reader: var JsonReader, value: var PubKey0x) - {.raises: [SerializationError, IOError, Defect].} = + {.raises: [SerializationError, IOError].} = try: value = PubKey0x hexToByteArray(reader.readValue(string), RawPubKeySize) except ValueError: @@ -212,7 +212,7 @@ proc writeValue*( w.writeValue "0x" & a.Eth2Digest.data.toHex() proc readValue*(r: var JsonReader, a: var Eth2Digest0x) - {.raises: [SerializationError, IOError, Defect].} = + {.raises: [SerializationError, IOError].} = try: a = Eth2Digest0x fromHex(Eth2Digest, r.readValue(string)) except ValueError: @@ -224,7 +224,7 @@ proc writeValue*( w.writeValue $distinctBase(a) proc readValue*(r: var JsonReader, a: var (SlotString or EpochString)) - {.raises: [SerializationError, IOError, Defect].} = + {.raises: [SerializationError, IOError].} = try: a = (typeof a)(r.readValue(string).parseBiggestUInt()) except ValueError: @@ -232,7 +232,7 @@ proc readValue*(r: var JsonReader, a: var (SlotString or EpochString)) proc importSlashingInterchange*( db: auto, - path: string): SlashingImportStatus {.raises: [Defect, IOError, SerializationError].} = + path: string): SlashingImportStatus {.raises: [IOError, SerializationError].} = ## Import a Slashing Protection Database Interchange Format ## into a Nimbus DB. ## This adds data to already existing data. @@ -275,7 +275,7 @@ proc importInterchangeV5Impl*( db: auto, spdir: var SPDIR ): SlashingImportStatus - {.raises: [SerializationError, IOError, Defect].} = + {.raises: [SerializationError, IOError].} = ## Common implementation of interchange import ## according to https://eips.ethereum.org/EIPS/eip-3076 ## spdir needs to be `var` as it will be sorted in-place diff --git a/beacon_chain/validators/slashing_protection_v2.nim b/beacon_chain/validators/slashing_protection_v2.nim index 888d1c2e9..1bf9ddecf 100644 --- a/beacon_chain/validators/slashing_protection_v2.nim +++ b/beacon_chain/validators/slashing_protection_v2.nim @@ -737,7 +737,7 @@ proc init*(T: type SlashingProtectionDB_v2, proc loadUnchecked*( T: type SlashingProtectionDB_v2, basePath, dbname: string, readOnly: bool - ): SlashingProtectionDB_v2 {.raises:[Defect, IOError].}= + ): SlashingProtectionDB_v2 {.raises:[IOError].}= ## Load a slashing protection DB ## Note: This is for conversion usage in ncli_slashing ## this doesn't check the genesis validator root @@ -1339,7 +1339,7 @@ proc registerSyntheticAttestation*( checkStatus() proc toSPDIR*(db: SlashingProtectionDB_v2): SPDIR - {.raises: [IOError, Defect].} = + {.raises: [IOError].} = ## Export the full slashing protection database ## to a json the Slashing Protection Database Interchange (Complete) Format result.metadata.interchange_format_version = "5" @@ -1435,7 +1435,7 @@ proc toSPDIR*(db: SlashingProtectionDB_v2): SPDIR doAssert status.isOk() proc inclSPDIR*(db: SlashingProtectionDB_v2, spdir: SPDIR): SlashingImportStatus - {.raises: [SerializationError, IOError, Defect].} = + {.raises: [SerializationError, IOError].} = ## Import a Slashing Protection Database Intermediate Representation ## file into the specified slashing protection DB ## diff --git a/beacon_chain/wallets.nim b/beacon_chain/wallets.nim index bff15c99b..95b790d6f 100644 --- a/beacon_chain/wallets.nim +++ b/beacon_chain/wallets.nim @@ -12,7 +12,7 @@ import ./conf proc doWallets*(config: BeaconNodeConf, rng: var HmacDrbgContext) {. - raises: [Defect, CatchableError].} = + raises: [CatchableError].} = case config.walletsCmd: of WalletsCmd.create: if config.createdWalletNameFlag.isSome: diff --git a/ncli/logtrace.nim b/ncli/logtrace.nim index e4c0206da..fdcdcb574 100644 --- a/ncli/logtrace.nim +++ b/ncli/logtrace.nim @@ -101,10 +101,10 @@ type categories: seq[IssuesGroup] LogVisitor = object - visitLine: proc(msg, fullLine: string) {.gcsafe, raises: [Defect].} - produceReport: proc(): FileReport {.gcsafe, raises: [Defect].} + visitLine: proc(msg, fullLine: string) {.gcsafe, raises: [].} + produceReport: proc(): FileReport {.gcsafe, raises: [].} - LogVisitorFactory = proc(): LogVisitor {.gcsafe, raises: [Defect].} + LogVisitorFactory = proc(): LogVisitor {.gcsafe, raises: [].} LogTracer = object enabledVisitors: seq[LogVisitorFactory] diff --git a/ncli/ncli_testnet.nim b/ncli/ncli_testnet.nim index 936ba9f11..76371f402 100644 --- a/ncli/ncli_testnet.nim +++ b/ncli/ncli_testnet.nim @@ -322,7 +322,7 @@ proc createDepositTreeSnapshot(deposits: seq[DepositData], proc doCreateTestnet*(config: CliConfig, rng: var HmacDrbgContext) - {.raises: [Defect, CatchableError].} = + {.raises: [CatchableError].} = let launchPadDeposits = try: Json.loadFile(config.testnetDepositsFile.string, seq[LaunchPadDeposit]) except SerializationError as err: @@ -465,7 +465,7 @@ proc sendEth(web3: Web3, to: Eth1Address, valueEth: int): Future[TxHash] = web3.send(tr) type - DelayGenerator* = proc(): chronos.Duration {.gcsafe, raises: [Defect].} + DelayGenerator* = proc(): chronos.Duration {.gcsafe, raises: [].} proc ethToWei(eth: UInt256): UInt256 = eth * 1000000000000000000.u256 diff --git a/nfuzz/libnfuzz.nim b/nfuzz/libnfuzz.nim index 29a1497c5..1e04253c8 100644 --- a/nfuzz/libnfuzz.nim +++ b/nfuzz/libnfuzz.nim @@ -42,7 +42,7 @@ type # TODO: change ptr uint to ptr csize_t when available in newer Nim version. proc copyState(state: phase0.BeaconState, xoutput: ptr byte, - xoutput_size: ptr uint): bool {.raises: [FuzzCrashError, Defect].} = + xoutput_size: ptr uint): bool {.raises: [FuzzCrashError].} = var resultState = try: SSZ.encode(state) @@ -99,17 +99,17 @@ template decodeAndProcess(typ, process: untyped): bool = false proc nfuzz_attestation(input: openArray[byte], xoutput: ptr byte, - xoutput_size: ptr uint, disable_bls: bool): bool {.exportc, raises: [FuzzCrashError, Defect].} = + xoutput_size: ptr uint, disable_bls: bool): bool {.exportc, raises: [FuzzCrashError].} = decodeAndProcess(AttestationInput): process_attestation(data.state, data.attestation, flags, 0.Gwei, cache).isOk proc nfuzz_attester_slashing(input: openArray[byte], xoutput: ptr byte, - xoutput_size: ptr uint, disable_bls: bool): bool {.exportc, raises: [FuzzCrashError, Defect].} = + xoutput_size: ptr uint, disable_bls: bool): bool {.exportc, raises: [FuzzCrashError].} = decodeAndProcess(AttesterSlashingInput): process_attester_slashing(getRuntimeConfig(some "mainnet"), data.state, data.attesterSlashing, flags, cache).isOk proc nfuzz_block(input: openArray[byte], xoutput: ptr byte, - xoutput_size: ptr uint, disable_bls: bool): bool {.exportc, raises: [FuzzCrashError, Defect].} = + xoutput_size: ptr uint, disable_bls: bool): bool {.exportc, raises: [FuzzCrashError].} = # There's not a perfect approach here, but it's not worth switching the rest # and requiring HashedBeaconState (yet). So to keep consistent, puts wrapper # only in one function. @@ -133,22 +133,22 @@ proc nfuzz_block(input: openArray[byte], xoutput: ptr byte, getRuntimeConfig(some "mainnet"), data, data.beaconBlock, flags, noRollback).isOk proc nfuzz_block_header(input: openArray[byte], xoutput: ptr byte, - xoutput_size: ptr uint, disable_bls: bool): bool {.exportc, raises: [FuzzCrashError, Defect].} = + xoutput_size: ptr uint, disable_bls: bool): bool {.exportc, raises: [FuzzCrashError].} = decodeAndProcess(BlockHeaderInput): process_block_header(data.state, data.beaconBlock.message, flags, cache).isOk proc nfuzz_deposit(input: openArray[byte], xoutput: ptr byte, - xoutput_size: ptr uint, disable_bls: bool): bool {.exportc, raises: [FuzzCrashError, Defect].} = + xoutput_size: ptr uint, disable_bls: bool): bool {.exportc, raises: [FuzzCrashError].} = decodeAndProcess(DepositInput): process_deposit(getRuntimeConfig(some "mainnet"), data.state, data.deposit, flags).isOk proc nfuzz_proposer_slashing(input: openArray[byte], xoutput: ptr byte, - xoutput_size: ptr uint, disable_bls: bool): bool {.exportc, raises: [FuzzCrashError, Defect].} = + xoutput_size: ptr uint, disable_bls: bool): bool {.exportc, raises: [FuzzCrashError].} = decodeAndProcess(ProposerSlashingInput): process_proposer_slashing(getRuntimeConfig(some "mainnet"), data.state, data.proposerSlashing, flags, cache).isOk proc nfuzz_voluntary_exit(input: openArray[byte], xoutput: ptr byte, - xoutput_size: ptr uint, disable_bls: bool): bool {.exportc, raises: [FuzzCrashError, Defect].} = + xoutput_size: ptr uint, disable_bls: bool): bool {.exportc, raises: [FuzzCrashError].} = decodeAndProcess(VoluntaryExitInput): process_voluntary_exit(getRuntimeConfig(some "mainnet"), data.state, data.exit, flags, cache).isOk @@ -157,7 +157,7 @@ proc nfuzz_voluntary_exit(input: openArray[byte], xoutput: ptr byte, # TODO: rework to copy immediatly in an uint8 openArray, considering we have to # go over the list anyhow? proc nfuzz_shuffle(input_seed: ptr byte, xoutput: var openArray[uint64]): bool - {.exportc, raises: [Defect].} = + {.exportc, raises: [].} = var seed: Eth2Digest # Should be OK as max 2 bytes are passed by the framework. let list_size = xoutput.len diff --git a/tests/test_deposit_snapshots.nim b/tests/test_deposit_snapshots.nim index 563e88d68..6128018a5 100644 --- a/tests/test_deposit_snapshots.nim +++ b/tests/test_deposit_snapshots.nim @@ -1,3 +1,10 @@ +# beacon_chain +# Copyright (c) 2022-2023 Status Research & Development GmbH +# 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. + {.used.} import @@ -19,7 +26,7 @@ template key2: array[1, byte] = [byte(kDepositTreeSnapshot)] type DepositSnapshotUpgradeProc = proc(old: OldDepositContractSnapshot): DepositTreeSnapshot - {.gcsafe, raises: [Defect].} + {.gcsafe, raises: [].} proc ifNecessaryMigrateDCS(db: BeaconChainDB, upgradeProc: DepositSnapshotUpgradeProc) = diff --git a/tests/test_discovery.nim b/tests/test_discovery.nim index 3e6352366..7888f7c58 100644 --- a/tests/test_discovery.nim +++ b/tests/test_discovery.nim @@ -20,7 +20,7 @@ proc new(T: type Eth2DiscoveryProtocol, bindPort: Port, bindIp: ValidIpAddress, enrFields: openArray[(string, seq[byte])] = [], rng: ref HmacDrbgContext): - T {.raises: [CatchableError, Defect].} = + T {.raises: [CatchableError].} = newProtocol(pk, enrIp, enrTcpPort, enrUdpPort, enrFields, bindPort = bindPort, bindIp = bindIp, rng = rng) diff --git a/tests/test_keymanager_api.nim b/tests/test_keymanager_api.nim index 44d235b9e..b1a6a7067 100644 --- a/tests/test_keymanager_api.nim +++ b/tests/test_keymanager_api.nim @@ -270,7 +270,7 @@ proc addPreTestRemoteKeystores(validatorsDir: string) = err = res.error quit 1 -proc startBeaconNode(basePort: int) {.raises: [Defect, CatchableError].} = +proc startBeaconNode(basePort: int) {.raises: [CatchableError].} = let rng = HmacDrbgContext.new() copyHalfValidators(nodeDataDir, true) @@ -339,7 +339,7 @@ const proc listLocalValidators(validatorsDir, secretsDir: string): seq[ValidatorPubKey] {. - raises: [Defect].} = + raises: [].} = var validators: seq[ValidatorPubKey] try: for el in listLoadableKeys(validatorsDir, secretsDir, @@ -352,7 +352,7 @@ proc listLocalValidators(validatorsDir, proc listRemoteValidators(validatorsDir, secretsDir: string): seq[ValidatorPubKey] {. - raises: [Defect].} = + raises: [].} = var validators: seq[ValidatorPubKey] try: for el in listLoadableKeys(validatorsDir, secretsDir,