improve consistency of checkpoint read function (#3178)

Makes `readSszForkedTrustedSignedBeaconBlock` consistent with
`readSszForkedHashedBeaconState`, adjusting the length check
to verify the same type that is used for length computation,
and using the same formatting.
This commit is contained in:
Etan Kissling 2021-12-10 03:41:57 +01:00 committed by GitHub
parent 342ba68053
commit 9d5389654b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -450,13 +450,12 @@ func readSszForkedTrustedSignedBeaconBlock*(
ForkedTrustedSignedBeaconBlock {.raises: [Defect, SszError].} =
## Helper to read a header from bytes when it's not certain what kind of block
## it is
if data.len() < sizeof(BeaconBlockHeader):
if data.len() < sizeof(ForkedBeaconBlockHeader):
raise (ref MalformedSszError)(msg: "Not enough data for SignedBeaconBlock header")
let header = SSZ.decode(
data.toOpenArray(0, sizeof(ForkedBeaconBlockHeader) - 1),
ForkedBeaconBlockHeader)
# careful - `result` is used, RVO didn't seem to work without
# TODO move time helpers somewhere to avoid circular imports
result = ForkedTrustedSignedBeaconBlock(