Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VoterSet and Bitfield Refactoring #93

Merged
merged 12 commits into from
Jan 17, 2020
Merged

Commits on Jan 17, 2020

  1. Refactor bitfield and voter set.

    Bitfield:
    
      * Simplify definition, as Bitfield::Blank and LiveBitfield(vec![])
        are equivalent.
      * Dynamically-sized with lazy allocation makes for a more ergonomic
        API and keeps bitfields smaller. If there are few voters, most votes
    	are likely on the same nodes / blocks but in that case bitfields
    	are almost never resized anyway. As there are more and more voters,
    	votes are spread across more and more nodes / blocks and thus not
    	all nodes need a fully-sized bitfield.
      * Avoid allocations when merging bitfields. Previously merging would
        always allocate a new bitfield, now the other bitfield is merged
    	into `self` and only allocates if `self` needs to be resized.
      * Avoid allocations when casting votes and computing weights.
        Previously both casting of new votes and computing weights
    	involved creating and merging bitfields. Now incorporating a
    	vote into the vote graph is a `set_bit` operation while
    	computing the vote weight on a node is based a bitfield-merging
    	iterator that does not allocate.
      * Better tests.
    
    VoterSet:
    
      * Make it impossible to construct inconsistent sets as well as
        empty sets. Both were previously possible.
      * Better tests.
    
    Related changes:
    
      * Introduce a `weights` module for encapsulating vote-weight
        arithmetic behind newtypes.
      * Introduce a `round::context` module for encapsulating the
        context of a round in which vote weights are computed,
    	consisting of the voter set and recorded equivocations.
    Roman S. Borschel authored and romanb committed Jan 17, 2020
    Configuration menu
    Copy the full SHA
    4897f71 View commit details
    Browse the repository at this point in the history
  2. Documentation tweak.

    Roman S. Borschel authored and romanb committed Jan 17, 2020
    Configuration menu
    Copy the full SHA
    b9c3d88 View commit details
    Browse the repository at this point in the history
  3. Fix some indentation and small test improvements.

    Roman S. Borschel authored and romanb committed Jan 17, 2020
    Configuration menu
    Copy the full SHA
    ceb788d View commit details
    Browse the repository at this point in the history
  4. Remove left-over unwrap.

    Roman S. Borschel authored and romanb committed Jan 17, 2020
    Configuration menu
    Copy the full SHA
    fd098e6 View commit details
    Browse the repository at this point in the history
  5. Add missing license headers.

    Roman S. Borschel authored and romanb committed Jan 17, 2020
    Configuration menu
    Copy the full SHA
    0b594b6 View commit details
    Browse the repository at this point in the history
  6. Prefer None over panic in VoterSet construction.

    Roman S. Borschel authored and romanb committed Jan 17, 2020
    Configuration menu
    Copy the full SHA
    72d053e View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    6bf8c3c View commit details
    Browse the repository at this point in the history
  8. Remove unused dependency

    romanb committed Jan 17, 2020
    Configuration menu
    Copy the full SHA
    f3a7f8a View commit details
    Browse the repository at this point in the history
  9. Remove unused import.

    romanb committed Jan 17, 2020
    Configuration menu
    Copy the full SHA
    84aadc2 View commit details
    Browse the repository at this point in the history
  10. Fix no-std build.

    romanb committed Jan 17, 2020
    Configuration menu
    Copy the full SHA
    a14ced3 View commit details
    Browse the repository at this point in the history
  11. Fix no-std tests.

    romanb committed Jan 17, 2020
    Configuration menu
    Copy the full SHA
    0958168 View commit details
    Browse the repository at this point in the history
  12. Sorting keys in a VoterSet is now redundant.

    Due to switching to a BTreeMap.
    romanb committed Jan 17, 2020
    Configuration menu
    Copy the full SHA
    7ded42e View commit details
    Browse the repository at this point in the history