Commit Graph

3991 Commits

Author SHA1 Message Date
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
Dave Collins
7b8f0dcee7
rpcserver: Allow scripthash addrs in createrawsstx.
This modifies the createrawsstx handler to accept pay-to-script-hash
addresses for the voting address since they are also valid.
2018-09-10 09:52:24 -05:00
Dave Collins
c409f53300
blockchain: Reduce block availability assumptions.
This modifies the code in blockchain to make less assumptions about the
availability of the block data by checking the status flags to determine
whether or not it is available.

While currently there aren't actually ever any nodes in the block index
that don't have the full block data available, that will not always be
true in the future.
2018-09-10 09:32:34 -05:00
Dave Collins
5db19ddcab
multi: Include additional fields on RPC tx results.
This modifies the results provided by the getrawtransaction and
searchrawtransactions RPCs to make them consistent with each other.

In particular, it adds the transaction expiry, block height, and block
index fields to the searchrawtransactions result and ensures that both
omit the block height when it is zero so that it is not included in the
results for mempool transactions.

Since populating the block index requires additional details to be
stored to the transaction index to efficiently provide, only the
infrastructure is added and the value is left as the default for now,
which means it will be omitted and therefore not change the visible
behavior.

Finally, it also updates the RPC server help to provide consistent
descriptions for the fields and also updates the JSON-RPC documentation.
2018-09-10 09:18:01 -05:00
Dave Collins
830aa6bcbc
indexers: Use testable bucket for existsaddrindex.
This modifies the functions in the exists address index to use the
internalBucket interface instead of directly taking a database.Bucket
interface.  This allows tests to mock the data the source and is
consistent with the address index.
2018-09-10 08:51:13 -05:00
Dave Collins
c5e3320f57
indexers: Remove unneeded existsaddrindex iface.
This removes the implementation of the NeedsInputser interface on the
exists address index since not implementing the interface is the same as
implementing it and returning false.

This is desirable because not only is it less code, it is consistent
with the transaction index.
2018-09-07 18:43:48 -05:00
Dave Collins
61cdcb81fc
limits: Make limits package internal. 2018-09-06 15:19:25 -05:00
Josh Rickmar
00a3f0eb60 peer: Protect handlePongMsg with p.statsMtx 2018-09-06 14:48:29 -04:00
Dave Collins
999ee7d863
multi: Make use of new internal version package.
This introduces a new internal package named version to house the
version information and updates the various code to use it.  This allows
both dcrd and dcrctl to make use of the package so the version
information only needs to be bumped in one place and also ensure that
any link-time overrides to the pre-release and/or build metadata apply
to both.

Also, while here, include the OS and architecture in the version log at
start of day as well as the output from the version CLI flag.
2018-09-04 17:34:31 -05:00
Dave Collins
2a18beb4d5
blockchain: Correct best pool size on disconnect.
This corrects the NextPoolSize field that was recently added to the best
state when a block is disconnected to calculate the next pool size
relative to the previous block since it will become the new best state.
2018-08-31 12:46:36 -05:00
Dave Collins
b4de1f178f
dcrec: Make function defs more consistent.
This makes the style of the function definitions in the dcrcec/edwards
package more consistent with the code throughout the rest of the code
base.

Also, move the nil check for pubkey parsing to the top of the function
before any more work is done.
2018-08-31 11:38:02 -05:00
Matheus Degiovani
e21c6b6af5 blockmanager: handle txs in invalid blocks
Current code results in transactions from invalidated blocks being
removed from the mempool instead of remaining there to be mined in a
future block.

The new version ensures that transactions are *only* removed once they
are in a block voted as valid.

This only applies to regular transactions, since stake transactions are
not affected by the validity bits.
2018-08-31 06:17:21 -05:00
Matheus Degiovani
56f1981127
mempool: tweak trace logs
This improves trace logs related to transaction removal from the
mempool. During some debugging, they were found to be slightly
misleading in their current form.
2018-08-28 16:07:00 -03:00
Dave Collins
083d446645 TravisCI: Update for Go1.11 and module builds. 2018-08-23 12:52:07 -05:00
Dave Collins
ca3f5bd39b multi: Make changes suggested by Go 1.11 gofmt -s. 2018-08-23 12:52:07 -05:00
Donald Adu-Poku
c540c2c69a blockchain: update BestState.
This adds PrevHash, NextPoolSize, NextStakeDiff, NextWinningTickets,
MissedTickets  and NextFinalState fields to BestState.

Port of upstream commit c57c18c. In preparation of the removal of
chainState.
2018-08-22 22:03:20 +00:00
Dave Collins
a1985a4b3a
release: Bump for 1.4 release cycle.
This marks the start of a new release process as compared to previous
releases.

Instead of bumping the version just before a release and releasing from
the master branch, as has been done up to this point, the minor (or
major when necessary) will now be bumped on the master branch at the
beginning of a release cycle.  In addition, the pre-release portion of
the semantic version is now the string "pre" to help make it more
obvious that the master branch represents a pre-release build of work
leading up to the next release.

When a new release is prepared, a new release branch will be created
that has a naming scheme of "release-vX.Y", where X is the major and Y
is the minor.  Any additional commits needed to prepare the release
leading up to a release candidate will be cherry-picked to the release
branch, and all tags for releases and release candidates will be created
against that.

This implies that should any additional patch releases be necessary, the
relevant commits will also be cherry-picked to the release branch as
needed, followed by a new release candidate for the patch release and
the eventual patch release.
2018-08-21 13:55:03 -05:00
Dave Collins
97a8f5f34c
peer: Add support for specifying ua comments.
This adds a new parameter named UserAgentComments to the peer Config
struct so that callers may specify additional comments to add to the
user agent string.

It also updates the server to include the prelease portion of the
semantic version as a comment when creating peers.
2018-08-21 13:44:01 -05:00
Dave Collins
36f61d8ebd build: Tidy module sums (go mod tidy). 2018-08-16 20:03:27 -05:00
Dave Collins
20eda7ec92
database: Use module-scoped data in iface tests.
This updates the interface tests in database/ffldb to reference the
block tests within the same module as opposed to escaping the module to
find it in the blockchain module.

This should have been a part of the previous commit that performs the
same, but was missed.
2018-08-16 16:26:43 -05:00
Dave Collins
e7495b5b38
blockchain: Use temp dirs for fullblocks test.
This modifies the fullblocktests that create a temporary database to
make use of ioutil.TempDir instead of a relative directory path.  This
allows the tests to be run from any path without failure.
2018-08-16 16:16:53 -05:00
Dave Collins
90d73a17d3
multi: Only use module-scoped data in tests.
This updates the tests in database/ffldb and blockchain/stake to
reference the block tests within the same module as opposed to escaping
the module to find it in the blockchain module.

This is necessary for the new test all functionality of the upcoming
go1.11 release since it individually tests each module in a separate
path and therefore it prevent the ability to use relative paths that
escape the module.

Unfortunately, this means the data had to be copied, but, but it's not a
huge amount of data, and it seems that git mostly deduplicates the data
internally.
2018-08-16 15:08:07 -05:00
Dave Collins
3e21bdaa89
multi: Use temp directories for database tests.
This modifies the various tests that create temporary databases to make
use of ioutil.TempDir instead of a relative directory path.  This allows
the tests to be run from any path without failure.
2018-08-16 14:13:56 -05:00
Dave Collins
05e242da0f
rpcserver: Cleanup cfilter handling.
This modifies the getcfilter and getcfilterheader RPC handlers to return
an error when an unknown block is provided as opposed an empty filter in
the case of the former and an all-zero hash in the case of the latter.

It also modifies the error returned when an unknown filter type is
specified to indicate an invalid parameter as opposed to a misc error so
it is more consistent with the other handlers.

Finally, it removes the debug logs in the error cases since the errors
are now returned to the caller.
2018-08-15 12:55:53 -05:00
David Hill
e4bdae9b0c gcs: use dchest/siphash 2018-08-14 17:13:22 -04:00
Dave Collins
8aa47c1a23
blockchain: Mark fastadd block valid.
This modifies the block connection logic to also mark the status of
blocks that are not already known to be valid in the fast add code path
as valid.

This change is being made because the intent of the fast add path is to
skip expensive checks on blocks which are already assumed to be valid
due to checkpoints and therefore should be marked accordingly.

Also, since the status for those blocks in the block index does not have
them marked valid, mark them all ancestors of the current tip as valid
init time.
2018-08-14 05:02:30 -05:00
Dave Collins
ae9c2aae56
docs: Update docs for versioned modules.
This updates the overall docs README to include all of the new modules
as well as introduce a module hierarchy diagram.
2018-08-14 04:53:08 -05:00
Sarlor
b232e6564e mempool: Correct min relay tx fee comment to DCR.
This corrects the comment for the MinRelayTxFee constant to correctly 
refer to DCR/kB instead of BTC/kB.
2018-08-14 04:52:04 -05:00
Dave Collins
9536f0c88f
release: Bump module versions and deps.
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.
2018-08-09 14:30:22 -05:00
Dave Collins
f0e65ec62f config: Warn if testnet2 database exists. 2018-08-08 10:36:11 -05:00
Dave Collins
553c8a6efb
release: Bump for v1.3.0. 2018-08-08 09:09:04 -05:00
Dave Collins
8fda21512f
multi: Remove testnet version 2 defs and refs.
This removes all definitions and references to the no longer available
testnet2 network.
2018-08-08 08:10:22 -05:00
Dave Collins
9e1579771b
multi: Reset testnet and bump to version 3.
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.
2018-08-08 08:09:32 -05:00
Dave Collins
74c9622e22
blockchain: Modify diff redux logic for testnet.
This modifies the logic which allows the reduction of difficulty on
testnet to match the upstream code such that after a block has not been
produced for a long period of time, as configured by the parameters, the
difficulty drops to the minimum allowed by the configured proof-of-work
limit for the network.

It should be noted that this would be a hard fork if the test network
had the code path enabled, however, since the code is disabled for
testnet2, it does not technically change the consensus rules for it.

The modified code will be active for testnet3.
2018-08-08 06:41:56 -05:00
Dave Collins
96a1a8546d
multi: Reduce testnet2 refs in unit tests.
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.
2018-08-08 06:41:50 -05:00
Dave Collins
1e0133e787
multi: Remove unnecessary network name funcs.
This removes the funcs which were used to override the test network name
as they were inherited from the upstream code and, once testnet v2 was
introduced, were no longer needed, but unfortunately weren't removed
accordingly.
2018-08-08 06:22:06 -05:00
Dave Collins
83a4903f81
chaincfg: Add checkpoints for upcoming release.
This adds a checkpoint to mainnet at height 259810.
2018-08-07 11:46:16 -05:00
Dave Collins
295179fc0d
build: Refine build module support.
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
2018-08-05 20:45:45 -05:00
Dave Collins
e2232a5c3d
dcrjson: Remove unused vote bit concat codec funcs.
These functions and associated tests are being removed because nothing
depends on them and they end up creating a dependency on
blockchain/stake package, which is not desirable.
2018-08-05 16:24:56 -05:00
Dave Collins
0761de1291 Sync upstream through 70db3246. 2018-08-01 15:22:39 -05:00
Donald Adu-Poku
e488d410da mempool: Stricter orphan evaluation and eviction.
This modifies the way orphan removal and processing is done to more
aggressively remove orphans that can no longer be valid due to other
transactions being added or removed from the primary transaction pool.

The net effect of these changes is that orphan pool will typically be
much smaller which greatly improves its effectiveness.  Previously, it
would typically quickly reach the max allowed worst-case usage and
effectively stay there forever.

The following is a summary of the changes:
- Modify the map that tracks which orphans redeem a given transaction to
  instead track by the specific outpoints that are redeemed
- Modify the various orphan removal and processing functions to accept
  the full transaction rather than just its hash
- Introduce a new flag on removeOrphans which specifies whether or not
  to remove the transactions that redeem the orphan being removed as
  well which is necessary since only some paths require it
- Add a new function named removeOrphanDoubleSpends that is invoked
  whenever a transaction is added to the main pool and thus the outputs
  they spent become concrete spends
- Introduce a new flag on maybeAcceptTransaction which specifies whether
  or not duplicate orphans should be rejected since only some paths
  require it
- Modify processOrphans as follows:
  - Make use of the modified map
  - Use newly available flags and logic work more strictly work with tx
    chains
  - Recursively remove any orphans that also redeem any outputs redeemed
    by the accepted transactions
- Several new tests to ensure proper functionality
  - Removing an orphan that doesn't exist is removed both when there is
    another orphan that redeems it and when there is not
  - Removing orphans works properly with orphan chains per the new
    remove redeemers flag
  - Removal of multi-input orphans that double spend an output when a
    concrete redeemer enters the transaction pool

Ticket purchase, vote and revocation orphan tests have also been added.
2018-08-01 18:56:30 +00:00
Donald Adu-Poku
3978c40b50 txscript: add/group crypto related op code tests. 2018-07-29 23:06:54 -05:00
Donald Adu-Poku
4fcdfab3c2 txscript: group reserved op code tests.
this groups reserved op codes and moves some dangling tests to their respective groups.
2018-07-29 22:46:55 -05:00
Donald Adu-Poku
1ce290d979 txscript: add/group numeric related opcode tests. 2018-07-29 21:10:59 -05:00
vctt94
aafe460fd9 dcrjson: add fundrawtransaction command 2018-07-29 02:04:04 -05:00
Donald Adu-Poku
315e0a9acd txscript: add/group bitwise logic, comparison & rotation op code tests. 2018-07-27 21:24:28 +00:00
Donald Adu-Poku
245c82557c txscript: group splice opcode tests. 2018-07-26 16:30:02 -05:00