work around some CastSizes warnings and fix unreachable code warnings (#5149)

This commit is contained in:
tersec 2023-06-30 19:34:04 +00:00 committed by GitHub
parent 0be95571a7
commit 583eb4db17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 16 deletions

View File

@ -968,22 +968,22 @@ proc validateBlsToExecutionChange*(
if res.isErr:
return pool.checkedReject(res.error)
# BLS to execution change signatures are batch-verified
let deferredCrypto = batchCrypto.scheduleBlsToExecutionChangeCheck(
pool.dag.cfg.genesisFork, signed_address_change)
if deferredCrypto.isErr():
return pool.checkedReject(deferredCrypto.error)
# BLS to execution change signatures are batch-verified
let deferredCrypto = batchCrypto.scheduleBlsToExecutionChangeCheck(
pool.dag.cfg.genesisFork, signed_address_change)
if deferredCrypto.isErr():
return pool.checkedReject(deferredCrypto.error)
let (cryptoFut, sig) = deferredCrypto.get()
case await cryptoFut
of BatchResult.Invalid:
return pool.checkedReject(
"SignedBLSToExecutionChange: invalid signature")
of BatchResult.Timeout:
return errIgnore(
"SignedBLSToExecutionChange: timeout checking signature")
of BatchResult.Valid:
discard # keep going only in this case
let (cryptoFut, sig) = deferredCrypto.get()
case await cryptoFut
of BatchResult.Invalid:
return pool.checkedReject(
"SignedBLSToExecutionChange: invalid signature")
of BatchResult.Timeout:
return errIgnore(
"SignedBLSToExecutionChange: timeout checking signature")
of BatchResult.Valid:
discard # keep going only in this case
return ok()

View File

@ -650,7 +650,8 @@ proc readValue*(
raiseUnexpectedValue(reader, "Hex string of 4 bytes expected")
func `$`*(x: JustificationBits): string =
"0x" & toHex(uint8(x))
# TODO, works around https://github.com/nim-lang/Nim/issues/22191
"0x" & toHex(uint64(uint8(x)))
proc readValue*(reader: var JsonReader, value: var JustificationBits)
{.raises: [IOError, SerializationError, Defect].} =