Skip to content

Commit

Permalink
work around some CastSizes warnings and fix unreachable code warnings (
Browse files Browse the repository at this point in the history
  • Loading branch information
tersec authored Jun 30, 2023
1 parent 0be9557 commit 583eb4d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
30 changes: 15 additions & 15 deletions beacon_chain/gossip_processing/gossip_validation.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 2 additions & 1 deletion beacon_chain/spec/datatypes/base.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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].} =
Expand Down

0 comments on commit 583eb4d

Please sign in to comment.