Commit Graph

2682 Commits

Author SHA1 Message Date
Alex Yocom-Piatt
4ce2279c4a Update to v0.6.1 2016-11-26 02:19:28 +00:00
Dave Collins
34e66ebf34 multi: Restore correct upstream majority version code.
This reverts to the correct upstream majority version code which
properly detects when certain thresholds of the network have been
updated in order to determine when to start rejecting old version
blocks and enforcing the rules in the new version block.
2016-11-26 02:15:59 +00:00
Josh Rickmar
d7c2adadc6 Notify only relevant stake txs, not all. (#447)
I misunderstood an old dcrd comment and thought that all stake
transactions were notified irrespective of whether they were actually
relevant to the wallet or not.  Fix this by only including those that
pass the tx filter for block connected notifications.  Rescanned
blocks already handled this correctly by only including the relevant
stake txs.
2016-11-09 13:24:04 -05:00
jolan
d3824c0cbe add more checkpoints (#446) 2016-11-09 11:36:01 -06:00
Josh Rickmar
18049cb68e Update dcrrpcclient for dcrctl. (#445) 2016-11-08 16:25:40 -05:00
Josh Rickmar
ed7c45a3e1 Use same notification for mined transactions and blocks. (#434)
Change the block connected and disconnected notifications to include
the entire block header.

Do not notify the previous block's regular tree transactions if the
newly attached block voted to approve them.  Instead, notify the
regular transactions from the newly attached block.  It is up to the
client to check the vote bits in the header to decide how to handle
the previous block's regular transactions.

Every websocket client now has an associated transaction filter that
is used to determine whether or not a processed transaction is (or
might be) relevant to the client.  A new RPC, loadtxfilter, has been
added to load, reload, or add to this filter.

Redo the entire rescan RPC to scan over previously-processed blocks
using the same transaction filter (rather than specifying which
addresses and outpoints to watch for in the rescan request).

Fixes #433.
2016-11-08 16:18:32 -05:00
Marco Peereboom
2d242b224e Add StakeVersion bits to various subsystems. (#441)
Bump block version and add stake version to wire.  Currently
StakeVersions are unused and once the enforcement logic goes in the
versions will bump again.

This fixes #435
2016-11-07 13:06:17 -06:00
Alex Yocom-Piatt
409005c9f8 Update 3rd part deps in glide (#439) 2016-11-04 10:12:59 -05:00
John C. Vernaleo
3000ee0e6b Bump for v0.6.0 2016-11-04 07:42:06 -04:00
Jonathan Chappelow
e7dcfbc982 Output of --help/-h should go to os.Stdout rather than os.Stderr (#386)
Fixes #105
2016-11-03 12:42:04 -05:00
David Hill
2bae2c02de dcrctl: Set width to max in --terminal (#436)
Fixes #424
2016-11-03 10:17:57 -05:00
John C. Vernaleo
13c3301cb4 fullblocktests: Add additional tests
* Test sub-second time precision
* Test difficulty less than zero
* Test difficulty above maximum
2016-11-02 00:39:32 -05:00
pedro martelletto
3e036a2a82 fullblocktests: Add several negative tests.
* Fraudulent transaction due to invalid index
* Transaction with no inputs
* Transaction with no outputs
* Transaction output with negative vlaue
* Transaction output with too large value
* Block with multiple transactions that sum to too large value
* Stakebase script too small and too large
* Input transactions with null outpoints
* Blocks with duplicate tx inputs
2016-11-02 00:36:36 -05:00
Alex Yocom-Piatt
f13d36dd1a fullblocktests: Add malformed coinbase tests
* Test no proof-of-work subsidy output in the coinbase
* Test invalid script type in the coinbase block commitment output
* Test too few bytes for the coinbase height commitment
* Test invalid block height in the coinbase commitment
2016-11-02 00:17:52 -05:00
Javed Khan
0d34382958 fullblocktests: Add block validation tests
* Test block with sbits underflow
* Test stake transaction pos limit
* Test stakebase script len checks
* Test stakebase unknown signature script
* Test stake transaction in regular tx tree
2016-11-02 00:17:51 -05:00
David Hill
e4c6cf1998 fullblocktests: Add additional tests
* Orphan with null prev hash
* Valid orphan due to undelivered block
* Duplicate regular block
* Duplicate orphan block
2016-11-02 00:17:51 -05:00
John C. Vernaleo
7c52a6317a fullblocktests: Add some voting tests.
* Vote with null ticket reference
* Regular tx in the stake tree
* Too many votes
* Too few votes
* Specified number of votes in header does not match included votes
2016-11-02 00:07:32 -05:00
Josh Rickmar
0a7a9530e6 fullblocktests: Add additional validation tests.
* Test early vote bits rule
* Invalid dev-org output script
* Invalid dev-org output script version
2016-11-02 00:07:32 -05:00
Dave Collins
0a38390437 blockchain: Add block validation infrastructure.
This adds a full-blown testing infrastructure in order to test consensus
validation rules.  It is built around the idea of dynamically generating
full blocks that link together to form a block chain.  In order to
properly test the rules, each test instance starts with a valid block
that is then modified to be invalid in the specific way needed to test a
specific rule.

Since the intent of this framework is to be able to detect any
regressions and/or otherwise inadvertent changes to the consensus rules,
it intentionally does not rely on any logic from the blockchain package
and instead has local implementations of everything necessary to build
valid blocks including things such as the initial premine block,
proof-of-work and proof-of-stake difficulty calculations, purchasing
stake tickets, and calculating lottery winners and casting the
appropriate votes.

In addition, blocks which exercise following rules have been added as an
initial starting point.  These are not exhaustive by any means, but they
serve to show how the framework is used and pave the way for more
exhaustive tests to be added over time.

* Invalid premine block
* Valid premine block
* Enough valid blocks to reach ticket maturity
* Enough valid blocks to reach stake enabled height
* Enough valid blocks to reach stake validation height
* Enough valid block to have a stable base of mature coinbases to spend
  for futher tests
* Basic forking and chain reorganization
* Double spend in regular transaction tree
* Too much proof-of-work coinbase (extending main chain, in block that
  forces a reorg, and in a valid fork)
* Too much dev-org coinbase (same scenarios as pow coinbase above)
* Max and too many signature operations via various combinations of
  OP_CHECKSIG, OP_MULTISIG, OP_CHECKSIGVERIFY, and OP_MULTISIGVERIFY
* Too many signature operations with offending sigop after invalid data
  push
* Attempt to spend tx created on a different forks
* Attempt to spend immature coinbase (on main chain and fork)
* Max size block and block that exceeds the max size
* Children of rejected blocks are either orphans or rejected
* Coinbase script too small and too large
* Max length coinbase script
* Attempt to spend tx in blocks that failed to connect
* Valid non-coinbase tx in place of coinbase
* Block with no transactions
* Invalid proof-of-work
* Block with a timestamp too far in the future
* Invalid regular tree merkle root
* Invalid proof-of-work limit (Bits header field)
* Two coinbase transactions
* Duplicate txns in the regular tree
* Timestamp exactly at and one second after the median time
* Spend from transaction index that is out of range
* Transaction that spends more that its inputs provide
* Non-final coinbase
* Spend from transaction earlier in same block
* Spend from transaction later in same block
* Double spend transaction from earlier in same block
* Coinbase that pays more than subsidy + fees
* Coinbase that includes subsidy + fees
* Spend from transaction that does not exist
2016-11-02 00:07:32 -05:00
Jonathan Chappelow
15be7b5ddc Add EncodeConcatenatedHashes with test. (#432) 2016-11-01 18:04:54 -04:00
Alex Yocom-Piatt
b086c13d6b Add existsexpiredtickets to rpcserver (#418) 2016-10-24 10:31:48 -05:00
Josh Rickmar
70c5a4957a Add getheaders JSON-RPC extension command. (#426)
This RPC is essentially a reimplementation of the wire protocol
getheaders and headers messages and is planned on being used by the
wallet to fetch block headers during startup sync.
2016-10-18 16:57:38 -04:00
Josh Rickmar
dfb2810fb4 Add func to decode string hashes to a passed destination. (#425)
Copy hash_test.go from btcd.  This file contains tests for encoding
and decoding of hashes to and from strings, and does not rely on the
hash algorithm.
2016-10-17 12:25:19 -04:00
cjepson
cc25399f6a Add new setticketsvotebits command
The dcrwallet command to set multiple tickets vote bits fields at
the same time has been added.  Functions to encode/decode relevant
hex strings (as passed over JSON) were also added, along with tests.
2016-10-14 13:06:30 -04:00
C Jepson
f26d1e4b34 Add voting version parsing function (#420)
A voting version parsing function was added.  Vote versions are
uint32s.
2016-10-13 11:56:29 -05:00
Josh Rickmar
024017c543 Add dcrjson decode func for concatenated hex hashes. (#421) 2016-10-13 09:35:35 -05:00
cjepson
c796d13e70 Add a block pruner that only prunes occassionally
The blockchain pruning functions would run at every newly inserted
block node, causing performance degradation. Now the blockchain will
only prune nodes to return the memory to the garbage collector at
prespecified (5 minute) intervals, resulting in much less overhead
when syncing the blockchain.
2016-10-12 14:07:27 -04:00
Josh Rickmar
d58299b059 Replace some unnecessary dcrutil.Tx usage with wire.MsgTx. (#419) 2016-10-12 13:57:47 -04:00
cjepson
0b2c81b0b8 Use correct function to fetch blocks from the blockchain for RPC
Sidechain and orphan blocks were given in previous version of the
software in response to the RPC command getblock, in line with
bitcoind.  Insight relied on this functionality.  It has been
restored in 0.5.0.  Fixes #406.
2016-10-11 10:57:32 -04:00
David Hill
d4860d75f0 dcrctl: fix output in --terminal mode (#416) 2016-10-11 10:54:59 -04:00
C Jepson
cd57e44f20 Prevent high memory usage when turning txindex on first time (#412)
If the transaction index was run and never synced before, the first
time run will cause an OOM failure on machines with low RAM. This was
due to the GC never collecting blocks and freeing them after they were
used, because there were references to the block pointers or internal
pointers to the transaction hashes in the database updates. The
pointers to hashes have all been replaced with values to save memory
and allow the GC to free the blocks/transactions as the indexer runs.
2016-10-10 12:28:52 -05:00
David Hill
26eb0c1591 Remove unused files (#408)
The files were moved to the peer pkg
2016-10-10 11:36:14 -05:00
C Jepson
393c48d32e Fix the dumpblockchain function (#405)
The dumpblockchain function used to serialize a map of block
into gob serialized format, which was used for testing but which
was incompatible with the addblock tool.  The function now dumps
a flat file the the same format required by the addblock tool.

A couple shutdown assertions were added as well, to prevent
potential panics if pointers were nil.  The duration of time
it took to sync the blockchain with addblock is now
reported.
2016-10-10 11:35:46 -05:00
Josh Rickmar
e206421edd Optimize coinbase output tax check.
Profiling indicated that significant time was being spent validating
coinbase outputs, ensuring that they paid to the development
organization's P2SH tax address.  This check was more inefficient than
necessary for a couple of reasons:

* The tax address was always decoded from a string to a dcrutil.Address.

* The actual script being validated was always parsed for addresses to
  check if they matched the tax address.

Neither of these are needed.  To optimize the algorithm, only the
equality of the output script and script version are checked.
2016-10-07 16:39:40 -04:00
Alex Yocom-Piatt
27f6efc2c1 Improve the order of the context free tests (#404) 2016-10-06 15:16:48 -05:00
Dave Collins
ccc3b7a133 stake: Correct prng uint32 rollover. (#403)
This corrects the the hash256 deterministic prng generator to properly
rollover and avoid repeating values when it has been invoked more than
2^35 + 8 times.

While here, it also removes the unnecessary 'seedState' struct field in
favor of storing the seed as a chainhash.Hash directly and just updating
it on rollover.

Finally, it also refactors the seed const to a package level constant to
avoid generating a new byte slice (and hence extra garbage) every time a
new generator is created.

It should be noted that this does not affect Decred consensus at all
because it's impossible to invoke the generator more than 2^35 + 8 times
due to other constraints.
2016-10-06 13:20:13 -05:00
Josh Rickmar
8e4b78998e Version the JSON-RPC API with semantic versioning. (#387)
Start at version 1.0.0.
2016-10-05 18:46:06 -04:00
cjepson
5a23b05852 Fix a bug reloading the blockchain
A bug in the restoration of stake nodes from the disk would prevent the
blockchain from reloading if there was an immediate reorganization
required on start up.  This correctly disconnects the block.
2016-10-05 18:10:08 -04:00
Alex Yocom-Piatt
6ab614f158 Update dcr* deps for 0.5.0 release (#401)
Fixes #398
2016-10-05 16:06:40 -05:00
David Hill
4c838e82b5 blockchain: remove unnecessary check. (#400) 2016-10-05 15:16:30 -04:00
C Jepson
8037faca0e Fix a bug for forced reorganizations (#392)
A bug when updating the chain state during forced reorganizations
was fixed. An assertion was added into the mining code so that it
now errors out if the blockchain and chainState of the block
manager are inconsistent.

The blockchain function to fetch the latest block header was
renamed for consistency and now returns a copy of the block header
instead of the pointer itself.
2016-10-05 11:20:42 -05:00
jolan
e917b92332 add more checkpoints for release (#396) 2016-10-05 10:15:39 -05:00
C Jepson
d98fc8319f Replace the ticket database with an efficient, atomic implementation
The legacy ticket database, which was GOB serialized and stored on
shut down, has been removed.  Ticket state information is now held in
a stake node, which acts as a modularized "black box" to contain all
information about the state of the stake system.  Stake nodes are now
a component of the blockchain blockNode struct, and are updated with
them.

Stake nodes, like their internal treap primitives, are immutable
objects that are created with their connect and disconnect node
functions.  The blockchain database now stores all information about
the stake state of the best node in the block database.  The blockchain
makes the assumption that the stake state of the best node is known at
any given time.  If the states of former blocks or sidechains must be
evaluated, this can be achieved by iterating backwards along the
blockchain from the best node, and then connecting stake nodes
iteratively if necessary.

Performance improvements with this new module are dramatic.  The long
delays on start up and shut down are removed.  Blockchain
synchronization time is improved approximately 5-10x on the mainnet
chain.  The state of the database is atomic, so unexpected shut downs
should no longer have the ability to disrupt the chain state.

An upgrade path has been added for version 1 blockchain databases.
Users with this blockchain database will automatically update when
they start their clients.
2016-10-04 13:40:19 -04:00
John C. Vernaleo
af40801d40 Bump for v0.5.0 2016-10-04 12:16:42 -04:00
John C. Vernaleo
6beae08edf Remove unused ErrBIP0030
Closes #356
2016-09-28 15:47:14 -04:00
Marco Peereboom
1c180c1106 Reconcile btcd and dcrd auto generated config file semantics
Fixes #316
2016-09-26 11:59:04 -05:00
cjepson
4cdf6b345b Fix a bug indexing addrindex when blocks are invalidated
The offset to index was incorrect when inserting addrindex keys for
blocks that had been invalidated.  Fixes #347.
2016-09-26 12:44:03 -04:00
cjepson
615c018baf Merge in btcd commit '6229e3583505a82d4514b1efa86f910b78693825'
Merges in btcd commit 6229e35835.
2016-09-23 21:13:30 -04:00
cjepson
3d5b9c81fc Merge in btcd commit '2adfb3b56acd280e84451e94dd0c06203eef9832'
Merges in btcd commit 2adfb3b56a.
2016-09-23 18:02:41 -04:00
cjepson
5e865d6683 Merge in btcd commit '5de5b7354ca458d6e7677d6b4629214d3f871b59'
Merges in btcd commit 5de5b7354c.
2016-09-23 16:24:02 -04:00