Commit Graph

4037 Commits

Author SHA1 Message Date
Corey Osman
ea54d032df rpcserver: Adds ability to allow alternative dns names for TLS.
- rpcserver: Adds ability to allow alternative dns names for TLS.
- Adds AltDNSNames config for passing additional hostnames to the
  TLS certificate generate method.  Without this change there is no
  way to pass in alternative dns names for the rpc server.
- Additionally this commit allows the user to set 'DCRD_ALT_DNSNAMES'
  as an environment variable when starting dcrd.  This is useful for
  docker and other app runtimes that require apps to be 12 factor.
2018-10-10 23:40:40 -05:00
Dave Collins
8c588a6b4d
docs: Add README badge and link for goreportcard. 2018-10-10 19:50:31 -05:00
Dave Collins
bd3a416cae
multi: Address some golint complaints. 2018-10-10 19:50:06 -05:00
Dave Collins
2606af87ec
multi: Correct a few typos found by misspell. 2018-10-10 19:49:23 -05:00
Dave Collins
527399b852
chaincfg: Unexport internal errors.
These errors are only used internally and thus should not be exported.

While here, it also removes the completely unused VoteBitsNotFound
error.

It should be noted that this is a breaking change to the API and thus
will need a v2 major version bump of the chaincfg module to be published
before the changes can be externally consumed.
2018-10-10 17:56:16 -05:00
Dave Collins
81c76dcb78
multi: Break blockchain dependency on dcrjson.
This modifies the ChainTips function in blockchain to return the results
using a type defined in the blockchain package itself instead of
directly returning a dcrjson type.  This is preferable since nothing
else in the module depends on dcrjson and therefore allows the
dependency on the dcrjson module to be broken.

It also updates the RPC server that makes use of the function to perform
the necessary conversions.

Finally, the associated module hierarchy documentation is updated to
properly remove the no longer required dependency.

It should be noted that this is a breaking change to the API and thus
will need a v2 major version bump of the blockchain module to be
published before the changes can be externally consumed.
2018-10-10 16:44:20 -05:00
Dave Collins
15f7f61e32
multi: Latest consensus active from simnet genesis.
This modifies simnet to include the latest consensus changes that have
been successfully voted into mainnet to date starting from its genesis
block.  This means it is no longer necessary to vote those changes in to
simnet first before making use of them.

The changes entail removing the deployment entries for those votes,
updating the mining templates to start from version 5, which matches the
current mainnet version, and modifying the various sections in
blockchain which make decisions accordingly.

The chaincfg and blockchain modules are affected, but since their
version has already been bumped since their last release tags, they are
not bumped again.
2018-10-10 15:58:53 -05:00
Dave Collins
0d3bbd2513
docs: Use unix line ending in mod hierarchy gv.
This converts the module hierarchy graphviz file to use unix line
endings so it is consistent with the rest of the code in the repository.
2018-10-10 13:12:31 -05:00
Dave Collins
6f9b6f1c6e
multi: Use regression test network in unit tests.
This modifies the majority of the tests that make use of chain
parameters and the RPC tests to use the resurrected regression test
network.

It also bumps the affected module versions as follows:

- github.com/decred/dcrd/txscript@v1.0.2
- github.com/decred/dcrd/blockchain/stake@v1.0.3
- github.com/decred/dcrd/mempool@v1.0.2

The blockchain and dcrutil modules are also affected, but since their
version has already been bumped since their last release tags, they are
not bumped again.
2018-10-09 19:40:10 -05:00
Dave Collins
47ade78c1a
multi: Resurrect regression network.
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.
2018-10-09 18:52:13 -05:00
Donald Adu-Poku
1ec04c40a2 multi: Add getblockchaininfo rpc. 2018-10-09 18:28:17 -05:00
vracek@protonmail.com
52109eab99 dcrjson: additions for pay to contract hash 2018-10-08 16:16:16 -05:00
Dave Collins
7e3dfb2197
build: Support MacOS sed for obtaining module list.
This modifies the code in run_tests.sh which obtains the stripped list
of modules to test based on the output of the go list command to work
with MacOS as well.  It seems that sed on MacOS does not like the "or"
regexp syntax, so this modifies it to perform each branch separately.
2018-10-08 12:32:17 -05:00
Dave Collins
5b80187e61
chaingen/fullblocktests: Add disapproval tests.
This adds some tests to ensure blocks that disapprove the regular
transaction tree of the parent as follows:

- Attempt to spend an output from a disapproved tree in the block that
  disapproves it is rejected
- Reorg to a side chain that contains two consecutive blocks that
  disapprove their parents is accepted without error
- Reorg back to the original chain which causes the disapproving blocks
  to be removed is accepted without error

While here, it adds a new function named AssertTipDisapprovesPrevious
which, as its name suggests, allows the caller to assert the vote bits
in the header disapprove of the previous block.
2018-10-08 10:44:33 -05:00
Dave Collins
a24e640ffb
chaingen: Only revoke missed tickets once.
This modifies the test chain generator infrastructure that automatically
tracks missed votes and generates revocations for them to only generate
a single revocation and properly handle reorgs by removing revoked
tickets from the pool of missed tickets when a block is connected and
adding back any revoked tickets to the pool of missed tickets when a
block that contains them is disconnected.

In addition, it modifies the handling of stake ticket purchases such
that the associated ticket purchases are created after the munge
functions run to ensure all changes are accurately account for.  In
particular, the indexes of the ticket purchase transactions within the
block can change if the munger adds or removes transactions before them.

This allows the large reorg tests to work as intended again.
2018-10-08 00:47:40 -05:00
Dave Collins
979d21f6f3
docs: Add github pull request template.
This adds a pull request template which provides a checklist and links
to the code contribution guidelines to help contributors ensure they are
adhering to project standards.
2018-10-01 11:32:16 -05:00
Dave Collins
b413da2350
blockmanager: Avoid duplicate header announcements.
Clients are able to choose between two modes of notification about new
blocks via the wire protocol.  The first, and current default, is via
inv messages and the second is via direct header announcements.

There is code in the peer package which deals with filtering duplicate
inventory announcements via the QueueInventory message.  This works as
expected for inv-based announcements, however, direct header
announcements are not inv messages and hence do not use that code path.

Consequently, the recent addition of the fast relay path which relied on
that filtering to avoid sending duplicate announcements resulted in
duplicate announcements being sent to peers who requested the header
announcements mode.

This resolves the issue by adding some logic directly to the
notifications themselves to deal with filtering duplicates, both for inv
and header-based announcements.
2018-09-28 12:44:50 -05:00
J Fixby
b6d564d119 main: add address encoding magic constants test
main: add address encoding magic constants test

Ensures address encoding magics and NetworkAddressPrefix are consistent
with each other. This test will light red when a new network is started
with incorrect values.
2018-09-26 16:09:11 -05:00
Dave Collins
42bc847479
multi: Cleanup and optimize tx input check code.
This optimizes and cleans up significant portions of the
CheckTransactionInputs function to avoid a lot extra allocations, remove
redundant checks, better document its semantics, and make the code
easier to reason about.  In addition, it renames a lot of the error
constants involved in said function to use the ticket/vote/revocation
terminology and improve their readability.  Even though several of the
checks have been rearranged for efficiency and readability purposes, all
consensus semantics have been retained.

One of the primary changes is to reduce the reliance on the stake package
for consensus validation.  Not only is more desirable to have the bulk
of the validation related to the blockchain in the blockchain package,
but it also allows the code to be more specific, which enables better
optimization opportunities as well as eliminates the need for a lot of
redundant checks that are simply unnecessary.

The stake identification functions are also part of consensus and have
not been modified, however, the actual validation related to all of
their inputs, such as ensuring commitments are observed, are now in the
blockchain package itself.

Since the only thing using the related verification functions is now
done in blockchain, this also removes the VerifyStakingPkhsAndAmounts,
VerifySStxAmounts, and related tests from the stake package.

Another significant change is the addition of new functions for
efficiently and specifically identifying the form of the scripts
required by stake transactions in order to reduce the dependence on the
standard code in txscript.  Standard code should _NOT_ be used in
consensus code as the two are not the same thing.

It should be noted that these changes break compatibility with the
current v1 blockchain and stake modules, so they will need a major
version bump prior to the next release.

Finally, all tests in the repository have been updated for the error
name changes as well as change in expected error in some cases due to
the reordering of the validation checks.
2018-09-26 09:23:03 -05:00
Jonathan Chappelow
9313309623 rpcclient: support getchaintips RPC
This adds support for the getchaintips RPC to rpcclient, adding
asynchronous and blocking functions to rpcclient.Client.
2018-09-26 08:59:34 -05:00
Dave Collins
ea8aa1ee57
blockchain: Store interrupt channel with state.
This modifies the Blockchain struct to keep a reference to the interrupt
channel (if any) provided by the caller.  While currently it is not used
outside of the initialization path, having it available in the state
will be useful for other use cases such as being able to decouple reorgs
from the download state and allowing interrupts of long reorgs.
2018-09-21 19:22:02 -05:00
Dave Collins
e0ce731efe
blockchain: Move unique coinbase func to validate.
This moves the checkCoinbaseUniqueHeight function from accept.go to
validate.go where it more naturally belongs as it is a validation
function.  This is also evidenced by only being called from validation
functions as well.
2018-09-21 15:56:33 -05:00
Dave Collins
07f87fd517
blockchain: Move finalized tx func to validation.
This moves the IsFinalizedTransaction function from accept.go to
validate.go where it more naturally belongs as it is a validation
function.  This is also evidenced by only being called from validation
functions as well.
2018-09-21 15:52:38 -05:00
David Hill
8e71fd006a docker: Update to go 1.11. 2018-09-20 13:25:35 -05:00
Marco Peereboom
d6d5e55843 Use the correct binary name 2018-09-20 10:34:02 -05:00
Dave Collins
c2d00964ca
build: Remove dep toml and lock file.
Now that everything has transitioned over to Go module builds, remove
the dep files that are no longer supported.
2018-09-17 15:57:05 -05:00
Dave Collins
37315c030b
blockchain: Ensure no stake opcodes in tx sanity.
This moves the check for validating that output scripts in non-stake
transactions do not contain any of the opcodes only allowed in the stake
tree to the CheckTransactionSanity function where it more naturally
belongs since it does not require access to transaction inputs as its
location in CheckTransactionInputs would otherwise indicate.

It should be noted that the check just before the one being moved in
this change is removed because it checked that specific patterns
involving stake opcodes where not being used in non-stake transactions
which is a strict subset of the more general check which ensures there
are no stake opcodes at all in the output scripts.

Also, to improve efficiency, the check is added to the existing loop
which already iterates the outputs and the entire block is moved after
some other faster checks.

Finally, since the transaction sanity code previously did not determine
if the transaction is a stake transaction which is required for the
check in question, this adds code to relatively efficiently determine
that.
2018-09-14 13:42:08 -05:00
Dave Collins
7ae066f5ef
blockchain: Separate tx input stake checks.
This separates all of the validation checks in CheckTransactionInputs
related to each allowed type of stake transaction into separate
functions dedicated to each type.

It also renames the utxo view parameter to CheckTransactionInputs to be
consistent with the name used in other functions throughout the package.

It does not perform any additional cleanup beyond the separation and
does not have any functional changes.
2018-09-14 13:38:55 -05:00
Dave Collins
b6c088dc0d
multi: No stake height checks in check tx inputs.
This removes a redundant check for validating that votes and revocations
are not in a block before they are allowed from CheckTransactionInputs since
it has nothing to do with validation of transaction inputs and it's an
impossible condition to hit in the block validation path because the
same check is done much earlier in the validation process.

It should also be noted that the checks this removes are also more
permissive than they need to be because the first vote is not allowed
until stake validation height, which is after stake enabled height.
There is no effect on consensus because, as previously mentioned, the
more restrictive checks earlier in the process prevent these checks from
ever being exercised.

However, the mempool previously relied on this duplicate check to reject
early votes and revocations, so this adds the checks, with the corrected
heights, directly to the mempool early in the process where they more
naturally belong.  It is more efficient to reject the transactions in
that scenario earlier before doing more work as well.
2018-09-14 12:59:06 -05:00
Dave Collins
06d00215e8
mempool: Stake-related readability improvements.
This does some minor cleanup of the code in the maybeAcceptTransaction
function to use some local bools with more easily readable names for
dealing with stake transactions.

It also improves the readability of the double spending exceptions
section and avoids some additional if statements.
2018-09-14 11:58:28 -05:00
Dave Collins
2d6a3dd4a2
mempool: Remove potential negative locktime check.
This removes the standardness check to reject transactions with a lock
time greater than a maxint32 because the requirement for the check was
due to legacy Bitcoin reasons that have never applied to Decred.
2018-09-14 11:11:37 -05:00
Dave Collins
2dcfb0a6da
multi: Move update blk time to blk templ generator.
This moves the UpdateBlockTime function to the recently introduced
BlkTmplGenerator type in order to break its dependence on the block
manager.
2018-09-13 23:32:58 -05:00
Dave Collins
79da9e6617
docs: Use relative versions in contrib checklist. 2018-09-13 15:15:15 -05:00
Donald Adu-Poku
88ca6f5525 multi: add cpuminerConfig.
Port of upstream commit 6719014.
2018-09-13 12:24:42 -05:00
Dave Collins
4a503a0f12
rpcserver: Remove createrawssgen RPC.
This removes the handler for the createrawssgen RPC and deprecates the
associated dcrjson structures.

This is being done because it doesn't make any sense for votes to be
created over the RPC interface.  In order for voting on the previous
block to have any semblance of relevance, the software producing the
vote clearly must have code to deserialize and understand the relevant
data structures.
2018-09-12 17:40:54 -05:00
Dave Collins
7ed83ceac4
blockchain: Avoid deployment expiration in tests.
This modifies the test code which deals with testing feature deployments
to clone the parameters and modify them such that the deployment being
tested never expires.
2018-09-12 17:36:52 -05:00
Dave Collins
817373d9d7
docs: Revamp main README.md and update docs.
This revamps the main README.md file in an attempt to provide a more
user-friendly introduction to the software and why someone would want to
run it and also updates the docs/README.md to remove some sections that
do not apply to Decred and update some others to reflect reality.

It also adds minimum recommended specifications for dcrd to the main
README.md and updates the build instruction for module-aware builds and
the recent changes the run_test.sh script.

Finally, it updates the contact information to point to the
decred.org/community page.
2018-09-12 15:11:03 -05:00
Donald Adu-Poku
e8e9f90c26 multi: add BlkTmplGenerator.
Port of upstream commit 74fe2a4. In preparation of moving all
mining related code into the mining package.
2018-09-12 17:18:44 +00:00
Donald Adu-Poku
3b33c0cc93 multi: move MinHighPriority into mining package.
Port of upstream commit a18f883.
2018-09-12 15:40:55 +00:00
Donald Adu-Poku
7b22549dcf blockmanager: remove block manager chain state.
Port of upstream commit 2274d36 (subset).
2018-09-12 15:39:31 +00:00
Donald Adu-Poku
c0b0b6c2bb multi: remove chainState deps in server & cpuminer.
Port of upstream commit 2274d36 (subset). In preparation of the
removal of chainState.
2018-09-12 15:28:45 +00:00
Donald Adu-Poku
fbbfb22c1f mining: remove chainState dependency.
Port of upstream commit 2274d36 (subset). In preparation of the
removal of chainState.
2018-09-12 15:24:35 +00:00
Donald Adu-Poku
3921320d55 multi: remove chainState dependency in rpcserver.
this updates the function signatures of minimumMedianTime and
medianAdjustedTime and removes all chainState usage  in
rpcserver.go in favour of using BestState.

Port of upstream commit 2274d36 (subset). In preparation of the
removal of chainState.
2018-09-12 10:06:33 -05:00
Donald Adu-Poku
60cbb70c67 txscript: add stake opcode tests. 2018-09-11 20:21:42 +00:00
Donald Adu-Poku
e0222e383c txscript: add p2sh opcode tests. 2018-09-11 20:14:29 +00:00
Donald Adu-Poku
566bb6625b txscript: group numeric encoding tests with their opcodes.
This also moves some dangling tests to their respective opcode groupings as well as some updates to  test comments.
2018-09-10 17:48:02 -05:00
Dave Collins
fefb89277a
blockmanager: Fast relay checked tip blocks.
This makes use of the newly exposed notification from blockchain when a
block that intends to extend the main chain has passed all sanity and
contextual checks to relay the block the rest of the network at that
point rather than needing to wait for the more expensive connection code
to complete.
2018-09-10 09:57:53 -05:00
Dave Collins
bf95e0fcf8
blockchain: Add new tip block checked notification.
This adds a new notification type to blockchain which allows the caller
to be notified when a block that intents to extend the main chain has
passed all sanity and contextual checks such as having valid proof of
work, valid merkle and stake roots, and only containing allowed votes
and revocations.

The intention is to allow faster relay of new tip blocks throughout the
network by providing a means to relay it before the more expensive
connection code takes place even though it may ultimately fail to
connect.

This is acceptable because blocks that pass all of the aforementioned
checks and then fail to connect are quite rare since it takes a
significant amount of work to create a block which satisfies the proof
of work requirement as well as all other checks up to that point.
2018-09-10 09:57:52 -05:00
Dave Collins
a3b09ccda2
server: Add infrastruct for immediate inv relay.
This modifies the infrastructure for the server inventory relay to allow
the caller to specify the inventory should be announced immediately
versus using the typical trickle mechanism.

It also updates all callers in the repository and changes the relay of
accepted blocks use the new ability.
2018-09-10 09:57:52 -05:00
Dave Collins
d051b8aacd
peer: Provide immediate queue inventory func.
This adds a new function to peers which allows an inventory vector to be
queued for immediate send versus the standard trickling batched
inventory queue method while still respecting the functionality which
filters attempts to notify peers about inventory that they are already
known to have.
2018-09-10 09:57:51 -05:00