diff --git a/beacon_chain/spec/state_transition_epoch.nim b/beacon_chain/spec/state_transition_epoch.nim index b80601fdb..a0b96c033 100644 --- a/beacon_chain/spec/state_transition_epoch.nim +++ b/beacon_chain/spec/state_transition_epoch.nim @@ -148,9 +148,9 @@ proc process_justification_and_finalization*( ## matter -- in the next epoch, they'll be 2 epochs old, when BeaconState ## tracks current_epoch_attestations and previous_epoch_attestations only ## per - ## https://github.com/ethereum/eth2.0-specs/blob/v0.10.1/specs/phase0/beacon-chain.md#attestations + ## https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#attestations ## and `get_matching_source_attestations(...)` via - ## https://github.com/ethereum/eth2.0-specs/blob/v0.10.1/specs/phase0/beacon-chain.md#helper-functions-1 + ## https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#helper-functions-1 ## and ## https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#final-updates ## after which the state.previous_epoch_attestations is replaced. diff --git a/beacon_chain/ssz/bytes_reader.nim b/beacon_chain/ssz/bytes_reader.nim index 96a5b8df0..e0cd0ea81 100644 --- a/beacon_chain/ssz/bytes_reader.nim +++ b/beacon_chain/ssz/bytes_reader.nim @@ -58,6 +58,14 @@ template fromSszBytes*(T: type BitSeq, bytes: openarray[byte]): auto = BitSeq @bytes func fromSszBytes*[N](T: type BitList[N], bytes: openarray[byte]): auto {.raisesssz.} = + if bytes.len == 0: + # https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/ssz/simple-serialize.md#bitlistn + # "An additional 1 bit is added to the end, at index e where e is the + # length of the bitlist (not the limit), so that the length in bits will + # also be known." + # It's not possible to have a literally 0-byte (raw) Bitlist. + # https://github.com/status-im/nim-beacon-chain/issues/931 + raise newException(MalformedSszError, "SSZ input Bitlist too small") BitList[N] @bytes func fromSszBytes*[N](T: type BitArray[N], bytes: openarray[byte]): T {.raisesssz.} = diff --git a/tests/test_mainchain_monitor.nim b/tests/test_mainchain_monitor.nim index 6ad86be49..1ba6ba50d 100644 --- a/tests/test_mainchain_monitor.nim +++ b/tests/test_mainchain_monitor.nim @@ -1,3 +1,5 @@ +{.used.} + import unittest, chronos, web3/ethtypes,