This removes the flags param from the ProcessBlock function in
blockchain since it is now passed in as BFNone in all instances. The
appropriate flags will now be determined internally within blockchain.
This removes the flags param from processBlockMsg and processBlock in
SyncManager since it is passed in as BFNone in all instances. The
appropriate flags will be determined internally within blockchain.
This removes the flags param from ProcessBlock in SyncManager since it
is passed in as BFNone in all instances. The appropriate flags will be
determined internally within blockchain.
This updates the block importer to enable bulk import mode on the chain
rather than passing in the blockchain.BFFastAdd parameter when
processing each block.
This will allow the blockchain.BehaviorFlags parameter to be removed
from the process block function in a subsequent commit.
This adds a bulk import mode that provides a mechanism to indicate that
several validation checks can be avoided when bulk importing blocks
already known to be valid. It will be used by the block importer in a
subsequent commit.
This provides an alternative mechanism to the current solution of
passing a BehaviorFlags parameter around, which is inconvenient and
makes it harder to determine where flags are being set.
This modifies the upgrade code related to block index entries to further
decouple it from the primary code base to help ensure legacy upgrade
paths remain stable as the primary code evolves.
The addition of the separate version 3 block index bits will also be
useful in future upgrade code as well.
This corrects the internal 96-bit accumulator used during modular
reduction over the curve order (ModNScalar) to properly handle the case
when both words of the multi-word addition overflow and adds accumulator
tests for all potential overflow conditions to ensure correctness.
This removes LatestBlockLocator since it is no longer used by anything
now that the desired hashes are always known from having all of the
headers available.
This updates the various blockchain call sites that deal with
determining if a node is an ancestor (or descendant) to make use of the
new IsAncestorOf convenience func.
This adds a convenience func to block nodes named IsAncestorOf for
determining whether or not a node is an ancestor of a given target node
along with tests to ensure proper functionality.
This addresses an issue in the ticket database when disconnecting a
block that contains an automatic revocation.
When the automatic ticket revocations agenda is enabled, a ticket can
become missed and revoked in the same block. When connecting that block
to the ticket database, this is recorded as two separate entries in the
undo data (the first moving it to missed, and the second moving it to
revoked). Therefore, when disconnecting the block, the undo data needs
to be applied in reverse order.
This updates the UTXO cache to flush all entries to the backend before
UTXO stats are fetched. This ensures that the UTXO stats are always in
sync with the current best block.
This also does not impact the effectiveness of the UTXO cache since
entries are still only evicted if necessary.
The method that calculates the next required difficulty currently logs
difficulty retargets which means it has side effects when it really
should free from them given its purpose.
This can be evidenced by the fact the logging is actually slightly
incorrect in a couple of ways due to those side effects. Namely, it can
potentially log when checking block templates when it shouldn't and it
is also currently logging when the headers are connected as opposed to
when the blocks themselves are actually connected which was the original
intention prior to the new headers-first logic.
Thus, this moves the debug logging for difficulty retargets from the
required difficulty calculation function to the block connection
function and also takes the opportunity to impose a new condition to
only log when the difficulty actually changes as opposed to the current
behavior of always logging on a retarget interval regardless.
This updates the blockchain checkpoints logic to use a single latest
checkpoint rather than multiple checkpoints. The intermediate
checkpoints are no longer necessary because headers first syncing was
introduced, which discovers the most recent checkpoint before block
syncing even starts.
This updates the Checkpoints param for mainnet and testnet to specify a
single latest checkpoint rather than multiple checkpoints. The
intermediate checkpoints are no longer necessary because headers first
syncing was introduced, which discovers the most recent checkpoint
before block syncing even starts.
This updates several of the tests in the script_test.go file to be more
consistent with the format used throughout the vast majority of the
other tests in the package.
The following is an overview of the changes:
- Use more compact format for the test definition tables
- Update the tests to make use of the short form script parsing logic
rather than manually defining byte slices
- Move the logic for testing various canonical integer and data pushes
into their respective test funcs
- Add names to the individual test conditions
- Update test failure output to be more consistent
This adds the ability for the short form script parsing to handle
different script versions and updates all of the tests to use the
version 0 function appropriately.
This updates the difficulty retarget logs to only be logged if the chain
believes it is current. These logs are otherwise very noisy when
syncing headers with the debug log level set.
This refactors finding the lowest index tip height out of CatchUp into
findLowestIndexTipHeight. The prevscripter snapshot now makes copies of
the pkScript to avoid holding on to references too long during the
catch up process.
This integrates the spend pruner's RemoveSpendConsumerDependency method
in the chaing query adapter to allow consumers access to the
functionality. The address index has been updated as such to remove its
spend journal dependencies when it processes block disconnections.
This updates the index subscriber catchup function to update
subscriptions directly with notification instead of going through the
Run lifecycle process which avoids a case of receiving out of sync
index notifications while catch up is in progress.
Multiple typos in error type tests and review issues have also been
fixed in this commit.
This removes last set of references to IndexManager and integrates the
IndexSubscriber into the chain. All indexes have now been updated to
subscribe to the index subscriber for updates.
This reworks the ExistsAddressIndex to implement the updated Indexer
interface for asynchoronous index updates. This index subscribes with
no prerequisites.
This updates the AddressIndex to implement the updated Indexer
interface for index updates. The index however subscribes with the
transaction index as a prerequisite.
This also adds the spend consumer for use by indexers that need to
lookup spend journal entries.
This reworks the TransactionIndex to implement the updated Indexer
interface for asynchoronous index updates. This index subscribes with
no prequisites.
This removes the IndexManager interface and reworks the ChainQueryer
and Indexer interfaces to facilitate index notification subscriptions
and asynchronous index notifications.
This adds the IndexSubscriber which allows subscribing for index
notifications as well as specifying an index notification dependency
or prerequisite for a subscriber.
This adds full test coverage for the calcTicketReturnAmounts function
to ensure that ticket return amounts are calculated correctly under a
variety of conditions.
This introduces automatic ticket revocations as defined in DCP0009,
including:
- Allowing tickets to be revoked by anyone instead of requiring a valid
signature from the voting address
- Requiring blocks to contain ticket revocation transactions for all
tickets that become missed or expired as of that block
An overview of the changes is as follows:
- blockchain/scriptval.go
- ValidateTransactionScripts, checkBlockScripts
- Skip script validation for version 2 revocations if the automatic
ticket revocations agenda is active
- blockchain/stake/staketx.go, blockchain/stake/staketx_test.go
- Introduce TxVersionAutoRevocations const for version 2 revocations
- CalculateRewards, CalculateRevocationRewards
- Add CalculateRevocationRewards to handle the required updates for
revocations while leaving CalculateRewards as-is for votes
- If the automatic ticket revocations agenda is active, and there is
a remainder after distributing the returns, then select a
uniformly pseudorandom output index to receive each remaining
atom
- Add additional tests to cover the new code paths
- CheckSSRtx
- Add checks to ensure that the input does not have a signature
script and does not have a fee if the automatic ticket revocations
agenda is active
- Add additional tests to cover the new code paths
- blockchain/validate.go, blockchain/validate_test.go
- checkTransactionContext
- Add rule that revocation transactions MUST be version 2 if the
automatic ticket revocations agenda is active.
- checkTicketRedeemers
- Add rule that if the automatic ticket revocations agenda is
active, then the block MUST contain revocation transactions for
all tickets that will become missed or expired as of that block
- Add rule that if the automatic ticket revocations agenda is
active, then revocations can spend tickets that will become missed
or expired as of that block (previously they could not be spent
until the block following the block where they became missed or
expired)
- Update to accept the referenced ticket hashes rather than the
overall block to simplify adding comprehensive unit tests for the
function
- calcTicketReturnAmounts
- Update to calculate the amounts for all outputs rather than a
single output
- For revocations, if the automatic ticket revocations agenda is active,
and there is a remainder after distributing the returns, then select a
uniformly pseudorandom output index to receive each remaining
atom
- checkTicketRedeemerCommitments
- Add rule that if the transaction is a version 2 revocation and the
automatic ticket revocation agenda is active, then the fee MUST be
zero
- Use the updated calcTicketReturnAmounts function so that returns
include the full amount, which allows for ensuring a truly zero
fee
- checkRevocationInputs
- Add rule that if the automatic ticket revocations agenda is
active, then revocations can spend tickets after ticket maturity
+ 1 blocks (in the block that they become missed or expired)
rather than after ticket maturity + 2 blocks (in the block AFTER
they become missed or expired)
- internal/mempool/mempool.go, internal/mempool/mempool_test.go
- Pass best block header to CheckTransactionInputs
- Pass isAutoRevocationsEnabled to ValidateTransactionScripts
- internal/mining/mining.go, internal/mining/mining_harness_test.go,
internal/mining/mining_test.go, internal/mining/mining_view_test.go
- Add a helper function, createRevocationFromTicket, to create a
revocation transaction from a ticket hash
- If the automatic ticket revocations agenda is active, then create
version 2 revocation transactions for all tickets that will become
missed or expired as of the block being created
- Create and insert these revocations into the priority queue AFTER
votes are done being added to ensure that revocations are added for
votes that fail validation checks or are otherwise not included into
the block
- Pass best block header to CheckTransactionInputs
- Pass isAutoRevocationsEnabled to ValidateTransactionScripts
- internal/rpcserver/interface.go, internal/rpcserver/rpcserver.go,
internal/rpcserver/rpcserverhandlers_test.go
- handleCreateRawSSRtx
- If the automatic ticket revocations agenda is active:
- Validate that the fee is zero
- Set the transaction version to 2
- Pass previous header bytes and isAutoRevocationsEnabled flag to
CreateRevocationFromTicket in order to create version 2 revocation
transactions properly with the updated rules
- Add additional tests to cover the new code paths
- server.go
- Pass previous block header to CheckTransactionInputs
- Pass isAutoRevocationsEnabled to ValidateTransactionScripts