remove `{.raises: [Defect].}` Nim 1.2 compatibility (#5352)

In Nim 1.6, `{.raises: [Defect].}` is no longer necessary. Remove it.
This commit is contained in:
Etan Kissling 2023-08-25 11:29:07 +02:00 committed by GitHub
parent 9637d3f8d0
commit c211a3849e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
58 changed files with 259 additions and 254 deletions

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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]

View File

@ -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

View File

@ -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,

View File

@ -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).

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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))

View File

@ -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")

View File

@ -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)

View File

@ -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* =

View File

@ -30,7 +30,7 @@ const
type
MsgTrustedBlockProcessor* =
proc(signedBlock: ForkedMsgTrustedSignedBeaconBlock): Future[void] {.
gcsafe, raises: [Defect].}
gcsafe, raises: [].}
OptimisticProcessor* = ref object
getBeaconTime: GetBeaconTimeFn

View File

@ -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* =

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -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:

View File

@ -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:

View File

@ -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

View File

@ -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)

View File

@ -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:

View File

@ -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:

View File

@ -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]

View File

@ -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

View File

@ -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.

View File

@ -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):

View File

@ -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)

View File

@ -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,

View File

@ -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)

View File

@ -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,

View File

@ -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

View File

@ -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)

View File

@ -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()

View File

@ -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:

View File

@ -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 =

View File

@ -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],

View File

@ -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*() =

View File

@ -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))

View File

@ -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](

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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, "'"

View File

@ -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

View File

@ -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
##

View File

@ -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:

View File

@ -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]

View File

@ -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

View File

@ -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

View File

@ -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) =

View File

@ -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)

View File

@ -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,