Commit Graph

2581 Commits

Author SHA1 Message Date
John C. Vernaleo
1001c19da0 Do not error if dcrctl can't find dcrd.conf.
Closes #303
2016-09-08 13:21:48 -04:00
C Jepson
9e2a8e1f0c Fix forced reorganizations (#330)
A bug in evaluating the correctness of a side chain block caused
forced reorganizations to fail post new database code. This was
corrected and children of the same parent at HEAD should now be
correctly evaluated and able to reorganize to one another without
issue. A test was also added for forced reorganizations.
2016-09-02 14:09:12 -04:00
John C. Vernaleo
6c162def5f Bump for v0.4.0 (#336) 2016-09-01 13:30:12 -05:00
Alex Yocom-Piatt
78035c2429 Use correct r.err in dcrdLog.Errorf msg (#333) 2016-08-31 10:15:05 -05:00
Josh Rickmar
6c1aa07a4f Add pipes for parent process IPC. (#311)
Rewrite startup/shutdown logic to simplify shutdown signaling.  All
cleanup is now run from deferred functions in the main function.

Add two new config options to set the read and write ends of a pair of
pipes.  This is used as a simple mechanism for a parent process to
communicate with, observe, and manage the lifetime of a child dcrd
process.  When the RX (read end) pipe is closed, clean shutdown
automatically begins.

Add a new flag --lifetimeevents to create and send lifetime event
notifications over the TX (write end) pipe during bringup and
shutdown.  This allows the parent process to observe which subsystems
are currently starting, running, and stopping.

Fixes #297.
Fixes #298.
2016-08-31 10:45:16 -04:00
jolan
f931a866be add more checkpoints for upcoming release (#329) 2016-08-30 12:35:09 -05:00
C Jepson
4960414937 Fix merge regression bugs relating to transaction notifications (#328)
There were two major regression related bugs from merging in the new
database. The first was failure to properly notify transactions in the
stake tree. The second was that the wrong sentinel value was being
used to terminate the rescanning loop, which normally causes
registration for relevant outpoints and addresses. Both bugs are
patched.
2016-08-30 11:32:26 -05:00
C Jepson
27a7bb1c86 Don't fail if no blockchain folder exists (#326)
Startup would fail if there was no preexisting folder for the
selected blockchain.
2016-08-29 13:40:30 -05:00
C Jepson
f82e56d252 Fix a mining bug that occurs during reorgs (#325)
When a main chain block has been reorganized out, the current
template for mining should be dropped because the parent no
longer exists in the main chain. Fixes #324.
2016-08-29 13:33:25 -05:00
David Hill
99b7aadb85 Fix upgrade path (#322) 2016-08-25 13:22:27 -05:00
David Hill
717040c945 Replace fastsha256 with crypto/sha256 (#319) 2016-08-24 11:18:48 -05:00
Jonathan Chappelow
1c9d038acd Add address argument to consolidate. (#317) 2016-08-24 10:10:02 -05:00
Alex Yocom-Piatt
73df0b6aaa Update glide.lock and remove version for dcrrpcclient (#321) 2016-08-24 10:06:27 -05:00
Dave Collins
3740feb673 database: Replace with new version.
This commit removes the old database package, moves the new package into
its place, and updates all imports accordingly.
2016-08-23 17:40:38 -04:00
Dave Collins
8e71bcf41a indexers: Implement optional tx/address indexes.
This introduces a new indexing infrastructure for supporting optional
indexes using the new database and blockchain infrastructure along with
two concrete indexer implementations which provide both a
transaction-by-hash and a transaction-by-address index.

The new infrastructure is mostly separated into a package named indexers
which is housed under the blockchain package.  In order to support this,
a new interface named IndexManager has been introduced in the blockchain
package which provides methods to be notified when the chain has been
initialized and when blocks are connected and disconnected from the main
chain.  A concrete implementation of an index manager is provided by the
new indexers package.

The new indexers package also provides a new interface named Indexer
which allows the index manager to manage concrete index implementations
which conform to the interface.

The following is high level overview of the main index infrastructure
changes:

- Define a new IndexManager interface in the blockchain package and
  modify the package to make use of the interface when specified
- Create a new indexers package
  - Provides an Index interface which allows concrete indexes to plugin
    to an index manager
  - Provides a concrete IndexManager implementation
    - Handles the lifecycle of all indexes it manages
    - Tracks the index tips
    - Handles catching up disabled indexes that have been reenabled
    - Handles reorgs while the index was disabled
    - Invokes the appropriate methods for all managed indexes to allow
      them to index and deindex the blocks and transactions
  - Implement a transaction-by-hash index
    - Makes use of internal block IDs to save a significant amount of
      space and indexing costs over the old transaction index format
  - Implement a transaction-by-address index
    - Makes use of a leveling scheme in order to provide a good tradeoff
      between space required and indexing costs
- Supports enabling and disabling indexes at will
- Support the ability to drop indexes if they are no longer desired

The following is an overview of the btcd changes:

- Add a new index logging subsystem
- Add new options --txindex and --addrindex in order to enable the
  optional indexes
  - NOTE: The transaction index will automatically be enabled when the
    address index is enabled because it depends on it
- Add new options --droptxindex and --dropaddrindex to allow the indexes
  to be removed
  - NOTE: The address index will also be removed when the transaction
    index is dropped because it depends on it
- Update getrawtransactions RPC to make use of the transaction index
- Reimplement the searchrawtransaction RPC that makes use of the address
  index
- Update sample-btcd.conf to include sample usage for the new optional
  index flags
2016-08-18 15:42:18 -04:00
Dave Collins
b6d426241d blockchain: Rework to use new db interface.
This commit is the first stage of several that are planned to convert
the blockchain package into a concurrent safe package that will
ultimately allow support for multi-peer download and concurrent chain
processing.  The goal is to update btcd proper after each step so it can
take advantage of the enhancements as they are developed.

In addition to the aforementioned benefit, this staged approach has been
chosen since it is absolutely critical to maintain consensus.
Separating the changes into several stages makes it easier for reviewers
to logically follow what is happening and therefore helps prevent
consensus bugs.  Naturally there are significant automated tests to help
prevent consensus issues as well.

The main focus of this stage is to convert the blockchain package to use
the new database interface and implement the chain-related functionality
which it no longer handles.  It also aims to improve efficiency in
various areas by making use of the new database and chain capabilities.

The following is an overview of the chain changes:

- Update to use the new database interface
- Add chain-related functionality that the old database used to handle
  - Main chain structure and state
  - Transaction spend tracking
- Implement a new pruned unspent transaction output (utxo) set
  - Provides efficient direct access to the unspent transaction outputs
  - Uses a domain specific compression algorithm that understands the
    standard transaction scripts in order to significantly compress them
  - Removes reliance on the transaction index and paves the way toward
    eventually enabling block pruning
- Modify the New function to accept a Config struct instead of
  inidividual parameters
- Replace the old TxStore type with a new UtxoViewpoint type that makes
  use of the new pruned utxo set
- Convert code to treat the new UtxoViewpoint as a rolling view that is
  used between connects and disconnects to improve efficiency
- Make best chain state always set when the chain instance is created
  - Remove now unnecessary logic for dealing with unset best state
- Make all exported functions concurrent safe
  - Currently using a single chain state lock as it provides a straight
    forward and easy to review path forward however this can be improved
    with more fine grained locking
- Optimize various cases where full blocks were being loaded when only
  the header is needed to help reduce the I/O load
- Add the ability for callers to get a snapshot of the current best
  chain stats in a concurrent safe fashion
  - Does not block callers while new blocks are being processed
- Make error messages that reference transaction outputs consistently
  use <transaction hash>:<output index>
- Introduce a new AssertError type an convert internal consistency
  checks to use it
- Update tests and examples to reflect the changes
- Add a full suite of tests to ensure correct functionality of the new
  code

The following is an overview of the btcd changes:

- Update to use the new database and chain interfaces
- Temporarily remove all code related to the transaction index
- Temporarily remove all code related to the address index
- Convert all code that uses transaction stores to use the new utxo
  view
- Rework several calls that required the block manager for safe
  concurrency to use the chain package directly now that it is
  concurrent safe
- Change all calls to obtain the best hash to use the new best state
  snapshot capability from the chain package
- Remove workaround for limits on fetching height ranges since the new
  database interface no longer imposes them
- Correct the gettxout RPC handler to return the best chain hash as
  opposed the hash the txout was found in
- Optimize various RPC handlers:
  - Change several of the RPC handlers to use the new chain snapshot
    capability to avoid needlessly loading data
  - Update several handlers to use new functionality to avoid accessing
    the block manager so they are able to return the data without
    blocking when the server is busy processing blocks
  - Update non-verbose getblock to avoid deserialization and
    serialization overhead
  - Update getblockheader to request the block height directly from
    chain and only load the header
  - Update getdifficulty to use the new cached data from chain
  - Update getmininginfo to use the new cached data from chain
  - Update non-verbose getrawtransaction to avoid deserialization and
    serialization overhead
  - Update gettxout to use the new utxo store versus loading
    full transactions using the transaction index

The following is an overview of the utility changes:
- Update addblock to use the new database and chain interfaces
- Update findcheckpoint to use the new database and chain interfaces
- Remove the dropafter utility which is no longer supported

NOTE: The transaction index and address index will be reimplemented in
another commit.
2016-08-18 15:42:18 -04:00
David Hill
0a9a0f1969 travis: Add go 1.7 and drop go 1.5 support. (#318) 2016-08-17 17:01:03 -04:00
David Hill
3c9995dd4a dcrd: Do not send a wakeup if not sleeping (#314)
A simple printf shows dozens of AfterFuncs being generated, especially
on testnet where the connectable node count is currently low.  By
resetting the timer, it prevents needless wakeups from filling the
channel.
2016-08-15 12:49:13 -05:00
Josh Rickmar
145065c87f Create appdata directory before writing config. 2016-08-11 12:55:46 -04:00
John C. Vernaleo
864b4d34b9 Bump for v0.3.0 2016-08-10 15:11:49 -04:00
Javed Khan
7401db6098 rpcserver: searchrawtx - update coinbase output (#299) 2016-08-10 11:53:00 -05:00
jolan
5f80cf9279 add another mainnet checkpoint, add initial testnet checkpoints (#307) 2016-08-09 14:23:35 -05:00
David Hill
696dcddb23 Return from syncMiningStateAfterSync if peer disconnected. (#310)
Before this fix, if a peer disconnected before the chain was marked
current, its goroutine and memory would hang around until the chain
was marked current.  This would cause out-of-memory errors.

This should also speed up blockchain processing since there are
no longer many goroutines calling IsCurrent every 3 seconds.
2016-08-09 13:59:46 -05:00
C Jepson
61dfe146a9 Fix the coin supply calculation (#309)
* Fix the coin supply calculation

The coin supply calculation was inaccurate. It has been fixed to
exactly calculate the coin supply based on the history of the
blockchain.

* Final block exception

* <=
2016-08-09 13:40:29 -05:00
David Hill
35a103d454 blockmanager: current() for testnet should check blockchain timesource. (#302) 2016-08-09 12:10:13 -05:00
John C. Vernaleo
bcca98d50a Remove --addrindex option.
addrindex does not currently work so do not allow it as an option.
The code for it is still currently there, but no longer hooked in
to something users can set.

Closes #282
2016-08-08 15:13:05 -04:00
David Hill
9069906139 dcrctl: fix reading from stdin in terminal mode (#294)
Fixes #77
2016-08-03 16:19:54 -04:00
Javed Khan
7feb573059 rpcserver: Account for block votes in coin supply (#296) 2016-08-02 14:54:31 -05:00
Alex Yocom-Piatt
83110a26ab Major update to home README (#278) 2016-07-27 13:38:58 -05:00
John C. Vernaleo
7716a500fd Bump version to v0.2.0 2016-07-22 11:22:12 -04:00
C Jepson
525770d48a Attempt to fix the broken paths in config autogen (#290)
The configuration autogenerator currently does not work well
and tries to read the sample file based on where the compiled
source's data directory was. This has been fixed so that dcrd
only checks the %PROGRAMFILES% directory on Windows where the
sample configuration file might be stored. Configuration
autogeneration has been disabled for toehr operating systems.
2016-07-20 13:17:20 -05:00
Alex Yocom-Piatt
b88cf9e80c Remove help fallthrough so help will get passed to RPC (#275)
Fixes #42
2016-07-20 11:47:01 -05:00
Marco Peereboom
4ea1c0f16b glide man 2016-07-15 15:46:43 -05:00
Dave Collins
67a1137109 Add automatic RPC configuration. (#287)
This commit is being cherry-picked from upstream btcd and has been
modified to integrate with dcrd by Dave Collins.
2016-07-15 14:09:42 -04:00
Alex Yocom-Piatt
9146525767 [dcrctl] Clear terminal history (#276)
Fixes #166 and Fixes #104
2016-07-08 11:09:53 -05:00
Alex Yocom-Piatt
3285b88ce3 docs: Add/update doc.go in a few spots (#277) 2016-07-08 11:09:32 -05:00
Alex Yocom-Piatt
3d6d9f1da0 Add BlockHeight field to getstakeinfo (#274) 2016-06-28 10:14:48 -05:00
David Hill
fee17a1a76 Quit when the specified configuration is file not found. (#273)
Also, error on an invalid rpc certificate.
2016-06-27 14:00:48 -05:00
Marco Peereboom
e6beeb689b add simnet to config file (#272) 2016-06-15 17:25:21 -04:00
John C. Vernaleo
927932170b Bump for v0.1.6 2016-06-13 16:23:39 -04:00
Marco Peereboom
fa72e214db Don't create .dcrd willy-nilly.
This interferes with the installer when it tries to detect if the
required .dirs already exist or not.

Debated with jrick and ay-p.
2016-06-09 11:25:33 -05:00
Alex Yocom-Piatt
2bbfd5f250 fix memory allignment for 32-bit architectures (#668) (#269)
having 3 int32s above the uint64s in the struct
will cause misalignment for some 32-bit architectures.
see https://golang.org/pkg/sync/atomic/#pkg-note-BUG
This aligns bytesReceived and bytesSent.
2016-06-08 08:07:22 -05:00
Dave Collins
92635a475e stake: New package for fast access to live tickets. (#266)
Ticket voting selection and validation require fast access to a
lexicographically sorted list of all available tickets.  The current
implementation stores these tickets in bucketized maps which are
unordered.  This means the data has to be sorted every time it is needed
in order to select a ticket and validate a block.  On my hardware, the
process of removing tickets that have been voted and adding new tickets
takes ~27ms with the current implementation.

In order to speed this up, this introduces a new internal package named
tickettreap that provides a tailored treap data structure that is
intended to be used for the in-memory live ticket pool when the new
database and blockchain enhancements have been synced from upstream.
Since it maintains the data in sorted order, it provides a significant
speedup over the current map-based implementation.  On my hardware, this
implementation is able to remove the tickets that have voted and add the
new tickets in ~0.083ms and iterate the entire structure for selecting the
tickets in ~1.88ms for a total of ~1.96ms.  That equates to roughly 14x
faster access.

In addition, it would also be possible for the stake code to keep a map
for height-based lookups (while still relying on this new data structure
for keeping the lexicographic sort ordering requirements) for an even
greater speedup since it would eliminate the need to iterate the
structure to remove tickets at a given height.

Finally, when evaluating forks, the current code is quite inefficient
because it needs to make a copy of all of the live ticket maps.  This
new structure provides O(1) snapshot/copy capabilities so it is much
more efficient in that regard as well.

Benchmarks:

ImmutableCopy     30000000      40.7 ns/op   0 B/op   0 allocs/op
ImmutableIterate  1000       1881738 ns/op   0 B/op   0 allocs/op
2016-06-06 14:33:17 -05:00
John C. Vernaleo
b869593789 Bump for v0.1.5 2016-06-06 14:34:47 -04:00
C Jepson
eda86f5267 Asynchronously call TicketPoolValue to stop block manager blocking (#265) 2016-06-03 15:13:47 -05:00
C Jepson
63fc4e7991 Add rescan and scanfrom options to importprivkey and importscript (#267) 2016-06-03 15:05:09 -05:00
Alex Yocom-Piatt
164f67787b Change Vin field AmountIn to display coins not int64 (#238)
Fixes #184
2016-06-01 16:04:10 -05:00
Jonathan Chappelow
33bcf33872 Fix median of slice of Amounts for ticketfeeinfo. (#239)
* Fix median of slice of Amounts for ticketfeeinfo.

The median function was not operating on a sorted array, so the
result was a random transaction. The modified function sorts
the slice, so a copy may be needed.
2016-06-01 16:00:57 -05:00
cjepson
e47d83cac3 Log block processing time in CHAN with debug on 2016-06-01 16:16:58 -04:00
Dave Collins
157d1cd20b mempool: Create and use mempoolPolicy.
Upstream commit 123ff368f4.

NOTE: This does not separate the new Decred-specific mempool
policy-related variables into the new policy structure.  That needs to
be done as a separate pull request.
2016-06-01 14:58:23 -05:00