docs: def state_length(state, size):
      """Check that the state is the given size."""
      if len(state) != size:
          raise ValueError('Invalid state: there must be one entry per '
                           'node in the network; this state has {} entries, but '
                           'there are {} nodes.'.format(len(state), size))
      return True