Commit Graph

5295 Commits

Author SHA1 Message Date
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
Josh Rickmar
00b9dba01c gencerts: Rewrite for additional use cases
This implements a complete rewrite of the gencerts tool, making the
tool suitable not only for generating server certificates, but client
keypairs as well.  The following functionality is added:

* Local hostnames and interfaces are not automatically included in the
  certificate.  This allows clients to generate certificates which do
  not leak their network interfaces to remote servers.

* The certificate and key names must be explicitly provided on the
  command line after all flags.  This allows clients to generate
  keypairs with names like "client.pem" and "client.pem.key", rather
  than the tool only generating files named "rpc.cert" and "rpc.key".

* The key algorithm may be specified to be any of P-256, P-384, P-521,
  or Ed25519.  The default algorithm is P-521, matching the previous
  gencerts implementation.

The certificate creation code has been added directly to gencerts
rather than modifying the certgen package, since this package is used
by dcrd, dcrwallet, and other Decred servers to automatically generate
keys with all local interfaces pre-included.
2020-10-15 15:09:53 -05:00
Dave Collins
91a7be27b3
rpcclient: Prepare v6.0.0.
This updates the rpcclient module dependencies, the copyright year in
the files modified since the previous release, and serves as a base for
rpcclient/v6.0.0.

The updated direct dependencies in this commit are as follows:

- github.com/decred/dcrd/dcrjson/v3@v3.1.0
- github.com/decred/dcrd/dcrutil/v3@v3.0.0
- github.com/decred/dcrd/gcs/v2@v2.1.0
- github.com/decred/dcrd/rpc/jsonrpc/types/v2@v2.1.0

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

- github.com/decred/dcrd/dcrjson/v3@v3.1.0
- github.com/decred/dcrd/dcrutil/v3@v3.0.0
- github.com/decred/dcrd/gcs/v2@v2.1.0
- github.com/decred/dcrd/rpc/jsonrpc/types/v2@v2.1.0
- github.com/decred/dcrd/wire@v1.4.0
- github.com/decred/slog@v1.1.0
- github.com/gorilla/websocket@v1.4.2

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 11:42:40 -05:00
Dave Collins
34e264038b
docs: Update for rpcclient/v6 module.
This updates the docs/README.md file, module hierarchy graphviz, and
module hierarchy diagram to reflect the new module version.

It also updates the rpcclient/README.md file to reference the correct
major version on the documentation site.
2020-10-15 11:42:33 -05:00
Dave Collins
4bf1682815
blockchain/mempool: Update for recent err convrsn.
This updates the blockchain and mempool packages for the recent
conversion to the new preferred error infrastructure to finish a TODO
that was mean to take advantage of it as well as address some other nits
such as comments that weren't updated properly and test formatting.
2020-10-15 11:36:57 -05:00
Dave Collins
9e6a76a1a2
peer: Prepare v2.2.0.
This updates the peer module dependencies, the copyright year in the
files modified since the previous release, and serves as a base for
peer/v2.2.0.

The updated direct dependencies in this commit are as follows:

- github.com/decred/dcrd/lru@v1.1.0
- github.com/decred/dcrd/txscript/v3@v3.0.0

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

- github.com/decred/dcrd/lru@v1.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 02:58:55 -05:00
Dave Collins
6e2b478025
docs: Update for peer/v2 module.
This updates the module hierarchy graphviz and module hierarchy diagram
to reflect the new module dependencies.
2020-10-15 02:58:55 -05:00
Sef Boukenken
15c3817777
mempool/mining: Implement aggregate fee sorting.
This modifies the mining prioritization logic to sort transactions by an aggregate fee based on a transaction’s ancestors in the mempool.

This modifies the mining prioritization logic to sort transactions by an
aggregate fee based on a transaction’s ancestors in the mempool.

Currently, the mining code prioritizes transactions by fee and only
includes them in the block template if they have no dependencies.  When
a transaction is included in the block template, it is removed as a
dependency from transactions that depend on it, making those dependent
transactions eligible for block template inclusion.

Aggregating ancestor statistics for large graphs of transactions in the
mempool may have high computational costs.  Performing this aggregation
in the block template generator would delay miners requesting a block
template since all of the aggregation would need to occur for each
transaction, at once.  To solve this problem, the complexity is spread
over time such that the transaction statistics are updated with mempool
event hooks.  Since the mempool is not locked during the entirety of
template generation, a mining view interface is exposed to safely
interact with a snapshot of the mempool.

The biggest risk in terms of performance are reorgs where transactions
with many descendants are added back to the mempool.  The number of
transactions added to the mempool in this way is limited by the block
size and proof of work, but the mempool has no restrictions on the
number of ancestors tracked for a given transaction.

A potential - and not implemented - solution to this reorg problem would
be to establish a limit on the number of ancestors a transaction may
have in the mempool.
2020-10-14 23:11:12 -05:00
Donald Adu-Poku
00933dcf0f multi: update blockchain and mempool error types.
This updates the blockchain and mempool error types to
leverage go 1.13 errors.Is/As functionality as well as confirm to
the error infrastructure best practices.
2020-10-14 20:42:41 -05: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
e5e2c2ed35
docs: Update for blockchain/stake 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-13 17:36:33 -05:00
Dave Collins
2b1dbb422b
rpcserver: Update known wallet RPC methods.
This updates the map of known wallet RPC methods to match the latest
reality so a more useful error message is returned to the user in the
case they attempt to issue wallet commands to the dcrd RPC server
instead of the wallet one.
2020-10-13 14:13:47 -05:00
Dave Collins
ac039fcacd
rpcserver: Correct known wallet method handling.
This corrects the code to return the expected RPC error in the case the
requested method is one known to be a wallet method or known to be
intentionally unimplemented.

Since dcrjson was updated to work with types instead of strings, parsing
a method that is not registered now fails, so the special error returns
are now handled there as opposed to the old approach of adding handlers
for certain method names which just returned the appropriate error.

This allows the standardCmdResult method to be simplified since it no
longer needs to include the logic for dealing with special handlers and
therefore it is updated accordingly.

Finally, the special handlers are removed since they are no longer
needed.
2020-10-13 14:13:43 -05:00
Matheus Degiovani
05dfc92b11 rpcserver: Add --rejectnonstd to rpctest
Previously you couldn't run simnet without --rejectnonstd so the rpctest
harness setup was left without this.

This ended up letting a bug slip through that would prevent tadds being
added to mempools and relayed through the network.
2020-10-13 13:29:31 -05:00
Dave Collins
9f43c1742e
mempool: Allow treasury txn vers as standard.
This updates the server configuration of the mempool to allow
transactions with the treasury transaction version to ensure they are
able to relay properly when/if the treasury agenda becomes active.

It also updates the test configuration to use the constant instead of a
hard-coded number.
2020-10-12 21:13:21 -05:00
Dave Collins
615072ef73
docs: Update JSON-RPC API examples.
This updates the JSON-RPC API documentation examples to use the latest
released module versions.
2020-10-07 10:27:49 -05:00
Dave Collins
6fd59228f3
docs: Update simnet env docs for ticket exhaustion.
This updates the simnet environment documentation for the changes that
prevent creating block templates for blocks that would lead to ticket
exhaustion.
2020-10-06 15:24:49 -05:00
Dave Collins
f1e004695e
blockchain: Simplify old block ver upgrade checks.
This converts the series of checks that rejects old block versions once
a majority of the network has upgraded to a loop.

When there were only a few this didn't matter, but as the number grows,
it is nicer to only need to change the number in a single place.
2020-10-06 13:06:33 -05:00
Dave Collins
d6c152c04c
blockchain: Reject old block vers for tsry vote.
This add the code necessary to reject old block versions once the
upgrade process to reach the block versions necessary to start the
treasury HFV has a super majority.
2020-10-06 12:44:39 -05:00
Dave Collins
4759ee1105
multi: Address some linter complaints. 2020-10-06 12:29:14 -05:00
Dave Collins
ccf024f771
mining: Add ticket exhaustion check.
This modifies the mining template creation logic to make use of the new
ability to check if the template would result in an unrecoverable chain
due to inevitable ticket exhaustion along with an associated new mining
rule error.
2020-10-05 19:29:28 -05:00
Dave Collins
fae24bb0ca
blockchain: Add ticket exhaustion check.
This adds a new function named checkTicketExhaustion which will return
a new rule error if extending a given block with another block that contains a
specified number of tickets will result in an unrecoverable chain due to
inevitable ticket exhaustion along with tests to ensure proper
functionality.

The approach taken is such that it should be easy to use in a future
consensus change gated behind a vote if that is ultimately desired,
which I personally think would be a good idea.

An exported variant is also provided that takes the hash of the block to
extend for use by external callers such as the mining template code.
2020-10-05 19:29:27 -05:00
Matheus Degiovani
492a4a943f mining: Remove unneeded disapproval check
This removes a now unneeded check for unmineable transactions due to
block disapproval from the template generation code.

Previously this check was meant to ensure that the list of transactions
considered for inclusion in a block template did not include
transactions with an input referencing a regular transaction from a
parent disapproved block.

However this check is redudant due to check executed earlier in the
template building loop that asserts all inputs are valid utxos
according to the PoV of the parent block and taking into account whether
the new block being created will approve or disapprove it.

The check being removed had a bug due to the dcrutil.Tx being duplicated
without also copying the internal tree, which caused transactions to
later fail to be added to the template due to an unknown tree being
used.
2020-10-05 19:26:33 -05:00
Dave Collins
50dd5bb88a blockchain: Rework AdvanceToHeight.
This reworks the AdvanceToHeight method introduced in the previous
commit to resolve various issues with it and simplify the code.
2020-10-05 17:43:10 -05:00
Donald Adu-Poku
da7b0ee837 blockchain: Add chaingen harness AdvanceToHeight.
This adds AdvanceToHeight to the chaingen harness to allow advancing the
chain to an arbitrary height while controlling the number of tickets
purchased per block after the first coinbase maturity.
2020-10-05 17:43:10 -05:00
Donald Adu-Poku
bf7072fb65 chaingen: implement DCP0001 for generator.
This ports the current stake difficulty algorithm (DCP0001) to the
generator.
2020-10-01 16:42:21 -05:00
Dave Collins
4e5a796e33
blockchain/standalone: Prepare v2.0.0.
This updates the copyright year in the files modified in the
blockchain/standalone module since the previous release and serves as a
base for blockchain/standalone/v2.0.0.

The full list of updated direct dependencies since the previous
blockchain/standalone/v1.1.0 release are as follows:

- github.com/decred/dcrd/wire@v1.4.0
2020-09-30 11:23:35 -05:00
Dave Collins
7a67caa4fb
docs: Update for blockchain/standalone v2 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-09-30 11:23:33 -05:00