dcrd/internal
Ryan Staudt 75c9844599 multi: DCP0009 Auto revocations consensus change.
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
2021-09-20 18:02:19 -05:00
..
fees fees: Remove deprecated DisableLog. 2020-12-28 13:13:47 -06:00
limits multi: replace godoc.org with pkg.go.dev 2020-02-18 19:35:19 -06:00
mempool multi: DCP0009 Auto revocations consensus change. 2021-09-20 18:02:19 -05:00
mining multi: DCP0009 Auto revocations consensus change. 2021-09-20 18:02:19 -05:00
netsync multi: Use database/v3 module 2021-08-02 09:13:45 -05:00
progresslog multi: Don't use deprecated ioutil package. 2021-09-01 06:09:37 -05:00
rpcserver multi: DCP0009 Auto revocations consensus change. 2021-09-20 18:02:19 -05:00
staging/stdscript multi: Address some linter complaints. 2021-07-26 20:51:03 -05:00
version version: Rework to support single version override. 2021-05-14 04:15:56 -05:00