This corrects the getpeerinfo RPC handler to avoid a panic when the
local address is nil which is the case when a peer is not currently
connected. This can happen for cases such as permanent peers and during
process shutdown as peers are disconnected and being cleaned up.
While here, it also updates the comments to specifically call out that
the LocalAddr method returns nil when a peer is not connected to better
inform callers they are expected to handle that condition.
This fixes a possible race condition that could happen between the Add
and Lookup calls when the cache size was small.
When an entry was found in the cache during a Lookup call, its value
was fetched from the internal list node outside the mutex lock. This
could race with a corresponding Add call when the node was actually
the LRU node and was about to be overwritten.
This could manifest as a race specially when using caches with a very
small size, since it becomes more likely to perform a lookup on an entry
that is about to be concurrently overwritten.
This fixes the issue by moving the code that extracts the value from the
node to be performed with the lock held.
This modifies the default curve used to generate the certificates by the
gencerts utility to be P-256 instead of P-521 to match a recent similar
change made to the RPC server automatic generation logic.
Unfortunately, Chromium removed support for P-521 and since that is what
electron uses under the hood, Decrediton can no longer connect to dcrd
RPC servers using a certificate with P-521.
Thus, given the gencerts utility is used in various scenarios which
involve interop with the aforementioned software, update it as well.
This modifies the default curve used to generate the RPC certificates to
be P-256 instead of P-521. While I very much prefer the stronger curve,
unfortunately, Chromium removed support for P-521 and since that is what
electron uses under the hood, Decrediton can no longer connect to dcrd
RPC servers using a certificate with P-521.
Since the next release of the software will include a vote to change the
consensus rules, this unmarks all blocks previously marked as having
failed validation so they are eligible for validation again under what
will likely become new consensus rules. This ensures clients that did
not update prior to new rules activating are able to automatically
recover under the new rules without having to download the entire chain
again.
This really should have been done as a part of the version 7 upgrade,
but it wasn't, so this bumps the database version accordingly.
Also, since the version has to be bumped, this also takes the
opportunity to roll the fix to ensure the treasury buckets that weren't
created in the v7 upgrade in the original RC into the v8 upgrade.
This removes all code related to upgrading old databases prior to
version 5 and adds code so the main dcrd block loading logic is able to
query the blockchain if the database is too old to be upgraded and then
automatically handle removing and recreating the database when it is.
In other words, there is no manual intervention required by the user as
it will behave the same as if the user had manually removed the database
and thus redownload the chain from scratch as normal.
Since the blockchain package is used by other callers and utilities as
well, the upgrade path is also updated to detect the situation and
return an appropriate error along with additional information informing
the caller that the version is no longer supported and the database must
be removed.
While it would be nice to continue to support upgrading from super old
versions, there was a major overhaul from v4 to v5 such that an entire
reindex that needs to be tightly integrated with the code was required.
Since the aforementioned code has continued to change since that time,
attempting to continue to support this now would require reimplementing
a massive amount of code solely to support upgrading nodes that are
woefully out of data at this point and have long since been hard forked
from the network.
Upgrades starting from v5 are still supported.
Finally, in order to make the error detection more ergonomic, this
introduces a new ContextError type which can be used to wrap any error
with additional context such that errors.Is is able to detect the
underlying wrapped error. Ideally, the other error types would be
consolidated in the future to make use to the new ContextError type
instead to provide the additional context, but since that would be a
breaking change the API, it will need to be done in a new major version.
This allows version 5 to 6 database upgrades to work again by
implementing code that is independent of the main code and works with
the data structures as they existed in the version 5 database.
While here, it also updates some other cases in both older and newer
upgrade code to make the upgrades stable even if the primary code
changes.
An high-level overview of the key changes is:
- Clear the failed validation status of the v2 block index entries
directly instead of loading the code into the main index, modifying
it, and flushing it
- Avoid using the unversioned main funcs related to serializing and
deserializing the spend journal
- Implement code to directly create a script source from a v2 spend
journal entry
- Reimplement the migration code that initializes the v2 GCS filters to
independently read the block tree and discover the main chain
This updates the rpcclient module dependencies and serves as a base for
rpcclient/v6.0.1.
The updated direct dependencies in this commit are as follows:
- github.com/decred/dcrd/rpc/jsonrpc/types/v2@v2.2.0
The full list of updated direct dependencies since the previous
rpcclient/v6.0.0 release are as follows:
- github.com/decred/dcrd/rpc/jsonrpc/types/v2@v2.2.0
Finally, all modules in the repository are tidied to ensure they are
updated to use the latest versions hoisted forward as a result.
This updates the JSON-RPC API documentation for getrawmempool to make it
match reality. In particular, it removes the incorrect information
about dcrd not mining, corrects the description, and adds the optional
txtype parameter along with a list of supported types.
This adds support to querying specifically for tadds when using the
getrawmempool rpc call.
It also adds the missing tspend to the help command when using an
invalid txtype argument to getrawmempool.
This fixes the stxosToScriptSource function so that it takes into
account the new treasury transactions which don't have any inputs
(treasury bases and treasury spends).
Previously, the presence of one of this transactions in the blockchain
would cause a panic during addrindex calculation due to previous scripts
for inputs of those transactions not existing.
This updates mining.Config to take in the block chain related functions
that it requires rather than requiring a blockchain.BlockChain instance.
This allows for alternate implementations to be provided for these
functions, such as for testing.
This modifies the database upgrade code in blockchain to properly create
the buckets needed to house the decentralized treasury information.
It is done in a such a way that it will correct any upgrades that have
already taken place before this code is active.
This prevents an issue with the way that children are added to the
priority queue when building mining templates. In particular, it
ensures the child has already had priority item built for it before
adding to the prioirty queue since it is possible that the child has not
yet been seen under certain circumstances such as when there are
complicated transaction graphs of unconfirmed transactions.
This moves BgBlkTmplGenerator and the related logic to a separate file,
mining/bgblktmplgenerator.go.
This is part of an effort to split mining into several files to make the
package easier to navigate, and in preparation of adding additional test
coverage.
This moves the interfaces that are defined by mining to a separate file,
mining/interface.go.
This is part of an effort to split mining into several files to make the
package easier to navigate, and in preparation of adding additional test
coverage.
This moves txPriorityQueue and the related logic to a separate file,
mining/txpriorityqueue.go. Additionally, it moves the txPriorityQueue
tests to mining/txpriorityqueue_tests.go.
This is part of an effort to split mining into several files to make the
package easier to navigate, and in preparation of adding additional test
coverage.
This modifies the registration function to return an error as expected
in the case the same method type is registered more than once and adds
code to return an error when the parameter type is already registered
for some other method type.
The current code allowed the same method type to be registered again so
long as it had the same parameter type associated with it, which is not
desirable since it might have been registered with a different set of
flags and the new registration would simply be ignored.
This updates the blockchain module dependencies, the copyright year in
the files modified since the previous release, and serves as a base for
blockchain/v3.0.0.
The updated direct dependencies in this commit are as follows:
- github.com/decred/dcrd/blockchain/stake/v3@v3.0.0
- github.com/decred/dcrd/blockchain/standalone/v2@v2.0.0
- github.com/decred/dcrd/chaincfg/v3@v3.0.0
- github.com/decred/dcrd/dcrec/secp256k1/v3@v3.0.0
- github.com/decred/dcrd/dcrutil/v3 v3.0.0
- github.com/decred/dcrd/gcs/v2@v2.1.0
- github.com/decred/dcrd/txscript/v3@v3.0.0
The full list of updated direct dependencies since the previous
blockchain/v2.1.0 release are as follows:
- github.com/decred/dcrd/blockchain/stake/v3@v3.0.0
- github.com/decred/dcrd/blockchain/standalone/v2@v2.0.0
- 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/gcs/v2@v2.1.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.
This updates the docs/README.md file, module hierarchy graphviz, and
module hierarchy diagram to reflect the new module version and the
removal of the chaincfg dependency.