* Bump block header version to 3.
* Enforce new rules once block version gets to 3.
* Use Voter Versions to control bumping of Stake Version.
* Calculate appropriate stake version based on history and prior
intervals in the mining code.
* Add bunch of UT to validate code.
This is the minimally correct working implementation. This code
desperately needs to memoize the questions that are asked repeatedly.
Fixes#523
This tweaks the full block test infrastructure to generate the pos
subsidy based upon the block being voted on as opposed to the current
one so it matches the consensus rules.
This modifies the full block consensus tests to only purchase tickets
until the target pool size is reached during the initial creation of the
blocks needed to reach stake validation height.
This helps make the code a little more flexible since it will allow many
more blocks to be created without spiking the ticket price as would
happen prior to this change.
For a little intuition, once stake validation height is reached the
tests intentionally purchase the same number of tickets as are voting on
each block in order to achieve a steady state, so if the number of
tickets in the pool are already higher than the target pool size prior
to reaching that steady state, the ticket price would keep rising until
the outputs used to purchase the tickets no longer had enough funds
available to purchase them.
This updates the various definitions of the simnet params used
exclusively in the tests to match their definitions used by the actual
simnet parameters defined in chaincfg.
While it would certainly be easier to simply use the params defined in
chaincfg, that also would not allow the tests to detect them being
inadvertently changed.
Upstream commit 7fac099bee.
Also, the merge commit contains the necessary decred-specific
alterations, adds a new policy parameter for AllowOldVotes to keep with
the spirit of the merged commit, modifies the RawMempoolVerbose to
accept an optional filter type to retain that functionality, and various
other cleanup intended to bring the code bases more in line with one
another.
This modifies the RPC server blockTemplateResult function to return RPC
errors as expected instead of using mempool and chain errors.
In addition to being more correct, it also helps pave the way for
mempool separation since its internal error funcs will no longer be
available to abuse as this code was doing.
This reverts to the correct upstream majority version code which
properly detects when certain thresholds of the network have been
updated in order to determine when to start rejecting old version
blocks and enforcing the rules in the new version block.
This splits the mining-specific code that deals with sorting blocks
according to the number of votes available for it in the mempool into
mining.go.
This is being done for a couple of reasons:
1) Mining-specific code does not belong directly in the mempool
2) It is required to be able to split the mempool into a separate
package which an upcoming upstream sync does
In order to accomplish this, a new function named VotesForBlocks has been
exposed on the mempool and the SortParentsByVotes code has been moved to
mining.go and modified to no longer return errors. The reasoning for
this is the same as the recent change to VoteHashesForBlock. That is to
say it is not the responsibility of a sorting function to dictate
caller-specific block eligibility logic.
This renames the GetVoteHashesForBlock on the mempool type to
VoteHashesForBlock so it is named according to Effective Go guidelines
as required by the project's code contribution guidelines and removes
the error return and paths from the function.
The error has been removed since the function should not be assuming how
the caller wishes to use the data. Consequently, now when there are no
votes for a given block hash, the function simply returns a nil slice to
reflect that. The caller can then decide if the lack of vote hashes for
a block is an error or not.
Also, the error path regarding an unset vote hash in the metadata is an
impossible condition because the mempool has full control over the vote
insertion and thus will never insert vote metadata without it.
Vote insertion is an internal mempool operation and thus should not be
exposed to callers outside of the package. It also had an undocumented
assumption that the provided tx had already passed stake.IsSSGen checks
which is yet another reason the function shouldn't be exposed.
This slightly optimizes the code which is invoked to provide the current
mining state to remote peers.
First, rather than creating copies of all of the hashes into a new slice
while limiting them in the OnGetMiningState function, just subslice
the hashes to the max length when there are too many.
Second, make the slices []chainhash.Hash which has better cache
locality and only requires a single allocation as opposed to one per
hash.
Finally, convert the pushMiningState function to accept []chainhash.Hash
slices for the block hashes and vote hashes and use the hashes directly
in the slices to build the final wire message.
This optimizes the vote map by making better use of Go's slice properties.
In particular, instead of creating a slice with empty entries and
iterating to find the next empty entry, just create the slice with a cap
and append entries as needed. This allows the code simply take the len
of the slice and range over it without needing additional code to deal
with nil entries.
While here, it also makes a few comments and returns more consistent
with the rest of the code base.
Upstream commit a7b35d9f9e.
Also, the merge commit contains necessary decred-specific alterations.
It also has the side effect of correcting a couple of min reduction bugs
even though they can't currently ever be hit due to the min reduction
interval flag being disabled for all networks.
Contains the following commits:
- 711f33450c
- b6b1e55d1e
- Reverted because Travis is already at a more recent version
- bd4e64d1d4
Also, the merge commit contains the necessary decred-specific
alterations, converts all other references to sha to hash to keep with
the spirit of the merged commits, and various other cleanup intended to
bring the code bases more in line with one another.
This exports the transaction tree constants from the wire package
instead of from dcrutil. The tree is a fundamental part of a
transaction and therefore its definitions belong in wire alongside the
other constants that are also related to fundamental transaction fields.
Further, the wire package most definitely should not depend on dcrutil
since that would create a cyclic import cycle.
Contains the following upstream commits:
- 5cbd1f85bf
- 777ccdade3
- f3d759d783
- 1ffc3dc18d
Also the merge commit updates the code to use the correct Decred
protocol versions and contains a few style-related changes.