Commit graph

2919 commits

Author SHA1 Message Date
Dave Collins
0ea4a6ebd4
multi: Switch to upstream golang.org/x/crypto.
Now that glide is used for version management and a specific commit of
the upstream repository can be locked it is no longer necessary to
maintain a fork of the package specifically to keep a stable dependency.

While here, update the glide dependency for btcutil as well since it was
switched to use the upstream path as well.
2017-05-09 11:35:01 -05:00
esemplastic
2a01456189 Fix docs/README.md
Invalid tokens: github had made some changes the past months, the old style is not rendering at all, so I fixed that for you. 

Other contributors can do the same for all of the project's documents.

Thanks.
2017-05-07 22:04:30 -05:00
Alex
4b348c1d33 rpctest: Add P2PAddress() for Harness to get P2P listen address 2017-03-22 14:54:42 -06:00
Alex Bosworth
efb4ab430c main: Improve comment for headers peer message. 2017-03-22 15:45:28 -05:00
Dave Collins
6788df79f1
TravisCI: Only run tests once.
This modifies the goclean.sh script that is executed on Travis to
only run the tests once.

While it is nice to see coverage reports in the log, unfortunately it
appears that both the -race and -cover flags can't be used together, and
the tests have grown in complexity such that they are starting to get
close to TravisCI time limits.
2017-03-22 15:34:47 -05:00
Dave Collins
efa50e6abc
multi: Simplify code per gosimple linter.
This simplifies the code based on the recommendations of the gosimple
lint tool.

Also, it increases the deadline for the linters to run to 10 minutes and
reduces the number of threads that is uses. This is being done because
the Travis environment has become increasingly slower and it also seems
to be hampered by too many threads running concurrently.
2017-03-22 15:34:13 -05:00
Alex
583684b21b rpcserver: Allow limited user access to getblockheader command. 2017-02-16 11:10:28 -07:00
David Hill
e3e4c726af Add GetMempoolEntry API 2017-02-03 14:27:05 -05:00
Dave Collins
d06c0bb181
blockchain: Use hash values in structs.
This modifies the blockNode and BestState structs in the blockchain
package to store hashes directly instead of pointers to them and updates
callers to deal with the API change in the exported BestState struct.

In general, the preferred approach for hashes moving forward is to store
hash values in complex data structures, particularly those that will be
used for cache entries, and accept pointers to hashes in arguments to
functions.

Some of the reasoning behind making this change is:

- It is generally preferred to avoid storing pointers to data in cache
  objects since doing so can easily lead to storing interior pointers
  into other structs that then can't be GC'd
- Keeping the hash values directly in the block node provides better
  cache locality
2017-02-03 11:36:33 -06:00
Dave Collins
05c7c14023
blockchain: Ignore side chains in exists check.
Since the code base is currently in the process of changing over to
decouple download and connection logic, but not all of the necessary
parts are updated yet, ensure blocks that are in the database, but do
not have an associated main chain block index entry, are treated as if
they do not exist for the purposes of chain connection and selection
logic.
2017-02-03 11:02:35 -06:00
Dave Collins
1ecfea4928
blockchain: Refactor main block index logic.
This refactors the block index logic into a separate struct and
introduces an individual lock for it so it can be queried independent of
the chain lock.
2017-02-01 13:14:41 -06:00
Dave Collins
59169540c3
blockchain: Reconstruct headers from block nodes.
This modifies the block node structure to include a couple of extra
fields needed to be able to reconstruct the block header from a node,
and exposes a new function from chain to fetch the block headers which
takes advantage of the new functionality to reconstruct the headers from
memory when possible.  Finally, it updates both the p2p and RPC servers
to make use of the new function.

This is useful since many of the block header fields need to be kept in
order to form the block index anyways and storing the extra fields means
the database does not have to be consulted when headers are requested if
the associated node is still in memory.

The following timings show representative performance gains as measured
from one system:

new: Time to fetch 100000 headers:   59ms
old: Time to fetch 100000 headers: 4783ms
2017-02-01 12:27:56 -06:00
David Hill
d9241e91a9 btcjson: Add getmempoolentry API 2017-02-01 11:54:51 -06:00
Dave Collins
d552176e1d
blockchain: Remove unused block node removal func.
This removes the removeBlockNode function since it is no longer used
after the addition of CLTV removed block node pruning.
2017-02-01 11:25:29 -06:00
Dave Collins
0d0f50c464
blockchain: Remove unused median time calc func.
This removes the CalcPastMedianTime since it is now exposed much more
efficiently via the MedianTime field of the BestState snapshot returned
from the BestSnapshot function.
2017-02-01 10:50:27 -06:00
Dave Collins
5ffd552214
blockchain: Use int64 timestamps in block nodes.
This modifies the block nodes used in the blockchain package for keeping
track of the block index to use int64 for the timestamps instead of
time.Time.

This is being done because a time.Time takes 24 bytes while an int64
only takes 8 and the plan is to eventually move the entire block index
into memory instead of the current dynamically-loaded version, so
cutting the number of bytes used for the timestamp by a third is highly
desirable.

Also, the consensus code requires working with unix-style timestamps
anyways, so switching over to them in the block node does not seem
unreasonable.

Finally, this does not go so far as to change all of the time.Time
references, particularly those that are in the public API, so it is
purely an internal change.
2017-01-31 17:51:29 -06:00
David Hill
9f71f090e6 txscript: Drop the mutex before doing crypto 2017-01-31 13:47:41 -05:00
Dave Collins
554460feda
rpctest: Update to use new filtered block ntfns.
This modifies the rpctest harness and its associated memwallet to make
use of the new filter-based notifications since the old notifications
are now deprecated.

It also updates the glide.lock file to require the necessary
btcrpcclient version.
2017-01-31 11:04:43 -06:00
Dave Collins
6a54323258
blockchain: Store side chain blocks in database.
This modifies the blockchain code to store all blocks that have passed
proof-of-work and contextual validity tests in the database even if they
may ultimately fail to connect.

This eliminates the need to store those blocks in memory, allows them to
be available as orphans later even if they were never part of the main
chain, and helps pave the way toward being able to separate the download
logic from the connection logic.
2017-01-31 10:25:43 -06:00
David Hill
ecd348b2a7 btcd: disable mempool requests if bloom filtering is disabled 2017-01-27 20:51:25 -06:00
Dave Collins
eef39394b7
Update ws example to use new filtered blocks ntfns.
The old notifications are now deprecated, so the examples shouldn't use
them.
2017-01-27 17:31:10 -06:00
Alex
47b5478cfc rpcserver: implement rescanblocks command backported from dcrd 2017-01-27 15:32:15 -07:00
Alex
03a8bf2eb4 btcjson/docs: add rescanblocks command backported from dcrd 2017-01-27 15:32:15 -07:00
Alex
4943ed11b3 rpcserver: implement loadtxfilter backported from dcrd 2017-01-27 15:32:15 -07:00
Alex
5c689c8b77 btcjson/docs: add loadtxfilter command backported from dcrd 2017-01-27 15:32:15 -07:00
Alex
abcdfb702a Port rescanblocks JSON-RPC command from dcrd 2017-01-27 14:43:43 -07:00
Alex
a835a9ca8b Port loadtxfilter JSON-RPC command from dcrd 2017-01-27 14:39:20 -07:00
David Hill
db5b9aef91 btcd: fix rebroadcasting of local txs. 2017-01-27 10:28:48 -05:00
David Hill
9bedd7720c btcd: only allow one getaddr request per peer 2017-01-25 12:05:55 -05:00
David Hill
e8b9147ba2 btcjson: Add more fields to ListTransactionsResult
These include Abandoned, BIP125Replaceable, and Trusted.
2017-01-23 15:56:45 -05:00
Dave Collins
07f8c84fb1
TravisCI: Use release version of glide.
This modifies the .travis.yml file to install a release version of glide
instead of using its latest master branch.  This will prevent upstream
changes from inadvertently breaking the CI builds.
2017-01-23 13:09:42 -06:00
Dave Collins
c065733c31
multi: Improvements to configurable checkpoints.
This contains a bit of cleanup and additional logic to improve the
recently-added ability to specify additional checkpoints via the
--addcheckpoint option.

In particular:
- Improve error messages in the checkpoint parsing
- Correct the mergeCheckpoints function to weed out duplicate height
  checkpoints while using the most-recently provided one as described by
  its comment
- Add an assertion to blockchain.New that the provided checkpoints are
  sorted as required
- Keep comments to 80 columns and use two spaces after periods in them to
  be consistent with the rest of the code base
- Make the entry in doc.go match the actual btcd -h output
2017-01-23 12:07:54 -06:00
Dave Collins
28d42ba23c
build: Exclude .glide from test coverage.
The most recent version of glide creates a working directory named
.glide that includes .go files and thus must be excluded from the find
operation that generates merged test coverage of all packages.
2017-01-23 11:42:38 -06:00
Steven Roose
c2af640c95 blockchain: Allow adding additional checkpoints
Introduces a `--checkpoint` flag that allows the user to specify
additional checkpoints or override the default ones provided in the
chain params.
2017-01-18 23:56:43 +01:00
Javed Khan
8caa921ac3 server: Fix connections to onion nodes.
A DNS lookup was being attempted on onion addresses causing
connections to fail. This has been fixed by introducing type
onionAddr (which implements a net.Addr interface) and passing
it to btcdDial.

Also, the following onion related fixes have been made:

* getaddednodeinfo - updated to handle onion addrs.
* TorLookupIP - fixed err being shadowed.
* newServer - rename tcpAddr to netAddr
* addrStringToNetAddr - skip if host is already an IP addr.
* addrStringToNetAddr - err if tor is disabled
* getaddednodeinfo - check if host is already an IP addr.
2017-01-18 21:40:41 +05:30
Javed Khan
91b7f5c1c8 config: Refactor tor config options.
* Remove unnecessary onionlookup func.
* Disallow --noonion and --onion flag combination.
* Tor isolation flag - prefer onion proxy.
* Proper argument names in cfg.oniondial closure.
* btcdLookup - error on onion address.
* Bridge mode - use onion for lookup
2017-01-18 13:32:31 +05:30
David Hill
e15ac5024a travis: test against latest releases.
While here, clean up goclean.sh.
2017-01-15 08:38:08 -05:00
David Hill
0efea24aa6 txscript: Implement ScriptVerifyNullFail
ScriptVerifyNullFail defines that signatures must be empty if a
CHECKSIG or CHECKMULTISIG operation fails.

This commit also enables ScriptVerifyNullFail at the mempool policy
level.
2017-01-13 14:19:11 -05:00
Dave Collins
153dca5c1e
txscript: Convert reference tests to new format.
This updates the data driven transaction script tests to use the most
recent format and test data as implemented by Core so the test data can
more easily be updated and help prove cross-compatibility correctness.

In particular, the new format combines the previously separate valid and
invalid test data files into a single file and adds a field for the
expected result.  This is a nice improvement since it means tests can
now ensure script failures are due to a specific expected reason as
opposed to only generically detecting failure as the previous format
required.

The btcd script engine typically returns more fine grained errors than
the test data expects, so the test adapter handles this by allowing
expected errors in the test data to be mapped to multiple txscript
errors.

It should also be noted that the tests related to segwit have been
stripped from the data since the segwit PR has not landed in master yet,
however the test adapter does recognize the new ability for optional
segwit data to be supplied, though it will need to properly construct
the transaction using that data when the time comes.
2017-01-12 13:13:21 -06:00
Dave Collins
fdc2bc867b
txscript: Significantly improve errors.
This converts the majority of script errors from generic errors created
via errors.New and fmt.Errorf to use a concrete type that implements the
error interface with an error code and description.

This allows callers to programmatically detect the type of error via
type assertions and an error code while still allowing the errors to
provide more context.

For example, instead of just having an error the reads "disabled opcode"
as would happen prior to these changes when a disabled opcode is
encountered, the error will now read "attempt to execute disabled opcode
OP_FOO".

While it was previously possible to programmatically detect many errors
due to them being exported, they provided no additional context and
there were also various instances that were just returning errors
created on the spot which callers could not reliably detect without
resorting to looking at the actual error message, which is nearly always
bad practice.

Also, while here, export the MaxStackSize and MaxScriptSize constants
since they can be useful for consumers of the package and perform some
minor cleanup of some of the tests.
2017-01-12 13:12:39 -06:00
David Hill
283706b3dc chaincfg: add testnet checkpoints 2017-01-12 11:30:13 -05:00
David Hill
406ddd17d3 blockchain: TimeSource is required. 2017-01-12 11:19:51 -05:00
David Hill
7c0fd83c87 btcd: use DialTimeout
If a host is down and doesn't send a TCP RST, the net.Dial function
blocks until the OS times out the connection. Convert to using
DialTimeout with a 30 second default timeout.
2017-01-11 16:54:37 -05:00
Alex Bosworth
2dfda48b94 Correct typo 2017-01-11 13:21:14 -08:00
David Hill
4cb933d035 travis: test against latest patch release. 2017-01-11 15:54:27 -05:00
David Hill
ab0f30c00d mining: drop getwork support.
Since the Midstate is no longer needed, switch to using
crypto/sha256.
2017-01-11 13:51:57 -05:00
Alex
5ce0ed6009 Port getheaders JSON-RPC command from dcrd 2017-01-10 19:47:28 -07:00
Alex
7c44b6472f Port getheaders JSON-RPC command from dcrd 2017-01-10 19:11:18 -07:00
Chris Pacia
765ca28711 Add MerkleBlock deadline to CmdGetData 2017-01-10 12:29:43 -06:00
David Hill
4f12c97d0f Drop btcsuite/go-flags in favor of upstream 2017-01-09 14:10:18 -06:00