Commit Graph

3823 Commits

Author SHA1 Message Date
Dave Collins
69f8579231
multi: No winning ticket ntfns for big reorg depth.
This modifies the logic which sends winning ticket notifications to RPC
clients to consider the reorganization depth and refuse to send the
notifications for blocks on side chains that would ultimately result in
a reorg of 6 or more blocks.

Also, the code used to send the notifications was needlessly repeated in
multiple places since any blocks accepted via ProcessBlock also result
in an accepted notification and therefore the RPC notification only
needs to be sent from there.
2018-05-29 11:16:09 -05:00
Dave Collins
b4000c094c
rpcserver: Correct rebroadcastwinners handler.
This corrects the handler for the rebroadcastwinners RPC to return the
hash of the block the tickets are voting on when there are multiple
candidates at the current tip as opposed to all claiming to vote on the
current best block.
2018-05-28 12:47:40 -05:00
Dave Collins
66010e4134
multi: Return fork len from ProcessBlock.
This modifies the ProcessBlock function in the blockchain package to
return the fork length for the connected block and updates all callers
and tests accordingly.  Several of the internal functions which
ProcessBlock calls are also updated in order to bubble the necessary
information back up so it can be returned.  It does not make any
behavioral changes.

This is being done to better expose information about the position of
the block within the chain to callers without them having to make
additional queries.
2018-05-27 20:20:43 -05:00
Donald Adu-Poku
7c87772d90 rpcclient: pass default value for NewPurchaseTicketCmd's comment param. 2018-05-27 18:09:07 +00:00
Shweini
5ec7a2a36c multi: Change NoSplitTransaction param to SplitTx.
The SplitTx parameter for PurchaseTicketCmd specifies theminimumnumberof inputs needed to use a split transaction for aticketpurchase. Theparameter options are 1 and 2. Ticket purchaseinputsless than the setSplitTx value are used directly in thetransaction.
2018-05-27 14:37:29 +00:00
Dave Collins
7a457fc9c3
policy: Lower default relay fee to 0.0001/kB.
This lowers the default minimum relay fee to 0.0001 DCR/Kb from its
previous value of 0.001 DCR/Kb and increases the high fee multiplier to
keep the same default high fee threshold of 1 DCR/kB.

In order to keep the comments accurate, it also updates the comments in
the isDust function and the sample config file to match the new default
relay fee as it's nice to have the most recent values as a reference in
the comments.

Finally, it updates the tests for the expected new values as a result of
the reduced default relay fee and adds add a couple of dust tests just
below and above the dust point for the new reduced default relay fee.

It should be noted that this is only a default node policy change and as
such does not affect the consensus rules in any way.
2018-05-26 09:45:38 -05:00
Dave Collins
c476afa931
txscript: Cleanup code for the substr opcode.
This cleans up the code for handling the substr opcode to explicitly
call out its semantics which are likely not otherwise obvious as well as
improve its readability.
2018-05-25 20:28:57 -05:00
Dave Collins
be318f5a69
chaincfg: Refine vgo deps.
Now that wire has been defined, update the chaincfg module to only
depend on it instead of the entire dcrd module.  The chainhash
dependency is handled transitively via wire.
2018-05-25 18:00:05 -05:00
Dave Collins
d5016f289f
addrmrg: Refine vgo deps.
Now that wire has been defined, update the addrmgr module to only depend
on it instead of the entire dcrd module.  Also, since there is no longer
a dep on the entire dcrd module to pick it up transitively, add the slog
dep as well.
2018-05-25 17:34:07 -05:00
Dave Collins
4ee21d807a
wire: Refine vgo deps.
Now that chainhash has been defined, update the wire module to only
depend on it instead of the entire dcrd module.
2018-05-25 17:06:49 -05:00
Dave Collins
07433d4cd8
chainhash: Define vgo module.
This adds module support for the versioned go toolchain to the chainhash package.

It does not update the travis build environment or README since it is
experimental at this point.
2018-05-25 16:21:37 -05:00
Dave Collins
45e313e6d2
multi: Define vgo modules.
This adds module support for the versioned go toolchain.  In particular,
the following packages are defined as modules:

* addrmgr
* blockchain
* certgen
* chaincfg
* connmgr
* database
* dcrjson
* dcrutil
* gcs
* hdkeychain
* mempool
* mining
* peer
* rpcclient
* txscript
* wire

It does not update the travis build environment or README since it is
experimental at this point.
2018-05-25 15:38:16 -05:00
Dmitry Fedorov
569f703105 dcrjson: add createvotingaccount and dropvotingaccount rpc methods
methods help to import and drop xpub key to generate
addresses on behalf of another wallet
2018-05-24 22:14:45 +03:00
Dave Collins
d8bc8fbae1
build: Update some vgo dependencies to use tags.
Also, while here, constrain slog in Gopkg.toml to 1.0.0 and update the
associated lock file accordingly.
2018-05-24 11:18:33 -05:00
Dave Collins
d7fc102c28
rpc: Use upstream gorilla/websocket.
This change is being made since no local changes exist and dependencies
are pinned unlike when it was originally vendored.
2018-05-23 19:35:36 -05:00
Dave Collins
678ff1efdd
multi: Replace btclog with slog.
This modifies all packages within the repository to the use the Decred
fork of btclog which has been renamed to slog and updates the dependency
files accordingly.
2018-05-23 14:22:10 -05:00
Dave Collins
e3d1201f45
build: Add experimental support for vgo.
This adds support for the versioned go toolchain.  It does not update
the travis build environment or README since it is experimental at this
point.
2018-05-23 10:41:57 -05:00
Donald Adu-Poku
02558ca948 mempool: use secp256k1 functions directly.
This PR replaces chainec function calls within the mempool packagewith the underlining secp256k1 functions. This is in preparation forremoving the chainec package.
2018-05-23 01:35:51 -05:00
Donald Adu-Poku
4513f81e43 blockchain: use secp256k1 functions directly.
This PR replaces chainec function calls within the blockchain package
with the underlining secp256k1 functions. This is in preparation for
removing the chainec package.
2018-05-23 01:34:50 -05:00
Donald Adu-Poku
35868ea0e4 dcrec: add Pubkey func to secp256k1 and edwards elliptic curves.
PubKey() returns the corresponding public key of the referenced private
key. This is preferred to Public() which returns the X and Y values
of the public key instead. Public() is scheduled to be removed after
the imposed chainec interface restrictions are removed.
2018-05-18 13:45:02 +00:00
Donald Adu-Poku
2e293f28bf multi: use secp256k1 types and fields directly.
The chainec package is scheduled to be removed. This PR replaces
chainec function calls within the hdkeychain package with the
underlining secp256k1 types and fields which breaks its dependence
on a package soon to be removed. memwallet, a member of rpctest which
calls hdkeychain functions is also updated.
2018-05-17 00:46:57 +00:00
Dave Collins
d04706089c
docs: Update node.js example for v8.11.1 LTS.
This modifies the example for connecting to the dcrd RPC server from
node.js to work with node.js v8.11.1 LTS and v10.0.1 along with calling
out the tested version and requirement for the additional ecdhCurve
parameter on v8.11.1 LTS.
2018-05-15 11:52:14 -05:00
Dave Collins
3a81a21ec9
txscript: Improve substr opcode test coverage.
This adds several tests to the reference script tests which exercise the
semantics of the substr opcode including both positive and negative
tests.
2018-05-15 03:38:18 -05:00
Dave Collins
f54fb6ce67
txscript: Remove unused strict multisig flag.
This removes the ScriptStrictMultiSig flag from the txscript package
since it is not used or needed by Decred.

The flag is a holdover from the upstream code which was used to address
a bug that does not exist in Decred.
2018-05-15 02:34:22 -05:00
David Hill
6adfdf6bdc dcrjson: add estimatesmartfee 2018-05-11 15:16:44 -04:00
Dave Collins
cc6993e61f
mempool: Use blockchain for tx expiry check.
This modifies the pruning code to make use of the newly available
function in blockchain to test if a transaction is expired.

While here, it makes the comments on the functions more consistent with
others and moves the unexported definition before the exported function
from which it is used.
2018-05-11 01:12:35 -05:00
Dave Collins
6b6d43fec1
blockchain: Validate tx expiry in block context.
The CheckTransactionInputs, as it name suggested, is only intended to
perform validation that requires the inputs to transactions.

Consequently, this moves the check for validating the transactions in
the block are not expired into the checkBlockContext function where it
more naturally belongs since it is only dependent on the block and its
contextual position within the chain.

Since this check is also needed by the mempool, it refactors the check
into separate functions named IsExpired and IsExpiredTx, which work with
both util transactions and raw wire transactions, respectively, and
updates mempool to perform the necessary check by making use of them.
2018-05-09 18:54:57 -05:00
Dave Collins
6a58366a02
Sync upstream through 60355258. 2018-05-09 18:52:08 -05:00
Donald Adu-Poku
8f22cfed65 fullblocktests: add additional premine and malformed tests. 2018-05-09 16:40:24 -05:00
Dave Collins
66f5acc9aa
multi: Correct typos found by misspell. 2018-05-08 21:29:33 -05:00
Donald Adu-Poku
63f2913e08 blockchain: utilize CalcNextReqStakeDifficulty in fullblocktests.
previously fullblocktests entries required in-depth knowledge of the
stake tree in order to retrieve the prevailing ticket price.
`ticketPrice := b.STransactions[5].TxOut[0].Value`
2018-05-08 15:28:28 -05:00
Dave Collins
75432b3c96
multi: Break coinbase dep on standardness rules.
Standardness rules are not the same as consensus rules and it is
important to keep clear separation between them, because standardness
rules can and do change, while the consensus rules must not change
without a specific vote, and even then, the old rules must be kept
around for validation of all blocks prior to any changes introduced by a
successful vote.

Prior to this commit, the blockchain code which enforces the consensus
rule that requires the second output of the coinbase transaction to
contain the height of the block in a provably pruneable nulldata script
push was relying on code in txscript/standard.go, which, as the name of
the file suggests, is specifically intended for code related to
standardness checks.

This introduces a new function in the txscript package named
ExtractCoinbaseNullData which does not rely on any of the code related
to standardness checks and modifies the blockchain code accordingly to
make use of the new function instead.  It also removes the
standardness-dependent GetNullDataContent function which is no longer
used by anything.

Finally, it adds tests in the txscript package to ensure the new
function has the required semantics.
2018-05-08 12:49:40 -05:00
Donald Adu-Poku
0ca75aba1a blockchain: rename ErrRegTxSpendStakeOut to ErrRegTxCreateStakeOut. 2018-05-07 18:19:32 -05:00
vctt94
14d0c207f6 dcrctl: Fix --skipverify failing if rpc.cert not found. 2018-05-07 15:57:47 -05:00
Donald Adu-Poku
afcf031471 mempool: Refactor pool membership test logic.
This introduces a new pool membership test function to the mempool
testing infrastructure and refactors the tests to make use of it.

It is useful since it is common logic that is not only needed in the
existing tests, but will be needed by most mempool-related tests.
2018-05-04 20:59:05 +00:00
Dave Collins
0921280e6e
multi: Correct clean and expand path handling.
This corrects an issue introduced by commit
c6f9474348 which resulted in empty paths
that were cleaned and expanded being transformed into "." instead of
having no effect as intended.
2018-05-03 16:21:35 -05:00
Dave Collins
d14d9a1174
fullblocktests: Add expired stake tx test.
This adds a test to ensure blocks with an expired transaction in the
stake tree is rejected as expected.

While here, it also updates the existing test for an expired transaction
in the regular tree to be the exact block height which is including it
to help detect any off by one errors.
2018-05-03 14:09:55 -05:00
Dave Collins
6327ed7fab
blockchain: CheckConnectBlockTemplate with tests.
This removes the CheckConnectBlock function in favor of a new function
named CheckConnectBlockTemplate which more accurately reflects its
purpose of testing block template proposals and uses this fact to be
more restrictive about the allowed inputs and to avoid performing the
proof of work check.

In particular, the provided block template must only build from the
current tip or its parent or an error is returned.

All mining code has been updated to call the new function accordingly.

Finally, it also adds a full suite of tests for the new function using
the chaingen framework in order to ensure proper functionality.
2018-05-03 13:53:24 -05:00
Alex Yocom-Piatt
0483c4a069 Fix typo in blockchain typo 2018-05-03 14:37:37 -04:00
vctt94
b789995319 dcrjson: Add Expiry field to CreateRawTransactionCmd 2018-05-02 20:49:03 -05:00
Markus Richter
dfee810f04 addrmgr: Test timestamp update during AddAddress()
Test for codepath that adds the same address twice and is supposed to
update the timestamp.
2018-05-02 20:47:26 -05:00
Markus Richter
5c2768047d addrmgr: Simplify package API.
Hide functions which are only used internally.
2018-05-02 20:35:40 -05:00
hypernoob
b62606dae8
main: Correct mem profile error message. 2018-05-03 08:17:12 +08:00
Dave Collins
1cd987cb44 Sync upstream through 6b8a249. 2018-05-02 17:14:43 -05:00
Donald Adu-Poku
9e65263b9e blockchain: move block validation rule tests into fullblocktests (3/3). 2018-05-02 19:39:04 +00:00
Markus Richter
73b4bd21b0 addrmgr: Skip low quality addresses for getaddr.
The AddressCache() should not propagate addresses of known low quality
to its peers.

Inspired by the Bitcoin Core implementation.
2018-05-01 12:49:25 -05:00
Markus Richter
8d12e29df5 addrmgr: Simplify tests for KnownAddress.
- Remove internal_test.go bridge and test internally instead.
- Used cached result of time.Now() everywhere.
2018-05-01 12:42:07 -05:00
David Hill
5a4f367b66 multi: Remove everything to do about bloom filters. 2018-05-01 11:43:32 -05:00
Dave Collins
b3ce2ad2ad
wire: Remove TxSerializeWitnessSigning.
This removes the TxSerializeWitnessSigning serialization type since
it is no longer required due to implementing it directly in the
signature hash calculation function.  It also removes all related tests.

Although this is technically a change to the wire protocol, the protocol
version is not being bumped because nothing ever sends messages using
this serialization type as it only applied for calculating signature
hashes and really should not have ever been in the wire package to begin
with.
2018-05-01 08:52:18 -05:00
Dave Collins
5717411882
txscript: Decouple and optimize sighash calc.
This modifies the signature hash calculation logic to completely
decouple it from the wire transaction serialization and significantly
optimizes it in the process.  It also significantly improves the
comments to specifically call out the semantics.

This change is highly desirable because it has several beneficial
properties:

- The signature hash semantics are much clearer and specific
- There is no longer a need to copy the entire transaction and modify
  the relevant portions since the necessary substitutions are made on
  the fly
- Allows much faster calculation by serializing directly into byte
  slices and avoiding all of the additional error handling logic
  dedicated to handling network streams
- Provides the possibility of changing the wire format without breaking
  signature hash calculation
  - Note that the caching portion still relies on the wire format, but
    that can be addressed in future commits since it is merely an
    optimization that can also be decoupled

The following is a before and after comparison of signature hash
calculation for both speed and memory allocations for a transaction with
many inputs:

benchmark                old ns/op     new ns/op     delta
------------------------------------------------------------
BenchmarkCalcSigHash     6299714       1551740       -75.37%

benchmark                old allocs    new allocs    delta
------------------------------------------------------------
BenchmarkCalcSigHash     18601         1691          -90.91%
2018-05-01 08:51:41 -05:00