Commit Graph

95 Commits

Author SHA1 Message Date
Dave Collins
fc54d98b1e
multi: Remove a bunch of dup words in comments. 2023-08-23 14:13:51 -05:00
Dave Collins
a12882b4f2
gcs: Prepare v4.0.0.
This updates the gcs module dependencies and serves as a base for
gcs/v4.0.0.

The full list of updated direct dependencies since the previous
gcs/v3.0.0 release are as follows:

- github.com/dchest/siphash@v1.2.3
- github.com/decred/dcrd/blockchain/stake/v5@v5.0.0
- github.com/decred/dcrd/chaincfg/chainhash@v1.0.4
- github.com/decred/dcrd/crypto/blake256@v1.0.1
- github.com/decred/dcrd/txscript/v4@v4.1.0
- github.com/decred/dcrd/wire@v1.6.0

The full list of updated indirect dependencies since the previous
gcs/v3.0.0 release are as follows:

- github.com/agl/ed25519@v0.0.0-20170116200512-5312a6153412
- github.com/decred/base58@v1.0.5
- github.com/decred/dcrd/chaincfg/v3@v3.2.0
- github.com/decred/dcrd/crypto/ripemd160@v1.0.2
- github.com/decred/dcrd/database/v3@v3.0.1
- github.com/decred/dcrd/dcrec@v1.0.1
- github.com/decred/dcrd/dcrec/edwards/v2@v2.0.3
- github.com/decred/dcrd/dcrec/secp256k1/v4@v4.2.0
- github.com/decred/dcrd/dcrutil/v4@v4.0.1
- github.com/decred/slog@v1.2.0
- github.com/klauspost/cpuid/v2@v2.0.9
- lukechampine.com/blake3@v1.2.1

Finally, all modules in the repository are tidied to ensure they are
updated to use the latest versions hoisted forward as a result.
2023-06-08 14:17:05 -05:00
Dave Collins
f6554540d0
blockchain/stake: Prepare v5.0.0.
This updates the blockchain/stake module dependencies, the copyright
year in the files modified since the previous release, and serves as a
base for blockchain/stake/v5.0.0.

The updated direct dependencies in this commit are as follows:

- github.com/decred/dcrd/chaincfg/chainhash@v1.0.4
- github.com/decred/dcrd/chaincfg@v3.2.0
- github.com/decred/dcrd/database/v3@v3.0.1
- github.com/decred/dcrd/dcrec/secp256k1/v4@v4.2.0
- github.com/decred/dcrd/dcrutil/v4@v4.0.1
- github.com/decred/dcrd/txscript/v4@v4.1.0
- github.com/decred/dcrd/wire@v1.6.0

The updated indirect dependencies in this commit are as follows:

- github.com/dchest/siphash@v1.2.3
- github.com/decred/base58@v1.0.5
- github.com/decred/dcrd/crypto/blake256@v1.0.1
- github.com/decred/dcrd/crypto/ripemd160 v1.0.2
- github.com/decred/dcrd/dcrec@v1.0.1
- github.com/decred/dcrd/dcrec/edwards/v2@v2.0.3
- github.com/klauspost/cpuid/v2@v2.0.9
- lukechampine.com/blake3@v1.2.1

The full list of updated direct dependencies since the previous
blockchain/stake/v4.0.0 release are the same as above.

The full list of updated indirect dependencies since the previous
blockchain/stake/v4.0.0 release are as follows:

- github.com/agl/ed25519@v0.0.0-20170116200512-5312a6153412
- github.com/dchest/siphash@v1.2.3
- github.com/decred/base58@v1.0.5
- github.com/decred/dcrd/crypto/blake256@v1.0.1
- github.com/decred/dcrd/crypto/ripemd160 v1.0.2
- github.com/decred/dcrd/dcrec@v1.0.1
- github.com/decred/dcrd/dcrec/edwards/v2@v2.0.3
- github.com/golang/snappy@v0.0.4
- github.com/klauspost/cpuid/v2@v2.0.9
- github.com/syndtr/goleveldb@v1.0.1-0.20210819022825-2ae1ddf74ef7
- lukechampine.com/blake3@v1.2.1

Finally, all modules in the repository are tidied to ensure they are
updated to use the latest versions hoisted forward as a result.
2023-06-08 13:51:08 -05:00
Dave Collins
ad02d8f300
multi: Go 1.19 doc comment formatting.
This modifies the entire repository to use the new formatting of doc
comments in the upcoming Go 1.19 release.

The primary motivating factors for this are:

- Builds check that files are formatted per gofmt and that will no
  longer be true as of Go 1.19 without these changes
- Separating all the updates into a single commit ensures these
  documentation only formatting changes do not clutter up diffs that
  actually change code

For the most part, the changes are just the automated changes suggested
by the Go 1.19 version of gofmt, but there are also a few cases where
the comments were reworded a bit to play nicely with the new formatting
requirements.

For example, the new version of gofmt reformats and collapses nested
lists where as the existing version does not.  Thus, instances of nested
lists have been changed to either eliminate them or use mixed markers
which produce expect results.
2022-07-30 04:08:58 -05:00
Dave Collins
9f8114e53d
blockchain: Move package to internal.
The moves the blockchain package from the blockchain module to an
internal package of the root module meaning that it is no longer a part
of the exported blockchain module.  Nearly all of the logic it provides
is really for the internal implementation of dcrd itself and thus having
it exported module significantly increases the maintenance burden.

Note that as of this change the blockchain module still exists and
provides the chaingen and fullblocktests packages both or which are
useful and used by external consumers.

This is part of a continuing overall effort to reduce the total number
of exported packages and modules and eventually get to the point it will
be possible to follow semver for the root module.

Overview of the major changes:

- Move all go files from blockchain -> internal/blockchain
- Move testdata from blockchain -> internal/blockchain
- Remove doc.go in favor of the README.md since godoc now displays it
- Move README.md from blockchain -> internal/blockchain and update to
  match the new reality
- Add a new README.md in the exported blockchain module that documents
  it contains the remaining exported packages
- Update all import paths in the repository accordingly
- Run go mod tidy on all modules
2022-05-30 15:32:41 -05:00
Dave Collins
bf162712d9
multi: Ensure newline at end of file. 2022-05-09 19:38:24 -05:00
Ryan Staudt
e0fe9a8cad multi: Remove agenda flags from DetermineTxType.
This removes the treasury and auto revocations agenda flags from the
stake.DetermineTxType since they are no longer used.
2022-05-08 11:47:32 -05:00
Ryan Staudt
c3680d0ce0 blockchain/stake: Start v5 module dev cycle.
Upcoming changes constitute breaking public API changes to the
blockchain/stake module, therefore, this follows the process for
introducing major API breaks which consists of:

- Bump the major version in the go.mod of the affected module if not
  already done since the last release tag
- Add a replacement to the go.mod in the main module if not already done
  since the last release tag
- Update all imports in the repo to use the new major version as
  necessary
- Make necessary modifications to allow all other modules to use the new
  version in the same commit
- Repeat the process for any other modules the require a new major as a
  result of consuming the new major(s)
2022-05-08 11:47:32 -05:00
Ryan Staudt
1f3a261031 gcs: Start v4 module dev cycle.
Upcoming changes constitute breaking public API changes to the gcs
module, therefore, this follows the process for introducing major API
breaks which consists of:

- Bump the major version in the go.mod of the affected module if not
  already done since the last release tag
- Add a replacement to the go.mod in the main module if not already done
  since the last release tag
- Update all imports in the repo to use the new major version as
  necessary
- Make necessary modifications to allow all other modules to use the new
  version in the same commit
- Repeat the process for any other modules the require a new major as a
  result of consuming the new major(s)
2022-05-08 11:47:32 -05:00
Dave Collins
7d59dd3b69
multi: Support module graph prune and lazy load.
This bumps the go directive for all of the modules provided by the
repository to 1.17 which will allow the new module graph pruning and
lazy loading capabilities introduced in Go 1.17 to be used once the
updated modules are released.

This means that, as described by the documentation, the go.mod files for
each module now include a separate require block that includes all of
the indirect dependencies
2022-03-25 07:20:01 -05:00
Dave Collins
36fbba3e22
gcs: Prepare v3.0.0.
This updates the gcs module dependencies, the copyright year in the
files modified since the previous release, and serves as a base for
gcs/v3.0.0.

The updated direct dependencies in this commit are as follows:

- github.com/decred/dcrd/blockchain/stake/v4@v4.0.0

The full list of updated direct dependencies since the previous
gcs/v2.1.0 release are as follows:

- github.com/dchest/siphash@v1.2.2
- github.com/decred/dcrd/blockchain/stake/v4@v4.0.0
- github.com/decred/dcrd/chaincfg/chainhash@v1.0.3
- github.com/decred/dcrd/txscript/v4@v4.0.0
- github.com/decred/dcrd/wire@v1.5.0

Finally, all modules in the repository that depend on the module are
tidied to ensure they are updated to use the latest versions hoisted
forward as a result.
2021-11-22 10:37:05 -06:00
Dave Collins
81ae286f23
database: Prepare v3.0.0.
This updates the database module dependencies, the copyright year in the
files modified since the previous release, and serves as a base for
database/v3.0.0.

The updated direct dependencies in this commit are as follows:

- github.com/decred/dcrd/dcrutil/v4@v4.0.0
- github.com/syndtr/goleveldb@v1.0.1-0.20210819022825-2ae1ddf74ef7

The full list of updated direct dependencies since the previous
database/v2.0.2 release are as follows:

- github.com/decred/dcrd/chaincfg/chainhash@v1.0.3
- github.com/decred/dcrd/chaincfg/v3@v3.1.0
- github.com/decred/dcrd/dcrutil/v4@v4.0.0
- github.com/decred/dcrd/wire@v1.5.0
- github.com/decred/slog@v1.2.0
- github.com/syndtr/goleveldb@v1.0.1-0.20210819022825-2ae1ddf74ef7

Finally, all modules in the repository that depend on the module are
tidied to ensure they are updated to use the latest versions hoisted
forward as a result.
2021-11-19 23:32:36 -06:00
Dave Collins
705015e400
dcrutil: Prepare v4.0.0.
This updates the dcrutil module dependencies, the copyright year in the
files modified since the previous release, and serves as a base for
dcrutil/v4.0.0.

The updated direct dependencies in this commit are as follows:

- github.com/decred/dcrd/txscript/v4@v4.0.0

The full list of updated direct dependencies since the previous
dcrutil/v3.0.0 release are as follows:

- github.com/decred/dcrd/chaincfg/chainhash@v1.0.3
- github.com/decred/dcrd/dcrec/edwards/v2@v2.0.2
- github.com/decred/dcrd/dcrec/secp256k1/v4@v4.0.1
- github.com/decred/dcrd/txscript/v4@v4.0.0
- github.com/decred/dcrd/wire@v1.5.0

Finally, all modules in the repository that depend on the module are
tidied to ensure they are updated to use the latest versions hoisted
forward as a result.
2021-11-19 11:54:59 -06:00
Dave Collins
55fb28cbbd
txscript: Prepare v4.0.0.
This updates the txscript module dependencies, the copyright year in the
files modified since the previous release, and serves as a base for
txscript/v4.0.0.

The updated direct dependencies in this commit are as follows:

- github.com/decred/dcrd/chaincfg/chainhash@v1.0.3
- github.com/decred/dcrd/chaincfg/v3@v3.1.0
- github.com/decred/dcrd/dcrec/edwards/v2@v2.0.2
- github.com/decred/dcrd/dcrec/secp256k1/v4@v4.0.1
- github.com/decred/dcrd/wire@v1.5.0
- github.com/decred/slog@v1.2.0

The full list of updated direct dependencies since the previous
txscript/v3.0.0 release are as follows:

- github.com/dchest/siphash@v1.2.2
- github.com/decred/base58@v1.0.3
- github.com/decred/dcrd/chaincfg/chainhash@v1.0.3
- github.com/decred/dcrd/chaincfg/v3@v3.1.0
- github.com/decred/dcrd/crypto/blake256@v1.0.0
- github.com/decred/dcrd/dcrec/edwards/v2@v2.0.2
- github.com/decred/dcrd/dcrec/secp256k1/v4@v4.0.1
- github.com/decred/dcrd/wire@v1.5.0
- github.com/decred/slog@v1.2.0

The following direct dependencies are no longer required as compared to
the previous txscript/v3.0.0 release:

- github.com/decred/dcrd/dcrutil/v3

Finally, all modules in the repository that depend on txscript are
tidied to ensure they are updated to use the latest versions hoisted
forward as a result.
2021-11-18 23:14:01 -06:00
Dave Collins
175d680afc
blockchain: Convert to use stdscript.
This converts the blockchain package to use the stdscript package
instead of txscript.

This is part of a series of commits to convert all packages in the
repository to make use of the new stdscript package.
2021-11-18 12:53:27 -06:00
Donald Adu-Poku
5c74266e3b multi: update build tags to pref. go1.17 syntax. 2021-10-19 20:21:44 -05:00
Ryan Staudt
ca03de05ec gcs: Prerel module release ver updates.
This modifies the recently-updated gcs module to use a valid prerelease
version of the blockchain/stake module so it can be used in require
statements in consumer code that is also under development.

The updated direct dependencies are as follows:

- github.com/decred/dcrd/blockchain/stake/v4 v4.0.0-20210906140327-598bf66f24a6
2021-09-16 12:28:59 -05:00
Ryan Staudt
598bf66f24 multi: Add isAutoRevocationsEnabled to CheckSSRtx.
This adds the isAutoRevocationsEnabled flag to stake.CheckSSRtx, which
in turn requires it to be added to stake.DetermineTxType and updating
all callers.

This is required for stake.CheckSSRtx since it will be updated to
return errors if revocation transactions are not valid when the
automatic ticket revocations agenda is enabled.

This is not ideal since it requires passing around the context-based
isAutoRevocationsEnabled flag in many places.

If the automatic ticket revocations agenda activates and there are no
existing version 2 revocation transactions in blocks, then this could
retroactively be removed and the updated checks can be based on the
transaction version instead.
2021-09-06 09:03:27 -05:00
Matheus Degiovani
893802fc06 multi: Use database/v3 module
This updates all users of the github.com/decred/dcrd/databasev/2 module
to use the recently introduced v3 version.

Replace directives are added as needed to ease development while the
final version of the database/v3 v3.0.0 isn't tagged.

The relevant documentation is also updated to use the new database/v3
module.
2021-08-02 09:13:45 -05:00
Matheus Degiovani
d9547c510f multi: Require last database/v2.0.3-x version.
This prepares the dependent modules for a version bump of the database
module by pointing their required version to the most recent one and
removing replace directives where they exist.
2021-08-02 08:29:46 -05:00
Dave Collins
d4084ec0e0
gcs: No standardness code in consensus.
This modifies the version 2 block filters in gcs to avoid using
standardness code since they are part of consensus code through header
commitments and therefore must not change even though the policy
regarding standardness can change.

It accomplishes the change by making use of the consensus-specific
script identification methods available via the stake package.
2021-06-14 11:58:11 -05:00
Dave Collins
0fb3e7eabd
dcrutil: Convert to use new stdaddr package.
This updates VerifyMessage to use the stdaddr package for addresses
instead of the local Address type in preparation for its removal.
2021-04-15 16:58:25 -05:00
Dave Collins
7f402345f0
stake: Convert to use new stdaddr package.
This converts the blockchain/stake package to use the stdaddr package
instead of dcrutil.Address as well as to support script versions.

All callers that use the package in the repository are updated
accordingly to maintain code that continues to build and work properly
as well as pass all tests.  In order to achieve this, it introduces
temporary address conversion code that will be removed in future
commits.

This is part of a series of commits to convert all packages in the
repository to make use of the new stdaddr package.
2021-04-09 13:39:16 -05:00
Dave Collins
472bc468f2
multi: Fix various typos. 2021-03-01 10:57:51 -06:00
Dave Collins
0a8c52a100
multi: Update to siphash v1.2.2.
This modifies the gcs and txscript modules to use the latest siphash
v1.2.2.

While here, it also updates the main module to use the latest rpcclient.

- github.com/dchest/siphash@v1.2.2
- github.com/decred/dcrd/rpcclient/v7@v7.0.0-20210129214723-fc227a05904d
2021-01-30 18:32:35 -06:00
Dave Collins
a4265d63b6
multi: Round 4 prerel module release ver updates.
This modifies some recently-updated modules to use a valid prerelease
version so they can be used in require statements in consumer code that
is also under development.

Several commits are needed since there is a dependency chain that
involves transitive deps.

The updated direct dependencies are as follows:

- github.com/decred/dcrd/blockchain/stake/v4@v4.0.0-20210129192908-660d0518b4cf
- github.com/decred/dcrd/blockchain/v4@v4.0.0-20210129192908-660d0518b4cf
- github.com/decred/dcrd/gcs/v3@v3.0.0-20210129192908-660d0518b4cf
- github.com/decred/dcrd/peer/v2@v2.2.1-0.20210129192908-660d0518b4cf
- github.com/decred/dcrd/rpcclient/v7@v7.0.0-20210129192908-660d0518b4cf
2021-01-29 13:52:02 -06:00
Dave Collins
660d0518b4
multi: Round 3 prerel module release ver updates.
This modifies some recently-updated modules to use a valid prerelease
version so they can be used in require statements in consumer code that
is also under development.

Several commits are needed since there is a dependency chain that
involves transitive deps.

The updated direct dependencies are as follows:

- github.com/decred/dcrd/blockchain/v4@v4.0.0-20210129190127-4ebd135a82f1
- github.com/decred/dcrd/database/v2@v2.0.3-0.20210129190127-4ebd135a82f1
- github.com/decred/dcrd/gcs/v3@v3.0.0-20210129190127-4ebd135a82f1
- github.com/decred/dcrd/hdkeychain/v3@v3.0.1-0.20210129190127-4ebd135a82f1
- github.com/decred/dcrd/peer/v2@v2.2.1-0.20210129190127-4ebd135a82f1
- github.com/decred/dcrd/rpcclient/v7@v7.0.0-20210129190127-4ebd135a82f1
- github.com/decred/dcrd/txscript/v4@v4.0.0-20210129190127-4ebd135a82f1
2021-01-29 13:29:08 -06:00
Dave Collins
4ebd135a82
multi: Round 2 prerel module release ver updates.
This modifies some recently-updated modules to use a valid prerelease
version so they can be used in require statements in consumer code that
is also under development.

Several commits are needed since there is a dependency chain that
involves transitive deps.

The updated direct dependencies are as follows:

- github.com/decred/dcrd/blockchain/stake/v4@v4.0.0-20210129181600-6ae0142d3b28
- github.com/decred/dcrd/blockchain/v4@4.0.0-20210129181600-6ae0142d3b28
- github.com/decred/dcrd/dcrutil/v4@v4.0.0-20210129181600-6ae0142d3b28
- github.com/decred/dcrd/hdkeychain/v3@v3.0.0-20210129181600-6ae0142d3b28
- github.com/decred/dcrd/txscript/v4@v4.0.0-20210129181600-6ae0142d3b28
2021-01-29 13:01:27 -06:00
Dave Collins
cecfb5a0b4
multi: Update README.md files for go modules.
This updates the installation and updating section of the README.md
files in the various packages to call out the module they are a part of
and instruct the consumer to use the standard go tooling instead of the
old, and no longer correct, package-based 'go get -u' instructions.
2021-01-22 14:39:23 -06:00
Ryan Staudt
e9460eb358 multi: Rework utxoset/view to use outpoints.
This modifies the utxoset in the database and related UtxoViewpoint to
store and work with unspent transaction outputs on a per-output basis
instead of at a transaction level.

The primary motivation is to simplify the code, pave the way for a
utxo cache, and generally focus on optimizing runtime performance.

The tradeoff is that this approach does somewhat increase the size of
the serialized utxoset since it means that the transaction hash is
duplicated for each output as a part of the key and some additional
details are duplicated in each output.  The details duplicated in each
output include flags encoded into a single byte that specify whether the
containing transaction is a coinbase, whether the containing transaction
has an expiry, and the transaction type.  Additionally, the containing
block height and index are stored in each output.

However, in practice, the size difference isn't all that large, disk
space is relatively cheap, certainly cheaper than memory, and it is much
more important to provide more efficient runtime operation since that is
the ultimate purpose of the daemon.

While performing this conversion, it also simplifies the code to remove
the transaction version information from the utxoset as well as the
spend journal.  The logic for only serializing it under certain
circumstances is complicated, and it was only used for the gettxout RPC,
where it has already been removed.

The utxo set and spend journal in the database are automatically
migrated to the new format with this commit and it is possible to
interrupt and resume the migration process.

Finally, it also updates all references and tests that previously dealt
with transaction hashes to use outpoints instead.

An overview of the changes are as follows:

- Remove transaction version from both spent and unspent output entries
  - Update utxo serialization format to exclude the version
  - Update spend journal serialization format to exclude the version
- Convert UtxoEntry to represent a specific utxo instead of a
  transaction with all remaining utxos
  - Optimize for memory usage with an eye toward a utxo cache
    - Combine fields such as whether the containing transaction is a
      coinbase, whether the containing transaction has an expiry, and
      the transaction type into a single byte
    - Align entry fields to eliminate extra padding since ultimately
      there will be a lot of these in memory
    - Introduce a free list for serializing an outpoint to the database
      key format to significantly reduce pressure on the GC
  - Update entries to be keyed by a <hash><tree><output index> outpoint
    rather than just a tx hash
  - Update all related functions that previously dealt with transaction
    hashes to accept outpoints instead
  - Update all callers accordingly
  - Only add individually requested outputs from the mempool when
    constructing a mempool view
- Modify the spend journal to always store the encoded flags with every
  spent txout
  - Combine fields such as whether the containing transaction is a
    coinbase, whether the containing transaction has an expiry, and the
    transaction type into a single byte
    - Use 4 bits instead of 3 for the transaction type to be consistent
      with utxos. The extra bit was already unused so this doesn't take
      any additional space
  - Remove the fully spent flag
- Introduce ticketMinOuts in place of stakeExtra
  - Renamed stakeExtra as ticketMinOuts and updated all comments to make
    the purpose of the field clearer
  - Only store ticketMinOuts for ticket submission outputs
  - Add TicketMinimalOutputs function on UtxoEntry in place of
    ConvertUtxosToMinimalOutputs
- Always decompress data loaded from the database now that a utxo entry
  only consists of a specific output
- Introduce upgrade code to migrate the utxo set and spend journal to
  the new format
  - Update current database version to 9
  - Update current utxo set version to 3
  - Update current spend journal version to 3
  - Introduce the ability to run upgrades after the block index has been
    loaded
- Update all tests to expect the correct encodings, remove tests that no
  longer apply, and add new ones for the new expected behavior
  - Convert old tests for the legacy utxo format deserialization code to
    test the new function that is used during upgrade
- Introduce a few new functions on UtxoViewpoint
  - AddTxOut for adding an individual txout versus all of them
  - addTxOut to handle the common code between the new AddTxOut and
    existing AddTxOuts
  - RemoveEntry for removing an individual txout
- Remove the ErrDiscordantTxTree error
  - Since utxos are now retrieved using an outpoint, which includes the
    tree, it is no longer possible to hit this error path
2021-01-14 17:25:06 -06:00
Dave Collins
8199e470a6
gcs: Remove unused v1 blockcf package.
This package is no longer needed now that support for the previously
deprecated v1 cfilters has been removed.
2021-01-02 12:38:34 -06:00
Donald Adu-Poku
bb3b544ee4 multi: update error code related documentation.
This renames leftover ErrorCode references
to ErrorKind in documentation for modules
where the type was renamed.
2020-12-21 13:00:59 -06:00
Donald Adu-Poku
57ffde8c30 multi: Start dcrec/secp256k1 v4 module dev cycle.
This updates the dcrec/secp256k1 module
version to v4 and updates import and dep sites.
2020-12-16 16:30:24 -06:00
Donald Adu-Poku
48e43ca109 multi: Start dcrutil v4 module dev cycle.
This updates the dcrutil module version to v4
and updates import and deps sites.
2020-12-16 16:30:24 -06:00
Donald Adu-Poku
d306a7fac6 multi: Start txscript v4 module dev cycle.
This updates the txscript module version to v4 and
updates import and dep sites.
2020-12-16 16:30:24 -06:00
Donald Adu-Poku
06fac5722a multi: Start blockchain/stake v4 module dev cycle.
This updates the blockchain/stake module version
to v4 and updates import and dep sites.
2020-12-16 16:30:24 -06:00
Donald Adu-Poku
e092918ac3 gcs: update error types.
This updates the gcs error types to leverage go 1.13 errors.Is/As functionality as well as confirm to the error infrastructure best practices.
2020-11-11 14:12:03 -06:00
Donald Adu-Poku
5bf4099b4b multi: Start gcs v3 module dev cycle.
This updates the gcs module version to v3 and
updates import and dep sites.
2020-11-10 16:51:38 -06:00
Dave Collins
11272d801d
gcs: Prepare v2.1.0.
This updates the gcs module dependencies, the copyright year in the
files modified since the previous release, and serves as a base for
gcs/v2.1.0.

The updated direct dependencies in this commit are as follows:

- github.com/decred/dcrd/blockchain/stake/v3@v3.0.0

The full list of updated direct dependencies since the previous
gcs/v2.0.1 release are as follows:

- github.com/decred/dcrd/blockchain/stake/v3@v3.0.0
- github.com/decred/dcrd/txscript/v3@v3.0.0
- github.com/decred/dcrd/wire@v1.4.0

Finally, all modules in the repository are tidied to ensure they are
updated to use the latest versions hoisted forward as a result.
2020-10-14 14:51:46 -05:00
Dave Collins
525853dbb9
blockchain/stake: Prepare v3.0.0.
This updates the blockchain/stake module dependencies, the copyright
year in the files modified since the previous release, and serves as a
base for blockchain/stake/v3.0.0.

The updated direct dependencies in this commit are as follows:

- github.com/decred/dcrd/database/v2@v2.0.2
- github.com/decred/dcrd/txscript/v3@v3.0.0

The full list of updated direct dependencies since the previous
blockchain/stake/v2.0.2 release are as follows:

- github.com/decred/dcrd/chaincfg/v3@v3.0.0
- github.com/decred/dcrd/database/v2@v2.0.2
- github.com/decred/dcrd/dcrec/secp256k1/v3@v3.0.0
- github.com/decred/dcrd/dcrutil/v3@v3.0.0
- github.com/decred/dcrd/txscript/v3@v3.0.0
- github.com/decred/dcrd/wire@v1.4.0
- github.com/decred/slog@v1.1.0

Finally, all modules in the repository are tidied to ensure they are
updated to use the latest versions hoisted forward as a result.
2020-10-13 17:36:37 -05:00
Dave Collins
a34e4204cc
txscript: Prepare v3.0.0.
This updates the txscript module dependencies and serves as a base for
txscript/v3.0.0.

The updated direct dependencies in this commit are as follows:

- github.com/decred/dcrd/chaincfg/v3@v3.0.0
- github.com/decred/dcrd/dcrutil/v3@v3.0.0
- github.com/decred/slog@v1.1.0

The full list of updated direct dependencies since the previous
txscript/v2.1.0 release are as follows:

- github.com/dchest/siphash@v1.2.1
- github.com/decred/dcrd/chaincfg/v3@v3.0.0
- github.com/decred/dcrd/crypto/ripemd160@v1.0.1
- github.com/decred/dcrd/dcrec/edwards/v2@v2.0.1
- github.com/decred/dcrd/dcrec/secp256k1/v3@v3.0.0
- github.com/decred/dcrd/dcrutil/v3@v3.0.0
- github.com/decred/dcrd/wire@v1.4.0
- github.com/decred/slog@v1.1.0

Finally, all modules in the repository that depend on txscript are
tidied to ensure they are updated to use the latest versions hoisted
forward as a result.
2020-09-26 13:26:40 -05:00
Matheus Degiovani
1a977a64ec multi: Fix treasury-related comments 2020-09-25 20:16:08 -05:00
Dave Collins
a8272f876d
dcrutil: Prepare v3.0.0.
This updates the dcrutil module dependencies and serves as a base for
dcrutil/v3.0.0.

The updated direct dependencies in this commit are as follows:

- github.com/decred/dcrd/crypto/ripemd160@v1.0.1
- github.com/decred/dcrd/dcrec/edwards/v2@v2.0.1
- github.com/decred/dcrd/dcrec/secp256k1/v3@v3.0.0

The full list of updated direct dependencies since the previous
dcrutil/v2.0.1 release are as follows:

- github.com/decred/base58@v1.0.3
- github.com/decred/dcrd/crypto/ripemd160@v1.0.1
- github.com/decred/dcrd/dcrec/edwards/v2@v2.0.1
- github.com/decred/dcrd/dcrec/secp256k1/v3@v3.0.0
- github.com/decred/dcrd/wire@v1.4.0

Further, the following dependencies that were previously required in the
dcrutil/v2.0.1 release are no longer required:

- github.com/decred/dcrd/chaincfg/v2

Finally, all modules in the repository that depend on dcrutil are tidied
to ensure they are updated to use the latest versions hoisted forward as
a result.
2020-09-25 16:00:44 -05:00
Dave Collins
f7af0ddb01
multi: Update chaincfg dependers to wire/v1.4.0. 2020-09-25 13:50:06 -05:00
Marco Peereboom
80f5feb1db
multi: Add decentralized treasury support.
This is based on https://proposals.decred.org/proposals/c96290a but was
modified in order to deal with realities that were unknown at the time
of the specification draft.

It is large and could not really be broken apart due to the pervasive
use of the isTreasuryEnabled flag. It was primarily authored by
* Marco Peereboom <marco@peereboom.us>
* Dave Collins <davec@conformal.com>
* Matheus Degiovani <opensource@matheusd.com>

With additional contributions from
* Donald Adu-Poku <donald.adu@gmail.com>
* Jamie Holdstock <jholdstock@decred.org>

Major changes:
* Add decentralized treasury agenda, as specified in DCP0006, to all supported
  nets.
* Add functions to determine if the decentralized treasury agenda is active at
  given block.
* Add new opcode OP_TADD that is a nop in txscript but is used to tag scripts
  that credit the treasury account. This opcode is overloaded for treasurybase
  and for normal transactions.
* Add new opcode OP_TSPEND that is a nop in txscript but is used to tag scripts
  that debit the treasury account.
* Add new opcode OP_TGEN that is a nop in txscript but is used to tag P2PKH and
  P2SH outputs in a TSpend transaction.
* Add functions that detect if a transaction is a valid TAdd, TSpend
  or treasurybase transaction.
* Add error codes that return specific treasurybase/TAdd/TSpend consensus
  violations.
* Modify countSpentOutputs to deal with treasury opcodes accordingly.
* Modify indexBlock to skip treasury transactions that do not have inputs.
* Add IsTreasuryEnabled call to ChainQueryer interface.
* Add treasury logger for debugging and logging the decentralized treasury
  subsystem.
* Add IsTreasuryActive flag to BlockConnectedNtfnsData and
  BlockDisconnectedNtfnsData.
* Modify OP_SSGEN to allow an optional output that contains votes for a TSpend
  transaction hash.
* Add function that returns TSpend votes from an SSGen transaction.
* Modify CalcStakeVoteSubsidy so that treasurybase, unlike coinbase, is always
  awarded the full percentage of the assigned block reward.
* Add helper functions to do all TSpend math so that callers don't roll their
  own.
* Modify IsCoinBaseTx to not mistake a TSpend transaction as a coinbase.
* Add checkTreasuryBase function that verifies that a treasurybase is properly
  constructed and pays the right amount to the treasury account.
* Add functions to calculate treasury balance for the provided block hash/node.
* Add function that verifies if a TSpend has a valid signature.
* Add functions to determine if a TSpend is not overspending.
* Add function to determine if a TSpend has been mined on the provided chain.
* Add functions that count and verifies treasury spend votes.
* Modify connectTransaction and disconnectTransactions to deal with the various
  treasury transactions.
* Split CheckTransactionSanity in two functions
  checkTransactionSanityContextFree and checkTransactionSanityContextual. This
  is done in order to keep the decentralized treasury, which is always
  contextual, from infecting the context free checks.
* Modify checkTransactionSanityContextual to recognize and verify treasury
  transactions.
* Modify CheckTransactionSanity to deal with treasury transactions.
* Split checkBlockSanity in two functions checkBlockSanityContextFree and
  checkBlockSanityContextual. This is done in order to keep the decentralized
  treasury, which is always contextual, from infecting the context free checks.
* Modify checkBlockSanityContextual to enforce treasurybase and TAdd consensus
  checks.
* Modify checkBlockPositional by unindenting it and adding TSpend consensus
  enforcement.
* Modify checkCoinbaseUniqueHeightWithAddress to deal with the removal of the
  project subsidy from output 0.
* Add checkCoinbaseUniqueHeightWithTreasuryBase that verifies coinbase and
  treasurybase in the provided block.
* Unindent checkBlockContext.
* Modify checkTicketRedeemerCommitments and checkVoteInputs to deal with
  potential tspend votes.
* Modify CheckTransactionInputs to skip treasurybase transactions.
* Modify CheckTransactionInputs to deal with TSpend transactions. Ensure the
  provided Pi key is valid and that the signature is valid for the transaction.
  Ensure that treasury TAdd and TSpend transaction utxo can only be spent after
  coinbase maturity.
* Modify CountSigOps to deal with treasury transactions.
* Modify CountP2SHSigOps to deal with treasury transactions.
* Modify getStakeTreeFees to skip treasury transactions. Modify
  totalOutputs to subtract ValueIn 0 for TSpend and treasurybase transactions.
* Modify checkTransactionsAndConnect to deal with modified amounts.
* Add tspendChecks function that verifies an entire TSpend transaction
  validity at the point of the provided block. It ensures a TSpend is on a TVI.
  It ensures the TSpend is in the valid window. It verifies that a TSpend In
  and Out amounts match. It ensures a TSpend has the ValueIn amount encoded in
  the OP_RETURN in Out 0. It ensures a TSpend has not been mined before on this
  chain. It ensures a TSpend has the requisite votes. It ensures a TSpend is
  not overspending.
* Modify checkConnectBlock to call checkTreasuryBase and tspendChecks when
  treasury agenda is active.
* Add two tables to the database. Table "treasury" records the balance as of
  this block and balance changes that occurred in this block which will become
  active in CoinbaseMaturity blocks. Table "tspend" records all block hashes
  where a TSpend has been mined this is to detect forks and prevent a Tspend
  from being mined more than once.
* Modify handleBlockchainNotification to communicate if the treasury agenda is
  active and skip treasurybase transaction when needed.
* Add various Treasury parameters to chaincfg params.
* Add hardcoded Tspend signatures in dcr_tmux_simnet_setup.sh.
* Add notifytspend and stoptspend calls to the RPC server. notifytspend
  notifies the mempool when a TSpend transaction arrives.
* Modify commit filters V2 to recognize TAdd and TSpend transactions. It was
  possible to modify V2 instead of introducing V3 because nothing changes from
  the viewpoint of the wallet and treasury opcodes are disallowed prior to
  agenda activation.
* Modify AddMemPoolTransaction to skip TSpend transactions that would throw the
  fee estimator off.
* Add IsTreasuryAgendaActive, OnTSpendReceived and TSpendMinedOnAncestor to
  mempool.Config in order to reject/accept TSpends in the mempool.
* Modify checkPoolDoubleSpend to ignore treasurybase.
* Modify mempool.maybeAcceptTransaction to enforce treasury standardness rules.
  Don't allow TSpend transactions prior to stake validation height. Skip
  treasurybase and tspend transactions in the orphan test. Ensure a tspend is
  in a valid window. Ensure not more than 7 TSpends are active in the mempool.
  Ensure TSpend has a well-known Pi key. Ensure The provided Pi key was used to
  sign the transaction. Ensure TSpend was not mined in an ancestor block.
  Notify subscribers that a valid TSpend was received.
* Add standardCoinbaseOpReturn and standardTreasurybaseOpReturn to create an
  OP_RETURN followed by a data push that little endian encodes the height of
  the block. Then there are a number of random bytes to ensure that the
  transaction hash is always random.
* Modify createCoinbaseTx to create a coinbase that is valid when treasury is
  enabled or not. Additionally, alter the transaction version if treasury is
  enabled.
* Add createTreasuryBaseTx that creates a standard treasurybase.
* Modify maybeInsertStakeTx to recognize treasurybase and TSpend transactions.
* Modify handleTooFewVoters to call createTreasuryBaseTx when the treasury
  agenda is active. Skip copying treasurybase.
* Modify NewBlockTemplate to recognize and deal with treasury transactions.
  Skip TSpend transaction if block is not a TVI. Skip TSpend transaction if it
  is not in the proper window. Skip TSpend transaction if a TSpend does not
  have enough yes votes. Skip TSpend transaction if it overspends the treasury
  account. Skip TAdd if there are more than 20 TAdds in the block. Create
  treasurybase if required. Insert valid TAdd/TSpend transactions into stake
  tree.
* Add TreasuryBalance and IsTreasuryAgendaActive to rpcserver Chain interface.
* Add gettreasurybalance, sendfromtreasury and sendtotreasury calls to RPC
  server.
* Add notifytspend and stopnotifytspend to RPC websocket commands.
* Add simnet miner to generate large number of blocks during rpctests without
  triggering PoW difficulty increases. This is used to verify various treasury
  and tspend conditions during CI/CT.
* Modify RPC voting wallet to also vote on TSpends.
* Add json tests to verify all new opcodes and corner cases in the script
  engine.
* Modify isStakeOpcode to recognize treasury opcodes.
* Modify countSigOpsV0 to count TSpends.
* Modify handleStakeOutSign to deal with TSpends.
* Modify SignTxOutput to recognize TSpends.
* Add TSpendSignatureScript that signs a TSpend transaction.
* Add TreasuryAddTy and TreasurySpendTy types to the standard scripts.
* Add isTreasuryAddScript and isTreasurySpendScript functions that recognize
  a form of TAdd and TSpend transactions.
* Modify ExtractPkScriptAddrs to deal with TAdd and TSpend outputs.
* Add TxVersionSeqLock = 2 and TxVersionTreasury = 3 to wire. This is
  used to discriminate between treasury and non-treasury scripts.
* Rig up all functions that need the isTreasuryEnabledflag directly or
  indirectly.
* Shuffle various functions around and export them when they were needed to be
  called from other packages.
* Added and modified numerous tests to verify (hopefully) all corner cases that
  the decentralized treasury agenda has added.
2020-09-21 12:15:31 -05:00
Ryan Staudt
d31d9305a4
multi: go mod tidy cleanup and run in CI.
This updates run_tests.sh to run `go mod tidy` in CI and fail if go.mod
and/or go.sum changes.
2020-06-15 08:49:38 -05:00
David Hill
e26e71a9a2 multi: replace godoc.org with pkg.go.dev 2020-02-18 19:35:19 -06:00
Dave Collins
b2cef202a7
multi: Round 4 prerel module release ver updates.
This modifies all prelease modules to use the latest commit to work out
more transitive dependency issues.  Several of these are needed due to
the dependency chain.

The updated direct dependencies are as follows:

- github.com/decred/dcrd/blockchain/stake/v3@v3.0.0-20200215031403-6b2ce76f0986
- github.com/decred/dcrd/blockchain/v3@v3.0.0-20200215031403-6b2ce76f0986
- github.com/decred/dcrd/chaincfg/v3@v3.0.0-20200215031403-6b2ce76f0986
- github.com/decred/dcrd/connmgr/v3@v3.0.0-20200215031403-6b2ce76f0986
- github.com/decred/dcrd/dcrec/secp256k1/v3@v3.0.0-20200215031403-6b2ce76f0986
- github.com/decred/dcrd/dcrutil/v3@v3.0.0-20200215031403-6b2ce76f0986
- github.com/decred/dcrd/hdkeychain/v3@v3.0.0-20200215031403-6b2ce76f0986
- github.com/decred/dcrd/mempool/v4@v4.0.0-20200215031403-6b2ce76f0986
- github.com/decred/dcrd/mining/v3@v3.0.0-20200215031403-6b2ce76f0986
- github.com/decred/dcrd/txscript/v3@v3.0.0-20200215031403-6b2ce76f0986
2020-02-14 22:55:06 -06:00
Dave Collins
6b2ce76f09
multi: Round 3 prerel module release ver updates.
This modifies all prelease modules to use the latest commit to work out
more transitive dependency issues.  Several of these are needed due to
the dependency chain.

The updated direct dependencies are as follows:

- github.com/decred/dcrd/blockchain/stake/v3@v3.0.0-20200215023918-6247af01d5e3
- github.com/decred/dcrd/blockchain/v3@v3.0.0-20200215023918-6247af01d5e3
- github.com/decred/dcrd/chaincfg/v3@v3.0.0-20200215023918-6247af01d5e3
- github.com/decred/dcrd/connmgr/v3@v3.0.0-20200215023918-6247af01d5e3
- github.com/decred/dcrd/dcrec/secp256k1/v3@v3.0.0-20200215023918-6247af01d5e3
- github.com/decred/dcrd/dcrutil/v3@v3.0.0-20200215023918-6247af01d5e3
- github.com/decred/dcrd/hdkeychain/v3@v3.0.0-20200215023918-6247af01d5e3
- github.com/decred/dcrd/mempool/v4@v4.0.0-20200215023918-6247af01d5e3
- github.com/decred/dcrd/mining/v3@v3.0.0-20200215023918-6247af01d5e3
- github.com/decred/dcrd/txscript/v3@v3.0.0-20200215023918-6247af01d5e3
2020-02-14 21:14:03 -06:00
Dave Collins
6247af01d5
multi: More prerel module release version updates.
This modifies all prelease modules to use the latest version to work out
more transitive dependency issues.

The updated direct dependencies are as follows:

- github.com/decred/dcrd/blockchain/stake/v3@v3.0.0-20200215015031-3283587e6add
- github.com/decred/dcrd/blockchain/v3@v3.0.0-20200215015031-3283587e6add
- github.com/decred/dcrd/chaincfg/v3@v3.0.0-20200215015031-3283587e6add
- github.com/decred/dcrd/connmgr/v3@v3.0.0-20200215015031-3283587e6add
- github.com/decred/dcrd/dcrec/secp256k1/v3@v3.0.0-20200215015031-3283587e6add
- github.com/decred/dcrd/dcrutil/v3@v3.0.0-20200215015031-3283587e6add
- github.com/decred/dcrd/hdkeychain/v3@v3.0.0-20200215015031-3283587e6add
- github.com/decred/dcrd/mempool/v4@v4.0.0-20200215015031-3283587e6add
- github.com/decred/dcrd/mining/v3@v3.0.0-20200215015031-3283587e6add
- github.com/decred/dcrd/txscript/v3@v3.0.0-20200215015031-3283587e6add
2020-02-14 20:39:18 -06:00