Commit Graph

3964 Commits

Author SHA1 Message Date
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
Dave Collins
b968b406bb
blockchain: Make block index flushable.
This modifies the block index to support tracking modified nodes and
flushing them to the database.  This ensures that validation states set
on arbitrary nodes are persisted to the database and helps pave the way
towards supporting decoupling the chain processing logic from the
download logic.

In the immediate term, as of this commit, side chains which encounter an
invalid block will no longer potentially have to be revalidated to
discover they are invalid after restart.

A few comments are also improved while here.
2018-07-26 15:52:51 -05:00
Dave Collins
46b081c96d
blockchain: Optimize reorg to use known status.
This optimizes the chain reorganization logic by making use of the
block index status flags for known valid and invalid blocks.

In particular, validation is now skipped for blocks that are either
already known valid or invalid.  When validating blocks, the result is
stored into the block index for the block accordingly, and in the case
of blocks that fail validation, all of the descendants of the invalid
block are marked as having an invalid ancestor.

It also introduces a new error named ErrKnownInvalidBlock which is
returned in the case a forced reorg is attempted to an invalid block and
adds a test to ensure it works as intended.
2018-07-26 15:20:28 -05:00
Donald Adu-Poku
34a33e1e57 txscript: add/group stack op code tests. 2018-07-25 23:28:45 -05:00
Dave Collins
a98388619f
mempool: Make expiry pruning self contained.
This modifies the mempool to handle pruning of expired transactions in a
self-contained way so that the caller is not responsible for worrying
about the specific semantics of height and expiration interplay and
updates all callers in the repository accordingly.

It also adds a test which ensures the behavior is correct by creating a
series of transactions with expirations, adding them just before the
point at which they will expire, and then advancing the chain so that
each transaction expires and thus should be pruned.
2018-07-25 23:10:22 -05:00
David Hill
f2624daab4 blockmanager: make pruning transactions consistent. 2018-07-25 11:32:40 -04:00
Donald Adu-Poku
59cc2a447e txscript: add/group control op code tests. 2018-07-24 23:02:25 -05:00
Dave Collins
2ba78e9a8e
dcrjson: Make linter happy by renaming Id to ID.
Also, update all callers in the repository while here.
2018-07-24 00:44:20 -05:00
Donald Adu-Poku
fb18a45553 txscript: add additional data push op code tests.
This adds tests for OP_DATA_[1...75], OP_1NEGATE, OP_RESERVED, OP_TRUE, OP_[1...16], OP_PUSHDATA1 and OP_PUSHDATA2.
2018-07-23 20:49:48 -05:00
Dave Collins
d75e22a52d
dcrjson: Consolidate tests into dcrjson package.
Putting the test code in the same package makes it easier for forks
since they don't have to change the import paths as much and it also
gets rid of the need for export_test.go to bridge.

Also, correct a couple of comments while here.
2018-07-23 18:20:13 -05:00
Dave Collins
67c4685987
database: Refine go build module support.
Now that the goleveldb, chainhash, dcrutil, wire, and slog modules have
been defined, create a database module that only depends on them instead
of the entire dcrd module.
2018-07-23 12:20:03 -05:00
Dave Collins
807b534d07
multi: Remove go modules that do not build.
This removes a bunch of build modules that rely on a version of dcrd
that doesn't exist and updates the root module so dcrd can be built with
the upcoming go1.11 release.
2018-07-21 17:59:44 -05:00
Dave Collins
4a3343f2f1
txscript: Refine go build module support.
Now that the chaincfg, chainhash, dcrec, edwards, secp256k1, dcrutil,
wire, and slog modules have been defined, update the txscript module to
only depend on them instead of the entire dcrd module.
2018-07-21 14:40:32 -05:00
Dave Collins
04be5e5efe
hdkeychain: Refine go build module support.
Now that the base58, chaincfg, chainhash, dcrec, secp256k1, and dcrutil
modules have been defined, update the hdkeychain module to only depend
on them instead of the entire dcrd module.
2018-07-21 14:07:38 -05:00
Dave Collins
520ad694fe
blockchain: Remove unnecessary genesis block check.
This modifies the checkConnectBlock function to remove the check which
tests if the block is the genesis block and returns an error since it is
no longer necessary due to other changes in the code since the function
was originally written.

In particular, the genesis block is valid by definition as the root of
the chain, so it does not make sense to try to connect it to a chain
that doesn't exist yet.
2018-07-21 13:53:59 -05:00
Dave Collins
5369a485ac
dcrutil: Refine go build module support.
Now that the base58, chaincfg, chainhash, dcrec, secp256k1, and wire
modules have been defined, update the dcrutil module to only depend on
them instead of the entire dcrd module.
2018-07-20 22:10:28 -05:00
Dave Collins
d26200ec71
certgen: Update go build module support.
This updates the certgen build module for the changes in the upcoming
go1.11 release.
2018-07-20 19:59:14 -05:00
Dave Collins
59fe2b293f
dcrec: Refine go build module support.
Update the dcrec and dcrec/edwards modules to only depend on on their
direct dependencies instead of the entire dcrd module.
2018-07-20 19:52:12 -05:00
Dave Collins
b5b24a7aa9
secp256k1: Refine go build module support.
Now that the chainhash module has been defined, update the secp256k1
module to only depend on it instead of the entire dcrd module.
2018-07-20 19:26:24 -05:00
Dave Collins
8f0af9c867
connmgr: Refine go build module support.
Now that the chaincfg, wire, and slog modules have been defined, update
the connmgr module to only depend on them instead of the entire dcrd
module.
2018-07-20 19:09:48 -05:00
Dave Collins
bb75b9c46d
chaincfg: Update go build module support.
This updates the chaincfg build module for the changes in the upcoming
go1.11 release and to depend on the latest chainhash and wire module
versions.
2018-07-20 18:47:32 -05:00
Dave Collins
46fe0ede74
addrmgr: Update go build module support.
This updates the addrmgr build module for the changes in the upcoming
go1.11 release and to depend on the latest chainhash and wire module
versions.
2018-07-20 18:12:01 -05:00
Dave Collins
95f450aa13
wire: Update go build module support.
This updates the wire build module for the changes in the upcoming
go1.11 release and to depend on the latest chainhash module version.
2018-07-20 17:49:56 -05:00
Dave Collins
4da20732f6
chainhash: Update go build module support.
This updates the chainhash build module for the changes in the upcoming
go1.11 release.
2018-07-20 17:27:06 -05:00
Dave Collins
9ef7db9b23
blockchain: Refactor to use new chain view.
This refactors and simplifies the code in blockchain to use the new more
efficient chain views.

An overview of the logic changes are as follows:

- Remove inMainChain from block nodes since that can now be efficiently
  determined by using the chain view
- Track the best chain via a chain view instead of a single block node
  - Use the tip of the best chain view everywhere bestNode was used
  - Update chain view tip instead of updating best node
- Remove height map and associated lock in favor of chain view
  - Use chain view NodeByHeight everywhere height map was used
- Change reorg logic to use more efficient chain view fork finding logic
- Change block locator code over to use more efficient chain view logic
  - Remove now unused block-index-based block locator code
  - Move BlockLocator definition to chain.go
  - Move BlockLocatorFromHash and LatestBlockLocator to chain.go
    - Update both to use more efficient chain view logic
- Rework several functions to use chain view for main chain detection
  - fetchMainChainBlockByNode
  - BlockByHeight
  - MainChainHasBlock
  - findPreviousCheckpoint
  - IsCheckpointCandidate
2018-07-20 17:19:52 -05:00
Dave Collins
6254feaeb8
blockchain: Faster chain view block locator.
This exposes the ability to more efficiently create a block locator from
a chain view for a given block node by using their ability to do O(1)
lookups.

It also adds tests to ensure the behavior is correct.
2018-07-20 16:54:15 -05:00
Josh Rickmar
60d7fe080f gcs: Pool MatchAny data allocations
This change optimizes the memory usage of gcs.MatchAny by introducing
a sync.Pool manage allocations of uncompressed match sets.

This change improves memory utilization for wallets which must execute
MatchAny against all block cfilters during rescanning.

benchmark                            old ns/op     new ns/op     delta
BenchmarkGCSFilterBuild50000-32      4112010       3874605       -5.77%
BenchmarkGCSFilterBuild100000-32     7913372       7462646       -5.70%
BenchmarkGCSFilterMatch-32           479           486           +1.46%
BenchmarkGCSFilterMatchAny-32        1577          1425          -9.64%

benchmark                            old allocs     new allocs     delta
BenchmarkGCSFilterBuild50000-32      30             30             +0.00%
BenchmarkGCSFilterBuild100000-32     33             33             +0.00%
BenchmarkGCSFilterMatch-32           0              0              +0.00%
BenchmarkGCSFilterMatchAny-32        2              0              -100.00%

benchmark                            old bytes     new bytes     delta
BenchmarkGCSFilterBuild50000-32      1202278       1202284       +0.00%
BenchmarkGCSFilterBuild100000-32     2496604       2496586       -0.00%
BenchmarkGCSFilterMatch-32           0             0             +0.00%
BenchmarkGCSFilterMatchAny-32        176           0             -100.00%
2018-07-12 11:05:57 -04:00
harzo
ddd66de604 connmgr: Fix the ConnReq print out causing panic 2018-07-11 06:26:24 -05:00