Commit Graph

5323 Commits

Author SHA1 Message Date
Donald Adu-Poku
bad849b69d multi: Start blockchain v4 module dev cycle.
This updates the blockchain module version to v4 and
updates import sites.
2020-11-10 16:51:38 -06:00
Dave Collins
51f6442a31
rpcserver: Correct getpeerinfo for peers w/o conn.
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.
2020-11-10 10:55:51 -06:00
Matheus Degiovani
7f7ab16282
lru: Fix lookup race on small caches.
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.
2020-11-09 15:32:22 -06:00
Dave Collins
acb08e042e
gencerts: Use the P-256 curve by default.
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.
2020-11-05 13:56:52 -06:00
Donald Adu-Poku
9a42f18a29 rpcserver: add handleGetVoteInfo tests.
This adds rpc tests for handleGetVoteInfo.
2020-11-04 15:35:23 -06:00
Donald Adu-Poku
dc55a75efc rpcserver: add handleSendRawTransaction tests.
This adds rpc tests for  handleSendRawTransaction.
2020-11-04 15:06:25 -06:00
Donald Adu-Poku
a844b33742 rpcserver: add NtfnManager interface. 2020-11-04 15:06:25 -06:00
Dave Collins
dfafa028fa
config: Use the P-256 curve by default for RPC.
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.
2020-11-04 12:23:07 -06:00
Donald Adu-Poku
b39612d4b1 rpcserver: add handleVerifyMessage tests.
This adds rpc tests for handleVerifyMessage.
2020-11-04 12:17:36 -06:00
Dave Collins
03726a5222
blockchain: Clear failed block flags for HF.
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.
2020-10-27 10:27:58 -05:00
Dave Collins
6a9a161c28
blockchain: Handle db upgrade paths for ver < 5.
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.
2020-10-27 10:25:49 -05:00
Dave Collins
c1d3c8c0c0
blockchain: Make ver 5 to 6 db upgrades work again.
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
2020-10-27 10:21:04 -05:00
Dave Collins
0000220376
rpcclient: Prepare v6.0.1.
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.
2020-10-27 10:01:42 -05:00
Donald Adu-Poku
110ae1e5c8 rpcserver: add handleTicketFeeInfo tests.
This adds rpc tests for handleTicketFeeInfo.
2020-10-26 21:55:55 -05:00
Donald Adu-Poku
12021cf417 rpcserver: add handleTxFeeInfo tests.
This adds rpc tests for handleTxFeeInfo.
2020-10-26 17:28:01 -05:00
Donald Adu-Poku
71c02896c2 rpcserver: add ticketvwap tests.
This adds rpc tests for ticketvwap.
2020-10-26 17:15:11 -05:00
Donald Adu-Poku
7e33fdaa05 rpcserver: add ticketsforaddress tests.
This adds rpc tests for ticketsforaddress.
2020-10-26 11:55:27 -05:00
Dave Collins
f0aa880e90
docs: Update JSON-RPC API getrawmempool.
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.
2020-10-25 16:07:26 -05:00
Dave Collins
e5da39377f
rpcserver: Update getrawmempool txtype help.
This updates the help for the getrawmempool txtype parameters to specify
the new supported treasury types.
2020-10-24 17:41:20 -05:00
JoeGruff
761ceaab1c rpcserver: Add handleGetHeaders test. 2020-10-24 04:24:48 -05:00
Matheus Degiovani
d2dfc40885 multi: Add TAdd support to getrawmempool
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.
2020-10-23 19:38:49 -05:00
Matheus Degiovani
10a01f0970 blockchain: Fix stxosToScriptSource
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.
2020-10-23 07:34:45 -05:00
Ryan Staudt
d10904f047 mining: Move block chain functions to Config.
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.
2020-10-23 05:54:23 -05:00
Ryan Staudt
893726d7c4 mining: Add Config struct to house mining params.
This adds a mining.Config struct to take in mining parameters rather
than passing them directly to NewBlkTmplGenerator.
2020-10-23 05:54:23 -05:00
Dave Collins
2f3291c5a2
docs: Add JSON-RPC API searchrawtxns req limit. 2020-10-22 18:15:47 -05:00
Dave Collins
c18950859b
docs: Fix JSON-RPC API gettreasuryspendvotes fmt. 2020-10-22 18:15:47 -05:00
Dave Collins
2a1a88f5fb
docs: Fix JSON-RPC API gettreasurybalance fmt. 2020-10-22 18:15:46 -05:00
Dave Collins
678dbb32da
docs: Add JSON-RPC API getpeerinfo missing fields. 2020-10-22 18:15:46 -05:00
Dave Collins
958c4baad8
docs: Fix JSON-RPC API gettxoutsetinfo description. 2020-10-22 18:15:46 -05:00
Dave Collins
e9ca581bec
blockchain: Create treasury buckets during upgrade.
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.
2020-10-22 18:08:16 -05:00
Josh Rickmar
0ba1ca40a3 secp256k1: Correct const name for doc comment 2020-10-22 18:02:17 -05:00
Dave Collins
9547385fc0
mining: Prevent panic in child prio item handling.
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.
2020-10-20 12:38:05 -05:00
David Hill
c07fa09c58 peer: various cleanups 2020-10-16 19:21:41 -05:00
David Hill
c967d67295 blockchain: fix errorlint warnings 2020-10-16 19:20:38 -05:00
Ryan Staudt
cbb4dcb81e mining: Move BgBlkTmplGenerator to separate file.
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.
2020-10-16 15:13:57 -05:00
Ryan Staudt
231670b30e mining: Add method comments to blockManagerFacade. 2020-10-16 15:13:57 -05:00
Ryan Staudt
0ea393c03c mining: Move interfaces to mining/interface.go.
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.
2020-10-16 15:13:57 -05:00
Ryan Staudt
325d0b7661 mining: Cleanup txPriorityQueue tests.
This includes some minor cleanup for the txPriorityQueue tests and
additionally improves the test coverage to 100% for txpriorityqueue.go.
2020-10-16 15:13:57 -05:00
Ryan Staudt
bac4b521ca mining: Move txPriorityQueue to a separate file.
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.
2020-10-16 15:13:57 -05:00
JoeGruff
58fd6018dd rpcserver: Add handleGetGenerate and handleGetHashesPerSec tests. 2020-10-15 22:35:37 -05:00
Ryan Staudt
f448066295 rpcserver: Add handleGetTreasuryBalance tests. 2020-10-15 19:32:51 -05:00
David Hill
e8b4d293f3 rpcserver: Upgrade is deprecated; switch to Upgrader 2020-10-15 17:09:25 -05:00
Dave Collins
64b440453c
dcrjson: Reject dup method type registrations.
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.
2020-10-15 17:03:50 -05:00
Dave Collins
fe025c8153
release: Bump for 1.7 release cycle. 2020-10-15 16:30:33 -05:00
Dave Collins
c05d878615
main: Update to use all new module versions.
This updates all code in the main module to use the latest module
versions to pull in the latest updates.
2020-10-15 16:16:48 -05:00
Josh Rickmar
aec945a550 gencerts: Add missing newline for unknown algorithm error 2020-10-15 16:15:40 -05:00
Dave Collins
bd99dbe0b5
mining: Update to latest block vers for trsy vote.
This updates the block versions created by the mining code to produce
the latest versions needed to trigger the treasury HFV.
2020-10-15 15:34:02 -05:00
Dave Collins
fa0020be2c
blockchain: Prepare v3.0.0.
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.
2020-10-15 15:33:44 -05:00
Dave Collins
7b89f1c0a5
docs: Update for blockchain v3 module.
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.
2020-10-15 15:33:43 -05:00
Dave Collins
7e443d4abb
mining: Remove unused methods. 2020-10-15 15:30:18 -05:00