Skip to content

Commit

Permalink
Add fixes from SSZ code in nimbus-eth2 (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdeme committed Nov 8, 2021
1 parent a7557e3 commit 1cb21ed
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ssz_serialization/codec.nim
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ func readSszValue*[T](input: openArray[byte],
val.setOutputSize resultLen
for i in 1 ..< resultLen:
let nextOffset = readOffset(i * offsetSize)
if nextOffset <= offset:
raise newException(MalformedSszError, "SSZ list element offsets are not monotonically increasing")
if nextOffset < offset:
raise newException(MalformedSszError, "SSZ list element offsets are decreasing")
else:
readSszValue(input.toOpenArray(offset, nextOffset - 1), val[i - 1])
offset = nextOffset
Expand Down
1 change: 1 addition & 0 deletions ssz_serialization/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ template `[]`*(x: BitList, idx: auto): auto = BitSeq(x)[idx]
template `[]=`*(x: var BitList, idx: auto, val: bool) = BitSeq(x)[idx] = val
template `==`*(a, b: BitList): bool = BitSeq(a) == BitSeq(b)
template setBit*(x: var BitList, idx: Natural) = setBit(BitSeq(x), idx)
template getBit*(x: var BitList, idx: Natural): bool = getBit(BitSeq(x), idx)
template clearBit*(x: var BitList, idx: Natural) = clearBit(BitSeq(x), idx)
template overlaps*(a, b: BitList): bool = overlaps(BitSeq(a), BitSeq(b))
template incl*(a: var BitList, b: BitList) = incl(BitSeq(a), BitSeq(b))
Expand Down

0 comments on commit 1cb21ed

Please sign in to comment.