Commit Graph

6 Commits

Author SHA1 Message Date
Dave Collins
9d6cf805f4
blockchain: Don't store full header in block node.
This modifies the block node structure to include only the specifically
used fields, some of which in a more compact format, as opposed to
copying the entire header and updates all code and tests accordingly.

Not only is this a more efficient approach that helps pave the way for
future optimizations, it is also consistent with the upstream code which
helps minimize the differences to facilitate easier syncs due to less
merge conflicts.

In particular, since the merkle and stake roots, number of revocations,
size, nonce, and extradata fields aren't used currently, they are no
longer copied into the block node.  Also, the block node already had a
height field, which is also in the header, so this change also removes
that duplication.

Another change is that the block node now stores the timestamp as an
int64 unix-style timestamp which is only 8 bytes versus the old
timestamp that was in the header which is a time.Time and thus 24 bytes.

It should be noted that future optimizations will very likely end up
adding most of the omitted header fields back to the block node as
individual fields so the headers can be efficiently reconstructed from
memory, however, these changes are still beneficial due to the ability
to decouple the block node storage format from the header struct which
allows more compact representations and reording of the fields for
optimal struct packing.

Ultimately, the need for the parent hash can also be removed, which will
save an additional 32 bytes which would not be possible without this
decoupling.
2018-01-29 11:35:06 -06:00
Dave Collins
05d8456d3e
multi: Rename vote choice IsIgnore to IsAbstain.
This renames the chaincfg parameter for the vote choice which represents
an abstaining vote to be named IsAbstain instead of IsIgnore since that
more accurately describes its intent and behavior.

It also updates the RPC server choice result field for isignore to be
named isabstain to match and bumps the major version accordingly.

Finally, it renames other internal variables which make use of the
choice to include the word abstain as well for clarity and renames a
couple of other internal variables.
2017-04-24 16:17:27 -05:00
Marco Peereboom
624f2d9ba7 blockchain: add expiration test during voting.
Add a test where the expiration time is roughly at the half of the
voting window.  We do that by spoofing the ExpireTime to be half of the
required RCI window.  The synthetics use a second per block time stamp
so we simply set ExpireTime to RCI/2 seconds.
2017-03-15 18:24:59 -05:00
Marco Peereboom
54d1da3151 Convert version array to version:bits tuple. (#586)
Propagate version and bits on the getstakeversions call.  Now we can
interrogate all raw vote version/bits data in addition to cooked values.

Diff is mostly mechanical exporting the Version:Bits tuple.
2017-02-21 12:39:43 -05:00
Marco Peereboom
b3763d4594 Create a tuple for vote version+bits.
With this change we can keep the version and the bits in blockNode.
This is used to fix an oversight where we weren't strictly enforcing
the vote version.  This also adds tests that validate quorum-1, quorum,
75%-1 and 75% rules during tallying.

Also adjust getvoteinfo totals to only return the specified vote version
totals.
2017-02-15 13:12:23 -06:00
Marco Peereboom
6967358649 blockchain: Implement configurable voting on top of PoS. (#542)
Port BIP0009 over from btcd.  The following is an overview of the
changes:
- Add new configuration options to the chaincfg package which allows the
  rule deployments to be defined per chain
- Implement code to calculate the threshold state as required by voting
  - Use threshold state caches that are stored to the database in order
    to accelerate startup time
  - Remove caches that are invalid due to definition changes in the
    params including additions, deletions, and changes to existing
    entries
  - Verify that PoW and PoS majorities have been reached.
- Add tests for new error type
- Add tests for threshold state
- Deployments are per stake version.
- Add human readable vote/choice infrastructure.
- Add RPC command to interrogate vote status (getvoteinfo).
2017-02-13 13:32:40 -05:00