This updates the following modules to use the secp256k1/v2 module:
- blockchain
- chaincfg/v2
- dcrutil/v2
- hdkeychain/v2
- mempool/v3
- txscript/v2
- main
The hdkeychain/v3 and txscript/v2 modules both use types from secp256k1
in their public API.
Consequently, in order avoid forcing them to bump their major versions,
secp256k1/v1.0.3 was released with the types redefined in terms of the
secp256k1/v2 module so callers still using v1 of the module that are not
ready to upgrade to the v2 module yet can interoperate by updating to
the latest patch version.
This updates the main module to use the latest available minor and patch
versions of all modules and reverts the recent change that incorrectly
removed all of the blake256 references from the various go.sum files.
The following required direct dependencies are bumped as follows:
- github.com/decred/dcrd/blockchain/stake@v1.2.1
- github.com/decred/dcrd/blockchain/stake/v2@v2.0.1
- github.com/decred/dcrd/certgen@v1.1.0
- github.com/decred/dcrd/chaincfg@v1.5.2
- github.com/decred/dcrd/chaincfg/chainhash@v1.0.2
- github.com/decred/dcrd/chaincfg/v2@v2.2.0
- github.com/decred/dcrd/dcrutil/v2@v2.0.0
- github.com/decred/dcrd/gcs@v1.1.0
- github.com/decred/dcrd/hdkeychain/v2@v2.0.1
- github.com/decred/dcrd/txscript/v2@v2.0.0
- github.com/decred/dcrwallet/rpc/jsonrpc/types@v1.2.0
This updates the code to make use of the new crypto/blake256 module instead of
github.com/dchest/blake256.
* change the references in the chaincfg/chainhash and gcs modules
* update chaincfg/chainhash to use the new Sum256 API
* remove references to dchest/blake256 from all go.sum files
This updates the hdkeychain dependencies and serves as a base for
hdkeychain/v2.0.1.
Note that even though some of the updated dependencies consume a new
major version, they are only used internally or in the example code and
therefore a major version bump of the hdkeychain module is not required.
The updated direct dependencies in this commit are as follows:
- github.com/decred/dcrd/chaincfg/v2@v2.0.2
- github.com/decred/dcrd/dcrutil/v2@2.0.0
- github.com/decred/dcrd/dcrec/secp256k1@v1.0.2
The full list of updated direct dependencies since the previous
hdkeychain/v2.0.0 release are as follows:
- github.com/decred/dcrd/chaincfg/v2@v2.0.2
- github.com/decred/dcrd/dcrec@v1.0.0
- github.com/decred/dcrd/dcrutil/v2@2.0.0
- github.com/decred/dcrd/dcrec/secp256k1@v1.0.2
This updates all of the modules that still rely on v1 of the chaincfg
module to use v1.5.1 which builds correctly with the major API bump
introduced in the edwards v1.0.0 module.
While here, it also updates all references to the v0 edwards and dcrec
modules to their tagged v1 counterparts, tidies all of the modules via
go mod tidy, and removes all unnecessary indirect entries from the mod
files to keep the modules using the versions the dependencies are tested
with.
The primary motivation for this change is that the chaincfg/v2 module
requires edwards/v1 which is not API compatible with edwards/v0.
Consequently, in order for each module to be incrementally updated to
use chaincfg/v2, all of its dependencies must also be able to build with
edwards/v1 which is the case as of chaincfg v1.5.1.
This implements a mock network params struct that implements the new
interface and modifies the test code to make use of the mock params
instead of chaincfg. This completely decouples the tests, with the
exception of the example code, from chaincfg and therefore any updates
to it such as introducing new test networks will not require changes to
the tests.
This introduces a new interface named NetworkParams and updates the
functions that currently take a pointer to a chaincfg.Params struct to
accept the interface instead.
This removes the tight coupling between the two packages at the API
boundary and allows callers to easily provide custom values without
having to create and register and entire chaincfg network as previous
required.
Finally, the README.md is updated accordingly.
This refactors the the extended key internals to keep track of the
public and private network ids instead of a version slice in order to
remove the need to rely on global state for looking up the extended
public key ID for the network.
Since the public and private network ids are 8 bytes and the version
slice was 24 bytes, this also has the nice side effect of slightly
optimizing the performance, particularly in the private to public case,
as shown by the following benchmark comparison:
benchmark old ns/op new ns/op delta
--------------------------------------------------------
BenchmarkDeriveHardened 5795 5600 -3.36%
BenchmarkDeriveNormal 6585 6263 -4.89%
BenchmarkPrivToPub 137 118 -13.87%
BenchmarkDeserialize 17618 17618 +0.00%
BenchmarkSerialize 21672 21061 -2.82%
benchmark old bytes new bytes delta
--------------------------------------------------------
BenchmarkDeriveHardened 1552 1536 -1.03%
BenchmarkDeriveNormal 1601 1585 -1.00%
BenchmarkPrivToPub 128 112 -12.50%
BenchmarkDeserialize 1640 1624 -0.98%
BenchmarkSerialize 1712 1712 +0.00%
This modifies NewKeyFromString to accept the required network parameters
for the provided encoded extended key and introduces a new error to
indicate the provide extended key is for the wrong network.
This means that NewKeyFromString will now return ErrWrongNetwork if the
extended key being decoded is not for the provided network. This
differs from the previous behavior relied on globally-registered
networks in chaincfg to determine which network the encoded key was for
followed by requiring the caller to check upon if the key was for the
specific network it desired upon return.
Finally, it removes the no longer necessary IsForNet method and updates
the documentation accordingly.
This removes the SetNet method from the ExtendedKey struct since its use
in practice could lead to subtle bugs due to the fact that changing the
network after keys have already been derived and then deriving more keys
will not result in the same derivation as starting with the target
network to begin with. It is better to simply avoid the possibility of
misuse.
It also removes the related tests.
This removes the Address method from the ExtendedKey struct since
ultimately there will be multiple address types and therefore it no
longer makes sense to return an address which probably isn't the one the
caller actually needs. Instead, the caller can make use of the ECPubKey
method to obtain the public key and create the desired address from
there.
It also removes the related tests, updates the example to show the
address conversion process for a standard pay-to-pubkey-hash address,
and updates the README.md and doc.go files accordingly.
Putting the test code in the same package makes it easier for forks
since they don't have to change the import paths as much and makes it
more consistent with the rest of the code base.
This updates the README.md in hdkeychain to account for changes made in
Decred, correct the NewMaster godoc example link, and format the
examples so the description is on the line after the link for
consistency with other packages in the code base.
This adds the go 1.11 directive to all of the modules in order to
clearly mark they build and work with that version. Go 1.12 modified
the tools such that tidy will automatically add the new version to
modules that do not already have a directive and that would prevent
builds on Go 1.11 through Go 1.11.3 which is not desirable.
This modifies all of the modules, with the exception of the root module,
to remove all replacement directives from their go.mod files and update
the requirements and module sums accordingly.
While it is nice to be able to build and test directly from each module
directory and have it pull in the latest untagged changes when
developing, having all of the overrides in each module makes it
infeasible to use the module tools to help maintain the modules and thus
makes it quite difficult to ensure they are all independently accurate
for external consumers.
By maintaining all of the overrides in the root module and invoking all
builds and tests from it, the overrides will apply to ensure the latest
code is being built and tested.
This also modifies the tests script used with in CI to run all of the
tests from the root module accordingly.
This bumps the various module versions as follows:
- github.com/decred/dcrd/dcrec/secp256k1@v1.0.1
- github.com/decred/dcrd/dcrjson@v1.1.0
- github.com/decred/dcrd/database@v1.0.3
- github.com/decred/dcrd/blockchain/stake@v1.1.0
- github.com/decred/dcrd/mining@v1.1.0
- github.com/decred/dcrd/certgen@v1.0.2
- github.com/decred/dcrd/connmgr@v1.0.2
- github.com/decred/dcrd/mempool@v1.1.0
In addition, it serves as a base for tagging releases of the following
module versions that have previous been bumped since the last release,
but not yet tagged:
- github.com/decred/dcrd/wire@v1.2.0
- github.com/decred/dcrd/chaincfg@v1.2.0
- github.com/decred/dcrd/dcrutil@v1.2.0
- github.com/decred/dcrd/txscript@v1.0.2
- github.com/decred/dcrd/blockchain@v1.1.0
- github.com/decred/dcrd/hdkeychain@v1.1.1
- github.com/decred/dcrd/peer@v1.1.0
- github.com/decred/dcrd/rpcclient@v1.1.0
Finally, it updates all of the dependencies for every module accordingly,
adds a few missing overrides for transitive dependencies, and tidies up
some of the go module sum files.
This resurrects the regression test network that was removed before
initial launch although it really should not have been. The simulation
test network and the regression test network do not serve the same
purpose. Specifically, the regression test network is intended for unit
tests, RPC server tests, and consensus tests. On the other hand, the
simulation test network is intended for private use within a group of
individuals doing simulation testing and full integration tests between
different applications such as wallets, voting service providers, mining
pools, block explorers, and other services that build on Decred.
Keeping the concerns separate will allow the simulation test network to
be modified in ways such as activating consensus changes that have been
successfully voted into mainnet without also needing to vote them in on
the simulation test network while still preserving the ability for the
unit tests to properly test the voting semantics and handling to help
prevent regressions.
In addition to resurrecting the regression test network, this also fully
fleshes out new values for the various addresses prefixes (Rk, Rs, Re,
etc), HD key prefixes (rprv, rpub), and treasury multisig details.
As a part of resurrecting the network, a new CLI flag `--regnet` is
added to allow the RPC test harness connect to a running instance, the
areas of the code which involve votes have been modified to allow the
votes to apply to the new network, and tests have been added to the
relevant modules.
This bumps the affected module versions as follows:
- github.com/decred/dcrd/wire@v1.2.0
- github.com/decred/dcrd/chaincfg@v1.2.0
- github.com/decred/dcrd/dcrutil@v1.2.0
- github.com/decred/dcrd/hdkeychain@v1.1.1
The blockchain module is also affected, but since its version has
already been bumped since the last release tag, it is not bumped again.
Finally, this does not include switching unit tests or the RPC test
harness over the new network since that will be done in a separate
commit.
This bumps the various module versions as follows:
- github.com/decred/dcrd/addrmgr@v1.0.2
- github.com/decred/dcrd/wire@v1.1.0
- github.com/decred/dcrd/chaincfg@v1.1.1
- github.com/decred/dcrd/connmgr@v1.0.1
- github.com/decred/dcrd/dcrutil@v1.1.1
- github.com/decred/dcrd/database@v1.0.1
- github.com/decred/dcrd/hdkeychain@v1.1.0
- github.com/decred/dcrd/txscript@v1.0.1
- github.com/decred/dcrd/blockchain/stake@v1.0.1
- github.com/decred/dcrd/gcs@v1.0.1
- github.com/decred/dcrd/blockchain@v1.0.1
- github.com/decred/dcrd/mining@v1.0.1
- github.com/decred/dcrd/mempool@v1.0.1
- github.com/decred/dcrd/peer@v1.0.1
- github.com/decred/dcrd/rpcclient@v1.0.1
It also updates all of the dependencies for every module accordingly and
adds a few missing overrides for transitive dependencies.
This adds a new testnet3 network with new genesis block, block one
ledger, treasury address, and network magic.
All consensus rules that were voted in by testnet2 are automatically
active on the new testnet3 without having to vote them in again.
Consequently, there are no consensus vote agendas defined for it.
This modifies the test code for several unit tests to prefer using
another network, such as mainnet or simnet, when not specifically
testing something that requires testnet.
In the cases where where testnet is required, it also now prefers a
local reference over directly accessing the testnet parameters directly
from the chaincfg package.
This is being done because the test network undergoes periodic resets
and by reducing the number of direct references, it simplifies the
process of resetting it.
This further refines the modules to add the following new modules
instead of depending on the entire dcrd module:
- github.com/decred/dcrd/dcrjson@v1.0.0
- github.com/decred/dcrd/blockchain@v1.0.0
- github.com/decred/dcrd/blockchain/stake@v1.0.0
- github.com/decred/dcrd/gcs@v1.0.0
- github.com/decred/dcrd/mining@v1.0.0
- github.com/decred/dcrd/mempool@v1.0.0
- github.com/decred/dcrd/peer@v1.0.0
- github.com/decred/dcrd/rpcclient@v1.0.0
Also, it ensures modules that rely on other modules within the repo are
provided replacements to the latest repo code to ensure builds against
master and continuous integration use the latest code.
- github.com/decred/dcrd/addrmgr
- github.com/decred/dcrd/blockchain
- github.com/decred/dcrd/blockchain/stake
- github.com/decred/dcrd/chaincfg
- github.com/decred/dcrd/connmgr
- github.com/decred/dcrd/database
- github.com/decred/dcrd/dcrec/secp256k1
- github.com/decred/dcrd/dcrjson
- github.com/decred/dcrd/dcrutil
- github.com/decred/dcrd/gcs
- github.com/decred/dcrd/hdkeychain
- github.com/decred/dcrd/mempool
- github.com/decred/dcrd/mining
- github.com/decred/dcrd/peer
- github.com/decred/dcrd/rpcclient
- github.com/decred/dcrd/txscript
- github.com/decred/dcrd/wire
Now that the base58, chaincfg, chainhash, dcrec, secp256k1, and dcrutil
modules have been defined, update the hdkeychain module to only depend
on them instead of the entire dcrd module.
This adds module support for the versioned go toolchain. In particular,
the following packages are defined as modules:
* addrmgr
* blockchain
* certgen
* chaincfg
* connmgr
* database
* dcrjson
* dcrutil
* gcs
* hdkeychain
* mempool
* mining
* peer
* rpcclient
* txscript
* wire
It does not update the travis build environment or README since it is
experimental at this point.
The chainec package is scheduled to be removed. This PR replaces
chainec function calls within the hdkeychain package with the
underlining secp256k1 types and fields which breaks its dependence
on a package soon to be removed. memwallet, a member of rpctest which
calls hdkeychain functions is also updated.
This change moves the hdkeychain package outside of the dcrutil
directory into its own top-level package. This change is being made
since hdkeychain only depends on dcrutil's address code, and if the
rpctest integration tests are ever moved outside of the dcrd repo,
hdkeychain will no longer be required to remain in dcrd to avoid a
cyclic dependency.